flowquery 1.0.2 → 1.0.5

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.
Files changed (186) hide show
  1. package/README.md +54 -1
  2. package/dist/compute/runner.d.ts +81 -0
  3. package/dist/compute/runner.d.ts.map +1 -0
  4. package/dist/index.browser.d.ts +10 -0
  5. package/dist/index.browser.d.ts.map +1 -0
  6. package/dist/index.d.ts +9 -0
  7. package/dist/index.d.ts.map +1 -0
  8. package/dist/index.node.d.ts +14 -0
  9. package/dist/index.node.d.ts.map +1 -0
  10. package/dist/io/command_line.d.ts +28 -0
  11. package/dist/io/command_line.d.ts.map +1 -0
  12. package/dist/parsing/alias.d.ts +10 -0
  13. package/dist/parsing/alias.d.ts.map +1 -0
  14. package/dist/parsing/alias_option.d.ts +6 -0
  15. package/dist/parsing/alias_option.d.ts.map +1 -0
  16. package/dist/parsing/ast_node.d.ts +100 -0
  17. package/dist/parsing/ast_node.d.ts.map +1 -0
  18. package/dist/parsing/base_parser.d.ts +49 -0
  19. package/dist/parsing/base_parser.d.ts.map +1 -0
  20. package/dist/parsing/components/csv.d.ts +6 -0
  21. package/dist/parsing/components/csv.d.ts.map +1 -0
  22. package/dist/parsing/components/from.d.ts +7 -0
  23. package/dist/parsing/components/from.d.ts.map +1 -0
  24. package/dist/parsing/components/headers.d.ts +7 -0
  25. package/dist/parsing/components/headers.d.ts.map +1 -0
  26. package/dist/parsing/components/json.d.ts +6 -0
  27. package/dist/parsing/components/json.d.ts.map +1 -0
  28. package/dist/parsing/components/null.d.ts +6 -0
  29. package/dist/parsing/components/null.d.ts.map +1 -0
  30. package/dist/parsing/components/post.d.ts +6 -0
  31. package/dist/parsing/components/post.d.ts.map +1 -0
  32. package/dist/parsing/components/text.d.ts +6 -0
  33. package/dist/parsing/components/text.d.ts.map +1 -0
  34. package/dist/parsing/context.d.ts +38 -0
  35. package/dist/parsing/context.d.ts.map +1 -0
  36. package/dist/parsing/data_structures/associative_array.d.ts +28 -0
  37. package/dist/parsing/data_structures/associative_array.d.ts.map +1 -0
  38. package/dist/parsing/data_structures/json_array.d.ts +26 -0
  39. package/dist/parsing/data_structures/json_array.d.ts.map +1 -0
  40. package/dist/parsing/data_structures/key_value_pair.d.ts +25 -0
  41. package/dist/parsing/data_structures/key_value_pair.d.ts.map +1 -0
  42. package/dist/parsing/data_structures/lookup.d.ts +25 -0
  43. package/dist/parsing/data_structures/lookup.d.ts.map +1 -0
  44. package/dist/parsing/data_structures/range_lookup.d.ts +14 -0
  45. package/dist/parsing/data_structures/range_lookup.d.ts.map +1 -0
  46. package/dist/parsing/expressions/expression.d.ts +53 -0
  47. package/dist/parsing/expressions/expression.d.ts.map +1 -0
  48. package/dist/parsing/expressions/f_string.d.ts +21 -0
  49. package/dist/parsing/expressions/f_string.d.ts.map +1 -0
  50. package/dist/parsing/expressions/identifier.d.ts +17 -0
  51. package/dist/parsing/expressions/identifier.d.ts.map +1 -0
  52. package/dist/parsing/expressions/number.d.ts +25 -0
  53. package/dist/parsing/expressions/number.d.ts.map +1 -0
  54. package/dist/parsing/expressions/operator.d.ts +79 -0
  55. package/dist/parsing/expressions/operator.d.ts.map +1 -0
  56. package/dist/parsing/expressions/reference.d.ts +29 -0
  57. package/dist/parsing/expressions/reference.d.ts.map +1 -0
  58. package/dist/parsing/expressions/string.d.ts +23 -0
  59. package/dist/parsing/expressions/string.d.ts.map +1 -0
  60. package/dist/parsing/functions/aggregate_function.d.ts +42 -0
  61. package/dist/parsing/functions/aggregate_function.d.ts.map +1 -0
  62. package/dist/parsing/functions/async_function.d.ts +52 -0
  63. package/dist/parsing/functions/async_function.d.ts.map +1 -0
  64. package/dist/parsing/functions/avg.d.ts +15 -0
  65. package/dist/parsing/functions/avg.d.ts.map +1 -0
  66. package/dist/parsing/functions/collect.d.ts +21 -0
  67. package/dist/parsing/functions/collect.d.ts.map +1 -0
  68. package/dist/parsing/functions/function.d.ts +36 -0
  69. package/dist/parsing/functions/function.d.ts.map +1 -0
  70. package/dist/parsing/functions/function_factory.d.ts +151 -0
  71. package/dist/parsing/functions/function_factory.d.ts.map +1 -0
  72. package/dist/parsing/functions/function_metadata.d.ts +83 -0
  73. package/dist/parsing/functions/function_metadata.d.ts.map +1 -0
  74. package/dist/parsing/functions/functions.d.ts +21 -0
  75. package/dist/parsing/functions/functions.d.ts.map +1 -0
  76. package/dist/parsing/functions/join.d.ts +9 -0
  77. package/dist/parsing/functions/join.d.ts.map +1 -0
  78. package/dist/parsing/functions/predicate_function.d.ts +18 -0
  79. package/dist/parsing/functions/predicate_function.d.ts.map +1 -0
  80. package/dist/parsing/functions/predicate_function_factory.d.ts +6 -0
  81. package/dist/parsing/functions/predicate_function_factory.d.ts.map +1 -0
  82. package/dist/parsing/functions/predicate_sum.d.ts +7 -0
  83. package/dist/parsing/functions/predicate_sum.d.ts.map +1 -0
  84. package/dist/parsing/functions/rand.d.ts +7 -0
  85. package/dist/parsing/functions/rand.d.ts.map +1 -0
  86. package/dist/parsing/functions/range.d.ts +7 -0
  87. package/dist/parsing/functions/range.d.ts.map +1 -0
  88. package/dist/parsing/functions/reducer_element.d.ts +6 -0
  89. package/dist/parsing/functions/reducer_element.d.ts.map +1 -0
  90. package/dist/parsing/functions/replace.d.ts +7 -0
  91. package/dist/parsing/functions/replace.d.ts.map +1 -0
  92. package/dist/parsing/functions/round.d.ts +7 -0
  93. package/dist/parsing/functions/round.d.ts.map +1 -0
  94. package/dist/parsing/functions/size.d.ts +7 -0
  95. package/dist/parsing/functions/size.d.ts.map +1 -0
  96. package/dist/parsing/functions/split.d.ts +9 -0
  97. package/dist/parsing/functions/split.d.ts.map +1 -0
  98. package/dist/parsing/functions/stringify.d.ts +9 -0
  99. package/dist/parsing/functions/stringify.d.ts.map +1 -0
  100. package/dist/parsing/functions/sum.d.ts +14 -0
  101. package/dist/parsing/functions/sum.d.ts.map +1 -0
  102. package/dist/parsing/functions/to_json.d.ts +7 -0
  103. package/dist/parsing/functions/to_json.d.ts.map +1 -0
  104. package/dist/parsing/functions/value_holder.d.ts +8 -0
  105. package/dist/parsing/functions/value_holder.d.ts.map +1 -0
  106. package/dist/parsing/logic/case.d.ts +7 -0
  107. package/dist/parsing/logic/case.d.ts.map +1 -0
  108. package/dist/parsing/logic/else.d.ts +7 -0
  109. package/dist/parsing/logic/else.d.ts.map +1 -0
  110. package/dist/parsing/logic/end.d.ts +6 -0
  111. package/dist/parsing/logic/end.d.ts.map +1 -0
  112. package/dist/parsing/logic/then.d.ts +7 -0
  113. package/dist/parsing/logic/then.d.ts.map +1 -0
  114. package/dist/parsing/logic/when.d.ts +7 -0
  115. package/dist/parsing/logic/when.d.ts.map +1 -0
  116. package/dist/parsing/operations/aggregated_return.d.ts +8 -0
  117. package/dist/parsing/operations/aggregated_return.d.ts.map +1 -0
  118. package/dist/parsing/operations/aggregated_with.d.ts +8 -0
  119. package/dist/parsing/operations/aggregated_with.d.ts.map +1 -0
  120. package/dist/parsing/operations/group_by.d.ts +35 -0
  121. package/dist/parsing/operations/group_by.d.ts.map +1 -0
  122. package/dist/parsing/operations/limit.d.ts +10 -0
  123. package/dist/parsing/operations/limit.d.ts.map +1 -0
  124. package/dist/parsing/operations/load.d.ts +48 -0
  125. package/dist/parsing/operations/load.d.ts.map +1 -0
  126. package/dist/parsing/operations/operation.d.ts +39 -0
  127. package/dist/parsing/operations/operation.d.ts.map +1 -0
  128. package/dist/parsing/operations/projection.d.ts +8 -0
  129. package/dist/parsing/operations/projection.d.ts.map +1 -0
  130. package/dist/parsing/operations/return.d.ts +23 -0
  131. package/dist/parsing/operations/return.d.ts.map +1 -0
  132. package/dist/parsing/operations/unwind.d.ts +12 -0
  133. package/dist/parsing/operations/unwind.d.ts.map +1 -0
  134. package/dist/parsing/operations/where.d.ts +26 -0
  135. package/dist/parsing/operations/where.d.ts.map +1 -0
  136. package/dist/parsing/operations/with.d.ts +17 -0
  137. package/dist/parsing/operations/with.d.ts.map +1 -0
  138. package/dist/parsing/parser.d.ts +66 -0
  139. package/dist/parsing/parser.d.ts.map +1 -0
  140. package/dist/parsing/parser.js +1 -1
  141. package/dist/parsing/token_to_node.d.ts +7 -0
  142. package/dist/parsing/token_to_node.d.ts.map +1 -0
  143. package/dist/tokenization/keyword.d.ts +43 -0
  144. package/dist/tokenization/keyword.d.ts.map +1 -0
  145. package/dist/tokenization/operator.d.ts +22 -0
  146. package/dist/tokenization/operator.d.ts.map +1 -0
  147. package/dist/tokenization/string_walker.d.ts +55 -0
  148. package/dist/tokenization/string_walker.d.ts.map +1 -0
  149. package/dist/tokenization/symbol.d.ts +15 -0
  150. package/dist/tokenization/symbol.d.ts.map +1 -0
  151. package/dist/tokenization/token.d.ts +176 -0
  152. package/dist/tokenization/token.d.ts.map +1 -0
  153. package/dist/tokenization/token_mapper.d.ts +40 -0
  154. package/dist/tokenization/token_mapper.d.ts.map +1 -0
  155. package/dist/tokenization/token_mapper.js +2 -2
  156. package/dist/tokenization/token_mapper.js.map +1 -1
  157. package/dist/tokenization/token_type.d.ts +16 -0
  158. package/dist/tokenization/token_type.d.ts.map +1 -0
  159. package/dist/tokenization/tokenizer.d.ts +45 -0
  160. package/dist/tokenization/tokenizer.d.ts.map +1 -0
  161. package/dist/tokenization/trie.d.ts +41 -0
  162. package/dist/tokenization/trie.d.ts.map +1 -0
  163. package/dist/utils/object_utils.d.ts +15 -0
  164. package/dist/utils/object_utils.d.ts.map +1 -0
  165. package/dist/utils/string_utils.d.ts +51 -0
  166. package/dist/utils/string_utils.d.ts.map +1 -0
  167. package/misc/apps/RAG/README.md +48 -0
  168. package/misc/apps/RAG/package.json +31 -0
  169. package/misc/apps/RAG/src/index.ts +20 -0
  170. package/misc/apps/RAG/tsconfig.json +19 -0
  171. package/misc/apps/RAG/webpack.config.js +32 -0
  172. package/misc/apps/README.md +1 -0
  173. package/package.json +1 -1
  174. package/src/parsing/parser.ts +1 -1
  175. package/src/tokenization/token_mapper.ts +2 -2
  176. package/tsconfig.json +3 -1
  177. /package/{queries → misc/queries}/analyze_catfacts.cql +0 -0
  178. /package/{queries → misc/queries}/azure_openai_completions.cql +0 -0
  179. /package/{queries → misc/queries}/azure_openai_models.cql +0 -0
  180. /package/{queries → misc/queries}/mock_pipeline.cql +0 -0
  181. /package/{queries → misc/queries}/openai_completions.cql +0 -0
  182. /package/{queries → misc/queries}/openai_models.cql +0 -0
  183. /package/{queries → misc/queries}/test.cql +0 -0
  184. /package/{queries → misc/queries}/tool_inference.cql +0 -0
  185. /package/{queries → misc/queries}/wisdom.cql +0 -0
  186. /package/{queries → misc/queries}/wisdom_letter_histogram.cql +0 -0
@@ -0,0 +1,40 @@
1
+ import Token from "./token";
2
+ /**
3
+ * Maps string values to tokens using a Trie for efficient lookup.
4
+ *
5
+ * Takes an enum of keywords, operators, or symbols and builds a trie
6
+ * for fast token matching during tokenization.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const mapper = new TokenMapper(Keyword);
11
+ * const token = mapper.map("WITH");
12
+ * ```
13
+ */
14
+ declare class TokenMapper {
15
+ private _enum;
16
+ private _trie;
17
+ /**
18
+ * Creates a TokenMapper from an enum of token values.
19
+ *
20
+ * @param _enum - An enum object containing token values
21
+ */
22
+ constructor(_enum: {
23
+ [key: string]: any;
24
+ });
25
+ /**
26
+ * Maps a string value to its corresponding token.
27
+ *
28
+ * @param value - The string value to map
29
+ * @returns The matched token, or undefined if no match found
30
+ */
31
+ map(value: string): Token | undefined;
32
+ /**
33
+ * Gets the last matched string from the most recent map operation.
34
+ *
35
+ * @returns The last found string, or null if no match
36
+ */
37
+ get last_found(): string | null;
38
+ }
39
+ export default TokenMapper;
40
+ //# sourceMappingURL=token_mapper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token_mapper.d.ts","sourceRoot":"","sources":["../../src/tokenization/token_mapper.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAG5B;;;;;;;;;;;GAWG;AACH,cAAM,WAAW;IAQD,OAAO,CAAC,KAAK;IAPzB,OAAO,CAAC,KAAK,CAAoB;IAEjC;;;;OAIG;gBACiB,KAAK,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE;IASjD;;;;;OAKG;IACI,GAAG,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAI5C;;;;OAIG;IACH,IAAW,UAAU,IAAI,MAAM,GAAG,IAAI,CAErC;CACJ;AAED,eAAe,WAAW,CAAC"}
@@ -3,8 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const token_1 = __importDefault(require("../../src/tokenization/token"));
7
- const trie_1 = __importDefault(require("../../src/tokenization/trie"));
6
+ const token_1 = __importDefault(require("./token"));
7
+ const trie_1 = __importDefault(require("./trie"));
8
8
  /**
9
9
  * Maps string values to tokens using a Trie for efficient lookup.
10
10
  *
@@ -1 +1 @@
1
- {"version":3,"file":"token_mapper.js","sourceRoot":"","sources":["../../src/tokenization/token_mapper.ts"],"names":[],"mappings":";;;;;AAAA,yEAAiD;AACjD,uEAA+C;AAE/C;;;;;;;;;;;GAWG;AACH,MAAM,WAAW;IAGb;;;;OAIG;IACH,YAAoB,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;QAPzC,UAAK,GAAS,IAAI,cAAI,EAAE,CAAC;QAQ7B,KAAI,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,MAAM,KAAK,GAAsB,eAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACnD,IAAG,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,KAAa;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;IACjC,CAAC;CACJ;AAED,kBAAe,WAAW,CAAC"}
1
+ {"version":3,"file":"token_mapper.js","sourceRoot":"","sources":["../../src/tokenization/token_mapper.ts"],"names":[],"mappings":";;;;;AAAA,oDAA4B;AAC5B,kDAA0B;AAE1B;;;;;;;;;;;GAWG;AACH,MAAM,WAAW;IAGb;;;;OAIG;IACH,YAAoB,KAA6B;QAA7B,UAAK,GAAL,KAAK,CAAwB;QAPzC,UAAK,GAAS,IAAI,cAAI,EAAE,CAAC;QAQ7B,KAAI,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAC9C,MAAM,KAAK,GAAsB,eAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YACnD,IAAG,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC7C,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC7B,CAAC;QACL,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAC,KAAa;QACpB,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,CAAC;IACjC,CAAC;CACJ;AAED,kBAAe,WAAW,CAAC"}
@@ -0,0 +1,16 @@
1
+ declare enum TokenType {
2
+ KEYWORD = "KEYWORD",
3
+ OPERATOR = "OPERATOR",
4
+ UNARY_OPERATOR = "UNARY_OPERATOR",
5
+ IDENTIFIER = "IDENTIFIER",
6
+ STRING = "STRING",
7
+ F_STRING = "F-STRING",
8
+ BACKTICK_STRING = "BACKTICK_STRING",
9
+ NUMBER = "NUMBER",
10
+ SYMBOL = "SYMBOL",
11
+ WHITESPACE = "WHITESPACE",
12
+ COMMENT = "COMMENT",
13
+ EOF = "EOF"
14
+ }
15
+ export default TokenType;
16
+ //# sourceMappingURL=token_type.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"token_type.d.ts","sourceRoot":"","sources":["../../src/tokenization/token_type.ts"],"names":[],"mappings":"AAAA,aAAK,SAAS;IACV,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,cAAc,mBAAmB;IACjC,UAAU,eAAe;IACzB,MAAM,WAAW;IACjB,QAAQ,aAAa;IACrB,eAAe,oBAAoB;IACnC,MAAM,WAAW;IACjB,MAAM,WAAW;IACjB,UAAU,eAAe;IACzB,OAAO,YAAY;IACnB,GAAG,QAAQ;CACd;AACD,eAAe,SAAS,CAAC"}
@@ -0,0 +1,45 @@
1
+ import Token from './token';
2
+ /**
3
+ * Tokenizes FlowQuery input strings into a sequence of tokens.
4
+ *
5
+ * The tokenizer performs lexical analysis, breaking down the input text into
6
+ * meaningful tokens such as keywords, identifiers, operators, strings, numbers,
7
+ * and symbols. It handles comments, whitespace, and f-strings.
8
+ *
9
+ * @example
10
+ * ```typescript
11
+ * const tokenizer = new Tokenizer("WITH x = 1 RETURN x");
12
+ * const tokens = tokenizer.tokenize();
13
+ * ```
14
+ */
15
+ declare class Tokenizer {
16
+ private walker;
17
+ private keywords;
18
+ private symbols;
19
+ private operators;
20
+ /**
21
+ * Creates a new Tokenizer instance for the given input.
22
+ *
23
+ * @param input - The FlowQuery input string to tokenize
24
+ */
25
+ constructor(input: string);
26
+ /**
27
+ * Tokenizes the input string into an array of tokens.
28
+ *
29
+ * @returns An array of Token objects representing the tokenized input
30
+ * @throws {Error} If an unrecognized token is encountered
31
+ */
32
+ tokenize(): Token[];
33
+ private getLastNonWhitespaceOrNonCommentToken;
34
+ private getNextToken;
35
+ comment(): Token | null;
36
+ private identifier;
37
+ private string;
38
+ private f_string;
39
+ private whitespace;
40
+ private number;
41
+ private lookup;
42
+ private skipMinus;
43
+ }
44
+ export default Tokenizer;
45
+ //# sourceMappingURL=tokenizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenizer.d.ts","sourceRoot":"","sources":["../../src/tokenization/tokenizer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;AAO5B;;;;;;;;;;;;GAYG;AACH,cAAM,SAAS;IACX,OAAO,CAAC,MAAM,CAAe;IAC7B,OAAO,CAAC,QAAQ,CAAyC;IACzD,OAAO,CAAC,OAAO,CAAwC;IACvD,OAAO,CAAC,SAAS,CAA0C;IAE3D;;;;OAIG;gBACS,KAAK,EAAE,MAAM;IAIzB;;;;;OAKG;IACI,QAAQ,IAAI,KAAK,EAAE;IAgB1B,OAAO,CAAC,qCAAqC;IAU7C,OAAO,CAAC,YAAY;IAgBb,OAAO,IAAI,KAAK,GAAG,IAAI;IAS9B,OAAO,CAAC,UAAU;IAWlB,OAAO,CAAC,MAAM;IAwBd,OAAO,CAAE,QAAQ;IA6CjB,OAAO,CAAC,UAAU;IASlB,OAAO,CAAC,MAAM;IAiBd,OAAO,CAAC,MAAM;IAkBd,OAAO,CAAC,SAAS;CASpB;AAED,eAAe,SAAS,CAAC"}
@@ -0,0 +1,41 @@
1
+ import Token from "./token";
2
+ /**
3
+ * Trie (prefix tree) data structure for efficient keyword and operator lookup.
4
+ *
5
+ * Used during tokenization to quickly match input strings against known keywords
6
+ * and operators. Supports case-insensitive matching and tracks the longest match found.
7
+ *
8
+ * @example
9
+ * ```typescript
10
+ * const trie = new Trie();
11
+ * trie.insert(Token.WITH);
12
+ * const found = trie.find("WITH");
13
+ * ```
14
+ */
15
+ declare class Trie {
16
+ private _root;
17
+ private _max_length;
18
+ private _last_found;
19
+ /**
20
+ * Inserts a token into the trie.
21
+ *
22
+ * @param token - The token to insert
23
+ * @throws {Error} If the token value is null or empty
24
+ */
25
+ insert(token: Token): void;
26
+ /**
27
+ * Finds a token by searching for the longest matching prefix in the trie.
28
+ *
29
+ * @param value - The string value to search for
30
+ * @returns The token if found, undefined otherwise
31
+ */
32
+ find(value: string): Token | undefined;
33
+ /**
34
+ * Gets the last matched string from the most recent find operation.
35
+ *
36
+ * @returns The last found string, or null if no match was found
37
+ */
38
+ get last_found(): string | null;
39
+ }
40
+ export default Trie;
41
+ //# sourceMappingURL=trie.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trie.d.ts","sourceRoot":"","sources":["../../src/tokenization/trie.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,SAAS,CAAC;AAqC5B;;;;;;;;;;;;GAYG;AACH,cAAM,IAAI;IACN,OAAO,CAAC,KAAK,CAAoB;IACjC,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,WAAW,CAAuB;IAE1C;;;;;OAKG;IACI,MAAM,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI;IAcjC;;;;;OAKG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS;IAyB7C;;;;OAIG;IACH,IAAW,UAAU,IAAI,MAAM,GAAG,IAAI,CAErC;CACJ;AAED,eAAe,IAAI,CAAC"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Utility class for object-related operations.
3
+ */
4
+ declare class ObjectUtils {
5
+ /**
6
+ * Checks if an object is an instance of any of the provided classes.
7
+ *
8
+ * @param obj - The object to check
9
+ * @param classes - Array of class constructors to test against
10
+ * @returns True if the object is an instance of any class, false otherwise
11
+ */
12
+ static isInstanceOfAny(obj: any, classes: any[]): boolean;
13
+ }
14
+ export default ObjectUtils;
15
+ //# sourceMappingURL=object_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object_utils.d.ts","sourceRoot":"","sources":["../../src/utils/object_utils.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAM,WAAW;IACb;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,GAAG,OAAO;CAG5D;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Utility class for string manipulation and validation.
3
+ *
4
+ * Provides methods for handling quoted strings, comments, escape sequences,
5
+ * and identifier validation.
6
+ */
7
+ declare class StringUtils {
8
+ static readonly quotes: string[];
9
+ static readonly letters = "abcdefghijklmnopqrstuvwxyz";
10
+ static readonly digits = "0123456789";
11
+ static readonly whitespace = " \t\n\r";
12
+ static readonly word_valid_chars: string;
13
+ /**
14
+ * Removes surrounding quotes from a string.
15
+ *
16
+ * @param str - The string to unquote
17
+ * @returns The unquoted string
18
+ */
19
+ static unquote(str: string): string;
20
+ /**
21
+ * Removes comment markers from a string.
22
+ *
23
+ * @param str - The comment string
24
+ * @returns The string without comment markers
25
+ */
26
+ static uncomment(str: string): string;
27
+ /**
28
+ * Removes escape sequences before quotes in a string.
29
+ *
30
+ * @param str - The string to process
31
+ * @param quoteChar - The quote character that was escaped
32
+ * @returns The string with escape sequences removed
33
+ */
34
+ static removeEscapedQuotes(str: string, quoteChar: string): string;
35
+ /**
36
+ * Removes escaped braces ({{ and }}) from f-strings.
37
+ *
38
+ * @param str - The string to process
39
+ * @returns The string with escaped braces resolved
40
+ */
41
+ static removeEscapedBraces(str: string): string;
42
+ /**
43
+ * Checks if a string is a valid identifier.
44
+ *
45
+ * @param str - The string to validate
46
+ * @returns True if the string can be used as an identifier, false otherwise
47
+ */
48
+ static can_be_identifier(str: string): boolean;
49
+ }
50
+ export default StringUtils;
51
+ //# sourceMappingURL=string_utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string_utils.d.ts","sourceRoot":"","sources":["../../src/utils/string_utils.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,cAAM,WAAW;IACb,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAmB;IACnD,MAAM,CAAC,QAAQ,CAAC,OAAO,gCAAgC;IACvD,MAAM,CAAC,QAAQ,CAAC,MAAM,gBAAgB;IACtC,MAAM,CAAC,QAAQ,CAAC,UAAU,aAAa;IACvC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,SAAkD;IAElF;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAqBnC;;;;;OAKG;IACH,MAAM,CAAC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAarC;;;;;;OAMG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,MAAM;IAWlE;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;IAW/C;;;;;OAKG;IACH,MAAM,CAAC,iBAAiB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO;CAWjD;AAED,eAAe,WAAW,CAAC"}
@@ -0,0 +1,48 @@
1
+ # RAG FlowQuery App
2
+
3
+ A RAG (Retrieval Augmented Generation) loop based on [FlowQuery](https://www.npmjs.com/package/flowquery).
4
+
5
+ ## Prerequisites
6
+
7
+ - Node.js 18+
8
+ - npm
9
+
10
+ ## Getting Started
11
+
12
+ ```bash
13
+ # Install dependencies
14
+ npm install
15
+
16
+ # Run in development mode (with ts-node)
17
+ npm run dev
18
+
19
+ # Or build and run
20
+ npm run build
21
+ npm start
22
+ ```
23
+
24
+ ## Available Scripts
25
+
26
+ | Script | Description |
27
+ |--------|-------------|
28
+ | `npm run dev` | Run directly with ts-node (for development) |
29
+ | `npm run build` | Compile TypeScript to `dist/` |
30
+ | `npm start` | Run the compiled JavaScript |
31
+ | `npm run build:bundle` | Create a webpack bundle |
32
+ | `npm run watch` | Watch mode for TypeScript compilation |
33
+
34
+ ## Project Structure
35
+
36
+ ```
37
+ RAG/
38
+ ├── src/
39
+ │ └── index.ts # Main entry point
40
+ ├── dist/ # Compiled output (generated)
41
+ ├── package.json
42
+ ├── tsconfig.json
43
+ └── webpack.config.js
44
+ ```
45
+
46
+ ## License
47
+
48
+ MIT
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "rag-flowquery",
3
+ "version": "1.0.0",
4
+ "description": "A RAG (Retrieval Augmented Generation) loop based on FlowQuery.",
5
+ "main": "dist/index.js",
6
+ "scripts": {
7
+ "start": "node dist/index.js",
8
+ "dev": "ts-node src/index.ts",
9
+ "build": "tsc",
10
+ "build:bundle": "webpack",
11
+ "watch": "tsc --watch"
12
+ },
13
+ "keywords": [
14
+ "rag",
15
+ "flowquery",
16
+ "retrieval-augmented-generation"
17
+ ],
18
+ "author": "",
19
+ "license": "MIT",
20
+ "dependencies": {
21
+ "flowquery": "^1.0.3"
22
+ },
23
+ "devDependencies": {
24
+ "@types/node": "^22.0.0",
25
+ "ts-loader": "^9.5.1",
26
+ "ts-node": "^10.9.2",
27
+ "typescript": "^5.7.2",
28
+ "webpack": "^5.97.1",
29
+ "webpack-cli": "^6.0.1"
30
+ }
31
+ }
@@ -0,0 +1,20 @@
1
+ import { FlowQuery } from 'flowquery';
2
+
3
+ /**
4
+ * RAG (Retrieval Augmented Generation) loop using FlowQuery.
5
+ *
6
+ * This is a starter template - customize it for your RAG implementation.
7
+ */
8
+ async function main() {
9
+ // Example: Run a simple FlowQuery query
10
+ const query = new FlowQuery('WITH 1 AS x RETURN x + 1');
11
+
12
+ try {
13
+ await query.run();
14
+ console.log('Result:', query.results); // [ { expr0: 2 } ]
15
+ } catch (error) {
16
+ console.error('Error running query:', error);
17
+ }
18
+ }
19
+
20
+ main();
@@ -0,0 +1,19 @@
1
+ {
2
+ "compilerOptions": {
3
+ "outDir": "./dist",
4
+ "rootDir": "./src",
5
+ "target": "ES2020",
6
+ "module": "commonjs",
7
+ "moduleResolution": "node",
8
+ "esModuleInterop": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "strict": true,
11
+ "skipLibCheck": true,
12
+ "declaration": true,
13
+ "sourceMap": true,
14
+ "resolveJsonModule": true,
15
+ "types": ["node"]
16
+ },
17
+ "include": ["src/**/*"],
18
+ "exclude": ["node_modules", "dist"]
19
+ }
@@ -0,0 +1,32 @@
1
+ const path = require('path');
2
+
3
+ module.exports = {
4
+ mode: 'production',
5
+ entry: './src/index.ts',
6
+ target: 'node',
7
+ output: {
8
+ filename: 'rag.bundle.js',
9
+ path: path.resolve(__dirname, 'dist'),
10
+ libraryTarget: 'commonjs2'
11
+ },
12
+ resolve: {
13
+ extensions: ['.ts', '.js']
14
+ },
15
+ module: {
16
+ rules: [
17
+ {
18
+ test: /\.ts$/,
19
+ use: 'ts-loader',
20
+ exclude: /node_modules/
21
+ }
22
+ ]
23
+ },
24
+ externals: {
25
+ // Add any externals here if needed
26
+ // For example, if you want to exclude flowquery from the bundle:
27
+ // 'flowquery': 'commonjs flowquery'
28
+ },
29
+ optimization: {
30
+ minimize: true
31
+ }
32
+ };
@@ -0,0 +1 @@
1
+ Example apps using FlowQuery.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "flowquery",
3
- "version": "1.0.2",
3
+ "version": "1.0.5",
4
4
  "description": "A declarative query language for data processing pipelines.",
5
5
  "main": "dist/index.node.js",
6
6
  "types": "dist/index.node.d.ts",
@@ -50,7 +50,7 @@ import Null from "./components/null";
50
50
  * @example
51
51
  * ```typescript
52
52
  * const parser = new Parser();
53
- * const ast = parser.parse("unwind [1, 2, 3, 4, 5] as num return num");
53
+ * const ast = parser.parse("unwind [1, 2, 3, 4] as num return num");
54
54
  * ```
55
55
  */
56
56
  class Parser extends BaseParser {
@@ -1,5 +1,5 @@
1
- import Token from "../../src/tokenization/token";
2
- import Trie from "../../src/tokenization/trie";
1
+ import Token from "./token";
2
+ import Trie from "./trie";
3
3
 
4
4
  /**
5
5
  * Maps string values to tokens using a Trie for efficient lookup.
package/tsconfig.json CHANGED
@@ -9,7 +9,9 @@
9
9
  "forceConsistentCasingInFileNames": true, /* Ensure that casing is correct in imports. */
10
10
  "strict": true,
11
11
  "types": ["node", "jest"],
12
- "sourceMap": true
12
+ "sourceMap": true,
13
+ "declaration": true, /* Generate .d.ts declaration files. */
14
+ "declarationMap": true /* Generate sourcemaps for .d.ts files. */
13
15
  },
14
16
  "include": ["src"]
15
17
  }
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes