@meshery/schemas Package Guide

Installation

npm install @meshery/schemas
# or
yarn add @meshery/schemas

What the Package Exports

The @meshery/schemas npm package provides three categories of exports:

1. Generated TypeScript Types

Type definitions produced by openapi-typescript from the bundled OpenAPI specs. These are .d.ts files in typescript/generated/.

import type { Connection } from "@meshery/schemas";
import type { Design } from "@meshery/schemas";
import type { Component } from "@meshery/schemas";

2. Runtime Schema Constants

The *Schema.ts files export the raw JSON schema as a JavaScript object, usable for runtime validation:

import { connectionSchema } from "@meshery/schemas";

// Use with any JSON Schema validator (e.g., Ajv)
const ajv = new Ajv();
const validate = ajv.compile(connectionSchema);

3. RTK Query Hooks

Pre-built API hooks for Redux Toolkit Query. See RTK Query Hooks.

import { cloudApi } from "@meshery/schemas/rtk";

Type Name Conventions

Generated TypeScript type names follow the schema components/schemas names (PascalCase):

Schema Component TypeScript Type
Connection Connection
ConnectionPayload ConnectionPayload
ConnectionPage ConnectionPage
Design Design
Component Component
Relationship Relationship
Property names may not be PascalCase While type names are PascalCase, property names match the schema exactly — which may be snake_case for DB-backed fields. Always check the generated .d.ts files for actual property names.

Deep Import Paths

For tree-shaking or direct access, use deep imports:

// Types from specific constructs
import type { Connection } from "@meshery/schemas/typescript/generated/connection";

// RTK hooks
import { cloudApi } from "@meshery/schemas/typescript/rtk/cloudApi";
import { mesheryApi } from "@meshery/schemas/typescript/rtk/mesheryApi";

// Permissions
import { permissions } from "@meshery/schemas/typescript/permissions";

Build from Source

If you need the latest unreleased types:

git clone https://github.com/meshery/schemas.git
cd schemas
make setup
make build      # Generates TS types + RTK hooks
npm run build   # Produces dist/

The dist/ directory contains the bundled package ready for local linking:

cd dist
npm link
# In your project:
npm link @meshery/schemas

Import Path Reference

Import Path Contents
@meshery/schemas Main entry — re-exports all types
@meshery/schemas/rtk RTK Query API hooks
@meshery/schemas/typescript/generated/* Per-construct generated types
@meshery/schemas/typescript/permissions Permission constants
Do not use .d.ts in import paths TypeScript resolves .d.ts files automatically. Import from the module path without extension.