UNPKG

riof

Version:

Rio framework

88 lines (87 loc) 3.36 kB
import { Data, Response, RioEvent, Schedule, State, Task } from "@retter/rdk"; import z, { ZodObject, ZodRawShape, ZodType } from "zod"; import { KeyValueString } from "@retter/rdk/src"; interface RioMethodProps { type?: "READ" | "STATIC" | "WRITE" | "QUEUED_WRITE"; queryStringModel?: RioValidationModel; inputModel?: RioValidationModel; outputModel?: RioValidationModel; errorModel?: RioValidationModel; schedule?: string; } export declare function RioMethod(options?: RioMethodProps): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => void; interface RioClassProps { architecture?: 'arm64' | 'x86_64'; accelerated?: boolean; description?: string; privateStateModel?: RioValidationModel; publicStateModel?: RioValidationModel; } export declare function RioClass(options?: RioClassProps): (target: Function) => void; export declare enum RioClassReservedMethods { INIT = "INIT", STATE = "STATE", GET = "GET", DESTROY = "DESTROY" } export declare enum RioReservedUserIdentities { DEVELOPER = "developer", ENDUSER = "enduser", NONE = "none", ANONYMOUSUSER = "anonymous_user" } declare type ClassLookup = { name: string; value: string; }; export declare type RioClassConstructor = string | undefined | { lookup: ClassLookup; } | { body: any; }; export declare type RioValidationModel<T extends ZodRawShape = any> = ZodObject<T>; export declare type RioMethodModelType<T extends ZodType<any, any, any>> = z.infer<T>; export declare class Rio<PrivateState = any, PublicState = any> { protected readonly body?: RioClassConstructor; protected readonly lookup?: ClassLookup; protected instanceId?: string; protected newInstance: boolean; protected state: State<PublicState, PrivateState, any, any>; protected schedule: Schedule[]; protected tasks: Task[]; protected events: RioEvent[]; constructor(constructorData?: RioClassConstructor); protected init(data: Data<any, any, PublicState, PrivateState>): Promise<void>; protected _get(data: Data<any, any, PublicState, PrivateState>): Promise<void>; protected destroy(data: Data<any, any, PublicState, PrivateState>): Promise<void>; protected authorizer(data: Data<any, any, PublicState, PrivateState>): Promise<boolean>; protected getInstanceId<Input>(data: Data<Input, any, PublicState, PrivateState>): Promise<string>; protected getState<Input>(data: Data<Input, any, PublicState, PrivateState>): Promise<State<any, any, any, any>>; protected generateInstanceId(): string; /** This method is magical and should not be used directly. **/ private setDataProperties; /** This method is magical and should not be used directly. **/ private getRioClassInstance; } export interface RioMethodRequest<T = any> { httpMethod?: string; body?: T; headers?: KeyValueString; queryStringParams?: Record<string, any>; } export declare class RioMethodError extends Error { readonly message: string; readonly title: string; private readonly statusCode; private readonly code?; private readonly addons?; constructor(props?: { statusCode?: number; code?: string; message?: string; title?: string; addons?: any; }); getRioResponse(): Response; } export {};