/** * ThreadForge Decorators — TC39 Stage 3 * * Real standard decorators (not legacy/experimental). * Work with TypeScript 5+, tsx, esbuild, and native when engines ship them. * * Decorator signature: (target: Function, context: DecoratorContext) => Function | void * * ═══════════════════════════════════════════════════════════════ * USAGE (TypeScript) * ═══════════════════════════════════════════════════════════════ * * @Prefix('/api/users') * @Auth('required') * @RateLimit('1000/min') * class UserService extends Service { * * @Route('GET', '/:id') * async getUser(data, auth, params) { ... } * * @Route('POST', '/', { rateLimit: '10/min' }) * @Emit('user.created') * @Validate({ name: 'string!', email: 'string!' }) * async createUser(data, auth) { ... } * * @Expose() // IPC only, no HTTP * async validateCredentials(data) { ... } * * @Internal({ localOnly: true }) // same-process only * async getUserFromCache(id) { ... } * * @On('billing', 'payment.received') * async onPayment(event) { ... } * } * * `forge generate` reads the resulting contract and produces: * - routes/users.yaml (ForgeProxy routing) * - routes/users.yaml (ForgeProxy routing manifest) */ declare global { interface SymbolConstructor { readonly metadata: unique symbol; } } export interface RouteEntry { httpMethod: string; path: string; handlerName: string; auth: string | null; rateLimit: string | null; cacheSecs: number | null; } export interface MethodMeta { name: string; options: Record; } export interface SubscriptionEntry { service: string; event: string; handlerName: string; } export interface ServiceContract { methods: Map; routes: RouteEntry[]; events: Map; subscriptions: SubscriptionEntry[]; prefix: string | null; auth: string; rateLimit: string | null; } interface RouteOptions { auth?: string; rateLimit?: string; cacheSecs?: number; } export declare const HttpMethod: { readonly GET: "GET"; readonly POST: "POST"; readonly PUT: "PUT"; readonly DELETE: "DELETE"; readonly PATCH: "PATCH"; readonly HEAD: "HEAD"; readonly OPTIONS: "OPTIONS"; }; export type HttpMethod = (typeof HttpMethod)[keyof typeof HttpMethod]; type HttpMethodInput = HttpMethod | Lowercase; interface ExposeOptions { [key: string]: unknown; } interface InternalOptions { localOnly?: boolean; [key: string]: unknown; } type ValidateSchema = Record | ((input: unknown) => string | null | undefined | false); interface StaticContractRoute { method: string; path: string; handler: string; auth?: string; rateLimit?: string; cacheSecs?: number; cache?: number; validate?: ValidateSchema; } interface StaticContractDefinition { expose?: string[]; routes?: StaticContractRoute[]; emits?: Record; on?: Array<{ service: string; event: string; handler: string; }>; } export interface ServiceClassLike { new (...args: unknown[]): unknown; prototype: Record; contract?: StaticContractDefinition; prefix?: string; auth?: string; rateLimit?: string; [Symbol.metadata]?: DecoratorMetadataObject; } type DecoratorMetadataObject = Record; export declare function getContract(ServiceClass: ServiceClassLike): ServiceContract | null; export declare function Prefix(path: string): (target: abstract new (...args: unknown[]) => unknown, context: ClassDecoratorContext) => void; export declare function Auth(requirement: string): (target: abstract new (...args: unknown[]) => unknown, context: ClassDecoratorContext) => void; export declare function RateLimit(limit: string): (target: abstract new (...args: unknown[]) => unknown, context: ClassDecoratorContext) => void; export declare function Route(httpMethod: HttpMethodInput, path: string, options?: RouteOptions): (target: Function, context: ClassMethodDecoratorContext) => void; export declare function Expose(target: Function, context: ClassMethodDecoratorContext): void; export declare function Expose(options?: ExposeOptions): (target: Function, context: ClassMethodDecoratorContext) => void; export declare function Internal(options?: InternalOptions): (target: Function, context: ClassMethodDecoratorContext) => void; export declare function Emit(eventName: string): (target: Function, context: ClassMethodDecoratorContext) => Function; export declare function On(serviceName: string, eventName: string): (target: Function, context: ClassMethodDecoratorContext) => void; export declare function Validate(schema: ValidateSchema): (target: Function, context: ClassMethodDecoratorContext) => Function; /** * DEC-M2: Apply deferred validation wrappers from static contracts. * Call this when the service is actually starting, not during contract inspection. * Safe to call multiple times — wrapping is applied at most once per class. */ export declare function applyStaticContractWrappers(ServiceClass: ServiceClassLike): void; export declare function isInternalMethod(ServiceClass: ServiceClassLike, methodName: string): boolean; export declare function isLocalOnlyMethod(ServiceClass: ServiceClassLike, methodName: string): boolean; export declare function getInternalMethods(ServiceClass: ServiceClassLike): string[]; export {}; //# sourceMappingURL=index.d.ts.map