@lowgular/code-graph 0.0.1 → 0.1.2

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 (155) hide show
  1. package/bin/cli.js +2463 -0
  2. package/lib.js +2430 -0
  3. package/package.json +26 -7
  4. package/apps/code-graph/src/main.js +0 -50
  5. package/libs/cli/code-graph/src/index.js +0 -39
  6. package/libs/cli/code-graph/src/lib/class-declarations/abstractions/service.js +0 -72
  7. package/libs/cli/code-graph/src/lib/class-declarations/abstractions/service.stateful.js +0 -68
  8. package/libs/cli/code-graph/src/lib/class-declarations/class-declarations.doc.js +0 -147
  9. package/libs/cli/code-graph/src/lib/class-declarations/class-declarations.graph.js +0 -55
  10. package/libs/cli/code-graph/src/lib/class-declarations/index.js +0 -27
  11. package/libs/cli/code-graph/src/lib/code.graph.factory.js +0 -63
  12. package/libs/cli/code-graph/src/lib/code.graph.js +0 -62
  13. package/libs/cli/code-graph/src/lib/core/core.js +0 -58
  14. package/libs/cli/code-graph/src/lib/core.js +0 -85
  15. package/libs/cli/code-graph/src/lib/decorators/index.js +0 -36
  16. package/libs/cli/code-graph/src/lib/docs/index.js +0 -21
  17. package/libs/cli/code-graph/src/lib/docs/specs.js +0 -36
  18. package/libs/cli/code-graph/src/lib/expressions/call-expressions.graph.js +0 -28
  19. package/libs/cli/code-graph/src/lib/fixtures/reactive-event-bus/src/app/examples.event-bus.js +0 -53
  20. package/libs/cli/code-graph/src/lib/method-declarations/index.js +0 -23
  21. package/libs/cli/code-graph/src/lib/method-declarations/method-declarations.doc.js +0 -106
  22. package/libs/cli/code-graph/src/lib/method-declarations/method-declarations.graph.js +0 -56
  23. package/libs/cli/code-graph/src/lib/parameters/index.js +0 -42
  24. package/libs/cli/code-graph/src/lib/property-declarations/abstractions/reactive-state.evals.js +0 -139
  25. package/libs/cli/code-graph/src/lib/property-declarations/abstractions/reactive-state.js +0 -104
  26. package/libs/cli/code-graph/src/lib/property-declarations/index.js +0 -25
  27. package/libs/cli/code-graph/src/lib/property-declarations/property-declarations.doc.js +0 -74
  28. package/libs/cli/code-graph/src/lib/property-declarations/property-declarations.graph.js +0 -43
  29. package/libs/cli/code-graph/src/lib/tools/index.js +0 -34
  30. package/libs/cli/code-graph/src/lib/tools/match-code-graph.tool.js +0 -64
  31. package/libs/cli/code-graph/src/lib/types/index.js +0 -99
  32. package/libs/cli/code-graph/src/lib/v2/extractors/extractor.doc.js +0 -345
  33. package/libs/cli/code-graph/src/lib/v2/extractors/extractor.js +0 -52
  34. package/libs/cli/code-graph/src/lib/v2/extractors/index.js +0 -23
  35. package/libs/cli/code-graph/src/lib/v2/graph-builder/code-graph.builder.js +0 -76
  36. package/libs/cli/code-graph/src/lib/v2/graph-builder/index.js +0 -21
  37. package/libs/cli/code-graph/src/lib/v2/graph-builder/node.processor.js +0 -48
  38. package/libs/cli/code-graph/src/lib/v2/graph-builder/relationship.processor.js +0 -79
  39. package/libs/cli/code-graph/src/lib/v2/graph-builder/type.processor.js +0 -45
  40. package/libs/cli/code-graph/src/lib/v2/index.js +0 -37
  41. package/libs/cli/code-graph/src/lib/v2/tools/build-code-graph.doc.js +0 -220
  42. package/libs/cli/code-graph/src/lib/v2/tools/build-code-graph.tool.js +0 -42
  43. package/libs/cli/cypher/src/index.js +0 -25
  44. package/libs/cli/cypher/src/lib/docs/features/advanced-optional-match.feature.js +0 -277
  45. package/libs/cli/cypher/src/lib/docs/features/anonymous-relationship.feature.js +0 -69
  46. package/libs/cli/cypher/src/lib/docs/features/anonymous-variable-length.feature.js +0 -105
  47. package/libs/cli/cypher/src/lib/docs/features/basic-filtering.feature.js +0 -70
  48. package/libs/cli/cypher/src/lib/docs/features/basic-optional-match.feature.js +0 -99
  49. package/libs/cli/cypher/src/lib/docs/features/basic-relationship.feature.js +0 -125
  50. package/libs/cli/cypher/src/lib/docs/features/index.js +0 -51
  51. package/libs/cli/cypher/src/lib/docs/features/limit.feature.js +0 -50
  52. package/libs/cli/cypher/src/lib/docs/features/match-nodes.feature.js +0 -106
  53. package/libs/cli/cypher/src/lib/docs/features/multiple-relationship-types.feature.js +0 -105
  54. package/libs/cli/cypher/src/lib/docs/features/order-by.feature.js +0 -143
  55. package/libs/cli/cypher/src/lib/docs/features/property-matching.feature.js +0 -152
  56. package/libs/cli/cypher/src/lib/docs/features/relationship-without-variable.feature.js +0 -48
  57. package/libs/cli/cypher/src/lib/docs/features/return-statement.feature.js +0 -65
  58. package/libs/cli/cypher/src/lib/docs/features/unidirected-relationship.feature.js +0 -82
  59. package/libs/cli/cypher/src/lib/docs/features/variable-length-path.feature.js +0 -136
  60. package/libs/cli/cypher/src/lib/docs/features/where-conditional.feature.js +0 -187
  61. package/libs/cli/cypher/src/lib/docs/features/where-operators.feature.js +0 -302
  62. package/libs/cli/cypher/src/lib/docs/prompts.js +0 -36
  63. package/libs/cli/cypher/src/lib/docs/specs.js +0 -181
  64. package/libs/cli/cypher/src/lib/executor/condition-evaluator.js +0 -158
  65. package/libs/cli/cypher/src/lib/executor/executor.js +0 -83
  66. package/libs/cli/cypher/src/lib/executor/graph.js +0 -15
  67. package/libs/cli/cypher/src/lib/executor/match-engine.js +0 -153
  68. package/libs/cli/cypher/src/lib/executor/pattern-matcher.js +0 -109
  69. package/libs/cli/cypher/src/lib/executor/relationship-navigator.js +0 -64
  70. package/libs/cli/cypher/src/lib/executor/result-formatter.js +0 -143
  71. package/libs/cli/cypher/src/lib/executor/traverse-engine.js +0 -164
  72. package/libs/cli/cypher/src/lib/executor/utils.js +0 -37
  73. package/libs/cli/cypher/src/lib/graph.stub.js +0 -63
  74. package/libs/cli/cypher/src/lib/index.js +0 -74
  75. package/libs/cli/cypher/src/lib/lexer.js +0 -398
  76. package/libs/cli/cypher/src/lib/parser.js +0 -602
  77. package/libs/cli/cypher/src/lib/validator/query-validator.js +0 -95
  78. package/libs/cli/cypher/src/lib/validator/supported-features.config.js +0 -111
  79. package/libs/cli/cypher/src/lib/validator/unsupported-features.config.js +0 -150
  80. package/libs/cli/shared/src/index.js +0 -53
  81. package/libs/cli/shared/src/lib/admin-token.js +0 -121
  82. package/libs/cli/shared/src/lib/config.js +0 -49
  83. package/libs/cli/shared/src/lib/consts.js +0 -57
  84. package/libs/cli/shared/src/lib/core.js +0 -46
  85. package/libs/cli/shared/src/lib/infrastructure/cli.js +0 -47
  86. package/libs/cli/shared/src/lib/infrastructure/config.js +0 -47
  87. package/libs/cli/shared/src/lib/infrastructure/config.reporitory.js +0 -51
  88. package/libs/cli/shared/src/lib/infrastructure/formatters/console-formatter.js +0 -96
  89. package/libs/cli/shared/src/lib/infrastructure/formatters/index.js +0 -41
  90. package/libs/cli/shared/src/lib/infrastructure/formatters/json-formatter.js +0 -64
  91. package/libs/cli/shared/src/lib/infrastructure/formatters/markdown-formatter.js +0 -120
  92. package/libs/cli/shared/src/lib/infrastructure/formatters/types.js +0 -15
  93. package/libs/cli/shared/src/lib/infrastructure/formatters/utils.js +0 -72
  94. package/libs/cli/shared/src/lib/infrastructure/git.js +0 -147
  95. package/libs/cli/shared/src/lib/infrastructure/http.js +0 -257
  96. package/libs/cli/shared/src/lib/infrastructure/markdown.js +0 -95
  97. package/libs/cli/shared/src/lib/infrastructure/transformers/embeddings.js +0 -88
  98. package/libs/cli/shared/src/lib/infrastructure/transformers/index.js +0 -25
  99. package/libs/cli/shared/src/lib/infrastructure/transformers/rag-eval.js +0 -154
  100. package/libs/cli/shared/src/lib/infrastructure/transformers/similarity.js +0 -210
  101. package/libs/cli/shared/src/lib/infrastructure/workspace.js +0 -297
  102. package/libs/cli/shared/src/lib/infrastructure/yaml.js +0 -237
  103. package/libs/cli/shared/src/lib/lowgular.config.js +0 -120
  104. package/libs/cli/shared/src/lib/token.js +0 -135
  105. package/libs/cli/shared/src/lib/utils/solution.util.js +0 -35
  106. package/libs/cli/shared/src/lib/utils/utils.js +0 -89
  107. package/libs/cli/typescript/src/index.js +0 -21
  108. package/libs/cli/typescript/src/lib/base/index.js +0 -23
  109. package/libs/cli/typescript/src/lib/base/nameable.js +0 -34
  110. package/libs/cli/typescript/src/lib/base/nodeable.js +0 -36
  111. package/libs/cli/typescript/src/lib/class.implementation.js +0 -52
  112. package/libs/cli/typescript/src/lib/core/declaration.registry.js +0 -107
  113. package/libs/cli/typescript/src/lib/core/design-pattern.js +0 -55
  114. package/libs/cli/typescript/src/lib/core/index.js +0 -35
  115. package/libs/cli/typescript/src/lib/core/navigable-declaration.js +0 -69
  116. package/libs/cli/typescript/src/lib/core/program-context.js +0 -71
  117. package/libs/cli/typescript/src/lib/core/syntax-kind.utils.js +0 -40
  118. package/libs/cli/typescript/src/lib/core/type.js +0 -374
  119. package/libs/cli/typescript/src/lib/declaration.abstraction.js +0 -90
  120. package/libs/cli/typescript/src/lib/decorator.implementation.js +0 -35
  121. package/libs/cli/typescript/src/lib/enum.implementation.js +0 -35
  122. package/libs/cli/typescript/src/lib/function-declaration.implementation.js +0 -35
  123. package/libs/cli/typescript/src/lib/index.js +0 -57
  124. package/libs/cli/typescript/src/lib/interface.implementation.js +0 -51
  125. package/libs/cli/typescript/src/lib/members/method-abstraction.resolver.js +0 -90
  126. package/libs/cli/typescript/src/lib/members/method-declaration.implementation.js +0 -44
  127. package/libs/cli/typescript/src/lib/members/method-signature.implementation.js +0 -46
  128. package/libs/cli/typescript/src/lib/members/method.util.js +0 -32
  129. package/libs/cli/typescript/src/lib/members/parameter.implementation.js +0 -38
  130. package/libs/cli/typescript/src/lib/members/property-declaration.implementation.js +0 -64
  131. package/libs/cli/typescript/src/lib/members/property-signature.implementation.js +0 -34
  132. package/libs/cli/typescript/src/lib/members/property.util.js +0 -61
  133. package/libs/cli/typescript/src/lib/members/statements/expressions/binary-expression.implementation.js +0 -42
  134. package/libs/cli/typescript/src/lib/members/statements/expressions/call-expression.implementation.js +0 -114
  135. package/libs/cli/typescript/src/lib/members/statements/expressions/expression.abstraction.js +0 -188
  136. package/libs/cli/typescript/src/lib/members/statements/expressions/property-access-expression.implementation.js +0 -35
  137. package/libs/cli/typescript/src/lib/members/statements/expressions/unary-expression.implementation.js +0 -51
  138. package/libs/cli/typescript/src/lib/members/statements/statement.implementation.js +0 -49
  139. package/libs/cli/typescript/src/lib/members/statements/utils.js +0 -51
  140. package/libs/cli/typescript/src/lib/plugins/built-in.plugin.js +0 -258
  141. package/libs/cli/typescript/src/lib/plugins/plugin.interface.js +0 -15
  142. package/libs/cli/typescript/src/lib/plugins/rxjs.plugin.js +0 -228
  143. package/libs/cli/typescript/src/lib/plugins/signal.plugin.js +0 -126
  144. package/libs/cli/typescript/src/lib/plugins/stubs.js +0 -66
  145. package/libs/cli/typescript/src/lib/type-alias.implementation.js +0 -72
  146. package/libs/cli/typescript/src/lib/utils.js +0 -39
  147. package/libs/cli/typescript/src/lib/variable-declaration.implementation.js +0 -35
  148. package/libs/core/codegular/src/index.js +0 -21
  149. package/libs/core/codegular/src/lib/index.js +0 -29
  150. package/libs/core/codegular/src/lib/node.js +0 -112
  151. package/libs/core/codegular/src/lib/program.js +0 -92
  152. package/libs/core/codegular/src/lib/string.js +0 -168
  153. package/libs/core/codegular/src/lib/type-checker.js +0 -170
  154. package/libs/core/codegular/src/lib/utils.js +0 -347
  155. package/main.js +0 -43
@@ -1,181 +0,0 @@
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 specs_exports = {};
19
- __export(specs_exports, {
20
- CYPHER_CONSTRAINTS: () => CYPHER_CONSTRAINTS,
21
- CYPHER_FORBIDDEN_FEATURES: () => CYPHER_FORBIDDEN_FEATURES,
22
- MATCH_BASICS: () => MATCH_BASICS,
23
- RELATIONSHIP_ADVANCED: () => RELATIONSHIP_ADVANCED,
24
- RELATIONSHIP_BASICS: () => RELATIONSHIP_BASICS,
25
- WHERE_BASICS: () => WHERE_BASICS,
26
- mb: () => mb
27
- });
28
- module.exports = __toCommonJS(specs_exports);
29
- var import_supported_features = require("../validator/supported-features.config");
30
- var import_unsupported_features = require("../validator/unsupported-features.config");
31
- var import_features = require("./features");
32
- var import_basic_optional_match = require("./features/basic-optional-match.feature");
33
- var import_return_statement = require("./features/return-statement.feature");
34
- const mb = (content, type) => `\`\`\`${type}
35
- ${content}
36
- \`\`\``;
37
- function generateFeatureList(depth, features) {
38
- return features.map((feature) => {
39
- const lines = [];
40
- lines.push(`${mh(depth)} ${feature.name}`);
41
- lines.push(feature.description);
42
- if (feature.queries) {
43
- lines.push(`Allowed queries:`);
44
- feature.queries.forEach((query) => {
45
- lines.push(mb(query.join("\n"), "cypher"));
46
- });
47
- }
48
- return lines.join("\n\n");
49
- }).join("\n");
50
- }
51
- function generateConstraintList(constraints) {
52
- return constraints.map((constraint) => `- ${constraint.description}`).join("\n");
53
- }
54
- function generateForbiddenFeaturesList(data) {
55
- return data.map((feature) => {
56
- let line = `- **${feature.name}** - ${feature.errorMessage}`;
57
- if (feature.alternative) {
58
- line += ` ${feature.alternative}`;
59
- }
60
- return line;
61
- }).join("\n");
62
- }
63
- const mh = (depth) => `${"#".repeat(depth)}`;
64
- const MATCH_BASICS = (depth) => `
65
- ${mh(depth)} MATCH Nodes
66
-
67
- ${generateFeatureList(depth + 1, import_features.MATCH_NODES_FEATURES)}
68
-
69
- ${mh(depth)} MATCH Nodes by Properties
70
-
71
- ${generateFeatureList(depth + 1, import_features.PROPERTY_MATCHING_FEATURES)}
72
-
73
- ${mh(depth)} Optional Match
74
-
75
- ${generateFeatureList(depth + 1, import_basic_optional_match.BASIC_OPTIONAL_MATCH_FEATURES)}
76
-
77
- ${mh(depth)} Return Statement
78
-
79
- ${generateFeatureList(depth + 1, import_return_statement.RETURN_STATEMENT_FEATURES)}
80
-
81
- ${mh(depth)} LIMIT Clause
82
-
83
- ${generateFeatureList(depth + 1, import_features.LIMIT_FEATURES)}
84
-
85
- ${mh(depth)} ORDER BY Clause
86
-
87
- Without ORDER BY, results are returned in graph insertion order:
88
- - Files: Order from TypeScript's program.getSourceFiles() (typically alphabetical by file path based on tsconfig include patterns)
89
- - Within files: Top-to-bottom AST traversal order (position in SourceFile)
90
-
91
- ${generateFeatureList(depth + 1, import_features.ORDER_BY_FEATURES)}
92
- `;
93
- const WHERE_BASICS = (depth) => `
94
- ${mh(depth)} Filtering Nodes
95
-
96
- ${generateFeatureList(depth + 1, import_features.BASIC_FILTERING_FEATURES)}
97
-
98
- ${mh(depth)} WHERE Clause Operators
99
-
100
- ${generateFeatureList(depth + 1, import_features.WHERE_OPERATORS_FEATURES)}
101
-
102
- ${mh(depth)} WHERE Conditional Logic
103
-
104
- ${generateFeatureList(depth + 1, import_features.WHERE_CONDITIONAL_LOGIC_FEATURES)}
105
-
106
- ${mh(depth)} Advanced Optional Match
107
-
108
- ${generateFeatureList(depth + 1, import_features.ADVANCED_OPTIONAL_MATCH_FEATURES)}
109
- `;
110
- const RELATIONSHIP_BASICS = (depth) => `
111
- ${mh(depth)} Basic Relationships
112
-
113
- ${generateFeatureList(depth + 1, import_features.BASIC_RELATIONSHIP_FEATURES)}
114
-
115
- ${mh(depth)} Undirected Relationships
116
-
117
- ${generateFeatureList(depth + 1, import_features.UNDIRECTED_RELATIONSHIP_FEATURES)}
118
-
119
- ${mh(depth)} Multiple Relationship Types
120
-
121
- ${generateFeatureList(depth + 1, import_features.MULTIPLE_RELATIONSHIP_TYPES_FEATURES)}
122
-
123
- ${mh(depth)} Anonymous Relationships
124
-
125
- ${generateFeatureList(depth + 1, import_features.ANONYMOUS_RELATIONSHIP_FEATURES)}
126
-
127
- ${mh(depth)} Relationship Without Variable
128
-
129
- ${generateFeatureList(depth + 1, import_features.RELATIONSHIP_WITHOUT_VARIABLE_FEATURES)}
130
- `;
131
- const RELATIONSHIP_ADVANCED = (depth) => `
132
- ${mh(depth)} Variable-Length Paths
133
-
134
- ${generateFeatureList(depth + 1, import_features.VARIABLE_LENGTH_PATH_FEATURES)}
135
-
136
- ${mh(depth)} Anonymous Variable-Length Paths
137
-
138
- ${generateFeatureList(depth + 1, import_features.ANONYMOUS_VARIABLE_LENGTH_FEATURES)}
139
- `;
140
- const CYPHER_CONSTRAINTS = (depth) => `${mh(depth)} Node Constraints
141
-
142
- ${generateConstraintList(import_supported_features.NODE_CONSTRAINTS)}
143
-
144
- ${mh(depth)} Relationship Constraints
145
-
146
- ${generateConstraintList(import_supported_features.RELATIONSHIP_CONSTRAINTS)}
147
-
148
- ${mh(depth)} Query Constraints
149
-
150
- ${generateConstraintList(import_supported_features.QUERY_CONSTRAINTS)}
151
-
152
- ${mh(depth)} Pattern Constraints
153
-
154
- ${generateConstraintList(import_supported_features.PATTERN_CONSTRAINTS)}`;
155
- const CYPHER_FORBIDDEN_FEATURES = (depth) => `${mh(depth)} Forbidden Keywords
156
-
157
- ${generateForbiddenFeaturesList(import_unsupported_features.FORBIDDEN_KEYWORDS)}
158
-
159
- ${mh(depth)} Forbidden Aggregations
160
-
161
- ${generateForbiddenFeaturesList(import_unsupported_features.FORBIDDEN_AGGREGATIONS)}
162
-
163
- ${mh(depth)} Forbidden Modifiers
164
-
165
- ${generateForbiddenFeaturesList(import_unsupported_features.FORBIDDEN_MODIFIERS)}
166
-
167
- ${mh(depth)} Forbidden Patterns
168
-
169
- ${generateForbiddenFeaturesList(import_unsupported_features.FORBIDDEN_PATTERNS)}
170
-
171
- `;
172
- // Annotate the CommonJS export names for ESM import in node:
173
- 0 && (module.exports = {
174
- CYPHER_CONSTRAINTS,
175
- CYPHER_FORBIDDEN_FEATURES,
176
- MATCH_BASICS,
177
- RELATIONSHIP_ADVANCED,
178
- RELATIONSHIP_BASICS,
179
- WHERE_BASICS,
180
- mb
181
- });
@@ -1,158 +0,0 @@
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 condition_evaluator_exports = {};
19
- __export(condition_evaluator_exports, {
20
- ConditionEvaluator: () => ConditionEvaluator
21
- });
22
- module.exports = __toCommonJS(condition_evaluator_exports);
23
- class ConditionEvaluator {
24
- // @TODO: apply where at match level
25
- /**
26
- * Apply WHERE clause filtering to matches
27
- */
28
- applyWhereClauseIfNeeded(matches, where) {
29
- return matches.filter((match) => {
30
- const conditionResults = where.conditions.map(
31
- (condition) => this.evaluateCondition(match, condition)
32
- );
33
- const logic = where.logic || "AND";
34
- if (logic === "AND") {
35
- return conditionResults.every((result) => result === true);
36
- } else {
37
- return conditionResults.some((result) => result === true);
38
- }
39
- });
40
- }
41
- // @fixme move to utils
42
- /**
43
- * Escape special regex characters in a string
44
- */
45
- escapeRegex(str) {
46
- return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
47
- }
48
- /**
49
- * Evaluate a single WHERE condition
50
- * Supports flat properties only (no nesting, like Neo4j Cypher)
51
- * Handles null values from optional matches (null values fail the condition)
52
- */
53
- evaluateCondition(match, condition) {
54
- const value = match[condition.variable];
55
- if ((condition.operator === "IS NULL" || condition.operator === "IS NOT NULL") && !condition.property) {
56
- const isNull = value === null || value === void 0;
57
- return condition.operator === "IS NULL" ? isNull : !isNull;
58
- }
59
- if (!value || value === null) {
60
- return false;
61
- }
62
- let baseObject;
63
- if ("id" in value) {
64
- baseObject = value;
65
- } else if ("type" in value && "source" in value) {
66
- baseObject = value;
67
- } else {
68
- return false;
69
- }
70
- let actualValue;
71
- if (!condition.property) {
72
- actualValue = baseObject;
73
- } else {
74
- actualValue = baseObject[condition.property];
75
- if (actualValue === void 0) {
76
- if (condition.operator === "IS NULL" || condition.operator === "IS NOT NULL") {
77
- actualValue = void 0;
78
- } else {
79
- return false;
80
- }
81
- }
82
- }
83
- const conditionValue = condition.value;
84
- switch (condition.operator) {
85
- case "=":
86
- return actualValue === conditionValue;
87
- case "!=":
88
- return actualValue !== conditionValue;
89
- case ">":
90
- return actualValue > conditionValue;
91
- case "<":
92
- return actualValue < conditionValue;
93
- case ">=":
94
- return actualValue >= conditionValue;
95
- case "<=":
96
- return actualValue <= conditionValue;
97
- case "IS NULL":
98
- return actualValue === null || actualValue === void 0;
99
- case "IS NOT NULL":
100
- return actualValue !== null && actualValue !== void 0;
101
- case "IN":
102
- if (Array.isArray(conditionValue)) {
103
- if (conditionValue.length > 0 && typeof conditionValue[0] === "object" && conditionValue[0] !== null) {
104
- const extractedValues = conditionValue.map((item) => item?.name).filter((name) => name !== void 0);
105
- return extractedValues.includes(actualValue);
106
- }
107
- return conditionValue.includes(actualValue);
108
- }
109
- return false;
110
- case "NOT IN":
111
- if (Array.isArray(conditionValue)) {
112
- if (conditionValue.length > 0 && typeof conditionValue[0] === "object" && conditionValue[0] !== null) {
113
- const extractedValues = conditionValue.map((item) => item?.name).filter((name) => name !== void 0);
114
- return !extractedValues.includes(actualValue);
115
- }
116
- return !conditionValue.includes(actualValue);
117
- }
118
- return true;
119
- case "STARTS WITH":
120
- return this.testRegex(
121
- new RegExp(`^${this.escapeRegex(conditionValue)}`),
122
- actualValue
123
- );
124
- case "ENDS WITH":
125
- return this.testRegex(
126
- new RegExp(`${this.escapeRegex(conditionValue)}$`),
127
- actualValue
128
- );
129
- case "CONTAINS":
130
- return this.testRegex(
131
- new RegExp(this.escapeRegex(conditionValue)),
132
- actualValue
133
- );
134
- case "=~":
135
- return this.testRegex(new RegExp(conditionValue), actualValue);
136
- default:
137
- throw new Error(`Unsupported operator: ${condition.operator}`);
138
- }
139
- }
140
- testRegex(regexp, actualValue) {
141
- if (actualValue === null || actualValue === void 0) {
142
- return false;
143
- }
144
- if (typeof actualValue !== "string" && typeof actualValue !== "number" && typeof actualValue !== "boolean") {
145
- return false;
146
- }
147
- const regexStr = typeof actualValue === "string" ? actualValue : String(actualValue);
148
- try {
149
- return regexp.test(regexStr);
150
- } catch {
151
- return false;
152
- }
153
- }
154
- }
155
- // Annotate the CommonJS export names for ESM import in node:
156
- 0 && (module.exports = {
157
- ConditionEvaluator
158
- });
@@ -1,83 +0,0 @@
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 executor_exports = {};
19
- __export(executor_exports, {
20
- CypherExecutor: () => CypherExecutor
21
- });
22
- module.exports = __toCommonJS(executor_exports);
23
- var import_condition_evaluator = require("./condition-evaluator");
24
- var import_match_engine = require("./match-engine");
25
- var import_pattern_matcher = require("./pattern-matcher");
26
- var import_relationship_navigator = require("./relationship-navigator");
27
- var import_result_formatter = require("./result-formatter");
28
- var import_traverse_engine = require("./traverse-engine");
29
- class CypherExecutor {
30
- constructor(graph) {
31
- this.graph = graph;
32
- this.conditionEvaluator = new import_condition_evaluator.ConditionEvaluator();
33
- const patternMatcher = new import_pattern_matcher.PatternMatcher();
34
- const relationshipNavigator = new import_relationship_navigator.RelationshipNavigator(patternMatcher);
35
- const traverseEngine = new import_traverse_engine.TraverseEngine(
36
- patternMatcher,
37
- relationshipNavigator
38
- );
39
- this.matchEngine = new import_match_engine.MatchEngine(patternMatcher, traverseEngine);
40
- this.resultFormatter = new import_result_formatter.ResultFormatter();
41
- }
42
- /**
43
- * Execute a parsed Cypher query
44
- * @param extractData - If true (default), returns node.data. If false, returns full GraphNode objects.
45
- * For edges, always returns the full GraphEdge object (edges have no data property).
46
- * Returns results where keys are variable names and values are either node data or edge objects
47
- */
48
- execute(query) {
49
- if (query.statements.length === 0) {
50
- throw new Error("Query must have at least one statement");
51
- }
52
- if (query.statements[query.statements.length - 1].type !== "ReturnStatement") {
53
- throw new Error("MATCH Query must have a RETURN statement");
54
- }
55
- let results = [];
56
- for (const statement of query.statements) {
57
- if (statement.type === "MatchStatement") {
58
- results = this.matchEngine.processMatchStatement(
59
- this.graph,
60
- statement,
61
- results
62
- );
63
- } else if (statement.type === "WhereStatement") {
64
- results = this.conditionEvaluator.applyWhereClauseIfNeeded(
65
- results,
66
- statement
67
- );
68
- } else if (statement.type === "OrderByStatement") {
69
- results = this.resultFormatter.sortResults(results, statement);
70
- }
71
- }
72
- const returnStatement = query.statements[query.statements.length - 1];
73
- let formattedResults = this.resultFormatter.formatResults(
74
- results,
75
- returnStatement
76
- );
77
- return formattedResults;
78
- }
79
- }
80
- // Annotate the CommonJS export names for ESM import in node:
81
- 0 && (module.exports = {
82
- CypherExecutor
83
- });
@@ -1,15 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __copyProps = (to, from, except, desc) => {
6
- if (from && typeof from === "object" || typeof from === "function") {
7
- for (let key of __getOwnPropNames(from))
8
- if (!__hasOwnProp.call(to, key) && key !== except)
9
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
10
- }
11
- return to;
12
- };
13
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
14
- var graph_exports = {};
15
- module.exports = __toCommonJS(graph_exports);
@@ -1,153 +0,0 @@
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 match_engine_exports = {};
19
- __export(match_engine_exports, {
20
- MatchEngine: () => MatchEngine
21
- });
22
- module.exports = __toCommonJS(match_engine_exports);
23
- var import_utils = require("./utils");
24
- class MatchEngine {
25
- constructor(patternMatcher, traverseEngine) {
26
- this.patternMatcher = patternMatcher;
27
- this.traverseEngine = traverseEngine;
28
- this.annonymizer = new import_utils.Annonymizer();
29
- }
30
- processMatchStatement(graph, match, existingResults = []) {
31
- if (match.patterns.length === 0)
32
- return existingResults;
33
- const starting = match.patterns[0];
34
- const allResults = [];
35
- this.patternMatcher.filterMatchingNodes(graph, starting).forEach((node) => {
36
- const matches = this.traverseEngine.traverseRelationships(
37
- graph,
38
- node,
39
- starting.variable || this.annonymizer.generate(node),
40
- match.patterns.slice(1),
41
- match.relationships
42
- );
43
- allResults.push(...matches);
44
- });
45
- if (existingResults.length > 0) {
46
- if (match.optional) {
47
- return this.mergeOptionalResults(existingResults, allResults, match);
48
- } else {
49
- return this.mergeResults(existingResults, allResults);
50
- }
51
- }
52
- return allResults;
53
- }
54
- mergeResults(existingResults, newResults) {
55
- if (existingResults.length === 0) {
56
- return newResults;
57
- }
58
- const mergedResults = [];
59
- for (const existingResult of existingResults) {
60
- for (const newResult of newResults) {
61
- if (this.canMergeResult(existingResult, newResult)) {
62
- mergedResults.push({ ...existingResult, ...newResult });
63
- }
64
- }
65
- }
66
- return mergedResults;
67
- }
68
- /**
69
- * Merge optional match results with existing results (left outer join)
70
- * - Keeps all existing results
71
- * - Merges optional results where variables overlap
72
- * - Adds nulls for optional variables when no match is found
73
- */
74
- mergeOptionalResults(existingResults, optionalResults, match) {
75
- if (existingResults.length === 0) {
76
- return optionalResults;
77
- }
78
- const optionalVarNames = /* @__PURE__ */ new Set();
79
- for (const pattern of match.patterns) {
80
- if (pattern.variable) {
81
- optionalVarNames.add(pattern.variable);
82
- }
83
- }
84
- if (match.relationships) {
85
- for (const rel of match.relationships) {
86
- if (rel.variable) {
87
- optionalVarNames.add(rel.variable);
88
- }
89
- }
90
- }
91
- if (optionalResults.length === 0) {
92
- return existingResults.map((result) => {
93
- const resultWithNulls = { ...result };
94
- for (const varName of optionalVarNames) {
95
- if (!(varName in resultWithNulls)) {
96
- resultWithNulls[varName] = null;
97
- }
98
- }
99
- return resultWithNulls;
100
- });
101
- }
102
- for (const optionalResult of optionalResults) {
103
- for (const key in optionalResult) {
104
- optionalVarNames.add(key);
105
- }
106
- }
107
- const mergedResults = [];
108
- for (const existingResult of existingResults) {
109
- let hasMatch = false;
110
- for (const optionalResult of optionalResults) {
111
- if (this.canMergeResult(existingResult, optionalResult)) {
112
- mergedResults.push({ ...existingResult, ...optionalResult });
113
- hasMatch = true;
114
- }
115
- }
116
- if (!hasMatch) {
117
- const resultWithNulls = { ...existingResult };
118
- for (const varName of optionalVarNames) {
119
- if (!(varName in resultWithNulls)) {
120
- resultWithNulls[varName] = null;
121
- }
122
- }
123
- mergedResults.push(resultWithNulls);
124
- }
125
- }
126
- return mergedResults;
127
- }
128
- /**
129
- * Check if additionalResult can be merged with existingResult
130
- * Returns true if shared variables match (same node/edge) or if there are no conflicts
131
- * Does NOT mutate any parameters
132
- */
133
- canMergeResult(additionalResult, existingResult) {
134
- for (const key in additionalResult) {
135
- if (key in existingResult) {
136
- const existing = existingResult[key];
137
- const additional = additionalResult[key];
138
- if (existing !== null && additional !== null) {
139
- if ("id" in existing && "id" in additional && existing.id !== additional.id) {
140
- return false;
141
- }
142
- } else if (existing !== additional) {
143
- return false;
144
- }
145
- }
146
- }
147
- return true;
148
- }
149
- }
150
- // Annotate the CommonJS export names for ESM import in node:
151
- 0 && (module.exports = {
152
- MatchEngine
153
- });
@@ -1,109 +0,0 @@
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 pattern_matcher_exports = {};
19
- __export(pattern_matcher_exports, {
20
- PatternMatcher: () => PatternMatcher
21
- });
22
- module.exports = __toCommonJS(pattern_matcher_exports);
23
- class PatternMatcher {
24
- /**
25
- * Check if an edge type matches the relationship pattern's edge type(s)
26
- * Supports both single edge type (string) and multiple edge types (array)
27
- */
28
- matchesEdgeType(edgeType, patternEdgeType) {
29
- if (!patternEdgeType) {
30
- return true;
31
- }
32
- if (typeof patternEdgeType === "string") {
33
- return edgeType === patternEdgeType;
34
- }
35
- return patternEdgeType.includes(edgeType);
36
- }
37
- /**
38
- * Deep equality check for arrays
39
- */
40
- arraysEqual(a, b) {
41
- if (a.length !== b.length) {
42
- return false;
43
- }
44
- for (let i = 0; i < a.length; i++) {
45
- if (Array.isArray(a[i]) && Array.isArray(b[i])) {
46
- if (!this.arraysEqual(a[i], b[i])) {
47
- return false;
48
- }
49
- } else if (a[i] !== b[i]) {
50
- return false;
51
- }
52
- }
53
- return true;
54
- }
55
- /**
56
- * Check if two values are equal (handles arrays with deep equality)
57
- */
58
- valuesEqual(expected, actual) {
59
- if (Array.isArray(expected) && Array.isArray(actual)) {
60
- return this.arraysEqual(expected, actual);
61
- }
62
- return expected === actual;
63
- }
64
- /**
65
- * Check if a node matches a pattern (labels and properties)
66
- */
67
- doesNodeMatchPattern(node, pattern) {
68
- if (pattern.labels.length > 0) {
69
- const labelOperator = pattern.labelOperator || "AND";
70
- if (labelOperator === "AND") {
71
- if (!pattern.labels.every((label) => node.labels.includes(label))) {
72
- return false;
73
- }
74
- } else {
75
- if (!pattern.labels.some((label) => node.labels.includes(label))) {
76
- return false;
77
- }
78
- }
79
- }
80
- if (pattern.properties) {
81
- const notFound = Object.entries(pattern.properties).find(
82
- ([key, expectedValue]) => !this.valuesEqual(expectedValue, node[key])
83
- ) !== void 0;
84
- if (notFound) {
85
- return false;
86
- }
87
- }
88
- return true;
89
- }
90
- findMatchingNodes(graph, pattern) {
91
- return Object.values(graph.nodesById).find(
92
- (node) => this.doesNodeMatchPattern(node, pattern)
93
- );
94
- }
95
- /**
96
- * Match a single node pattern
97
- * Finds all nodes in the graph that match the given pattern
98
- * Reuses matchesPattern to avoid code duplication
99
- */
100
- filterMatchingNodes(graph, pattern) {
101
- return Object.values(graph.nodesById).filter(
102
- (node) => this.doesNodeMatchPattern(node, pattern)
103
- );
104
- }
105
- }
106
- // Annotate the CommonJS export names for ESM import in node:
107
- 0 && (module.exports = {
108
- PatternMatcher
109
- });