@lowgular/code-graph 0.0.1 → 0.1.1

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 (179) hide show
  1. package/bin/cli.js +10 -0
  2. package/code-graph-v2/code.graph.js +37 -0
  3. package/code-graph-v2/config-from-query.js +131 -0
  4. package/code-graph-v2/extractors/extractor.js +27 -0
  5. package/code-graph-v2/extractors/index.js +1 -0
  6. package/code-graph-v2/graph-builder/code-graph.builder.js +49 -0
  7. package/code-graph-v2/graph-builder/index.js +1 -0
  8. package/code-graph-v2/graph-builder/node.processor.js +22 -0
  9. package/{libs/cli/code-graph/src/lib/v2 → code-graph-v2}/graph-builder/relationship.processor.js +11 -35
  10. package/code-graph-v2/graph-builder/type.processor.js +21 -0
  11. package/code-graph-v2/index.js +4 -0
  12. package/code-graph-v2/tools/build-code-graph.tool.js +19 -0
  13. package/code-graph-v2/utils.js +34 -0
  14. package/codegular/index.js +5 -0
  15. package/codegular/node.js +71 -0
  16. package/codegular/program.js +100 -0
  17. package/{libs/core/codegular/src/lib → codegular}/string.js +6 -53
  18. package/{libs/core/codegular/src/lib → codegular}/type-checker.js +3 -40
  19. package/codegular/type.js +356 -0
  20. package/{libs/core/codegular/src/lib → codegular}/utils.js +50 -62
  21. package/cypher/index.js +1 -0
  22. package/{libs/cli/cypher/src → cypher}/lib/executor/condition-evaluator.js +2 -25
  23. package/cypher/lib/executor/executor.js +60 -0
  24. package/cypher/lib/executor/graph.js +0 -0
  25. package/{libs/cli/cypher/src → cypher}/lib/executor/match-engine.js +4 -27
  26. package/{libs/cli/cypher/src → cypher}/lib/executor/pattern-matcher.js +2 -25
  27. package/{libs/cli/cypher/src → cypher}/lib/executor/relationship-navigator.js +2 -25
  28. package/{libs/cli/cypher/src → cypher}/lib/executor/result-formatter.js +37 -31
  29. package/{libs/cli/cypher/src → cypher}/lib/executor/traverse-engine.js +4 -27
  30. package/cypher/lib/executor/utils.js +14 -0
  31. package/cypher/lib/graph.stub.js +38 -0
  32. package/cypher/lib/index.js +32 -0
  33. package/{libs/cli/cypher/src → cypher}/lib/lexer.js +4 -26
  34. package/{libs/cli/cypher/src → cypher}/lib/parser.js +119 -135
  35. package/{libs/cli/cypher/src → cypher}/lib/validator/query-validator.js +12 -32
  36. package/{libs/cli/cypher/src → cypher}/lib/validator/supported-features.config.js +2 -30
  37. package/{libs/cli/cypher/src → cypher}/lib/validator/unsupported-features.config.js +8 -34
  38. package/cypher-cli.js +41 -0
  39. package/infra/code-graph.js +147 -0
  40. package/main.js +0 -43
  41. package/package.json +25 -7
  42. package/resources-cli.js +75 -0
  43. package/run-cli.js +43 -0
  44. package/apps/code-graph/src/main.js +0 -50
  45. package/libs/cli/code-graph/src/index.js +0 -39
  46. package/libs/cli/code-graph/src/lib/class-declarations/abstractions/service.js +0 -72
  47. package/libs/cli/code-graph/src/lib/class-declarations/abstractions/service.stateful.js +0 -68
  48. package/libs/cli/code-graph/src/lib/class-declarations/class-declarations.doc.js +0 -147
  49. package/libs/cli/code-graph/src/lib/class-declarations/class-declarations.graph.js +0 -55
  50. package/libs/cli/code-graph/src/lib/class-declarations/index.js +0 -27
  51. package/libs/cli/code-graph/src/lib/code.graph.factory.js +0 -63
  52. package/libs/cli/code-graph/src/lib/code.graph.js +0 -62
  53. package/libs/cli/code-graph/src/lib/core/core.js +0 -58
  54. package/libs/cli/code-graph/src/lib/core.js +0 -85
  55. package/libs/cli/code-graph/src/lib/decorators/index.js +0 -36
  56. package/libs/cli/code-graph/src/lib/docs/index.js +0 -21
  57. package/libs/cli/code-graph/src/lib/docs/specs.js +0 -36
  58. package/libs/cli/code-graph/src/lib/expressions/call-expressions.graph.js +0 -28
  59. package/libs/cli/code-graph/src/lib/fixtures/reactive-event-bus/src/app/examples.event-bus.js +0 -53
  60. package/libs/cli/code-graph/src/lib/method-declarations/index.js +0 -23
  61. package/libs/cli/code-graph/src/lib/method-declarations/method-declarations.doc.js +0 -106
  62. package/libs/cli/code-graph/src/lib/method-declarations/method-declarations.graph.js +0 -56
  63. package/libs/cli/code-graph/src/lib/parameters/index.js +0 -42
  64. package/libs/cli/code-graph/src/lib/property-declarations/abstractions/reactive-state.evals.js +0 -139
  65. package/libs/cli/code-graph/src/lib/property-declarations/abstractions/reactive-state.js +0 -104
  66. package/libs/cli/code-graph/src/lib/property-declarations/index.js +0 -25
  67. package/libs/cli/code-graph/src/lib/property-declarations/property-declarations.doc.js +0 -74
  68. package/libs/cli/code-graph/src/lib/property-declarations/property-declarations.graph.js +0 -43
  69. package/libs/cli/code-graph/src/lib/tools/index.js +0 -34
  70. package/libs/cli/code-graph/src/lib/tools/match-code-graph.tool.js +0 -64
  71. package/libs/cli/code-graph/src/lib/types/index.js +0 -99
  72. package/libs/cli/code-graph/src/lib/v2/extractors/extractor.doc.js +0 -345
  73. package/libs/cli/code-graph/src/lib/v2/extractors/extractor.js +0 -52
  74. package/libs/cli/code-graph/src/lib/v2/extractors/index.js +0 -23
  75. package/libs/cli/code-graph/src/lib/v2/graph-builder/code-graph.builder.js +0 -76
  76. package/libs/cli/code-graph/src/lib/v2/graph-builder/index.js +0 -21
  77. package/libs/cli/code-graph/src/lib/v2/graph-builder/node.processor.js +0 -48
  78. package/libs/cli/code-graph/src/lib/v2/graph-builder/type.processor.js +0 -45
  79. package/libs/cli/code-graph/src/lib/v2/index.js +0 -37
  80. package/libs/cli/code-graph/src/lib/v2/tools/build-code-graph.doc.js +0 -220
  81. package/libs/cli/code-graph/src/lib/v2/tools/build-code-graph.tool.js +0 -42
  82. package/libs/cli/cypher/src/index.js +0 -25
  83. package/libs/cli/cypher/src/lib/docs/features/advanced-optional-match.feature.js +0 -277
  84. package/libs/cli/cypher/src/lib/docs/features/anonymous-relationship.feature.js +0 -69
  85. package/libs/cli/cypher/src/lib/docs/features/anonymous-variable-length.feature.js +0 -105
  86. package/libs/cli/cypher/src/lib/docs/features/basic-filtering.feature.js +0 -70
  87. package/libs/cli/cypher/src/lib/docs/features/basic-optional-match.feature.js +0 -99
  88. package/libs/cli/cypher/src/lib/docs/features/basic-relationship.feature.js +0 -125
  89. package/libs/cli/cypher/src/lib/docs/features/index.js +0 -51
  90. package/libs/cli/cypher/src/lib/docs/features/limit.feature.js +0 -50
  91. package/libs/cli/cypher/src/lib/docs/features/match-nodes.feature.js +0 -106
  92. package/libs/cli/cypher/src/lib/docs/features/multiple-relationship-types.feature.js +0 -105
  93. package/libs/cli/cypher/src/lib/docs/features/order-by.feature.js +0 -143
  94. package/libs/cli/cypher/src/lib/docs/features/property-matching.feature.js +0 -152
  95. package/libs/cli/cypher/src/lib/docs/features/relationship-without-variable.feature.js +0 -48
  96. package/libs/cli/cypher/src/lib/docs/features/return-statement.feature.js +0 -65
  97. package/libs/cli/cypher/src/lib/docs/features/unidirected-relationship.feature.js +0 -82
  98. package/libs/cli/cypher/src/lib/docs/features/variable-length-path.feature.js +0 -136
  99. package/libs/cli/cypher/src/lib/docs/features/where-conditional.feature.js +0 -187
  100. package/libs/cli/cypher/src/lib/docs/features/where-operators.feature.js +0 -302
  101. package/libs/cli/cypher/src/lib/docs/prompts.js +0 -36
  102. package/libs/cli/cypher/src/lib/docs/specs.js +0 -181
  103. package/libs/cli/cypher/src/lib/executor/executor.js +0 -83
  104. package/libs/cli/cypher/src/lib/executor/graph.js +0 -15
  105. package/libs/cli/cypher/src/lib/executor/utils.js +0 -37
  106. package/libs/cli/cypher/src/lib/graph.stub.js +0 -63
  107. package/libs/cli/cypher/src/lib/index.js +0 -74
  108. package/libs/cli/shared/src/index.js +0 -53
  109. package/libs/cli/shared/src/lib/admin-token.js +0 -121
  110. package/libs/cli/shared/src/lib/config.js +0 -49
  111. package/libs/cli/shared/src/lib/consts.js +0 -57
  112. package/libs/cli/shared/src/lib/core.js +0 -46
  113. package/libs/cli/shared/src/lib/infrastructure/cli.js +0 -47
  114. package/libs/cli/shared/src/lib/infrastructure/config.js +0 -47
  115. package/libs/cli/shared/src/lib/infrastructure/config.reporitory.js +0 -51
  116. package/libs/cli/shared/src/lib/infrastructure/formatters/console-formatter.js +0 -96
  117. package/libs/cli/shared/src/lib/infrastructure/formatters/index.js +0 -41
  118. package/libs/cli/shared/src/lib/infrastructure/formatters/json-formatter.js +0 -64
  119. package/libs/cli/shared/src/lib/infrastructure/formatters/markdown-formatter.js +0 -120
  120. package/libs/cli/shared/src/lib/infrastructure/formatters/types.js +0 -15
  121. package/libs/cli/shared/src/lib/infrastructure/formatters/utils.js +0 -72
  122. package/libs/cli/shared/src/lib/infrastructure/git.js +0 -147
  123. package/libs/cli/shared/src/lib/infrastructure/http.js +0 -257
  124. package/libs/cli/shared/src/lib/infrastructure/markdown.js +0 -95
  125. package/libs/cli/shared/src/lib/infrastructure/transformers/embeddings.js +0 -88
  126. package/libs/cli/shared/src/lib/infrastructure/transformers/index.js +0 -25
  127. package/libs/cli/shared/src/lib/infrastructure/transformers/rag-eval.js +0 -154
  128. package/libs/cli/shared/src/lib/infrastructure/transformers/similarity.js +0 -210
  129. package/libs/cli/shared/src/lib/infrastructure/workspace.js +0 -297
  130. package/libs/cli/shared/src/lib/infrastructure/yaml.js +0 -237
  131. package/libs/cli/shared/src/lib/lowgular.config.js +0 -120
  132. package/libs/cli/shared/src/lib/token.js +0 -135
  133. package/libs/cli/shared/src/lib/utils/solution.util.js +0 -35
  134. package/libs/cli/shared/src/lib/utils/utils.js +0 -89
  135. package/libs/cli/typescript/src/index.js +0 -21
  136. package/libs/cli/typescript/src/lib/base/index.js +0 -23
  137. package/libs/cli/typescript/src/lib/base/nameable.js +0 -34
  138. package/libs/cli/typescript/src/lib/base/nodeable.js +0 -36
  139. package/libs/cli/typescript/src/lib/class.implementation.js +0 -52
  140. package/libs/cli/typescript/src/lib/core/declaration.registry.js +0 -107
  141. package/libs/cli/typescript/src/lib/core/design-pattern.js +0 -55
  142. package/libs/cli/typescript/src/lib/core/index.js +0 -35
  143. package/libs/cli/typescript/src/lib/core/navigable-declaration.js +0 -69
  144. package/libs/cli/typescript/src/lib/core/program-context.js +0 -71
  145. package/libs/cli/typescript/src/lib/core/syntax-kind.utils.js +0 -40
  146. package/libs/cli/typescript/src/lib/core/type.js +0 -374
  147. package/libs/cli/typescript/src/lib/declaration.abstraction.js +0 -90
  148. package/libs/cli/typescript/src/lib/decorator.implementation.js +0 -35
  149. package/libs/cli/typescript/src/lib/enum.implementation.js +0 -35
  150. package/libs/cli/typescript/src/lib/function-declaration.implementation.js +0 -35
  151. package/libs/cli/typescript/src/lib/index.js +0 -57
  152. package/libs/cli/typescript/src/lib/interface.implementation.js +0 -51
  153. package/libs/cli/typescript/src/lib/members/method-abstraction.resolver.js +0 -90
  154. package/libs/cli/typescript/src/lib/members/method-declaration.implementation.js +0 -44
  155. package/libs/cli/typescript/src/lib/members/method-signature.implementation.js +0 -46
  156. package/libs/cli/typescript/src/lib/members/method.util.js +0 -32
  157. package/libs/cli/typescript/src/lib/members/parameter.implementation.js +0 -38
  158. package/libs/cli/typescript/src/lib/members/property-declaration.implementation.js +0 -64
  159. package/libs/cli/typescript/src/lib/members/property-signature.implementation.js +0 -34
  160. package/libs/cli/typescript/src/lib/members/property.util.js +0 -61
  161. package/libs/cli/typescript/src/lib/members/statements/expressions/binary-expression.implementation.js +0 -42
  162. package/libs/cli/typescript/src/lib/members/statements/expressions/call-expression.implementation.js +0 -114
  163. package/libs/cli/typescript/src/lib/members/statements/expressions/expression.abstraction.js +0 -188
  164. package/libs/cli/typescript/src/lib/members/statements/expressions/property-access-expression.implementation.js +0 -35
  165. package/libs/cli/typescript/src/lib/members/statements/expressions/unary-expression.implementation.js +0 -51
  166. package/libs/cli/typescript/src/lib/members/statements/statement.implementation.js +0 -49
  167. package/libs/cli/typescript/src/lib/members/statements/utils.js +0 -51
  168. package/libs/cli/typescript/src/lib/plugins/built-in.plugin.js +0 -258
  169. package/libs/cli/typescript/src/lib/plugins/plugin.interface.js +0 -15
  170. package/libs/cli/typescript/src/lib/plugins/rxjs.plugin.js +0 -228
  171. package/libs/cli/typescript/src/lib/plugins/signal.plugin.js +0 -126
  172. package/libs/cli/typescript/src/lib/plugins/stubs.js +0 -66
  173. package/libs/cli/typescript/src/lib/type-alias.implementation.js +0 -72
  174. package/libs/cli/typescript/src/lib/utils.js +0 -39
  175. package/libs/cli/typescript/src/lib/variable-declaration.implementation.js +0 -35
  176. package/libs/core/codegular/src/index.js +0 -21
  177. package/libs/core/codegular/src/lib/index.js +0 -29
  178. package/libs/core/codegular/src/lib/node.js +0 -112
  179. package/libs/core/codegular/src/lib/program.js +0 -92
@@ -1,26 +1,4 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var parser_exports = {};
19
- __export(parser_exports, {
20
- Parser: () => Parser
21
- });
22
- module.exports = __toCommonJS(parser_exports);
23
- var import_lexer = require("./lexer");
1
+ import { TokenType } from "./lexer.js";
24
2
  class Parser {
25
3
  constructor(tokens) {
26
4
  this.tokens = [];
@@ -57,29 +35,29 @@ class Parser {
57
35
  * Note: Cypher uses colon (:) for properties in node patterns, not equals (=)
58
36
  */
59
37
  parseProperties() {
60
- this.expect(import_lexer.TokenType.LBRACE);
38
+ this.expect(TokenType.LBRACE);
61
39
  const properties = {};
62
- if (this.current().type === import_lexer.TokenType.RBRACE) {
40
+ if (this.current().type === TokenType.RBRACE) {
63
41
  this.advance();
64
42
  return properties;
65
43
  }
66
44
  while (true) {
67
- const key = this.expect(import_lexer.TokenType.IDENTIFIER).value;
68
- this.expect(import_lexer.TokenType.LABEL);
45
+ const key = this.expect(TokenType.IDENTIFIER).value;
46
+ this.expect(TokenType.LABEL);
69
47
  let value;
70
- if (this.current().type === import_lexer.TokenType.LBRACKET) {
48
+ if (this.current().type === TokenType.LBRACKET) {
71
49
  value = this.parseArrayLiteral();
72
- } else if (this.current().type === import_lexer.TokenType.STRING) {
50
+ } else if (this.current().type === TokenType.STRING) {
73
51
  value = this.advance().value;
74
- } else if (this.current().type === import_lexer.TokenType.NUMBER) {
52
+ } else if (this.current().type === TokenType.NUMBER) {
75
53
  value = parseFloat(this.advance().value);
76
- } else if (this.current().type === import_lexer.TokenType.TRUE) {
54
+ } else if (this.current().type === TokenType.TRUE) {
77
55
  value = true;
78
56
  this.advance();
79
- } else if (this.current().type === import_lexer.TokenType.FALSE) {
57
+ } else if (this.current().type === TokenType.FALSE) {
80
58
  value = false;
81
59
  this.advance();
82
- } else if (this.current().type === import_lexer.TokenType.IDENTIFIER) {
60
+ } else if (this.current().type === TokenType.IDENTIFIER) {
83
61
  value = this.advance().value;
84
62
  } else {
85
63
  throw new Error(
@@ -87,11 +65,11 @@ class Parser {
87
65
  );
88
66
  }
89
67
  properties[key] = value;
90
- if (this.current().type === import_lexer.TokenType.RBRACE) {
68
+ if (this.current().type === TokenType.RBRACE) {
91
69
  this.advance();
92
70
  break;
93
71
  }
94
- this.expect(import_lexer.TokenType.COMMA);
72
+ this.expect(TokenType.COMMA);
95
73
  }
96
74
  return properties;
97
75
  }
@@ -99,30 +77,30 @@ class Parser {
99
77
  * Parse a node pattern: (var:Label {prop: value}) or (:Label {prop: value})
100
78
  */
101
79
  parseNodePattern() {
102
- this.expect(import_lexer.TokenType.LPAREN);
80
+ this.expect(TokenType.LPAREN);
103
81
  const pattern = {
104
82
  type: "NodePattern",
105
83
  labels: []
106
84
  };
107
- if (this.current().type === import_lexer.TokenType.IDENTIFIER) {
85
+ if (this.current().type === TokenType.IDENTIFIER) {
108
86
  const nextToken = this.peek();
109
- if (nextToken.type === import_lexer.TokenType.LABEL || nextToken.type === import_lexer.TokenType.LBRACE || nextToken.type === import_lexer.TokenType.RPAREN) {
87
+ if (nextToken.type === TokenType.LABEL || nextToken.type === TokenType.LBRACE || nextToken.type === TokenType.RPAREN) {
110
88
  pattern.variable = this.advance().value;
111
89
  }
112
90
  }
113
- if (this.current().type === import_lexer.TokenType.LABEL) {
91
+ if (this.current().type === TokenType.LABEL) {
114
92
  this.advance();
115
- if (this.current().type !== import_lexer.TokenType.IDENTIFIER) {
93
+ if (this.current().type !== TokenType.IDENTIFIER) {
116
94
  throw new Error(
117
95
  `Expected identifier after :, got ${this.current().type}`
118
96
  );
119
97
  }
120
98
  pattern.labels.push(this.advance().value);
121
- if (this.current().type === import_lexer.TokenType.LABEL) {
99
+ if (this.current().type === TokenType.LABEL) {
122
100
  pattern.labelOperator = "AND";
123
- while (this.current().type === import_lexer.TokenType.LABEL) {
101
+ while (this.current().type === TokenType.LABEL) {
124
102
  this.advance();
125
- if (this.current().type === import_lexer.TokenType.IDENTIFIER) {
103
+ if (this.current().type === TokenType.IDENTIFIER) {
126
104
  pattern.labels.push(this.advance().value);
127
105
  } else {
128
106
  throw new Error(
@@ -130,11 +108,11 @@ class Parser {
130
108
  );
131
109
  }
132
110
  }
133
- } else if (this.current().type === import_lexer.TokenType.PIPE) {
111
+ } else if (this.current().type === TokenType.PIPE) {
134
112
  pattern.labelOperator = "OR";
135
- while (this.current().type === import_lexer.TokenType.PIPE) {
113
+ while (this.current().type === TokenType.PIPE) {
136
114
  this.advance();
137
- if (this.current().type === import_lexer.TokenType.IDENTIFIER) {
115
+ if (this.current().type === TokenType.IDENTIFIER) {
138
116
  pattern.labels.push(this.advance().value);
139
117
  } else {
140
118
  throw new Error(
@@ -146,10 +124,10 @@ class Parser {
146
124
  pattern.labelOperator = "AND";
147
125
  }
148
126
  }
149
- if (this.current().type === import_lexer.TokenType.LBRACE) {
127
+ if (this.current().type === TokenType.LBRACE) {
150
128
  pattern.properties = this.parseProperties();
151
129
  }
152
- this.expect(import_lexer.TokenType.RPAREN);
130
+ this.expect(TokenType.RPAREN);
153
131
  return pattern;
154
132
  }
155
133
  /**
@@ -160,49 +138,49 @@ class Parser {
160
138
  type: "RelationshipPattern",
161
139
  direction: "outgoing"
162
140
  };
163
- if (this.current().type === import_lexer.TokenType.ARROW && this.current().value === "<-") {
141
+ if (this.current().type === TokenType.ARROW && this.current().value === "<-") {
164
142
  relationship.direction = "incoming";
165
143
  this.advance();
166
144
  } else {
167
- this.expect(import_lexer.TokenType.DASH);
145
+ this.expect(TokenType.DASH);
168
146
  }
169
- if (this.current().type === import_lexer.TokenType.LBRACKET) {
147
+ if (this.current().type === TokenType.LBRACKET) {
170
148
  this.advance();
171
- if (this.current().type === import_lexer.TokenType.IDENTIFIER) {
149
+ if (this.current().type === TokenType.IDENTIFIER) {
172
150
  const nextToken = this.peek();
173
- if (nextToken.type === import_lexer.TokenType.LABEL || nextToken.type === import_lexer.TokenType.ASTERISK) {
151
+ if (nextToken.type === TokenType.LABEL || nextToken.type === TokenType.ASTERISK) {
174
152
  relationship.variable = this.advance().value;
175
153
  }
176
154
  }
177
- if (this.current().type === import_lexer.TokenType.ASTERISK) {
155
+ if (this.current().type === TokenType.ASTERISK) {
178
156
  this.advance();
179
157
  relationship.variableLength = true;
180
158
  relationship.minLength = 0;
181
159
  relationship.maxLength = void 0;
182
- } else if (this.current().type === import_lexer.TokenType.LABEL) {
160
+ } else if (this.current().type === TokenType.LABEL) {
183
161
  this.advance();
184
162
  const edgeTypes = [];
185
- edgeTypes.push(this.expect(import_lexer.TokenType.IDENTIFIER).value);
186
- while (this.current().type === import_lexer.TokenType.PIPE) {
163
+ edgeTypes.push(this.expect(TokenType.IDENTIFIER).value);
164
+ while (this.current().type === TokenType.PIPE) {
187
165
  this.advance();
188
- edgeTypes.push(this.expect(import_lexer.TokenType.IDENTIFIER).value);
166
+ edgeTypes.push(this.expect(TokenType.IDENTIFIER).value);
189
167
  }
190
168
  relationship.edgeType = edgeTypes.length === 1 ? edgeTypes[0] : edgeTypes;
191
- if (this.current().type === import_lexer.TokenType.ASTERISK) {
169
+ if (this.current().type === TokenType.ASTERISK) {
192
170
  this.advance();
193
171
  relationship.variableLength = true;
194
172
  relationship.minLength = 0;
195
173
  relationship.maxLength = void 0;
196
174
  }
197
175
  }
198
- this.expect(import_lexer.TokenType.RBRACKET);
176
+ this.expect(TokenType.RBRACKET);
199
177
  }
200
178
  if (relationship.direction === "incoming") {
201
- this.expect(import_lexer.TokenType.DASH);
179
+ this.expect(TokenType.DASH);
202
180
  } else {
203
- if (this.current().type === import_lexer.TokenType.ARROW && this.current().value === "->") {
181
+ if (this.current().type === TokenType.ARROW && this.current().value === "->") {
204
182
  this.advance();
205
- } else if (this.current().type === import_lexer.TokenType.DASH) {
183
+ } else if (this.current().type === TokenType.DASH) {
206
184
  relationship.direction = "both";
207
185
  this.advance();
208
186
  }
@@ -213,11 +191,11 @@ class Parser {
213
191
  * Parse MATCH clause (supports OPTIONAL MATCH)
214
192
  */
215
193
  parseMatch() {
216
- const isOptional = this.isKeyword(import_lexer.TokenType.OPTIONAL);
194
+ const isOptional = this.isKeyword(TokenType.OPTIONAL);
217
195
  if (isOptional) {
218
196
  this.advance();
219
197
  }
220
- this.expect(import_lexer.TokenType.MATCH);
198
+ this.expect(TokenType.MATCH);
221
199
  const firstPattern = this.parsePatternChain();
222
200
  const matchClause = {
223
201
  type: "MatchClause",
@@ -225,7 +203,7 @@ class Parser {
225
203
  relationships: firstPattern.relationships,
226
204
  additionalMatches: []
227
205
  };
228
- while (this.current().type === import_lexer.TokenType.COMMA) {
206
+ while (this.current().type === TokenType.COMMA) {
229
207
  this.advance();
230
208
  const additionalPattern = this.parsePatternChain();
231
209
  matchClause.additionalMatches.push(additionalPattern);
@@ -253,7 +231,7 @@ class Parser {
253
231
  const patterns = [];
254
232
  const relationships = [];
255
233
  patterns.push(this.parseNodePattern());
256
- while (this.current().type === import_lexer.TokenType.DASH || this.current().type === import_lexer.TokenType.ARROW) {
234
+ while (this.current().type === TokenType.DASH || this.current().type === TokenType.ARROW) {
257
235
  relationships.push(this.parseRelationship());
258
236
  patterns.push(this.parseNodePattern());
259
237
  }
@@ -269,68 +247,68 @@ class Parser {
269
247
  * Note: Flat properties only (no nesting, like Neo4j Cypher)
270
248
  */
271
249
  parseWhere() {
272
- this.expect(import_lexer.TokenType.WHERE);
250
+ this.expect(TokenType.WHERE);
273
251
  const conditions = [];
274
252
  let logic;
275
253
  while (true) {
276
- const variable = this.expect(import_lexer.TokenType.IDENTIFIER).value;
254
+ const variable = this.expect(TokenType.IDENTIFIER).value;
277
255
  let property;
278
- if (this.current().type === import_lexer.TokenType.DOT) {
256
+ if (this.current().type === TokenType.DOT) {
279
257
  this.advance();
280
- property = this.expect(import_lexer.TokenType.IDENTIFIER).value;
258
+ property = this.expect(TokenType.IDENTIFIER).value;
281
259
  }
282
260
  let operator = "=";
283
- if (this.current().type === import_lexer.TokenType.EQUALS) {
261
+ if (this.current().type === TokenType.EQUALS) {
284
262
  operator = "=";
285
263
  this.advance();
286
- } else if (this.current().type === import_lexer.TokenType.NOT_EQUALS) {
264
+ } else if (this.current().type === TokenType.NOT_EQUALS) {
287
265
  operator = "!=";
288
266
  this.advance();
289
- } else if (this.current().type === import_lexer.TokenType.GT) {
267
+ } else if (this.current().type === TokenType.GT) {
290
268
  operator = ">";
291
269
  this.advance();
292
- } else if (this.current().type === import_lexer.TokenType.LT) {
270
+ } else if (this.current().type === TokenType.LT) {
293
271
  operator = "<";
294
272
  this.advance();
295
- } else if (this.current().type === import_lexer.TokenType.GTE) {
273
+ } else if (this.current().type === TokenType.GTE) {
296
274
  operator = ">=";
297
275
  this.advance();
298
- } else if (this.current().type === import_lexer.TokenType.LTE) {
276
+ } else if (this.current().type === TokenType.LTE) {
299
277
  operator = "<=";
300
278
  this.advance();
301
- } else if (this.current().type === import_lexer.TokenType.NOT) {
279
+ } else if (this.current().type === TokenType.NOT) {
302
280
  this.advance();
303
- this.expect(import_lexer.TokenType.IN);
281
+ this.expect(TokenType.IN);
304
282
  operator = "NOT IN";
305
- } else if (this.current().type === import_lexer.TokenType.IN) {
283
+ } else if (this.current().type === TokenType.IN) {
306
284
  this.advance();
307
285
  operator = "IN";
308
- } else if (this.current().type === import_lexer.TokenType.IS) {
286
+ } else if (this.current().type === TokenType.IS) {
309
287
  this.advance();
310
- if (this.isKeyword(import_lexer.TokenType.NULL)) {
288
+ if (this.isKeyword(TokenType.NULL)) {
311
289
  this.advance();
312
290
  operator = "IS NULL";
313
- } else if (this.isKeyword(import_lexer.TokenType.NOT)) {
291
+ } else if (this.isKeyword(TokenType.NOT)) {
314
292
  this.advance();
315
- this.expect(import_lexer.TokenType.NULL);
293
+ this.expect(TokenType.NULL);
316
294
  operator = "IS NOT NULL";
317
295
  } else {
318
296
  throw new Error(
319
297
  `Expected NULL or NOT NULL after IS at position ${this.current().position}`
320
298
  );
321
299
  }
322
- } else if (this.current().type === import_lexer.TokenType.STARTS) {
300
+ } else if (this.current().type === TokenType.STARTS) {
323
301
  this.advance();
324
- this.expect(import_lexer.TokenType.WITH);
302
+ this.expect(TokenType.WITH);
325
303
  operator = "STARTS WITH";
326
- } else if (this.current().type === import_lexer.TokenType.ENDS) {
304
+ } else if (this.current().type === TokenType.ENDS) {
327
305
  this.advance();
328
- this.expect(import_lexer.TokenType.WITH);
306
+ this.expect(TokenType.WITH);
329
307
  operator = "ENDS WITH";
330
- } else if (this.current().type === import_lexer.TokenType.CONTAINS) {
308
+ } else if (this.current().type === TokenType.CONTAINS) {
331
309
  operator = "CONTAINS";
332
310
  this.advance();
333
- } else if (this.current().type === import_lexer.TokenType.REGEX_MATCH) {
311
+ } else if (this.current().type === TokenType.REGEX_MATCH) {
334
312
  operator = "=~";
335
313
  this.advance();
336
314
  } else {
@@ -341,26 +319,26 @@ class Parser {
341
319
  let value = null;
342
320
  if (operator === "IS NULL" || operator === "IS NOT NULL") {
343
321
  } else if (operator === "STARTS WITH" || operator === "ENDS WITH" || operator === "CONTAINS" || operator === "=~") {
344
- if (this.current().type === import_lexer.TokenType.STRING) {
322
+ if (this.current().type === TokenType.STRING) {
345
323
  value = this.advance().value;
346
324
  } else {
347
325
  throw new Error(
348
326
  `String matching operators (${operator}) require a string value at position ${this.current().position}`
349
327
  );
350
328
  }
351
- } else if (this.current().type === import_lexer.TokenType.LBRACKET) {
329
+ } else if (this.current().type === TokenType.LBRACKET) {
352
330
  value = this.parseArrayLiteral();
353
- } else if (this.current().type === import_lexer.TokenType.STRING) {
331
+ } else if (this.current().type === TokenType.STRING) {
354
332
  value = this.advance().value;
355
- } else if (this.current().type === import_lexer.TokenType.NUMBER) {
333
+ } else if (this.current().type === TokenType.NUMBER) {
356
334
  value = parseFloat(this.advance().value);
357
- } else if (this.current().type === import_lexer.TokenType.TRUE) {
335
+ } else if (this.current().type === TokenType.TRUE) {
358
336
  value = true;
359
337
  this.advance();
360
- } else if (this.current().type === import_lexer.TokenType.FALSE) {
338
+ } else if (this.current().type === TokenType.FALSE) {
361
339
  value = false;
362
340
  this.advance();
363
- } else if (this.current().type === import_lexer.TokenType.IDENTIFIER) {
341
+ } else if (this.current().type === TokenType.IDENTIFIER) {
364
342
  value = this.advance().value;
365
343
  } else {
366
344
  throw new Error(
@@ -368,7 +346,7 @@ class Parser {
368
346
  );
369
347
  }
370
348
  conditions.push({ variable, property, operator, value });
371
- if (this.isKeyword(import_lexer.TokenType.AND)) {
349
+ if (this.isKeyword(TokenType.AND)) {
372
350
  if (logic === void 0) {
373
351
  logic = "AND";
374
352
  } else if (logic !== "AND") {
@@ -376,7 +354,7 @@ class Parser {
376
354
  }
377
355
  this.advance();
378
356
  continue;
379
- } else if (this.isKeyword(import_lexer.TokenType.OR)) {
357
+ } else if (this.isKeyword(TokenType.OR)) {
380
358
  if (logic === void 0) {
381
359
  logic = "OR";
382
360
  } else if (logic !== "OR") {
@@ -397,33 +375,33 @@ class Parser {
397
375
  * Parse array literal: [value1, value2, ...]
398
376
  */
399
377
  parseArrayLiteral() {
400
- this.expect(import_lexer.TokenType.LBRACKET);
378
+ this.expect(TokenType.LBRACKET);
401
379
  const array = [];
402
- if (this.current().type === import_lexer.TokenType.RBRACKET) {
380
+ if (this.current().type === TokenType.RBRACKET) {
403
381
  this.advance();
404
382
  return array;
405
383
  }
406
384
  while (true) {
407
- if (this.current().type === import_lexer.TokenType.STRING) {
385
+ if (this.current().type === TokenType.STRING) {
408
386
  array.push(this.advance().value);
409
- } else if (this.current().type === import_lexer.TokenType.NUMBER) {
387
+ } else if (this.current().type === TokenType.NUMBER) {
410
388
  array.push(parseFloat(this.advance().value));
411
- } else if (this.current().type === import_lexer.TokenType.TRUE) {
389
+ } else if (this.current().type === TokenType.TRUE) {
412
390
  array.push(true);
413
391
  this.advance();
414
- } else if (this.current().type === import_lexer.TokenType.FALSE) {
392
+ } else if (this.current().type === TokenType.FALSE) {
415
393
  array.push(false);
416
394
  this.advance();
417
- } else if (this.current().type === import_lexer.TokenType.IDENTIFIER) {
395
+ } else if (this.current().type === TokenType.IDENTIFIER) {
418
396
  array.push(this.advance().value);
419
397
  } else {
420
398
  throw new Error(
421
399
  `Unexpected token type in array literal: ${this.current().type}`
422
400
  );
423
401
  }
424
- if (this.current().type === import_lexer.TokenType.COMMA) {
402
+ if (this.current().type === TokenType.COMMA) {
425
403
  this.advance();
426
- } else if (this.current().type === import_lexer.TokenType.RBRACKET) {
404
+ } else if (this.current().type === TokenType.RBRACKET) {
427
405
  this.advance();
428
406
  break;
429
407
  } else {
@@ -436,15 +414,20 @@ class Parser {
436
414
  }
437
415
  /**
438
416
  * Parse RETURN clause
439
- * Supports: RETURN *, RETURN var1, var2, RETURN var AS alias, LIMIT n
417
+ * Supports: RETURN *, RETURN DISTINCT, RETURN var1, var2, RETURN var AS alias, LIMIT n
440
418
  */
441
419
  parseReturn() {
442
- this.expect(import_lexer.TokenType.RETURN);
443
- if (this.current().type === import_lexer.TokenType.ASTERISK) {
420
+ this.expect(TokenType.RETURN);
421
+ const distinct = this.isKeyword(TokenType.DISTINCT);
422
+ if (distinct) {
423
+ this.advance();
424
+ }
425
+ if (this.current().type === TokenType.ASTERISK) {
444
426
  this.advance();
445
427
  const limit2 = this.parseOptionalLimit();
446
428
  return {
447
429
  type: "ReturnClause",
430
+ distinct,
448
431
  returnAll: true,
449
432
  items: [],
450
433
  limit: limit2
@@ -452,14 +435,14 @@ class Parser {
452
435
  }
453
436
  const items = [];
454
437
  while (true) {
455
- const expression = this.expect(import_lexer.TokenType.IDENTIFIER).value;
438
+ const expression = this.expect(TokenType.IDENTIFIER).value;
456
439
  let alias;
457
- if (this.isKeyword(import_lexer.TokenType.AS)) {
440
+ if (this.isKeyword(TokenType.AS)) {
458
441
  this.advance();
459
- alias = this.expect(import_lexer.TokenType.IDENTIFIER).value;
442
+ alias = this.expect(TokenType.IDENTIFIER).value;
460
443
  }
461
444
  items.push({ expression, alias });
462
- if (this.current().type === import_lexer.TokenType.COMMA) {
445
+ if (this.current().type === TokenType.COMMA) {
463
446
  this.advance();
464
447
  continue;
465
448
  }
@@ -468,6 +451,7 @@ class Parser {
468
451
  const limit = this.parseOptionalLimit();
469
452
  return {
470
453
  type: "ReturnClause",
454
+ distinct,
471
455
  returnAll: false,
472
456
  items,
473
457
  limit
@@ -478,9 +462,9 @@ class Parser {
478
462
  * Returns the limit number or undefined if not present
479
463
  */
480
464
  parseOptionalLimit() {
481
- if (this.isKeyword(import_lexer.TokenType.LIMIT)) {
465
+ if (this.isKeyword(TokenType.LIMIT)) {
482
466
  this.advance();
483
- const limitToken = this.expect(import_lexer.TokenType.NUMBER);
467
+ const limitToken = this.expect(TokenType.NUMBER);
484
468
  return parseInt(limitToken.value, 10);
485
469
  }
486
470
  return void 0;
@@ -491,26 +475,26 @@ class Parser {
491
475
  * Also supports multiple fields: ORDER BY n.type DESC, n.name ASC
492
476
  */
493
477
  parseOrderBy() {
494
- this.expect(import_lexer.TokenType.ORDER);
495
- this.expect(import_lexer.TokenType.BY);
478
+ this.expect(TokenType.ORDER);
479
+ this.expect(TokenType.BY);
496
480
  const items = [];
497
481
  while (true) {
498
- const variable = this.expect(import_lexer.TokenType.IDENTIFIER).value;
482
+ const variable = this.expect(TokenType.IDENTIFIER).value;
499
483
  let property;
500
- if (this.current().type === import_lexer.TokenType.DOT) {
484
+ if (this.current().type === TokenType.DOT) {
501
485
  this.advance();
502
- property = this.expect(import_lexer.TokenType.IDENTIFIER).value;
486
+ property = this.expect(TokenType.IDENTIFIER).value;
503
487
  }
504
488
  let direction = "ASC";
505
- if (this.isKeyword(import_lexer.TokenType.ASC)) {
489
+ if (this.isKeyword(TokenType.ASC)) {
506
490
  this.advance();
507
491
  direction = "ASC";
508
- } else if (this.isKeyword(import_lexer.TokenType.DESC)) {
492
+ } else if (this.isKeyword(TokenType.DESC)) {
509
493
  this.advance();
510
494
  direction = "DESC";
511
495
  }
512
496
  items.push({ variable, property, direction });
513
- if (this.current().type === import_lexer.TokenType.COMMA) {
497
+ if (this.current().type === TokenType.COMMA) {
514
498
  this.advance();
515
499
  continue;
516
500
  }
@@ -524,9 +508,9 @@ class Parser {
524
508
  */
525
509
  parse() {
526
510
  const statements = [];
527
- while (this.current().type !== import_lexer.TokenType.EOF) {
528
- if (this.isKeyword(import_lexer.TokenType.MATCH) || this.isKeyword(import_lexer.TokenType.OPTIONAL)) {
529
- const isOptional = this.isKeyword(import_lexer.TokenType.OPTIONAL);
511
+ while (this.current().type !== TokenType.EOF) {
512
+ if (this.isKeyword(TokenType.MATCH) || this.isKeyword(TokenType.OPTIONAL)) {
513
+ const isOptional = this.isKeyword(TokenType.OPTIONAL);
530
514
  const matchClause = this.parseMatch();
531
515
  if (matchClause.optionalMatches) {
532
516
  for (const optionalMatch of matchClause.optionalMatches) {
@@ -559,7 +543,7 @@ class Parser {
559
543
  }
560
544
  continue;
561
545
  }
562
- if (this.isKeyword(import_lexer.TokenType.WHERE)) {
546
+ if (this.isKeyword(TokenType.WHERE)) {
563
547
  const whereClause = this.parseWhere();
564
548
  statements.push({
565
549
  type: "WhereStatement",
@@ -568,15 +552,16 @@ class Parser {
568
552
  });
569
553
  continue;
570
554
  }
571
- if (this.isKeyword(import_lexer.TokenType.ORDER)) {
555
+ if (this.isKeyword(TokenType.ORDER)) {
572
556
  const orderByStatement = this.parseOrderBy();
573
557
  statements.push(orderByStatement);
574
558
  continue;
575
559
  }
576
- if (this.isKeyword(import_lexer.TokenType.RETURN)) {
560
+ if (this.isKeyword(TokenType.RETURN)) {
577
561
  const returnClause = this.parseReturn();
578
562
  statements.push({
579
563
  type: "ReturnStatement",
564
+ distinct: returnClause.distinct,
580
565
  returnAll: returnClause.returnAll,
581
566
  items: returnClause.items,
582
567
  limit: returnClause.limit
@@ -585,7 +570,7 @@ class Parser {
585
570
  }
586
571
  break;
587
572
  }
588
- if (this.current().type !== import_lexer.TokenType.EOF) {
573
+ if (this.current().type !== TokenType.EOF) {
589
574
  throw new Error(
590
575
  `Unexpected token: ${this.current().type} at position ${this.current().position}`
591
576
  );
@@ -596,7 +581,6 @@ class Parser {
596
581
  };
597
582
  }
598
583
  }
599
- // Annotate the CommonJS export names for ESM import in node:
600
- 0 && (module.exports = {
584
+ export {
601
585
  Parser
602
- });
586
+ };
@@ -1,33 +1,14 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __export = (target, all) => {
6
- for (var name in all)
7
- __defProp(target, name, { get: all[name], enumerable: true });
8
- };
9
- var __copyProps = (to, from, except, desc) => {
10
- if (from && typeof from === "object" || typeof from === "function") {
11
- for (let key of __getOwnPropNames(from))
12
- if (!__hasOwnProp.call(to, key) && key !== except)
13
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
- }
15
- return to;
16
- };
17
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
18
- var query_validator_exports = {};
19
- __export(query_validator_exports, {
20
- UnsupportedFeatureError: () => UnsupportedFeatureError,
21
- validateQuery: () => validateQuery,
22
- validateQuerySafe: () => validateQuerySafe
23
- });
24
- module.exports = __toCommonJS(query_validator_exports);
25
- var import_unsupported_features = require("./unsupported-features.config");
1
+ import {
2
+ FORBIDDEN_AGGREGATIONS,
3
+ FORBIDDEN_KEYWORDS,
4
+ FORBIDDEN_MODIFIERS,
5
+ FORBIDDEN_PATTERNS
6
+ } from "./unsupported-features.config.js";
26
7
  const UNSUPPORTED_FEATURES = [
27
- ...import_unsupported_features.FORBIDDEN_KEYWORDS,
28
- ...import_unsupported_features.FORBIDDEN_AGGREGATIONS,
29
- ...import_unsupported_features.FORBIDDEN_MODIFIERS,
30
- ...import_unsupported_features.FORBIDDEN_PATTERNS
8
+ ...FORBIDDEN_KEYWORDS,
9
+ ...FORBIDDEN_AGGREGATIONS,
10
+ ...FORBIDDEN_MODIFIERS,
11
+ ...FORBIDDEN_PATTERNS
31
12
  ];
32
13
  class UnsupportedFeatureError extends Error {
33
14
  constructor(feature, query) {
@@ -87,9 +68,8 @@ function validateQuerySafe(query) {
87
68
  throw error;
88
69
  }
89
70
  }
90
- // Annotate the CommonJS export names for ESM import in node:
91
- 0 && (module.exports = {
71
+ export {
92
72
  UnsupportedFeatureError,
93
73
  validateQuery,
94
74
  validateQuerySafe
95
- });
75
+ };