@hubspot/local-dev-lib 4.0.4 → 5.0.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 (205) hide show
  1. package/api/appsDev.d.ts +2 -2
  2. package/api/appsDev.js +13 -22
  3. package/api/crm.d.ts +2 -2
  4. package/api/crm.js +9 -16
  5. package/api/customObjects.d.ts +2 -2
  6. package/api/customObjects.js +13 -22
  7. package/api/designManager.d.ts +2 -2
  8. package/api/designManager.js +5 -10
  9. package/api/devSecrets.d.ts +2 -2
  10. package/api/devSecrets.js +9 -16
  11. package/api/developerTestAccounts.d.ts +2 -4
  12. package/api/developerTestAccounts.js +23 -52
  13. package/api/fileManager.d.ts +2 -2
  14. package/api/fileManager.js +14 -24
  15. package/api/fileMapper.d.ts +2 -3
  16. package/api/fileMapper.js +34 -49
  17. package/api/fileTransport.d.ts +1 -1
  18. package/api/fileTransport.js +12 -21
  19. package/api/fireAlarm.d.ts +2 -3
  20. package/api/fireAlarm.js +5 -9
  21. package/api/functions.d.ts +2 -2
  22. package/api/functions.js +11 -19
  23. package/api/github.d.ts +2 -4
  24. package/api/github.js +16 -27
  25. package/api/hubdb.d.ts +2 -2
  26. package/api/hubdb.js +19 -31
  27. package/api/lighthouseScore.d.ts +2 -2
  28. package/api/lighthouseScore.js +7 -13
  29. package/api/localDevAuth.d.ts +3 -6
  30. package/api/localDevAuth.js +10 -37
  31. package/api/marketplaceValidation.d.ts +2 -2
  32. package/api/marketplaceValidation.js +7 -13
  33. package/api/projects.d.ts +6 -8
  34. package/api/projects.js +65 -100
  35. package/api/sandboxHubs.d.ts +2 -5
  36. package/api/sandboxHubs.js +15 -42
  37. package/api/sandboxSync.d.ts +2 -2
  38. package/api/sandboxSync.js +7 -12
  39. package/api/secrets.d.ts +2 -2
  40. package/api/secrets.js +9 -16
  41. package/api/validateHubl.d.ts +2 -2
  42. package/api/validateHubl.js +3 -7
  43. package/config/defaultAccountOverride.d.ts +2 -1
  44. package/config/defaultAccountOverride.js +16 -26
  45. package/config/index.d.ts +4 -4
  46. package/config/index.js +141 -177
  47. package/config/migrate.d.ts +2 -2
  48. package/config/migrate.js +26 -37
  49. package/config/state.d.ts +1 -1
  50. package/config/state.js +17 -45
  51. package/config/utils.d.ts +4 -4
  52. package/config/utils.js +85 -108
  53. package/constants/api.js +3 -6
  54. package/constants/auth.js +9 -12
  55. package/constants/config.js +37 -43
  56. package/constants/endpoints.d.ts +6 -0
  57. package/constants/endpoints.js +6 -0
  58. package/constants/environments.js +1 -4
  59. package/constants/extensions.js +6 -9
  60. package/constants/files.js +5 -8
  61. package/constants/ports.js +3 -6
  62. package/constants/projects.js +2 -5
  63. package/enums/build.d.ts +1 -0
  64. package/enums/build.js +6 -8
  65. package/enums/deploy.js +2 -5
  66. package/enums/project.js +1 -4
  67. package/errors/index.d.ts +4 -5
  68. package/errors/index.js +17 -39
  69. package/errors/isSystemError.d.ts +2 -0
  70. package/errors/isSystemError.js +9 -0
  71. package/http/addQueryParams.d.ts +1 -1
  72. package/http/addQueryParams.js +1 -5
  73. package/http/client.js +14 -42
  74. package/http/getAxiosConfig.d.ts +1 -1
  75. package/http/getAxiosConfig.js +21 -31
  76. package/http/index.d.ts +2 -2
  77. package/http/index.js +39 -46
  78. package/http/unauthed.d.ts +1 -1
  79. package/http/unauthed.js +15 -18
  80. package/lang/en.json +1 -1
  81. package/lib/archive.d.ts +1 -3
  82. package/lib/archive.js +37 -67
  83. package/lib/cms/functions.d.ts +1 -1
  84. package/lib/cms/functions.js +45 -55
  85. package/lib/cms/handleFieldsJS.js +36 -44
  86. package/lib/cms/modules.d.ts +2 -2
  87. package/lib/cms/modules.js +49 -59
  88. package/lib/cms/processFieldsJs.js +17 -32
  89. package/lib/cms/templates.js +17 -26
  90. package/lib/cms/themes.js +10 -18
  91. package/lib/cms/uploadFolder.d.ts +4 -4
  92. package/lib/cms/uploadFolder.js +55 -64
  93. package/lib/cms/validate.d.ts +1 -1
  94. package/lib/cms/validate.js +11 -18
  95. package/lib/cms/watch.d.ts +2 -2
  96. package/lib/cms/watch.js +66 -73
  97. package/lib/crm.d.ts +1 -1
  98. package/lib/crm.js +15 -23
  99. package/lib/customObjects.d.ts +1 -1
  100. package/lib/customObjects.js +15 -25
  101. package/lib/environment.d.ts +1 -1
  102. package/lib/environment.js +5 -11
  103. package/lib/escapeRegExp.js +1 -5
  104. package/lib/fileManager.js +43 -51
  105. package/lib/fileMapper.d.ts +1 -1
  106. package/lib/fileMapper.js +68 -84
  107. package/lib/fs.d.ts +1 -1
  108. package/lib/fs.js +18 -27
  109. package/lib/github.d.ts +1 -3
  110. package/lib/github.js +39 -51
  111. package/lib/gitignore.d.ts +1 -1
  112. package/lib/gitignore.js +16 -24
  113. package/lib/hubdb.d.ts +1 -1
  114. package/lib/hubdb.js +29 -40
  115. package/lib/ignoreRules.js +25 -34
  116. package/lib/isDeepEqual.js +1 -5
  117. package/lib/logger.d.ts +8 -20
  118. package/lib/logger.js +47 -59
  119. package/lib/notify.js +9 -16
  120. package/lib/oauth.d.ts +2 -2
  121. package/lib/oauth.js +12 -17
  122. package/lib/path.d.ts +0 -1
  123. package/lib/path.js +30 -48
  124. package/lib/personalAccessKey.d.ts +2 -4
  125. package/lib/personalAccessKey.js +43 -60
  126. package/lib/portManager.d.ts +2 -2
  127. package/lib/portManager.js +26 -41
  128. package/lib/text.js +2 -7
  129. package/lib/trackUsage.d.ts +0 -2
  130. package/lib/trackUsage.js +23 -29
  131. package/lib/urls.js +4 -9
  132. package/models/FileSystemError.d.ts +1 -1
  133. package/models/FileSystemError.js +12 -16
  134. package/models/HubSpotConfigError.d.ts +1 -1
  135. package/models/HubSpotConfigError.js +8 -12
  136. package/models/HubSpotHttpError.d.ts +1 -1
  137. package/models/HubSpotHttpError.js +22 -26
  138. package/models/OAuth2Manager.d.ts +1 -1
  139. package/models/OAuth2Manager.js +17 -24
  140. package/package.json +20 -16
  141. package/types/Accounts.d.ts +6 -5
  142. package/types/Accounts.js +1 -2
  143. package/types/Activity.d.ts +3 -3
  144. package/types/Activity.js +1 -2
  145. package/types/Api.d.ts +1 -1
  146. package/types/Api.js +1 -2
  147. package/types/Apps.js +1 -2
  148. package/types/Archive.js +1 -2
  149. package/types/Build.d.ts +4 -5
  150. package/types/Build.js +1 -2
  151. package/types/CLIOptions.js +1 -2
  152. package/types/ComponentStructure.d.ts +2 -2
  153. package/types/ComponentStructure.js +1 -2
  154. package/types/Config.d.ts +4 -6
  155. package/types/Config.js +1 -2
  156. package/types/Crm.js +1 -2
  157. package/types/Deploy.d.ts +5 -11
  158. package/types/Deploy.js +1 -2
  159. package/types/DesignManager.js +1 -2
  160. package/types/DevSecrets.js +1 -2
  161. package/types/Error.js +1 -2
  162. package/types/FieldsJS.js +1 -2
  163. package/types/FileManager.js +1 -2
  164. package/types/Files.d.ts +4 -4
  165. package/types/Files.js +1 -2
  166. package/types/FireAlarm.js +1 -2
  167. package/types/Functions.js +1 -2
  168. package/types/Github.d.ts +1 -1
  169. package/types/Github.js +1 -2
  170. package/types/Http.d.ts +0 -4
  171. package/types/Http.js +1 -2
  172. package/types/Hubdb.js +1 -2
  173. package/types/HublValidation.js +1 -2
  174. package/types/Lang.d.ts +1 -1
  175. package/types/Lang.js +1 -2
  176. package/types/Lighthouse.js +1 -2
  177. package/types/MarketplaceValidation.js +1 -2
  178. package/types/Migration.d.ts +2 -2
  179. package/types/Migration.js +1 -4
  180. package/types/Modules.js +1 -2
  181. package/types/PortManager.js +1 -2
  182. package/types/Project.d.ts +3 -21
  183. package/types/Project.js +1 -2
  184. package/types/ProjectComponents.d.ts +24 -0
  185. package/types/ProjectComponents.js +1 -0
  186. package/types/ProjectLog.js +1 -2
  187. package/types/Sandbox.js +2 -5
  188. package/types/Schemas.js +1 -2
  189. package/types/Secrets.js +1 -2
  190. package/types/Utils.js +1 -2
  191. package/types/developerTestAccounts.js +1 -2
  192. package/utils/PortManagerServer.d.ts +1 -2
  193. package/utils/PortManagerServer.js +32 -38
  194. package/utils/cms/fieldsJS.d.ts +1 -1
  195. package/utils/cms/fieldsJS.js +1 -5
  196. package/utils/cms/modules.d.ts +1 -1
  197. package/utils/cms/modules.js +13 -22
  198. package/utils/detectPort.js +12 -19
  199. package/utils/git.js +17 -26
  200. package/utils/lang.d.ts +1 -1
  201. package/utils/lang.js +5 -14
  202. package/utils/personalAccessKey.d.ts +8 -0
  203. package/utils/personalAccessKey.js +51 -0
  204. package/errors/errors_DEPRECATED.d.ts +0 -3
  205. package/errors/errors_DEPRECATED.js +0 -60
@@ -1,6 +1,6 @@
1
- import { Build } from './Build';
2
- import { GithubSourceData } from './Github';
3
- import { ProjectLog } from './ProjectLog';
1
+ import type { Build } from './Build.js';
2
+ import { GithubSourceData } from './Github.js';
3
+ import { ProjectLog } from './ProjectLog.js';
4
4
  export type Project = {
5
5
  createdAt: number;
6
6
  deletedAt: number;
@@ -45,24 +45,6 @@ export type FetchPlatformVersionResponse = {
45
45
  defaultPlatformVersion: string;
46
46
  activePlatformVersions: Array<string>;
47
47
  };
48
- export type ProjectStandardError = {
49
- status: string;
50
- id?: string;
51
- category: string;
52
- subCategory?: string;
53
- message?: string;
54
- errors?: Array<{
55
- message: string;
56
- in?: string;
57
- code?: string;
58
- subcateogy?: string;
59
- context: object;
60
- }>;
61
- context: object;
62
- links: {
63
- [key: string]: string;
64
- };
65
- };
66
48
  export type WarnLogsResponse = {
67
49
  logs: Array<ProjectLog>;
68
50
  };
package/types/Project.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -0,0 +1,24 @@
1
+ export type DeployStatusTaskLocator = {
2
+ id: string;
3
+ links: Array<{
4
+ status: string;
5
+ }>;
6
+ };
7
+ export type ProjectStandardError = {
8
+ status: string;
9
+ id?: string;
10
+ category: string;
11
+ subCategory?: string;
12
+ message?: string;
13
+ errors?: Array<{
14
+ message: string;
15
+ in?: string;
16
+ code?: string;
17
+ subcateogy?: string;
18
+ context: object;
19
+ }>;
20
+ context: object;
21
+ links: {
22
+ [key: string]: string;
23
+ };
24
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/types/Sandbox.js CHANGED
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SandboxStatus = exports.SandboxVersioning = void 0;
4
- exports.SandboxVersioning = {
1
+ export const SandboxVersioning = {
5
2
  V1: 'V1',
6
3
  V2: 'V2',
7
4
  };
8
- exports.SandboxStatus = {
5
+ export const SandboxStatus = {
9
6
  PENDING: 'PENDING',
10
7
  READY: 'READY',
11
8
  FAILED: 'FAILED',
package/types/Schemas.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/types/Secrets.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/types/Utils.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
@@ -1,7 +1,6 @@
1
- /// <reference types="node" />
2
1
  import { Express } from 'express';
3
2
  import { Server } from 'http';
4
- import { ServerPortMap } from '../types/PortManager';
3
+ import { ServerPortMap } from '../types/PortManager.js';
5
4
  export declare const HEALTH_CHECK_PATH = "/port-manager-health-check";
6
5
  export declare const SERVICE_HEALTHY = "OK";
7
6
  declare class _PortManagerServer {
@@ -1,18 +1,12 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.PortManagerServer = exports.SERVICE_HEALTHY = exports.HEALTH_CHECK_PATH = void 0;
7
- const express_1 = __importDefault(require("express"));
8
- const cors_1 = __importDefault(require("cors"));
9
- const detectPort_1 = require("./detectPort");
10
- const ports_1 = require("../constants/ports");
11
- const logger_1 = require("../lib/logger");
12
- const lang_1 = require("./lang");
1
+ import express from 'express';
2
+ import cors from 'cors';
3
+ import { detectPort } from './detectPort.js';
4
+ import { MIN_PORT_NUMBER, MAX_PORT_NUMBER, PORT_MANAGER_SERVER_PORT, } from '../constants/ports.js';
5
+ import { logger } from '../lib/logger.js';
6
+ import { i18n } from './lang.js';
13
7
  const i18nKey = 'utils.PortManagerServer';
14
- exports.HEALTH_CHECK_PATH = '/port-manager-health-check';
15
- exports.SERVICE_HEALTHY = 'OK';
8
+ export const HEALTH_CHECK_PATH = '/port-manager-health-check';
9
+ export const SERVICE_HEALTHY = 'OK';
16
10
  class _PortManagerServer {
17
11
  app;
18
12
  server;
@@ -22,19 +16,19 @@ class _PortManagerServer {
22
16
  }
23
17
  async init() {
24
18
  if (!(await this.portAvailable())) {
25
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.portInUse`, {
26
- port: ports_1.PORT_MANAGER_SERVER_PORT,
19
+ throw new Error(i18n(`${i18nKey}.errors.portInUse`, {
20
+ port: PORT_MANAGER_SERVER_PORT,
27
21
  }));
28
22
  }
29
23
  if (this.app) {
30
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.duplicateInstance`));
24
+ throw new Error(i18n(`${i18nKey}.errors.duplicateInstance`));
31
25
  }
32
- this.app = (0, express_1.default)();
33
- this.app.use(express_1.default.json());
34
- this.app.use((0, cors_1.default)());
26
+ this.app = express();
27
+ this.app.use(express.json());
28
+ this.app.use(cors());
35
29
  this.setupRoutes();
36
30
  this.server = await this.listen();
37
- logger_1.logger.debug(this.server);
31
+ logger.debug(this.server);
38
32
  }
39
33
  reset() {
40
34
  this.app = undefined;
@@ -42,13 +36,13 @@ class _PortManagerServer {
42
36
  this.serverPortMap = {};
43
37
  }
44
38
  async portAvailable() {
45
- return ((await (0, detectPort_1.detectPort)(ports_1.PORT_MANAGER_SERVER_PORT)) === ports_1.PORT_MANAGER_SERVER_PORT);
39
+ return ((await detectPort(PORT_MANAGER_SERVER_PORT)) === PORT_MANAGER_SERVER_PORT);
46
40
  }
47
41
  listen() {
48
42
  return new Promise((resolve, reject) => {
49
- const server = this.app.listen(ports_1.PORT_MANAGER_SERVER_PORT, () => {
50
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.started`, {
51
- port: ports_1.PORT_MANAGER_SERVER_PORT,
43
+ const server = this.app.listen(PORT_MANAGER_SERVER_PORT, () => {
44
+ logger.debug(i18n(`${i18nKey}.started`, {
45
+ port: PORT_MANAGER_SERVER_PORT,
52
46
  }));
53
47
  resolve(server);
54
48
  }).on('error', (err) => {
@@ -65,16 +59,16 @@ class _PortManagerServer {
65
59
  this.app.post('/servers', this.assignPortsToServers);
66
60
  this.app.delete('/servers/:instanceId', this.deleteServerInstance);
67
61
  this.app.post('/close', this.closeServer);
68
- this.app.use(exports.HEALTH_CHECK_PATH, (req, res) => {
69
- res.status(200).send({ status: exports.SERVICE_HEALTHY });
62
+ this.app.use(HEALTH_CHECK_PATH, (req, res) => {
63
+ res.status(200).send({ status: SERVICE_HEALTHY });
70
64
  });
71
65
  }
72
66
  setPort(instanceId, port) {
73
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.setPort`, { instanceId, port }));
67
+ logger.debug(i18n(`${i18nKey}.setPort`, { instanceId, port }));
74
68
  this.serverPortMap[instanceId] = port;
75
69
  }
76
70
  deletePort(instanceId) {
77
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.deletedPort`, {
71
+ logger.debug(i18n(`${i18nKey}.deletedPort`, {
78
72
  instanceId,
79
73
  port: this.serverPortMap[instanceId],
80
74
  }));
@@ -83,7 +77,7 @@ class _PortManagerServer {
83
77
  send404(res, instanceId) {
84
78
  res
85
79
  .status(404)
86
- .send((0, lang_1.i18n)(`${i18nKey}.errors.404`, { instanceId: instanceId }));
80
+ .send(i18n(`${i18nKey}.errors.404`, { instanceId: instanceId }));
87
81
  }
88
82
  getServers = async (req, res) => {
89
83
  res.send({
@@ -107,22 +101,22 @@ class _PortManagerServer {
107
101
  for (let i = 0; i < portData.length; i++) {
108
102
  const { port, instanceId } = portData[i];
109
103
  if (this.serverPortMap[instanceId]) {
110
- res.status(409).send((0, lang_1.i18n)(`${i18nKey}.errors.409`, {
104
+ res.status(409).send(i18n(`${i18nKey}.errors.409`, {
111
105
  instanceId,
112
106
  port: this.serverPortMap[instanceId],
113
107
  }));
114
108
  return;
115
109
  }
116
- else if (port && (port < ports_1.MIN_PORT_NUMBER || port > ports_1.MAX_PORT_NUMBER)) {
117
- res.status(400).send((0, lang_1.i18n)(`${i18nKey}.errors.400`, {
118
- minPort: ports_1.MIN_PORT_NUMBER,
119
- maxPort: ports_1.MAX_PORT_NUMBER,
110
+ else if (port && (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER)) {
111
+ res.status(400).send(i18n(`${i18nKey}.errors.400`, {
112
+ minPort: MIN_PORT_NUMBER,
113
+ maxPort: MAX_PORT_NUMBER,
120
114
  }));
121
115
  return;
122
116
  }
123
117
  else {
124
118
  const promise = new Promise(resolve => {
125
- (0, detectPort_1.detectPort)(port, Object.values(this.serverPortMap)).then(resolvedPort => {
119
+ detectPort(port, Object.values(this.serverPortMap)).then(resolvedPort => {
126
120
  resolve({
127
121
  [instanceId]: resolvedPort,
128
122
  });
@@ -151,11 +145,11 @@ class _PortManagerServer {
151
145
  };
152
146
  closeServer = (req, res) => {
153
147
  if (this.server) {
154
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.close`));
148
+ logger.debug(i18n(`${i18nKey}.close`));
155
149
  res.sendStatus(200);
156
150
  this.server.close();
157
151
  this.reset();
158
152
  }
159
153
  };
160
154
  }
161
- exports.PortManagerServer = new _PortManagerServer();
155
+ export const PortManagerServer = new _PortManagerServer();
@@ -1,2 +1,2 @@
1
- import { FieldsArray } from '../../types/FieldsJS';
1
+ import { FieldsArray } from '../../types/FieldsJS.js';
2
2
  export declare function fieldsArrayToJson<T>(fields: FieldsArray<T>): string;
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fieldsArrayToJson = void 0;
4
1
  /*
5
2
  * Polyfill for `Array.flat(Infinity)` since the `flat` is only available for Node v11+
6
3
  * https://stackoverflow.com/a/15030117
@@ -11,8 +8,7 @@ function flattenArray(arr) {
11
8
  }, []);
12
9
  }
13
10
  //Transform fields array to JSON
14
- function fieldsArrayToJson(fields) {
11
+ export function fieldsArrayToJson(fields) {
15
12
  const flattened = flattenArray(fields);
16
13
  return JSON.stringify(flattened, null, 2);
17
14
  }
18
- exports.fieldsArrayToJson = fieldsArrayToJson;
@@ -1,4 +1,4 @@
1
- import { PathInput } from '../../types/Modules';
1
+ import { PathInput } from '../../types/Modules.js';
2
2
  export declare function isPathInput(pathInput?: PathInput): boolean;
3
3
  export declare function isModuleFolder(pathInput: PathInput): boolean;
4
4
  export declare function isModuleFolderChild(pathInput: PathInput, ignoreLocales?: boolean): boolean;
@@ -1,42 +1,34 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.isModuleFolderChild = exports.isModuleFolder = exports.isPathInput = void 0;
7
- const path_1 = __importDefault(require("path"));
8
- const path_2 = require("../../lib/path");
9
- const extensions_1 = require("../../constants/extensions");
10
- const lang_1 = require("../lang");
1
+ import path from 'path';
2
+ import { getExt, splitHubSpotPath, splitLocalPath } from '../../lib/path.js';
3
+ import { MODULE_EXTENSION } from '../../constants/extensions.js';
4
+ import { i18n } from '../lang.js';
11
5
  const i18nKey = 'utils.cms.modules';
12
6
  const isBool = (x) => !!x === x;
13
- function isPathInput(pathInput) {
7
+ export function isPathInput(pathInput) {
14
8
  return !!(pathInput &&
15
9
  typeof pathInput.path === 'string' &&
16
10
  (isBool(pathInput.isLocal) || isBool(pathInput.isHubSpot)));
17
11
  }
18
- exports.isPathInput = isPathInput;
19
12
  function throwInvalidPathInput(pathInput) {
20
13
  if (isPathInput(pathInput))
21
14
  return;
22
- throw new Error((0, lang_1.i18n)(`${i18nKey}.throwInvalidPathInput`));
15
+ throw new Error(i18n(`${i18nKey}.throwInvalidPathInput`));
23
16
  }
24
- function isModuleFolder(pathInput) {
17
+ export function isModuleFolder(pathInput) {
25
18
  throwInvalidPathInput(pathInput);
26
19
  const _path = pathInput.isHubSpot
27
- ? path_1.default.posix.normalize(pathInput.path)
28
- : path_1.default.normalize(pathInput.path);
29
- return (0, path_2.getExt)(_path) === extensions_1.MODULE_EXTENSION;
20
+ ? path.posix.normalize(pathInput.path)
21
+ : path.normalize(pathInput.path);
22
+ return getExt(_path) === MODULE_EXTENSION;
30
23
  }
31
- exports.isModuleFolder = isModuleFolder;
32
- function isModuleFolderChild(pathInput, ignoreLocales = false) {
24
+ export function isModuleFolderChild(pathInput, ignoreLocales = false) {
33
25
  throwInvalidPathInput(pathInput);
34
26
  let pathParts = [];
35
27
  if (pathInput.isLocal) {
36
- pathParts = (0, path_2.splitLocalPath)(pathInput.path);
28
+ pathParts = splitLocalPath(pathInput.path);
37
29
  }
38
30
  else if (pathInput.isHubSpot) {
39
- pathParts = (0, path_2.splitHubSpotPath)(pathInput.path);
31
+ pathParts = splitHubSpotPath(pathInput.path);
40
32
  }
41
33
  const { length } = pathParts;
42
34
  // Not a child path?
@@ -51,4 +43,3 @@ function isModuleFolderChild(pathInput, ignoreLocales = false) {
51
43
  .slice(0, length - 1)
52
44
  .some(part => isModuleFolder({ ...pathInput, path: part }));
53
45
  }
54
- exports.isModuleFolderChild = isModuleFolderChild;
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  /*
3
2
  From https://github.com/node-modules/detect-port/tree/master
4
3
 
@@ -23,32 +22,26 @@ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
23
22
  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24
23
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
24
  */
26
- var __importDefault = (this && this.__importDefault) || function (mod) {
27
- return (mod && mod.__esModule) ? mod : { "default": mod };
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.detectPort = void 0;
31
- const net_1 = __importDefault(require("net"));
32
- const address_1 = require("address");
33
- const ports_1 = require("../constants/ports");
34
- const lang_1 = require("./lang");
25
+ import net from 'net';
26
+ import { ip } from 'address';
27
+ import { MIN_PORT_NUMBER, MAX_PORT_NUMBER } from '../constants/ports.js';
28
+ import { i18n } from './lang.js';
35
29
  const i18nKey = 'utils.detectPort';
36
- function detectPort(port, exclude = []) {
37
- if (port && (port < ports_1.MIN_PORT_NUMBER || port > ports_1.MAX_PORT_NUMBER)) {
38
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.invalidPort`, {
39
- minPort: ports_1.MIN_PORT_NUMBER,
40
- maxPort: ports_1.MAX_PORT_NUMBER,
30
+ export function detectPort(port, exclude = []) {
31
+ if (port && (port < MIN_PORT_NUMBER || port > MAX_PORT_NUMBER)) {
32
+ throw new Error(i18n(`${i18nKey}.errors.invalidPort`, {
33
+ minPort: MIN_PORT_NUMBER,
34
+ maxPort: MAX_PORT_NUMBER,
41
35
  }));
42
36
  }
43
37
  const portToUse = port || 0;
44
- const maxPort = Math.min(portToUse + 10, ports_1.MAX_PORT_NUMBER);
38
+ const maxPort = Math.min(portToUse + 10, MAX_PORT_NUMBER);
45
39
  return new Promise(resolve => {
46
40
  tryListen(portToUse, maxPort, exclude, (_, resolvedPort) => {
47
41
  resolve(resolvedPort);
48
42
  });
49
43
  });
50
44
  }
51
- exports.detectPort = detectPort;
52
45
  function tryListen(port, maxPort, exclude, callback) {
53
46
  const shouldGiveUp = port >= maxPort;
54
47
  const nextPort = shouldGiveUp ? 0 : port + 1;
@@ -75,7 +68,7 @@ function tryListen(port, maxPort, exclude, callback) {
75
68
  return tryListen(nextPort, nextMaxPort, exclude, callback);
76
69
  }
77
70
  // 4. check current ip
78
- listen(port, (0, address_1.ip)(), (err, realPort) => {
71
+ listen(port, ip(), (err, realPort) => {
79
72
  if (err) {
80
73
  return tryListen(nextPort, nextMaxPort, exclude, callback);
81
74
  }
@@ -86,7 +79,7 @@ function tryListen(port, maxPort, exclude, callback) {
86
79
  });
87
80
  }
88
81
  function listen(port, hostname, callback) {
89
- const server = new net_1.default.Server();
82
+ const server = new net.Server();
90
83
  server.on('error', (err) => {
91
84
  server.close();
92
85
  if (err.code === 'ENOTFOUND') {
package/utils/git.js CHANGED
@@ -1,26 +1,20 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.configFilenameIsIgnoredByGitignore = exports.isConfigPathInGitRepo = exports.getGitignoreFiles = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const ignore_1 = __importDefault(require("ignore"));
10
- const findup_sync_1 = __importDefault(require("findup-sync"));
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import ignore from 'ignore';
4
+ import findup from 'findup-sync';
11
5
  const GITIGNORE_FILE = '.gitignore';
12
6
  function makeComparisonDir(filepath) {
13
7
  if (typeof filepath !== 'string')
14
8
  return null;
15
- const dir = path_1.default.dirname(path_1.default.resolve(filepath)).toLowerCase();
9
+ const dir = path.dirname(path.resolve(filepath)).toLowerCase();
16
10
  // Append sep to make comparisons easier e.g. 'foos'.startsWith('foo')
17
- return dir + (!dir.endsWith(path_1.default.sep) ? path_1.default.sep : '');
11
+ return dir + (!dir.endsWith(path.sep) ? path.sep : '');
18
12
  }
19
13
  function getGitComparisonDir() {
20
- return makeComparisonDir((0, findup_sync_1.default)('.git'));
14
+ return makeComparisonDir(findup('.git'));
21
15
  }
22
16
  // Get all .gitignore files since they can cascade down directory structures
23
- function getGitignoreFiles(configPath) {
17
+ export function getGitignoreFiles(configPath) {
24
18
  const gitDir = getGitComparisonDir();
25
19
  const files = [];
26
20
  if (!gitDir) {
@@ -28,9 +22,9 @@ function getGitignoreFiles(configPath) {
28
22
  return files;
29
23
  }
30
24
  // Start findup from config dir
31
- let cwd = configPath && path_1.default.dirname(configPath);
25
+ let cwd = configPath && path.dirname(configPath);
32
26
  while (cwd) {
33
- const ignorePath = (0, findup_sync_1.default)(GITIGNORE_FILE, { cwd });
27
+ const ignorePath = findup(GITIGNORE_FILE, { cwd });
34
28
  const cmpIgnorePath = makeComparisonDir(ignorePath);
35
29
  const cmpGitDir = makeComparisonDir(gitDir);
36
30
  if (ignorePath &&
@@ -38,9 +32,9 @@ function getGitignoreFiles(configPath) {
38
32
  cmpGitDir &&
39
33
  // Stop findup after .git dir is reached
40
34
  cmpIgnorePath.startsWith(cmpGitDir)) {
41
- const file = path_1.default.resolve(ignorePath);
35
+ const file = path.resolve(ignorePath);
42
36
  files.push(file);
43
- cwd = path_1.default.resolve(path_1.default.dirname(file) + '..');
37
+ cwd = path.resolve(path.dirname(file) + '..');
44
38
  }
45
39
  else {
46
40
  cwd = null;
@@ -48,8 +42,7 @@ function getGitignoreFiles(configPath) {
48
42
  }
49
43
  return files;
50
44
  }
51
- exports.getGitignoreFiles = getGitignoreFiles;
52
- function isConfigPathInGitRepo(configPath) {
45
+ export function isConfigPathInGitRepo(configPath) {
53
46
  const gitDir = getGitComparisonDir();
54
47
  if (!gitDir)
55
48
  return false;
@@ -58,15 +51,13 @@ function isConfigPathInGitRepo(configPath) {
58
51
  return false;
59
52
  return configDir.startsWith(gitDir);
60
53
  }
61
- exports.isConfigPathInGitRepo = isConfigPathInGitRepo;
62
- function configFilenameIsIgnoredByGitignore(ignoreFiles, configPath) {
54
+ export function configFilenameIsIgnoredByGitignore(ignoreFiles, configPath) {
63
55
  return ignoreFiles.some(gitignore => {
64
- const gitignoreContents = fs_extra_1.default.readFileSync(gitignore).toString();
65
- const gitignoreConfig = (0, ignore_1.default)().add(gitignoreContents);
66
- if (gitignoreConfig.ignores(path_1.default.relative(path_1.default.dirname(gitignore), configPath))) {
56
+ const gitignoreContents = fs.readFileSync(gitignore).toString();
57
+ const gitignoreConfig = ignore().add(gitignoreContents);
58
+ if (gitignoreConfig.ignores(path.relative(path.dirname(gitignore), configPath))) {
67
59
  return true;
68
60
  }
69
61
  return false;
70
62
  });
71
63
  }
72
- exports.configFilenameIsIgnoredByGitignore = configFilenameIsIgnoredByGitignore;
package/utils/lang.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { LanguageObject, LangKey, InterpolationData } from '../types/Lang';
1
+ import { LanguageObject, LangKey, InterpolationData } from '../types/Lang.js';
2
2
  export declare function interpolate(stringValue: string, interpolationData: InterpolationData): string;
3
3
  export declare function i18n(lookupDotNotation: LangKey, options?: {
4
4
  [identifier: string]: string | number;
package/utils/lang.js CHANGED
@@ -1,12 +1,6 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.setLangData = exports.i18n = exports.interpolate = void 0;
7
- const en_json_1 = __importDefault(require("../lang/en.json"));
1
+ import en from '../lang/en.json' with { type: 'json' };
8
2
  const LANGUAGES = {
9
- en: en_json_1.default,
3
+ en,
10
4
  };
11
5
  const MISSING_LANGUAGE_DATA_PREFIX = '[Missing language data]';
12
6
  let languageObj;
@@ -53,7 +47,7 @@ function generateReplaceFn(matchedText, startIndex, replacementString) {
53
47
  return `${currentStringValue.slice(0, startIndex)}${replacementString || ''}${currentStringValue.slice(startIndex + matchedText.length)}`;
54
48
  };
55
49
  }
56
- function interpolate(stringValue, interpolationData) {
50
+ export function interpolate(stringValue, interpolationData) {
57
51
  const interpolationIdentifierRegEx = new RegExp(`${delimiters.interpolation.start}(.*?)${delimiters.interpolation.end}`, 'g');
58
52
  const replaceQueue = [];
59
53
  let match;
@@ -69,8 +63,7 @@ function interpolate(stringValue, interpolationData) {
69
63
  const compiledString = replaceQueue.reduce((currentValue, replaceFn) => replaceFn(currentValue), stringValue);
70
64
  return compiledString;
71
65
  }
72
- exports.interpolate = interpolate;
73
- function i18n(lookupDotNotation, options = {}) {
66
+ export function i18n(lookupDotNotation, options = {}) {
74
67
  if (!languageObj) {
75
68
  loadLanguageForLocale();
76
69
  }
@@ -81,8 +74,6 @@ function i18n(lookupDotNotation, options = {}) {
81
74
  const shouldInterpolate = !textValue.startsWith(MISSING_LANGUAGE_DATA_PREFIX);
82
75
  return shouldInterpolate ? interpolate(textValue, options) : textValue;
83
76
  }
84
- exports.i18n = i18n;
85
- const setLangData = (newLocale, newLangObj) => {
77
+ export const setLangData = (newLocale, newLangObj) => {
86
78
  languageObj = newLangObj;
87
79
  };
88
- exports.setLangData = setLangData;
@@ -0,0 +1,8 @@
1
+ import { AxiosPromise } from 'axios';
2
+ import { AccessTokenResponse, Environment } from '../types/Accounts.js';
3
+ import { DeveloperTestAccount } from '../types/developerTestAccounts.js';
4
+ import { SandboxHubData } from '../types/Sandbox.js';
5
+ import { HubSpotPromise } from '../types/Http.js';
6
+ export declare function fetchAccessToken(personalAccessKey: string, env?: Environment, portalId?: number): HubSpotPromise<AccessTokenResponse>;
7
+ export declare function fetchSandboxHubData(accessToken: string, accountId: number, env?: Environment): AxiosPromise<SandboxHubData>;
8
+ export declare function fetchDeveloperTestAccountData(accessToken: string, accountId: number, env?: Environment): HubSpotPromise<DeveloperTestAccount>;
@@ -0,0 +1,51 @@
1
+ import { httpClient } from '../http/client.js';
2
+ import { getAxiosConfig } from '../http/getAxiosConfig.js';
3
+ import { ENVIRONMENTS } from '../constants/environments.js';
4
+ import { LOCALDEVAUTH_ACCESS_TOKEN_PATH } from '../constants/endpoints.js';
5
+ const SANDBOX_API_PATH = 'sandbox-hubs/v1';
6
+ const TEST_ACCOUNTS_API_PATH = 'integrators/test-portals/v2';
7
+ export function fetchAccessToken(personalAccessKey, env = ENVIRONMENTS.PROD, portalId) {
8
+ const axiosConfig = getAxiosConfig({
9
+ env,
10
+ localHostOverride: true,
11
+ url: LOCALDEVAUTH_ACCESS_TOKEN_PATH,
12
+ data: {
13
+ encodedOAuthRefreshToken: personalAccessKey,
14
+ },
15
+ params: portalId ? { portalId } : {},
16
+ });
17
+ return httpClient({
18
+ ...axiosConfig,
19
+ method: 'post',
20
+ });
21
+ }
22
+ export function fetchSandboxHubData(accessToken, accountId, env = ENVIRONMENTS.PROD) {
23
+ const axiosConfig = getAxiosConfig({
24
+ env,
25
+ url: `${SANDBOX_API_PATH}/self`,
26
+ params: { portalId: accountId },
27
+ });
28
+ const reqWithToken = {
29
+ ...axiosConfig,
30
+ headers: {
31
+ ...axiosConfig.headers,
32
+ Authorization: `Bearer ${accessToken}`,
33
+ },
34
+ };
35
+ return httpClient(reqWithToken);
36
+ }
37
+ export function fetchDeveloperTestAccountData(accessToken, accountId, env = ENVIRONMENTS.PROD) {
38
+ const axiosConfig = getAxiosConfig({
39
+ env,
40
+ url: `${TEST_ACCOUNTS_API_PATH}/self`,
41
+ params: { portalId: accountId },
42
+ });
43
+ const reqWithToken = {
44
+ ...axiosConfig,
45
+ headers: {
46
+ ...axiosConfig.headers,
47
+ Authorization: `Bearer ${accessToken}`,
48
+ },
49
+ };
50
+ return httpClient(reqWithToken);
51
+ }
@@ -1,3 +0,0 @@
1
- import { BaseError, FileSystemErrorContext, ErrorContext } from '../types/Error';
2
- export declare function logErrorInstance(error: BaseError, context?: ErrorContext): void;
3
- export declare function logFileSystemErrorInstance(error: BaseError, context: FileSystemErrorContext): void;