From 091565f020623db4e5129839e292107e92860a40 Mon Sep 17 00:00:00 2001 From: Vitali Semianiaka Date: Tue, 10 Feb 2026 23:25:42 +0300 Subject: [PATCH] stabilize --- MyCompany.MyProject.BackendApi/Program.cs | 75 +++ QuasarFrontend/quasar.config.ts | 4 +- QuasarFrontend/src/components/s8n-runtime.ts | 21 +- .../components_s8n/ComponentCalculator.vue | 22 +- .../components_s8n/ComponentHttpRequest.vue | 22 +- QuasarFrontend/src/layouts/MainLayout.vue | 86 ++-- QuasarFrontend/src/pages/PlaygroundPage.vue | 479 ++++++++++++++++-- .../src/services/callHistoryStorage.ts | 53 ++ S8n.Components.Packages/Basics/Calculator.cs | 2 +- components | 2 +- 10 files changed, 664 insertions(+), 102 deletions(-) create mode 100644 QuasarFrontend/src/services/callHistoryStorage.ts diff --git a/MyCompany.MyProject.BackendApi/Program.cs b/MyCompany.MyProject.BackendApi/Program.cs index aae554d..268e3ba 100644 --- a/MyCompany.MyProject.BackendApi/Program.cs +++ b/MyCompany.MyProject.BackendApi/Program.cs @@ -1,5 +1,7 @@ using System.Reflection; using System.Text.Json; +using System.Collections.Generic; +using System.IO; using Scalar.AspNetCore; // Ensure S8n.Components.Packages assembly is loaded @@ -41,6 +43,47 @@ app.MapGet("/weatherforecast", () => }) .WithName("GetWeatherForecast"); +// Component registry endpoint +app.MapGet("/api/components", () => +{ + var components = new List(); + var componentsPath = Path.Combine(Directory.GetCurrentDirectory(), "..", "components"); + + if (!Directory.Exists(componentsPath)) + { + // Fallback to absolute path from workspace root + componentsPath = Path.Combine(Directory.GetCurrentDirectory(), "components"); + } + + if (Directory.Exists(componentsPath)) + { + var jsonFiles = Directory.GetFiles(componentsPath, "*.json", SearchOption.AllDirectories); + foreach (var file in jsonFiles) + { + try + { + var json = File.ReadAllText(file); + var component = JsonSerializer.Deserialize(json, new JsonSerializerOptions + { + PropertyNameCaseInsensitive = true + }); + if (component != null) + { + components.Add(component); + } + } + catch (Exception ex) + { + // Log error but continue + Console.WriteLine($"Error reading component file {file}: {ex.Message}"); + } + } + } + + return Results.Ok(components); +}) +.WithName("GetComponents"); + // Runtime execution endpoint app.MapPost("/api/runtime/execute", (RuntimeRequest request) => { @@ -164,3 +207,35 @@ record RuntimeResponse public object? Outputs { get; set; } public string? Error { get; set; } } + +record ComponentDefinition +{ + public string Code { get; set; } = string.Empty; + public string Name { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public string Icon { get; set; } = string.Empty; + public List Inputs { get; set; } = new(); + public List Outputs { get; set; } = new(); + public string Source { get; set; } = string.Empty; + public string Class { get; set; } = string.Empty; + public List Methods { get; set; } = new(); + public string Gui { get; set; } = string.Empty; + public string Category { get; set; } = string.Empty; + public List Tags { get; set; } = new(); +} + +record ComponentInput +{ + public string Name { get; set; } = string.Empty; + public string Type { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; + public List? Enum { get; set; } + public bool Required { get; set; } = true; +} + +record ComponentOutput +{ + public string Name { get; set; } = string.Empty; + public string Type { get; set; } = string.Empty; + public string Description { get; set; } = string.Empty; +} diff --git a/QuasarFrontend/quasar.config.ts b/QuasarFrontend/quasar.config.ts index 5f78074..8c5a922 100644 --- a/QuasarFrontend/quasar.config.ts +++ b/QuasarFrontend/quasar.config.ts @@ -106,7 +106,9 @@ export default defineConfig((ctx) => { // https://v2.quasar.dev/quasar-cli-vite/quasar-config-file#framework framework: { - config: {}, + config: { + dark: 'auto', + }, // iconSet: 'material-icons', // Quasar icon set // lang: 'en-US', // Quasar language pack diff --git a/QuasarFrontend/src/components/s8n-runtime.ts b/QuasarFrontend/src/components/s8n-runtime.ts index 8bc5475..baabbd1 100644 --- a/QuasarFrontend/src/components/s8n-runtime.ts +++ b/QuasarFrontend/src/components/s8n-runtime.ts @@ -8,6 +8,7 @@ export interface RuntimeExecutor { inputs: Ref; outputs: Ref; error: Ref; + statusCode: Ref; duration: Ref; } @@ -22,15 +23,17 @@ export const runtime = { const duration = shallowRef(0); const running = shallowRef(false); const error = shallowRef(); + const statusCode = shallowRef(); const execute = async (method: string): Promise => { console.trace('executing...', className, method); const startTime = performance.now(); try { error.value = undefined; + statusCode.value = undefined; running.value = true; duration.value = 0; - const response = await fetch(`${API_BASE_URL}/api/runtime/execute`, { + const request = fetch(`${API_BASE_URL}/api/runtime/execute`, { method: 'POST', headers: { 'Content-Type': 'application/json', @@ -42,9 +45,17 @@ export const runtime = { }), }); + + let response: Response | undefined; + await request.then(r => { + response = r; + statusCode.value = response.status; + }); + if (!response) return; + if (!response.ok) { const errorData = await response.json(); - throw new Error(errorData.error || `HTTP error! status: ${response.status}`); + throw new Error(errorData.error || `HTTP error! ${response.statusText}`); } const data = await response.json(); @@ -54,11 +65,14 @@ export const runtime = { } outputs.value = data.outputs || {}; + if (data.error) { + error.value = data.error; + } + return outputs.value; } catch (err) { console.error('Runtime execution error:', err); error.value = err instanceof Error ? err.message : 'An error occurred'; - if (!silentErrors) { throw err; } @@ -78,6 +92,7 @@ export const runtime = { inputs, outputs, error, + statusCode, }; }, }; diff --git a/QuasarFrontend/src/components_s8n/ComponentCalculator.vue b/QuasarFrontend/src/components_s8n/ComponentCalculator.vue index c59dcb5..48bd6f9 100644 --- a/QuasarFrontend/src/components_s8n/ComponentCalculator.vue +++ b/QuasarFrontend/src/components_s8n/ComponentCalculator.vue @@ -46,16 +46,6 @@ -
- -
@@ -63,7 +53,7 @@