From 59649b6c81c332ab7bac503150fe3d21bdde380e Mon Sep 17 00:00:00 2001 From: Artem Demochko Date: Thu, 5 Feb 2026 10:07:08 +0200 Subject: [PATCH 1/4] Simplify function schemas --- src/core/resources/function/config.ts | 17 ++++------------- src/core/resources/function/schema.ts | 6 +++--- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/src/core/resources/function/config.ts b/src/core/resources/function/config.ts index 1a592d36..1da93942 100644 --- a/src/core/resources/function/config.ts +++ b/src/core/resources/function/config.ts @@ -8,7 +8,7 @@ import type { } from "@/core/resources/function/schema.js"; import { FunctionConfigSchema, - FunctionSchema, + BackendFunctionSchema, } from "@/core/resources/function/schema.js"; import { pathExists, readJsonFile } from "@/core/utils/fs.js"; @@ -42,22 +42,13 @@ export async function readFunction( ); } - const files = await globby("*.{js,ts,json}", { + const filePaths = await globby("*.{js,ts,json}", { cwd: functionDir, absolute: true, }); - const functionData = { ...config, entryPath, files }; - const result = FunctionSchema.safeParse(functionData); - if (!result.success) { - throw new SchemaValidationError( - "Invalid function", - result.error, - configPath - ); - } - - return result.data; + const functionData: BackendFunction = { ...config, entryPath, filePaths }; + return functionData; } export async function readAllFunctions( diff --git a/src/core/resources/function/schema.ts b/src/core/resources/function/schema.ts index e3021d63..c12adb45 100644 --- a/src/core/resources/function/schema.ts +++ b/src/core/resources/function/schema.ts @@ -16,9 +16,9 @@ export const FunctionConfigSchema = z.object({ entry: z.string().min(1, "Entry point cannot be empty"), }); -export const FunctionSchema = FunctionConfigSchema.extend({ +export const BackendFunctionSchema = FunctionConfigSchema.extend({ entryPath: z.string().min(1, "Entry path cannot be empty"), - files: z.array(z.string()).min(1, "Function must have at least one file"), + filePaths: z.array(z.string()).min(1, "Function must have at least one file"), }); export const FunctionDeploySchema = z.object({ @@ -38,7 +38,7 @@ export const DeployFunctionsResponseSchema = z.object({ }); export type FunctionConfig = z.infer; -export type BackendFunction = z.infer; +export type BackendFunction = z.infer; export type FunctionFile = z.infer; export type FunctionDeploy = z.infer; export type DeployFunctionsResponse = z.infer< From 26485a71bd3e3fc9a7bd628236453cec49e616fd Mon Sep 17 00:00:00 2001 From: Artem Demochko Date: Thu, 5 Feb 2026 10:10:47 +0200 Subject: [PATCH 2/4] fix --- src/core/resources/function/deploy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/resources/function/deploy.ts b/src/core/resources/function/deploy.ts index 88a52a76..0607d18f 100644 --- a/src/core/resources/function/deploy.ts +++ b/src/core/resources/function/deploy.ts @@ -12,7 +12,7 @@ async function loadFunctionCode( fn: BackendFunction ): Promise { const loadedFiles: FunctionFile[] = await Promise.all( - fn.files.map(async (filePath) => { + fn.filePaths.map(async (filePath) => { const content = await readTextFile(filePath); return { path: basename(filePath), content }; }) From 58e0fb598f32a9ead6e9b1c95b9d731aad3e3497 Mon Sep 17 00:00:00 2001 From: Artem Demochko Date: Thu, 5 Feb 2026 10:13:14 +0200 Subject: [PATCH 3/4] fix --- src/core/resources/function/config.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/core/resources/function/config.ts b/src/core/resources/function/config.ts index 1da93942..c5f9de25 100644 --- a/src/core/resources/function/config.ts +++ b/src/core/resources/function/config.ts @@ -1,5 +1,5 @@ -import { dirname, join } from "node:path"; import { globby } from "globby"; +import { dirname, join } from "node:path"; import { FUNCTION_CONFIG_FILE } from "@/core/consts.js"; import { FileNotFoundError, SchemaValidationError } from "@/core/errors.js"; import type { @@ -8,7 +8,6 @@ import type { } from "@/core/resources/function/schema.js"; import { FunctionConfigSchema, - BackendFunctionSchema, } from "@/core/resources/function/schema.js"; import { pathExists, readJsonFile } from "@/core/utils/fs.js"; From 9b3c8ab44bb99a86473c982a7740fa8ef7f12e49 Mon Sep 17 00:00:00 2001 From: Artem Demochko Date: Thu, 5 Feb 2026 10:14:34 +0200 Subject: [PATCH 4/4] lint --- src/core/resources/function/config.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/core/resources/function/config.ts b/src/core/resources/function/config.ts index c5f9de25..563c3b25 100644 --- a/src/core/resources/function/config.ts +++ b/src/core/resources/function/config.ts @@ -1,14 +1,12 @@ -import { globby } from "globby"; import { dirname, join } from "node:path"; +import { globby } from "globby"; import { FUNCTION_CONFIG_FILE } from "@/core/consts.js"; import { FileNotFoundError, SchemaValidationError } from "@/core/errors.js"; import type { BackendFunction, FunctionConfig, } from "@/core/resources/function/schema.js"; -import { - FunctionConfigSchema, -} from "@/core/resources/function/schema.js"; +import { FunctionConfigSchema } from "@/core/resources/function/schema.js"; import { pathExists, readJsonFile } from "@/core/utils/fs.js"; export async function readFunctionConfig(