mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-18 10:37:27 +00:00
refactor(config): share install record schema shape
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import path from "node:path";
|
||||
import { z } from "zod";
|
||||
import { InstallRecordShape } from "./zod-schema.installs.js";
|
||||
import { sensitive } from "./zod-schema.sensitive.js";
|
||||
|
||||
function isSafeRelativeModulePath(raw: string): boolean {
|
||||
@@ -96,12 +97,7 @@ const HookConfigSchema = z
|
||||
|
||||
const HookInstallRecordSchema = z
|
||||
.object({
|
||||
source: z.union([z.literal("npm"), z.literal("archive"), z.literal("path")]),
|
||||
spec: z.string().optional(),
|
||||
sourcePath: z.string().optional(),
|
||||
installPath: z.string().optional(),
|
||||
version: z.string().optional(),
|
||||
installedAt: z.string().optional(),
|
||||
...InstallRecordShape,
|
||||
hooks: z.array(z.string()).optional(),
|
||||
})
|
||||
.strict();
|
||||
|
||||
16
src/config/zod-schema.installs.ts
Normal file
16
src/config/zod-schema.installs.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export const InstallSourceSchema = z.union([
|
||||
z.literal("npm"),
|
||||
z.literal("archive"),
|
||||
z.literal("path"),
|
||||
]);
|
||||
|
||||
export const InstallRecordShape = {
|
||||
source: InstallSourceSchema,
|
||||
spec: z.string().optional(),
|
||||
sourcePath: z.string().optional(),
|
||||
installPath: z.string().optional(),
|
||||
version: z.string().optional(),
|
||||
installedAt: z.string().optional(),
|
||||
} as const;
|
||||
@@ -4,6 +4,7 @@ import { AgentsSchema, AudioSchema, BindingsSchema, BroadcastSchema } from "./zo
|
||||
import { ApprovalsSchema } from "./zod-schema.approvals.js";
|
||||
import { HexColorSchema, ModelsConfigSchema } from "./zod-schema.core.js";
|
||||
import { HookMappingSchema, HooksGmailSchema, InternalHooksSchema } from "./zod-schema.hooks.js";
|
||||
import { InstallRecordShape } from "./zod-schema.installs.js";
|
||||
import { ChannelsSchema } from "./zod-schema.providers.js";
|
||||
import { sensitive } from "./zod-schema.sensitive.js";
|
||||
import {
|
||||
@@ -639,12 +640,7 @@ export const OpenClawSchema = z
|
||||
z.string(),
|
||||
z
|
||||
.object({
|
||||
source: z.union([z.literal("npm"), z.literal("archive"), z.literal("path")]),
|
||||
spec: z.string().optional(),
|
||||
sourcePath: z.string().optional(),
|
||||
installPath: z.string().optional(),
|
||||
version: z.string().optional(),
|
||||
installedAt: z.string().optional(),
|
||||
...InstallRecordShape,
|
||||
})
|
||||
.strict(),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user