@lap-platform/lapsh
v0.4.4
Published
TypeScript SDK for LAP (Lean API Platform) -- Parse and work with LAP API specifications
Maintainers
Readme
@lap-platform/lapsh -- TypeScript SDK for LAP
Parse and work with LAP (Lean API Platform) API specifications in TypeScript/JavaScript.
Install
# Use directly (no install)
npx @lap-platform/lapsh compile api.yaml -o api.lap
# Or install globally
npm install -g @lap-platform/lapsh
# Or add to a project
npm install @lap-platform/lapshQuick Start
import { LAPClient, toContext } from '@lap-platform/lapsh';
const client = new LAPClient();
const spec = client.loadFile('./stripe-charges.lap');
// Get a specific endpoint
const ep = spec.getEndpoint('POST', '/v1/charges');
console.log(ep.requiredParams); // [{ name: 'amount', type: 'int', ... }, ...]
console.log(ep.responses); // [{ statusCode: 200, fields: [...] }]
console.log(ep.errors); // [{ statusCode: 400, description: '...' }, ...]
// Generate LLM-friendly context
const ctx = toContext(spec, { lean: true });API
LAPClient
loadFile(path)— Parse a.lapfile from diskloadString(text)— Parse LAP text directlyfromRegistry(url, apiName)— Fetch from a LAP registry (async)
parse(text): LAPSpec
Low-level parser. Returns a LAPSpec with:
apiName,baseUrl,apiVersion,authendpoints: Endpoint[]getEndpoint(method, path): Endpoint | undefined
toContext(spec, opts): string
Format a spec for LLM consumption. Options:
lean: boolean— omit descriptionsendpoints: string[]— filter by"METHOD /path"
Types
interface Param {
name: string; type: string; required: boolean;
nullable: boolean; isArray: boolean;
enumValues?: string[]; defaultValue?: string;
description?: string; format?: string;
nested?: ResponseField[];
}
interface ResponseField {
name: string; type: string; nullable: boolean;
description?: string; enumValues?: string[];
format?: string; nested?: ResponseField[];
}
interface Endpoint {
method: string; path: string; description?: string;
requiredParams: Param[]; optionalParams: Param[];
allParams: Param[];
responses: ResponseSchema[]; errors: ErrorSchema[];
}Build & Test
npm install
npx tsc
node dist/tests/parser.test.jsZero Dependencies
No runtime dependencies — just TypeScript types and Node.js built-ins.
