| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
JSON Schemas and TypeScript types that govern the message formats and configuration file formats for Codify.
@codifycli/schemas is the central contract library for the Codify ecosystem, providing:
This package ensures that all components of the Codify ecosystem communicate using a well-defined, validated protocol.
npm install @codifycli/schemasImport schemas and types to build type-safe Codify plugins:
import {
InitializeRequestData,
InitializeResponseData,
ValidateRequestData,
ValidateResponseData,
PlanRequestData,
PlanResponseData,
ApplyRequestData,
MessageCmd,
MessageStatus,
ResourceOperation,
} from '@codifycli/schemas';
// Handle initialize message
function handleInitialize(request: InitializeRequestData): InitializeResponseData {
return {
resourceDefinitions: [
{
type: 'my-resource',
dependencies: [],
os: ['linux', 'macOS'],
linuxDistros: ['debian', 'ubuntu'],
isSensitive: [],
allowMultiple: false,
}
]
};
}
// Handle plan message
function handlePlan(request: PlanRequestData): PlanResponseData {
return {
planId: crypto.randomUUID(),
operation: ResourceOperation.CREATE,
parameterChanges: [],
};
}Use the included AJV validator to validate IPC messages:
import Ajv from 'ajv';
import {
InitializeRequestDataSchema,
InitializeResponseDataSchema,
} from '@codifycli/schemas';
const ajv = new Ajv({ strict: true });
// Validate request
const validateRequest = ajv.compile(InitializeRequestDataSchema);
if (!validateRequest(data)) {
console.error('Invalid request:', validateRequest.errors);
}
// Validate response
const validateResponse = ajv.compile(InitializeResponseDataSchema);
if (!validateResponse(responseData)) {
console.error('Invalid response:', validateResponse.errors);
}Use configuration schemas to validate Codify config files:
import {
ConfigFileSchema,
ProjectSchema,
ResourceSchema,
Config,
ProjectConfig,
ResourceConfig,
} from '@codifycli/schemas';
// Type-safe configuration
const config: Config[] = [
{
type: 'project',
version: '1.0.0',
plugins: {
'my-plugin': '1.0.0',
},
},
{
type: 'my-resource',
name: 'example',
dependsOn: [],
os: ['linux'],
},
];Plugin lifecycle messages:
CLI support messages:
The package exports comprehensive TypeScript types and enums:
All request/response data types are exported as TypeScript interfaces, providing full type safety when building plugins.
The package includes a comprehensive schema store file (codify-schema.json) for IDE autocomplete and validation. Configure your IDE to use this schema for .codify or similar configuration files.
npm testTests use Vitest and AJV to validate that all schemas compile correctly and accept/reject appropriate inputs.
npm run prepublishOnlyCompiles TypeScript and prepares the package for publishing.
src/ ├── messages/ # Request/response schemas for IPC messages ├── types/ # TypeScript type definitions ├── schemastore/ # IDE integration schema ├── *.json # Core configuration schemas └── index.ts # Main exports
When building a Codify plugin, you'll implement handlers for these core messages:
Each message type has strictly validated request and response formats defined by this package.
Contributions are welcome! Please ensure:
ISC
| Back | FazBrowse Home | New Git URL |