Typegres API Reference - v0.2.0
    Preparing search index...

    Function expose

    • Type Parameters

      • Schemas extends StandardSchemaV1<unknown, unknown>[]

      Parameters

      Returns {
          <
              This,
              Value extends (this: This, ...args: SchemasToParams<Schemas>) => any,
          >(
              target: Value,
              context: ClassMethodDecoratorContext<This, Value>,
          ): Value;
          <This, Value>(
              target: (this: This) => Value,
              context: ClassGetterDecoratorContext<This, Value>,
          ): (this: This) => Value;
          <This, Value>(
              target: undefined,
              context: ClassFieldDecoratorContext<This, Value>,
          ): (value: Value) => Value;
          <Value extends new (...args: any) => any>(
              target: Value,
              context: ClassDecoratorContext<Value>,
          ): void;
      }

      decorator - marks a method, getter, field, or class as a tool

      Methods: returns a replacement function on the prototype with validation + toolSymbol. Getters: returns a replacement getter with toolSymbol on the function. If the getter returns a function, it's wrapped with asTool(fn, undefined, schemas). Fields: adds field name to toolFieldsSymbol Set on instance. If value is a function with schemas, wraps with asTool. Classes: returns replacement class with constructor validation + toolSymbol.

      NOTE: @expose() on a class means new MyClass(...) is callable by sandboxed code that has a reference to it. This is intended for builtins (e.g. new Date, new Map) where construction is part of the API. For capability classes where you want to expose only methods (not construction), don't decorate the class — just decorate the methods.