package trailbase:component@0.1.1;

@since(version = 0.1.0)
interface init-endpoint {
  record arguments {
    version: option<string>,
  }

  enum http-method-type {
    get,
    post,
    head,
    options,
    patch,
    delete,
    put,
    trace,
    connect,
  }

  record http-handlers {
    /// Registered http handlers (method, path)[].
    handlers: list<tuple<http-method-type, string>>,
  }

  @since(version = 0.1.0)
  init-http-handlers: func(args: arguments) -> http-handlers;

  record job-handlers {
    /// Registered jobs (name, spec)[].
    handlers: list<tuple<string, string>>,
  }

  @since(version = 0.1.0)
  init-job-handlers: func(args: arguments) -> job-handlers;

  enum sqlite-function-flags {
    /// Specifies UTF-8 as the text encoding this SQL function prefers for its parameters.
    utf8,
    /// Specifies UTF-16 using little-endian byte order as the text encoding this SQL function prefers for its parameters.
    utf16le,
    /// Specifies UTF-16 using big-endian byte order as the text encoding this SQL function prefers for its parameters.
    utf16be,
    /// Specifies UTF-16 using native byte order as the text encoding this SQL function prefers for its parameters.
    utf16,
    /// Means that the function always gives the same output when the input parameters are the same.
    deterministic,
    /// Means that the function may only be invoked from top-level SQL.
    direct-only,
    /// Indicates to SQLite that a function may call `sqlite3_value_subtype()` to inspect the subtypes of its arguments.
    subtype,
    /// Means that the function is unlikely to cause problems even if misused.
    innocuous,
    /// Indicates to SQLite that a function might call `sqlite3_result_subtype()` to cause a subtype to be associated with its result.
    result-subtype,
    /// Indicates that the function is an aggregate that internally orders the values provided to the first argument.
    selforder1,
  }

  record sqlite-scalar-function {
    name: string,
    num-args: u32,
    function-flags: list<sqlite-function-flags>,
  }

  record sqlite-functions {
    scalar-functions: list<sqlite-scalar-function>,
  }

  @since(version = 0.1.0)
  init-sqlite-functions : func(args: arguments) -> sqlite-functions;
}
