kysely-org / kysely

A type-safe typescript SQL query builder
https://kysely.dev
MIT License
9.82k stars 250 forks source link

How to define a custom plugin using the FunctionNode? #967

Closed QuentinJanuel closed 2 months ago

QuentinJanuel commented 2 months ago

Hello!

I was writing a custom plugin and needed to import among other nodes the FunctionNode but I realized it was not exported. Should it be exported or am I doing something unintended? I know all nodes are marked as internal, but I see no other way to define a custom plugin and the OperationNodeTransformer I use isn't marked as internal while still exposing the nodes so I'm not sure.

Thank you for the excellent project by the way!

igalklebanov commented 2 months ago

Hey 👋

It appears we forgot to add it to the exports. I've opened a PR that takes care of that.

For now, you can still override transformFunction, and define FunctionNode type temporarily as follows:

export interface FunctionNode extends OperationNode {
  readonly kind: 'FunctionNode'
  readonly func: string
  readonly arguments: ReadonlyArray<OperationNode>
}