@hubspot/cli 7.7.19-experimental.2 → 7.7.20-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 (296) hide show
  1. package/api/__tests__/migrate.test.d.ts +1 -0
  2. package/api/__tests__/migrate.test.js +183 -0
  3. package/commands/__tests__/account.test.d.ts +1 -0
  4. package/commands/__tests__/account.test.js +74 -0
  5. package/commands/__tests__/auth.test.d.ts +1 -0
  6. package/commands/__tests__/auth.test.js +43 -0
  7. package/commands/__tests__/cms.test.d.ts +1 -0
  8. package/commands/__tests__/cms.test.js +49 -0
  9. package/commands/__tests__/config.test.d.ts +1 -0
  10. package/commands/__tests__/config.test.js +49 -0
  11. package/commands/__tests__/create.test.d.ts +1 -0
  12. package/commands/__tests__/create.test.js +38 -0
  13. package/commands/__tests__/customObject.test.d.ts +1 -0
  14. package/commands/__tests__/customObject.test.js +54 -0
  15. package/commands/__tests__/doctor.test.d.ts +1 -0
  16. package/commands/__tests__/doctor.test.js +139 -0
  17. package/commands/__tests__/feedback.test.d.ts +1 -0
  18. package/commands/__tests__/feedback.test.js +62 -0
  19. package/commands/__tests__/fetch.test.d.ts +1 -0
  20. package/commands/__tests__/fetch.test.js +56 -0
  21. package/commands/__tests__/filemanager.test.d.ts +1 -0
  22. package/commands/__tests__/filemanager.test.js +50 -0
  23. package/commands/__tests__/function.test.d.ts +1 -0
  24. package/commands/__tests__/function.test.js +51 -0
  25. package/commands/__tests__/getStarted.test.d.ts +1 -0
  26. package/commands/__tests__/getStarted.test.js +170 -0
  27. package/commands/__tests__/hubdb.test.d.ts +1 -0
  28. package/commands/__tests__/hubdb.test.js +55 -0
  29. package/commands/__tests__/init.test.d.ts +1 -0
  30. package/commands/__tests__/init.test.js +47 -0
  31. package/commands/__tests__/lint.test.d.ts +1 -0
  32. package/commands/__tests__/lint.test.js +38 -0
  33. package/commands/__tests__/list.test.d.ts +1 -0
  34. package/commands/__tests__/list.test.js +47 -0
  35. package/commands/__tests__/logs.test.d.ts +1 -0
  36. package/commands/__tests__/logs.test.js +70 -0
  37. package/commands/__tests__/mcp.test.d.ts +1 -0
  38. package/commands/__tests__/mcp.test.js +51 -0
  39. package/commands/__tests__/mv.test.d.ts +1 -0
  40. package/commands/__tests__/mv.test.js +84 -0
  41. package/commands/__tests__/open.test.d.ts +1 -0
  42. package/commands/__tests__/open.test.js +96 -0
  43. package/commands/__tests__/project.test.d.ts +1 -0
  44. package/commands/__tests__/project.test.js +100 -0
  45. package/commands/__tests__/remove.test.d.ts +1 -0
  46. package/commands/__tests__/remove.test.js +77 -0
  47. package/commands/__tests__/sandbox.test.d.ts +1 -0
  48. package/commands/__tests__/sandbox.test.js +49 -0
  49. package/commands/__tests__/secret.test.d.ts +1 -0
  50. package/commands/__tests__/secret.test.js +54 -0
  51. package/commands/__tests__/testAccount.test.d.ts +1 -0
  52. package/commands/__tests__/testAccount.test.js +60 -0
  53. package/commands/__tests__/theme.test.d.ts +1 -0
  54. package/commands/__tests__/theme.test.js +52 -0
  55. package/commands/account/__tests__/auth.test.d.ts +1 -0
  56. package/commands/account/__tests__/auth.test.js +31 -0
  57. package/commands/account/__tests__/clean.test.d.ts +1 -0
  58. package/commands/account/__tests__/clean.test.js +33 -0
  59. package/commands/account/__tests__/createOverride.test.d.ts +1 -0
  60. package/commands/account/__tests__/createOverride.test.js +37 -0
  61. package/commands/account/__tests__/info.test.d.ts +1 -0
  62. package/commands/account/__tests__/info.test.js +33 -0
  63. package/commands/account/__tests__/list.test.d.ts +1 -0
  64. package/commands/account/__tests__/list.test.js +33 -0
  65. package/commands/account/__tests__/remove.test.d.ts +1 -0
  66. package/commands/account/__tests__/remove.test.js +41 -0
  67. package/commands/account/__tests__/removeOverride.d.ts +1 -0
  68. package/commands/account/__tests__/removeOverride.js +30 -0
  69. package/commands/account/__tests__/rename.test.d.ts +1 -0
  70. package/commands/account/__tests__/rename.test.js +47 -0
  71. package/commands/account/__tests__/use.test.d.ts +1 -0
  72. package/commands/account/__tests__/use.test.js +37 -0
  73. package/commands/app/__tests__/migrate.test.d.ts +1 -0
  74. package/commands/app/__tests__/migrate.test.js +129 -0
  75. package/commands/app/secret/__tests__/add.test.d.ts +1 -0
  76. package/commands/app/secret/__tests__/add.test.js +33 -0
  77. package/commands/app/secret/__tests__/delete.test.d.ts +1 -0
  78. package/commands/app/secret/__tests__/delete.test.js +33 -0
  79. package/commands/app/secret/__tests__/list.test.d.ts +1 -0
  80. package/commands/app/secret/__tests__/list.test.js +30 -0
  81. package/commands/app/secret/__tests__/update.test.d.ts +1 -0
  82. package/commands/app/secret/__tests__/update.test.js +33 -0
  83. package/commands/app.js +1 -6
  84. package/commands/customObject/__tests__/create.test.d.ts +1 -0
  85. package/commands/customObject/__tests__/create.test.js +45 -0
  86. package/commands/customObject/__tests__/schema.test.d.ts +1 -0
  87. package/commands/customObject/__tests__/schema.test.js +58 -0
  88. package/commands/customObject/schema/__tests__/create.test.d.ts +1 -0
  89. package/commands/customObject/schema/__tests__/create.test.js +33 -0
  90. package/commands/customObject/schema/__tests__/delete.test.d.ts +1 -0
  91. package/commands/customObject/schema/__tests__/delete.test.js +47 -0
  92. package/commands/customObject/schema/__tests__/fetch-all.test.d.ts +1 -0
  93. package/commands/customObject/schema/__tests__/fetch-all.test.js +46 -0
  94. package/commands/customObject/schema/__tests__/fetch.test.d.ts +1 -0
  95. package/commands/customObject/schema/__tests__/fetch.test.js +50 -0
  96. package/commands/customObject/schema/__tests__/list.test.d.ts +1 -0
  97. package/commands/customObject/schema/__tests__/list.test.js +34 -0
  98. package/commands/customObject/schema/__tests__/update.test.d.ts +1 -0
  99. package/commands/customObject/schema/__tests__/update.test.js +45 -0
  100. package/commands/fetch.js +0 -1
  101. package/commands/filemanager/__tests__/fetch.test.d.ts +1 -0
  102. package/commands/filemanager/__tests__/fetch.test.js +37 -0
  103. package/commands/filemanager/__tests__/upload.test.d.ts +1 -0
  104. package/commands/filemanager/__tests__/upload.test.js +35 -0
  105. package/commands/hubdb/__tests__/clear.test.d.ts +1 -0
  106. package/commands/hubdb/__tests__/clear.test.js +33 -0
  107. package/commands/hubdb/__tests__/create.test.d.ts +1 -0
  108. package/commands/hubdb/__tests__/create.test.js +33 -0
  109. package/commands/hubdb/__tests__/delete.test.d.ts +1 -0
  110. package/commands/hubdb/__tests__/delete.test.js +33 -0
  111. package/commands/hubdb/__tests__/fetch.test.d.ts +1 -0
  112. package/commands/hubdb/__tests__/fetch.test.js +33 -0
  113. package/commands/hubdb/__tests__/list.test.d.ts +1 -0
  114. package/commands/hubdb/__tests__/list.test.js +101 -0
  115. package/commands/logs.js +0 -1
  116. package/commands/mcp/__tests__/setup.test.d.ts +1 -0
  117. package/commands/mcp/__tests__/setup.test.js +31 -0
  118. package/commands/mcp/__tests__/start.test.d.ts +1 -0
  119. package/commands/mcp/__tests__/start.test.js +32 -0
  120. package/commands/project/__tests__/add.test.d.ts +1 -0
  121. package/commands/project/__tests__/add.test.js +48 -0
  122. package/commands/project/__tests__/create.test.d.ts +1 -0
  123. package/commands/project/__tests__/create.test.js +45 -0
  124. package/commands/project/__tests__/deploy.test.d.ts +1 -0
  125. package/commands/project/__tests__/deploy.test.js +344 -0
  126. package/commands/project/__tests__/devUnifiedFlow.test.d.ts +1 -0
  127. package/commands/project/__tests__/devUnifiedFlow.test.js +419 -0
  128. package/commands/project/__tests__/download.test.d.ts +1 -0
  129. package/commands/project/__tests__/download.test.js +44 -0
  130. package/commands/project/__tests__/fixtures/exampleProject.json +33 -0
  131. package/commands/project/__tests__/installDeps.test.d.ts +1 -0
  132. package/commands/project/__tests__/installDeps.test.js +180 -0
  133. package/commands/project/__tests__/listBuilds.test.d.ts +1 -0
  134. package/commands/project/__tests__/listBuilds.test.js +43 -0
  135. package/commands/project/__tests__/logs.test.d.ts +1 -0
  136. package/commands/project/__tests__/logs.test.js +246 -0
  137. package/commands/project/__tests__/migrate.test.d.ts +1 -0
  138. package/commands/project/__tests__/migrate.test.js +116 -0
  139. package/commands/project/__tests__/migrateApp.test.d.ts +1 -0
  140. package/commands/project/__tests__/migrateApp.test.js +87 -0
  141. package/commands/project/__tests__/open.test.d.ts +1 -0
  142. package/commands/project/__tests__/open.test.js +44 -0
  143. package/commands/project/__tests__/profile.test.d.ts +1 -0
  144. package/commands/project/__tests__/profile.test.js +47 -0
  145. package/commands/project/__tests__/upload.test.d.ts +1 -0
  146. package/commands/project/__tests__/upload.test.js +48 -0
  147. package/commands/project/__tests__/watch.test.d.ts +1 -0
  148. package/commands/project/__tests__/watch.test.js +40 -0
  149. package/commands/project/dev/unifiedFlow.js +1 -1
  150. package/commands/sandbox/__tests__/create.test.d.ts +1 -0
  151. package/commands/sandbox/__tests__/create.test.js +36 -0
  152. package/commands/sandbox/__tests__/delete.test.d.ts +1 -0
  153. package/commands/sandbox/__tests__/delete.test.js +36 -0
  154. package/commands/secret/__tests__/addSecret.test.d.ts +1 -0
  155. package/commands/secret/__tests__/addSecret.test.js +34 -0
  156. package/commands/secret/__tests__/deleteSecret.test.d.ts +1 -0
  157. package/commands/secret/__tests__/deleteSecret.test.js +46 -0
  158. package/commands/secret/__tests__/listSecret.test.d.ts +1 -0
  159. package/commands/secret/__tests__/listSecret.test.js +34 -0
  160. package/commands/secret/__tests__/updateSecret.test.d.ts +1 -0
  161. package/commands/secret/__tests__/updateSecret.test.js +34 -0
  162. package/commands/testAccount/__tests__/create.test.d.ts +1 -0
  163. package/commands/testAccount/__tests__/create.test.js +38 -0
  164. package/commands/testAccount/__tests__/createConfig.test.d.ts +1 -0
  165. package/commands/testAccount/__tests__/createConfig.test.js +40 -0
  166. package/commands/testAccount/__tests__/delete.test.d.ts +1 -0
  167. package/commands/testAccount/__tests__/delete.test.js +36 -0
  168. package/commands/testAccount/create.js +24 -14
  169. package/commands/theme/__tests__/generate-selectors.test.d.ts +1 -0
  170. package/commands/theme/__tests__/generate-selectors.test.js +33 -0
  171. package/commands/theme/__tests__/marketplace-validate.test.d.ts +1 -0
  172. package/commands/theme/__tests__/marketplace-validate.test.js +41 -0
  173. package/commands/theme/__tests__/preview.test.d.ts +1 -0
  174. package/commands/theme/__tests__/preview.test.js +65 -0
  175. package/lang/en.d.ts +6 -65
  176. package/lang/en.js +6 -65
  177. package/lib/__tests__/accountTypes.test.d.ts +1 -0
  178. package/lib/__tests__/accountTypes.test.js +100 -0
  179. package/lib/__tests__/buildAccount.test.d.ts +1 -0
  180. package/lib/__tests__/buildAccount.test.js +231 -0
  181. package/lib/__tests__/commonOpts.test.d.ts +1 -0
  182. package/lib/__tests__/commonOpts.test.js +87 -0
  183. package/lib/__tests__/dependencyManagement.test.d.ts +1 -0
  184. package/lib/__tests__/dependencyManagement.test.js +180 -0
  185. package/lib/__tests__/developerTestAccounts.test.d.ts +1 -0
  186. package/lib/__tests__/developerTestAccounts.test.js +180 -0
  187. package/lib/__tests__/hasFeature.test.d.ts +1 -0
  188. package/lib/__tests__/hasFeature.test.js +37 -0
  189. package/lib/__tests__/npm.test.d.ts +1 -0
  190. package/lib/__tests__/npm.test.js +62 -0
  191. package/lib/__tests__/oauth.test.d.ts +1 -0
  192. package/lib/__tests__/oauth.test.js +113 -0
  193. package/lib/__tests__/parsing.test.d.ts +1 -0
  194. package/lib/__tests__/parsing.test.js +36 -0
  195. package/lib/__tests__/polling.test.d.ts +1 -0
  196. package/lib/__tests__/polling.test.js +78 -0
  197. package/lib/__tests__/process.test.d.ts +1 -0
  198. package/lib/__tests__/process.test.js +90 -0
  199. package/lib/__tests__/projectProfiles.test.d.ts +1 -0
  200. package/lib/__tests__/projectProfiles.test.js +134 -0
  201. package/lib/__tests__/sandboxSync.test.d.ts +1 -0
  202. package/lib/__tests__/sandboxSync.test.js +131 -0
  203. package/lib/__tests__/sandboxes.test.d.ts +1 -0
  204. package/lib/__tests__/sandboxes.test.js +148 -0
  205. package/lib/__tests__/serverlessLogs.test.d.ts +1 -0
  206. package/lib/__tests__/serverlessLogs.test.js +154 -0
  207. package/lib/__tests__/usageTracking.test.d.ts +1 -0
  208. package/lib/__tests__/usageTracking.test.js +171 -0
  209. package/lib/__tests__/validation.test.d.ts +1 -0
  210. package/lib/__tests__/validation.test.js +145 -0
  211. package/lib/__tests__/yargsUtils.test.d.ts +1 -0
  212. package/lib/__tests__/yargsUtils.test.js +74 -0
  213. package/lib/app/__tests__/migrate.test.d.ts +1 -0
  214. package/lib/app/__tests__/migrate.test.js +495 -0
  215. package/lib/app/__tests__/migrate_legacy.test.d.ts +1 -0
  216. package/lib/app/__tests__/migrate_legacy.test.js +136 -0
  217. package/lib/buildAccount.d.ts +1 -7
  218. package/lib/buildAccount.js +4 -54
  219. package/lib/doctor/Diagnosis.js +11 -11
  220. package/lib/doctor/Doctor.js +42 -42
  221. package/lib/doctor/__tests__/Diagnosis.test.d.ts +1 -0
  222. package/lib/doctor/__tests__/Diagnosis.test.js +87 -0
  223. package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.d.ts +1 -0
  224. package/lib/doctor/__tests__/DiagnosticInfoBuilder.test.js +172 -0
  225. package/lib/doctor/__tests__/Doctor.test.d.ts +1 -0
  226. package/lib/doctor/__tests__/Doctor.test.js +398 -0
  227. package/lib/mcp/setup.js +18 -2
  228. package/lib/middleware/__test__/configMiddleware.test.js +12 -12
  229. package/lib/middleware/__test__/gitMiddleware.test.js +4 -4
  230. package/lib/middleware/__test__/notificationsMiddleware.test.js +2 -2
  231. package/lib/middleware/__test__/requestMiddleware.test.js +2 -2
  232. package/lib/middleware/__test__/yargsChecksMiddleware.test.js +7 -7
  233. package/lib/middleware/notificationsMiddleware.js +16 -13
  234. package/lib/projects/__tests__/AppDevModeInterface.test.d.ts +1 -0
  235. package/lib/projects/__tests__/AppDevModeInterface.test.js +517 -0
  236. package/lib/projects/__tests__/LocalDevProcess.test.d.ts +1 -0
  237. package/lib/projects/__tests__/LocalDevProcess.test.js +314 -0
  238. package/lib/projects/__tests__/LocalDevWebsocketServer.test.d.ts +1 -0
  239. package/lib/projects/__tests__/LocalDevWebsocketServer.test.js +175 -0
  240. package/lib/projects/__tests__/ProjectLogsManager.test.d.ts +1 -0
  241. package/lib/projects/__tests__/ProjectLogsManager.test.js +191 -0
  242. package/lib/projects/__tests__/buildAndDeploy.test.d.ts +1 -0
  243. package/lib/projects/__tests__/buildAndDeploy.test.js +25 -0
  244. package/lib/projects/__tests__/components.test.d.ts +1 -0
  245. package/lib/projects/__tests__/components.test.js +186 -0
  246. package/lib/projects/__tests__/projects.test.d.ts +1 -0
  247. package/lib/projects/__tests__/projects.test.js +89 -0
  248. package/lib/projects/__tests__/structure.test.d.ts +1 -0
  249. package/lib/projects/__tests__/structure.test.js +249 -0
  250. package/lib/projects/add/__tests__/legacyAddComponent.test.d.ts +1 -0
  251. package/lib/projects/add/__tests__/legacyAddComponent.test.js +206 -0
  252. package/lib/projects/add/__tests__/v3AddComponent.test.d.ts +1 -0
  253. package/lib/projects/add/__tests__/v3AddComponent.test.js +190 -0
  254. package/lib/projects/create/__tests__/legacy.test.d.ts +1 -0
  255. package/lib/projects/create/__tests__/legacy.test.js +126 -0
  256. package/lib/projects/create/__tests__/v3.test.d.ts +1 -0
  257. package/lib/projects/create/__tests__/v3.test.js +80 -0
  258. package/lib/projects/localDev/DevServerManager.js +0 -1
  259. package/lib/projects/localDev/helpers.d.ts +1 -1
  260. package/lib/projects/localDev/helpers.js +2 -2
  261. package/lib/projects/structure.d.ts +2 -2
  262. package/lib/projects/upload.d.ts +1 -2
  263. package/lib/projects/upload.js +0 -1
  264. package/lib/prompts/__tests__/downloadProjectPrompt.test.d.ts +1 -0
  265. package/lib/prompts/__tests__/downloadProjectPrompt.test.js +30 -0
  266. package/lib/prompts/__tests__/projectsLogsPrompt.test.d.ts +1 -0
  267. package/lib/prompts/__tests__/projectsLogsPrompt.test.js +42 -0
  268. package/lib/prompts/createDeveloperTestAccountConfigPrompt.d.ts +10 -9
  269. package/lib/prompts/createDeveloperTestAccountConfigPrompt.js +43 -81
  270. package/lib/schema.js +5 -1
  271. package/lib/ui/SpinniesManager.js +0 -1
  272. package/lib/ui/supportHyperlinks.js +2 -2
  273. package/lib/ui/supportsColor.js +2 -2
  274. package/lib/utils/hasFlag.d.ts +1 -0
  275. package/lib/utils/hasFlag.js +15 -0
  276. package/lib/yargsUtils.d.ts +2 -1
  277. package/lib/yargsUtils.js +3 -13
  278. package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.d.ts +1 -0
  279. package/mcp-server/tools/project/__tests__/AddFeatureToProject.test.js +152 -0
  280. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.d.ts +1 -0
  281. package/mcp-server/tools/project/__tests__/CreateProjectTool.test.js +129 -0
  282. package/mcp-server/tools/project/__tests__/DeployProject.test.d.ts +1 -0
  283. package/mcp-server/tools/project/__tests__/DeployProject.test.js +120 -0
  284. package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.d.ts +1 -0
  285. package/mcp-server/tools/project/__tests__/GuidedWalkthroughTool.test.js +127 -0
  286. package/mcp-server/tools/project/__tests__/UploadProjectTools.test.d.ts +1 -0
  287. package/mcp-server/tools/project/__tests__/UploadProjectTools.test.js +108 -0
  288. package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.d.ts +1 -0
  289. package/mcp-server/tools/project/__tests__/ValidateProjectTool.test.js +111 -0
  290. package/mcp-server/utils/__tests__/command.test.d.ts +1 -0
  291. package/mcp-server/utils/__tests__/command.test.js +47 -0
  292. package/mcp-server/utils/__tests__/project.test.d.ts +1 -0
  293. package/mcp-server/utils/__tests__/project.test.js +81 -0
  294. package/package.json +8 -8
  295. package/commands/app/install.d.ts +0 -8
  296. package/commands/app/install.js +0 -127
@@ -0,0 +1,134 @@
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
+ const path_1 = __importDefault(require("path"));
7
+ const project_parsing_lib_1 = require("@hubspot/project-parsing-lib");
8
+ const en_1 = require("../../lang/en");
9
+ const ui_1 = require("../ui");
10
+ const logger_1 = require("../ui/logger");
11
+ const exitCodes_1 = require("../enums/exitCodes");
12
+ const projectProfiles_1 = require("../projectProfiles");
13
+ // Mock dependencies
14
+ vi.mock('@hubspot/project-parsing-lib');
15
+ vi.mock('../ui');
16
+ vi.mock('../ui/logger');
17
+ vi.mock('../../lang/en');
18
+ // Mock process.exit
19
+ const mockExit = vi.spyOn(process, 'exit').mockImplementation(code => {
20
+ throw new Error(`Process.exit called with code ${code}`);
21
+ });
22
+ const mockedLoadHsProfileFile = project_parsing_lib_1.loadHsProfileFile;
23
+ const mockedGetHsProfileFilename = project_parsing_lib_1.getHsProfileFilename;
24
+ const mockedGetAllHsProfiles = project_parsing_lib_1.getAllHsProfiles;
25
+ const mockedUiBetaTag = ui_1.uiBetaTag;
26
+ const mockedUiLine = ui_1.uiLine;
27
+ const mockedUiLogger = logger_1.uiLogger;
28
+ describe('lib/projectProfiles', () => {
29
+ describe('logProfileHeader()', () => {
30
+ it('should log profile header with correct format', () => {
31
+ const profileName = 'test-profile';
32
+ const filename = 'test-profile.hsprofile';
33
+ mockedGetHsProfileFilename.mockReturnValue(filename);
34
+ (0, projectProfiles_1.logProfileHeader)(profileName);
35
+ expect(mockedUiLine).toHaveBeenCalled();
36
+ expect(mockedUiBetaTag).toHaveBeenCalledWith(en_1.lib.projectProfiles.logs.usingProfile(filename));
37
+ expect(mockedUiLogger.log).toHaveBeenCalledWith('');
38
+ });
39
+ });
40
+ describe('logProfileFooter()', () => {
41
+ const mockProfile = {
42
+ accountId: 123,
43
+ variables: {
44
+ key1: 'value1',
45
+ key2: 'value2',
46
+ },
47
+ };
48
+ it('should log profile footer with account ID', () => {
49
+ (0, projectProfiles_1.logProfileFooter)(mockProfile);
50
+ expect(mockedUiLogger.log).toHaveBeenCalledWith(en_1.lib.projectProfiles.logs.profileTargetAccount(mockProfile.accountId));
51
+ expect(mockedUiLine).toHaveBeenCalled();
52
+ expect(mockedUiLogger.log).toHaveBeenCalledWith('');
53
+ });
54
+ it('should log variables when includeVariables is true', () => {
55
+ (0, projectProfiles_1.logProfileFooter)(mockProfile, true);
56
+ expect(mockedUiLogger.log).toHaveBeenCalledWith(en_1.lib.projectProfiles.logs.profileTargetAccount(mockProfile.accountId));
57
+ expect(mockedUiLogger.log).toHaveBeenCalledWith('');
58
+ expect(mockedUiLogger.log).toHaveBeenCalledWith(en_1.lib.projectProfiles.logs.profileVariables);
59
+ expect(mockedUiLogger.log).toHaveBeenCalledWith(' key1: value1');
60
+ expect(mockedUiLogger.log).toHaveBeenCalledWith(' key2: value2');
61
+ expect(mockedUiLine).toHaveBeenCalled();
62
+ expect(mockedUiLogger.log).toHaveBeenCalledWith('');
63
+ });
64
+ });
65
+ describe('loadProfile()', () => {
66
+ const mockProjectConfig = {
67
+ srcDir: 'src',
68
+ name: 'test-project',
69
+ platformVersion: '1.0.0',
70
+ };
71
+ const mockProjectDir = '/test/project';
72
+ const mockProfileName = 'test-profile';
73
+ const mockProfile = {
74
+ accountId: 123,
75
+ };
76
+ it('should return undefined when project config is missing', () => {
77
+ const result = (0, projectProfiles_1.loadProfile)(null, mockProjectDir, mockProfileName);
78
+ expect(result).toBeUndefined();
79
+ expect(mockedUiLogger.error).toHaveBeenCalledWith(en_1.lib.projectProfiles.loadProfile.errors.noProjectConfig);
80
+ });
81
+ it('should return undefined when profile is not found', () => {
82
+ mockedLoadHsProfileFile.mockReturnValue(null);
83
+ const filename = 'test-profile.hsprofile';
84
+ mockedGetHsProfileFilename.mockReturnValue(filename);
85
+ const result = (0, projectProfiles_1.loadProfile)(mockProjectConfig, mockProjectDir, mockProfileName);
86
+ expect(result).toBeUndefined();
87
+ expect(mockedUiLogger.error).toHaveBeenCalledWith(en_1.lib.projectProfiles.loadProfile.errors.profileNotFound(filename));
88
+ });
89
+ it('should return undefined when profile has no account ID', () => {
90
+ mockedLoadHsProfileFile.mockReturnValue({});
91
+ const filename = 'test-profile.hsprofile';
92
+ mockedGetHsProfileFilename.mockReturnValue(filename);
93
+ const result = (0, projectProfiles_1.loadProfile)(mockProjectConfig, mockProjectDir, mockProfileName);
94
+ expect(result).toBeUndefined();
95
+ expect(mockedUiLogger.error).toHaveBeenCalledWith(en_1.lib.projectProfiles.loadProfile.errors.missingAccountId(filename));
96
+ });
97
+ it('should return undefined when profile loading fails', () => {
98
+ mockedLoadHsProfileFile.mockImplementation(() => {
99
+ throw new Error('Load failed');
100
+ });
101
+ const filename = 'test-profile.hsprofile';
102
+ mockedGetHsProfileFilename.mockReturnValue(filename);
103
+ const result = (0, projectProfiles_1.loadProfile)(mockProjectConfig, mockProjectDir, mockProfileName);
104
+ expect(result).toBeUndefined();
105
+ expect(mockedUiLogger.error).toHaveBeenCalledWith(en_1.lib.projectProfiles.loadProfile.errors.failedToLoadProfile(filename));
106
+ });
107
+ it('should return profile when loading succeeds', () => {
108
+ mockedLoadHsProfileFile.mockReturnValue(mockProfile);
109
+ const result = (0, projectProfiles_1.loadProfile)(mockProjectConfig, mockProjectDir, mockProfileName);
110
+ expect(result).toEqual(mockProfile);
111
+ expect(mockedLoadHsProfileFile).toHaveBeenCalledWith(path_1.default.join(mockProjectDir, mockProjectConfig.srcDir), mockProfileName);
112
+ });
113
+ });
114
+ describe('exitIfUsingProfiles()', () => {
115
+ const mockProjectConfig = {
116
+ srcDir: 'src',
117
+ name: 'test-project',
118
+ platformVersion: '1.0.0',
119
+ };
120
+ const mockProjectDir = '/test/project';
121
+ it('should not exit when no profiles exist', async () => {
122
+ mockedGetAllHsProfiles.mockResolvedValue([]);
123
+ await (0, projectProfiles_1.exitIfUsingProfiles)(mockProjectConfig, mockProjectDir);
124
+ expect(mockedUiLogger.error).not.toHaveBeenCalled();
125
+ expect(mockExit).not.toHaveBeenCalled();
126
+ });
127
+ it('should exit with error when profiles exist', async () => {
128
+ mockedGetAllHsProfiles.mockResolvedValue(['profile1', 'profile2']);
129
+ await expect((0, projectProfiles_1.exitIfUsingProfiles)(mockProjectConfig, mockProjectDir)).rejects.toThrow(`Process.exit called with code ${exitCodes_1.EXIT_CODES.ERROR}`);
130
+ expect(mockedUiLogger.error).toHaveBeenCalledWith(en_1.lib.projectProfiles.exitIfUsingProfiles.errors.noProfileSpecified);
131
+ expect(mockExit).toHaveBeenCalledWith(exitCodes_1.EXIT_CODES.ERROR);
132
+ });
133
+ });
134
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,131 @@
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
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
7
+ const sandboxSync_1 = require("@hubspot/local-dev-lib/api/sandboxSync");
8
+ const config_1 = require("@hubspot/local-dev-lib/config");
9
+ const config_2 = require("@hubspot/local-dev-lib/constants/config");
10
+ const testUtils_1 = require("../testUtils");
11
+ const sandboxes_1 = require("../sandboxes");
12
+ const sandboxSync_2 = require("../sandboxSync");
13
+ const SpinniesManager_1 = __importDefault(require("../ui/SpinniesManager"));
14
+ vi.mock('@hubspot/local-dev-lib/logger');
15
+ vi.mock('@hubspot/local-dev-lib/api/sandboxSync');
16
+ vi.mock('@hubspot/local-dev-lib/config');
17
+ vi.mock('../sandboxes');
18
+ vi.mock('../ui/SpinniesManager');
19
+ const mockedLogger = logger_1.logger;
20
+ const mockedInitiateSync = sandboxSync_1.initiateSync;
21
+ const mockedGetAccountId = config_1.getAccountId;
22
+ const mockedGetAvailableSyncTypes = sandboxes_1.getAvailableSyncTypes;
23
+ const mockedSpinniesInit = SpinniesManager_1.default.init;
24
+ const mockedSpinniesAdd = SpinniesManager_1.default.add;
25
+ const mockedSpinniesSucceed = SpinniesManager_1.default.succeed;
26
+ const mockedSpinniesFail = SpinniesManager_1.default.fail;
27
+ describe('lib/sandboxSync', () => {
28
+ const mockEnv = 'qa';
29
+ const mockParentAccount = {
30
+ name: 'Parent Account',
31
+ portalId: 123,
32
+ accountType: config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
33
+ env: mockEnv,
34
+ };
35
+ const mockChildAccount = {
36
+ name: 'Child Account',
37
+ portalId: 456,
38
+ accountType: config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
39
+ env: mockEnv,
40
+ };
41
+ const mockSyncTasks = [{ type: 'mock-sync-type' }];
42
+ beforeEach(() => {
43
+ mockedGetAccountId
44
+ .mockReturnValueOnce(mockChildAccount.portalId)
45
+ .mockReturnValueOnce(mockParentAccount.portalId);
46
+ mockedGetAvailableSyncTypes.mockResolvedValue(mockSyncTasks);
47
+ });
48
+ describe('syncSandbox()', () => {
49
+ it('successfully syncs a sandbox with provided sync tasks', async () => {
50
+ mockedInitiateSync.mockResolvedValue({ status: 'SUCCESS' });
51
+ await (0, sandboxSync_2.syncSandbox)(mockChildAccount, mockParentAccount, mockEnv, mockSyncTasks);
52
+ expect(mockedSpinniesInit).toHaveBeenCalled();
53
+ expect(mockedSpinniesAdd).toHaveBeenCalled();
54
+ expect(mockedInitiateSync).toHaveBeenCalledWith(mockParentAccount.portalId, mockChildAccount.portalId, mockSyncTasks, mockChildAccount.portalId);
55
+ expect(mockedSpinniesSucceed).toHaveBeenCalled();
56
+ });
57
+ it('fetches sync types when no tasks are provided', async () => {
58
+ mockedInitiateSync.mockResolvedValue({ status: 'SUCCESS' });
59
+ await (0, sandboxSync_2.syncSandbox)(mockChildAccount, mockParentAccount, mockEnv, []);
60
+ expect(mockedGetAvailableSyncTypes).toHaveBeenCalledWith(mockParentAccount, mockChildAccount);
61
+ expect(mockedGetAvailableSyncTypes).toHaveBeenCalledWith(mockParentAccount, mockChildAccount);
62
+ expect(mockedInitiateSync).toHaveBeenCalled();
63
+ });
64
+ it('throws error when account IDs are missing', async () => {
65
+ mockedGetAccountId.mockReset();
66
+ mockedGetAccountId.mockReturnValue(null);
67
+ const errorRegex = new RegExp(`Couldn't sync ${mockChildAccount.portalId} because your account has been removed from`);
68
+ await expect((0, sandboxSync_2.syncSandbox)(mockChildAccount, mockParentAccount, mockEnv, mockSyncTasks)).rejects.toThrow(errorRegex);
69
+ });
70
+ it('handles sync in progress error', async () => {
71
+ const error = (0, testUtils_1.mockHubSpotHttpError)('', {
72
+ status: 429,
73
+ data: {
74
+ category: 'RATE_LIMITS',
75
+ subCategory: 'sandboxes-sync-api.SYNC_IN_PROGRESS',
76
+ },
77
+ });
78
+ mockedInitiateSync.mockRejectedValue(error);
79
+ await expect((0, sandboxSync_2.syncSandbox)(mockChildAccount, mockParentAccount, mockEnv, mockSyncTasks)).rejects.toEqual(error);
80
+ expect(mockedSpinniesFail).toHaveBeenCalled();
81
+ expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/Couldn't run the sync because there's another sync in progress/));
82
+ });
83
+ it('handles invalid user error', async () => {
84
+ const error = (0, testUtils_1.mockHubSpotHttpError)('', {
85
+ status: 403,
86
+ data: {
87
+ category: 'BANNED',
88
+ subCategory: 'sandboxes-sync-api.SYNC_NOT_ALLOWED_INVALID_USER',
89
+ },
90
+ });
91
+ mockedInitiateSync.mockRejectedValue(error);
92
+ await expect((0, sandboxSync_2.syncSandbox)(mockChildAccount, mockParentAccount, mockEnv, mockSyncTasks)).rejects.toEqual(error);
93
+ expect(mockedSpinniesFail).toHaveBeenCalled();
94
+ expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/because your account has been removed from/));
95
+ });
96
+ it('handles not super admin error', async () => {
97
+ const error = (0, testUtils_1.mockHubSpotHttpError)('', {
98
+ status: 403,
99
+ data: {
100
+ category: 'BANNED',
101
+ subCategory: 'sandboxes-sync-api.SYNC_NOT_ALLOWED_INVALID_USERID',
102
+ },
103
+ });
104
+ mockedInitiateSync.mockRejectedValue(error);
105
+ await expect((0, sandboxSync_2.syncSandbox)(mockChildAccount, mockParentAccount, mockEnv, mockSyncTasks)).rejects.toEqual(error);
106
+ expect(mockedSpinniesFail).toHaveBeenCalled();
107
+ expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/Couldn't run the sync because you are not a super admin in/));
108
+ });
109
+ it('handles sandbox not found error', async () => {
110
+ const error = (0, testUtils_1.mockHubSpotHttpError)('', {
111
+ status: 404,
112
+ data: {
113
+ category: 'OBJECT_NOT_FOUND',
114
+ subCategory: 'SandboxErrors.SANDBOX_NOT_FOUND',
115
+ },
116
+ });
117
+ mockedInitiateSync.mockRejectedValue(error);
118
+ await expect((0, sandboxSync_2.syncSandbox)(mockChildAccount, mockParentAccount, mockEnv, mockSyncTasks)).rejects.toEqual(error);
119
+ expect(mockedSpinniesFail).toHaveBeenCalled();
120
+ expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/may have been deleted through the UI/));
121
+ });
122
+ it('displays slim info message when specified', async () => {
123
+ mockedInitiateSync.mockResolvedValue({ status: 'SUCCESS' });
124
+ await (0, sandboxSync_2.syncSandbox)(mockChildAccount, mockParentAccount, mockEnv, mockSyncTasks, true);
125
+ expect(mockedLogger.info).not.toHaveBeenCalled();
126
+ expect(mockedSpinniesSucceed).toHaveBeenCalledWith('sandboxSync', expect.objectContaining({
127
+ text: expect.stringMatching(/Initiated sync of object definitions from production to /),
128
+ }));
129
+ });
130
+ });
131
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const logger_1 = require("@hubspot/local-dev-lib/logger");
4
+ const sandboxHubs_1 = require("@hubspot/local-dev-lib/api/sandboxHubs");
5
+ const sandboxSync_1 = require("@hubspot/local-dev-lib/api/sandboxSync");
6
+ const config_1 = require("@hubspot/local-dev-lib/config");
7
+ const config_2 = require("@hubspot/local-dev-lib/constants/config");
8
+ const testUtils_1 = require("../testUtils");
9
+ const sandboxes_1 = require("../sandboxes");
10
+ vi.mock('@hubspot/local-dev-lib/logger');
11
+ vi.mock('@hubspot/local-dev-lib/api/sandboxHubs');
12
+ vi.mock('@hubspot/local-dev-lib/api/sandboxSync');
13
+ vi.mock('@hubspot/local-dev-lib/config');
14
+ const mockedGetAccountId = config_1.getAccountId;
15
+ const mockedGetSandboxUsageLimits = sandboxHubs_1.getSandboxUsageLimits;
16
+ const mockedFetchTypes = sandboxSync_1.fetchTypes;
17
+ const mockedGetConfigAccounts = config_1.getConfigAccounts;
18
+ const mockedLogger = logger_1.logger;
19
+ describe('lib/sandboxes', () => {
20
+ describe('getSandboxTypeAsString()', () => {
21
+ it('returns "development" for development sandbox type', () => {
22
+ expect((0, sandboxes_1.getSandboxTypeAsString)(config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)).toBe('development');
23
+ });
24
+ it('returns "standard" for standard sandbox type', () => {
25
+ expect((0, sandboxes_1.getSandboxTypeAsString)(config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX)).toBe('standard');
26
+ });
27
+ it('returns "standard" for undefined input', () => {
28
+ expect((0, sandboxes_1.getSandboxTypeAsString)(undefined)).toBe('standard');
29
+ });
30
+ });
31
+ describe('getHasSandboxesByType()', () => {
32
+ const mockParentAccount = {
33
+ name: 'Parent Account',
34
+ portalId: 123,
35
+ authType: undefined,
36
+ accountType: config_2.HUBSPOT_ACCOUNT_TYPES.STANDARD_SANDBOX,
37
+ env: 'qa',
38
+ };
39
+ it('returns true when sandbox of specified type exists', () => {
40
+ mockedGetAccountId.mockReturnValue(mockParentAccount.portalId);
41
+ mockedGetConfigAccounts.mockReturnValue([
42
+ mockParentAccount,
43
+ {
44
+ ...mockParentAccount,
45
+ parentAccountId: 123,
46
+ accountType: config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX,
47
+ },
48
+ ]);
49
+ expect((0, sandboxes_1.getHasSandboxesByType)(mockParentAccount, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)).toBe(true);
50
+ });
51
+ it('returns false when no sandbox of specified type exists', () => {
52
+ mockedGetConfigAccounts.mockReturnValue([mockParentAccount]);
53
+ expect((0, sandboxes_1.getHasSandboxesByType)(mockParentAccount, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX)).toBe(false);
54
+ });
55
+ });
56
+ describe('getAvailableSyncTypes()', () => {
57
+ const mockParentAccount = {
58
+ name: 'Parent Account',
59
+ portalId: 123,
60
+ env: 'qa',
61
+ };
62
+ const mockChildAccount = {
63
+ ...mockParentAccount,
64
+ portalId: 456,
65
+ };
66
+ it('returns available sync types when fetch is successful', async () => {
67
+ const mockSyncTypes = [{ name: 'type1' }, { name: 'type2' }];
68
+ mockedGetAccountId
69
+ .mockReturnValue(mockParentAccount.portalId)
70
+ .mockReturnValue(mockChildAccount.portalId);
71
+ mockedFetchTypes.mockResolvedValue({
72
+ data: { results: mockSyncTypes },
73
+ });
74
+ const result = await (0, sandboxes_1.getAvailableSyncTypes)(mockParentAccount, mockChildAccount);
75
+ expect(result).toEqual([{ type: 'type1' }, { type: 'type2' }]);
76
+ });
77
+ it('throws error when sync types fetch fails', async () => {
78
+ mockedFetchTypes.mockResolvedValue({ data: { results: null } });
79
+ await expect((0, sandboxes_1.getAvailableSyncTypes)(mockParentAccount, mockChildAccount)).rejects.toThrow(/Unable to fetch available sandbox sync types/);
80
+ });
81
+ });
82
+ describe('validateSandboxUsageLimits()', () => {
83
+ const mockAccount = {
84
+ name: 'Test Account',
85
+ portalId: 123,
86
+ authType: undefined,
87
+ env: 'qa',
88
+ };
89
+ it('validates successfully when limits are not reached', async () => {
90
+ mockedGetAccountId.mockReturnValue(mockAccount.portalId);
91
+ mockedGetSandboxUsageLimits.mockResolvedValue({
92
+ data: {
93
+ usage: { DEVELOPER: { available: 1, limit: 3 } },
94
+ },
95
+ });
96
+ await expect((0, sandboxes_1.validateSandboxUsageLimits)(mockAccount, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX, 'qa')).resolves.not.toThrow();
97
+ });
98
+ it('throws error when development sandbox limit is reached', async () => {
99
+ mockedGetAccountId.mockReturnValue(mockAccount.portalId);
100
+ mockedGetConfigAccounts.mockReturnValue([]);
101
+ mockedGetSandboxUsageLimits.mockResolvedValue({
102
+ data: {
103
+ usage: { DEVELOPER: { available: 0, limit: 1 } },
104
+ },
105
+ });
106
+ await expect((0, sandboxes_1.validateSandboxUsageLimits)(mockAccount, config_2.HUBSPOT_ACCOUNT_TYPES.DEVELOPMENT_SANDBOX, 'qa')).rejects.toThrow(/reached the limit of 1 development sandbox/);
107
+ });
108
+ });
109
+ describe('handleSandboxCreateError()', () => {
110
+ const mockEnv = 'qa';
111
+ const mockName = 'Test Sandbox';
112
+ const mockAccountId = 123;
113
+ it('handles missing scope error', () => {
114
+ const error = (0, testUtils_1.mockHubSpotHttpError)('missing scopes error', {
115
+ status: 403,
116
+ data: {
117
+ message: 'Missing scopes error',
118
+ category: 'MISSING_SCOPES',
119
+ },
120
+ });
121
+ expect(() => (0, sandboxes_1.handleSandboxCreateError)(error, mockEnv, mockName, mockAccountId)).toThrow(error);
122
+ expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/The personal access key you provided doesn't include sandbox permissions/));
123
+ expect(mockedLogger.info).toHaveBeenCalledWith(expect.stringMatching(/To update CLI permissions for/));
124
+ });
125
+ it('handles user access not allowed error', () => {
126
+ const error = (0, testUtils_1.mockHubSpotHttpError)('user access not allowed error', {
127
+ status: 403,
128
+ data: {
129
+ category: 'BANNED',
130
+ subCategory: 'SandboxErrors.USER_ACCESS_NOT_ALLOWED',
131
+ },
132
+ });
133
+ expect(() => (0, sandboxes_1.handleSandboxCreateError)(error, mockEnv, mockName, mockAccountId)).toThrow(error);
134
+ expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/your permission set doesn't allow you to create the sandbox/));
135
+ });
136
+ it('handles 403 gating error', () => {
137
+ const error = (0, testUtils_1.mockHubSpotHttpError)('403 gating error', {
138
+ status: 403,
139
+ data: {
140
+ category: 'BANNED',
141
+ subCategory: 'SandboxErrors.DEVELOPMENT_SANDBOX_ACCESS_NOT_ALLOWED',
142
+ },
143
+ });
144
+ expect(() => (0, sandboxes_1.handleSandboxCreateError)(error, mockEnv, mockName, mockAccountId)).toThrow(error);
145
+ expect(mockedLogger.error).toHaveBeenCalledWith(expect.stringMatching(/does not have access to development sandboxes/));
146
+ });
147
+ });
148
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,154 @@
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
+ const mock_stdin_1 = __importDefault(require("mock-stdin"));
7
+ const serverlessFunctionLogs_1 = require("../ui/serverlessFunctionLogs");
8
+ const serverlessLogs_1 = require("../serverlessLogs");
9
+ vi.mock('../ui/serverlessFunctionLogs');
10
+ vi.mock('@hubspot/local-dev-lib/logger');
11
+ vi.mock('../ui/SpinniesManager', () => ({
12
+ default: {
13
+ init: vi.fn(),
14
+ add: vi.fn(),
15
+ remove: vi.fn(),
16
+ succeed: vi.fn(),
17
+ fail: vi.fn(),
18
+ stopAll: vi.fn(),
19
+ },
20
+ }));
21
+ vi.useFakeTimers();
22
+ const ACCOUNT_ID = 123;
23
+ describe('lib/serverlessLogs', () => {
24
+ describe('tailLogs()', () => {
25
+ let stdinMock;
26
+ beforeEach(() => {
27
+ // @ts-ignore - we don't need to mock the entire process object
28
+ vi.spyOn(process, 'exit').mockImplementation(() => { });
29
+ stdinMock = mock_stdin_1.default.stdin();
30
+ });
31
+ afterEach(() => {
32
+ vi.clearAllTimers();
33
+ stdinMock.restore();
34
+ });
35
+ it('calls tailCall() to get the next results', async () => {
36
+ const compact = false;
37
+ const fetchLatest = vi.fn(() => {
38
+ return Promise.resolve({
39
+ data: {
40
+ id: '1234',
41
+ executionTime: 510,
42
+ log: 'Log message',
43
+ error: { message: '', type: '', stackTrace: [] },
44
+ status: 'SUCCESS',
45
+ createdAt: 1620232011451,
46
+ memory: '70/128 MB',
47
+ duration: '53.40 ms',
48
+ },
49
+ status: 200,
50
+ statusText: 'OK',
51
+ headers: {},
52
+ config: {},
53
+ });
54
+ });
55
+ const tailCall = vi.fn(() => {
56
+ return Promise.resolve({
57
+ data: {
58
+ results: [],
59
+ paging: {
60
+ next: {
61
+ after: 'somehash',
62
+ },
63
+ },
64
+ },
65
+ status: 200,
66
+ statusText: 'OK',
67
+ headers: {},
68
+ config: {},
69
+ });
70
+ });
71
+ // @ts-ignore - headers is not used in the actual function and does not need to be mocked
72
+ await (0, serverlessLogs_1.tailLogs)(ACCOUNT_ID, 'name', fetchLatest, tailCall, compact);
73
+ vi.runOnlyPendingTimers();
74
+ expect(fetchLatest).toHaveBeenCalled();
75
+ expect(tailCall).toHaveBeenCalledTimes(2);
76
+ });
77
+ it('outputs results', async () => {
78
+ const compact = false;
79
+ const fetchLatest = vi.fn(() => {
80
+ return Promise.resolve({
81
+ data: {
82
+ id: '1234',
83
+ executionTime: 510,
84
+ log: 'Log message',
85
+ error: { message: '', type: '', stackTrace: [], statusCode: null },
86
+ status: 'SUCCESS',
87
+ createdAt: 1620232011451,
88
+ memory: '70/128 MB',
89
+ duration: '53.40 ms',
90
+ },
91
+ status: 200,
92
+ statusText: 'OK',
93
+ headers: {},
94
+ config: {},
95
+ });
96
+ });
97
+ const latestLogResponse = {
98
+ results: [
99
+ {
100
+ id: '456',
101
+ executionTime: 510,
102
+ log: 'Message 1',
103
+ error: null,
104
+ status: 'SUCCESS',
105
+ createdAt: 1620232011451,
106
+ memory: '70/128 MB',
107
+ duration: '53.40 ms',
108
+ },
109
+ {
110
+ id: '457',
111
+ executionTime: 510,
112
+ log: 'Message 2',
113
+ error: null,
114
+ status: 'SUCCESS',
115
+ createdAt: 1620232011451,
116
+ memory: '70/128 MB',
117
+ duration: '53.40 ms',
118
+ },
119
+ ],
120
+ paging: {
121
+ next: {
122
+ after: 'somehash',
123
+ },
124
+ },
125
+ };
126
+ const tailCall = vi.fn(() => Promise.resolve({ data: latestLogResponse }));
127
+ // @ts-ignore - headers is not used in the actual function and does not need to be mocked
128
+ await (0, serverlessLogs_1.tailLogs)(ACCOUNT_ID, 'name', fetchLatest, tailCall, compact);
129
+ vi.runOnlyPendingTimers();
130
+ expect(serverlessFunctionLogs_1.outputLogs).toHaveBeenCalledWith(latestLogResponse, expect.objectContaining({ compact }));
131
+ expect(tailCall).toHaveBeenCalledTimes(2);
132
+ });
133
+ it('handles no logs', async () => {
134
+ const compact = false;
135
+ const fetchLatest = vi.fn(() => {
136
+ return Promise.reject({
137
+ message: '',
138
+ type: '',
139
+ stackTrace: [],
140
+ statusCode: 404,
141
+ });
142
+ });
143
+ const tailCall = vi.fn(() => Promise.reject({
144
+ message: '',
145
+ type: '',
146
+ stackTrace: [],
147
+ statusCode: 404,
148
+ }));
149
+ await (0, serverlessLogs_1.tailLogs)(ACCOUNT_ID, 'name', fetchLatest, tailCall, compact);
150
+ vi.runOnlyPendingTimers();
151
+ expect(tailCall).toHaveBeenCalledTimes(2);
152
+ });
153
+ });
154
+ });
@@ -0,0 +1 @@
1
+ export {};