Advice on building plugin for working with parameters

Solution
ISIvan Shadrin4/27/2023
I am currently working on a driver for YDB https://github.com/Gaspero/kysely-ydb
YDB dialect expects query parameters to be explicitly declared as a part of the query using DECLARE statement (reference https://ydb.tech/en/docs/yql/reference/syntax/declare )

I want to build a custom plugin that would automatically add DECLARE statements for each parameter in query

Take a look at the following example query https://kyse.link/?p=s&i=lEJ4rdYMqPWYE5jrEcQE

Expected output would be:
DECLARE $1 AS String; DECLARE $2 AS String; DECLARE $3 AS String; SELECT "id", "last_name" FROM "user" WHERE "id" IN ($1, $2, $3)
*Please ignore type differences between native JS objects and database types. This is out of the scope of the question.

I have checked https://github.com/kysely-org/kysely/tree/master/src/plugin as reference and read documentation but could not figure out how I could access query parameters from OperationNodeTransformer instance.

Could you please give me some advice?
IIgal4/27/2023
Hey 👋

I had a similar constraint when creating the surreal db dialect
IIgal4/27/2023
Had to prepend a bunch of let statements before the main query
IIgal4/27/2023
if this is possible in YDB, it'll be easier than altering the AST
IIgal4/27/2023
and better ergonomically than forcing a plugin on consumers
IIgal4/27/2023
in general, Kysely's parameters sit in ValueNode and other ValueX nodes
ISIvan Shadrin4/27/2023
Thanks a lot!