UNPKG

@grnsft/if

Version:

Impact Framework

466 lines (465 loc) 18.3 kB
import { ZodSchema, z } from 'zod'; /** * At least one property defined handler. */ export declare const atLeastOneDefined: (obj: Record<string | number | symbol, unknown>) => boolean; /** * All properties are defined handler. */ export declare const allDefined: (obj: Record<string | number | symbol, unknown>) => boolean; /** * Validation schema for manifests. */ export declare const manifestSchema: z.ZodObject<{ name: z.ZodString; description: z.ZodNullable<z.ZodOptional<z.ZodString>>; tags: z.ZodNullable<z.ZodOptional<z.ZodObject<{ kind: z.ZodNullable<z.ZodOptional<z.ZodString>>; complexity: z.ZodNullable<z.ZodOptional<z.ZodString>>; category: z.ZodNullable<z.ZodOptional<z.ZodString>>; }, "strip", z.ZodTypeAny, { kind?: string | null | undefined; complexity?: string | null | undefined; category?: string | null | undefined; }, { kind?: string | null | undefined; complexity?: string | null | undefined; category?: string | null | undefined; }>>>; explainer: z.ZodOptional<z.ZodBoolean>; explain: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; aggregation: z.ZodNullable<z.ZodOptional<z.ZodObject<{ metrics: z.ZodArray<z.ZodString, "many">; type: z.ZodEnum<["horizontal", "time", "vertical", "component", "both"]>; 'skip-components': z.ZodOptional<z.ZodArray<z.ZodString, "many">>; }, "strip", z.ZodTypeAny, { type: "horizontal" | "time" | "vertical" | "component" | "both"; metrics: string[]; 'skip-components'?: string[] | undefined; }, { type: "horizontal" | "time" | "vertical" | "component" | "both"; metrics: string[]; 'skip-components'?: string[] | undefined; }>>>; initialize: z.ZodObject<{ plugins: z.ZodRecord<z.ZodString, z.ZodOptional<z.ZodObject<{ path: z.ZodString; method: z.ZodString; mapping: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>; config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>; 'parameter-metadata': z.ZodOptional<z.ZodObject<{ inputs: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{ unit: z.ZodString; description: z.ZodString; 'aggregation-method': z.ZodObject<{ time: z.ZodEnum<["sum", "avg", "none", "copy"]>; component: z.ZodEnum<["sum", "avg", "none", "copy"]>; }, "strip", z.ZodTypeAny, { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }, { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }>; }, "strip", z.ZodTypeAny, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }>>>>; outputs: z.ZodNullable<z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodObject<{ unit: z.ZodString; description: z.ZodString; 'aggregation-method': z.ZodObject<{ time: z.ZodEnum<["sum", "avg", "none", "copy"]>; component: z.ZodEnum<["sum", "avg", "none", "copy"]>; }, "strip", z.ZodTypeAny, { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }, { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }>; }, "strip", z.ZodTypeAny, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }>>>>; }, "strip", z.ZodTypeAny, { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; }, { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; }>>; }, "strip", z.ZodTypeAny, { path: string; method: string; mapping?: Record<string, string> | undefined; config?: Record<string, any> | undefined; 'parameter-metadata'?: { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; } | undefined; }, { path: string; method: string; mapping?: Record<string, string> | undefined; config?: Record<string, any> | undefined; 'parameter-metadata'?: { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; } | undefined; }>>>; }, "strip", z.ZodTypeAny, { plugins: Record<string, { path: string; method: string; mapping?: Record<string, string> | undefined; config?: Record<string, any> | undefined; 'parameter-metadata'?: { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; } | undefined; } | undefined>; }, { plugins: Record<string, { path: string; method: string; mapping?: Record<string, string> | undefined; config?: Record<string, any> | undefined; 'parameter-metadata'?: { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; } | undefined; } | undefined>; }>; execution: z.ZodOptional<z.ZodObject<{ command: z.ZodOptional<z.ZodString>; environment: z.ZodOptional<z.ZodObject<{ 'if-version': z.ZodString; os: z.ZodString; 'os-version': z.ZodString; 'node-version': z.ZodString; 'date-time': z.ZodString; dependencies: z.ZodArray<z.ZodString, "many">; }, "strip", z.ZodTypeAny, { 'if-version': string; os: string; 'os-version': string; 'node-version': string; 'date-time': string; dependencies: string[]; }, { 'if-version': string; os: string; 'os-version': string; 'node-version': string; 'date-time': string; dependencies: string[]; }>>; status: z.ZodString; error: z.ZodOptional<z.ZodString>; }, "strip", z.ZodTypeAny, { status: string; command?: string | undefined; environment?: { 'if-version': string; os: string; 'os-version': string; 'node-version': string; 'date-time': string; dependencies: string[]; } | undefined; error?: string | undefined; }, { status: string; command?: string | undefined; environment?: { 'if-version': string; os: string; 'os-version': string; 'node-version': string; 'date-time': string; dependencies: string[]; } | undefined; error?: string | undefined; }>>; tree: z.ZodRecord<z.ZodString, z.ZodAny>; }, "strip", z.ZodTypeAny, { name: string; initialize: { plugins: Record<string, { path: string; method: string; mapping?: Record<string, string> | undefined; config?: Record<string, any> | undefined; 'parameter-metadata'?: { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; } | undefined; } | undefined>; }; tree: Record<string, any>; description?: string | null | undefined; tags?: { kind?: string | null | undefined; complexity?: string | null | undefined; category?: string | null | undefined; } | null | undefined; explainer?: boolean | undefined; explain?: Record<string, any> | undefined; aggregation?: { type: "horizontal" | "time" | "vertical" | "component" | "both"; metrics: string[]; 'skip-components'?: string[] | undefined; } | null | undefined; execution?: { status: string; command?: string | undefined; environment?: { 'if-version': string; os: string; 'os-version': string; 'node-version': string; 'date-time': string; dependencies: string[]; } | undefined; error?: string | undefined; } | undefined; }, { name: string; initialize: { plugins: Record<string, { path: string; method: string; mapping?: Record<string, string> | undefined; config?: Record<string, any> | undefined; 'parameter-metadata'?: { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; } | undefined; } | undefined>; }; tree: Record<string, any>; description?: string | null | undefined; tags?: { kind?: string | null | undefined; complexity?: string | null | undefined; category?: string | null | undefined; } | null | undefined; explainer?: boolean | undefined; explain?: Record<string, any> | undefined; aggregation?: { type: "horizontal" | "time" | "vertical" | "component" | "both"; metrics: string[]; 'skip-components'?: string[] | undefined; } | null | undefined; execution?: { status: string; command?: string | undefined; environment?: { 'if-version': string; os: string; 'os-version': string; 'node-version': string; 'date-time': string; dependencies: string[]; } | undefined; error?: string | undefined; } | undefined; }>; /** * Validates given `manifest` object to match pattern. */ export declare const validateManifest: (manifest: any) => { name: string; initialize: { plugins: Record<string, { path: string; method: string; mapping?: Record<string, string> | undefined; config?: Record<string, any> | undefined; 'parameter-metadata'?: { inputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; outputs?: Record<string, { unit: string; description: string; 'aggregation-method': { time: "sum" | "avg" | "none" | "copy"; component: "sum" | "avg" | "none" | "copy"; }; }> | null | undefined; } | undefined; } | undefined>; }; tree: Record<string, any>; description?: string | null | undefined; tags?: { kind?: string | null | undefined; complexity?: string | null | undefined; category?: string | null | undefined; } | null | undefined; explainer?: boolean | undefined; explain?: Record<string, any> | undefined; aggregation?: { type: "horizontal" | "time" | "vertical" | "component" | "both"; metrics: string[]; 'skip-components'?: string[] | undefined; } | null | undefined; execution?: { status: string; command?: string | undefined; environment?: { 'if-version': string; os: string; 'os-version': string; 'node-version': string; 'date-time': string; dependencies: string[]; } | undefined; error?: string | undefined; } | undefined; }; /** * Validates given `object` with given `schema`. */ export declare const validate: <T>(schema: ZodSchema<T, z.ZodTypeDef, T>, object: any, index?: number, errorConstructor?: ErrorConstructor) => T;