@hubspot/local-dev-lib 0.6.1-experimental.0 → 0.6.3-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 (207) 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 -55
  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 -40
  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 -45
  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 +144 -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.d.ts +30 -1
  56. package/constants/config.js +65 -42
  57. package/constants/endpoints.d.ts +6 -0
  58. package/constants/endpoints.js +6 -0
  59. package/constants/environments.js +1 -4
  60. package/constants/extensions.js +6 -9
  61. package/constants/files.js +5 -8
  62. package/constants/ports.js +3 -6
  63. package/constants/projects.js +2 -5
  64. package/enums/build.d.ts +1 -0
  65. package/enums/build.js +6 -8
  66. package/enums/deploy.js +2 -5
  67. package/enums/project.js +1 -4
  68. package/errors/index.d.ts +4 -5
  69. package/errors/index.js +17 -39
  70. package/errors/isSystemError.d.ts +2 -0
  71. package/errors/isSystemError.js +9 -0
  72. package/http/addQueryParams.d.ts +1 -1
  73. package/http/addQueryParams.js +1 -5
  74. package/http/client.d.ts +1 -0
  75. package/http/client.js +54 -0
  76. package/http/getAxiosConfig.d.ts +1 -1
  77. package/http/getAxiosConfig.js +21 -31
  78. package/http/index.d.ts +2 -2
  79. package/http/index.js +39 -124
  80. package/http/unauthed.d.ts +1 -1
  81. package/http/unauthed.js +15 -21
  82. package/lang/en.json +3 -2
  83. package/lib/archive.d.ts +1 -3
  84. package/lib/archive.js +37 -67
  85. package/lib/cms/functions.d.ts +1 -1
  86. package/lib/cms/functions.js +45 -55
  87. package/lib/cms/handleFieldsJS.js +36 -44
  88. package/lib/cms/modules.d.ts +2 -2
  89. package/lib/cms/modules.js +49 -59
  90. package/lib/cms/processFieldsJs.js +17 -32
  91. package/lib/cms/templates.js +17 -26
  92. package/lib/cms/themes.js +10 -18
  93. package/lib/cms/uploadFolder.d.ts +4 -4
  94. package/lib/cms/uploadFolder.js +55 -64
  95. package/lib/cms/validate.d.ts +1 -1
  96. package/lib/cms/validate.js +11 -18
  97. package/lib/cms/watch.d.ts +2 -2
  98. package/lib/cms/watch.js +66 -73
  99. package/lib/crm.d.ts +1 -1
  100. package/lib/crm.js +15 -23
  101. package/lib/customObjects.d.ts +1 -1
  102. package/lib/customObjects.js +15 -25
  103. package/lib/environment.d.ts +1 -1
  104. package/lib/environment.js +5 -11
  105. package/lib/escapeRegExp.js +1 -5
  106. package/lib/fileManager.js +43 -51
  107. package/lib/fileMapper.d.ts +1 -1
  108. package/lib/fileMapper.js +68 -84
  109. package/lib/fs.d.ts +1 -1
  110. package/lib/fs.js +18 -27
  111. package/lib/github.d.ts +1 -3
  112. package/lib/github.js +39 -51
  113. package/lib/gitignore.d.ts +1 -1
  114. package/lib/gitignore.js +16 -24
  115. package/lib/hubdb.d.ts +1 -1
  116. package/lib/hubdb.js +29 -40
  117. package/lib/ignoreRules.js +25 -34
  118. package/lib/isDeepEqual.js +1 -5
  119. package/lib/logger.d.ts +8 -20
  120. package/lib/logger.js +47 -59
  121. package/lib/notify.js +9 -16
  122. package/lib/oauth.d.ts +2 -2
  123. package/lib/oauth.js +12 -17
  124. package/lib/path.d.ts +0 -1
  125. package/lib/path.js +30 -48
  126. package/lib/personalAccessKey.d.ts +2 -4
  127. package/lib/personalAccessKey.js +43 -60
  128. package/lib/portManager.d.ts +2 -2
  129. package/lib/portManager.js +26 -41
  130. package/lib/text.js +2 -7
  131. package/lib/trackUsage.d.ts +0 -2
  132. package/lib/trackUsage.js +27 -31
  133. package/lib/urls.js +4 -9
  134. package/models/FileSystemError.d.ts +1 -1
  135. package/models/FileSystemError.js +12 -16
  136. package/models/HubSpotConfigError.d.ts +1 -1
  137. package/models/HubSpotConfigError.js +8 -12
  138. package/models/HubSpotHttpError.d.ts +1 -1
  139. package/models/HubSpotHttpError.js +22 -26
  140. package/models/OAuth2Manager.d.ts +1 -1
  141. package/models/OAuth2Manager.js +17 -24
  142. package/package.json +21 -17
  143. package/types/Accounts.d.ts +6 -5
  144. package/types/Accounts.js +1 -2
  145. package/types/Activity.d.ts +3 -3
  146. package/types/Activity.js +1 -2
  147. package/types/Api.d.ts +1 -1
  148. package/types/Api.js +1 -2
  149. package/types/Apps.js +1 -2
  150. package/types/Archive.js +1 -2
  151. package/types/Build.d.ts +4 -5
  152. package/types/Build.js +1 -2
  153. package/types/CLIOptions.js +1 -2
  154. package/types/ComponentStructure.d.ts +2 -2
  155. package/types/ComponentStructure.js +1 -2
  156. package/types/Config.d.ts +4 -6
  157. package/types/Config.js +1 -2
  158. package/types/Crm.js +1 -2
  159. package/types/Deploy.d.ts +5 -11
  160. package/types/Deploy.js +1 -2
  161. package/types/DesignManager.js +1 -2
  162. package/types/DevSecrets.js +1 -2
  163. package/types/Error.js +1 -2
  164. package/types/FieldsJS.js +1 -2
  165. package/types/FileManager.js +1 -2
  166. package/types/Files.d.ts +4 -4
  167. package/types/Files.js +1 -2
  168. package/types/FireAlarm.js +1 -2
  169. package/types/Functions.js +1 -2
  170. package/types/Github.d.ts +1 -1
  171. package/types/Github.js +1 -2
  172. package/types/Http.d.ts +0 -4
  173. package/types/Http.js +1 -2
  174. package/types/Hubdb.js +1 -2
  175. package/types/HublValidation.js +1 -2
  176. package/types/Lang.d.ts +1 -1
  177. package/types/Lang.js +1 -2
  178. package/types/Lighthouse.js +1 -2
  179. package/types/MarketplaceValidation.js +1 -2
  180. package/types/Migration.d.ts +2 -2
  181. package/types/Migration.js +1 -4
  182. package/types/Modules.js +1 -2
  183. package/types/PortManager.js +1 -2
  184. package/types/Project.d.ts +3 -21
  185. package/types/Project.js +1 -2
  186. package/types/ProjectComponents.d.ts +24 -0
  187. package/types/ProjectComponents.js +1 -0
  188. package/types/ProjectLog.js +1 -2
  189. package/types/Sandbox.js +2 -5
  190. package/types/Schemas.js +1 -2
  191. package/types/Secrets.js +1 -2
  192. package/types/Utils.js +1 -2
  193. package/types/developerTestAccounts.js +1 -2
  194. package/utils/PortManagerServer.d.ts +1 -2
  195. package/utils/PortManagerServer.js +32 -38
  196. package/utils/cms/fieldsJS.d.ts +1 -1
  197. package/utils/cms/fieldsJS.js +1 -5
  198. package/utils/cms/modules.d.ts +1 -1
  199. package/utils/cms/modules.js +13 -22
  200. package/utils/detectPort.js +12 -19
  201. package/utils/git.js +17 -26
  202. package/utils/lang.d.ts +1 -1
  203. package/utils/lang.js +5 -14
  204. package/utils/personalAccessKey.d.ts +8 -0
  205. package/utils/personalAccessKey.js +51 -0
  206. package/errors/errors_DEPRECATED.d.ts +0 -3
  207. package/errors/errors_DEPRECATED.js +0 -60
@@ -1,29 +1,21 @@
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.downloadSchema = exports.downloadSchemas = exports.writeSchemaToDisk = exports.getResolvedPath = void 0;
7
- const fs_extra_1 = __importDefault(require("fs-extra"));
8
- const path_1 = __importDefault(require("path"));
9
- const prettier_1 = __importDefault(require("prettier"));
10
- const path_2 = require("../lib/path");
11
- const customObjects_1 = require("../api/customObjects");
12
- function getResolvedPath(dest, name) {
1
+ import fs from 'fs-extra';
2
+ import path from 'path';
3
+ import { getCwd } from '../lib/path.js';
4
+ import { fetchObjectSchemas, fetchObjectSchema } from '../api/customObjects.js';
5
+ import { format } from 'prettier';
6
+ export function getResolvedPath(dest, name) {
13
7
  if (name)
14
- return path_1.default.resolve((0, path_2.getCwd)(), dest || '', `${name}.json`);
15
- return path_1.default.resolve((0, path_2.getCwd)(), dest || '');
8
+ return path.resolve(getCwd(), dest || '', `${name}.json`);
9
+ return path.resolve(getCwd(), dest || '');
16
10
  }
17
- exports.getResolvedPath = getResolvedPath;
18
- async function writeSchemaToDisk(schema, dest) {
19
- const formattedSchema = await prettier_1.default.format(JSON.stringify(schema), {
11
+ export async function writeSchemaToDisk(schema, dest) {
12
+ const formattedSchema = await format(JSON.stringify(schema), {
20
13
  parser: 'json',
21
14
  });
22
- fs_extra_1.default.outputFileSync(getResolvedPath(dest, schema.name), formattedSchema);
15
+ fs.outputFileSync(getResolvedPath(dest, schema.name), formattedSchema);
23
16
  }
24
- exports.writeSchemaToDisk = writeSchemaToDisk;
25
- async function downloadSchemas(accountId, dest) {
26
- const axiosResponse = await (0, customObjects_1.fetchObjectSchemas)(accountId);
17
+ export async function downloadSchemas(accountId, dest) {
18
+ const axiosResponse = await fetchObjectSchemas(accountId);
27
19
  const response = axiosResponse.data;
28
20
  if (response.results.length) {
29
21
  for (const schema of response.results) {
@@ -32,11 +24,9 @@ async function downloadSchemas(accountId, dest) {
32
24
  }
33
25
  return response.results;
34
26
  }
35
- exports.downloadSchemas = downloadSchemas;
36
- async function downloadSchema(accountId, schemaObjectType, dest) {
37
- const axiosResponse = await (0, customObjects_1.fetchObjectSchema)(accountId, schemaObjectType);
27
+ export async function downloadSchema(accountId, schemaObjectType, dest) {
28
+ const axiosResponse = await fetchObjectSchema(accountId, schemaObjectType);
38
29
  const response = axiosResponse.data;
39
30
  await writeSchemaToDisk(response, dest);
40
31
  return response;
41
32
  }
42
- exports.downloadSchema = downloadSchema;
@@ -1,2 +1,2 @@
1
- import { Environment } from '../types/Config';
1
+ import { Environment } from '../types/Accounts.js';
2
2
  export declare function getValidEnv(env?: string | null, maskedProductionValue?: Environment): Environment;
@@ -1,16 +1,10 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getValidEnv = void 0;
4
- const environments_1 = require("../constants/environments");
5
- function getValidEnv(env, maskedProductionValue) {
1
+ import { ENVIRONMENTS } from '../constants/environments.js';
2
+ export function getValidEnv(env, maskedProductionValue) {
6
3
  const prodValue = typeof maskedProductionValue === 'string'
7
4
  ? maskedProductionValue
8
- : environments_1.ENVIRONMENTS.PROD;
9
- const returnVal = typeof env &&
10
- typeof env === 'string' &&
11
- env.toLowerCase() === environments_1.ENVIRONMENTS.QA
12
- ? environments_1.ENVIRONMENTS.QA
5
+ : ENVIRONMENTS.PROD;
6
+ const returnVal = env && typeof env === 'string' && env.toLowerCase() === ENVIRONMENTS.QA
7
+ ? ENVIRONMENTS.QA
13
8
  : prodValue;
14
9
  return returnVal;
15
10
  }
16
- exports.getValidEnv = getValidEnv;
@@ -1,7 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.escapeRegExp = void 0;
4
- function escapeRegExp(string) {
1
+ export function escapeRegExp(string) {
5
2
  return string.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
6
3
  }
7
- exports.escapeRegExp = escapeRegExp;
@@ -1,74 +1,67 @@
1
- "use strict";
2
1
  // FILE MANAGER - not to be confused with fileMapper.ts
3
- var __importDefault = (this && this.__importDefault) || function (mod) {
4
- return (mod && mod.__esModule) ? mod : { "default": mod };
5
- };
6
- Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.downloadFileOrFolder = exports.uploadFolder = void 0;
8
- const fs_extra_1 = __importDefault(require("fs-extra"));
9
- const path_1 = __importDefault(require("path"));
10
- const fileManager_1 = require("../api/fileManager");
11
- const fs_1 = require("./fs");
12
- const logger_1 = require("./logger");
13
- const ignoreRules_1 = require("./ignoreRules");
14
- const http_1 = require("../http");
15
- const escapeRegExp_1 = require("./escapeRegExp");
16
- const path_2 = require("./path");
17
- const lang_1 = require("../utils/lang");
18
- const errors_1 = require("../errors");
19
- const FileSystemError_1 = require("../models/FileSystemError");
2
+ import fs from 'fs-extra';
3
+ import path from 'path';
4
+ import { uploadFile, fetchStat, fetchFiles, fetchFolders, } from '../api/fileManager.js';
5
+ import { walk } from './fs.js';
6
+ import { logger } from './logger.js';
7
+ import { createIgnoreFilter } from './ignoreRules.js';
8
+ import { http } from '../http/index.js';
9
+ import { escapeRegExp } from './escapeRegExp.js';
10
+ import { getCwd, convertToUnixPath, convertToLocalFileSystemPath, } from './path.js';
11
+ import { i18n } from '../utils/lang.js';
12
+ import { isAuthError, isHubSpotHttpError } from '../errors/index.js';
13
+ import { FileSystemError } from '../models/FileSystemError.js';
20
14
  const i18nKey = 'lib.fileManager';
21
- async function uploadFolder(accountId, src, dest) {
22
- const regex = new RegExp(`^${(0, escapeRegExp_1.escapeRegExp)(src)}`);
23
- const files = await (0, fs_1.walk)(src);
24
- const filesToUpload = files.filter((0, ignoreRules_1.createIgnoreFilter)(false));
15
+ export async function uploadFolder(accountId, src, dest) {
16
+ const regex = new RegExp(`^${escapeRegExp(src)}`);
17
+ const files = await walk(src);
18
+ const filesToUpload = files.filter(createIgnoreFilter(false));
25
19
  const len = filesToUpload.length;
26
20
  for (let index = 0; index < len; index++) {
27
21
  const file = filesToUpload[index];
28
22
  const relativePath = file.replace(regex, '');
29
- const destPath = (0, path_2.convertToUnixPath)(path_1.default.join(dest, relativePath));
30
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.uploadStarted`, {
23
+ const destPath = convertToUnixPath(path.join(dest, relativePath));
24
+ logger.debug(i18n(`${i18nKey}.uploadStarted`, {
31
25
  file,
32
26
  destPath,
33
27
  accountId,
34
28
  }));
35
29
  try {
36
- await (0, fileManager_1.uploadFile)(accountId, file, destPath);
37
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.uploadSuccess`, { file, destPath }));
30
+ await uploadFile(accountId, file, destPath);
31
+ logger.log(i18n(`${i18nKey}.uploadSuccess`, { file, destPath }));
38
32
  }
39
33
  catch (err) {
40
- if ((0, errors_1.isHubSpotHttpError)(err)) {
34
+ if (isHubSpotHttpError(err)) {
41
35
  err.updateContext({
42
36
  filepath: file,
43
37
  dest: destPath,
44
38
  });
45
39
  throw err;
46
40
  }
47
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.uploadFailed`, {
41
+ throw new Error(i18n(`${i18nKey}.errors.uploadFailed`, {
48
42
  file,
49
43
  destPath,
50
44
  }));
51
45
  }
52
46
  }
53
47
  }
54
- exports.uploadFolder = uploadFolder;
55
48
  async function skipExisting(overwrite, filepath) {
56
49
  if (overwrite) {
57
50
  return false;
58
51
  }
59
- if (await fs_extra_1.default.pathExists(filepath)) {
60
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.skippedExisting`, { filepath }));
52
+ if (await fs.pathExists(filepath)) {
53
+ logger.log(i18n(`${i18nKey}.skippedExisting`, { filepath }));
61
54
  return true;
62
55
  }
63
56
  return false;
64
57
  }
65
58
  async function downloadFile(accountId, file, dest, overwrite) {
66
59
  const fileName = `${file.name}.${file.extension}`;
67
- const destPath = (0, path_2.convertToLocalFileSystemPath)(path_1.default.join(dest, fileName));
60
+ const destPath = convertToLocalFileSystemPath(path.join(dest, fileName));
68
61
  if (await skipExisting(overwrite || false, destPath)) {
69
62
  return;
70
63
  }
71
- await http_1.http.getOctetStream(accountId, {
64
+ await http.getOctetStream(accountId, {
72
65
  baseURL: file.url,
73
66
  url: '',
74
67
  }, destPath);
@@ -79,7 +72,7 @@ async function fetchAllPagedFiles(accountId, folderId, includeArchived) {
79
72
  let count = 0;
80
73
  let offset = 0;
81
74
  while (totalFiles === null || count < totalFiles) {
82
- const { data: response } = await (0, fileManager_1.fetchFiles)(accountId, folderId, offset, includeArchived);
75
+ const { data: response } = await fetchFiles(accountId, folderId, offset, includeArchived);
83
76
  if (totalFiles === null) {
84
77
  totalFiles = response.total_count;
85
78
  }
@@ -91,26 +84,26 @@ async function fetchAllPagedFiles(accountId, folderId, includeArchived) {
91
84
  }
92
85
  async function fetchFolderContents(accountId, folder, dest, overwrite, includeArchived) {
93
86
  try {
94
- await fs_extra_1.default.ensureDir(dest);
87
+ await fs.ensureDir(dest);
95
88
  }
96
89
  catch (err) {
97
- throw new FileSystemError_1.FileSystemError({ cause: err }, {
90
+ throw new FileSystemError({ cause: err }, {
98
91
  dest,
99
92
  accountId,
100
93
  operation: 'write',
101
94
  });
102
95
  }
103
96
  const files = await fetchAllPagedFiles(accountId, folder.id, includeArchived);
104
- logger_1.logger.debug((0, lang_1.i18n)(`${i18nKey}.fetchingFiles`, {
97
+ logger.debug(i18n(`${i18nKey}.fetchingFiles`, {
105
98
  fileCount: files.length,
106
99
  folderName: folder.name || '',
107
100
  }));
108
101
  for (const file of files) {
109
102
  await downloadFile(accountId, file, dest, overwrite);
110
103
  }
111
- const { data: { objects: folders }, } = await (0, fileManager_1.fetchFolders)(accountId, folder.id);
104
+ const { data: { objects: folders }, } = await fetchFolders(accountId, folder.id);
112
105
  for (const folder of folders) {
113
- const nestedFolder = path_1.default.join(dest, folder.name);
106
+ const nestedFolder = path.join(dest, folder.name);
114
107
  await fetchFolderContents(accountId, folder, nestedFolder, overwrite, includeArchived);
115
108
  }
116
109
  }
@@ -118,18 +111,18 @@ async function fetchFolderContents(accountId, folder, dest, overwrite, includeAr
118
111
  async function downloadFolder(accountId, src, dest, folder, overwrite, includeArchived) {
119
112
  let absolutePath;
120
113
  if (folder.name) {
121
- absolutePath = (0, path_2.convertToLocalFileSystemPath)(path_1.default.resolve((0, path_2.getCwd)(), dest, folder.name));
114
+ absolutePath = convertToLocalFileSystemPath(path.resolve(getCwd(), dest, folder.name));
122
115
  }
123
116
  else {
124
- absolutePath = (0, path_2.convertToLocalFileSystemPath)(path_1.default.resolve((0, path_2.getCwd)(), dest));
117
+ absolutePath = convertToLocalFileSystemPath(path.resolve(getCwd(), dest));
125
118
  }
126
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.fetchFolderStarted`, {
119
+ logger.log(i18n(`${i18nKey}.fetchFolderStarted`, {
127
120
  src,
128
121
  path: absolutePath,
129
122
  accountId,
130
123
  }));
131
124
  await fetchFolderContents(accountId, folder, absolutePath, overwrite, includeArchived);
132
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.fetchFolderSuccess`, {
125
+ logger.success(i18n(`${i18nKey}.fetchFolderSuccess`, {
133
126
  src,
134
127
  dest,
135
128
  }));
@@ -137,24 +130,24 @@ async function downloadFolder(accountId, src, dest, folder, overwrite, includeAr
137
130
  // Download a single file and write to local file system.
138
131
  async function downloadSingleFile(accountId, src, dest, file, overwrite, includeArchived) {
139
132
  if (!includeArchived && file.archived) {
140
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.archivedFile`, { src }));
133
+ throw new Error(i18n(`${i18nKey}.errors.archivedFile`, { src }));
141
134
  }
142
135
  if (file.hidden) {
143
- throw new Error((0, lang_1.i18n)(`${i18nKey}.errors.hiddenFile`, { src }));
136
+ throw new Error(i18n(`${i18nKey}.errors.hiddenFile`, { src }));
144
137
  }
145
- logger_1.logger.log((0, lang_1.i18n)(`${i18nKey}.fetchFileStarted`, {
138
+ logger.log(i18n(`${i18nKey}.fetchFileStarted`, {
146
139
  src,
147
140
  dest,
148
141
  accountId,
149
142
  }));
150
143
  await downloadFile(accountId, file, dest, overwrite);
151
- logger_1.logger.success((0, lang_1.i18n)(`${i18nKey}.fetchFileSuccess`, {
144
+ logger.success(i18n(`${i18nKey}.fetchFileSuccess`, {
152
145
  src,
153
146
  dest,
154
147
  }));
155
148
  }
156
149
  // Lookup path in file manager and initiate download
157
- async function downloadFileOrFolder(accountId, src, dest, overwrite, includeArchived) {
150
+ export async function downloadFileOrFolder(accountId, src, dest, overwrite, includeArchived) {
158
151
  try {
159
152
  if (src == '/') {
160
153
  // Filemanager API treats 'None' as the root
@@ -162,7 +155,7 @@ async function downloadFileOrFolder(accountId, src, dest, overwrite, includeArch
162
155
  await downloadFolder(accountId, src, dest, rootFolder, overwrite, includeArchived);
163
156
  }
164
157
  else {
165
- const { data: { file, folder }, } = await (0, fileManager_1.fetchStat)(accountId, src);
158
+ const { data: { file, folder }, } = await fetchStat(accountId, src);
166
159
  if (file) {
167
160
  await downloadSingleFile(accountId, src, dest, file, overwrite, includeArchived);
168
161
  }
@@ -172,7 +165,7 @@ async function downloadFileOrFolder(accountId, src, dest, overwrite, includeArch
172
165
  }
173
166
  }
174
167
  catch (err) {
175
- if ((0, errors_1.isAuthError)(err)) {
168
+ if (isAuthError(err)) {
176
169
  err.updateContext({
177
170
  request: src,
178
171
  accountId,
@@ -181,4 +174,3 @@ async function downloadFileOrFolder(accountId, src, dest, overwrite, includeArch
181
174
  throw err;
182
175
  }
183
176
  }
184
- exports.downloadFileOrFolder = downloadFileOrFolder;
@@ -1,4 +1,4 @@
1
- import { FileMapperNode, CmsPublishMode, FileMapperOptions, FileMapperInputOptions, PathTypeData, RecursiveFileMapperCallback } from '../types/Files';
1
+ import { FileMapperNode, CmsPublishMode, FileMapperOptions, FileMapperInputOptions, PathTypeData, RecursiveFileMapperCallback } from '../types/Files.js';
2
2
  export declare function isPathToFile(filepath: string): boolean;
3
3
  export declare function isPathToModule(filepath: string): boolean;
4
4
  export declare function isPathToRoot(filepath: string): boolean;