UNPKG

life

Version:

Life.js is the first fullstack framework to build agentic web applications. It is minimal, extensible, and typesafe. Well, everything you love.

101 lines (98 loc) 2.22 kB
import { __name } from "./chunk-2D3UJWOA.mjs"; // shared/method-name.ts var SEPARATOR_PATTERN = /[-\s_]+/; function toMethodName(input) { return input.split(SEPARATOR_PATTERN).filter(Boolean).map( (word, index) => index === 0 ? word.toLowerCase() : word.charAt(0).toUpperCase() + word.slice(1).toLowerCase() ).join(""); } __name(toMethodName, "toMethodName"); // plugins/server/types.ts import z from "zod"; var eventSourceSchema = z.discriminatedUnion("type", [ z.object({ type: z.literal("handler"), plugin: z.string(), handler: z.string(), event: z.string() }), z.object({ type: z.literal("server"), name: z.string() }), z.object({ type: z.literal("client"), name: z.string() }) ]); var pluginEventSchema = z.object({ id: z.string(), name: z.string(), urgent: z.boolean().prefault(false), data: z.any().prefault(null), created: z.object({ at: z.number(), by: eventSourceSchema }), edited: z.array( z.object({ at: z.number(), by: z.object({ plugin: z.string(), handler: z.string() }), reason: z.string(), dataBefore: z.any(), dataAfter: z.any() }) ).or(z.literal(false)).default(false), dropped: z.object({ at: z.number(), by: z.object({ plugin: z.string(), handler: z.string() }), reason: z.string() }).or(z.literal(false)).prefault(false), contextChanges: z.array( z.object({ at: z.number(), byHandler: z.string(), valueBefore: z.any(), valueAfter: z.any() }) ).prefault([]) }); var pluginEventInputSchema = pluginEventSchema.omit({ id: true, created: true, edited: true, dropped: true, contextChanges: true }); var internalEventsDef = [ { name: "plugin.start", dataSchema: z.object({ isRestart: z.boolean().prefault(false), restartCount: z.number().prefault(0) }) }, { name: "plugin.stop" }, { name: "plugin.test" }, { name: "plugin.error", dataSchema: z.object({ error: z.custom(), event: pluginEventSchema }) } ]; export { toMethodName, pluginEventInputSchema, internalEventsDef }; //# sourceMappingURL=chunk-X455LF5V.mjs.map