flowquery 1.0.13 → 1.0.14
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/dist/flowquery.min.js +1 -1
- package/dist/parsing/functions/async_function.d.ts +16 -2
- package/dist/parsing/functions/async_function.d.ts.map +1 -1
- package/dist/parsing/functions/async_function.js +15 -1
- package/dist/parsing/functions/async_function.js.map +1 -1
- package/dist/parsing/operations/load.d.ts +1 -0
- package/dist/parsing/operations/load.d.ts.map +1 -1
- package/dist/parsing/operations/load.js +3 -1
- package/dist/parsing/operations/load.js.map +1 -1
- package/docs/flowquery.min.js +1 -1
- package/flowquery-vscode/flowQueryEngine/flowquery.min.js +1 -1
- package/misc/apps/RAG/package.json +1 -1
- package/misc/apps/RAG/src/plugins/loaders/Form.ts +3 -3
- package/package.json +1 -1
- package/src/parsing/functions/async_function.ts +16 -2
- package/src/parsing/operations/load.ts +3 -1
- package/misc/apps/RAG/src/plugins/loaders/FetchJson.ts +0 -66
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Example plugin: Fetch JSON data from a URL.
|
|
3
|
-
*
|
|
4
|
-
* Usage in FlowQuery:
|
|
5
|
-
* LOAD JSON FROM fetchJson('https://api.example.com/data') AS item
|
|
6
|
-
* RETURN item.name, item.value
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
import { FunctionDef } from 'flowquery/extensibility';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* FetchJson class - fetches JSON data from a URL and yields items.
|
|
13
|
-
*/
|
|
14
|
-
@FunctionDef({
|
|
15
|
-
description: 'Fetches JSON data from a URL. If the response is an array, yields each item individually.',
|
|
16
|
-
category: 'async',
|
|
17
|
-
parameters: [
|
|
18
|
-
{
|
|
19
|
-
name: 'url',
|
|
20
|
-
description: 'The URL to fetch JSON from',
|
|
21
|
-
type: 'string',
|
|
22
|
-
required: true
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
name: 'options',
|
|
26
|
-
description: 'Optional fetch options (headers, method, etc.)',
|
|
27
|
-
type: 'object',
|
|
28
|
-
required: false
|
|
29
|
-
}
|
|
30
|
-
],
|
|
31
|
-
output: {
|
|
32
|
-
description: 'JSON data items',
|
|
33
|
-
type: 'object'
|
|
34
|
-
},
|
|
35
|
-
examples: [
|
|
36
|
-
"LOAD JSON FROM fetchJson('https://api.example.com/users') AS user RETURN user.name",
|
|
37
|
-
"LOAD JSON FROM fetchJson('https://api.example.com/data') AS item RETURN item WHERE item.active = true"
|
|
38
|
-
]
|
|
39
|
-
})
|
|
40
|
-
export class FetchJson {
|
|
41
|
-
/**
|
|
42
|
-
* Fetches JSON data from a URL and yields each item if array, or the object itself.
|
|
43
|
-
*
|
|
44
|
-
* @param url - The URL to fetch JSON from
|
|
45
|
-
* @param options - Optional fetch options
|
|
46
|
-
*/
|
|
47
|
-
async *fetch(url: string, options?: RequestInit): AsyncGenerator<any, void, unknown> {
|
|
48
|
-
const response = await fetch(url, options);
|
|
49
|
-
|
|
50
|
-
if (!response.ok) {
|
|
51
|
-
throw new Error(`HTTP ${response.status}: ${response.statusText}`);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const data = await response.json();
|
|
55
|
-
|
|
56
|
-
if (Array.isArray(data)) {
|
|
57
|
-
for (const item of data) {
|
|
58
|
-
yield item;
|
|
59
|
-
}
|
|
60
|
-
} else {
|
|
61
|
-
yield data;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default FetchJson;
|