@hubspot/ui-extensions-dev-server 1.1.8 → 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.
- package/dist/lib/DevModeParentInterface.js +5 -6
- package/dist/lib/DevModeUnifiedInterface.js +2 -2
- package/dist/lib/DevServerState.d.ts +14 -4
- package/dist/lib/DevServerState.js +34 -1
- package/dist/lib/__tests__/DevModeParentInterface.spec.js +42 -1
- package/dist/lib/__tests__/DevModeUnifiedInterface.spec.js +34 -0
- package/dist/lib/__tests__/DevServerState.spec.js +180 -0
- package/dist/lib/__tests__/{app-functions/errorReporter.spec.js → errorReporter.spec.js} +5 -5
- package/dist/lib/__tests__/extensionsService.spec.js +57 -9
- package/dist/lib/__tests__/factories.d.ts +1 -1
- package/dist/lib/__tests__/factories.js +1 -1
- package/dist/lib/__tests__/fixtures/extensionConfig.js +3 -0
- package/dist/lib/__tests__/plugins/devBuildPlugin.spec.js +1 -1
- package/dist/lib/__tests__/{app-functions/services → proxy}/AppProxyService.spec.js +73 -3
- package/dist/lib/__tests__/{app-functions → proxy}/signing.spec.js +1 -1
- package/dist/lib/__tests__/server.spec.js +14 -11
- package/dist/lib/__tests__/serverless/config.spec.js +61 -0
- package/dist/lib/__tests__/{app-functions → serverless}/context.spec.js +2 -2
- package/dist/lib/__tests__/serverless/executor_unsupported.spec.js +37 -0
- package/dist/lib/__tests__/{app-functions/executor_v20232.spec.js → serverless/executor_v20251.spec.js} +6 -13
- package/dist/lib/__tests__/{app-functions/executor_v20231.spec.js → serverless/executor_v202603.spec.js} +26 -11
- package/dist/lib/__tests__/{app-functions → serverless}/fixtures/constants.d.ts +4 -3
- package/dist/lib/__tests__/{app-functions → serverless}/fixtures/constants.js +9 -3
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-async-fails.cjs +5 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-async-fails.d.cts +1 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-async-succeeds.cjs +5 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-async-succeeds.d.cts +3 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-does-not-export-main.cjs +4 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-does-not-export-main.d.cts +1 -0
- package/dist/lib/__tests__/{app-functions/fixtures/v2023.1/app.functions → serverless/fixtures/v2026.03/functions}/func-echos-input.cjs +3 -3
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-echos-input.d.cts +5 -0
- package/dist/lib/__tests__/{app-functions/fixtures/v2023.1/app.functions → serverless/fixtures/v2026.03/functions}/func-logs.cjs +2 -2
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-logs.d.cts +3 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-function.cjs +4 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-function.d.cts +1 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-implicitly.cjs +7 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-implicitly.d.cts +1 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-promise-rejected.cjs +4 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-promise-rejected.d.cts +1 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-promise-resolved.cjs +4 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-promise-resolved.d.cts +3 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-text.cjs +4 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-text.d.cts +1 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-undefined.cjs +4 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-returns-undefined.d.cts +1 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-times-out.cjs +12 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-times-out.d.cts +1 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-undeclared.cjs +4 -0
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-undeclared.d.cts +1 -0
- package/dist/lib/__tests__/{app-functions/fixtures/v2023.1/app.functions → serverless/fixtures/v2026.03/functions}/func-uses-secret.cjs +3 -3
- package/dist/lib/__tests__/serverless/fixtures/v2026.03/functions/func-uses-secret.d.cts +4 -0
- package/dist/lib/__tests__/{app-functions → serverless}/secrets.spec.js +4 -4
- package/dist/lib/__tests__/{app-functions → serverless}/services/PrivateAppUserTokenManager.spec.js +4 -4
- package/dist/lib/__tests__/serverless/services/services_v20251.spec.d.ts +1 -0
- package/dist/lib/__tests__/{app-functions/services/services_v20232.spec.js → serverless/services/services_v20251.spec.js} +9 -63
- package/dist/lib/__tests__/serverless/services/services_v202603.spec.d.ts +1 -0
- package/dist/lib/__tests__/{app-functions/services/services_v20231.spec.js → serverless/services/services_v202603.spec.js} +18 -91
- package/dist/lib/__tests__/serverless/setup.d.ts +1 -0
- package/dist/lib/__tests__/utils.spec.js +26 -1
- package/dist/lib/constants.d.ts +2 -2
- package/dist/lib/constants.js +2 -2
- package/dist/lib/{app-functions/errorReporter.js → errorReporter.js} +2 -2
- package/dist/lib/extensionsService.js +6 -0
- package/dist/lib/{app-functions/services → proxy}/AppProxyService.d.ts +1 -1
- package/dist/lib/{app-functions/services → proxy}/AppProxyService.js +15 -4
- package/dist/lib/proxy/constants.d.ts +13 -0
- package/dist/lib/{app-functions → proxy}/constants.js +0 -18
- package/dist/lib/proxy/types.d.ts +44 -0
- package/dist/lib/proxy/types.js +1 -0
- package/dist/lib/server.js +2 -1
- package/dist/lib/serverless/config.js +100 -0
- package/dist/lib/serverless/constants.d.ts +7 -0
- package/dist/lib/serverless/constants.js +12 -0
- package/dist/lib/{app-functions → serverless}/errors.d.ts +1 -0
- package/dist/lib/{app-functions → serverless}/errors.js +6 -0
- package/dist/lib/{app-functions → serverless}/executor.js +19 -13
- package/dist/lib/serverless/secrets.d.ts +5 -0
- package/dist/lib/{app-functions → serverless}/services/AppFunctionExecutionService.js +1 -1
- package/dist/lib/{app-functions → serverless}/services/PrivateAppUserTokenManager.js +1 -1
- package/dist/lib/{app-functions → serverless}/types.d.ts +1 -44
- package/dist/lib/types.d.ts +12 -3
- package/dist/lib/types.js +7 -2
- package/dist/lib/utils.d.ts +2 -1
- package/dist/lib/utils.js +3 -0
- package/package.json +8 -5
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-fails.cjs +0 -8
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-fails.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-succeeds.cjs +0 -8
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-succeeds.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-callback-on-promise-rejected.cjs +0 -8
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-callback-on-promise-resolved.cjs +0 -8
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-callback-on-promise-resolved.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-does-not-export-main.cjs +0 -4
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-does-not-export-main.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-echos-input.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-logs.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-function.cjs +0 -4
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-function.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-promise-rejected.cjs +0 -7
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-promise-rejected.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-promise-resolved.cjs +0 -7
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-promise-resolved.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-text.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-undefined.cjs +0 -4
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-undefined.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-times-out.cjs +0 -10
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-times-out.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-undeclared.cjs +0 -4
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-undeclared.d.cts +0 -1
- package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-uses-secret.d.cts +0 -1
- package/dist/lib/app-functions/config.js +0 -48
- package/dist/lib/app-functions/constants.d.ts +0 -26
- package/dist/lib/app-functions/index.d.ts +0 -4
- package/dist/lib/app-functions/index.js +0 -4
- package/dist/lib/app-functions/secrets.d.ts +0 -5
- package/dist/lib/app-functions/services/index.d.ts +0 -3
- package/dist/lib/app-functions/services/index.js +0 -3
- /package/dist/lib/__tests__/{app-functions/context.spec.d.ts → DevServerState.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions/errorReporter.spec.d.ts → errorReporter.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions/services → proxy}/AppProxyService.spec.d.ts +0 -0
- /package/dist/lib/__tests__/{app-functions → proxy}/signing.spec.d.ts +0 -0
- /package/dist/lib/__tests__/{app-functions/executor_v20231.spec.d.ts → serverless/config.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions/executor_v20232.spec.d.ts → serverless/context.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions/secrets.spec.d.ts → serverless/executor_unsupported.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions/services/PrivateAppUserTokenManager.spec.d.ts → serverless/executor_v20251.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions/services/services_v20231.spec.d.ts → serverless/executor_v202603.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-async-fails.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-async-fails.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-async-succeeds.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-async-succeeds.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-calls-callback.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-calls-callback.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-does-not-export-main.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-does-not-export-main.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-echos-input.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-echos-input.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-logs.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-logs.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-function.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-function.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-implicitly.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-implicitly.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-promise-rejected.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-promise-rejected.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-promise-resolved.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-promise-resolved.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-text.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-text.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-undefined.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-returns-undefined.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.1 → serverless/fixtures/v2025.1}/app.functions/func-throws-error.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.1 → serverless/fixtures/v2025.1}/app.functions/func-throws-error.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-times-out.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-times-out.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-undeclared.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-undeclared.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-uses-secret.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2 → serverless/fixtures/v2025.1}/app.functions/func-uses-secret.d.cts +0 -0
- /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
- /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
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2/app.functions → serverless/fixtures/v2026.03/functions}/func-throws-error.cjs +0 -0
- /package/dist/lib/__tests__/{app-functions/fixtures/v2023.2/app.functions → serverless/fixtures/v2026.03/functions}/func-throws-error.d.cts +0 -0
- /package/dist/lib/__tests__/{app-functions/services/services_v20232.spec.d.ts → serverless/secrets.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions/setup.d.ts → serverless/services/PrivateAppUserTokenManager.spec.d.ts} +0 -0
- /package/dist/lib/__tests__/{app-functions → serverless}/setup.js +0 -0
- /package/dist/lib/{app-functions/errorReporter.d.ts → errorReporter.d.ts} +0 -0
- /package/dist/lib/{app-functions → proxy}/signing.d.ts +0 -0
- /package/dist/lib/{app-functions → proxy}/signing.js +0 -0
- /package/dist/lib/{app-functions → serverless}/api/privateAppUserToken.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/api/privateAppUserToken.js +0 -0
- /package/dist/lib/{app-functions → serverless}/config.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/context.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/context.js +0 -0
- /package/dist/lib/{app-functions → serverless}/executor.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/secrets.js +0 -0
- /package/dist/lib/{app-functions → serverless}/services/AppFunctionExecutionService.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/services/PrivateAppUserTokenManager.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/services/constants.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/services/constants.js +0 -0
- /package/dist/lib/{app-functions → serverless}/services/messages.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/services/messages.js +0 -0
- /package/dist/lib/{app-functions → serverless}/types.js +0 -0
- /package/dist/lib/{app-functions → serverless}/utils.d.ts +0 -0
- /package/dist/lib/{app-functions → serverless}/utils.js +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
import { APP_FUNCTIONS_DIRNAME, APP_FUNCTIONS_MANIFEST_FILENAME, UNIFIED_FUNCTIONS_DIRNAME, EXECUTION_TIMEOUT_MS, } from "./constants.js";
|
|
4
|
+
import { PLATFORM_VERSION } from "../constants.js";
|
|
5
|
+
import { throwUnhandledPlatformVersionError } from "./utils.js";
|
|
6
|
+
import { Reason, ExecutionError } from "./errors.js";
|
|
7
|
+
function loadMultiFunctionInfoLegacy(config) {
|
|
8
|
+
const srcDir = path.join(config.app.path, APP_FUNCTIONS_DIRNAME);
|
|
9
|
+
if (!fs.existsSync(srcDir)) {
|
|
10
|
+
throw new Error(`Cannot locate app function directory: ${srcDir}`);
|
|
11
|
+
}
|
|
12
|
+
const stats = fs.lstatSync(srcDir);
|
|
13
|
+
if (!stats.isDirectory()) {
|
|
14
|
+
throw new Error(`Invalid app function directory: ${srcDir}`);
|
|
15
|
+
}
|
|
16
|
+
const manifestPath = path.join(srcDir, APP_FUNCTIONS_MANIFEST_FILENAME);
|
|
17
|
+
const manifest = JSON.parse(fs.readFileSync(manifestPath, {
|
|
18
|
+
encoding: 'utf-8',
|
|
19
|
+
}));
|
|
20
|
+
const { appFunctions = {} } = manifest;
|
|
21
|
+
// TODO validation
|
|
22
|
+
return { appFunctions, srcDir };
|
|
23
|
+
}
|
|
24
|
+
function loadMultiFunctionInfoUnified(config) {
|
|
25
|
+
const srcDir = path.join(config.app.path, UNIFIED_FUNCTIONS_DIRNAME);
|
|
26
|
+
if (!fs.existsSync(srcDir)) {
|
|
27
|
+
throw new Error(`Cannot locate functions directory: ${srcDir}`);
|
|
28
|
+
}
|
|
29
|
+
const stats = fs.lstatSync(srcDir);
|
|
30
|
+
if (!stats.isDirectory()) {
|
|
31
|
+
throw new Error(`Invalid functions directory: ${srcDir}`);
|
|
32
|
+
}
|
|
33
|
+
const files = fs.readdirSync(srcDir);
|
|
34
|
+
const hsmetaFiles = files.filter((f) => f.endsWith('-hsmeta.json'));
|
|
35
|
+
const appFunctions = {};
|
|
36
|
+
for (const hsmetaFile of hsmetaFiles) {
|
|
37
|
+
const filePath = path.join(srcDir, hsmetaFile);
|
|
38
|
+
let meta;
|
|
39
|
+
try {
|
|
40
|
+
meta = JSON.parse(fs.readFileSync(filePath, { encoding: 'utf-8' }));
|
|
41
|
+
}
|
|
42
|
+
catch (err) {
|
|
43
|
+
config.logger.warn(`Failed to read or parse ${filePath}: ${err}`);
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (meta.type !== 'app-function') {
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
appFunctions[meta.uid] = {
|
|
50
|
+
file: path.basename(meta.config.entrypoint),
|
|
51
|
+
secrets: meta.config.secretKeys ?? [],
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
return { appFunctions, srcDir };
|
|
55
|
+
}
|
|
56
|
+
export function loadMultiFunctionInfo(config) {
|
|
57
|
+
switch (config.platformVersion) {
|
|
58
|
+
case PLATFORM_VERSION.V20251:
|
|
59
|
+
return loadMultiFunctionInfoLegacy(config);
|
|
60
|
+
case PLATFORM_VERSION.V202603:
|
|
61
|
+
case PLATFORM_VERSION.V202603BETA:
|
|
62
|
+
case PLATFORM_VERSION.UNSTABLE:
|
|
63
|
+
return loadMultiFunctionInfoUnified(config);
|
|
64
|
+
case PLATFORM_VERSION.V20252:
|
|
65
|
+
// We shouldn't run into this specific case due to earlier throwing but we need it just in case an app gets in a weird state.
|
|
66
|
+
throw new ExecutionError({
|
|
67
|
+
reason: Reason.UnsupportedVersion,
|
|
68
|
+
functionName: 'unknown',
|
|
69
|
+
});
|
|
70
|
+
default:
|
|
71
|
+
return throwUnhandledPlatformVersionError(config.platformVersion);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
export function loadFunctionInfo(config, functionName, appId) {
|
|
75
|
+
const { logger } = config;
|
|
76
|
+
const { appFunctions, srcDir } = loadMultiFunctionInfo(config);
|
|
77
|
+
const metadata = appFunctions[functionName];
|
|
78
|
+
if (!metadata) {
|
|
79
|
+
const manifestPath = path.join(srcDir, APP_FUNCTIONS_MANIFEST_FILENAME);
|
|
80
|
+
logger.error(`App function "${functionName}" is not declared in ${manifestPath}`);
|
|
81
|
+
throw new ExecutionError({
|
|
82
|
+
reason: Reason.FunctionNotFound,
|
|
83
|
+
functionName,
|
|
84
|
+
appId,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
// TODO validation
|
|
88
|
+
return { ...metadata, srcDir, name: functionName };
|
|
89
|
+
}
|
|
90
|
+
export function buildServiceConfiguration(appPath, options) {
|
|
91
|
+
return {
|
|
92
|
+
accountId: options.accountId,
|
|
93
|
+
app: { path: appPath },
|
|
94
|
+
functionTimeoutMs: options.functionTimeoutMs ?? EXECUTION_TIMEOUT_MS,
|
|
95
|
+
hubspotApiOrigin: options.hubspotApiOrigin,
|
|
96
|
+
hubspotWebsiteOrigin: options.hubspotWebsiteOrigin,
|
|
97
|
+
logger: options.logger ?? console,
|
|
98
|
+
platformVersion: options.platformVersion ?? PLATFORM_VERSION.V20251,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const APP_FUNCTIONS_DIRNAME = "app.functions";
|
|
2
|
+
export declare const APP_FUNCTIONS_MANIFEST_FILENAME = "serverless.json";
|
|
3
|
+
export declare const UNIFIED_FUNCTIONS_DIRNAME = "functions";
|
|
4
|
+
export declare const DEV_SERVER_DEFAULT_PORT = 6789;
|
|
5
|
+
export declare const EXECUTION_TIMEOUT_MS = 15000;
|
|
6
|
+
export declare const PRIVATE_APP_ACCESS_TOKEN = "PRIVATE_APP_ACCESS_TOKEN";
|
|
7
|
+
export declare const SECRETS_IN_CONTEXT: string[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const APP_FUNCTIONS_DIRNAME = 'app.functions';
|
|
2
|
+
export const APP_FUNCTIONS_MANIFEST_FILENAME = 'serverless.json';
|
|
3
|
+
export const UNIFIED_FUNCTIONS_DIRNAME = 'functions';
|
|
4
|
+
export const DEV_SERVER_DEFAULT_PORT = 6789;
|
|
5
|
+
export const EXECUTION_TIMEOUT_MS = 15_000;
|
|
6
|
+
export const PRIVATE_APP_ACCESS_TOKEN = 'PRIVATE_APP_ACCESS_TOKEN';
|
|
7
|
+
export const SECRETS_IN_CONTEXT = [
|
|
8
|
+
PRIVATE_APP_ACCESS_TOKEN,
|
|
9
|
+
'HS_ENVIRONMENT',
|
|
10
|
+
'HS_HUBLET',
|
|
11
|
+
'HS_SERVERLESS_FUNCTION_ID',
|
|
12
|
+
];
|
|
@@ -4,6 +4,7 @@ export declare const Reason: {
|
|
|
4
4
|
readonly InvalidResponse: "INVALID_RESPONSE";
|
|
5
5
|
readonly InvalidFunction: "INVALID_FUNCTION";
|
|
6
6
|
readonly FunctionNotFound: "FUNCTION_NOT_FOUND";
|
|
7
|
+
readonly UnsupportedVersion: "UNSUPPORTED_VERSION";
|
|
7
8
|
};
|
|
8
9
|
type Reason = (typeof Reason)[keyof typeof Reason];
|
|
9
10
|
export declare class ExecutionError extends Error {
|
|
@@ -5,6 +5,7 @@ export const Reason = {
|
|
|
5
5
|
InvalidResponse: 'INVALID_RESPONSE',
|
|
6
6
|
InvalidFunction: 'INVALID_FUNCTION',
|
|
7
7
|
FunctionNotFound: 'FUNCTION_NOT_FOUND',
|
|
8
|
+
UnsupportedVersion: 'UNSUPPORTED_VERSION',
|
|
8
9
|
};
|
|
9
10
|
export class ExecutionError extends Error {
|
|
10
11
|
details;
|
|
@@ -23,6 +24,7 @@ const ERROR_BUILDERS = {
|
|
|
23
24
|
[Reason.InvalidResponse]: buildServerlessFunctionError_nonJsonResponse,
|
|
24
25
|
[Reason.InvalidFunction]: buildServerlessFunctionError_mainNotFound,
|
|
25
26
|
[Reason.FunctionNotFound]: buildServerlessFunctionError_functionNotFound,
|
|
27
|
+
[Reason.UnsupportedVersion]: buildServerlessFunctionError_unsupportedVersion,
|
|
26
28
|
};
|
|
27
29
|
export function buildBadRequestBody({ details }) {
|
|
28
30
|
const error = ERROR_BUILDERS[details.reason]?.(details);
|
|
@@ -68,6 +70,10 @@ function buildServerlessFunctionError_functionNotFound({ functionName, appId = 0
|
|
|
68
70
|
const errorMessage = `com.hubspot.apicaller.exceptions.ApiFailure: Api[name=app-functions-executor-client, httpMethod=POST, subPath=/v1/app/${appId}/function/${functionName}] Failed to process your request. Error code was '400'. Error message was:\n{"status":"error","message":"The serverless function ${functionName} doesn't exist in this project. Go to the Activity tab for the project to check its deploy status.","correlationId":"bd3bc53f-db78-4c60-9713-b8a98a6303d4","context":{"SERVERLESS_FUNCTION":["${functionName}"]},"category":"VALIDATION_ERROR","subCategory":"AppFunctionsExecutorErrorType.SERVERLESS_FUNCTION_NOT_FOUND"}`;
|
|
69
71
|
return buildServerlessFunctionError(functionName, errorMessage);
|
|
70
72
|
}
|
|
73
|
+
function buildServerlessFunctionError_unsupportedVersion({ functionName, }) {
|
|
74
|
+
const errorMessage = `Serverless functions are not yet supported in this platform version`;
|
|
75
|
+
return buildServerlessFunctionError(functionName, errorMessage);
|
|
76
|
+
}
|
|
71
77
|
function buildServerlessFunctionError(functionName, errorMessage) {
|
|
72
78
|
return {
|
|
73
79
|
subCategory: 'ServerlessActionExecutionError.SERVERLESS_FUNCTION_ERROR',
|
|
@@ -6,11 +6,18 @@ import { loadSecrets, setProperTokenInSecrets } from "./secrets.js";
|
|
|
6
6
|
import { buildContext } from "./context.js";
|
|
7
7
|
import { Reason, ExecutionError } from "./errors.js";
|
|
8
8
|
import { diffLists, formatSeconds, throwUnhandledPlatformVersionError, } from "./utils.js";
|
|
9
|
-
import {
|
|
9
|
+
import { PRIVATE_APP_ACCESS_TOKEN } from "./constants.js";
|
|
10
|
+
import { PLATFORM_VERSION } from "../constants.js";
|
|
10
11
|
const require = createRequire(import.meta.url);
|
|
11
12
|
export async function executeFunction(config, functionName, localExecutionInputs, callback, privateAppUserTokenManager) {
|
|
12
13
|
const { logger } = config;
|
|
13
14
|
const { appId } = localExecutionInputs;
|
|
15
|
+
if (config.platformVersion === PLATFORM_VERSION.V20252) {
|
|
16
|
+
throw new ExecutionError({
|
|
17
|
+
reason: Reason.UnsupportedVersion,
|
|
18
|
+
functionName,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
14
21
|
const functionInfo = loadFunctionInfo(config, functionName, appId);
|
|
15
22
|
const functionPath = path.resolve(path.join(functionInfo.srcDir, functionInfo.file));
|
|
16
23
|
if (!fs.existsSync(functionPath)) {
|
|
@@ -74,24 +81,23 @@ export async function executeFunction(config, functionName, localExecutionInputs
|
|
|
74
81
|
// Catch any error thrown from the function, which may or may not be async
|
|
75
82
|
try {
|
|
76
83
|
switch (config.platformVersion) {
|
|
77
|
-
case PLATFORM_VERSION.
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
resolve(response);
|
|
82
|
-
});
|
|
83
|
-
break;
|
|
84
|
-
case PLATFORM_VERSION.V20232:
|
|
85
|
-
case PLATFORM_VERSION.V20251: {
|
|
84
|
+
case PLATFORM_VERSION.V20251:
|
|
85
|
+
case PLATFORM_VERSION.V202603:
|
|
86
|
+
case PLATFORM_VERSION.V202603BETA:
|
|
87
|
+
case PLATFORM_VERSION.UNSTABLE: {
|
|
86
88
|
const response = await main(context);
|
|
87
89
|
clearTimeout(timeout);
|
|
88
90
|
process.env = savedEnv;
|
|
89
91
|
resolve(response);
|
|
90
92
|
break;
|
|
91
93
|
}
|
|
92
|
-
case PLATFORM_VERSION.V20252:
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
case PLATFORM_VERSION.V20252: {
|
|
95
|
+
clearTimeout(timeout);
|
|
96
|
+
process.env = savedEnv;
|
|
97
|
+
reject(new ExecutionError({
|
|
98
|
+
reason: Reason.UnsupportedVersion,
|
|
99
|
+
functionName,
|
|
100
|
+
}));
|
|
95
101
|
break;
|
|
96
102
|
}
|
|
97
103
|
default:
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { FunctionContext, ServiceConfiguration, PrivateAppUserToken } from './types.ts';
|
|
2
|
+
type Secrets = FunctionContext['secrets'];
|
|
3
|
+
export declare function setProperTokenInSecrets(secrets: Secrets, logger: ServiceConfiguration['logger'], privateAppUserToken?: PrivateAppUserToken): Secrets;
|
|
4
|
+
export declare function loadSecrets(srcDir: string): Secrets;
|
|
5
|
+
export {};
|
|
@@ -4,7 +4,7 @@ import { executeFunction } from "../executor.js";
|
|
|
4
4
|
import { buildServiceConfiguration } from "../config.js";
|
|
5
5
|
import { buildBadRequestBody, buildInternalErrorBody, ExecutionError, } from "../errors.js";
|
|
6
6
|
import { PrivateAppUserTokenManager } from "./PrivateAppUserTokenManager.js";
|
|
7
|
-
import { reportError } from "
|
|
7
|
+
import { reportError } from "../../errorReporter.js";
|
|
8
8
|
export const AppFunctionExecutionService = (partialConfig) => {
|
|
9
9
|
const config = setupConfig(partialConfig);
|
|
10
10
|
const { logger, accountId } = config;
|
|
@@ -3,7 +3,7 @@ import { isHubSpotHttpError } from '@hubspot/local-dev-lib/errors/index';
|
|
|
3
3
|
import { fetchPrivateAppUserToken, createPrivateAppUserToken, updatePrivateAppUserToken, } from "../api/privateAppUserToken.js";
|
|
4
4
|
import { USER_TOKEN_READ, USER_TOKEN_WRITE, TOKEN_TIME_TO_LIVE, TOKEN_REFRESH_THRESHOLD, } from "./constants.js";
|
|
5
5
|
import { generateCahedTokeMessage, generateMissingScopesMessage, generateTokensEnableMessage, generateTokensNotEnabledMessage, generateTokenCachedMessage, generateTokenOpErrorMessage, generateCreateTokenMessage, generateTokenRefreshMessage, generateMissingScopesMoreContextMessage, } from "./messages.js";
|
|
6
|
-
import { reportError } from "
|
|
6
|
+
import { reportError } from "../../errorReporter.js";
|
|
7
7
|
const MINUTES_TO_MS = 60000;
|
|
8
8
|
function getTokenExpirationDate() {
|
|
9
9
|
return new Date(Date.now() + TOKEN_TIME_TO_LIVE * MINUTES_TO_MS).toISOString();
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PLATFORM_VERSION } from '
|
|
1
|
+
import { PLATFORM_VERSION } from '../constants.ts';
|
|
2
2
|
export interface AppFunctionsManifest {
|
|
3
3
|
runtime: string;
|
|
4
4
|
version: string;
|
|
@@ -110,49 +110,6 @@ export interface LocalExecutionInputs {
|
|
|
110
110
|
parameters?: ServerlessExecutionRequest['parameters'];
|
|
111
111
|
event?: ServerlessExecutionRequest['event'];
|
|
112
112
|
}
|
|
113
|
-
export interface LocalDevUrlMapping {
|
|
114
|
-
[hostUrl: string]: string;
|
|
115
|
-
}
|
|
116
|
-
export interface ProxyServiceConfig {
|
|
117
|
-
logger: Pick<typeof console, 'debug' | 'info' | 'warn' | 'error'>;
|
|
118
|
-
localDevUrlMapping: LocalDevUrlMapping;
|
|
119
|
-
accountId: number;
|
|
120
|
-
allowedUrls: string[];
|
|
121
|
-
}
|
|
122
|
-
interface Context {
|
|
123
|
-
correlationId: string[];
|
|
124
|
-
httpMethod: string[];
|
|
125
|
-
appServerStatusCode?: string[];
|
|
126
|
-
portalId: string[];
|
|
127
|
-
requestUri: string[];
|
|
128
|
-
}
|
|
129
|
-
export interface AppProxyServiceSuccessResponse {
|
|
130
|
-
status: 'success';
|
|
131
|
-
responseBody: unknown;
|
|
132
|
-
context: Context;
|
|
133
|
-
}
|
|
134
|
-
export interface AppProxyServiceErrorResponse {
|
|
135
|
-
status: 'error';
|
|
136
|
-
category: string;
|
|
137
|
-
message: string;
|
|
138
|
-
context: Context;
|
|
139
|
-
errors?: unknown[];
|
|
140
|
-
responseBody?: unknown;
|
|
141
|
-
}
|
|
142
|
-
export type AppProxyServiceResponse = AppProxyServiceSuccessResponse | AppProxyServiceErrorResponse;
|
|
143
|
-
export interface ProxyServerError {
|
|
144
|
-
status: number;
|
|
145
|
-
data?: unknown;
|
|
146
|
-
message: string;
|
|
147
|
-
category: string;
|
|
148
|
-
}
|
|
149
|
-
export interface ProxyRequest {
|
|
150
|
-
requestUri: string;
|
|
151
|
-
method: string;
|
|
152
|
-
requestTimeoutMillis: number;
|
|
153
|
-
requestBody: unknown;
|
|
154
|
-
requestHeaders?: Record<string, string>;
|
|
155
|
-
}
|
|
156
113
|
export type PrivateAppUserToken = {
|
|
157
114
|
userId: number;
|
|
158
115
|
portalId: number;
|
package/dist/lib/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PLATFORM_VERSION, PRIVATE_APP, PUBLIC_APP } from './constants.ts';
|
|
2
|
-
import { LocalDevUrlMapping } from './
|
|
2
|
+
import { LocalDevUrlMapping } from './proxy/types.ts';
|
|
3
3
|
export interface ObjectTypes {
|
|
4
4
|
name: string;
|
|
5
5
|
}
|
|
@@ -69,9 +69,14 @@ export interface PublicAppAuth {
|
|
|
69
69
|
optionalScopes: string[];
|
|
70
70
|
additionalScopes: string[];
|
|
71
71
|
}
|
|
72
|
+
export type UnifiedAppDistribution = 'private' | 'marketplace';
|
|
73
|
+
export declare enum UnifiedAppDistributionTypes {
|
|
74
|
+
PRIVATE = "private",
|
|
75
|
+
MARKETPLACE = "marketplace"
|
|
76
|
+
}
|
|
72
77
|
export declare enum UnifiedAppAuthTypes {
|
|
73
|
-
OAUTH = "
|
|
74
|
-
STATIC = "
|
|
78
|
+
OAUTH = "oauth",
|
|
79
|
+
STATIC = "static"
|
|
75
80
|
}
|
|
76
81
|
export interface UnifiedAppAuth {
|
|
77
82
|
type: UnifiedAppAuthTypes;
|
|
@@ -150,6 +155,7 @@ export interface UnifiedAppComponent {
|
|
|
150
155
|
config: {
|
|
151
156
|
description: string;
|
|
152
157
|
name: string;
|
|
158
|
+
distribution: UnifiedAppDistribution;
|
|
153
159
|
logo?: string;
|
|
154
160
|
auth: UnifiedAppAuth;
|
|
155
161
|
permittedUrls?: {
|
|
@@ -177,7 +183,9 @@ export interface UnifiedAppComponent {
|
|
|
177
183
|
};
|
|
178
184
|
}
|
|
179
185
|
export type UnifiedAppConfig = Omit<PublicAppConfig, 'auth'> & {
|
|
186
|
+
unified: true;
|
|
180
187
|
auth: UnifiedAppAuth;
|
|
188
|
+
distribution: UnifiedAppDistribution;
|
|
181
189
|
isPublicApp: boolean;
|
|
182
190
|
variables?: {
|
|
183
191
|
[key: string]: string | number | boolean;
|
|
@@ -281,6 +289,7 @@ export interface DevModeSetupArguments extends DevModeBaseSetupArguments {
|
|
|
281
289
|
export interface UnifiedDevModeSetupArguments extends DevModeBaseSetupArguments {
|
|
282
290
|
components: UnifiedProjectComponentMap;
|
|
283
291
|
profileData?: ProfileVariables;
|
|
292
|
+
platformVersion?: PlatformVersion;
|
|
284
293
|
}
|
|
285
294
|
export type ProfileVariableValue = string | number | boolean;
|
|
286
295
|
export type ProfileVariables = Record<string, ProfileVariableValue>;
|
package/dist/lib/types.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
export var UnifiedAppDistributionTypes;
|
|
2
|
+
(function (UnifiedAppDistributionTypes) {
|
|
3
|
+
UnifiedAppDistributionTypes["PRIVATE"] = "private";
|
|
4
|
+
UnifiedAppDistributionTypes["MARKETPLACE"] = "marketplace";
|
|
5
|
+
})(UnifiedAppDistributionTypes || (UnifiedAppDistributionTypes = {}));
|
|
1
6
|
export var UnifiedAppAuthTypes;
|
|
2
7
|
(function (UnifiedAppAuthTypes) {
|
|
3
|
-
UnifiedAppAuthTypes["OAUTH"] = "
|
|
4
|
-
UnifiedAppAuthTypes["STATIC"] = "
|
|
8
|
+
UnifiedAppAuthTypes["OAUTH"] = "oauth";
|
|
9
|
+
UnifiedAppAuthTypes["STATIC"] = "static";
|
|
5
10
|
})(UnifiedAppAuthTypes || (UnifiedAppAuthTypes = {}));
|
|
6
11
|
export var UnifiedComponentTypes;
|
|
7
12
|
(function (UnifiedComponentTypes) {
|
package/dist/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AppConfig, ExtensionConfig } from './types.ts';
|
|
1
|
+
import { AppConfig, UnifiedAppConfig, ExtensionConfig } from './types.ts';
|
|
2
2
|
export declare function getUrlSafeFileName(filePath: string): string;
|
|
3
3
|
export declare function stripAnsiColorCodes(stringWithColorCodes: string | undefined | null): string | null;
|
|
4
4
|
export declare function loadManifest(outputDir: string, output: string): any;
|
|
@@ -12,6 +12,7 @@ export declare class UnhandledPlatformVersionError extends Error {
|
|
|
12
12
|
constructor(platformVersion: never);
|
|
13
13
|
}
|
|
14
14
|
export declare function throwUnhandledPlatformVersionError(platformVersion: never): never;
|
|
15
|
+
export declare function isUnifiedAppConfig(config: AppConfig | UnifiedAppConfig): config is UnifiedAppConfig;
|
|
15
16
|
export declare function extractAllowedUrls(appConfig?: AppConfig): string[];
|
|
16
17
|
/**
|
|
17
18
|
* This function generates a deterministic hash from any number of arguments
|
package/dist/lib/utils.js
CHANGED
|
@@ -64,6 +64,9 @@ export class UnhandledPlatformVersionError extends Error {
|
|
|
64
64
|
export function throwUnhandledPlatformVersionError(platformVersion) {
|
|
65
65
|
throw new UnhandledPlatformVersionError(platformVersion);
|
|
66
66
|
}
|
|
67
|
+
export function isUnifiedAppConfig(config) {
|
|
68
|
+
return 'unified' in config && config.unified === true;
|
|
69
|
+
}
|
|
67
70
|
export function extractAllowedUrls(appConfig) {
|
|
68
71
|
if (!appConfig || !('allowedUrls' in appConfig) || !appConfig.allowedUrls) {
|
|
69
72
|
return [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hubspot/ui-extensions-dev-server",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,27 +26,30 @@
|
|
|
26
26
|
"access": "public"
|
|
27
27
|
},
|
|
28
28
|
"exports": {
|
|
29
|
-
".": "./dist/index.js"
|
|
29
|
+
".": "./dist/index.js",
|
|
30
|
+
"./build": "./dist/lib/build.js"
|
|
30
31
|
},
|
|
31
32
|
"files": [
|
|
32
33
|
"dist"
|
|
33
34
|
],
|
|
34
35
|
"license": "MIT",
|
|
35
36
|
"dependencies": {
|
|
37
|
+
"chalk": "5.4.1",
|
|
38
|
+
"estraverse": "5.3.0",
|
|
39
|
+
"vite": "6.3.6"
|
|
40
|
+
},
|
|
41
|
+
"optionalDependencies": {
|
|
36
42
|
"@hubspot/api-client": "12.0.1",
|
|
37
43
|
"@hubspot/local-dev-lib": "5.1.1",
|
|
38
44
|
"@sentry/node": "10.37.0",
|
|
39
45
|
"axios": "1.13.5",
|
|
40
|
-
"chalk": "5.4.1",
|
|
41
46
|
"commander": "13.1.0",
|
|
42
47
|
"cors": "2.8.6",
|
|
43
48
|
"detect-port": "2.1.0",
|
|
44
49
|
"dotenv": "^17.3.1",
|
|
45
|
-
"estraverse": "5.3.0",
|
|
46
50
|
"express": "5.1.0",
|
|
47
51
|
"inquirer": "12.9.6",
|
|
48
52
|
"ora": "8.2.0",
|
|
49
|
-
"vite": "6.3.6",
|
|
50
53
|
"ws": "^8.18.3"
|
|
51
54
|
},
|
|
52
55
|
"devDependencies": {
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-fails.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.main = async (__context = {}, callback) => {
|
|
3
|
-
// Asynchronous app functions are technically not supported.
|
|
4
|
-
// If a function makes an async call, it must invoke callback to return the result.
|
|
5
|
-
// Any error thrown in the async function will be caught by the Lambda handler.
|
|
6
|
-
const { data } = await Promise.reject(new Error('fail'));
|
|
7
|
-
callback(data);
|
|
8
|
-
};
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-fails.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): Promise<void>;
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-succeeds.cjs
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.main = async (__context = {}, callback) => {
|
|
3
|
-
// Asynchronous app functions are technically not supported.
|
|
4
|
-
// If a function makes an async call, it must invoke callback to return the result.
|
|
5
|
-
// Any error thrown in the async function will be caught by the Lambda handler.
|
|
6
|
-
const { data } = await Promise.resolve({ data: { result: 'simulated' } });
|
|
7
|
-
callback(data);
|
|
8
|
-
};
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-async-succeeds.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): Promise<void>;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.main = (__context = {}, callback) => {
|
|
3
|
-
// Floating promises are not recommended. Callback and error from the promise may not work as expected.
|
|
4
|
-
// The purpose of this test case is to validate/document the behavior.
|
|
5
|
-
Promise.reject(new Error('fail'))
|
|
6
|
-
.then((res) => callback(res.data))
|
|
7
|
-
.catch((err) => callback({ error: `${err}` }));
|
|
8
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.main = (__context = {}, callback) => {
|
|
3
|
-
// Floating promises are not recommended. Callback and error from the promise may not work as expected.
|
|
4
|
-
// The purpose of this test case is to validate/document the behavior.
|
|
5
|
-
Promise.resolve({ data: { result: 'simulated' } })
|
|
6
|
-
.then((res) => callback(res.data))
|
|
7
|
-
.catch((err) => callback({ error: `${err}` }));
|
|
8
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function notMain(__context: {} | undefined, callback: any): void;
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-echos-input.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(context: {} | undefined, callback: any): void;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): void;
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-function.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): void;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.main = (__context = {}, callback) => {
|
|
3
|
-
// Asynchronous app functions are technically not supported.
|
|
4
|
-
// If a function makes an async call, it must invoke callback to return the result.
|
|
5
|
-
// Any error thrown in the promise will be caught by the Lambda handler.
|
|
6
|
-
return Promise.reject(new Error('fail')).then((res) => callback(res.data));
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): Promise<any>;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.main = (__context = {}, callback) => {
|
|
3
|
-
// Asynchronous app functions are technically not supported.
|
|
4
|
-
// If a function makes an async call, it must invoke callback to return the result.
|
|
5
|
-
// Any error thrown in the promise will be caught by the Lambda handler.
|
|
6
|
-
return Promise.resolve({ data: { result: 'simulated' } }).then((res) => callback(res.data));
|
|
7
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): Promise<any>;
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-text.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): void;
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-returns-undefined.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): void;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
exports.main = (context = {}, callback) => {
|
|
3
|
-
const parameters = context.parameters || {};
|
|
4
|
-
const delayMs = parameters.delayMs || 60_000;
|
|
5
|
-
const startedAt = Date.now();
|
|
6
|
-
setTimeout(() => callback({
|
|
7
|
-
status: 'success',
|
|
8
|
-
elapsedMs: Date.now() - startedAt,
|
|
9
|
-
}), delayMs);
|
|
10
|
-
};
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-times-out.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(context: {} | undefined, callback: any): void;
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-undeclared.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(__context: {} | undefined, callback: any): void;
|
package/dist/lib/__tests__/app-functions/fixtures/v2023.1/app.functions/func-uses-secret.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function main(context: {} | undefined, callback: any): void;
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { APP_FUNCTIONS_DIRNAME, APP_FUNCTIONS_MANIFEST_FILENAME, EXECUTION_TIMEOUT_MS, PLATFORM_VERSION, } from "./constants.js";
|
|
4
|
-
import { Reason, ExecutionError } from "./errors.js";
|
|
5
|
-
export function loadMultiFunctionInfo(config) {
|
|
6
|
-
const srcDir = path.join(config.app.path, APP_FUNCTIONS_DIRNAME);
|
|
7
|
-
if (!fs.existsSync(srcDir)) {
|
|
8
|
-
throw new Error(`Cannot locate app function directory: ${srcDir}`);
|
|
9
|
-
}
|
|
10
|
-
const stats = fs.lstatSync(srcDir);
|
|
11
|
-
if (!stats.isDirectory()) {
|
|
12
|
-
throw new Error(`Invalid app function directory: ${srcDir}`);
|
|
13
|
-
}
|
|
14
|
-
const manifestPath = path.join(srcDir, APP_FUNCTIONS_MANIFEST_FILENAME);
|
|
15
|
-
const manifest = JSON.parse(fs.readFileSync(manifestPath, {
|
|
16
|
-
encoding: 'utf-8',
|
|
17
|
-
}));
|
|
18
|
-
const { appFunctions = {} } = manifest;
|
|
19
|
-
// TODO validation
|
|
20
|
-
return { appFunctions, srcDir };
|
|
21
|
-
}
|
|
22
|
-
export function loadFunctionInfo(config, functionName, appId) {
|
|
23
|
-
const { logger } = config;
|
|
24
|
-
const { appFunctions, srcDir } = loadMultiFunctionInfo(config);
|
|
25
|
-
const metadata = appFunctions[functionName];
|
|
26
|
-
if (!metadata) {
|
|
27
|
-
const manifestPath = path.join(srcDir, APP_FUNCTIONS_MANIFEST_FILENAME);
|
|
28
|
-
logger.error(`App function "${functionName}" is not declared in ${manifestPath}`);
|
|
29
|
-
throw new ExecutionError({
|
|
30
|
-
reason: Reason.FunctionNotFound,
|
|
31
|
-
functionName,
|
|
32
|
-
appId,
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
// TODO validation
|
|
36
|
-
return { ...metadata, srcDir, name: functionName };
|
|
37
|
-
}
|
|
38
|
-
export function buildServiceConfiguration(appPath, options) {
|
|
39
|
-
return {
|
|
40
|
-
accountId: options.accountId,
|
|
41
|
-
app: { path: appPath },
|
|
42
|
-
functionTimeoutMs: options.functionTimeoutMs ?? EXECUTION_TIMEOUT_MS,
|
|
43
|
-
hubspotApiOrigin: options.hubspotApiOrigin,
|
|
44
|
-
hubspotWebsiteOrigin: options.hubspotWebsiteOrigin,
|
|
45
|
-
logger: options.logger ?? console,
|
|
46
|
-
platformVersion: options.platformVersion ?? PLATFORM_VERSION.V20231,
|
|
47
|
-
};
|
|
48
|
-
}
|