@hubspot/ui-extensions-dev-server 1.2.0 → 2.0.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 (184) hide show
  1. package/dist/lib/DevModeParentInterface.js +5 -6
  2. package/dist/lib/DevModeUnifiedInterface.js +2 -2
  3. package/dist/lib/DevServerState.d.ts +14 -4
  4. package/dist/lib/DevServerState.js +34 -1
  5. package/dist/lib/__tests__/DevModeParentInterface.spec.js +42 -1
  6. package/dist/lib/__tests__/DevModeUnifiedInterface.spec.js +34 -0
  7. package/dist/lib/__tests__/DevServerState.spec.js +180 -0
  8. package/dist/lib/__tests__/{app-functions/errorReporter.spec.js → errorReporter.spec.js} +5 -5
  9. package/dist/lib/__tests__/extensionsService.spec.js +57 -9
  10. package/dist/lib/__tests__/factories.d.ts +1 -1
  11. package/dist/lib/__tests__/factories.js +1 -1
  12. package/dist/lib/__tests__/fixtures/extensionConfig.js +3 -0
  13. package/dist/lib/__tests__/plugins/devBuildPlugin.spec.js +1 -1
  14. package/dist/lib/__tests__/{app-functions/services → proxy}/AppProxyService.spec.js +73 -3
  15. package/dist/lib/__tests__/{app-functions → proxy}/signing.spec.js +1 -1
  16. package/dist/lib/__tests__/server.spec.js +14 -11
  17. package/dist/lib/__tests__/serverless/config.spec.js +61 -0
  18. package/dist/lib/__tests__/{app-functions → serverless}/context.spec.js +2 -2
  19. package/dist/lib/__tests__/serverless/executor_unsupported.spec.js +37 -0
  20. package/dist/lib/__tests__/{app-functions/executor_v20232.spec.js → serverless/executor_v20251.spec.js} +6 -13
  21. package/dist/lib/__tests__/{app-functions/executor_v20231.spec.js → serverless/executor_v202603.spec.js} +26 -11
  22. package/dist/lib/__tests__/{app-functions → serverless}/fixtures/constants.d.ts +4 -3
  23. package/dist/lib/__tests__/{app-functions → serverless}/fixtures/constants.js +9 -3
  24. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-async-fails.cjs +5 -0
  25. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-async-fails.d.cts +1 -0
  26. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-async-succeeds.cjs +5 -0
  27. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-async-succeeds.d.cts +3 -0
  28. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-does-not-export-main.cjs +4 -0
  29. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-does-not-export-main.d.cts +1 -0
  30. package/dist/lib/__tests__/{app-functions/fixtures/v2023.1/app.functions → serverless/fixtures/v2026.03/functions}/func-echos-input.cjs +3 -3
  31. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-echos-input.d.cts +5 -0
  32. package/dist/lib/__tests__/{app-functions/fixtures/v2023.1/app.functions → serverless/fixtures/v2026.03/functions}/func-logs.cjs +2 -2
  33. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-logs.d.cts +3 -0
  34. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-function.cjs +4 -0
  35. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-function.d.cts +1 -0
  36. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-implicitly.cjs +7 -0
  37. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-implicitly.d.cts +1 -0
  38. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-promise-rejected.cjs +4 -0
  39. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-promise-rejected.d.cts +1 -0
  40. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-promise-resolved.cjs +4 -0
  41. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-promise-resolved.d.cts +3 -0
  42. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-text.cjs +4 -0
  43. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-text.d.cts +1 -0
  44. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-undefined.cjs +4 -0
  45. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-undefined.d.cts +1 -0
  46. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-times-out.cjs +12 -0
  47. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-times-out.d.cts +1 -0
  48. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-undeclared.cjs +4 -0
  49. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-undeclared.d.cts +1 -0
  50. package/dist/lib/__tests__/{app-functions/fixtures/v2023.1/app.functions → serverless/fixtures/v2026.03/functions}/func-uses-secret.cjs +3 -3
  51. package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-uses-secret.d.cts +4 -0
  52. package/dist/lib/__tests__/{app-functions → serverless}/secrets.spec.js +4 -4
  53. package/dist/lib/__tests__/{app-functions → serverless}/services/PrivateAppUserTokenManager.spec.js +4 -4
  54. package/dist/lib/__tests__/serverless/services/services_v20251.spec.d.ts +1 -0
  55. package/dist/lib/__tests__/{app-functions/services/services_v20232.spec.js → serverless/services/services_v20251.spec.js} +9 -63
  56. package/dist/lib/__tests__/serverless/services/services_v202603.spec.d.ts +1 -0
  57. package/dist/lib/__tests__/{app-functions/services/services_v20231.spec.js → serverless/services/services_v202603.spec.js} +18 -91
  58. package/dist/lib/__tests__/serverless/setup.d.ts +1 -0
  59. package/dist/lib/__tests__/utils.spec.js +26 -1
  60. package/dist/lib/constants.d.ts +2 -2
  61. package/dist/lib/constants.js +2 -2
  62. package/dist/lib/{app-functions/errorReporter.js → errorReporter.js} +2 -2
  63. package/dist/lib/extensionsService.js +6 -0
  64. package/dist/lib/{app-functions/services → proxy}/AppProxyService.d.ts +1 -1
  65. package/dist/lib/{app-functions/services → proxy}/AppProxyService.js +15 -4
  66. package/dist/lib/proxy/constants.d.ts +13 -0
  67. package/dist/lib/{app-functions → proxy}/constants.js +0 -18
  68. package/dist/lib/proxy/types.d.ts +44 -0
  69. package/dist/lib/proxy/types.js +1 -0
  70. package/dist/lib/server.js +2 -1
  71. package/dist/lib/serverless/config.js +100 -0
  72. package/dist/lib/serverless/constants.d.ts +7 -0
  73. package/dist/lib/serverless/constants.js +12 -0
  74. package/dist/lib/{app-functions → serverless}/errors.d.ts +1 -0
  75. package/dist/lib/{app-functions → serverless}/errors.js +6 -0
  76. package/dist/lib/{app-functions → serverless}/executor.js +19 -13
  77. package/dist/lib/serverless/secrets.d.ts +5 -0
  78. package/dist/lib/{app-functions → serverless}/services/AppFunctionExecutionService.js +1 -1
  79. package/dist/lib/{app-functions → serverless}/services/PrivateAppUserTokenManager.js +1 -1
  80. package/dist/lib/{app-functions → serverless}/types.d.ts +1 -44
  81. package/dist/lib/types.d.ts +12 -3
  82. package/dist/lib/types.js +7 -2
  83. package/dist/lib/utils.d.ts +2 -1
  84. package/dist/lib/utils.js +3 -0
  85. package/package.json +1 -1
  86. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-fails.cjs +0 -8
  87. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-fails.d.cts +0 -1
  88. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-succeeds.cjs +0 -8
  89. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-succeeds.d.cts +0 -1
  90. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-callback-on-promise-rejected.cjs +0 -8
  91. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-callback-on-promise-resolved.cjs +0 -8
  92. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-callback-on-promise-resolved.d.cts +0 -1
  93. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-does-not-export-main.cjs +0 -4
  94. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-does-not-export-main.d.cts +0 -1
  95. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-echos-input.d.cts +0 -1
  96. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-logs.d.cts +0 -1
  97. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-function.cjs +0 -4
  98. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-function.d.cts +0 -1
  99. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-promise-rejected.cjs +0 -7
  100. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-promise-rejected.d.cts +0 -1
  101. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-promise-resolved.cjs +0 -7
  102. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-promise-resolved.d.cts +0 -1
  103. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-text.d.cts +0 -1
  104. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-undefined.cjs +0 -4
  105. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-undefined.d.cts +0 -1
  106. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-times-out.cjs +0 -10
  107. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-times-out.d.cts +0 -1
  108. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-undeclared.cjs +0 -4
  109. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-undeclared.d.cts +0 -1
  110. package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-uses-secret.d.cts +0 -1
  111. package/dist/lib/app-functions/config.js +0 -48
  112. package/dist/lib/app-functions/constants.d.ts +0 -26
  113. package/dist/lib/app-functions/index.d.ts +0 -4
  114. package/dist/lib/app-functions/index.js +0 -4
  115. package/dist/lib/app-functions/secrets.d.ts +0 -5
  116. package/dist/lib/app-functions/services/index.d.ts +0 -3
  117. package/dist/lib/app-functions/services/index.js +0 -3
  118. /package/dist/lib/__tests__/{app-functions/context.spec.d.ts → DevServerState.spec.d.ts} +0 -0
  119. /package/dist/lib/__tests__/{app-functions/errorReporter.spec.d.ts → errorReporter.spec.d.ts} +0 -0
  120. /package/dist/lib/__tests__/{app-functions/services → proxy}/AppProxyService.spec.d.ts +0 -0
  121. /package/dist/lib/__tests__/{app-functions → proxy}/signing.spec.d.ts +0 -0
  122. /package/dist/lib/__tests__/{app-functions/executor_v20231.spec.d.ts → serverless/config.spec.d.ts} +0 -0
  123. /package/dist/lib/__tests__/{app-functions/executor_v20232.spec.d.ts → serverless/context.spec.d.ts} +0 -0
  124. /package/dist/lib/__tests__/{app-functions/secrets.spec.d.ts → serverless/executor_unsupported.spec.d.ts} +0 -0
  125. /package/dist/lib/__tests__/{app-functions/services/PrivateAppUserTokenManager.spec.d.ts → serverless/executor_v20251.spec.d.ts} +0 -0
  126. /package/dist/lib/__tests__/{app-functions/services/services_v20231.spec.d.ts → serverless/executor_v202603.spec.d.ts} +0 -0
  127. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-async-fails.cjs +0 -0
  128. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-async-fails.d.cts +0 -0
  129. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-async-succeeds.cjs +0 -0
  130. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-async-succeeds.d.cts +0 -0
  131. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-calls-callback.cjs +0 -0
  132. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-calls-callback.d.cts +0 -0
  133. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-does-not-export-main.cjs +0 -0
  134. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-does-not-export-main.d.cts +0 -0
  135. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-echos-input.cjs +0 -0
  136. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-echos-input.d.cts +0 -0
  137. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-logs.cjs +0 -0
  138. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-logs.d.cts +0 -0
  139. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-function.cjs +0 -0
  140. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-function.d.cts +0 -0
  141. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-implicitly.cjs +0 -0
  142. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-implicitly.d.cts +0 -0
  143. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-promise-rejected.cjs +0 -0
  144. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-promise-rejected.d.cts +0 -0
  145. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-promise-resolved.cjs +0 -0
  146. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-promise-resolved.d.cts +0 -0
  147. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-text.cjs +0 -0
  148. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-text.d.cts +0 -0
  149. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-undefined.cjs +0 -0
  150. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-undefined.d.cts +0 -0
  151. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.1 → serverless/fixtures/v2025.1}/app.functions/func-throws-error.cjs +0 -0
  152. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.1 → serverless/fixtures/v2025.1}/app.functions/func-throws-error.d.cts +0 -0
  153. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-times-out.cjs +0 -0
  154. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-times-out.d.cts +0 -0
  155. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-undeclared.cjs +0 -0
  156. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-undeclared.d.cts +0 -0
  157. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-uses-secret.cjs +0 -0
  158. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-uses-secret.d.cts +0 -0
  159. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.1/app.functions/func-returns-text.cjs → serverless/fixtures/v2026.03/functions/func-calls-callback.cjs} +0 -0
  160. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.1/app.functions/func-callback-on-promise-rejected.d.cts → serverless/fixtures/v2026.03/functions/func-calls-callback.d.cts} +0 -0
  161. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2/app.functions → serverless/fixtures/v2026.03/functions}/func-throws-error.cjs +0 -0
  162. /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2/app.functions → serverless/fixtures/v2026.03/functions}/func-throws-error.d.cts +0 -0
  163. /package/dist/lib/__tests__/{app-functions/services/services_v20232.spec.d.ts → serverless/secrets.spec.d.ts} +0 -0
  164. /package/dist/lib/__tests__/{app-functions/setup.d.ts → serverless/services/PrivateAppUserTokenManager.spec.d.ts} +0 -0
  165. /package/dist/lib/__tests__/{app-functions → serverless}/setup.js +0 -0
  166. /package/dist/lib/{app-functions/errorReporter.d.ts → errorReporter.d.ts} +0 -0
  167. /package/dist/lib/{app-functions → proxy}/signing.d.ts +0 -0
  168. /package/dist/lib/{app-functions → proxy}/signing.js +0 -0
  169. /package/dist/lib/{app-functions → serverless}/api/privateAppUserToken.d.ts +0 -0
  170. /package/dist/lib/{app-functions → serverless}/api/privateAppUserToken.js +0 -0
  171. /package/dist/lib/{app-functions → serverless}/config.d.ts +0 -0
  172. /package/dist/lib/{app-functions → serverless}/context.d.ts +0 -0
  173. /package/dist/lib/{app-functions → serverless}/context.js +0 -0
  174. /package/dist/lib/{app-functions → serverless}/executor.d.ts +0 -0
  175. /package/dist/lib/{app-functions → serverless}/secrets.js +0 -0
  176. /package/dist/lib/{app-functions → serverless}/services/AppFunctionExecutionService.d.ts +0 -0
  177. /package/dist/lib/{app-functions → serverless}/services/PrivateAppUserTokenManager.d.ts +0 -0
  178. /package/dist/lib/{app-functions → serverless}/services/constants.d.ts +0 -0
  179. /package/dist/lib/{app-functions → serverless}/services/constants.js +0 -0
  180. /package/dist/lib/{app-functions → serverless}/services/messages.d.ts +0 -0
  181. /package/dist/lib/{app-functions → serverless}/services/messages.js +0 -0
  182. /package/dist/lib/{app-functions → serverless}/types.js +0 -0
  183. /package/dist/lib/{app-functions → serverless}/utils.d.ts +0 -0
  184. /package/dist/lib/{app-functions → serverless}/utils.js +0 -0
@@ -0,0 +1 @@
1
+ export function main(__context?: {}): string;
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- exports.main = (context = {}, callback) => {
2
+ exports.main = (context = {}) => {
3
3
  const parameters = context.parameters || {};
4
4
  const paramPhrase = parameters['PHRASE'] || '';
5
5
  const secrets = context.secrets || {};
@@ -7,8 +7,8 @@ exports.main = (context = {}, callback) => {
7
7
  const secretPhrase = secrets['PHRASE'] || '';
8
8
  const envToken = process.env['PRIVATE_APP_ACCESS_TOKEN'] || '';
9
9
  const envPhrase = process.env['PHRASE'] || '';
10
- callback({
10
+ return {
11
11
  contextSecrets: `${secretToken}${paramPhrase}${secretPhrase}`,
12
12
  processEnvs: `${envToken}${paramPhrase}${envPhrase}`,
13
- });
13
+ };
14
14
  };
@@ -0,0 +1,4 @@
1
+ export function main(context?: {}): {
2
+ contextSecrets: string;
3
+ processEnvs: string;
4
+ };
@@ -1,9 +1,9 @@
1
1
  import { describe, it, beforeEach, expect, vi, afterEach } from 'vitest';
2
2
  import { vol } from 'memfs';
3
- import { loadSecrets, setProperTokenInSecrets, } from "../../app-functions/secrets.js";
4
- import { APP_FUNCTIONS_MANIFEST_FILENAME, PRIVATE_APP_ACCESS_TOKEN, } from "../../app-functions/constants.js";
3
+ import { loadSecrets, setProperTokenInSecrets, } from "../../serverless/secrets.js";
4
+ import { APP_FUNCTIONS_MANIFEST_FILENAME, PRIVATE_APP_ACCESS_TOKEN, } from "../../serverless/constants.js";
5
5
  import { SAMPLE_FUNCTION_JS, SAMPLE_SERVERLESS_JSON, } from "./fixtures/constants.js";
6
- import { PrivateAppUserTokenManager } from "../../app-functions/services/PrivateAppUserTokenManager.js";
6
+ import { PrivateAppUserTokenManager } from "../../serverless/services/PrivateAppUserTokenManager.js";
7
7
  const SRC_DIR = '/path/to/app.functions';
8
8
  const FUNCTION_NAME = 'sample-function';
9
9
  const FUNCTION_FILENAME = `${FUNCTION_NAME}.cjs`;
@@ -32,7 +32,7 @@ vi.mock('node:fs/promises', async () => {
32
32
  const memfs = await import('memfs');
33
33
  return { default: memfs.fs.promises, ...memfs.fs.promises };
34
34
  });
35
- vi.mock('../../app-functions/errorReporter.ts', () => ({
35
+ vi.mock('../../errorReporter.ts', () => ({
36
36
  reportError: vi.fn(),
37
37
  }));
38
38
  /**
@@ -1,12 +1,12 @@
1
1
  import { vi, describe, beforeEach, afterEach, it, expect, } from 'vitest';
2
2
  import { scopesOnAccessToken as __scopesOnAccessToken } from '@hubspot/local-dev-lib/personalAccessKey';
3
- import { PrivateAppUserTokenManager } from "../../../app-functions/services/PrivateAppUserTokenManager.js";
4
- import { fetchPrivateAppUserToken as __fetchPrivateAppUserToken, createPrivateAppUserToken as __createPrivateAppUserToken, updatePrivateAppUserToken as __updatePrivateAppUserToken, } from "../../../app-functions/api/privateAppUserToken.js";
3
+ import { PrivateAppUserTokenManager } from "../../../serverless/services/PrivateAppUserTokenManager.js";
4
+ import { fetchPrivateAppUserToken as __fetchPrivateAppUserToken, createPrivateAppUserToken as __createPrivateAppUserToken, updatePrivateAppUserToken as __updatePrivateAppUserToken, } from "../../../serverless/api/privateAppUserToken.js";
5
5
  import { HubSpotHttpError } from '@hubspot/local-dev-lib/models/HubSpotHttpError';
6
6
  import { AxiosError, AxiosHeaders } from 'axios';
7
- import { generateTokensEnableMessage, generateMissingScopesMessage, generateMissingScopesMoreContextMessage, } from "../../../app-functions/services/messages.js";
7
+ import { generateTokensEnableMessage, generateMissingScopesMessage, generateMissingScopesMoreContextMessage, } from "../../../serverless/services/messages.js";
8
8
  vi.mock('@hubspot/local-dev-lib/personalAccessKey');
9
- vi.mock('../../../app-functions/api/privateAppUserToken.ts');
9
+ vi.mock('../../../serverless/api/privateAppUserToken.ts');
10
10
  const scopesOnAccessToken = __scopesOnAccessToken;
11
11
  const fetchPrivateAppUserToken = __fetchPrivateAppUserToken;
12
12
  const createPrivateAppUserToken = __createPrivateAppUserToken;
@@ -1,13 +1,13 @@
1
1
  import { describe, it, expect, vi, afterEach, beforeEach, } from 'vitest';
2
2
  import httpMocks from 'node-mocks-http';
3
3
  import { EventEmitter } from 'node:events';
4
- import { AppFunctionExecutionService } from "../../../app-functions/services/index.js";
5
- import { TEST_CONFIG_V20232 as TEST_CONFIG } from "../fixtures/constants.js";
6
- import * as executor from "../../../app-functions/executor.js";
4
+ import { AppFunctionExecutionService } from "../../../serverless/services/AppFunctionExecutionService.js";
5
+ import { TEST_CONFIG_V20251 as TEST_CONFIG } from "../fixtures/constants.js";
6
+ import * as executor from "../../../serverless/executor.js";
7
7
  import { scopesOnAccessToken as __scopesOnAccessToken } from '@hubspot/local-dev-lib/personalAccessKey';
8
- import { USER_TOKEN_READ, USER_TOKEN_WRITE, } from "../../../app-functions/services/constants.js";
9
- import { PrivateAppUserTokenManager } from "../../../app-functions/services/PrivateAppUserTokenManager.js";
10
- vi.mock('../../../app-functions/services/PrivateAppUserTokenManager.ts');
8
+ import { USER_TOKEN_READ, USER_TOKEN_WRITE, } from "../../../serverless/services/constants.js";
9
+ import { PrivateAppUserTokenManager } from "../../../serverless/services/PrivateAppUserTokenManager.js";
10
+ vi.mock('../../../serverless/services/PrivateAppUserTokenManager.ts');
11
11
  vi.mock('@hubspot/local-dev-lib/personalAccessKey');
12
12
  const scopesOnAccessToken = __scopesOnAccessToken;
13
13
  const callAppFunction = async (functionName, parameters) => {
@@ -37,16 +37,12 @@ const callAppFunction = async (functionName, parameters) => {
37
37
  await handler(request, response);
38
38
  return await responsePromised;
39
39
  };
40
- /**
41
- * Validate the service for executing app functions
42
- */
43
- describe('app function dev server', () => {
40
+ describe('app function dev server (v2025.1)', () => {
44
41
  const initialEnvJson = JSON.stringify(process.env);
45
42
  beforeEach(() => {
46
43
  scopesOnAccessToken.mockResolvedValue([USER_TOKEN_READ, USER_TOKEN_WRITE]);
47
44
  });
48
45
  afterEach(() => {
49
- // restore process.env
50
46
  process.env = JSON.parse(initialEnvJson);
51
47
  vi.resetAllMocks();
52
48
  vi.restoreAllMocks();
@@ -54,167 +50,132 @@ describe('app function dev server', () => {
54
50
  it('returns "200 OK" response if function execution succeeded', async () => {
55
51
  const getTokenspy = vi.spyOn(PrivateAppUserTokenManager.prototype, 'getPrivateAppUserToken');
56
52
  const response = await callAppFunction('returns-text');
57
- // Validate response status and body
58
53
  expect(response.statusCode).toEqual(200);
59
54
  expect(response._getJSONData()).toEqual({
60
55
  logId: 'n/a',
61
56
  response: 'result',
62
57
  });
63
- // Validate log output
64
58
  expect(TEST_CONFIG.logger.debug).toHaveBeenCalledWith(expect.stringContaining('App function "returns-text" execution succeeded'));
65
59
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledTimes(0);
66
60
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledTimes(0);
67
- // Validate process.env is put back to what it was before the call
68
61
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
69
- // get the token
70
62
  expect(getTokenspy).toHaveBeenCalledTimes(1);
71
63
  });
72
64
  it('returns "400 Bad Request" response if function execution failed', async () => {
73
65
  const response = await callAppFunction('throws-error');
74
- // Validate response status and body
75
66
  expect(response.statusCode).toEqual(400);
76
67
  const body = response._getJSONData();
77
68
  expect(body).toHaveProperty('status', 'error');
78
69
  expect(body).toHaveProperty('category', 'VALIDATION_ERROR');
79
70
  const exception = body.errors?.[0]?.context?.exception?.[0];
80
71
  expect(exception).toEqual('Error: Oops');
81
- // Validate log output
82
72
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledWith(expect.stringContaining('App function "throws-error" execution failed'));
83
73
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledWith('App function encountered an uncaught error.', expect.anything());
84
- // Validate process.env is put back to what it was before the call
85
74
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
86
75
  });
87
76
  describe('handles asynchronous functions (promise chaining)', () => {
88
77
  it('returns "200 OK" response if function returns a promise that resolves', async () => {
89
78
  const response = await callAppFunction('returns-promise-resolved');
90
- // Validate response status and body
91
79
  expect(response.statusCode).toEqual(200);
92
80
  expect(response._getJSONData()).toEqual({
93
81
  logId: 'n/a',
94
82
  response: { result: 'simulated' },
95
83
  });
96
- // Validate log output
97
84
  expect(TEST_CONFIG.logger.debug).toHaveBeenCalledWith(expect.stringContaining('App function "returns-promise-resolved" execution succeeded'));
98
85
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledTimes(0);
99
86
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledTimes(0);
100
- // Validate process.env is put back to what it was before the call
101
87
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
102
88
  });
103
89
  it('returns "400 Bad Request" response if function returns a promise that rejects', async () => {
104
90
  const response = await callAppFunction('returns-promise-rejected');
105
- // Validate response status and body
106
91
  expect(response.statusCode).toEqual(400);
107
92
  const body = response._getJSONData();
108
93
  expect(body).toHaveProperty('status', 'error');
109
94
  expect(body).toHaveProperty('category', 'VALIDATION_ERROR');
110
95
  const exception = body.errors?.[0]?.context?.exception?.[0];
111
96
  expect(exception).toEqual('Error: fail');
112
- // Validate log output
113
97
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledWith(expect.stringContaining('App function "returns-promise-rejected" execution failed'));
114
98
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledWith('App function encountered an uncaught error.', expect.anything());
115
- // Validate process.env is put back to what it was before the call
116
99
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
117
100
  });
118
101
  });
119
102
  describe('handles asynchronous functions (async/await)', () => {
120
103
  it('returns "200 OK" response if an async function execution succeeded', async () => {
121
104
  const response = await callAppFunction('async-succeeds');
122
- // Validate response status and body
123
105
  expect(response.statusCode).toEqual(200);
124
106
  expect(response._getJSONData()).toEqual({
125
107
  logId: 'n/a',
126
108
  response: { result: 'simulated' },
127
109
  });
128
- // Validate log output
129
110
  expect(TEST_CONFIG.logger.debug).toHaveBeenCalledWith(expect.stringContaining('App function "async-succeeds" execution succeeded'));
130
111
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledTimes(0);
131
112
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledTimes(0);
132
- // Validate process.env is put back to what it was before the call
133
113
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
134
114
  });
135
115
  it('returns "400 Bad Request" response if an async function execution failed', async () => {
136
116
  const response = await callAppFunction('async-fails');
137
- // Validate response status and body
138
117
  expect(response.statusCode).toEqual(400);
139
118
  const body = response._getJSONData();
140
119
  expect(body).toHaveProperty('status', 'error');
141
120
  expect(body).toHaveProperty('category', 'VALIDATION_ERROR');
142
121
  const exception = body.errors?.[0]?.context?.exception?.[0];
143
122
  expect(exception).toEqual('Error: fail');
144
- // Validate log output
145
123
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledWith(expect.stringContaining('App function "async-fails" execution failed'));
146
124
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledWith('App function encountered an uncaught error.', expect.anything());
147
- // Validate process.env is put back to what it was before the call
148
125
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
149
126
  });
150
127
  });
151
- it('returns "200 OK" response if function returns implicitly (only 2023.2)', async () => {
128
+ it('returns "200 OK" response if function returns implicitly', async () => {
152
129
  const response = await callAppFunction('returns-implicitly');
153
- // Validate response status and body
154
130
  expect(response.statusCode).toEqual(200);
155
131
  expect(response._getJSONData()).toEqual({
156
132
  logId: 'n/a',
157
133
  response: null,
158
134
  });
159
- // Validate log output
160
135
  expect(TEST_CONFIG.logger.debug).toHaveBeenCalledWith(expect.stringContaining('App function "returns-implicitly" execution succeeded'));
161
136
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledTimes(0);
162
137
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledTimes(0);
163
- // Validate process.env is put back to what it was before the call
164
138
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
165
139
  });
166
140
  it('returns "400 Bad Request" response if function not found', async () => {
167
141
  const response = await callAppFunction('does-not-exist');
168
- // Validate response status and body
169
142
  expect(response.statusCode).toEqual(400);
170
143
  const body = response._getJSONData();
171
144
  expect(body).toHaveProperty('status', 'error');
172
145
  expect(body).toHaveProperty('category', 'VALIDATION_ERROR');
173
146
  const exception = body.errors?.[0]?.context?.exception?.[0];
174
147
  expect(exception).toMatch(/doesn't exist in this project/);
175
- // Validate log output
176
148
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledWith(expect.stringContaining('App function "does-not-exist" execution failed'));
177
149
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledWith(expect.stringContaining('Could not find file'));
178
- // Validate process.env is put back to what it was before the call
179
150
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
180
151
  });
181
152
  it('returns "400 Bad Request" response if function does not export main', async () => {
182
- // TEST_CONFIG.functionTimeoutMs = 250
183
153
  const response = await callAppFunction('does-not-export-main');
184
- // Validate response status and body
185
154
  expect(response.statusCode).toEqual(400);
186
155
  const body = response._getJSONData();
187
156
  expect(body).toHaveProperty('status', 'error');
188
157
  expect(body).toHaveProperty('category', 'VALIDATION_ERROR');
189
158
  const exception = body.errors?.[0]?.context?.exception?.[0];
190
159
  expect(exception).toMatch(/customerPayload\.main is not a function/);
191
- // Validate log output
192
160
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledWith(expect.stringContaining('App function "does-not-export-main" execution failed'));
193
161
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledWith(expect.stringContaining('Could not find "main" export in'));
194
- // Validate process.env is put back to what it was before the call
195
162
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
196
163
  });
197
164
  it('returns "400 Bad Request" response if function returns invalid json', async () => {
198
- // TEST_CONFIG.functionTimeoutMs = 250
199
165
  const response = await callAppFunction('returns-function');
200
- // Validate response status and body
201
166
  expect(response.statusCode).toEqual(400);
202
167
  const body = response._getJSONData();
203
168
  expect(body).toHaveProperty('status', 'error');
204
169
  expect(body).toHaveProperty('category', 'VALIDATION_ERROR');
205
170
  const exception = body.errors?.[0]?.context?.exception?.[0];
206
171
  expect(exception).toMatch(/Wrong arguments/);
207
- // Validate log output
208
172
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledWith(expect.stringContaining('App function "returns-function" execution failed'));
209
173
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledWith('App function reponse is not valid JSON.');
210
- // Validate process.env is put back to what it was before the call
211
174
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
212
175
  });
213
176
  it('returns "200 OK" response if function returns before timeout', async () => {
214
- // TEST_CONFIG.functionTimeoutMs = 250
215
177
  const response = await callAppFunction('times-out', { delayMs: 200 });
216
- const variance = 10; // milliseconds
217
- // Validate response status and body
178
+ const variance = 10;
218
179
  expect(response.statusCode).toEqual(200);
219
180
  const body = response._getJSONData();
220
181
  expect(body).toEqual({
@@ -223,27 +184,21 @@ describe('app function dev server', () => {
223
184
  });
224
185
  expect(body.response.elapsedMs).toBeGreaterThanOrEqual(200 - variance);
225
186
  expect(body.response.elapsedMs).toBeLessThanOrEqual(200 + variance);
226
- // Validate log output
227
187
  expect(TEST_CONFIG.logger.debug).toHaveBeenCalledWith(expect.stringContaining('App function "times-out" execution succeeded'));
228
188
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledTimes(0);
229
189
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledTimes(0);
230
- // Validate process.env is put back to what it was before the call
231
190
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
232
191
  });
233
192
  it('returns "400 Bad Request" response if function returns after timeout', async () => {
234
- // TEST_CONFIG.functionTimeoutMs = 250
235
193
  const response = await callAppFunction('times-out', { delayMs: 300 });
236
- // Validate response status and body
237
194
  expect(response.statusCode).toEqual(400);
238
195
  const body = response._getJSONData();
239
196
  expect(body).toHaveProperty('status', 'error');
240
197
  expect(body).toHaveProperty('category', 'VALIDATION_ERROR');
241
198
  const exception = body.errors?.[0]?.context?.exception?.[0];
242
199
  expect(exception).toMatch(/Task timed out after/);
243
- // Validate log output
244
200
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledWith(expect.stringContaining('App function "times-out" execution failed'));
245
201
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledWith('App function failed to callback within 0.25 second.');
246
- // Validate process.env is put back to what it was before the call
247
202
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
248
203
  });
249
204
  it('returns "500 Internal Server Error" response if something went wrong', async () => {
@@ -251,18 +206,14 @@ describe('app function dev server', () => {
251
206
  vi.spyOn(executor, 'executeFunction').mockImplementation(() => {
252
207
  throw error;
253
208
  });
254
- // Act
255
209
  const response = await callAppFunction('returns-text');
256
- // Validate response status and body
257
210
  expect(response.statusCode).toEqual(500);
258
211
  const body = response._getJSONData();
259
212
  expect(body).toHaveProperty('status', 'error');
260
213
  expect(body).not.toHaveProperty('category', 'INTERNAL_ERROR');
261
214
  expect(body).toHaveProperty('message', 'internal error');
262
- // Validate log output
263
215
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledWith(expect.stringContaining('App function "returns-text" execution failed due to server internal error'));
264
216
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledWith(error);
265
- // Validate process.env is put back to what it was before the call
266
217
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
267
218
  });
268
219
  it('logs to console from inside the function', async () => {
@@ -271,15 +222,12 @@ describe('app function dev server', () => {
271
222
  const info = vi.spyOn(console, 'info').mockImplementation(() => { });
272
223
  const warn = vi.spyOn(console, 'warn').mockImplementation(() => { });
273
224
  const error = vi.spyOn(console, 'error').mockImplementation(() => { });
274
- // Act
275
225
  const response = await callAppFunction('logs');
276
- // Validate response status and body
277
226
  expect(response.statusCode).toEqual(200);
278
227
  expect(response._getJSONData()).toEqual({
279
228
  logId: 'n/a',
280
229
  response: { status: 'success' },
281
230
  });
282
- // Validate function logging
283
231
  expect(log).toHaveBeenCalledTimes(1);
284
232
  expect(log).toHaveBeenCalledWith('log line');
285
233
  expect(debug).toHaveBeenCalledTimes(1);
@@ -291,12 +239,10 @@ describe('app function dev server', () => {
291
239
  expect(warn).toHaveBeenCalledWith('warn line');
292
240
  expect(error).toHaveBeenCalledTimes(1);
293
241
  expect(error).toHaveBeenCalledWith('error line');
294
- // Validate service logging, which is separate from function logging
295
242
  expect(TEST_CONFIG.logger.debug).toHaveBeenCalledTimes(1);
296
243
  expect(TEST_CONFIG.logger.debug).toHaveBeenNthCalledWith(1, expect.stringContaining('App function "logs" execution succeeded'));
297
244
  expect(TEST_CONFIG.logger.warn).toHaveBeenCalledTimes(0);
298
245
  expect(TEST_CONFIG.logger.error).toHaveBeenCalledTimes(0);
299
- // Validate process.env is put back to what it was before the call
300
246
  expect(process.env).toEqual(JSON.parse(initialEnvJson));
301
247
  });
302
248
  });