diff --git a/packages/spec/src/system/plugin.test.ts b/packages/spec/src/system/plugin.test.ts index 821108fd7..1ac0a8357 100644 --- a/packages/spec/src/system/plugin.test.ts +++ b/packages/spec/src/system/plugin.test.ts @@ -1,10 +1,10 @@ import { describe, it, expect } from 'vitest'; -import { - PluginContextSchema, +import { + PluginContextSchema, PluginLifecycleSchema, PluginSchema, type PluginContextData, - type PluginLifecycleHooks, + type PluginLifecycleCallbacks, type PluginDefinition, } from './plugin.zod'; @@ -139,13 +139,13 @@ describe('PluginContextSchema', () => { describe('PluginLifecycleSchema', () => { it('should accept empty lifecycle (all hooks optional)', () => { - const lifecycle: PluginLifecycleHooks = {}; + const lifecycle: PluginLifecycleCallbacks = {}; expect(() => PluginLifecycleSchema.parse(lifecycle)).not.toThrow(); }); it('should accept lifecycle with onInstall hook', () => { - const lifecycle: PluginLifecycleHooks = { + const lifecycle: PluginLifecycleCallbacks = { onInstall: async (context: PluginContextData) => { // Installation logic }, @@ -155,7 +155,7 @@ describe('PluginLifecycleSchema', () => { }); it('should accept lifecycle with onEnable hook', () => { - const lifecycle: PluginLifecycleHooks = { + const lifecycle: PluginLifecycleCallbacks = { onEnable: async (context: PluginContextData) => { // Enable logic }, @@ -165,7 +165,7 @@ describe('PluginLifecycleSchema', () => { }); it('should accept lifecycle with onDisable hook', () => { - const lifecycle: PluginLifecycleHooks = { + const lifecycle: PluginLifecycleCallbacks = { onDisable: async (context: PluginContextData) => { // Disable logic }, @@ -175,7 +175,7 @@ describe('PluginLifecycleSchema', () => { }); it('should accept lifecycle with onUninstall hook', () => { - const lifecycle: PluginLifecycleHooks = { + const lifecycle: PluginLifecycleCallbacks = { onUninstall: async (context: PluginContextData) => { // Uninstall logic }, @@ -185,7 +185,7 @@ describe('PluginLifecycleSchema', () => { }); it('should accept lifecycle with onUpgrade hook', () => { - const lifecycle: PluginLifecycleHooks = { + const lifecycle: PluginLifecycleCallbacks = { onUpgrade: async (context: PluginContextData, fromVersion: string, toVersion: string) => { // Upgrade logic }, @@ -195,7 +195,7 @@ describe('PluginLifecycleSchema', () => { }); it('should accept lifecycle with all hooks', () => { - const lifecycle: PluginLifecycleHooks = { + const lifecycle: PluginLifecycleCallbacks = { onInstall: async (context: PluginContextData) => { await context.ql.object('plugin_data').syncSchema(); }, diff --git a/packages/spec/src/system/plugin.zod.ts b/packages/spec/src/system/plugin.zod.ts index bdf21a5d1..549215624 100644 --- a/packages/spec/src/system/plugin.zod.ts +++ b/packages/spec/src/system/plugin.zod.ts @@ -172,7 +172,7 @@ export const PluginLifecycleSchema = z.object({ .args(PluginContextSchema) .returns(z.promise(z.void())) .optional() - .describe('Hook called on plugin installation'), + .describe('Lifecycle callback on plugin installation'), /** * Called when the plugin is enabled. @@ -184,7 +184,7 @@ export const PluginLifecycleSchema = z.object({ .args(PluginContextSchema) .returns(z.promise(z.void())) .optional() - .describe('Hook called when plugin is enabled'), + .describe('Lifecycle callback when plugin is enabled'), /** * Called when the plugin is disabled. @@ -196,7 +196,7 @@ export const PluginLifecycleSchema = z.object({ .args(PluginContextSchema) .returns(z.promise(z.void())) .optional() - .describe('Hook called when plugin is disabled'), + .describe('Lifecycle callback when plugin is disabled'), /** * Called when the plugin is uninstalled. @@ -208,7 +208,7 @@ export const PluginLifecycleSchema = z.object({ .args(PluginContextSchema) .returns(z.promise(z.void())) .optional() - .describe('Hook called on plugin uninstallation'), + .describe('Lifecycle callback on plugin uninstallation'), /** * Called when the plugin is upgraded to a new version. @@ -222,7 +222,7 @@ export const PluginLifecycleSchema = z.object({ .args(PluginContextSchema, z.string(), z.string()) .returns(z.promise(z.void())) .optional() - .describe('Hook called on plugin upgrade'), + .describe('Lifecycle callback on plugin upgrade'), }); /** @@ -248,5 +248,5 @@ export const PluginSchema = PluginLifecycleSchema.extend({ * TypeScript types */ export type PluginContextData = z.infer; -export type PluginLifecycleHooks = z.infer; +export type PluginLifecycleCallbacks = z.infer; export type PluginDefinition = z.infer;