@tsed/schema
Version:
JsonSchema module for Ts.ED Framework
50 lines (49 loc) • 1.82 kB
TypeScript
import { Type } from "@tsed/core";
import { JsonEntityStore, JsonEntityStoreOptions } from "./JsonEntityStore.js";
import type { JsonMethodStore } from "./JsonMethodStore.js";
import { JsonParameter } from "./JsonParameter.js";
export interface JsonParameterStoreOptions extends JsonEntityStoreOptions {
dataPath?: string;
paramType?: string;
expression?: string;
}
export interface PipeMethods<T = any, R = any> {
transform(value: T, metadata: JsonParameterStore): R;
}
export declare class JsonParameterStore extends JsonEntityStore {
paramType: string;
expression: string;
dataPath: string;
/**
* Define pipes can be called by the framework to transform input parameter
*/
pipes: Type<PipeMethods>[];
/**
* Ref to JsonParameter when the decorated object is a parameter.
*/
readonly parameter: JsonParameter;
readonly parent: JsonMethodStore;
constructor(options: JsonParameterStoreOptions);
/**
* Return the required state.
* @returns {boolean}
*/
get required(): boolean;
set required(value: boolean);
get allowedRequiredValues(): any[];
get schema(): import("./JsonSchema.js").JsonSchema;
static getParams<T extends JsonParameterStore = JsonParameterStore>(target: Type<any>, propertyKey: string | symbol): T[];
static get(target: Type<any>, propertyKey: string | symbol, index: number): JsonParameterStore;
/**
* Check precondition between value, required and allowedRequiredValues to know if the entity is required.
* @param value
* @returns {boolean}
*/
isRequired(value: any): boolean;
protected build(): void;
}
/**
* @alias JsonParameterStore
*/
export type ParamMetadata = JsonParameterStore;
export declare const ParamMetadata: typeof JsonParameterStore;