A comprehensive TypeScript type definitions and Zod schema validation library for developing Choiceform Atomemo plugins. This library ensures type safety at compile time and runtime validation for plugin definitions. Plugins must declare the implementation language via the lang field (currently elixir or typescript).
- π― Type Safety: Complete TypeScript type definitions for plugin development
- β Runtime Validation: Zod schema validation for plugin definitions
- π i18n Support: Built-in internationalization text types and validation
- π¨ Flexible Property System: Support for various data types and UI components
- π§ Conditional Display: Conditional display logic based on other property values
- π¦ Tree-shakeable: Optimized exports for minimal bundle size
# Using npm
npm install @choiceopen/atomemo-plugin-schema zod
# Using yarn
yarn add @choiceopen/atomemo-plugin-schema zod
# Using pnpm
pnpm add @choiceopen/atomemo-plugin-schema zod
# Using bun
bun add @choiceopen/atomemo-plugin-schema zodNote:
zodis a peer dependency and must be installed separately.
import type {
PluginDefinition,
CredentialDefinition,
DataSourceDefinition,
ModelDefinition,
ToolDefinition,
Property,
} from '@choiceopen/atomemo-plugin-schema/types';import {
PluginDefinitionSchema,
CredentialDefinitionSchema,
DataSourceDefinitionSchema,
ModelDefinitionSchema,
ToolDefinitionSchema,
PropertySchema,
} from '@choiceopen/atomemo-plugin-schema/schemas';import { PluginDefinitionSchema } from '@choiceopen/atomemo-plugin-schema/schemas';
import type { PluginDefinition } from '@choiceopen/atomemo-plugin-schema/types';
const pluginDefinition: PluginDefinition = {
name: 'my-plugin',
display_name: {
en_US: 'My Plugin',
zh_CN: 'ζηζδ»Ά',
},
description: {
en_US: 'A sample plugin for Atomemo',
zh_CN: 'δΈδΈͺη€ΊδΎζδ»Ά',
},
icon: 'https://example.com/icon.png',
version: '1.0.0',
locales: ['en', 'zh_CN'],
lang: 'typescript',
};
// Validate at runtime
const result = PluginDefinitionSchema.safeParse(pluginDefinition);
if (!result.success) {
console.error('Validation failed:', result.error);
}A plugin definition contains metadata about your plugin:
- Basic information: name, display name, description, icon
- Author information: name, email, repository URL, version
- Supported languages list
Feature definitions include:
- Credential: For storing and managing authentication information
- DataSource: For connecting to external data sources
- Model: For defining LLM models
- Tool: For executing specific functions
The property system is the core of defining plugin parameters and settings:
Property Types:
string: String typenumber/integer: Number typeboolean: Boolean typearray: Array typeobject: Object typediscriminated_union: Discriminated union typecredential_id: Credential ID typeencrypted_string: Encrypted string type
Property Features:
- Constant values (
constant) - Default values (
default) - Enum values (
enum) - Range constraints (
min_length,max_length,minimum,maximum,min_items,max_items) - Conditional display (
display.hide/show) - AI configuration (
ai.llm_description)
Each property type can be configured with different UI components:
String type components:
input,textarea,code-editorselect,radio-groupemoji-picker,color-picker,credential-select
Number type components:
number-input,slider
Boolean type components:
switch
Array type components:
multi-select,tag-input,key-value-editor,slider,array-section
Object type components:
collapsible-panel,json-schema-editor,conditions-editor,code-editor
Supports conditional display logic based on other property values:
Operators:
- Comparison:
$eq,$ne,$gt,$gte,$lt,$lte - Existence check:
$exists - Set operations:
$in,$nin - Regex matching:
$regex,$options - Array operations:
$size,$mod - Logical combination:
$and,$or,$nor
The package exports two main entry points:
@choiceopen/atomemo-plugin-schema/types- TypeScript type definitions@choiceopen/atomemo-plugin-schema/schemas- Zod schema validators
In development environments, the package exports source files directly for better debugging and hot reload support:
{
"./schemas": {
"development": "./src/schemas.ts",
"default": "./dist/schemas.js"
},
"./types": {
"development": "./src/types.ts",
"default": "./dist/types.js"
}
}- Bun >= 1.0.0
- Node.js >= 18.0.0 (if not using Bun)
# Install dependencies
bun install# Watch and rebuild in development
bun run dev
# Build the library
bun run build
# Run linting and formatting
bun run check
# Run type checking
bun run typecheck
# Run unit tests
bun run testThis project uses Biome for unified linting and formatting. For the best development experience, install the Biome VS Code extension.
atomemo-plugin-schema/
βββ src/ # Source code
β βββ schemas/ # Zod schema validation modules
β βββ types/ # TypeScript type definitions
β βββ utils/ # Utility functions
β βββ schemas.ts # Schema exports
β βββ types.ts # Type exports
βββ tests/ # Test files
βββ dist/ # Build output
βββ [config files] # package.json, tsconfig.json, etc.
Contributions are welcome! Please follow these guidelines:
- Follow the project's code style (use Biome for formatting)
- Ensure all tests pass
- Ensure type safety (use
IsEqualfor validation) - Update relevant documentation
- Run
bun run checkandbun run testbefore submitting
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting (
bun run check && bun run test) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
See CHANGELOG.md for a list of changes and version history.
This project is licensed under the MIT License - see the LICENSE file for details.
- π Documentation
- π Issue Tracker
- π¬ Discussions
- Built with TypeScript
- Schema validation powered by Zod
- Tool types from type-fest