{"version":3,"sources":["../src/nest/index.ts","../src/nest/decorators.ts","../src/rpc/decorators.ts"],"sourcesContent":["export * from './decorators';\nexport * from '../rpc/decorators';\n","// NestJS Integration - Decorators for wexts\n// These decorators add metadata for auto API client generation\n\nimport 'reflect-metadata';\n\nexport interface FusionRouteMetadata {\n    method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';\n    path: string;\n    responseType?: string;\n    requestType?: string;\n}\n\nconst FUSION_METADATA_KEY = 'fusion:routes';\n\n/**\n * Mark a NestJS controller for Fusion codegen\n * Usage: @FusionController('users')\n */\nexport function FusionController(prefix: string = ''): ClassDecorator {\n    return function (target: any) {\n        Reflect.defineMetadata('fusion:controller', { prefix }, target);\n        return target;\n    };\n}\n\n/**\n * Mark a route for API client generation\n * Usage: @FusionRoute({ method: 'GET', path: '/:id' })\n */\nexport function FusionRoute(metadata: FusionRouteMetadata): MethodDecorator {\n    return function (target: any, propertyKey: string | symbol, descriptor: PropertyDescriptor) {\n        const routes = Reflect.getMetadata(FUSION_METADATA_KEY, target.constructor) || [];\n        routes.push({\n            ...metadata,\n            handler: propertyKey,\n        });\n        Reflect.defineMetadata(FUSION_METADATA_KEY, routes, target.constructor);\n        return descriptor;\n    };\n}\n\n/**\n * Helper decorators for common HTTP methods\n */\nexport function FusionGet(path: string = ''): MethodDecorator {\n    return FusionRoute({ method: 'GET', path });\n}\n\nexport function FusionPost(path: string = ''): MethodDecorator {\n    return FusionRoute({ method: 'POST', path });\n}\n\nexport function FusionPut(path: string = ''): MethodDecorator {\n    return FusionRoute({ method: 'PUT', path });\n}\n\nexport function FusionDelete(path: string = ''): MethodDecorator {\n    return FusionRoute({ method: 'DELETE', path });\n}\n\n/**\n * Get Fusion metadata from a controller\n */\nexport function getFusionMetadata(controller: any): {\n    controller: any;\n    routes: any[];\n} {\n    return {\n        controller: Reflect.getMetadata('fusion:controller', controller),\n        routes: Reflect.getMetadata(FUSION_METADATA_KEY, controller) || [],\n    };\n}\n","import 'reflect-metadata';\nimport type { RpcAuthPolicy } from './types';\n\nconst RPC_SERVICE_KEY = 'wexts:rpc:service';\nconst RPC_METHODS_KEY = 'wexts:rpc:methods';\n\nexport interface RpcServiceOptions {\n    name?: string;\n    requireAuth?: boolean;\n}\n\nexport interface RpcMethodOptions {\n    name?: string;\n    requireAuth?: boolean;\n}\n\nexport interface RuntimeRpcServiceMetadata {\n    name?: string;\n    requireAuth: boolean;\n}\n\nexport interface RuntimeRpcMethodMetadata {\n    propertyKey: string | symbol;\n    name?: string;\n    requireAuth?: boolean;\n}\n\nexport function RpcService(nameOrOptions?: string | RpcServiceOptions): ClassDecorator {\n    const options = normalizeServiceOptions(nameOrOptions);\n\n    return (target) => {\n        Reflect.defineMetadata(RPC_SERVICE_KEY, options, target);\n        return target;\n    };\n}\n\nexport function RpcMethod(nameOrOptions?: string | RpcMethodOptions): MethodDecorator {\n    const options = normalizeMethodOptions(nameOrOptions);\n\n    return (target, propertyKey) => {\n        const constructor = target.constructor;\n        const methods: RuntimeRpcMethodMetadata[] = Reflect.getMetadata(RPC_METHODS_KEY, constructor) || [];\n        const nextMethods = methods.filter((method) => method.propertyKey !== propertyKey);\n        nextMethods.push({ propertyKey, ...options });\n        Reflect.defineMetadata(RPC_METHODS_KEY, nextMethods, constructor);\n    };\n}\n\nexport function RequireAuth(): MethodDecorator & ClassDecorator {\n    return (target: object, propertyKey?: string | symbol) => {\n        if (propertyKey) {\n            RpcMethod({ requireAuth: true })(target, propertyKey, Object.getOwnPropertyDescriptor(target, propertyKey)!);\n            return;\n        }\n\n        const existing = getRuntimeRpcServiceMetadata(target as Function);\n        Reflect.defineMetadata(RPC_SERVICE_KEY, { ...existing, requireAuth: true }, target);\n    };\n}\n\nexport function getRuntimeRpcServiceMetadata(target: Function): RuntimeRpcServiceMetadata | undefined {\n    return Reflect.getMetadata(RPC_SERVICE_KEY, target);\n}\n\nexport function getRuntimeRpcMethodsMetadata(target: Function): RuntimeRpcMethodMetadata[] {\n    return Reflect.getMetadata(RPC_METHODS_KEY, target) || [];\n}\n\nexport function getRpcAuthPolicy(requireAuth?: boolean): RpcAuthPolicy {\n    return requireAuth ? 'required' : 'public';\n}\n\nexport const WextsRpcService = RpcService;\nexport const WextsRpc = RpcMethod;\n\nfunction normalizeServiceOptions(input?: string | RpcServiceOptions): RuntimeRpcServiceMetadata {\n    if (typeof input === 'string') {\n        return { name: input, requireAuth: false };\n    }\n\n    return {\n        name: input?.name,\n    requireAuth: input?.requireAuth ?? true,\n    };\n}\n\nfunction normalizeMethodOptions(input?: string | RpcMethodOptions): RpcMethodOptions {\n    if (typeof input === 'string') {\n        return { name: input };\n    }\n\n    return input ?? {};\n}\n"],"mappings":";;;;;;AAAA;;;;;;;;;;;;;;;;;;;;ACGA,OAAO;AASP,IAAMA,sBAAsB;AAMrB,SAASC,iBAAiBC,SAAiB,IAAE;AAChD,SAAO,SAAUC,QAAW;AACxBC,YAAQC,eAAe,qBAAqB;MAAEH;IAAO,GAAGC,MAAAA;AACxD,WAAOA;EACX;AACJ;AALgBF;AAWT,SAASK,YAAYC,UAA6B;AACrD,SAAO,SAAUJ,QAAaK,aAA8BC,YAA8B;AACtF,UAAMC,SAASN,QAAQO,YAAYX,qBAAqBG,OAAO,WAAW,KAAK,CAAA;AAC/EO,WAAOE,KAAK;MACR,GAAGL;MACHM,SAASL;IACb,CAAA;AACAJ,YAAQC,eAAeL,qBAAqBU,QAAQP,OAAO,WAAW;AACtE,WAAOM;EACX;AACJ;AAVgBH;AAeT,SAASQ,UAAUC,OAAe,IAAE;AACvC,SAAOT,YAAY;IAAEU,QAAQ;IAAOD;EAAK,CAAA;AAC7C;AAFgBD;AAIT,SAASG,WAAWF,OAAe,IAAE;AACxC,SAAOT,YAAY;IAAEU,QAAQ;IAAQD;EAAK,CAAA;AAC9C;AAFgBE;AAIT,SAASC,UAAUH,OAAe,IAAE;AACvC,SAAOT,YAAY;IAAEU,QAAQ;IAAOD;EAAK,CAAA;AAC7C;AAFgBG;AAIT,SAASC,aAAa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QO,YAAYd,iBAAiBM,MAAAA;AAChD;AAFgBkB;AAIT,SAASC,6BAA6BnB,QAAgB;AACzD,SAAOC,QAAQO,YAAYb,iBAAiBK,MAAAA,KAAW,CAAA;AAC3D;AAFgBmB;AAIT,SAASC,iBAAiBN,aAAqB;AAClD,SAAOA,cAAc,aAAa;AACtC;AAFgBM;AAIT,IAAMC,kBAAkBzB;AACxB,IAAM0B,WAAWnB;AAExB,SAASJ,wBAAwBwB,OAAkC;AAC/D,MAAI,OAAOA,UAAU,UAAU;AAC3B,WAAO;MAAEC,MAAMD;MAAOT,aAAa;IAAM;EAC7C;AAEA,SAAO;IACHU,MAAMD,OAAOC;IACjBV,aAAaS,OAAOT,eAAe;EACnC;AACJ;AATSf;AAWT,SAASK,uBAAuBmB,OAAiC;AAC7D,MAAI,OAAOA,UAAU,UAAU;AAC3B,WAAO;MAAEC,MAAMD;IAAM;EACzB;AAEA,SAAOA,SAAS,CAAC;AACrB;AANSnB;","names":["FUSION_METADATA_KEY","FusionController","prefix","target","Reflect","defineMetadata","FusionRoute","metadata","propertyKey","descriptor","routes","getMetadata","push","handler","FusionGet","path","method","FusionPost","FusionPut","FusionDelete","getFusionMetadata","controller","RPC_SERVICE_KEY","RPC_METHODS_KEY","RpcService","nameOrOptions","options","normalizeServiceOptions","target","Reflect","defineMetadata","RpcMethod","normalizeMethodOptions","propertyKey","constructor","methods","getMetadata","nextMethods","filter","method","push","RequireAuth","requireAuth","Object","getOwnPropertyDescriptor","existing","getRuntimeRpcServiceMetadata","getRuntimeRpcMethodsMetadata","getRpcAuthPolicy","WextsRpcService","WextsRpc","input","name"]}