flowquery 1.0.0 → 1.0.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.
- package/.github/workflows/npm-publish.yml +2 -0
- package/.github/workflows/release.yml +24 -9
- package/dist/compute/runner.js +75 -0
- package/dist/compute/runner.js.map +1 -0
- package/dist/flowquery.min.js +1 -0
- package/dist/index.browser.js +119 -0
- package/dist/index.browser.js.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/index.node.js +123 -0
- package/dist/index.node.js.map +1 -0
- package/dist/io/command_line.js +102 -0
- package/dist/io/command_line.js.map +1 -0
- package/dist/parsing/alias.js +23 -0
- package/dist/parsing/alias.js.map +1 -0
- package/dist/parsing/alias_option.js +11 -0
- package/dist/parsing/alias_option.js.map +1 -0
- package/dist/parsing/ast_node.js +145 -0
- package/dist/parsing/ast_node.js.map +1 -0
- package/dist/parsing/base_parser.js +92 -0
- package/dist/parsing/base_parser.js.map +1 -0
- package/dist/parsing/components/csv.js +13 -0
- package/dist/parsing/components/csv.js.map +1 -0
- package/dist/parsing/components/from.js +16 -0
- package/dist/parsing/components/from.js.map +1 -0
- package/dist/parsing/components/headers.js +16 -0
- package/dist/parsing/components/headers.js.map +1 -0
- package/dist/parsing/components/json.js +13 -0
- package/dist/parsing/components/json.js.map +1 -0
- package/dist/parsing/components/null.js +13 -0
- package/dist/parsing/components/null.js.map +1 -0
- package/dist/parsing/components/post.js +13 -0
- package/dist/parsing/components/post.js.map +1 -0
- package/dist/parsing/components/text.js +13 -0
- package/dist/parsing/components/text.js.map +1 -0
- package/dist/parsing/context.js +47 -0
- package/dist/parsing/context.js.map +1 -0
- package/dist/parsing/data_structures/associative_array.js +45 -0
- package/dist/parsing/data_structures/associative_array.js.map +1 -0
- package/dist/parsing/data_structures/json_array.js +35 -0
- package/dist/parsing/data_structures/json_array.js.map +1 -0
- package/dist/parsing/data_structures/key_value_pair.js +41 -0
- package/dist/parsing/data_structures/key_value_pair.js.map +1 -0
- package/dist/parsing/data_structures/lookup.js +44 -0
- package/dist/parsing/data_structures/lookup.js.map +1 -0
- package/dist/parsing/data_structures/range_lookup.js +40 -0
- package/dist/parsing/data_structures/range_lookup.js.map +1 -0
- package/dist/parsing/expressions/expression.js +142 -0
- package/dist/parsing/expressions/expression.js.map +1 -0
- package/dist/parsing/expressions/f_string.js +29 -0
- package/dist/parsing/expressions/f_string.js.map +1 -0
- package/dist/parsing/expressions/identifier.js +26 -0
- package/dist/parsing/expressions/identifier.js.map +1 -0
- package/dist/parsing/expressions/number.js +41 -0
- package/dist/parsing/expressions/number.js.map +1 -0
- package/dist/parsing/expressions/operator.js +180 -0
- package/dist/parsing/expressions/operator.js.map +1 -0
- package/dist/parsing/expressions/reference.js +45 -0
- package/dist/parsing/expressions/reference.js.map +1 -0
- package/dist/parsing/expressions/string.js +34 -0
- package/dist/parsing/expressions/string.js.map +1 -0
- package/dist/parsing/functions/aggregate_function.js +58 -0
- package/dist/parsing/functions/aggregate_function.js.map +1 -0
- package/dist/parsing/functions/async_function.js +119 -0
- package/dist/parsing/functions/async_function.js.map +1 -0
- package/dist/parsing/functions/avg.js +43 -0
- package/dist/parsing/functions/avg.js.map +1 -0
- package/dist/parsing/functions/collect.js +52 -0
- package/dist/parsing/functions/collect.js.map +1 -0
- package/dist/parsing/functions/function.js +59 -0
- package/dist/parsing/functions/function.js.map +1 -0
- package/dist/parsing/functions/function_factory.js +259 -0
- package/dist/parsing/functions/function_factory.js.map +1 -0
- package/dist/parsing/functions/function_metadata.js +159 -0
- package/dist/parsing/functions/function_metadata.js.map +1 -0
- package/dist/parsing/functions/functions.js +47 -0
- package/dist/parsing/functions/functions.js.map +1 -0
- package/dist/parsing/functions/join.js +29 -0
- package/dist/parsing/functions/join.js.map +1 -0
- package/dist/parsing/functions/predicate_function.js +37 -0
- package/dist/parsing/functions/predicate_function.js.map +1 -0
- package/dist/parsing/functions/predicate_function_factory.js +19 -0
- package/dist/parsing/functions/predicate_function_factory.js.map +1 -0
- package/dist/parsing/functions/predicate_sum.js +33 -0
- package/dist/parsing/functions/predicate_sum.js.map +1 -0
- package/dist/parsing/functions/rand.js +17 -0
- package/dist/parsing/functions/rand.js.map +1 -0
- package/dist/parsing/functions/range.js +22 -0
- package/dist/parsing/functions/range.js.map +1 -0
- package/dist/parsing/functions/reducer_element.js +12 -0
- package/dist/parsing/functions/reducer_element.js.map +1 -0
- package/dist/parsing/functions/replace.js +23 -0
- package/dist/parsing/functions/replace.js.map +1 -0
- package/dist/parsing/functions/round.js +21 -0
- package/dist/parsing/functions/round.js.map +1 -0
- package/dist/parsing/functions/size.js +21 -0
- package/dist/parsing/functions/size.js.map +1 -0
- package/dist/parsing/functions/split.js +29 -0
- package/dist/parsing/functions/split.js.map +1 -0
- package/dist/parsing/functions/stringify.js +29 -0
- package/dist/parsing/functions/stringify.js.map +1 -0
- package/dist/parsing/functions/sum.js +38 -0
- package/dist/parsing/functions/sum.js.map +1 -0
- package/dist/parsing/functions/to_json.js +21 -0
- package/dist/parsing/functions/to_json.js.map +1 -0
- package/dist/parsing/functions/value_holder.js +16 -0
- package/dist/parsing/functions/value_holder.js.map +1 -0
- package/dist/parsing/logic/case.js +27 -0
- package/dist/parsing/logic/case.js.map +1 -0
- package/dist/parsing/logic/else.js +16 -0
- package/dist/parsing/logic/else.js.map +1 -0
- package/dist/parsing/logic/end.js +13 -0
- package/dist/parsing/logic/end.js.map +1 -0
- package/dist/parsing/logic/then.js +16 -0
- package/dist/parsing/logic/then.js.map +1 -0
- package/dist/parsing/logic/when.js +16 -0
- package/dist/parsing/logic/when.js.map +1 -0
- package/dist/parsing/operations/aggregated_return.js +35 -0
- package/dist/parsing/operations/aggregated_return.js.map +1 -0
- package/dist/parsing/operations/aggregated_with.js +41 -0
- package/dist/parsing/operations/aggregated_with.js.map +1 -0
- package/dist/parsing/operations/group_by.js +139 -0
- package/dist/parsing/operations/group_by.js.map +1 -0
- package/dist/parsing/operations/limit.js +38 -0
- package/dist/parsing/operations/limit.js.map +1 -0
- package/dist/parsing/operations/load.js +174 -0
- package/dist/parsing/operations/load.js.map +1 -0
- package/dist/parsing/operations/operation.js +81 -0
- package/dist/parsing/operations/operation.js.map +1 -0
- package/dist/parsing/operations/projection.js +21 -0
- package/dist/parsing/operations/projection.js.map +1 -0
- package/dist/parsing/operations/return.js +60 -0
- package/dist/parsing/operations/return.js.map +1 -0
- package/dist/parsing/operations/unwind.js +46 -0
- package/dist/parsing/operations/unwind.js.map +1 -0
- package/dist/parsing/operations/where.js +53 -0
- package/dist/parsing/operations/where.js.map +1 -0
- package/dist/parsing/operations/with.js +36 -0
- package/dist/parsing/operations/with.js.map +1 -0
- package/dist/parsing/parser.js +812 -0
- package/dist/parsing/parser.js.map +1 -0
- package/dist/parsing/token_to_node.js +121 -0
- package/dist/parsing/token_to_node.js.map +1 -0
- package/dist/tokenization/keyword.js +46 -0
- package/dist/tokenization/keyword.js.map +1 -0
- package/dist/tokenization/operator.js +28 -0
- package/dist/tokenization/operator.js.map +1 -0
- package/dist/tokenization/string_walker.js +165 -0
- package/dist/tokenization/string_walker.js.map +1 -0
- package/dist/tokenization/symbol.js +18 -0
- package/dist/tokenization/symbol.js.map +1 -0
- package/dist/tokenization/token.js +484 -0
- package/dist/tokenization/token.js.map +1 -0
- package/dist/tokenization/token_mapper.js +55 -0
- package/dist/tokenization/token_mapper.js.map +1 -0
- package/dist/tokenization/token_type.js +19 -0
- package/dist/tokenization/token_type.js.map +1 -0
- package/dist/tokenization/tokenizer.js +220 -0
- package/dist/tokenization/tokenizer.js.map +1 -0
- package/dist/tokenization/trie.js +111 -0
- package/dist/tokenization/trie.js.map +1 -0
- package/dist/utils/object_utils.js +19 -0
- package/dist/utils/object_utils.js.map +1 -0
- package/dist/utils/string_utils.js +110 -0
- package/dist/utils/string_utils.js.map +1 -0
- package/docs/flowquery.min.js +1 -1
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
- package/package.json +22 -4
- package/src/compute/runner.ts +45 -0
- package/src/index.browser.ts +118 -0
- package/src/index.node.ts +141 -0
- package/src/parsing/functions/async_function.ts +95 -0
- package/src/parsing/functions/function_factory.ts +230 -1
- package/src/parsing/functions/function_metadata.ts +238 -0
- package/src/parsing/functions/functions.ts +43 -0
- package/src/parsing/operations/load.ts +51 -2
- package/src/parsing/parser.ts +45 -4
- package/tests/parsing/function_plugins.test.ts +369 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const ast_node_1 = __importDefault(require("../ast_node"));
|
|
16
|
+
/**
|
|
17
|
+
* Base class for all FlowQuery operations.
|
|
18
|
+
*
|
|
19
|
+
* Operations represent the main statements in FlowQuery (WITH, UNWIND, RETURN, LOAD, WHERE).
|
|
20
|
+
* They form a linked list structure and can be executed sequentially.
|
|
21
|
+
*
|
|
22
|
+
* @abstract
|
|
23
|
+
*/
|
|
24
|
+
class Operation extends ast_node_1.default {
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new Operation instance.
|
|
27
|
+
*/
|
|
28
|
+
constructor() {
|
|
29
|
+
super();
|
|
30
|
+
this._previous = null;
|
|
31
|
+
this._next = null;
|
|
32
|
+
}
|
|
33
|
+
get previous() {
|
|
34
|
+
return this._previous;
|
|
35
|
+
}
|
|
36
|
+
set previous(value) {
|
|
37
|
+
this._previous = value;
|
|
38
|
+
}
|
|
39
|
+
get next() {
|
|
40
|
+
return this._next;
|
|
41
|
+
}
|
|
42
|
+
set next(value) {
|
|
43
|
+
this._next = value;
|
|
44
|
+
}
|
|
45
|
+
addSibling(operation) {
|
|
46
|
+
var _a;
|
|
47
|
+
(_a = this._parent) === null || _a === void 0 ? void 0 : _a.addChild(operation);
|
|
48
|
+
operation.previous = this;
|
|
49
|
+
this.next = operation;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Executes this operation. Must be implemented by subclasses.
|
|
53
|
+
*
|
|
54
|
+
* @returns A promise that resolves when the operation completes
|
|
55
|
+
* @throws {Error} If not implemented by subclass
|
|
56
|
+
*/
|
|
57
|
+
run() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
throw new Error('Not implemented');
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Finishes execution by calling finish on the next operation in the chain.
|
|
64
|
+
*
|
|
65
|
+
* @returns A promise that resolves when all operations finish
|
|
66
|
+
*/
|
|
67
|
+
finish() {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
var _a;
|
|
70
|
+
yield ((_a = this.next) === null || _a === void 0 ? void 0 : _a.finish());
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
reset() {
|
|
74
|
+
;
|
|
75
|
+
}
|
|
76
|
+
get results() {
|
|
77
|
+
throw new Error('Not implemented');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.default = Operation;
|
|
81
|
+
//# sourceMappingURL=operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"operation.js","sourceRoot":"","sources":["../../../src/parsing/operations/operation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,2DAAkC;AAElC;;;;;;;GAOG;AACH,MAAe,SAAU,SAAQ,kBAAO;IAIpC;;OAEG;IACH;QACI,KAAK,EAAE,CAAC;QAPJ,cAAS,GAAqB,IAAI,CAAC;QACnC,UAAK,GAAqB,IAAI,CAAC;IAOvC,CAAC;IACD,IAAW,QAAQ;QACf,OAAO,IAAI,CAAC,SAAS,CAAC;IAC1B,CAAC;IACD,IAAW,QAAQ,CAAC,KAAuB;QACvC,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;IAC3B,CAAC;IACD,IAAW,IAAI;QACX,OAAO,IAAI,CAAC,KAAK,CAAC;IACtB,CAAC;IACD,IAAW,IAAI,CAAC,KAAuB;QACnC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACvB,CAAC;IACM,UAAU,CAAC,SAAoB;;QAClC,MAAA,IAAI,CAAC,OAAO,0CAAE,QAAQ,CAAC,SAAS,CAAC,CAAC;QAClC,SAAS,CAAC,QAAQ,GAAG,IAAI,CAAC;QAC1B,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACU,GAAG;;YACZ,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;QACvC,CAAC;KAAA;IAED;;;;OAIG;IACU,MAAM;;;YACf,MAAM,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,MAAM,EAAE,CAAA,CAAC;QAC9B,CAAC;KAAA;IACM,KAAK;QACR,CAAC;IACL,CAAC;IACD,IAAW,OAAO;QACd,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IACvC,CAAC;CACJ;AAED,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
7
|
+
class Projection extends operation_1.default {
|
|
8
|
+
constructor(expressions) {
|
|
9
|
+
super();
|
|
10
|
+
this.children = expressions;
|
|
11
|
+
}
|
|
12
|
+
*expressions() {
|
|
13
|
+
for (let i = 0; i < this.children.length; i++) {
|
|
14
|
+
const expression = this.children[i];
|
|
15
|
+
const alias = expression.alias || `expr${i}`;
|
|
16
|
+
yield [expression, alias];
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.default = Projection;
|
|
21
|
+
//# sourceMappingURL=projection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"projection.js","sourceRoot":"","sources":["../../../src/parsing/operations/projection.ts"],"names":[],"mappings":";;;;;AAAA,4DAAoC;AAGpC,MAAM,UAAW,SAAQ,mBAAS;IAC9B,YAAY,WAAyB;QACjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,GAAG,WAAW,CAAC;IAChC,CAAC;IACS,CAAC,WAAW;QAClB,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3C,MAAM,UAAU,GAAe,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAe,CAAC;YAC9D,MAAM,KAAK,GAAG,UAAU,CAAC,KAAK,IAAI,OAAO,CAAC,EAAE,CAAC;YAC7C,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;QAC9B,CAAC;IACL,CAAC;CACJ;AAED,kBAAe,UAAU,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const projection_1 = __importDefault(require("./projection"));
|
|
16
|
+
/**
|
|
17
|
+
* Represents a RETURN operation that produces the final query results.
|
|
18
|
+
*
|
|
19
|
+
* The RETURN operation evaluates expressions and collects them into result records.
|
|
20
|
+
* It can optionally have a WHERE clause to filter results.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // RETURN x, y WHERE x > 0
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
class Return extends projection_1.default {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
this._where = null;
|
|
31
|
+
this._results = [];
|
|
32
|
+
}
|
|
33
|
+
set where(where) {
|
|
34
|
+
this._where = where;
|
|
35
|
+
}
|
|
36
|
+
get where() {
|
|
37
|
+
if (this._where === null) {
|
|
38
|
+
return true;
|
|
39
|
+
}
|
|
40
|
+
return this._where.value();
|
|
41
|
+
}
|
|
42
|
+
run() {
|
|
43
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
if (!this.where) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const record = new Map();
|
|
48
|
+
for (const [expression, alias] of this.expressions()) {
|
|
49
|
+
const value = expression.value();
|
|
50
|
+
record.set(alias, value);
|
|
51
|
+
}
|
|
52
|
+
this._results.push(Object.fromEntries(record));
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
get results() {
|
|
56
|
+
return this._results;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.default = Return;
|
|
60
|
+
//# sourceMappingURL=return.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"return.js","sourceRoot":"","sources":["../../../src/parsing/operations/return.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8DAAsC;AAGtC;;;;;;;;;;GAUG;AACH,MAAM,MAAO,SAAQ,oBAAU;IAA/B;;QACc,WAAM,GAAiB,IAAI,CAAC;QAC5B,aAAQ,GAA0B,EAAE,CAAC;IAwBnD,CAAC;IAvBG,IAAW,KAAK,CAAC,KAAY;QACzB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACxB,CAAC;IACD,IAAW,KAAK;QACZ,IAAG,IAAI,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YACtB,OAAO,IAAI,CAAC;QAChB,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IAC/B,CAAC;IACY,GAAG;;YACZ,IAAG,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;gBACb,OAAO;YACX,CAAC;YACD,MAAM,MAAM,GAAqB,IAAI,GAAG,EAAE,CAAC;YAC3C,KAAI,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;gBAClD,MAAM,KAAK,GAAQ,UAAU,CAAC,KAAK,EAAE,CAAC;gBACtC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;YAC7B,CAAC;YACD,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC;QACnD,CAAC;KAAA;IACD,IAAW,OAAO;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC;IACzB,CAAC;CACJ;AAED,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
16
|
+
class Unwind extends operation_1.default {
|
|
17
|
+
constructor(expression) {
|
|
18
|
+
super();
|
|
19
|
+
this.addChild(expression);
|
|
20
|
+
}
|
|
21
|
+
get expression() {
|
|
22
|
+
return this.children[0];
|
|
23
|
+
}
|
|
24
|
+
get as() {
|
|
25
|
+
return this.children[1].value;
|
|
26
|
+
}
|
|
27
|
+
run() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
var _a, _b;
|
|
30
|
+
const expression = this.expression.value();
|
|
31
|
+
if (!(Array.isArray(expression))) {
|
|
32
|
+
throw new Error('Expected array');
|
|
33
|
+
}
|
|
34
|
+
for (let i = 0; i < expression.length; i++) {
|
|
35
|
+
this._value = expression[i];
|
|
36
|
+
yield ((_a = this.next) === null || _a === void 0 ? void 0 : _a.run());
|
|
37
|
+
}
|
|
38
|
+
(_b = this.next) === null || _b === void 0 ? void 0 : _b.reset();
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
value() {
|
|
42
|
+
return this._value;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.default = Unwind;
|
|
46
|
+
//# sourceMappingURL=unwind.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"unwind.js","sourceRoot":"","sources":["../../../src/parsing/operations/unwind.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,4DAAoC;AAGpC,MAAM,MAAO,SAAQ,mBAAS;IAE1B,YAAY,UAAsB;QAC9B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IACD,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAe,CAAC;IAC1C,CAAC;IACD,IAAW,EAAE;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAA0B,CAAC;IACvD,CAAC;IACY,GAAG;;;YACZ,MAAM,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YAC3C,IAAG,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;YACtC,CAAC;YACD,KAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACxC,IAAI,CAAC,MAAM,GAAG,UAAU,CAAC,CAAC,CAAC,CAAC;gBAC5B,MAAM,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,GAAG,EAAE,CAAA,CAAC;YAC3B,CAAC;YACD,MAAA,IAAI,CAAC,IAAI,0CAAE,KAAK,EAAE,CAAC;QACvB,CAAC;KAAA;IACM,KAAK;QACR,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ;AAED,kBAAe,MAAM,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const operation_1 = __importDefault(require("./operation"));
|
|
16
|
+
/**
|
|
17
|
+
* Represents a WHERE operation that filters data based on a condition.
|
|
18
|
+
*
|
|
19
|
+
* The WHERE operation evaluates a boolean expression and only continues
|
|
20
|
+
* execution to the next operation if the condition is true.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // RETURN x WHERE x > 0
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
class Where extends operation_1.default {
|
|
28
|
+
/**
|
|
29
|
+
* Creates a new WHERE operation with the given condition.
|
|
30
|
+
*
|
|
31
|
+
* @param expression - The boolean expression to evaluate
|
|
32
|
+
*/
|
|
33
|
+
constructor(expression) {
|
|
34
|
+
super();
|
|
35
|
+
this.addChild(expression);
|
|
36
|
+
}
|
|
37
|
+
get expression() {
|
|
38
|
+
return this.children[0];
|
|
39
|
+
}
|
|
40
|
+
run() {
|
|
41
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
42
|
+
var _a;
|
|
43
|
+
if (this.expression.value()) {
|
|
44
|
+
yield ((_a = this.next) === null || _a === void 0 ? void 0 : _a.run());
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
value() {
|
|
49
|
+
return this.expression.value();
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.default = Where;
|
|
53
|
+
//# sourceMappingURL=where.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"where.js","sourceRoot":"","sources":["../../../src/parsing/operations/where.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,4DAAoC;AAGpC;;;;;;;;;;GAUG;AACH,MAAM,KAAM,SAAQ,mBAAS;IACzB;;;;OAIG;IACH,YAAY,UAAsB;QAC9B,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAC9B,CAAC;IACD,IAAW,UAAU;QACjB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAe,CAAC;IAC1C,CAAC;IACY,GAAG;;;YACZ,IAAG,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,EAAE,CAAC;gBACzB,MAAM,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,GAAG,EAAE,CAAA,CAAC;YAC3B,CAAC;QACL,CAAC;KAAA;IACM,KAAK;QACR,OAAO,IAAI,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;IACnC,CAAC;CACJ;AAED,kBAAe,KAAK,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
const projection_1 = __importDefault(require("./projection"));
|
|
16
|
+
/**
|
|
17
|
+
* Represents a WITH operation that defines variables or intermediate results.
|
|
18
|
+
*
|
|
19
|
+
* The WITH operation creates named expressions that can be referenced later in the query.
|
|
20
|
+
* It passes control to the next operation in the chain.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // WITH x = 1, y = 2 RETURN x + y
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
class With extends projection_1.default {
|
|
28
|
+
run() {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
var _a;
|
|
31
|
+
yield ((_a = this.next) === null || _a === void 0 ? void 0 : _a.run());
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
exports.default = With;
|
|
36
|
+
//# sourceMappingURL=with.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"with.js","sourceRoot":"","sources":["../../../src/parsing/operations/with.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,8DAAsC;AAEtC;;;;;;;;;;GAUG;AACH,MAAM,IAAK,SAAQ,oBAAU;IACZ,GAAG;;;YACZ,MAAM,CAAA,MAAA,IAAI,CAAC,IAAI,0CAAE,GAAG,EAAE,CAAA,CAAC;QAC3B,CAAC;KAAA;CACJ;AAED,kBAAe,IAAI,CAAC"}
|