From 471b619a5bee95e7eb62f7ea6ab6de9ccfe724f7 Mon Sep 17 00:00:00 2001 From: Eugenio Arosteguy Date: Mon, 16 Apr 2018 14:46:29 -0300 Subject: [PATCH] Create index.d.ts https://basarat.gitbooks.io/typescript/docs/types/ambient/d.ts.html --- index.d.ts | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 index.d.ts diff --git a/index.d.ts b/index.d.ts new file mode 100644 index 0000000..bccb272 --- /dev/null +++ b/index.d.ts @@ -0,0 +1,62 @@ +// Declaration file to have types in Typescript code that uses sqlite-parser +declare module 'sqlite-parser' { + + function sqliteParser(expression: string): sqliteParser.ParsedObject + + namespace sqliteParser { + // some sqlite-parser types for literal types + type dataType = 'text' | 'decimal' | 'boolean' | 'date' | 'datetime' | 'null'; + + interface BaseNode { + type: string, + } + + interface IdentifierNode extends BaseNode { + type: 'identifier' + name: string + } + + interface LiteralNode extends BaseNode { + type: 'literal' + value: string + variant: dataType + } + + interface FunctionNode extends BaseNode { + type: 'function' + name: IdentifierNode + args: {expression: BaseNode[]} + } + + interface ExpressionNode extends BaseNode { + type: 'expression' + format: 'binary'|'unary' + } + + interface BinaryExpressionNode extends ExpressionNode { + format: 'binary' + operation: string + left: BaseNode + right: BaseNode + } + + interface UnaryExpressionNode extends ExpressionNode { + format: 'unary' + operator: string + expression: BaseNode + } + + type ParsedObject = { + type: "statement", + variant: "list", + statement: [ + { + type: "statement", + variant: "select", + result: BaseNode[] + } + ] + }; + } + export = sqliteParser +}