@uwdata/mosaic-sql 0.17.0 → 0.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +47 -0
- package/README.md +0 -2
- package/dist/src/ast/aggregate.d.ts +82 -0
- package/dist/src/ast/aggregate.d.ts.map +1 -0
- package/dist/src/ast/aggregate.js +180 -0
- package/dist/src/ast/aggregate.js.map +1 -0
- package/dist/src/ast/between-op.d.ts +46 -0
- package/dist/src/ast/between-op.d.ts.map +1 -0
- package/dist/src/ast/between-op.js +60 -0
- package/dist/src/ast/between-op.js.map +1 -0
- package/dist/src/ast/binary-op.d.ts +21 -0
- package/dist/src/ast/binary-op.d.ts.map +1 -0
- package/dist/src/ast/binary-op.js +29 -0
- package/dist/src/ast/binary-op.js.map +1 -0
- package/dist/src/ast/case.d.ts +53 -0
- package/dist/src/ast/case.d.ts.map +1 -0
- package/dist/src/ast/case.js +75 -0
- package/dist/src/ast/case.js.map +1 -0
- package/dist/src/ast/cast.d.ts +18 -0
- package/dist/src/ast/cast.d.ts.map +1 -0
- package/dist/src/ast/cast.js +26 -0
- package/dist/src/ast/cast.js.map +1 -0
- package/dist/src/ast/collate.d.ts +18 -0
- package/dist/src/ast/collate.d.ts.map +1 -0
- package/dist/src/ast/collate.js +25 -0
- package/dist/src/ast/collate.js.map +1 -0
- package/dist/src/ast/column-param.d.ts +23 -0
- package/dist/src/ast/column-param.d.ts.map +1 -0
- package/dist/src/ast/column-param.js +29 -0
- package/dist/src/ast/column-param.js.map +1 -0
- package/dist/src/ast/column-ref.d.ts +40 -0
- package/dist/src/ast/column-ref.d.ts.map +1 -0
- package/dist/src/ast/column-ref.js +58 -0
- package/dist/src/ast/column-ref.js.map +1 -0
- package/dist/src/ast/fragment.d.ts +20 -0
- package/dist/src/ast/fragment.d.ts.map +1 -0
- package/dist/src/ast/fragment.js +26 -0
- package/dist/src/ast/fragment.js.map +1 -0
- package/dist/src/ast/from.d.ts +22 -0
- package/dist/src/ast/from.d.ts.map +1 -0
- package/dist/src/ast/from.js +37 -0
- package/dist/src/ast/from.js.map +1 -0
- package/dist/src/ast/function.d.ts +18 -0
- package/dist/src/ast/function.d.ts.map +1 -0
- package/dist/src/ast/function.js +26 -0
- package/dist/src/ast/function.js.map +1 -0
- package/dist/src/ast/in-op.d.ts +18 -0
- package/dist/src/ast/in-op.d.ts.map +1 -0
- package/dist/src/ast/in-op.js +25 -0
- package/dist/src/ast/in-op.js.map +1 -0
- package/dist/src/ast/interval.d.ts +18 -0
- package/dist/src/ast/interval.d.ts.map +1 -0
- package/dist/src/ast/interval.js +25 -0
- package/dist/src/ast/interval.js.map +1 -0
- package/dist/src/ast/literal.d.ts +16 -0
- package/dist/src/ast/literal.d.ts.map +1 -0
- package/dist/src/ast/literal.js +53 -0
- package/dist/src/ast/literal.js.map +1 -0
- package/dist/src/ast/logical-op.d.ts +32 -0
- package/dist/src/ast/logical-op.d.ts.map +1 -0
- package/dist/src/ast/logical-op.js +46 -0
- package/dist/src/ast/logical-op.js.map +1 -0
- package/dist/src/ast/node.d.ts +25 -0
- package/dist/src/ast/node.d.ts.map +1 -0
- package/dist/src/ast/node.js +36 -0
- package/dist/src/ast/node.js.map +1 -0
- package/dist/src/ast/order-by.d.ts +21 -0
- package/dist/src/ast/order-by.d.ts.map +1 -0
- package/dist/src/ast/order-by.js +36 -0
- package/dist/src/ast/order-by.js.map +1 -0
- package/dist/src/ast/param.d.ts +20 -0
- package/dist/src/ast/param.d.ts.map +1 -0
- package/dist/src/ast/param.js +28 -0
- package/dist/src/ast/param.js.map +1 -0
- package/dist/src/ast/query.d.ts +294 -0
- package/dist/src/ast/query.d.ts.map +1 -0
- package/dist/src/ast/query.js +584 -0
- package/dist/src/ast/query.js.map +1 -0
- package/dist/src/ast/sample.d.ts +27 -0
- package/dist/src/ast/sample.d.ts.map +1 -0
- package/dist/src/ast/sample.js +38 -0
- package/dist/src/ast/sample.js.map +1 -0
- package/dist/src/ast/select.d.ts +19 -0
- package/dist/src/ast/select.d.ts.map +1 -0
- package/dist/src/ast/select.js +35 -0
- package/dist/src/ast/select.js.map +1 -0
- package/dist/src/ast/subquery.d.ts +16 -0
- package/dist/src/ast/subquery.d.ts.map +1 -0
- package/dist/src/ast/subquery.js +21 -0
- package/dist/src/ast/subquery.js.map +1 -0
- package/dist/src/ast/table-ref.d.ts +24 -0
- package/dist/src/ast/table-ref.d.ts.map +1 -0
- package/dist/src/ast/table-ref.js +35 -0
- package/dist/src/ast/table-ref.js.map +1 -0
- package/dist/src/ast/unary-op.d.ts +40 -0
- package/dist/src/ast/unary-op.d.ts.map +1 -0
- package/dist/src/ast/unary-op.js +52 -0
- package/dist/src/ast/unary-op.js.map +1 -0
- package/dist/src/ast/verbatim.d.ts +18 -0
- package/dist/src/ast/verbatim.d.ts.map +1 -0
- package/dist/src/ast/verbatim.js +25 -0
- package/dist/src/ast/verbatim.js.map +1 -0
- package/dist/src/ast/window-frame.d.ts +54 -0
- package/dist/src/ast/window-frame.d.ts.map +1 -0
- package/dist/src/ast/window-frame.js +79 -0
- package/dist/src/ast/window-frame.js.map +1 -0
- package/dist/src/ast/window.d.ts +128 -0
- package/dist/src/ast/window.d.ts.map +1 -0
- package/dist/src/ast/window.js +194 -0
- package/dist/src/ast/window.js.map +1 -0
- package/dist/src/ast/with.d.ts +25 -0
- package/dist/src/ast/with.d.ts.map +1 -0
- package/dist/src/ast/with.js +36 -0
- package/dist/src/ast/with.js.map +1 -0
- package/dist/src/constants.d.ts +38 -0
- package/dist/src/constants.d.ts.map +1 -0
- package/dist/src/constants.js +38 -0
- package/dist/src/constants.js.map +1 -0
- package/dist/src/functions/aggregate.d.ts +236 -0
- package/dist/src/functions/aggregate.d.ts.map +1 -0
- package/dist/src/functions/aggregate.js +308 -0
- package/dist/src/functions/aggregate.js.map +1 -0
- package/dist/src/functions/case.d.ts +13 -0
- package/dist/src/functions/case.d.ts.map +1 -0
- package/dist/src/functions/case.js +17 -0
- package/dist/src/functions/case.js.map +1 -0
- package/dist/src/functions/cast.d.ts +23 -0
- package/dist/src/functions/cast.d.ts.map +1 -0
- package/dist/src/functions/cast.js +32 -0
- package/dist/src/functions/cast.js.map +1 -0
- package/dist/src/functions/collate.d.ts +10 -0
- package/dist/src/functions/collate.d.ts.map +1 -0
- package/dist/src/functions/collate.js +12 -0
- package/dist/src/functions/collate.js.map +1 -0
- package/dist/src/functions/column.d.ts +10 -0
- package/dist/src/functions/column.d.ts.map +1 -0
- package/dist/src/functions/column.js +17 -0
- package/dist/src/functions/column.js.map +1 -0
- package/dist/src/functions/cte.d.ts +13 -0
- package/dist/src/functions/cte.d.ts.map +1 -0
- package/dist/src/functions/cte.js +14 -0
- package/dist/src/functions/cte.js.map +1 -0
- package/dist/src/functions/datetime.d.ts +32 -0
- package/dist/src/functions/datetime.d.ts.map +1 -0
- package/dist/src/functions/datetime.js +45 -0
- package/dist/src/functions/datetime.js.map +1 -0
- package/dist/src/functions/interval.d.ts +48 -0
- package/dist/src/functions/interval.d.ts.map +1 -0
- package/dist/src/functions/interval.js +66 -0
- package/dist/src/functions/interval.js.map +1 -0
- package/dist/src/functions/literal.d.ts +16 -0
- package/dist/src/functions/literal.d.ts.map +1 -0
- package/dist/src/functions/literal.js +20 -0
- package/dist/src/functions/literal.js.map +1 -0
- package/dist/src/functions/numeric.d.ts +80 -0
- package/dist/src/functions/numeric.d.ts.map +1 -0
- package/dist/src/functions/numeric.js +110 -0
- package/dist/src/functions/numeric.js.map +1 -0
- package/dist/src/functions/operators.d.ts +169 -0
- package/dist/src/functions/operators.d.ts.map +1 -0
- package/dist/src/functions/operators.js +235 -0
- package/dist/src/functions/operators.js.map +1 -0
- package/dist/src/functions/order-by.d.ts +15 -0
- package/dist/src/functions/order-by.d.ts.map +1 -0
- package/dist/src/functions/order-by.js +19 -0
- package/dist/src/functions/order-by.js.map +1 -0
- package/dist/src/functions/spatial.d.ts +32 -0
- package/dist/src/functions/spatial.d.ts.map +1 -0
- package/dist/src/functions/spatial.js +44 -0
- package/dist/src/functions/spatial.js.map +1 -0
- package/dist/src/functions/sql-template-tag.d.ts +13 -0
- package/dist/src/functions/sql-template-tag.d.ts.map +1 -0
- package/dist/src/functions/sql-template-tag.js +44 -0
- package/dist/src/functions/sql-template-tag.js.map +1 -0
- package/dist/src/functions/string.d.ts +49 -0
- package/dist/src/functions/string.d.ts.map +1 -0
- package/dist/src/functions/string.js +67 -0
- package/dist/src/functions/string.js.map +1 -0
- package/dist/src/functions/table-ref.d.ts +10 -0
- package/dist/src/functions/table-ref.d.ts.map +1 -0
- package/dist/src/functions/table-ref.js +13 -0
- package/dist/src/functions/table-ref.js.map +1 -0
- package/dist/src/functions/util.d.ts +7 -0
- package/dist/src/functions/util.d.ts.map +1 -0
- package/dist/src/functions/util.js +9 -0
- package/dist/src/functions/util.js.map +1 -0
- package/dist/src/functions/window-frame.d.ts +41 -0
- package/dist/src/functions/window-frame.d.ts.map +1 -0
- package/dist/src/functions/window-frame.js +52 -0
- package/dist/src/functions/window-frame.js.map +1 -0
- package/dist/src/functions/window.d.ts +74 -0
- package/dist/src/functions/window.d.ts.map +1 -0
- package/dist/src/functions/window.js +96 -0
- package/dist/src/functions/window.js.map +1 -0
- package/dist/src/index.d.ts +69 -0
- package/dist/src/index.d.ts.map +1 -0
- package/{src → dist/src}/index.js +4 -8
- package/dist/src/index.js.map +1 -0
- package/dist/src/load/create.d.ts +10 -0
- package/dist/src/load/create.d.ts.map +1 -0
- package/dist/src/load/create.js +14 -0
- package/dist/src/load/create.js.map +1 -0
- package/dist/src/load/extension.d.ts +2 -0
- package/dist/src/load/extension.d.ts.map +1 -0
- package/dist/src/load/extension.js +4 -0
- package/dist/src/load/extension.js.map +1 -0
- package/dist/src/load/load.d.ts +18 -0
- package/dist/src/load/load.d.ts.map +1 -0
- package/dist/src/load/load.js +80 -0
- package/dist/src/load/load.js.map +1 -0
- package/dist/src/load/sql-from.d.ts +14 -0
- package/dist/src/load/sql-from.d.ts.map +1 -0
- package/dist/src/load/sql-from.js +29 -0
- package/dist/src/load/sql-from.js.map +1 -0
- package/dist/src/transforms/bin-1d.d.ts +16 -0
- package/dist/src/transforms/bin-1d.d.ts.map +1 -0
- package/dist/src/transforms/bin-1d.js +21 -0
- package/dist/src/transforms/bin-1d.js.map +1 -0
- package/dist/src/transforms/bin-2d.d.ts +19 -0
- package/dist/src/transforms/bin-2d.d.ts.map +1 -0
- package/dist/src/transforms/bin-2d.js +27 -0
- package/dist/src/transforms/bin-2d.js.map +1 -0
- package/dist/src/transforms/bin-date.d.ts +31 -0
- package/dist/src/transforms/bin-date.d.ts.map +1 -0
- package/dist/src/transforms/bin-date.js +20 -0
- package/dist/src/transforms/bin-date.js.map +1 -0
- package/dist/src/transforms/bin-histogram.d.ts +37 -0
- package/dist/src/transforms/bin-histogram.d.ts.map +1 -0
- package/dist/src/transforms/bin-histogram.js +32 -0
- package/dist/src/transforms/bin-histogram.js.map +1 -0
- package/dist/src/transforms/bin-linear-1d.d.ts +11 -0
- package/dist/src/transforms/bin-linear-1d.d.ts.map +1 -0
- package/dist/src/transforms/bin-linear-1d.js +25 -0
- package/dist/src/transforms/bin-linear-1d.js.map +1 -0
- package/dist/src/transforms/bin-linear-2d.d.ts +20 -0
- package/dist/src/transforms/bin-linear-2d.d.ts.map +1 -0
- package/dist/src/transforms/bin-linear-2d.js +49 -0
- package/dist/src/transforms/bin-linear-2d.js.map +1 -0
- package/dist/src/transforms/filter-query.d.ts +12 -0
- package/dist/src/transforms/filter-query.d.ts.map +1 -0
- package/dist/src/transforms/filter-query.js +39 -0
- package/dist/src/transforms/filter-query.js.map +1 -0
- package/dist/src/transforms/line-density.d.ts +24 -0
- package/dist/src/transforms/line-density.d.ts.map +1 -0
- package/dist/src/transforms/line-density.js +98 -0
- package/dist/src/transforms/line-density.js.map +1 -0
- package/dist/src/transforms/m4.d.ts +19 -0
- package/dist/src/transforms/m4.d.ts.map +1 -0
- package/dist/src/transforms/m4.js +38 -0
- package/dist/src/transforms/m4.js.map +1 -0
- package/dist/src/transforms/scales.d.ts +30 -0
- package/dist/src/transforms/scales.d.ts.map +1 -0
- package/dist/src/transforms/scales.js +103 -0
- package/dist/src/transforms/scales.js.map +1 -0
- package/dist/src/transforms/util/bin-step.d.ts +50 -0
- package/dist/src/transforms/util/bin-step.d.ts.map +1 -0
- package/dist/src/transforms/util/bin-step.js +53 -0
- package/dist/src/transforms/util/bin-step.js.map +1 -0
- package/dist/src/transforms/util/time-interval.d.ts +14 -0
- package/dist/src/transforms/util/time-interval.d.ts.map +1 -0
- package/dist/src/transforms/util/time-interval.js +88 -0
- package/dist/src/transforms/util/time-interval.js.map +1 -0
- package/dist/src/types.d.ts +49 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/util/ast.d.ts +62 -0
- package/dist/src/util/ast.d.ts.map +1 -0
- package/{src → dist/src}/util/ast.js +36 -41
- package/dist/src/util/ast.js.map +1 -0
- package/dist/src/util/function.d.ts +56 -0
- package/dist/src/util/function.d.ts.map +1 -0
- package/dist/src/util/function.js +73 -0
- package/dist/src/util/function.js.map +1 -0
- package/dist/src/util/identity.d.ts +6 -0
- package/dist/src/util/identity.d.ts.map +1 -0
- package/dist/src/util/identity.js +8 -0
- package/dist/src/util/identity.js.map +1 -0
- package/dist/src/util/string.d.ts +4 -0
- package/dist/src/util/string.d.ts.map +1 -0
- package/dist/src/util/string.js +14 -0
- package/dist/src/util/string.js.map +1 -0
- package/dist/src/util/type-check.d.ts +17 -0
- package/dist/src/util/type-check.d.ts.map +1 -0
- package/dist/src/util/type-check.js +28 -0
- package/dist/src/util/type-check.js.map +1 -0
- package/dist/src/visit/clone.d.ts +7 -0
- package/dist/src/visit/clone.d.ts.map +1 -0
- package/dist/src/visit/clone.js +52 -0
- package/dist/src/visit/clone.js.map +1 -0
- package/dist/src/visit/recurse.d.ts +2 -0
- package/dist/src/visit/recurse.d.ts.map +1 -0
- package/dist/src/visit/recurse.js +36 -0
- package/dist/src/visit/recurse.js.map +1 -0
- package/dist/src/visit/rewrite.d.ts +9 -0
- package/dist/src/visit/rewrite.d.ts.map +1 -0
- package/dist/src/visit/rewrite.js +39 -0
- package/dist/src/visit/rewrite.js.map +1 -0
- package/dist/src/visit/visitors.d.ts +32 -0
- package/dist/src/visit/visitors.d.ts.map +1 -0
- package/dist/src/visit/visitors.js +95 -0
- package/dist/src/visit/visitors.js.map +1 -0
- package/dist/src/visit/walk.d.ts +21 -0
- package/dist/src/visit/walk.d.ts.map +1 -0
- package/dist/src/visit/walk.js +32 -0
- package/dist/src/visit/walk.js.map +1 -0
- package/package.json +13 -7
- package/src/ast/{aggregate.js → aggregate.ts} +49 -60
- package/src/ast/{between-op.js → between-op.ts} +19 -26
- package/src/ast/binary-op.ts +31 -0
- package/src/ast/{case.js → case.ts} +29 -44
- package/src/ast/{cast.js → cast.ts} +8 -14
- package/src/ast/{collate.js → collate.ts} +8 -14
- package/src/ast/column-param.ts +34 -0
- package/src/ast/{column-ref.js → column-ref.ts} +16 -25
- package/src/ast/fragment.ts +28 -0
- package/src/ast/{from.js → from.ts} +12 -21
- package/src/ast/{function.js → function.ts} +8 -14
- package/src/ast/{in-op.js → in-op.ts} +8 -14
- package/src/ast/{interval.js → interval.ts} +8 -14
- package/src/ast/{literal.js → literal.ts} +6 -9
- package/src/ast/logical-op.ts +50 -0
- package/src/ast/{node.js → node.ts} +10 -13
- package/src/ast/order-by.ts +38 -0
- package/src/ast/{param.js → param.ts} +6 -12
- package/src/ast/{query.js → query.ts} +159 -203
- package/src/ast/sample.ts +47 -0
- package/src/ast/{select.js → select.ts} +10 -16
- package/src/ast/{subquery.js → subquery.ts} +9 -8
- package/src/ast/{table-ref.js → table-ref.ts} +7 -12
- package/src/ast/{unary-op.js → unary-op.ts} +16 -23
- package/src/ast/verbatim.ts +27 -0
- package/src/ast/{window-frame.js → window-frame.ts} +37 -47
- package/src/ast/window.ts +246 -0
- package/src/ast/{with.js → with.ts} +19 -20
- package/src/functions/aggregate.ts +344 -0
- package/src/functions/{case.js → case.ts} +5 -8
- package/src/functions/{cast.js → cast.ts} +9 -13
- package/src/functions/{collate.js → collate.ts} +4 -7
- package/src/functions/{column.js → column.ts} +9 -10
- package/src/functions/{cte.js → cte.ts} +9 -6
- package/src/functions/{datetime.js → datetime.ts} +12 -20
- package/src/functions/interval.ts +74 -0
- package/src/functions/{literal.js → literal.ts} +5 -7
- package/src/functions/numeric.ts +125 -0
- package/src/functions/operators.ts +272 -0
- package/src/functions/order-by.ts +21 -0
- package/src/functions/spatial.ts +50 -0
- package/src/functions/{sql-template-tag.js → sql-template-tag.ts} +16 -13
- package/src/functions/string.ts +79 -0
- package/src/functions/{table-ref.js → table-ref.ts} +4 -4
- package/src/functions/util.ts +10 -0
- package/src/functions/window-frame.ts +58 -0
- package/src/functions/{window.js → window.ts} +18 -35
- package/src/index.ts +75 -0
- package/src/load/{create.js → create.ts} +9 -3
- package/src/load/extension.ts +3 -0
- package/src/load/{load.js → load.ts} +25 -10
- package/src/load/{sql-from.js → sql-from.ts} +14 -7
- package/src/transforms/{bin-1d.js → bin-1d.ts} +13 -9
- package/src/transforms/{bin-2d.js → bin-2d.ts} +17 -13
- package/src/transforms/bin-date.ts +48 -0
- package/src/transforms/bin-histogram.ts +61 -0
- package/src/transforms/{bin-linear-1d.js → bin-linear-1d.ts} +16 -11
- package/src/transforms/{bin-linear-2d.js → bin-linear-2d.ts} +23 -35
- package/src/transforms/{filter-query.js → filter-query.ts} +10 -14
- package/src/transforms/{line-density.js → line-density.ts} +19 -17
- package/src/transforms/{m4.js → m4.ts} +17 -14
- package/src/transforms/{scales.js → scales.ts} +57 -14
- package/src/transforms/util/bin-step.ts +100 -0
- package/src/transforms/util/{time-interval.js → time-interval.ts} +32 -21
- package/src/types.ts +5 -39
- package/src/util/ast.ts +104 -0
- package/src/util/{function.js → function.ts} +40 -31
- package/src/util/identity.ts +7 -0
- package/src/util/{string.js → string.ts} +4 -4
- package/src/util/type-check.ts +31 -0
- package/src/visit/{clone.js → clone.ts} +10 -10
- package/src/visit/{recurse.js → recurse.ts} +1 -1
- package/src/visit/{rewrite.js → rewrite.ts} +7 -7
- package/src/visit/{visitors.js → visitors.ts} +22 -30
- package/src/visit/walk.ts +46 -0
- package/src/ast/binary-op.js +0 -40
- package/src/ast/column-param.js +0 -40
- package/src/ast/fragment.js +0 -26
- package/src/ast/logical-op.js +0 -67
- package/src/ast/order-by.js +0 -48
- package/src/ast/sample.js +0 -53
- package/src/ast/verbatim.js +0 -33
- package/src/ast/window.js +0 -260
- package/src/functions/aggregate.js +0 -347
- package/src/functions/interval.js +0 -83
- package/src/functions/numeric.js +0 -143
- package/src/functions/operators.js +0 -301
- package/src/functions/order-by.js +0 -27
- package/src/functions/spatial.js +0 -59
- package/src/functions/string.js +0 -85
- package/src/functions/util.js +0 -14
- package/src/functions/window-frame.js +0 -61
- package/src/index-types.ts +0 -2
- package/src/load/extension.js +0 -3
- package/src/transforms/bin-date.js +0 -38
- package/src/transforms/bin-histogram.js +0 -52
- package/src/transforms/util/bin-step.js +0 -79
- package/src/util/type-check.js +0 -33
- package/src/visit/walk.js +0 -34
- package/tsconfig.json +0 -8
- package/vitest.config.ts +0 -3
- /package/src/{constants.js → constants.ts} +0 -0
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @import { ColumnRefNode } from '../ast/column-ref.js'
|
|
3
|
-
* @import { TableRefNode } from '../ast/table-ref.js'
|
|
4
|
-
*/
|
|
5
1
|
import { ExprNode } from '../ast/node.js';
|
|
6
2
|
import { ParamNode } from '../ast/param.js';
|
|
7
3
|
import { WindowDefNode } from '../ast/window.js';
|
|
@@ -10,90 +6,89 @@ import { literal, verbatim } from '../functions/literal.js';
|
|
|
10
6
|
import { tableRef } from '../functions/table-ref.js';
|
|
11
7
|
import { parseIdentifier } from './string.js';
|
|
12
8
|
import { isArray, isParamLike, isString } from './type-check.js';
|
|
13
|
-
|
|
14
9
|
/**
|
|
15
10
|
* Interpret a value as a SQL AST node. String values are assumed to be
|
|
16
11
|
* column references. All other primitive values are interpreted as
|
|
17
12
|
* SQL literals. Dynamic parameters are interpreted as param AST nodes,
|
|
18
13
|
* while existing AST nodes are left as-is.
|
|
19
|
-
* @param
|
|
20
|
-
* @returns {ExprNode}
|
|
14
|
+
* @param value The value to interpret as a SQL AST node.
|
|
21
15
|
*/
|
|
22
16
|
export function asNode(value) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
return isString(value)
|
|
18
|
+
? parseColumnRef(value)
|
|
19
|
+
: asLiteral(value);
|
|
26
20
|
}
|
|
27
|
-
|
|
28
21
|
/**
|
|
29
22
|
* Interpret a value as a verbatim SQL AST node. String values will be
|
|
30
23
|
* passed through to queries as verbatim text. All other primitive values
|
|
31
24
|
* are interpreted as SQL literals. Dynamic parameters are interpreted
|
|
32
25
|
* as param AST nodes, while existing AST nodes are left as-is.
|
|
33
|
-
* @param
|
|
34
|
-
* @returns {ExprNode}
|
|
26
|
+
* @param value The value to interpret as a verbatim AST node.
|
|
35
27
|
*/
|
|
36
28
|
export function asVerbatim(value) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
return isString(value)
|
|
30
|
+
? verbatim(value)
|
|
31
|
+
: asLiteral(value);
|
|
40
32
|
}
|
|
41
|
-
|
|
42
33
|
/**
|
|
43
34
|
* Interpret a value as a literal AST node. All other primitive values
|
|
44
35
|
* are interpreted as SQL literals. Dynamic parameters are interpreted
|
|
45
36
|
* as param AST nodes, while existing AST nodes are left as-is.
|
|
46
|
-
* @param
|
|
47
|
-
* @returns {ExprNode}
|
|
37
|
+
* @param value The value to interpret as a literal AST node.
|
|
48
38
|
*/
|
|
49
39
|
export function asLiteral(value) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
40
|
+
return value instanceof ExprNode ? value
|
|
41
|
+
: isParamLike(value) ? new ParamNode(value)
|
|
42
|
+
: literal(value);
|
|
53
43
|
}
|
|
54
|
-
|
|
55
44
|
/**
|
|
56
45
|
* Interpret a value as a table reference AST node. String values are parsed
|
|
57
46
|
* assuming dot ('.') delimiters (as in `schema.table`). Array values are
|
|
58
47
|
* interpreted as pre-parsed name paths (as in `['schema', 'table']`). Any
|
|
59
48
|
* other values are left as-is.
|
|
60
|
-
* @param
|
|
61
|
-
* table reference AST node.
|
|
62
|
-
* @returns {TableRefNode}
|
|
49
|
+
* @param value The value to interpret as a table reference AST node.
|
|
63
50
|
*/
|
|
64
51
|
export function asTableRef(value) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
52
|
+
return getTableRef(value);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Try to interpret a value as a table reference AST node. String values are
|
|
56
|
+
* parsed assuming dot ('.') delimiters (as in `schema.table`). Array values
|
|
57
|
+
* are interpreted as pre-parsed name paths (as in `['schema', 'table']`). Any
|
|
58
|
+
* other values are left as-is.
|
|
59
|
+
* @param value The value to interpret as a table reference.
|
|
60
|
+
*/
|
|
61
|
+
export function maybeTableRef(value) {
|
|
62
|
+
return getTableRef(value);
|
|
63
|
+
}
|
|
64
|
+
function getTableRef(value) {
|
|
65
|
+
return isString(value) ? parseTableRef(value)
|
|
66
|
+
: isArray(value) ? tableRef(value)
|
|
67
|
+
: value;
|
|
68
68
|
}
|
|
69
|
-
|
|
70
69
|
/**
|
|
71
70
|
* Parse a string as a column reference, potentially with
|
|
72
71
|
* dot ('.') delimited table, schema, and database references.
|
|
73
|
-
* @param
|
|
74
|
-
* @returns {ColumnRefNode}
|
|
72
|
+
* @param ref The column reference string.
|
|
75
73
|
*/
|
|
76
74
|
export function parseColumnRef(ref) {
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
const ids = parseIdentifier(ref);
|
|
76
|
+
return column(ids.pop(), tableRef(ids));
|
|
79
77
|
}
|
|
80
|
-
|
|
81
78
|
/**
|
|
82
79
|
* Parse a string as a table reference, potentially with
|
|
83
80
|
* dot ('.') delimited schema and database references.
|
|
84
|
-
* @param
|
|
85
|
-
* @returns {TableRefNode}
|
|
81
|
+
* @param ref The table reference string.
|
|
86
82
|
*/
|
|
87
83
|
export function parseTableRef(ref) {
|
|
88
|
-
|
|
84
|
+
return tableRef(parseIdentifier(ref));
|
|
89
85
|
}
|
|
90
|
-
|
|
91
86
|
/**
|
|
92
87
|
* Create a new window definition node. The return value is an empty
|
|
93
88
|
* window definition. Use chained calls such as `partitionby` and `orderby`
|
|
94
89
|
* to specify the window settings.
|
|
95
|
-
* @returns {WindowDefNode}
|
|
96
90
|
*/
|
|
97
91
|
export function over() {
|
|
98
|
-
|
|
92
|
+
return new WindowDefNode();
|
|
99
93
|
}
|
|
94
|
+
//# sourceMappingURL=ast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../../src/util/ast.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAgB,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEjE;;;;;;GAMG;AACH,MAAM,UAAU,MAAM,CAAC,KAAc;IACnC,OAAO,QAAQ,CAAC,KAAK,CAAC;QACpB,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC;QACvB,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AACvB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UA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IAAI;IAClB,OAAO,IAAI,aAAa,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ExprNode, SQLNode } from '../ast/node.js';
|
|
2
|
+
import type { WindowFunctionName } from '../types.js';
|
|
3
|
+
import { AggregateNode } from '../ast/aggregate.js';
|
|
4
|
+
import { FunctionNode } from '../ast/function.js';
|
|
5
|
+
import { WindowNode } from '../ast/window.js';
|
|
6
|
+
/**
|
|
7
|
+
* Test if an AST node is a specific function call.
|
|
8
|
+
* @param node The SQL AST node to test.
|
|
9
|
+
* @param name The function name.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isFunctionCall(node: SQLNode, name: string): node is FunctionNode;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new function call AST node.
|
|
14
|
+
* @param name The function name.
|
|
15
|
+
* @param args The function arguments.
|
|
16
|
+
*/
|
|
17
|
+
export declare function fn(name: string, ...args: unknown[]): FunctionNode;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new aggregate function AST node.
|
|
20
|
+
* @param name The function name.
|
|
21
|
+
* @param args The function arguments.
|
|
22
|
+
*/
|
|
23
|
+
export declare function aggFn(name: string, ...args: unknown[]): AggregateNode;
|
|
24
|
+
/**
|
|
25
|
+
* Create a new window AST node. The output node has an empty window
|
|
26
|
+
* definition. Use chained calls such as `partitionby` and `orderby`
|
|
27
|
+
* to specify the window settings.
|
|
28
|
+
* @param name The function name.
|
|
29
|
+
* @param args The function arguments.
|
|
30
|
+
*/
|
|
31
|
+
export declare function winFn(name: WindowFunctionName, ...args: unknown[]): WindowNode;
|
|
32
|
+
/**
|
|
33
|
+
* Process a list of expression inputs. Nested arrays are flattened,
|
|
34
|
+
* null results are removed, and each input is cast to a SQL AST node.
|
|
35
|
+
* @param list The list of expression inputs.
|
|
36
|
+
* @param cast A function that casts an input value
|
|
37
|
+
* to a desired type. By default, `asNode` is used to coerce
|
|
38
|
+
* inputs to AST nodes as needed.
|
|
39
|
+
*/
|
|
40
|
+
export declare function exprList<T>(list: unknown[], cast: ((x: unknown) => T)): T[];
|
|
41
|
+
/**
|
|
42
|
+
* Process a list of expression inputs. Nested arrays are flattened,
|
|
43
|
+
* null results are removed, and each input is cast (as needed) to
|
|
44
|
+
* be a proper SQL AST node. By default, strings are assumed to be
|
|
45
|
+
* column names, while other primitive values map to SQL literals.
|
|
46
|
+
* Use an alternative *cast* function to change this behavior.
|
|
47
|
+
* @param list The list of expression inputs.
|
|
48
|
+
*/
|
|
49
|
+
export declare function nodeList(list: unknown[]): ExprNode[];
|
|
50
|
+
/**
|
|
51
|
+
* Process a list of function arguments, stripping any undefined
|
|
52
|
+
* values from the end of the list.
|
|
53
|
+
* @param list The input function arguments.
|
|
54
|
+
*/
|
|
55
|
+
export declare function argsList<T>(list: T[]): T[];
|
|
56
|
+
//# sourceMappingURL=function.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.d.ts","sourceRoot":"","sources":["../../../src/util/function.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AACxD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAsB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAGlE;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,GACX,IAAI,IAAI,YAAY,CAEtB;AAED;;;;GAIG;AACH,wBAAgB,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,YAAY,CAEjE;AAED;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,aAAa,CAErE;AAED;;;;;;GAMG;AACH,wBAAgB,KAAK,CACnB,IAAI,EAAE,kBAAkB,EACxB,GAAG,IAAI,EAAE,OAAO,EAAE,GACjB,UAAU,CAIZ;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,IAAI,EAAE,OAAO,EAAE,EACf,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,KAAK,CAAC,CAAC,GACxB,CAAC,EAAE,CAEL;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,QAAQ,EAAE,CAEpD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,EAAE,CAK1C"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { AggregateNode } from '../ast/aggregate.js';
|
|
2
|
+
import { FunctionNode } from '../ast/function.js';
|
|
3
|
+
import { WindowFunctionNode, WindowNode } from '../ast/window.js';
|
|
4
|
+
import { asNode } from './ast.js';
|
|
5
|
+
/**
|
|
6
|
+
* Test if an AST node is a specific function call.
|
|
7
|
+
* @param node The SQL AST node to test.
|
|
8
|
+
* @param name The function name.
|
|
9
|
+
*/
|
|
10
|
+
export function isFunctionCall(node, name) {
|
|
11
|
+
return node instanceof FunctionNode && node.name === name;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a new function call AST node.
|
|
15
|
+
* @param name The function name.
|
|
16
|
+
* @param args The function arguments.
|
|
17
|
+
*/
|
|
18
|
+
export function fn(name, ...args) {
|
|
19
|
+
return new FunctionNode(name, argsList(args).map(asNode));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Create a new aggregate function AST node.
|
|
23
|
+
* @param name The function name.
|
|
24
|
+
* @param args The function arguments.
|
|
25
|
+
*/
|
|
26
|
+
export function aggFn(name, ...args) {
|
|
27
|
+
return new AggregateNode(name, argsList(args).map(asNode));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Create a new window AST node. The output node has an empty window
|
|
31
|
+
* definition. Use chained calls such as `partitionby` and `orderby`
|
|
32
|
+
* to specify the window settings.
|
|
33
|
+
* @param name The function name.
|
|
34
|
+
* @param args The function arguments.
|
|
35
|
+
*/
|
|
36
|
+
export function winFn(name, ...args) {
|
|
37
|
+
return new WindowNode(new WindowFunctionNode(name, argsList(args).map(asNode)));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Process a list of expression inputs. Nested arrays are flattened,
|
|
41
|
+
* null results are removed, and each input is cast to a SQL AST node.
|
|
42
|
+
* @param list The list of expression inputs.
|
|
43
|
+
* @param cast A function that casts an input value
|
|
44
|
+
* to a desired type. By default, `asNode` is used to coerce
|
|
45
|
+
* inputs to AST nodes as needed.
|
|
46
|
+
*/
|
|
47
|
+
export function exprList(list, cast) {
|
|
48
|
+
return list.flat().filter(x => x != null).map(x => cast(x));
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Process a list of expression inputs. Nested arrays are flattened,
|
|
52
|
+
* null results are removed, and each input is cast (as needed) to
|
|
53
|
+
* be a proper SQL AST node. By default, strings are assumed to be
|
|
54
|
+
* column names, while other primitive values map to SQL literals.
|
|
55
|
+
* Use an alternative *cast* function to change this behavior.
|
|
56
|
+
* @param list The list of expression inputs.
|
|
57
|
+
*/
|
|
58
|
+
export function nodeList(list) {
|
|
59
|
+
return exprList(list, asNode);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Process a list of function arguments, stripping any undefined
|
|
63
|
+
* values from the end of the list.
|
|
64
|
+
* @param list The input function arguments.
|
|
65
|
+
*/
|
|
66
|
+
export function argsList(list) {
|
|
67
|
+
const n = list.length;
|
|
68
|
+
let i = n;
|
|
69
|
+
for (; i > 0 && list[i - 1] === undefined; --i)
|
|
70
|
+
;
|
|
71
|
+
return i < n ? list.slice(0, i) : list;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=function.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function.js","sourceRoot":"","sources":["../../../src/util/function.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAC5B,IAAa,EACb,IAAY;IAEZ,OAAO,IAAI,YAAY,YAAY,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,EAAE,CAAC,IAAY,EAAE,GAAG,IAAe;IACjD,OAAO,IAAI,YAAY,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC5D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,KAAK,CAAC,IAAY,EAAE,GAAG,IAAe;IACpD,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAC7D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CACnB,IAAwB,EACxB,GAAG,IAAe;IAElB,OAAO,IAAI,UAAU,CACnB,IAAI,kBAAkB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CACzD,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CACtB,IAAe,EACf,IAAyB;IAEzB,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,IAAe;IACtC,OAAO,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AAChC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,QAAQ,CAAI,IAAS;IACnC,MAAM,CAAC,GAAG,IAAI,CAAC,MAAM,CAAC;IACtB,IAAI,CAAC,GAAG,CAAC,CAAC;IACV,OAAO,CAAC,GAAG,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,SAAS,EAAE,EAAE,CAAC;QAAC,CAAC;IAChD,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.d.ts","sourceRoot":"","sources":["../../../src/util/identity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,KAE/B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"identity.js","sourceRoot":"","sources":["../../../src/util/identity.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAI,CAAI;IAC9B,OAAO,CAAC,CAAC;AACX,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../../src/util/string.ts"],"names":[],"mappings":"AACA,wBAAgB,eAAe,CAAC,EAAE,EAAE,MAAM,YAEzC;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,OAAO,UAE7C;AAED,wBAAgB,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,sBAEjC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// TODO: handle case where identifiers are already quoted?
|
|
2
|
+
export function parseIdentifier(id) {
|
|
3
|
+
return id.split('.');
|
|
4
|
+
}
|
|
5
|
+
export function quoteIdentifier(value) {
|
|
6
|
+
return `"${value}"`;
|
|
7
|
+
}
|
|
8
|
+
export function unquote(s) {
|
|
9
|
+
return s && isDoubleQuoted(s) ? s.slice(1, -1) : s;
|
|
10
|
+
}
|
|
11
|
+
function isDoubleQuoted(s) {
|
|
12
|
+
return s[0] === '"' && s[s.length - 1] === '"';
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=string.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"string.js","sourceRoot":"","sources":["../../../src/util/string.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,MAAM,UAAU,eAAe,CAAC,EAAU;IACxC,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AACvB,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAc;IAC5C,OAAO,IAAI,KAAK,GAAG,CAAC;AACtB,CAAC;AAED,MAAM,UAAU,OAAO,CAAC,CAAU;IAChC,OAAO,CAAC,IAAI,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,SAAS,cAAc,CAAC,CAAS;IAC/B,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,GAAC,CAAC,CAAC,KAAK,GAAG,CAAC;AAC/C,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ParamLike } from '../types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is a string.
|
|
4
|
+
* @param value The value to check.
|
|
5
|
+
*/
|
|
6
|
+
export declare function isString(value: unknown): value is string;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a value is an array.
|
|
9
|
+
* @param value The value to check.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isArray(value: unknown): value is Array<unknown>;
|
|
12
|
+
/**
|
|
13
|
+
* Check if a value is a dynamic parameter.
|
|
14
|
+
* @param value The value to check.
|
|
15
|
+
*/
|
|
16
|
+
export declare function isParamLike(value: unknown): value is ParamLike;
|
|
17
|
+
//# sourceMappingURL=type-check.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-check.d.ts","sourceRoot":"","sources":["../../../src/util/type-check.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAExD;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,CAE/D;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,SAAS,CAQ9D"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a value is a string.
|
|
3
|
+
* @param value The value to check.
|
|
4
|
+
*/
|
|
5
|
+
export function isString(value) {
|
|
6
|
+
return typeof value === 'string';
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Check if a value is an array.
|
|
10
|
+
* @param value The value to check.
|
|
11
|
+
*/
|
|
12
|
+
export function isArray(value) {
|
|
13
|
+
return Array.isArray(value);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Check if a value is a dynamic parameter.
|
|
17
|
+
* @param value The value to check.
|
|
18
|
+
*/
|
|
19
|
+
export function isParamLike(value) {
|
|
20
|
+
if (value) {
|
|
21
|
+
const v = value;
|
|
22
|
+
return typeof v?.addEventListener === 'function'
|
|
23
|
+
&& v.dynamic !== false
|
|
24
|
+
&& 'value' in v;
|
|
25
|
+
}
|
|
26
|
+
return false;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=type-check.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"type-check.js","sourceRoot":"","sources":["../../../src/util/type-check.ts"],"names":[],"mappings":"AAEA;;;GAGG;AACH,MAAM,UAAU,QAAQ,CAAC,KAAc;IACrC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAAc;IACpC,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc;IACxC,IAAI,KAAK,EAAE,CAAC;QACV,MAAM,CAAC,GAAG,KAA+B,CAAC;QAC1C,OAAO,OAAO,CAAC,EAAE,gBAAgB,KAAK,UAAU;eAC3C,CAAC,CAAC,OAAO,KAAK,KAAK;eACnB,OAAO,IAAI,CAAC,CAAC;IACpB,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.d.ts","sourceRoot":"","sources":["../../../src/visit/clone.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,GAAG,CAAC,CAkBvC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { isNode } from '../ast/node.js';
|
|
2
|
+
import { recurse } from './recurse.js';
|
|
3
|
+
/**
|
|
4
|
+
* Create a deep clone of the given SQL AST node and all children nodes.
|
|
5
|
+
* @param node The node to deeply clone.
|
|
6
|
+
* @returns The cloned node.
|
|
7
|
+
*/
|
|
8
|
+
export function deepClone(node) {
|
|
9
|
+
const clone = shallowClone(node);
|
|
10
|
+
if (isNode(node)) {
|
|
11
|
+
const props = recurse[node.type];
|
|
12
|
+
const n = props?.length ?? 0;
|
|
13
|
+
for (let i = 0; i < n; ++i) {
|
|
14
|
+
const key = props[i];
|
|
15
|
+
// @ts-expect-error allow assignment
|
|
16
|
+
const value = node[key];
|
|
17
|
+
// @ts-expect-error allow assignment
|
|
18
|
+
clone[key] = Array.isArray(value)
|
|
19
|
+
? value.map(v => deepClone(v))
|
|
20
|
+
: deepClone(value);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return clone;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Create a shallow clone of the given SQL AST node.
|
|
27
|
+
* @param node The node to clone.
|
|
28
|
+
* @returns The cloned node.
|
|
29
|
+
*/
|
|
30
|
+
function shallowClone(node) {
|
|
31
|
+
/** @type {T} */
|
|
32
|
+
let clone;
|
|
33
|
+
if (!node || typeof node !== 'object') {
|
|
34
|
+
return node;
|
|
35
|
+
}
|
|
36
|
+
else if (isNode(node)) {
|
|
37
|
+
clone = node.clone();
|
|
38
|
+
}
|
|
39
|
+
else if (node instanceof Date) {
|
|
40
|
+
// @ts-expect-error node is known to be Date
|
|
41
|
+
return new Date(+node);
|
|
42
|
+
}
|
|
43
|
+
else if (Array.isArray(node)) {
|
|
44
|
+
// @ts-expect-error allow slice
|
|
45
|
+
return node.slice();
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return { ...node };
|
|
49
|
+
}
|
|
50
|
+
return clone;
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=clone.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clone.js","sourceRoot":"","sources":["../../../src/visit/clone.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC;;;;GAIG;AACH,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,EAAE,CAAC;QAC/B,+BAA+B;QAC/B,OAAO,IAAI,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;SAAM,CAAC;QACN,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC;IACrB,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recurse.d.ts","sourceRoot":"","sources":["../../../src/visit/recurse.ts"],"names":[],"mappings":"AAmCA,eAAO,MAAM,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAiC5C,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { AGGREGATE, BETWEEN_OPERATOR, BINARY_OPERATOR, CASE, CAST, COLLATE, COLUMN_PARAM, COLUMN_REF, DESCRIBE_QUERY, EXPRESSION, FRAGMENT, FROM_CLAUSE, FUNCTION, IN_OPERATOR, LOGICAL_OPERATOR, NOT_BETWEEN_OPERATOR, ORDER_BY, PARAM, SCALAR_SUBQUERY, SELECT_CLAUSE, SELECT_QUERY, SET_OPERATION, UNARY_OPERATOR, UNARY_POSTFIX_OPERATOR, WHEN, WINDOW, WINDOW_CLAUSE, WINDOW_DEF, WINDOW_EXTENT_EXPR, WINDOW_FRAME, WINDOW_FUNCTION, WITH_CLAUSE } from '../constants.js';
|
|
2
|
+
export const recurse = {
|
|
3
|
+
[AGGREGATE]: ['args', 'order', 'filter'],
|
|
4
|
+
[BETWEEN_OPERATOR]: ['expr', 'extent'],
|
|
5
|
+
[BINARY_OPERATOR]: ['left', 'right'],
|
|
6
|
+
[CASE]: ['expr', '_when', '_else'],
|
|
7
|
+
[CAST]: ['expr'],
|
|
8
|
+
[COLLATE]: ['expr'],
|
|
9
|
+
[COLUMN_PARAM]: ['param', 'table'],
|
|
10
|
+
[COLUMN_REF]: ['table'],
|
|
11
|
+
[DESCRIBE_QUERY]: ['query'],
|
|
12
|
+
[EXPRESSION]: ['node'],
|
|
13
|
+
[FRAGMENT]: ['spans'],
|
|
14
|
+
[FROM_CLAUSE]: ['expr'],
|
|
15
|
+
[FUNCTION]: ['args'],
|
|
16
|
+
[IN_OPERATOR]: ['expr', 'values'],
|
|
17
|
+
[LOGICAL_OPERATOR]: ['clauses'],
|
|
18
|
+
[NOT_BETWEEN_OPERATOR]: ['expr', 'extent'],
|
|
19
|
+
[ORDER_BY]: ['expr'],
|
|
20
|
+
[PARAM]: ['value'],
|
|
21
|
+
[SCALAR_SUBQUERY]: ['subquery'],
|
|
22
|
+
[SELECT_CLAUSE]: ['expr'],
|
|
23
|
+
[SELECT_QUERY]: ['_with', '_select', '_from', '_where', '_sample', '_groupby', '_having', '_window', '_qualify', '_orderby'],
|
|
24
|
+
[SET_OPERATION]: ['queries', '_orderby'],
|
|
25
|
+
[UNARY_OPERATOR]: ['expr'],
|
|
26
|
+
[UNARY_POSTFIX_OPERATOR]: ['expr'],
|
|
27
|
+
[WHEN]: ['when', 'then'],
|
|
28
|
+
[WINDOW]: ['func', 'def'],
|
|
29
|
+
[WINDOW_CLAUSE]: ['def'],
|
|
30
|
+
[WINDOW_DEF]: ['partition', 'order', 'framedef'],
|
|
31
|
+
[WINDOW_EXTENT_EXPR]: ['expr'],
|
|
32
|
+
[WINDOW_FRAME]: ['extent'],
|
|
33
|
+
[WINDOW_FUNCTION]: ['args'],
|
|
34
|
+
[WITH_CLAUSE]: ['query']
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=recurse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"recurse.js","sourceRoot":"","sources":["../../../src/visit/recurse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,IAAI,EACJ,OAAO,EACP,YAAY,EACZ,UAAU,EACV,cAAc,EACd,UAAU,EACV,QAAQ,EACR,WAAW,EACX,QAAQ,EACR,WAAW,EACX,gBAAgB,EAChB,oBAAoB,EACpB,QAAQ,EACR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ClB,CAAC,eAAe,CAAC,EAAE,CAAC,UAAU,CAAC;IAC/B,CAAC,aAAa,CAAC,EAAE,CAAC,MAAM,CAAC;IACzB,CAAC,YAAY,CAAC,EAAE,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,UAAU,EAAE,UAAU,CAAC;IAC5H,CAAC,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,UAAU,CAAC;IACxC,CAAC,cAAc,CAAC,EAAE,CAAC,MAAM,CAAC;IAC1B,CAAC,sBAAsB,CAAC,EAAE,CAAC,MAAM,CAAC;IAClC,CAAC,IAAI,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,CAAC;IACzB,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,CAAC;IACxB,CAAC,UAAU,CAAC,EAAE,CAAC,WAAW,EAAE,OAAO,EAAE,UAAU,CAAC;IAChD,CAAC,kBAAkB,CAAC,EAAE,CAAC,MAAM,CAAC;IAC9B,CAAC,YAAY,CAAC,EAAE,CAAC,QAAQ,CAAC;IAC1B,CAAC,eAAe,CAAC,EAAE,CAAC,MAAM,CAAC;IAC3B,CAAC,WAAW,CAAC,EAAE,CAAC,OAAO,CAAC;CACzB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type ExprNode } from '../ast/node.js';
|
|
2
|
+
/**
|
|
3
|
+
* Rewrite a SQL expression, based on a map of nodes to replace.
|
|
4
|
+
* This method copies nodes as needed; it does not modify the input node.
|
|
5
|
+
* @param node The root AST node of the expression.
|
|
6
|
+
* @param map The rewrite map. When encountered, key nodes are replaced by value nodes.
|
|
7
|
+
*/
|
|
8
|
+
export declare function rewrite(node: ExprNode, map: Map<ExprNode, ExprNode>): ExprNode | undefined;
|
|
9
|
+
//# sourceMappingURL=rewrite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rewrite.d.ts","sourceRoot":"","sources":["../../../src/visit/rewrite.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAU,MAAM,gBAAgB,CAAC;AAGvD;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,QAAQ,EAAE,GAAG,EAAE,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,wBA2BnE"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { isNode } from '../ast/node.js';
|
|
2
|
+
import { recurse } from './recurse.js';
|
|
3
|
+
/**
|
|
4
|
+
* Rewrite a SQL expression, based on a map of nodes to replace.
|
|
5
|
+
* This method copies nodes as needed; it does not modify the input node.
|
|
6
|
+
* @param node The root AST node of the expression.
|
|
7
|
+
* @param map The rewrite map. When encountered, key nodes are replaced by value nodes.
|
|
8
|
+
*/
|
|
9
|
+
export function rewrite(node, map) {
|
|
10
|
+
if (map.has(node)) {
|
|
11
|
+
return map.get(node);
|
|
12
|
+
}
|
|
13
|
+
else if (isNode(node)) {
|
|
14
|
+
const props = recurse[node.type];
|
|
15
|
+
const n = props?.length ?? 0;
|
|
16
|
+
if (n > 0) {
|
|
17
|
+
node = node.clone();
|
|
18
|
+
for (let i = 0; i < n; ++i) {
|
|
19
|
+
const prop = props[i];
|
|
20
|
+
// @ts-expect-error lookup valid property
|
|
21
|
+
const child = node[prop];
|
|
22
|
+
if (Array.isArray(child)) {
|
|
23
|
+
// @ts-expect-error rewrite known property
|
|
24
|
+
const a = (node[prop] = child.slice());
|
|
25
|
+
const m = child.length;
|
|
26
|
+
for (let j = 0; j < m; ++j) {
|
|
27
|
+
a[j] = rewrite(child[j], map);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
else if (child) {
|
|
31
|
+
// @ts-expect-error rewrite known property
|
|
32
|
+
node[prop] = rewrite(child, map);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
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EAAE,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC;wBAC3B,CAAC,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;oBAChC,CAAC;gBACH,CAAC;qBAAM,IAAI,KAAK,EAAE,CAAC;oBACjB,0CAA0C;oBAC1C,IAAI,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;gBACnC,CAAC;YACH,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type AggregateNode } from '../ast/aggregate.js';
|
|
2
|
+
import type { ColumnRefNode } from '../ast/column-ref.js';
|
|
3
|
+
import type { SQLNode } from '../ast/node.js';
|
|
4
|
+
import type { ParamLike } from '../types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Indicate if the input AST contains an aggregate expression.
|
|
7
|
+
* The string content of verbatim nodes is analyzed to try to identify
|
|
8
|
+
* unparsed aggregate functions calls within SQL strings.
|
|
9
|
+
* @param root The root of the AST to search.
|
|
10
|
+
* @returns Return 0 if no aggregate functions are found.
|
|
11
|
+
* Sets bit 1 if an AggregateFunction instance is found.
|
|
12
|
+
* Sets bit 2 if an aggregate embedded in verbatim text is found.
|
|
13
|
+
*/
|
|
14
|
+
export declare function isAggregateExpression(root: SQLNode): number;
|
|
15
|
+
/**
|
|
16
|
+
* Collect all aggregate function nodes.
|
|
17
|
+
* @param root The root of the AST to search.
|
|
18
|
+
*/
|
|
19
|
+
export declare function collectAggregates(root: SQLNode): AggregateNode[];
|
|
20
|
+
/**
|
|
21
|
+
* Collect all unique column references.
|
|
22
|
+
* Multiple references to the same column are de-duplicated, even if
|
|
23
|
+
* they are not object-equal node instances.
|
|
24
|
+
* @param root The root of the AST to search.
|
|
25
|
+
*/
|
|
26
|
+
export declare function collectColumns(root: SQLNode): ColumnRefNode[];
|
|
27
|
+
/**
|
|
28
|
+
* Collect all unique dynamic parameter instances.
|
|
29
|
+
* @param root The root of the AST to search.
|
|
30
|
+
*/
|
|
31
|
+
export declare function collectParams(root: SQLNode): ParamLike[];
|
|
32
|
+
//# sourceMappingURL=visitors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"visitors.d.ts","sourceRoot":"","sources":["../../../src/visit/visitors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,aAAa,EAAkB,MAAM,qBAAqB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAE9C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAkB7C;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,EAAE,OAAO,UA4BlD;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,OAAO,mBAQ9C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,EAAE,OAAO,mBAS3C;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,EAAE,OAAO,eAQ1C"}
|