flowquery 1.0.3 → 1.0.6
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/README.md +182 -0
- package/dist/compute/runner.d.ts +81 -0
- package/dist/compute/runner.d.ts.map +1 -0
- package/dist/extensibility.d.ts +9 -0
- package/dist/extensibility.d.ts.map +1 -0
- package/dist/extensibility.js +25 -0
- package/dist/extensibility.js.map +1 -0
- package/dist/flowquery.min.js +1 -1
- package/dist/index.browser.d.ts +10 -0
- package/dist/index.browser.d.ts.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.node.d.ts +14 -0
- package/dist/index.node.d.ts.map +1 -0
- package/dist/io/command_line.d.ts +28 -0
- package/dist/io/command_line.d.ts.map +1 -0
- package/dist/parsing/alias.d.ts +10 -0
- package/dist/parsing/alias.d.ts.map +1 -0
- package/dist/parsing/alias_option.d.ts +6 -0
- package/dist/parsing/alias_option.d.ts.map +1 -0
- package/dist/parsing/ast_node.d.ts +100 -0
- package/dist/parsing/ast_node.d.ts.map +1 -0
- package/dist/parsing/base_parser.d.ts +49 -0
- package/dist/parsing/base_parser.d.ts.map +1 -0
- package/dist/parsing/components/csv.d.ts +6 -0
- package/dist/parsing/components/csv.d.ts.map +1 -0
- package/dist/parsing/components/from.d.ts +7 -0
- package/dist/parsing/components/from.d.ts.map +1 -0
- package/dist/parsing/components/headers.d.ts +7 -0
- package/dist/parsing/components/headers.d.ts.map +1 -0
- package/dist/parsing/components/json.d.ts +6 -0
- package/dist/parsing/components/json.d.ts.map +1 -0
- package/dist/parsing/components/null.d.ts +6 -0
- package/dist/parsing/components/null.d.ts.map +1 -0
- package/dist/parsing/components/post.d.ts +6 -0
- package/dist/parsing/components/post.d.ts.map +1 -0
- package/dist/parsing/components/text.d.ts +6 -0
- package/dist/parsing/components/text.d.ts.map +1 -0
- package/dist/parsing/context.d.ts +38 -0
- package/dist/parsing/context.d.ts.map +1 -0
- package/dist/parsing/data_structures/associative_array.d.ts +28 -0
- package/dist/parsing/data_structures/associative_array.d.ts.map +1 -0
- package/dist/parsing/data_structures/json_array.d.ts +26 -0
- package/dist/parsing/data_structures/json_array.d.ts.map +1 -0
- package/dist/parsing/data_structures/key_value_pair.d.ts +25 -0
- package/dist/parsing/data_structures/key_value_pair.d.ts.map +1 -0
- package/dist/parsing/data_structures/lookup.d.ts +25 -0
- package/dist/parsing/data_structures/lookup.d.ts.map +1 -0
- package/dist/parsing/data_structures/range_lookup.d.ts +14 -0
- package/dist/parsing/data_structures/range_lookup.d.ts.map +1 -0
- package/dist/parsing/expressions/expression.d.ts +53 -0
- package/dist/parsing/expressions/expression.d.ts.map +1 -0
- package/dist/parsing/expressions/f_string.d.ts +21 -0
- package/dist/parsing/expressions/f_string.d.ts.map +1 -0
- package/dist/parsing/expressions/identifier.d.ts +17 -0
- package/dist/parsing/expressions/identifier.d.ts.map +1 -0
- package/dist/parsing/expressions/number.d.ts +25 -0
- package/dist/parsing/expressions/number.d.ts.map +1 -0
- package/dist/parsing/expressions/operator.d.ts +79 -0
- package/dist/parsing/expressions/operator.d.ts.map +1 -0
- package/dist/parsing/expressions/reference.d.ts +29 -0
- package/dist/parsing/expressions/reference.d.ts.map +1 -0
- package/dist/parsing/expressions/string.d.ts +23 -0
- package/dist/parsing/expressions/string.d.ts.map +1 -0
- package/dist/parsing/functions/aggregate_function.d.ts +42 -0
- package/dist/parsing/functions/aggregate_function.d.ts.map +1 -0
- package/dist/parsing/functions/async_function.d.ts +52 -0
- package/dist/parsing/functions/async_function.d.ts.map +1 -0
- package/dist/parsing/functions/avg.d.ts +15 -0
- package/dist/parsing/functions/avg.d.ts.map +1 -0
- package/dist/parsing/functions/avg.js +20 -2
- package/dist/parsing/functions/avg.js.map +1 -1
- package/dist/parsing/functions/collect.d.ts +21 -0
- package/dist/parsing/functions/collect.d.ts.map +1 -0
- package/dist/parsing/functions/collect.js +20 -2
- package/dist/parsing/functions/collect.js.map +1 -1
- package/dist/parsing/functions/extensibility/index.d.ts +37 -0
- package/dist/parsing/functions/extensibility/index.d.ts.map +1 -0
- package/dist/parsing/functions/extensibility/index.js +50 -0
- package/dist/parsing/functions/extensibility/index.js.map +1 -0
- package/dist/parsing/functions/function.d.ts +36 -0
- package/dist/parsing/functions/function.d.ts.map +1 -0
- package/dist/parsing/functions/function_factory.d.ts +174 -0
- package/dist/parsing/functions/function_factory.d.ts.map +1 -0
- package/dist/parsing/functions/function_factory.js +44 -47
- package/dist/parsing/functions/function_factory.js.map +1 -1
- package/dist/parsing/functions/function_metadata.d.ts +134 -0
- package/dist/parsing/functions/function_metadata.d.ts.map +1 -0
- package/dist/parsing/functions/function_metadata.js +103 -153
- package/dist/parsing/functions/function_metadata.js.map +1 -1
- package/dist/parsing/functions/functions.d.ts +21 -0
- package/dist/parsing/functions/functions.d.ts.map +1 -0
- package/dist/parsing/functions/functions.js +37 -2
- package/dist/parsing/functions/functions.js.map +1 -1
- package/dist/parsing/functions/join.d.ts +9 -0
- package/dist/parsing/functions/join.d.ts.map +1 -0
- package/dist/parsing/functions/join.js +21 -2
- package/dist/parsing/functions/join.js.map +1 -1
- package/dist/parsing/functions/predicate_function.d.ts +19 -0
- package/dist/parsing/functions/predicate_function.d.ts.map +1 -0
- package/dist/parsing/functions/predicate_function.js +3 -0
- package/dist/parsing/functions/predicate_function.js.map +1 -1
- package/dist/parsing/functions/predicate_sum.d.ts +7 -0
- package/dist/parsing/functions/predicate_sum.d.ts.map +1 -0
- package/dist/parsing/functions/predicate_sum.js +23 -2
- package/dist/parsing/functions/predicate_sum.js.map +1 -1
- package/dist/parsing/functions/rand.d.ts +7 -0
- package/dist/parsing/functions/rand.d.ts.map +1 -0
- package/dist/parsing/functions/rand.js +18 -2
- package/dist/parsing/functions/rand.js.map +1 -1
- package/dist/parsing/functions/range.d.ts +7 -0
- package/dist/parsing/functions/range.d.ts.map +1 -0
- package/dist/parsing/functions/range.js +21 -2
- package/dist/parsing/functions/range.js.map +1 -1
- package/dist/parsing/functions/reducer_element.d.ts +6 -0
- package/dist/parsing/functions/reducer_element.d.ts.map +1 -0
- package/dist/parsing/functions/replace.d.ts +7 -0
- package/dist/parsing/functions/replace.d.ts.map +1 -0
- package/dist/parsing/functions/replace.js +22 -2
- package/dist/parsing/functions/replace.js.map +1 -1
- package/dist/parsing/functions/round.d.ts +7 -0
- package/dist/parsing/functions/round.d.ts.map +1 -0
- package/dist/parsing/functions/round.js +20 -2
- package/dist/parsing/functions/round.js.map +1 -1
- package/dist/parsing/functions/size.d.ts +7 -0
- package/dist/parsing/functions/size.d.ts.map +1 -0
- package/dist/parsing/functions/size.js +20 -2
- package/dist/parsing/functions/size.js.map +1 -1
- package/dist/parsing/functions/split.d.ts +9 -0
- package/dist/parsing/functions/split.d.ts.map +1 -0
- package/dist/parsing/functions/split.js +21 -2
- package/dist/parsing/functions/split.js.map +1 -1
- package/dist/parsing/functions/stringify.d.ts +9 -0
- package/dist/parsing/functions/stringify.d.ts.map +1 -0
- package/dist/parsing/functions/stringify.js +20 -2
- package/dist/parsing/functions/stringify.js.map +1 -1
- package/dist/parsing/functions/sum.d.ts +14 -0
- package/dist/parsing/functions/sum.d.ts.map +1 -0
- package/dist/parsing/functions/sum.js +20 -2
- package/dist/parsing/functions/sum.js.map +1 -1
- package/dist/parsing/functions/to_json.d.ts +7 -0
- package/dist/parsing/functions/to_json.d.ts.map +1 -0
- package/dist/parsing/functions/to_json.js +20 -2
- package/dist/parsing/functions/to_json.js.map +1 -1
- package/dist/parsing/functions/value_holder.d.ts +8 -0
- package/dist/parsing/functions/value_holder.d.ts.map +1 -0
- package/dist/parsing/logic/case.d.ts +7 -0
- package/dist/parsing/logic/case.d.ts.map +1 -0
- package/dist/parsing/logic/else.d.ts +7 -0
- package/dist/parsing/logic/else.d.ts.map +1 -0
- package/dist/parsing/logic/end.d.ts +6 -0
- package/dist/parsing/logic/end.d.ts.map +1 -0
- package/dist/parsing/logic/then.d.ts +7 -0
- package/dist/parsing/logic/then.d.ts.map +1 -0
- package/dist/parsing/logic/when.d.ts +7 -0
- package/dist/parsing/logic/when.d.ts.map +1 -0
- package/dist/parsing/operations/aggregated_return.d.ts +8 -0
- package/dist/parsing/operations/aggregated_return.d.ts.map +1 -0
- package/dist/parsing/operations/aggregated_with.d.ts +8 -0
- package/dist/parsing/operations/aggregated_with.d.ts.map +1 -0
- package/dist/parsing/operations/group_by.d.ts +35 -0
- package/dist/parsing/operations/group_by.d.ts.map +1 -0
- package/dist/parsing/operations/limit.d.ts +10 -0
- package/dist/parsing/operations/limit.d.ts.map +1 -0
- package/dist/parsing/operations/load.d.ts +48 -0
- package/dist/parsing/operations/load.d.ts.map +1 -0
- package/dist/parsing/operations/operation.d.ts +39 -0
- package/dist/parsing/operations/operation.d.ts.map +1 -0
- package/dist/parsing/operations/projection.d.ts +8 -0
- package/dist/parsing/operations/projection.d.ts.map +1 -0
- package/dist/parsing/operations/return.d.ts +23 -0
- package/dist/parsing/operations/return.d.ts.map +1 -0
- package/dist/parsing/operations/unwind.d.ts +12 -0
- package/dist/parsing/operations/unwind.d.ts.map +1 -0
- package/dist/parsing/operations/where.d.ts +26 -0
- package/dist/parsing/operations/where.d.ts.map +1 -0
- package/dist/parsing/operations/with.d.ts +17 -0
- package/dist/parsing/operations/with.d.ts.map +1 -0
- package/dist/parsing/parser.d.ts +66 -0
- package/dist/parsing/parser.d.ts.map +1 -0
- package/dist/parsing/parser.js +2 -3
- package/dist/parsing/parser.js.map +1 -1
- package/dist/parsing/token_to_node.d.ts +7 -0
- package/dist/parsing/token_to_node.d.ts.map +1 -0
- package/dist/tokenization/keyword.d.ts +43 -0
- package/dist/tokenization/keyword.d.ts.map +1 -0
- package/dist/tokenization/operator.d.ts +22 -0
- package/dist/tokenization/operator.d.ts.map +1 -0
- package/dist/tokenization/string_walker.d.ts +55 -0
- package/dist/tokenization/string_walker.d.ts.map +1 -0
- package/dist/tokenization/symbol.d.ts +15 -0
- package/dist/tokenization/symbol.d.ts.map +1 -0
- package/dist/tokenization/token.d.ts +176 -0
- package/dist/tokenization/token.d.ts.map +1 -0
- package/dist/tokenization/token_mapper.d.ts +40 -0
- package/dist/tokenization/token_mapper.d.ts.map +1 -0
- package/dist/tokenization/token_type.d.ts +16 -0
- package/dist/tokenization/token_type.d.ts.map +1 -0
- package/dist/tokenization/tokenizer.d.ts +45 -0
- package/dist/tokenization/tokenizer.d.ts.map +1 -0
- package/dist/tokenization/trie.d.ts +41 -0
- package/dist/tokenization/trie.d.ts.map +1 -0
- package/dist/utils/object_utils.d.ts +15 -0
- package/dist/utils/object_utils.d.ts.map +1 -0
- package/dist/utils/string_utils.d.ts +51 -0
- package/dist/utils/string_utils.d.ts.map +1 -0
- package/docs/flowquery.min.js +1 -1
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
- package/misc/apps/RAG/.env.example +14 -0
- package/misc/apps/RAG/README.md +0 -7
- package/misc/apps/RAG/package.json +16 -7
- package/misc/apps/RAG/public/index.html +18 -0
- package/misc/apps/RAG/src/App.css +42 -0
- package/misc/apps/RAG/src/App.tsx +50 -0
- package/misc/apps/RAG/src/components/ApiKeySettings.tsx +245 -0
- package/misc/apps/RAG/src/components/ChatContainer.css +67 -0
- package/misc/apps/RAG/src/components/ChatContainer.tsx +239 -0
- package/misc/apps/RAG/src/components/ChatInput.css +23 -0
- package/misc/apps/RAG/src/components/ChatInput.tsx +62 -0
- package/misc/apps/RAG/src/components/ChatMessage.css +136 -0
- package/misc/apps/RAG/src/components/ChatMessage.tsx +152 -0
- package/misc/apps/RAG/src/components/FlowQueryAgent.ts +390 -0
- package/misc/apps/RAG/src/components/FlowQueryRunner.css +104 -0
- package/misc/apps/RAG/src/components/FlowQueryRunner.tsx +332 -0
- package/misc/apps/RAG/src/components/index.ts +15 -0
- package/misc/apps/RAG/src/index.tsx +17 -0
- package/misc/apps/RAG/src/plugins/PluginRegistry.ts +136 -0
- package/misc/apps/RAG/src/plugins/README.md +139 -0
- package/misc/apps/RAG/src/plugins/index.ts +72 -0
- package/misc/apps/RAG/src/plugins/loaders/CatFacts.ts +79 -0
- package/misc/apps/RAG/src/plugins/loaders/FetchJson.ts +71 -0
- package/misc/apps/RAG/src/plugins/loaders/Llm.ts +441 -0
- package/misc/apps/RAG/src/plugins/loaders/MockData.ts +161 -0
- package/misc/apps/RAG/src/plugins/types.ts +52 -0
- package/misc/apps/RAG/src/prompts/FlowQuerySystemPrompt.ts +385 -0
- package/misc/apps/RAG/src/prompts/index.ts +10 -0
- package/misc/apps/RAG/src/utils/FlowQueryExecutor.ts +131 -0
- package/misc/apps/RAG/src/utils/FlowQueryExtractor.ts +203 -0
- package/misc/apps/RAG/src/utils/index.ts +9 -0
- package/misc/apps/RAG/tsconfig.json +4 -2
- package/misc/apps/RAG/webpack.config.js +23 -12
- package/package.json +7 -1
- package/src/extensibility.ts +9 -0
- package/src/parsing/functions/avg.ts +10 -0
- package/src/parsing/functions/collect.ts +10 -0
- package/src/parsing/functions/extensibility/index.ts +54 -0
- package/src/parsing/functions/function_factory.ts +51 -48
- package/src/parsing/functions/function_metadata.ts +132 -156
- package/src/parsing/functions/functions.ts +27 -0
- package/src/parsing/functions/join.ts +11 -0
- package/src/parsing/functions/predicate_function.ts +4 -0
- package/src/parsing/functions/predicate_sum.ts +13 -0
- package/src/parsing/functions/rand.ts +8 -0
- package/src/parsing/functions/range.ts +11 -0
- package/src/parsing/functions/replace.ts +12 -0
- package/src/parsing/functions/round.ts +10 -0
- package/src/parsing/functions/size.ts +10 -0
- package/src/parsing/functions/split.ts +11 -0
- package/src/parsing/functions/stringify.ts +10 -0
- package/src/parsing/functions/sum.ts +10 -0
- package/src/parsing/functions/to_json.ts +10 -0
- package/src/parsing/parser.ts +2 -3
- package/tests/parsing/function_plugins.test.ts +11 -11
- package/tsconfig.json +4 -1
- package/dist/parsing/functions/predicate_function_factory.js +0 -19
- package/dist/parsing/functions/predicate_function_factory.js.map +0 -1
- package/misc/apps/RAG/src/index.ts +0 -20
- package/src/parsing/functions/predicate_function_factory.ts +0 -15
|
@@ -3,20 +3,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const sum_1 = __importDefault(require("./sum"));
|
|
7
|
-
const collect_1 = __importDefault(require("./collect"));
|
|
8
|
-
const avg_1 = __importDefault(require("./avg"));
|
|
9
|
-
const range_1 = __importDefault(require("./range"));
|
|
10
|
-
const rand_1 = __importDefault(require("./rand"));
|
|
11
|
-
const round_1 = __importDefault(require("./round"));
|
|
12
|
-
const split_1 = __importDefault(require("./split"));
|
|
13
|
-
const join_1 = __importDefault(require("./join"));
|
|
14
|
-
const to_json_1 = __importDefault(require("./to_json"));
|
|
15
|
-
const replace_1 = __importDefault(require("./replace"));
|
|
16
|
-
const stringify_1 = __importDefault(require("./stringify"));
|
|
17
|
-
const size_1 = __importDefault(require("./size"));
|
|
18
|
-
const functions_1 = __importDefault(require("./functions"));
|
|
19
6
|
const function_1 = __importDefault(require("./function"));
|
|
7
|
+
const predicate_function_1 = __importDefault(require("./predicate_function"));
|
|
8
|
+
// Import built-in functions to ensure their @FunctionDef decorators run
|
|
9
|
+
require("./sum");
|
|
10
|
+
require("./collect");
|
|
11
|
+
require("./avg");
|
|
12
|
+
require("./range");
|
|
13
|
+
require("./rand");
|
|
14
|
+
require("./round");
|
|
15
|
+
require("./split");
|
|
16
|
+
require("./join");
|
|
17
|
+
require("./to_json");
|
|
18
|
+
require("./replace");
|
|
19
|
+
require("./stringify");
|
|
20
|
+
require("./size");
|
|
21
|
+
require("./functions");
|
|
22
|
+
require("./predicate_sum");
|
|
20
23
|
const function_metadata_1 = require("./function_metadata");
|
|
21
24
|
/**
|
|
22
25
|
* Factory for creating function instances by name.
|
|
@@ -143,8 +146,8 @@ class FunctionFactory {
|
|
|
143
146
|
if (FunctionFactory.metadata.has(lowerName)) {
|
|
144
147
|
return FunctionFactory.metadata.get(lowerName);
|
|
145
148
|
}
|
|
146
|
-
// Fall back to
|
|
147
|
-
return function_metadata_1.
|
|
149
|
+
// Fall back to decorator-registered metadata
|
|
150
|
+
return (0, function_metadata_1.getFunctionMetadata)(lowerName);
|
|
148
151
|
}
|
|
149
152
|
/**
|
|
150
153
|
* Lists all registered functions with their metadata.
|
|
@@ -156,9 +159,9 @@ class FunctionFactory {
|
|
|
156
159
|
static listFunctions(options) {
|
|
157
160
|
const result = [];
|
|
158
161
|
const includeBuiltins = (options === null || options === void 0 ? void 0 : options.includeBuiltins) !== false;
|
|
159
|
-
// Add
|
|
162
|
+
// Add decorator-registered functions (built-ins)
|
|
160
163
|
if (includeBuiltins) {
|
|
161
|
-
for (const meta of function_metadata_1.
|
|
164
|
+
for (const meta of (0, function_metadata_1.getRegisteredFunctionMetadata)()) {
|
|
162
165
|
if ((options === null || options === void 0 ? void 0 : options.category) && meta.category !== options.category)
|
|
163
166
|
continue;
|
|
164
167
|
if (options === null || options === void 0 ? void 0 : options.asyncOnly)
|
|
@@ -184,7 +187,7 @@ class FunctionFactory {
|
|
|
184
187
|
* @returns Array of function names
|
|
185
188
|
*/
|
|
186
189
|
static listFunctionNames() {
|
|
187
|
-
const builtinNames = function_metadata_1.
|
|
190
|
+
const builtinNames = (0, function_metadata_1.getRegisteredFunctionMetadata)().map(m => m.name);
|
|
188
191
|
const pluginNames = Array.from(FunctionFactory.plugins.keys());
|
|
189
192
|
const asyncNames = Array.from(FunctionFactory.asyncProviders.keys());
|
|
190
193
|
return [...new Set([...builtinNames, ...pluginNames, ...asyncNames])];
|
|
@@ -211,36 +214,30 @@ class FunctionFactory {
|
|
|
211
214
|
if (FunctionFactory.plugins.has(lowerName)) {
|
|
212
215
|
return FunctionFactory.plugins.get(lowerName)();
|
|
213
216
|
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
return new collect_1.default();
|
|
219
|
-
case "avg":
|
|
220
|
-
return new avg_1.default();
|
|
221
|
-
case "range":
|
|
222
|
-
return new range_1.default();
|
|
223
|
-
case "rand":
|
|
224
|
-
return new rand_1.default();
|
|
225
|
-
case "round":
|
|
226
|
-
return new round_1.default();
|
|
227
|
-
case "split":
|
|
228
|
-
return new split_1.default();
|
|
229
|
-
case "join":
|
|
230
|
-
return new join_1.default();
|
|
231
|
-
case "tojson":
|
|
232
|
-
return new to_json_1.default();
|
|
233
|
-
case "replace":
|
|
234
|
-
return new replace_1.default();
|
|
235
|
-
case "stringify":
|
|
236
|
-
return new stringify_1.default();
|
|
237
|
-
case "size":
|
|
238
|
-
return new size_1.default();
|
|
239
|
-
case "functions":
|
|
240
|
-
return new functions_1.default();
|
|
241
|
-
default:
|
|
242
|
-
return new function_1.default(name);
|
|
217
|
+
// Check decorator-registered functions (built-ins use @FunctionDef)
|
|
218
|
+
const decoratorFactory = (0, function_metadata_1.getRegisteredFunctionFactory)(lowerName);
|
|
219
|
+
if (decoratorFactory) {
|
|
220
|
+
return decoratorFactory();
|
|
243
221
|
}
|
|
222
|
+
// Unknown function - return generic Function instance
|
|
223
|
+
return new function_1.default(name);
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Creates a predicate function instance by name.
|
|
227
|
+
* Predicate functions are used in WHERE clauses with quantifiers (e.g., ANY, ALL).
|
|
228
|
+
*
|
|
229
|
+
* @param name - The function name (case-insensitive)
|
|
230
|
+
* @returns A PredicateFunction instance of the appropriate type
|
|
231
|
+
*/
|
|
232
|
+
static createPredicate(name) {
|
|
233
|
+
const lowerName = name.toLowerCase();
|
|
234
|
+
// Check decorator-registered predicate functions
|
|
235
|
+
const decoratorFactory = (0, function_metadata_1.getRegisteredFunctionFactory)(lowerName, 'predicate');
|
|
236
|
+
if (decoratorFactory) {
|
|
237
|
+
return decoratorFactory();
|
|
238
|
+
}
|
|
239
|
+
// Unknown predicate function - return generic PredicateFunction instance
|
|
240
|
+
return new predicate_function_1.default(name);
|
|
244
241
|
}
|
|
245
242
|
}
|
|
246
243
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function_factory.js","sourceRoot":"","sources":["../../../src/parsing/functions/function_factory.ts"],"names":[],"mappings":";;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"function_factory.js","sourceRoot":"","sources":["../../../src/parsing/functions/function_factory.ts"],"names":[],"mappings":";;;;;AAAA,0DAAkC;AAClC,8EAAqD;AACrD,wEAAwE;AACxE,iBAAe;AACf,qBAAmB;AACnB,iBAAe;AACf,mBAAiB;AACjB,kBAAgB;AAChB,mBAAiB;AACjB,mBAAiB;AACjB,kBAAgB;AAChB,qBAAmB;AACnB,qBAAmB;AACnB,uBAAqB;AACrB,kBAAgB;AAChB,uBAAqB;AACrB,2BAAyB;AACzB,2DAO6B;AAa7B;;;;;;;;;;;GAWG;AACH,MAAM,eAAe;IAgBjB;;;;;OAKG;IACI,MAAM,CAAC,QAAQ,CAAC,IAAY,EAAE,gBAA2D;QAC5F,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACrC,IAAI,OAAO,gBAAgB,KAAK,UAAU,EAAE,CAAC;YACzC,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,gBAAgB,CAAC,CAAC;QAC7D,CAAC;aAAM,CAAC;YACJ,eAAe,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC;YACjE,eAAe,CAAC,QAAQ,CAAC,GAAG,CAAC,SAAS,kCAC/B,gBAAgB,CAAC,QAAQ,KAC5B,IAAI,EAAE,SAAS,EACf,eAAe,EAAE,KAAK,IACxB,CAAC;QACP,CAAC;IACL,CAAC;IAED;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,IAAY;QACjC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACrC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;QAC1C,eAAe,C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AAC;QAED,oEAAoE;QACpE,MAAM,gBAAgB,GAAG,IAAA,gDAA4B,EAAC,SAAS,CAAC,CAAC;QACjE,IAAI,gBAAgB,EAAE,CAAC;YACnB,OAAO,gBAAgB,EAAE,CAAC;QAC9B,CAAC;QAED,sDAAsD;QACtD,OAAO,IAAI,kBAAQ,CAAC,IAAI,CAAC,CAAC;IAC9B,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,eAAe,CAAC,IAAY;QACtC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAErC,iDAAiD;QACjD,MAAM,gBAAgB,GAAG,IAAA,gDAA4B,EAAC,SAAS,EAAE,WAAW,CAAC,CAAC;QAC9E,IAAI,gBAAgB,EAAE,CAAC;YACnB,OAAO,gBAAgB,EAAE,CAAC;QAC9B,CAAC;QAED,yEAAyE;QACzE,OAAO,IAAI,4BAAiB,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;;AApPD;;GAEG;AACY,uBAAO,GAAiC,IAAI,GAAG,EAAE,CAAC;AAEjE;;GAEG;AACY,8BAAc,GAAmC,IAAI,GAAG,EAAE,CAAC;AAE1E;;GAEG;AACY,wBAAQ,GAAkC,IAAI,GAAG,EAAE,CAAC;AA0OvE,kBAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Category types for functions.
|
|
3
|
+
* Core categories: scalar, aggregate, predicate, async
|
|
4
|
+
* Additional categories for organization: string, math, data, etc.
|
|
5
|
+
*/
|
|
6
|
+
export type FunctionCategory = "scalar" | "aggregate" | "predicate" | "async" | "string" | "math" | "data" | "introspection" | string;
|
|
7
|
+
/**
|
|
8
|
+
* Schema definition for function arguments and outputs.
|
|
9
|
+
* Compatible with JSON Schema for LLM consumption.
|
|
10
|
+
*/
|
|
11
|
+
export interface ParameterSchema {
|
|
12
|
+
/** The parameter name */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Description of the parameter */
|
|
15
|
+
description: string;
|
|
16
|
+
/** JSON Schema type: string, number, boolean, object, array, null */
|
|
17
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "null" | string;
|
|
18
|
+
/** Whether the parameter is required (default: true) */
|
|
19
|
+
required?: boolean;
|
|
20
|
+
/** Default value if not provided */
|
|
21
|
+
default?: any;
|
|
22
|
+
/** For arrays, the schema of items */
|
|
23
|
+
items?: Omit<ParameterSchema, 'name' | 'required' | 'default'>;
|
|
24
|
+
/** For objects, the properties schema */
|
|
25
|
+
properties?: Record<string, Omit<ParameterSchema, 'name' | 'required'>>;
|
|
26
|
+
/** Enum of allowed values */
|
|
27
|
+
enum?: any[];
|
|
28
|
+
/** Example value */
|
|
29
|
+
example?: any;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Schema definition for function output.
|
|
33
|
+
*/
|
|
34
|
+
export interface OutputSchema {
|
|
35
|
+
/** Description of the output */
|
|
36
|
+
description: string;
|
|
37
|
+
/** JSON Schema type */
|
|
38
|
+
type: "string" | "number" | "boolean" | "object" | "array" | "null" | string;
|
|
39
|
+
/** For arrays, the schema of items */
|
|
40
|
+
items?: Omit<OutputSchema, 'description'>;
|
|
41
|
+
/** For objects, the properties schema */
|
|
42
|
+
properties?: Record<string, Omit<ParameterSchema, 'name' | 'required'>>;
|
|
43
|
+
/** Example output value */
|
|
44
|
+
example?: any;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Metadata for a registered function, designed for LLM consumption.
|
|
48
|
+
*/
|
|
49
|
+
export interface FunctionMetadata {
|
|
50
|
+
/** The function name */
|
|
51
|
+
name: string;
|
|
52
|
+
/** Human-readable description of what the function does */
|
|
53
|
+
description: string;
|
|
54
|
+
/** Category for grouping functions */
|
|
55
|
+
category?: FunctionCategory;
|
|
56
|
+
/** Array of parameter schemas */
|
|
57
|
+
parameters: ParameterSchema[];
|
|
58
|
+
/** Output schema */
|
|
59
|
+
output: OutputSchema;
|
|
60
|
+
/** Example usage in FlowQuery syntax */
|
|
61
|
+
examples?: string[];
|
|
62
|
+
/** Additional notes or caveats */
|
|
63
|
+
notes?: string;
|
|
64
|
+
/** Whether this is an async data provider (for LOAD operations) */
|
|
65
|
+
isAsyncProvider?: boolean;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Options for registering a sync function with metadata.
|
|
69
|
+
*/
|
|
70
|
+
export interface RegisterFunctionOptions {
|
|
71
|
+
/** Factory function that creates the Function instance */
|
|
72
|
+
factory: () => any;
|
|
73
|
+
/** Function metadata for documentation */
|
|
74
|
+
metadata: FunctionMetadata;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Options for registering an async data provider with metadata.
|
|
78
|
+
*/
|
|
79
|
+
export interface RegisterAsyncProviderOptions {
|
|
80
|
+
/** Async generator or function that returns data */
|
|
81
|
+
provider: (...args: any[]) => AsyncGenerator<any, void, unknown> | Promise<any>;
|
|
82
|
+
/** Function metadata for documentation */
|
|
83
|
+
metadata: FunctionMetadata;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Decorator options - metadata without the name (derived from class).
|
|
87
|
+
*/
|
|
88
|
+
export type FunctionDefOptions = Omit<FunctionMetadata, 'name'>;
|
|
89
|
+
/**
|
|
90
|
+
* Class decorator that registers function metadata.
|
|
91
|
+
* The function name is derived from the class's constructor call to super().
|
|
92
|
+
*
|
|
93
|
+
* @param options - Function metadata (excluding name)
|
|
94
|
+
* @returns Class decorator
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* @FunctionDef({
|
|
99
|
+
* description: "Calculates the sum of numeric values",
|
|
100
|
+
* category: "aggregate",
|
|
101
|
+
* parameters: [{ name: "value", description: "Numeric value to sum", type: "number" }],
|
|
102
|
+
* output: { description: "Sum of all values", type: "number", example: 150 },
|
|
103
|
+
* examples: ["WITH [1, 2, 3] AS nums UNWIND nums AS n RETURN sum(n)"]
|
|
104
|
+
* })
|
|
105
|
+
* class Sum extends AggregateFunction { ... }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
export declare function FunctionDef(options: FunctionDefOptions): <T extends new (...args: any[]) => any>(constructor: T) => T;
|
|
109
|
+
/**
|
|
110
|
+
* Gets all registered function metadata from decorators.
|
|
111
|
+
*
|
|
112
|
+
* @returns Array of function metadata
|
|
113
|
+
*/
|
|
114
|
+
export declare function getRegisteredFunctionMetadata(): FunctionMetadata[];
|
|
115
|
+
/**
|
|
116
|
+
* Gets a registered function factory by name.
|
|
117
|
+
* Used by FunctionFactory to instantiate decorator-registered functions.
|
|
118
|
+
*
|
|
119
|
+
* @param name - Function name (case-insensitive)
|
|
120
|
+
* @param category - Optional category to disambiguate (e.g., 'predicate')
|
|
121
|
+
* @returns Factory function or undefined
|
|
122
|
+
*/
|
|
123
|
+
export declare function getRegisteredFunctionFactory(name: string, category?: string): (() => any) | undefined;
|
|
124
|
+
/**
|
|
125
|
+
* Gets metadata for a specific function by name.
|
|
126
|
+
* If multiple functions share the same name (e.g., aggregate vs predicate),
|
|
127
|
+
* optionally specify the category to get the specific one.
|
|
128
|
+
*
|
|
129
|
+
* @param name - Function name (case-insensitive)
|
|
130
|
+
* @param category - Optional category to disambiguate
|
|
131
|
+
* @returns Function metadata or undefined
|
|
132
|
+
*/
|
|
133
|
+
export declare function getFunctionMetadata(name: string, category?: string): FunctionMetadata | undefined;
|
|
134
|
+
//# sourceMappingURL=function_metadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"function_metadata.d.ts","sourceRoot":"","sources":["../../../src/parsing/functions/function_metadata.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,WAAW,GAAG,WAAW,GAAG,OAAO,GAAG,QAAQ,GAAG,MAAM,GAAG,MAAM,GAAG,eAAe,GAAG,MAAM,CAAC;AAEtI;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC5B,yBAAyB;IACzB,IAAI,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E,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,gBAAgB,GAAG,SAAS,CAiBjG"}
|
|
@@ -1,159 +1,109 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.FunctionDef = FunctionDef;
|
|
4
|
+
exports.getRegisteredFunctionMetadata = getRegisteredFunctionMetadata;
|
|
5
|
+
exports.getRegisteredFunctionFactory = getRegisteredFunctionFactory;
|
|
6
|
+
exports.getFunctionMetadata = getFunctionMetadata;
|
|
4
7
|
/**
|
|
5
|
-
*
|
|
8
|
+
* Registry for function metadata collected via decorators.
|
|
6
9
|
*/
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
name
|
|
40
|
-
|
|
41
|
-
category:
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
description: "Converts a value to its JSON string representation",
|
|
104
|
-
category: "conversion",
|
|
105
|
-
parameters: [
|
|
106
|
-
{ name: "value", description: "Value to stringify", type: "any" }
|
|
107
|
-
],
|
|
108
|
-
output: { description: "JSON string", type: "string", example: "{\"a\":1}" },
|
|
109
|
-
examples: ["WITH {a: 1} AS obj RETURN stringify(obj)"]
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
name: "tojson",
|
|
113
|
-
description: "Parses a JSON string into an object",
|
|
114
|
-
category: "conversion",
|
|
115
|
-
parameters: [
|
|
116
|
-
{ name: "text", description: "JSON string to parse", type: "string" }
|
|
117
|
-
],
|
|
118
|
-
output: { description: "Parsed object or array", type: "object", example: { a: 1 } },
|
|
119
|
-
examples: ["WITH '{\"a\": 1}' AS s RETURN tojson(s)"]
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
name: "size",
|
|
123
|
-
description: "Returns the length of an array or string",
|
|
124
|
-
category: "utility",
|
|
125
|
-
parameters: [
|
|
126
|
-
{ name: "value", description: "Array or string to measure", type: "array" }
|
|
127
|
-
],
|
|
128
|
-
output: { description: "Length of the input", type: "number", example: 3 },
|
|
129
|
-
examples: ["WITH [1, 2, 3] AS arr RETURN size(arr)"]
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
name: "functions",
|
|
133
|
-
description: "Lists all registered functions with their metadata. Useful for discovering available functions and their documentation. Results include name, description, parameters, output schema, and usage examples.",
|
|
134
|
-
category: "introspection",
|
|
135
|
-
parameters: [
|
|
136
|
-
{ name: "category", description: "Optional category to filter by (e.g., 'aggregation', 'string', 'math')", type: "string", required: false }
|
|
137
|
-
],
|
|
138
|
-
output: {
|
|
139
|
-
description: "Array of function metadata objects",
|
|
140
|
-
type: "array",
|
|
141
|
-
items: {
|
|
142
|
-
type: "object",
|
|
143
|
-
properties: {
|
|
144
|
-
name: { description: "Function name", type: "string" },
|
|
145
|
-
description: { description: "What the function does", type: "string" },
|
|
146
|
-
category: { description: "Function category", type: "string" },
|
|
147
|
-
parameters: { description: "Array of parameter definitions", type: "array" },
|
|
148
|
-
output: { description: "Output schema", type: "object" },
|
|
149
|
-
examples: { description: "Usage examples", type: "array" }
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
examples: [
|
|
154
|
-
"WITH functions() AS funcs RETURN funcs",
|
|
155
|
-
"WITH functions('aggregation') AS funcs UNWIND funcs AS f RETURN f.name, f.description"
|
|
156
|
-
]
|
|
10
|
+
const functionMetadataRegistry = new Map();
|
|
11
|
+
/**
|
|
12
|
+
* Registry for function factories collected via decorators.
|
|
13
|
+
* Allows @FunctionDef to automatically register functions for instantiation.
|
|
14
|
+
*/
|
|
15
|
+
const functionFactoryRegistry = new Map();
|
|
16
|
+
/**
|
|
17
|
+
* Class decorator that registers function metadata.
|
|
18
|
+
* The function name is derived from the class's constructor call to super().
|
|
19
|
+
*
|
|
20
|
+
* @param options - Function metadata (excluding name)
|
|
21
|
+
* @returns Class decorator
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```typescript
|
|
25
|
+
* @FunctionDef({
|
|
26
|
+
* description: "Calculates the sum of numeric values",
|
|
27
|
+
* category: "aggregate",
|
|
28
|
+
* parameters: [{ name: "value", description: "Numeric value to sum", type: "number" }],
|
|
29
|
+
* output: { description: "Sum of all values", type: "number", example: 150 },
|
|
30
|
+
* examples: ["WITH [1, 2, 3] AS nums UNWIND nums AS n RETURN sum(n)"]
|
|
31
|
+
* })
|
|
32
|
+
* class Sum extends AggregateFunction { ... }
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
function FunctionDef(options) {
|
|
36
|
+
return function (constructor) {
|
|
37
|
+
var _a;
|
|
38
|
+
// Create an instance to get the function name from super() call
|
|
39
|
+
const instance = new constructor();
|
|
40
|
+
const baseName = ((_a = instance.name) === null || _a === void 0 ? void 0 : _a.toLowerCase()) || constructor.name.toLowerCase();
|
|
41
|
+
// Use category-qualified key to avoid collisions (e.g., sum vs sum:predicate)
|
|
42
|
+
// but store the display name without the qualifier
|
|
43
|
+
const displayName = baseName.includes(':') ? baseName.split(':')[0] : baseName;
|
|
44
|
+
const registryKey = options.category ? `${displayName}:${options.category}` : displayName;
|
|
45
|
+
// Register metadata with display name but category-qualified key
|
|
46
|
+
const metadata = Object.assign({ name: displayName }, options);
|
|
47
|
+
functionMetadataRegistry.set(registryKey, metadata);
|
|
48
|
+
// Register factory function for automatic instantiation
|
|
49
|
+
// Only register to the simple name if no collision exists (predicate functions use qualified keys)
|
|
50
|
+
if (options.category !== 'predicate') {
|
|
51
|
+
functionFactoryRegistry.set(displayName, () => new constructor());
|
|
52
|
+
}
|
|
53
|
+
functionFactoryRegistry.set(registryKey, () => new constructor());
|
|
54
|
+
return constructor;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Gets all registered function metadata from decorators.
|
|
59
|
+
*
|
|
60
|
+
* @returns Array of function metadata
|
|
61
|
+
*/
|
|
62
|
+
function getRegisteredFunctionMetadata() {
|
|
63
|
+
return Array.from(functionMetadataRegistry.values());
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Gets a registered function factory by name.
|
|
67
|
+
* Used by FunctionFactory to instantiate decorator-registered functions.
|
|
68
|
+
*
|
|
69
|
+
* @param name - Function name (case-insensitive)
|
|
70
|
+
* @param category - Optional category to disambiguate (e.g., 'predicate')
|
|
71
|
+
* @returns Factory function or undefined
|
|
72
|
+
*/
|
|
73
|
+
function getRegisteredFunctionFactory(name, category) {
|
|
74
|
+
const lowerName = name.toLowerCase();
|
|
75
|
+
// If category specified, look for exact match
|
|
76
|
+
if (category) {
|
|
77
|
+
return functionFactoryRegistry.get(`${lowerName}:${category}`);
|
|
78
|
+
}
|
|
79
|
+
// Try direct match first
|
|
80
|
+
if (functionFactoryRegistry.has(lowerName)) {
|
|
81
|
+
return functionFactoryRegistry.get(lowerName);
|
|
82
|
+
}
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Gets metadata for a specific function by name.
|
|
87
|
+
* If multiple functions share the same name (e.g., aggregate vs predicate),
|
|
88
|
+
* optionally specify the category to get the specific one.
|
|
89
|
+
*
|
|
90
|
+
* @param name - Function name (case-insensitive)
|
|
91
|
+
* @param category - Optional category to disambiguate
|
|
92
|
+
* @returns Function metadata or undefined
|
|
93
|
+
*/
|
|
94
|
+
function getFunctionMetadata(name, category) {
|
|
95
|
+
const lowerName = name.toLowerCase();
|
|
96
|
+
// If category specified, look for exact match
|
|
97
|
+
if (category) {
|
|
98
|
+
return functionMetadataRegistry.get(`${lowerName}:${category}`);
|
|
99
|
+
}
|
|
100
|
+
// Otherwise, first try direct match (for functions without category conflicts)
|
|
101
|
+
// Then search for any function with matching name
|
|
102
|
+
for (const [key, meta] of functionMetadataRegistry) {
|
|
103
|
+
if (meta.name === lowerName) {
|
|
104
|
+
return meta;
|
|
105
|
+
}
|
|
157
106
|
}
|
|
158
|
-
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
159
109
|
//# sourceMappingURL=function_metadata.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"function_metadata.js","sourceRoot":"","sources":["../../../src/parsing/functions/function_metadata.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"function_metadata.js","sourceRoot":"","sources":["../../../src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ists all registered functions with their metadata.
|
|
4
|
+
*
|
|
5
|
+
* Can be used in FlowQuery to discover available functions:
|
|
6
|
+
* - `WITH functions() AS funcs RETURN funcs` - returns all functions
|
|
7
|
+
* - `WITH functions('aggregation') AS funcs RETURN funcs` - returns functions in a category
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```
|
|
11
|
+
* WITH functions() AS funcs
|
|
12
|
+
* UNWIND funcs AS func
|
|
13
|
+
* RETURN func.name, func.description
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
declare class Functions extends Function {
|
|
17
|
+
constructor();
|
|
18
|
+
value(): any;
|
|
19
|
+
}
|
|
20
|
+
export default Functions;
|
|
21
|
+
//# sourceMappingURL=functions.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"functions.d.ts","sourceRoot":"","sources":["../../../src/parsing/functions/functions.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,YAAY,CAAC;AAIlC;;;;;;;;;;;;;GAaG;AACH,cA0BM,SAAU,SAAQ,QAAQ;;IAMrB,KAAK,IAAI,GAAG;CAiBtB;AAED,eAAe,SAAS,CAAC"}
|