/** * Schema helpers for defining scope plugins with type inference. * * Wraps `json-schema-to-ts` so plugin authors get TypeScript types * from JSON Schema without importing or configuring anything. * * Usage: * import { s } from "@nullplatform/plugin"; * * type Caps = s.infer; * type Input = s.infer; */ import type { ExtendedJSONSchema, FromExtendedSchema } from "json-schema-to-ts"; // ─── Nullplatform custom keywords ──────────────────────────────────── // These mirror main-service-api Validator.js + catalog-entities-api type FormRole = "create" | "read" | "update" | "delete" | "list"; export type NpKeywords = { order?: number; visibleOn?: readonly FormRole[]; editableOn?: readonly FormRole[]; secret?: boolean; comparable?: boolean; identifier?: boolean; example?: unknown; /** `true`/`false`, or how the value is exported (with `secret` for a secret env var). */ export?: | boolean | { type: "environment_variable" | "file" | "symbolic_link"; target?: string; secret?: boolean; }; readOnly?: boolean; }; // ─── Schema type ───────────────────────────────────────────────────── /** JSON Schema with nullplatform custom keywords. */ export type NpJSONSchema = ExtendedJSONSchema; // ─── Type inference ────────────────────────────────────────────────── /** * Infer TypeScript type from a JSON Schema. * * Usage: * const schema = { type: "object", properties: { ... } } as const; * type T = s.infer; */ export type infer = S extends NpJSONSchema ? FromExtendedSchema : never;