@fractal-solutions/qflow 1.0.62 → 1.0.63

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 (109) hide show
  1. package/package.json +1 -1
  2. package/dist/agent/agent.d.ts +0 -23
  3. package/dist/agent/agent.js +0 -365
  4. package/dist/agent/base_agent.d.ts +0 -21
  5. package/dist/agent/base_agent.js +0 -206
  6. package/dist/agent/logger.d.ts +0 -9
  7. package/dist/agent/logger.js +0 -45
  8. package/dist/agent/lpavrl_agent.d.ts +0 -5
  9. package/dist/agent/lpavrl_agent.js +0 -178
  10. package/dist/agent/ooda_agent.d.ts +0 -5
  11. package/dist/agent/ooda_agent.js +0 -167
  12. package/dist/agent/pema_agent.d.ts +0 -5
  13. package/dist/agent/pema_agent.js +0 -171
  14. package/dist/agent/raor_agent.d.ts +0 -5
  15. package/dist/agent/raor_agent.js +0 -164
  16. package/dist/agent/tools.d.ts +0 -5378
  17. package/dist/agent/tools.js +0 -1174
  18. package/dist/logger.d.ts +0 -9
  19. package/dist/logger.js +0 -107
  20. package/dist/nodes/agent_llm.d.ts +0 -31
  21. package/dist/nodes/agent_llm.js +0 -302
  22. package/dist/nodes/browser_control.d.ts +0 -4
  23. package/dist/nodes/browser_control.js +0 -73
  24. package/dist/nodes/code_interpreter.d.ts +0 -9
  25. package/dist/nodes/code_interpreter.js +0 -121
  26. package/dist/nodes/data_extractor.d.ts +0 -5
  27. package/dist/nodes/data_extractor.js +0 -81
  28. package/dist/nodes/data_validation.d.ts +0 -9
  29. package/dist/nodes/data_validation.js +0 -48
  30. package/dist/nodes/database.d.ts +0 -6
  31. package/dist/nodes/database.js +0 -89
  32. package/dist/nodes/display_image.d.ts +0 -4
  33. package/dist/nodes/display_image.js +0 -47
  34. package/dist/nodes/embedding.d.ts +0 -7
  35. package/dist/nodes/embedding.js +0 -45
  36. package/dist/nodes/filesystem.d.ts +0 -41
  37. package/dist/nodes/filesystem.js +0 -88
  38. package/dist/nodes/gis.d.ts +0 -37
  39. package/dist/nodes/gis.js +0 -106
  40. package/dist/nodes/git.d.ts +0 -4
  41. package/dist/nodes/git.js +0 -55
  42. package/dist/nodes/github.d.ts +0 -27
  43. package/dist/nodes/github.js +0 -75
  44. package/dist/nodes/hackernews.d.ts +0 -19
  45. package/dist/nodes/hackernews.js +0 -47
  46. package/dist/nodes/hardware_interaction.d.ts +0 -8
  47. package/dist/nodes/hardware_interaction.js +0 -98
  48. package/dist/nodes/http.d.ts +0 -26
  49. package/dist/nodes/http.js +0 -67
  50. package/dist/nodes/http_server.d.ts +0 -17
  51. package/dist/nodes/http_server.js +0 -190
  52. package/dist/nodes/image_gallery.d.ts +0 -8
  53. package/dist/nodes/image_gallery.js +0 -100
  54. package/dist/nodes/index.d.ts +0 -48
  55. package/dist/nodes/index.js +0 -48
  56. package/dist/nodes/interactive_input.d.ts +0 -4
  57. package/dist/nodes/interactive_input.js +0 -71
  58. package/dist/nodes/interactive_webview.d.ts +0 -19
  59. package/dist/nodes/interactive_webview.js +0 -310
  60. package/dist/nodes/iterator.d.ts +0 -5
  61. package/dist/nodes/iterator.js +0 -23
  62. package/dist/nodes/llm.d.ts +0 -18
  63. package/dist/nodes/llm.js +0 -215
  64. package/dist/nodes/memory.d.ts +0 -12
  65. package/dist/nodes/memory.js +0 -48
  66. package/dist/nodes/multimedia_processing.d.ts +0 -10
  67. package/dist/nodes/multimedia_processing.js +0 -80
  68. package/dist/nodes/openrouter_llm.d.ts +0 -8
  69. package/dist/nodes/openrouter_llm.js +0 -124
  70. package/dist/nodes/pdf_processor.d.ts +0 -4
  71. package/dist/nodes/pdf_processor.js +0 -75
  72. package/dist/nodes/remote_execution.d.ts +0 -4
  73. package/dist/nodes/remote_execution.js +0 -83
  74. package/dist/nodes/s3.d.ts +0 -6
  75. package/dist/nodes/s3.js +0 -38
  76. package/dist/nodes/scheduler.d.ts +0 -20
  77. package/dist/nodes/scheduler.js +0 -98
  78. package/dist/nodes/search.d.ts +0 -25
  79. package/dist/nodes/search.js +0 -78
  80. package/dist/nodes/semantic_memory.d.ts +0 -17
  81. package/dist/nodes/semantic_memory.js +0 -111
  82. package/dist/nodes/shell.d.ts +0 -11
  83. package/dist/nodes/shell.js +0 -29
  84. package/dist/nodes/speech_synthesis.d.ts +0 -45
  85. package/dist/nodes/speech_synthesis.js +0 -142
  86. package/dist/nodes/spreadsheet.d.ts +0 -10
  87. package/dist/nodes/spreadsheet.js +0 -241
  88. package/dist/nodes/stripe.d.ts +0 -23
  89. package/dist/nodes/stripe.js +0 -69
  90. package/dist/nodes/subflow.d.ts +0 -5
  91. package/dist/nodes/subflow.js +0 -16
  92. package/dist/nodes/summarize.d.ts +0 -12
  93. package/dist/nodes/summarize.js +0 -31
  94. package/dist/nodes/system_notification.d.ts +0 -4
  95. package/dist/nodes/system_notification.js +0 -50
  96. package/dist/nodes/transform.d.ts +0 -5
  97. package/dist/nodes/transform.js +0 -32
  98. package/dist/nodes/user.d.ts +0 -11
  99. package/dist/nodes/user.js +0 -32
  100. package/dist/nodes/webhook.d.ts +0 -15
  101. package/dist/nodes/webhook.js +0 -125
  102. package/dist/nodes/webscraper.d.ts +0 -11
  103. package/dist/nodes/webscraper.js +0 -33
  104. package/dist/nodes/websockets.d.ts +0 -4
  105. package/dist/nodes/websockets.js +0 -73
  106. package/dist/nodes/webview.d.ts +0 -12
  107. package/dist/nodes/webview.js +0 -27
  108. package/dist/qflow.d.ts +0 -69
  109. package/dist/qflow.js +0 -320
@@ -1,81 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import * as cheerio from 'cheerio';
3
- import { log } from '../logger.js';
4
- export class DataExtractorNode extends AsyncNode {
5
- async execAsync() {
6
- const { input, type, selector, jsonPath, regex, group } = this.params;
7
- if (!input) {
8
- throw new Error('DataExtractorNode requires an `input` string.');
9
- }
10
- if (!type || !['html', 'json', 'text'].includes(type)) {
11
- throw new Error('DataExtractorNode requires a valid `type` (html, json, text).');
12
- }
13
- let result;
14
- switch (type) {
15
- case 'html':
16
- if (!selector) {
17
- throw new Error('HTML extraction requires a `selector`.');
18
- }
19
- log(`[DataExtractor] Extracting HTML with selector: ${selector}`, this.params.logging);
20
- const $ = cheerio.load(input);
21
- result = $(selector).map((i, el) => $(el).text()).get();
22
- break;
23
- case 'json':
24
- if (!jsonPath) {
25
- throw new Error('JSON extraction requires a `jsonPath`.');
26
- }
27
- log(`[DataExtractor] Extracting JSON with path: ${jsonPath}`, this.params.logging);
28
- try {
29
- const data = JSON.parse(input);
30
- // Simple JSON path implementation (dot notation and array indexing)
31
- result = jsonPath.split('.').reduce((acc, part) => {
32
- if (acc === undefined || acc === null)
33
- return undefined;
34
- const arrayMatch = part.match(/(.*)\[(\d+)\]$/);
35
- if (arrayMatch) {
36
- const prop = arrayMatch[1];
37
- const index = parseInt(arrayMatch[2], 10);
38
- return acc[prop] ? acc[prop][index] : undefined;
39
- }
40
- else {
41
- return acc[part];
42
- }
43
- }, data);
44
- }
45
- catch (e) {
46
- throw new Error(`Invalid JSON input or jsonPath: ${e.message}`);
47
- }
48
- break;
49
- case 'text':
50
- if (!regex) {
51
- throw new Error('Text extraction requires a `regex`.');
52
- }
53
- log(`[DataExtractor] Extracting text with regex: ${regex}`, this.params.logging);
54
- const re = new RegExp(regex, 'g');
55
- const matches = [];
56
- let match;
57
- while ((match = re.exec(input)) !== null) {
58
- if (group !== undefined && match.length > group) {
59
- matches.push(match[group]);
60
- }
61
- else if (group === undefined) {
62
- matches.push(match[0]);
63
- }
64
- else {
65
- // Group not found, push undefined or skip
66
- matches.push(undefined);
67
- }
68
- }
69
- result = matches;
70
- break;
71
- default:
72
- throw new Error('Unsupported extraction type.');
73
- }
74
- log(`[DataExtractor] Extraction complete. Result: ${JSON.stringify(result).substring(0, 100)}...`, this.params.logging);
75
- return result;
76
- }
77
- async postAsync(shared, prepRes, execRes) {
78
- shared.extractedData = execRes;
79
- return 'default';
80
- }
81
- }
@@ -1,9 +0,0 @@
1
- export class DataValidationNode extends AsyncNode {
2
- ajv: Ajv;
3
- execAsync(): Promise<{
4
- isValid: boolean;
5
- errors: import("ajv").ErrorObject<string, Record<string, any>, unknown>[] | null | undefined;
6
- }>;
7
- }
8
- import { AsyncNode } from '../qflow.js';
9
- import Ajv from 'ajv';
@@ -1,48 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import { promises as fs } from 'fs';
3
- import Ajv from 'ajv'; // npm install ajv
4
- import addFormats from 'ajv-formats'; // npm install ajv-formats
5
- export class DataValidationNode extends AsyncNode {
6
- constructor(maxRetries = 1, wait = 0) {
7
- super(maxRetries, wait);
8
- this.ajv = new Ajv({ allErrors: true, verbose: true }); // Configure AJV for detailed errors
9
- addFormats(this.ajv); // Add format validators
10
- }
11
- async execAsync() {
12
- const { data, // The data to be validated
13
- schema, // The JSON Schema object directly
14
- schemaPath, // Optional: Path to a JSON Schema file
15
- action = 'validate' // Currently only 'validate'
16
- } = this.params;
17
- if (action !== 'validate') {
18
- throw new Error('DataValidationNode currently only supports `action: "validate"`.');
19
- }
20
- if (!data) {
21
- throw new Error('DataValidationNode requires `data` to validate.');
22
- }
23
- if (!schema && !schemaPath) {
24
- throw new Error('DataValidationNode requires either `schema` or `schemaPath`.');
25
- }
26
- let validationSchema;
27
- if (schema) {
28
- validationSchema = schema;
29
- }
30
- else if (schemaPath) {
31
- try {
32
- const schemaContent = await fs.readFile(schemaPath, 'utf8');
33
- validationSchema = JSON.parse(schemaContent);
34
- }
35
- catch (e) {
36
- throw new Error(`Failed to read or parse schema file from ${schemaPath}: ${e.message}`);
37
- }
38
- }
39
- const validate = this.ajv.compile(validationSchema);
40
- const isValid = validate(data);
41
- if (isValid) {
42
- return { isValid: true, errors: null };
43
- }
44
- else {
45
- return { isValid: false, errors: validate.errors };
46
- }
47
- }
48
- }
@@ -1,6 +0,0 @@
1
- export class DatabaseNode extends AsyncNode {
2
- execAsync(prepRes: any, shared: any): Promise<any>;
3
- postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
4
- #private;
5
- }
6
- import { AsyncNode } from '../qflow.js';
@@ -1,89 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import { SQL } from 'bun';
3
- import { Database as SQLiteDatabase } from 'bun:sqlite';
4
- export class DatabaseNode extends AsyncNode {
5
- #db = null;
6
- async prepAsync(shared) {
7
- const { connection, adapter } = this.params;
8
- if (!shared.db_connections) {
9
- shared.db_connections = {};
10
- }
11
- if (shared.db_connections[connection]) {
12
- this.#db = shared.db_connections[connection];
13
- }
14
- else {
15
- if (adapter === 'sqlite') {
16
- this.#db = new SQLiteDatabase(connection);
17
- }
18
- else {
19
- this.#db = new SQL(connection || process.env.DATABASE_URL);
20
- }
21
- shared.db_connections[connection] = this.#db;
22
- }
23
- }
24
- async execAsync(prepRes, shared) {
25
- const { action, query, table, data, where, operations } = this.params;
26
- if (this.#db instanceof SQLiteDatabase) {
27
- // bun:sqlite logic
28
- switch (action) {
29
- case 'query':
30
- return this.#db.query(query).all();
31
- case 'insert':
32
- const keys = Object.keys(data).map(k => k.replace('$', '')).join(', ');
33
- const values = Object.keys(data).map(k => k).join(', ');
34
- const statement = this.#db.prepare(`INSERT INTO ${table} (${keys}) VALUES (${values})`);
35
- return statement.run(data);
36
- case 'bulk_insert':
37
- const bulkKeys = Object.keys(data[0]).map(k => k.replace('$', '')).join(', ');
38
- const bulkValues = Object.keys(data[0]).map(k => k).join(', ');
39
- const bulkStatement = this.#db.prepare(`INSERT INTO ${table} (${bulkKeys}) VALUES (${bulkValues})`);
40
- return this.#db.transaction(items => {
41
- for (const item of items)
42
- bulkStatement.run(item);
43
- })(data);
44
- case 'update':
45
- const setClause = Object.keys(data).map(k => `${k.replace('$', '')} = ${k}`).join(', ');
46
- const updateStatement = this.#db.prepare(`UPDATE ${table} SET ${setClause} WHERE ${where}`);
47
- return updateStatement.run(data);
48
- case 'delete':
49
- const deleteStatement = this.#db.prepare(`DELETE FROM ${table} WHERE ${where}`);
50
- return deleteStatement.run();
51
- case 'transaction':
52
- return this.#db.transaction(() => {
53
- for (const op of operations) {
54
- this.#db.run(op.query, op.params);
55
- }
56
- })();
57
- default:
58
- throw new Error(`Unsupported database action for sqlite: ${action}`);
59
- }
60
- }
61
- else {
62
- // bun:sql logic
63
- switch (action) {
64
- case 'query':
65
- return this.#db.query(query);
66
- case 'insert':
67
- return this.#db.query `INSERT INTO ${this.#db(table)} ${this.#db(data)}`;
68
- case 'bulk_insert':
69
- return this.#db.query `INSERT INTO ${this.#db(table)} ${this.#db(data)}`;
70
- case 'update':
71
- return this.#db.query `UPDATE ${this.#db(table)} SET ${this.#db(data)} WHERE ${this.#db.unsafe(where)}`;
72
- case 'delete':
73
- return this.#db.query `DELETE FROM ${this.#db(table)} WHERE ${this.#db.unsafe(where)}`;
74
- case 'transaction':
75
- return this.#db.begin(async (tx) => {
76
- for (const op of operations) {
77
- await tx.query(op.query, op.params);
78
- }
79
- });
80
- default:
81
- throw new Error(`Unsupported database action for bun:sql: ${action}`);
82
- }
83
- }
84
- }
85
- async postAsync(shared, prepRes, execRes) {
86
- shared.db_result = execRes;
87
- return 'default';
88
- }
89
- }
@@ -1,4 +0,0 @@
1
- export class DisplayImageNode extends AsyncNode {
2
- execAsync(): Promise<any>;
3
- }
4
- import { AsyncNode } from '../qflow.js';
@@ -1,47 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import { exec } from 'child_process';
3
- import os from 'os';
4
- import { log } from '../logger.js';
5
- export class DisplayImageNode extends AsyncNode {
6
- constructor(maxRetries = 1, wait = 0) {
7
- super(maxRetries, wait);
8
- }
9
- async execAsync() {
10
- const { imagePath } = this.params;
11
- if (!imagePath) {
12
- throw new Error('DisplayImageNode requires an `imagePath` parameter.');
13
- }
14
- let command = '';
15
- const platform = os.platform();
16
- switch (platform) {
17
- case 'linux':
18
- // 'xdg-open' is a standard way to open files with default application on Linux desktops
19
- command = `xdg-open "${imagePath}"`;
20
- break;
21
- case 'darwin': // macOS
22
- // 'open' command opens files with their default application
23
- command = `open "${imagePath}"`;
24
- break;
25
- case 'win32': // Windows
26
- // 'start' command opens files with their default application
27
- command = `start "" "${imagePath}"`; // The first "" is for the title, which is optional but good practice
28
- break;
29
- default:
30
- throw new Error(`Unsupported platform for DisplayImageNode: ${platform}`);
31
- }
32
- log(`[DisplayImageNode] Executing: ${command}`, this.params.logging);
33
- return new Promise((resolve, reject) => {
34
- exec(command, (error, stdout, stderr) => {
35
- if (error) {
36
- log(`DisplayImageNode error: ${error.message}`, this.params.logging, { type: 'error' });
37
- return reject(error);
38
- }
39
- if (stderr) {
40
- log(`DisplayImageNode stderr: ${stderr}`, this.params.logging, { type: 'warn' });
41
- }
42
- log(`Image opened: ${imagePath}`, this.params.logging);
43
- resolve({ imagePath, stdout, stderr });
44
- });
45
- });
46
- }
47
- }
@@ -1,7 +0,0 @@
1
- export class EmbeddingNode extends AsyncNode {
2
- execAsync(): Promise<{
3
- embedding: any;
4
- }>;
5
- postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
6
- }
7
- import { AsyncNode } from '../qflow.js';
@@ -1,45 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import { log } from '../logger.js';
3
- export class EmbeddingNode extends AsyncNode {
4
- constructor(maxRetries = 3, wait = 2) {
5
- super(maxRetries, wait);
6
- }
7
- async execAsync() {
8
- const { text, model = 'nomic-embed-text', baseUrl = 'http://localhost:11434' } = this.params;
9
- if (!text) {
10
- throw new Error('EmbeddingNode requires a `text` parameter to embed.');
11
- }
12
- const url = `${baseUrl}/api/embeddings`;
13
- const payload = {
14
- model: model,
15
- prompt: text,
16
- };
17
- log(`[EmbeddingNode] Generating embedding for text (model: ${model}) at ${baseUrl}...`, this.params.logging);
18
- try {
19
- const response = await fetch(url, {
20
- method: 'POST',
21
- headers: {
22
- 'Content-Type': 'application/json',
23
- },
24
- body: JSON.stringify(payload),
25
- });
26
- if (!response.ok) {
27
- const errorText = await response.text();
28
- throw new Error(`Ollama embedding API error: ${response.status} ${response.statusText} - ${errorText}`);
29
- }
30
- const data = await response.json();
31
- if (!data.embedding) {
32
- throw new Error('Ollama embedding API response missing embedding.');
33
- }
34
- log(`[EmbeddingNode] Embedding generated successfully.`, this.params.logging);
35
- return { embedding: data.embedding };
36
- }
37
- catch (error) {
38
- throw new Error(`Failed to generate embedding: ${error.message}`);
39
- }
40
- }
41
- async postAsync(shared, prepRes, execRes) {
42
- shared.embeddingResult = execRes.embedding; // Store the embedding array directly
43
- return 'default';
44
- }
45
- }
@@ -1,41 +0,0 @@
1
- /**
2
- * Reads a file from the file system.
3
- * @param {object} params - The parameters for the node.
4
- * @param {string} params.filePath - The path to the file to read.
5
- * @returns {Promise<string>} A promise that resolves to the content of the file.
6
- */
7
- export class ReadFileNode extends AsyncNode {
8
- execAsync(): Promise<string>;
9
- postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
10
- }
11
- /**
12
- * Writes a file to the file system.
13
- * @param {object} params - The parameters for the node.
14
- * @param {string} params.filePath - The path to the file to write.
15
- * @param {string} params.content - The content to write to the file.
16
- * @returns {Promise<void>} A promise that resolves when the file has been written.
17
- */
18
- export class WriteFileNode extends AsyncNode {
19
- execAsync(): Promise<string>;
20
- }
21
- /**
22
- * Appends content to a file.
23
- * @param {object} params - The parameters for the node.
24
- * @param {string} params.filePath - The path to the file to append to.
25
- * @param {string} params.content - The content to append to the file.
26
- * @returns {Promise<void>} A promise that resolves when the content has been appended.
27
- */
28
- export class AppendFileNode extends AsyncNode {
29
- execAsync(): Promise<string>;
30
- }
31
- /**
32
- * Lists the files in a directory.
33
- * @param {object} params - The parameters for the node.
34
- * @param {string} params.directoryPath - The path to the directory to list.
35
- * @returns {Promise<string[]>} A promise that resolves to an array of file names.
36
- */
37
- export class ListDirectoryNode extends AsyncNode {
38
- execAsync(): Promise<string[]>;
39
- postAsync(shared: any, prepRes: any, execRes: any): Promise<string>;
40
- }
41
- import { AsyncNode } from '../qflow.js';
@@ -1,88 +0,0 @@
1
- import { AsyncNode } from '../qflow.js';
2
- import { promises as fs } from 'fs';
3
- import path from 'path';
4
- import { log } from '../logger.js';
5
- /**
6
- * Reads a file from the file system.
7
- * @param {object} params - The parameters for the node.
8
- * @param {string} params.filePath - The path to the file to read.
9
- * @returns {Promise<string>} A promise that resolves to the content of the file.
10
- */
11
- export class ReadFileNode extends AsyncNode {
12
- async execAsync() {
13
- const { filePath } = this.params;
14
- if (!filePath) {
15
- throw new Error('Missing required parameter: filePath');
16
- }
17
- log(`[FileSystem] Reading file: ${filePath}`, this.params.logging);
18
- const content = await fs.readFile(filePath, 'utf-8');
19
- log(`[FileSystem] Successfully read file: ${filePath}`, this.params.logging);
20
- return content;
21
- }
22
- async postAsync(shared, prepRes, execRes) {
23
- shared.fileContent = execRes;
24
- return 'default';
25
- }
26
- }
27
- /**
28
- * Writes a file to the file system.
29
- * @param {object} params - The parameters for the node.
30
- * @param {string} params.filePath - The path to the file to write.
31
- * @param {string} params.content - The content to write to the file.
32
- * @returns {Promise<void>} A promise that resolves when the file has been written.
33
- */
34
- export class WriteFileNode extends AsyncNode {
35
- async execAsync() {
36
- const { filePath, content } = this.params;
37
- if (!filePath || content === undefined) {
38
- throw new Error('Missing required parameters: filePath, content');
39
- }
40
- log(`[FileSystem] Writing to file: ${filePath}`, this.params.logging);
41
- await fs.mkdir(path.dirname(filePath), { recursive: true });
42
- await fs.writeFile(filePath, content, 'utf-8');
43
- log(`[FileSystem] Successfully wrote to file: ${filePath}`, this.params.logging);
44
- return 'default';
45
- }
46
- }
47
- /**
48
- * Appends content to a file.
49
- * @param {object} params - The parameters for the node.
50
- * @param {string} params.filePath - The path to the file to append to.
51
- * @param {string} params.content - The content to append to the file.
52
- * @returns {Promise<void>} A promise that resolves when the content has been appended.
53
- */
54
- export class AppendFileNode extends AsyncNode {
55
- async execAsync() {
56
- const { filePath, content } = this.params;
57
- if (!filePath || content === undefined) {
58
- throw new Error('Missing required parameters: filePath, content');
59
- }
60
- log(`[FileSystem] Appending to file: ${filePath}`, this.params.logging);
61
- await fs.mkdir(path.dirname(filePath), { recursive: true });
62
- await fs.appendFile(filePath, content, 'utf-8');
63
- log(`[FileSystem] Successfully appended to file: ${filePath}`, this.params.logging);
64
- return 'default';
65
- }
66
- }
67
- /**
68
- * Lists the files in a directory.
69
- * @param {object} params - The parameters for the node.
70
- * @param {string} params.directoryPath - The path to the directory to list.
71
- * @returns {Promise<string[]>} A promise that resolves to an array of file names.
72
- */
73
- export class ListDirectoryNode extends AsyncNode {
74
- async execAsync() {
75
- const { directoryPath } = this.params;
76
- if (!directoryPath) {
77
- throw new Error('Missing required parameter: directoryPath');
78
- }
79
- log(`[FileSystem] Listing directory: ${directoryPath}`, this.params.logging);
80
- const files = await fs.readdir(directoryPath);
81
- log(`[FileSystem] Successfully listed directory: ${directoryPath}`, this.params.logging);
82
- return files;
83
- }
84
- async postAsync(shared, prepRes, execRes) {
85
- shared.directoryFiles = execRes;
86
- return 'default';
87
- }
88
- }
@@ -1,37 +0,0 @@
1
- export class GISNode extends AsyncNode {
2
- providers: {
3
- google: GoogleMapsProvider;
4
- openstreetmap: OpenStreetMapProvider;
5
- };
6
- execAsync(): Promise<any>;
7
- }
8
- import { AsyncNode } from '../qflow.js';
9
- declare class GoogleMapsProvider {
10
- constructor(apiKey: any);
11
- apiKey: any;
12
- baseUrl: string;
13
- geocode(address: any): Promise<{
14
- lat: any;
15
- lng: any;
16
- formattedAddress: any;
17
- }>;
18
- reverseGeocode(lat: any, lng: any): Promise<{
19
- lat: number;
20
- lng: number;
21
- formattedAddress: any;
22
- }>;
23
- }
24
- declare class OpenStreetMapProvider {
25
- baseUrl: string;
26
- geocode(address: any): Promise<{
27
- lat: number;
28
- lng: number;
29
- formattedAddress: any;
30
- }>;
31
- reverseGeocode(lat: any, lng: any): Promise<{
32
- lat: number;
33
- lng: number;
34
- formattedAddress: any;
35
- }>;
36
- }
37
- export {};
package/dist/nodes/gis.js DELETED
@@ -1,106 +0,0 @@
1
- import { AsyncNode, AsyncFlow } from '../qflow.js';
2
- import { HttpRequestNode } from './index.js'; // For making HTTP requests to APIs
3
- // Internal helper for Google Maps API calls
4
- class GoogleMapsProvider {
5
- constructor(apiKey) {
6
- this.apiKey = apiKey;
7
- this.baseUrl = "https://maps.googleapis.com/maps/api";
8
- }
9
- async geocode(address) {
10
- if (!this.apiKey) {
11
- throw new Error("Google Maps API Key is not configured for GoogleMapsProvider.");
12
- }
13
- const url = `${this.baseUrl}/geocode/json?address=${encodeURIComponent(address)}&key=${this.apiKey}`;
14
- const httpRequest = new HttpRequestNode();
15
- httpRequest.setParams({ url, method: 'GET' });
16
- const response = await new AsyncFlow(httpRequest).runAsync({});
17
- const data = response.body;
18
- if (data.status === 'OK' && data.results.length > 0) {
19
- const location = data.results[0].geometry.location;
20
- return { lat: location.lat, lng: location.lng, formattedAddress: data.results[0].formatted_address };
21
- }
22
- throw new Error(`Google Geocoding failed: ${data.status || JSON.stringify(data)}`);
23
- }
24
- async reverseGeocode(lat, lng) {
25
- if (!this.apiKey) {
26
- throw new Error("Google Maps API Key is not configured for GoogleMapsProvider.");
27
- }
28
- const url = `${this.baseUrl}/geocode/json?latlng=${lat},${lng}&key=${this.apiKey}`;
29
- const httpRequest = new HttpRequestNode();
30
- httpRequest.setParams({ url, method: 'GET' });
31
- const response = await new AsyncFlow(httpRequest).runAsync({});
32
- const data = response.body;
33
- if (data.status === 'OK' && data.results.length > 0) {
34
- const result = data.results[0];
35
- return { lat: parseFloat(result.geometry.location.lat), lng: parseFloat(result.geometry.location.lng), formattedAddress: result.formatted_address };
36
- }
37
- throw new Error(`Google Reverse Geocoding failed: ${data.status || JSON.stringify(data)}`);
38
- }
39
- }
40
- // Internal helper for OpenStreetMap (Nominatim for geocoding)
41
- class OpenStreetMapProvider {
42
- constructor() {
43
- this.baseUrl = "https://nominatim.openstreetmap.org";
44
- }
45
- async geocode(address) {
46
- const url = `${this.baseUrl}/search?q=${encodeURIComponent(address)}&format=json&limit=1`;
47
- const httpRequest = new HttpRequestNode();
48
- httpRequest.setParams({ url, method: 'GET', headers: { 'User-Agent': 'QFlowGISNode/1.0 (https://github.com/fractal-solutions/qflow)' } }); // Nominatim requires User-Agent
49
- const response = await new AsyncFlow(httpRequest).runAsync({});
50
- const data = response.body;
51
- if (Array.isArray(data) && data.length > 0) {
52
- const result = data[0];
53
- return { lat: parseFloat(result.lat), lng: parseFloat(result.lon), formattedAddress: result.display_name };
54
- }
55
- throw new Error(`OpenStreetMap Geocoding failed: No results for ${address}`);
56
- }
57
- async reverseGeocode(lat, lng) {
58
- const url = `${this.baseUrl}/reverse?lat=${lat}&lon=${lng}&format=json`;
59
- const httpRequest = new HttpRequestNode();
60
- httpRequest.setParams({ url, method: 'GET', headers: { 'User-Agent': 'QFlowGISNode/1.0 (https://github.com/fractal-solutions/qflow)' } }); // Nominatim requires User-Agent
61
- const response = await new AsyncFlow(httpRequest).runAsync({});
62
- const data = response.body;
63
- if (data && data.display_name) {
64
- return { lat: parseFloat(data.lat), lng: parseFloat(data.lon), formattedAddress: data.display_name };
65
- }
66
- throw new Error(`OpenStreetMap Reverse Geocoding failed: No results for ${lat},${lng}`);
67
- }
68
- }
69
- export class GISNode extends AsyncNode {
70
- constructor(maxRetries = 3, wait = 1) {
71
- super(maxRetries, wait);
72
- this.providers = {
73
- google: new GoogleMapsProvider(process.env.GOOGLE_MAPS_API_KEY), // API key from env var
74
- openstreetmap: new OpenStreetMapProvider(),
75
- // Add other providers here (e.g., mapbox: new MapboxProvider(process.env.MAPBOX_API_KEY))
76
- };
77
- }
78
- async execAsync() {
79
- const { operation, provider = 'openstreetmap', params } = this.params; // Default to openstreetmap
80
- if (!operation) {
81
- throw new Error('GISNode requires an `operation` parameter (e.g., "geocode", "reverseGeocode", "route").');
82
- }
83
- if (!this.providers[provider]) {
84
- throw new Error(`GIS provider '${provider}' not supported or configured.`);
85
- }
86
- const currentProvider = this.providers[provider];
87
- // Dispatch to the appropriate provider method based on operation
88
- switch (operation) {
89
- case 'geocode':
90
- if (!params || !params.address) {
91
- throw new Error('Geocode operation requires `params.address`.');
92
- }
93
- return await currentProvider.geocode(params.address);
94
- case 'reverseGeocode':
95
- if (!params || typeof params.lat !== 'number' || typeof params.lng !== 'number') {
96
- throw new Error('Reverse Geocode operation requires `params.lat` and `params.lng` as numbers.');
97
- }
98
- return await currentProvider.reverseGeocode(params.lat, params.lng);
99
- // Add other operations here
100
- // case 'route':
101
- // return await currentProvider.route(params.origin, params.destination);
102
- default:
103
- throw new Error(`Unsupported GIS operation: ${operation}`);
104
- }
105
- }
106
- }
@@ -1,4 +0,0 @@
1
- export class GitNode extends AsyncNode {
2
- execAsync(): Promise<{}>;
3
- }
4
- import { AsyncNode } from '../qflow.js';