From 7390da71b1dbc7c13b74d5f7bbdb05bac02d8b53280651dd98ac6a1936eda9e0 Mon Sep 17 00:00:00 2001 From: gsadmin Date: Fri, 7 Aug 2026 23:04:50 -0400 Subject: [PATCH 01/18] Group rules: CIDR matching and a derived platform field New in/not-in CIDR operators evaluate device IPs against comma-separated ranges using the BCL System.Net.IPNetwork (IPv4 and IPv6; bare IPs mean equality; host bits in the base address are normalized, so 10.20.4.99/24 matches the same network as 10.20.4.0/24). Not-in is universal across multi-homed devices: every address must be outside. os.platform (windows/linux/macos) derives from the OS caption so rules and the default platform groups can target an OS family without caption gymnastics. Co-Authored-By: Claude Fable 5 --- src/Shared.Contracts/Models/GroupRules.cs | 5 ++ .../Grouping/DeviceFieldBag.cs | 21 ++++++ .../Grouping/RuleEvaluator.cs | 71 ++++++++++++++++++- src/WebUI/src/lib/api/types.ts | 4 +- .../src/lib/components/RuleBuilder.svelte | 4 +- tests/Shared.Tests/RuleEvaluatorTests.cs | 44 ++++++++++++ 6 files changed, 146 insertions(+), 3 deletions(-) diff --git a/src/Shared.Contracts/Models/GroupRules.cs b/src/Shared.Contracts/Models/GroupRules.cs index ce40661..2f4ae1f 100644 --- a/src/Shared.Contracts/Models/GroupRules.cs +++ b/src/Shared.Contracts/Models/GroupRules.cs @@ -32,6 +32,10 @@ public enum RuleOperator LessOrEqual, Exists, NotExists, + + /// Value is an IP address inside any of the listed CIDR ranges (or equals a bare IP). + InCidr, + NotInCidr, } /// @@ -93,6 +97,7 @@ public static class GroupFields new("systemType", "System type", "Hardware"), new("domain", "Domain / workgroup", "Identity"), new("partOfDomain", "Domain joined", "Identity"), + new("os.platform", "Platform (windows/linux/macos)", "Operating system"), new("os.caption", "OS name", "Operating system"), new("os.version", "OS version", "Operating system"), new("os.build", "OS build", "Operating system"), diff --git a/src/Shared.Infrastructure/Grouping/DeviceFieldBag.cs b/src/Shared.Infrastructure/Grouping/DeviceFieldBag.cs index 6023d37..a0e8c1d 100644 --- a/src/Shared.Infrastructure/Grouping/DeviceFieldBag.cs +++ b/src/Shared.Infrastructure/Grouping/DeviceFieldBag.cs @@ -87,6 +87,7 @@ public sealed class DeviceFieldBag bag.Set("domain", inventory.Identity.DomainOrWorkgroup); bag.Set("partOfDomain", inventory.Identity.PartOfDomain ? "true" : "false"); + bag.Set("os.platform", DerivePlatform(inventory.Os.Caption)); bag.Set("os.caption", inventory.Os.Caption); bag.Set("os.version", inventory.Os.Version); bag.Set("os.build", inventory.Os.Build); @@ -119,4 +120,24 @@ public sealed class DeviceFieldBag return bag; } + + /// Coarse platform from the OS caption: windows, macos or linux. + public static string? DerivePlatform(string? osCaption) + { + if (string.IsNullOrWhiteSpace(osCaption)) + { + return null; + } + + if (osCaption.Contains("windows", StringComparison.OrdinalIgnoreCase)) + { + return "windows"; + } + + return osCaption.Contains("macos", StringComparison.OrdinalIgnoreCase) + || osCaption.Contains("mac os", StringComparison.OrdinalIgnoreCase) + || osCaption.Contains("darwin", StringComparison.OrdinalIgnoreCase) + ? "macos" + : "linux"; + } } diff --git a/src/Shared.Infrastructure/Grouping/RuleEvaluator.cs b/src/Shared.Infrastructure/Grouping/RuleEvaluator.cs index e468b5c..35cf29f 100644 --- a/src/Shared.Infrastructure/Grouping/RuleEvaluator.cs +++ b/src/Shared.Infrastructure/Grouping/RuleEvaluator.cs @@ -1,4 +1,5 @@ using System.Globalization; +using System.Net; using System.Text.RegularExpressions; using Shared.Contracts.Models; @@ -15,7 +16,8 @@ public static class RuleEvaluator /// Operators that are inherently negative and so must hold for ALL values. private static bool IsUniversal(RuleOperator op) - => op is RuleOperator.NotEquals or RuleOperator.NotContains or RuleOperator.NotIn or RuleOperator.NotExists; + => op is RuleOperator.NotEquals or RuleOperator.NotContains or RuleOperator.NotIn + or RuleOperator.NotExists or RuleOperator.NotInCidr; public static bool Matches(GroupRuleSet? ruleSet, DeviceFieldBag fields) { @@ -129,11 +131,78 @@ public static class RuleEvaluator case RuleOperator.LessOrEqual: return CompareNumeric(actual, expected, condition.Operator); + case RuleOperator.InCidr: + return MatchesCidr(actual, expected); + case RuleOperator.NotInCidr: + return !MatchesCidr(actual, expected); + default: return false; } } + /// + /// True when is an IP address inside any of the + /// comma-separated CIDR ranges (bare IPs compare for equality). Uses the + /// BCL ; IPv4 and IPv6 both work. + /// + private static bool MatchesCidr(string actual, string expected) + { + if (!IPAddress.TryParse(actual.Trim(), out var address)) + { + return false; + } + + foreach (var item in SplitList(expected)) + { + if (item.Contains('/')) + { + if (TryParseNetwork(item, out var network) && network.Contains(address)) + { + return true; + } + } + else if (IPAddress.TryParse(item, out var single) && single.Equals(address)) + { + return true; + } + } + + return false; + } + + /// + /// Lenient CIDR parse: host bits in the base address are tolerated, so + /// "10.30.9.27/24" means the same network as "10.30.9.0/24" (the strict + /// BCL parser rejects non-zero host bits). + /// + private static bool TryParseNetwork(string cidr, out IPNetwork network) + { + network = default; + var slash = cidr.IndexOf('/'); + if (slash <= 0 + || !IPAddress.TryParse(cidr[..slash].Trim(), out var baseAddress) + || !int.TryParse(cidr[(slash + 1)..].Trim(), out var prefix)) + { + return false; + } + + var bytes = baseAddress.GetAddressBytes(); + if (prefix < 0 || prefix > bytes.Length * 8) + { + return false; + } + + for (var i = 0; i < bytes.Length; i++) + { + var bitsForByte = Math.Clamp(prefix - (i * 8), 0, 8); + bytes[i] &= (byte)(0xFF << (8 - bitsForByte)); + } + + network = new IPNetwork(new IPAddress(bytes), prefix); + return true; + } + private static bool CompareNumeric(string actual, string expected, RuleOperator op) { if (!double.TryParse(actual, NumberStyles.Float, CultureInfo.InvariantCulture, out var left) diff --git a/src/WebUI/src/lib/api/types.ts b/src/WebUI/src/lib/api/types.ts index bc5c50d..ba6e728 100644 --- a/src/WebUI/src/lib/api/types.ts +++ b/src/WebUI/src/lib/api/types.ts @@ -58,7 +58,9 @@ export type RuleOperator = | 'lessThan' | 'lessOrEqual' | 'exists' - | 'notExists'; + | 'notExists' + | 'inCidr' + | 'notInCidr'; export interface RuleCondition { field: string; diff --git a/src/WebUI/src/lib/components/RuleBuilder.svelte b/src/WebUI/src/lib/components/RuleBuilder.svelte index f67e509..f9e0741 100644 --- a/src/WebUI/src/lib/components/RuleBuilder.svelte +++ b/src/WebUI/src/lib/components/RuleBuilder.svelte @@ -27,7 +27,9 @@ { value: 'lessThan', label: '<', needsValue: true }, { value: 'lessOrEqual', label: '<=', needsValue: true }, { value: 'exists', label: 'exists', needsValue: false }, - { value: 'notExists', label: 'does not exist', needsValue: false } + { value: 'notExists', label: 'does not exist', needsValue: false }, + { value: 'inCidr', label: 'in CIDR range', needsValue: true }, + { value: 'notInCidr', label: 'not in CIDR range', needsValue: true } ]; const needsValue = (op: RuleOperator) => operators.find((o) => o.value === op)?.needsValue ?? true; diff --git a/tests/Shared.Tests/RuleEvaluatorTests.cs b/tests/Shared.Tests/RuleEvaluatorTests.cs index b0dae4f..8a3153e 100644 --- a/tests/Shared.Tests/RuleEvaluatorTests.cs +++ b/tests/Shared.Tests/RuleEvaluatorTests.cs @@ -189,4 +189,48 @@ public class RuleEvaluatorTests Assert.True(RuleEvaluator.Matches(new RuleCondition("network.ipv4", RuleOperator.StartsWith, "10.20."), bag)); Assert.True(RuleEvaluator.Matches(new RuleCondition("os.caption", RuleOperator.Contains, "Windows 11"), bag)); } + + [Theory] + [InlineData("10.20.0.0/16", true)] + [InlineData("10.20.4.0/24", true)] + // Host bits in the base address are tolerated (normalized to the network). + [InlineData("10.20.4.99/24", true)] + [InlineData("10.30.0.0/16", false)] + [InlineData("192.168.1.0/24, 10.20.0.0/16", true)] // any range in the list + [InlineData("10.20.4.14", true)] // bare IP means equality + [InlineData("10.20.4.15", false)] + [InlineData("not-a-cidr", false)] // invalid input never matches + [InlineData("10.20.4.0/33", false)] // invalid prefix never matches + public void InCidrMatchesAddressesAgainstRanges(string cidr, bool expected) + { + var condition = new RuleCondition("network.ipv4", RuleOperator.InCidr, cidr); + Assert.Equal(expected, RuleEvaluator.Matches(condition, Bag())); + } + + [Fact] + public void NotInCidrIsUniversalAcrossAllAddresses() + { + var multiHomed = Bag(inventory: Inventory(ips: ["10.20.4.14", "192.168.50.9"])); + + // One address inside the range → NotInCidr fails (must hold for ALL). + Assert.False(RuleEvaluator.Matches( + new RuleCondition("network.ipv4", RuleOperator.NotInCidr, "192.168.0.0/16"), multiHomed)); + Assert.True(RuleEvaluator.Matches( + new RuleCondition("network.ipv4", RuleOperator.NotInCidr, "172.16.0.0/12"), multiHomed)); + // And InCidr matches when ANY address is inside. + Assert.True(RuleEvaluator.Matches( + new RuleCondition("network.ipv4", RuleOperator.InCidr, "192.168.0.0/16"), multiHomed)); + } + + [Theory] + [InlineData("Windows Server 2022 Datacenter", "windows")] + [InlineData("Windows 11 Pro", "windows")] + [InlineData("Ubuntu 24.04.1 LTS", "linux")] + [InlineData("macOS 15.3", "macos")] + [InlineData("Debian GNU/Linux 12 (bookworm)", "linux")] + public void PlatformDerivesFromOsCaption(string caption, string platform) + { + var bag = Bag(inventory: Inventory(os: caption)); + Assert.True(RuleEvaluator.Matches(new RuleCondition("os.platform", RuleOperator.Equals, platform), bag)); + } } -- 2.52.0 From ef7bdf4b25518287460118f24e308face99588acc0b3f3c865f4763ff37fce5b Mon Sep 17 00:00:00 2001 From: gsadmin Date: Fri, 7 Aug 2026 23:04:50 -0400 Subject: [PATCH 02/18] Seed platform groups and starter schedules on first boot MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every deployment starts with four dynamic groups (Windows Servers, Windows Workstations, Linux, macOS — driven by os.platform) and four common cadences (hourly, daily 1 AM, weekdays 7 AM, weekly Sunday 2 AM, UTC). Each family seeds only while its table is empty, so operator edits and deletions are never recreated. Co-Authored-By: Claude Fable 5 --- src/Backend/Data/DefaultSeeder.cs | 100 ++++++++++++++++++++++++++++++ src/Backend/Program.cs | 3 + 2 files changed, 103 insertions(+) create mode 100644 src/Backend/Data/DefaultSeeder.cs diff --git a/src/Backend/Data/DefaultSeeder.cs b/src/Backend/Data/DefaultSeeder.cs new file mode 100644 index 0000000..dcdece0 --- /dev/null +++ b/src/Backend/Data/DefaultSeeder.cs @@ -0,0 +1,100 @@ +using Backend.Jobs; +using Microsoft.EntityFrameworkCore; +using Shared.Contracts.Models; +using Shared.Contracts.Serialization; + +namespace Backend.Data; + +/// +/// First-boot defaults every deployment gets: platform dynamic groups and a +/// few common schedule cadences. Each family seeds only while its table is +/// empty, so operator edits and deletions are never fought. +/// +public static class DefaultSeeder +{ + public static async Task SeedAsync(AppDbContext db, CancellationToken cancellationToken) + { + await SeedGroupsAsync(db, cancellationToken); + await SeedSchedulesAsync(db, cancellationToken); + } + + private static async Task SeedGroupsAsync(AppDbContext db, CancellationToken cancellationToken) + { + if (await db.DeviceGroups.AnyAsync(cancellationToken)) + { + return; + } + + var now = DateTimeOffset.UtcNow; + foreach (var (name, description, rules) in PlatformGroups()) + { + db.DeviceGroups.Add(new DeviceGroupEntity + { + Id = Guid.NewGuid(), + Name = name, + Description = description, + Kind = GroupKind.Dynamic, + RulesJson = JsonDefaults.Serialize(rules), + CreatedUtc = now, + UpdatedUtc = now, + UpdatedBy = "system", + }); + } + + await db.SaveChangesAsync(cancellationToken); + } + + private static async Task SeedSchedulesAsync(AppDbContext db, CancellationToken cancellationToken) + { + if (await db.Schedules.AnyAsync(cancellationToken)) + { + return; + } + + var now = DateTimeOffset.UtcNow; + foreach (var (name, cron) in new[] + { + ("Hourly", "0 * * * *"), + ("Daily at 1:00 AM", "0 1 * * *"), + ("Weekdays at 7:00 AM", "0 7 * * MON-FRI"), + ("Weekly · Sunday 2:00 AM", "0 2 * * SUN"), + }) + { + db.Schedules.Add(new ScheduleEntity + { + Id = Guid.NewGuid(), + Name = name, + CronExpression = cron, + TimeZoneId = "UTC", + Enabled = true, + NextRunUtc = ScheduleCron.NextOccurrence(cron, "UTC", now), + CreatedUtc = now, + UpdatedUtc = now, + CreatedBy = "system", + UpdatedBy = "system", + }); + } + + await db.SaveChangesAsync(cancellationToken); + } + + private static IEnumerable<(string Name, string Description, GroupRuleSet Rules)> PlatformGroups() + { + static GroupRuleSet Set(params RuleCondition[] conditions) + => new(RuleCombine.And, [new RuleGroup(RuleCombine.And, conditions)]); + + yield return ("Windows Servers", "Every Windows Server edition.", + Set(new RuleCondition("os.platform", RuleOperator.Equals, "windows"), + new RuleCondition("os.caption", RuleOperator.Contains, "Server"))); + + yield return ("Windows Workstations", "Windows clients (10, 11, ...).", + Set(new RuleCondition("os.platform", RuleOperator.Equals, "windows"), + new RuleCondition("os.caption", RuleOperator.NotContains, "Server"))); + + yield return ("Linux", "All Linux devices.", + Set(new RuleCondition("os.platform", RuleOperator.Equals, "linux"))); + + yield return ("macOS", "All Apple devices.", + Set(new RuleCondition("os.platform", RuleOperator.Equals, "macos"))); + } +} diff --git a/src/Backend/Program.cs b/src/Backend/Program.cs index 7be85c6..7b4e2a5 100644 --- a/src/Backend/Program.cs +++ b/src/Backend/Program.cs @@ -170,6 +170,9 @@ using (var scope = app.Services.CreateScope()) // System roles must exist before any user is created or resolved. await scope.ServiceProvider.GetRequiredService().EnsureSystemRolesAsync(CancellationToken.None); + // First-boot defaults: platform dynamic groups + starter schedules. + await DefaultSeeder.SeedAsync(db, CancellationToken.None); + // First-boot initial admin from environment secrets (never a default password). await scope.ServiceProvider.GetRequiredService().EnsureInitialAdminAsync( builder.Configuration["INITIAL_ADMIN_USERNAME"], -- 2.52.0 From 9ce34e2892188cb157335ebc0bfc939288c18502c120b8fdb725b7ea123d83ef Mon Sep 17 00:00:00 2001 From: gsadmin Date: Sat, 8 Aug 2026 09:10:41 -0400 Subject: [PATCH 03/18] Script editor: vertical flow, pop-out, IntelliSense; triggers move here MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The editor now owns the page: full width with a toolbar (optional IntelliSense toggle and a pop-out that fills the window, Esc restores). IntelliSense is a curated offline provider — common cmdlets, keywords, automatic variables, snippets, plus the script's own parameters and $Secrets bindings — no language server. Below the editor everything flows vertically: an Execution card (target + Execution values, the new name for run values), Schedules, and Triggers; group fan-out and Output sit full width underneath so output finally has room. Triggers belong to scripts now (run on agent ready / registration, scoped to a group or all devices) — the card lives on the script page and the Groups page drops its trigger section. Engine selection is labeled Script Engine with short names (PowerShell 7 / PowerShell 5 / Bash) and a one-line hint describing the selected engine's platform behavior. Function modules are simply Functions everywhere. Co-Authored-By: Claude Fable 5 --- .../src/lib/components/TriggersCard.svelte | 155 ++++++ .../src/lib/editor/powershell-completions.ts | 263 ++++++++++ src/WebUI/src/routes/functions/+page.svelte | 6 +- src/WebUI/src/routes/groups/+page.svelte | 123 +---- .../src/routes/scripts/[id]/+page.svelte | 451 +++++++++++------- 5 files changed, 696 insertions(+), 302 deletions(-) create mode 100644 src/WebUI/src/lib/components/TriggersCard.svelte create mode 100644 src/WebUI/src/lib/editor/powershell-completions.ts diff --git a/src/WebUI/src/lib/components/TriggersCard.svelte b/src/WebUI/src/lib/components/TriggersCard.svelte new file mode 100644 index 0000000..374ec21 --- /dev/null +++ b/src/WebUI/src/lib/components/TriggersCard.svelte @@ -0,0 +1,155 @@ + + +
+

Triggers

+

+ Run this script automatically when a device registers, or when its agent connects and is ready + for jobs. +

+ +
+ + + + +
+ + {#if errorText}

{errorText}

{/if} + + {#if mine.length === 0} +

No triggers yet.

+ {:else} +
    + {#each mine as trigger (trigger.id)} +
  • + + {labels[trigger.triggerType]} + · {trigger.groupName ?? 'All devices'} + {#if trigger.oncePerDevice}· once per device{/if} + + +
  • + {/each} +
+ {/if} +
+ + diff --git a/src/WebUI/src/lib/editor/powershell-completions.ts b/src/WebUI/src/lib/editor/powershell-completions.ts new file mode 100644 index 0000000..d3b7d13 --- /dev/null +++ b/src/WebUI/src/lib/editor/powershell-completions.ts @@ -0,0 +1,263 @@ +/** + * Lightweight PowerShell IntelliSense for the Monaco editor: a curated set of + * common cmdlets, language keywords, automatic variables and snippets, plus + * dynamic entries for the script's own parameters and secret bindings. No + * language server involved — fast, offline and optional. + */ + +/* eslint-disable @typescript-eslint/no-explicit-any */ + +const CMDLETS = [ + 'Get-ChildItem', + 'Get-Content', + 'Set-Content', + 'Add-Content', + 'Get-Item', + 'Get-ItemProperty', + 'Set-ItemProperty', + 'New-Item', + 'New-ItemProperty', + 'Remove-Item', + 'Copy-Item', + 'Move-Item', + 'Rename-Item', + 'Test-Path', + 'Join-Path', + 'Split-Path', + 'Resolve-Path', + 'Get-Location', + 'Set-Location', + 'Get-Process', + 'Stop-Process', + 'Start-Process', + 'Wait-Process', + 'Get-Service', + 'Start-Service', + 'Stop-Service', + 'Restart-Service', + 'Set-Service', + 'Get-CimInstance', + 'Invoke-CimMethod', + 'Get-Date', + 'Start-Sleep', + 'Write-Output', + 'Write-Host', + 'Write-Error', + 'Write-Warning', + 'Write-Verbose', + 'Write-Debug', + 'Write-Progress', + 'Read-Host', + 'Out-String', + 'Out-Null', + 'Out-File', + 'ForEach-Object', + 'Where-Object', + 'Select-Object', + 'Sort-Object', + 'Group-Object', + 'Measure-Object', + 'Compare-Object', + 'Select-String', + 'ConvertTo-Json', + 'ConvertFrom-Json', + 'ConvertTo-Csv', + 'ConvertFrom-Csv', + 'Export-Csv', + 'Import-Csv', + 'Invoke-RestMethod', + 'Invoke-WebRequest', + 'Invoke-Expression', + 'Invoke-Command', + 'Test-Connection', + 'Test-NetConnection', + 'Resolve-DnsName', + 'Get-NetIPAddress', + 'Get-NetAdapter', + 'Compress-Archive', + 'Expand-Archive', + 'Get-FileHash', + 'New-Guid', + 'Get-Random', + 'Get-WinEvent', + 'Get-EventLog', + 'Get-HotFix', + 'Get-ComputerInfo', + 'Restart-Computer', + 'Stop-Computer', + 'Get-LocalUser', + 'Get-LocalGroup', + 'Add-LocalGroupMember', + 'Get-ScheduledTask', + 'Register-ScheduledTask', + 'Unregister-ScheduledTask', + 'Get-Module', + 'Import-Module', + 'Install-PSResource', + 'Find-PSResource', + 'Start-ThreadJob', + 'Get-Job', + 'Receive-Job', + 'Wait-Job', + 'Remove-Job', + 'Get-Variable', + 'Set-Variable', + 'Get-Command', + 'Get-Member', + 'Get-Help', + 'Get-Error', + 'New-Object', + 'Add-Type', + 'Get-Acl', + 'Set-Acl', + 'ConvertTo-SecureString', + 'ConvertFrom-SecureString' +]; + +const KEYWORDS = [ + 'if', + 'elseif', + 'else', + 'switch', + 'foreach', + 'for', + 'while', + 'do', + 'until', + 'break', + 'continue', + 'return', + 'function', + 'param', + 'begin', + 'process', + 'end', + 'try', + 'catch', + 'finally', + 'throw', + 'trap', + 'class', + 'enum', + 'using', + 'in', + 'exit' +]; + +const AUTOMATIC_VARIABLES = [ + '$_', + '$PSItem', + '$args', + '$error', + '$LASTEXITCODE', + '$PSVersionTable', + '$PSScriptRoot', + '$env:COMPUTERNAME', + '$env:USERNAME', + '$env:TEMP', + '$env:ProgramFiles', + '$true', + '$false', + '$null', + '$ErrorActionPreference', + '$ProgressPreference' +]; + +const SNIPPETS: { label: string; detail: string; insert: string }[] = [ + { + label: 'param block', + detail: 'Script parameter declaration', + insert: 'param(\n [string]$${1:Name}${2:,\n [int]$${3:Count} = ${4:1}}\n)\n' + }, + { + label: 'try / catch', + detail: 'Error handling block', + insert: 'try {\n ${1}\n}\ncatch {\n Write-Error "${2:Operation failed}: $_"\n}\n' + }, + { + label: 'foreach loop', + detail: 'Iterate a collection', + insert: 'foreach ($${1:item} in $${2:collection}) {\n ${3}\n}\n' + }, + { + label: 'progress loop', + detail: 'Loop reporting Write-Progress', + insert: + '1..${1:10} | ForEach-Object {\n Write-Progress -Activity \'${2:Working}\' -Status "Step $_ of ${1:10}" -PercentComplete ($_ * ${3:10})\n ${4}\n}\n' + } +]; + +export interface CompletionContext { + /** Names of the script's declared parameters. */ + parameterNames: () => string[]; + /** Names bound in the secrets dictionary. */ + secretNames: () => string[]; + /** The secrets variable name (default "Secrets"). */ + secretsVariable: () => string; +} + +/** Registers the provider for the given language; returns its disposable. */ +export function registerPowerShellCompletions( + monaco: any, + language: string, + context: CompletionContext +): { dispose(): void } { + return monaco.languages.registerCompletionItemProvider(language, { + triggerCharacters: ['-', '$', '.'], + provideCompletionItems(model: any, position: any) { + const word = model.getWordUntilPosition(position); + const range = { + startLineNumber: position.lineNumber, + endLineNumber: position.lineNumber, + startColumn: word.startColumn, + endColumn: word.endColumn + }; + const kinds = monaco.languages.CompletionItemKind; + + const suggestions: any[] = [ + ...CMDLETS.map((c) => ({ + label: c, + kind: kinds.Function, + insertText: c, + range + })), + ...KEYWORDS.map((k) => ({ + label: k, + kind: kinds.Keyword, + insertText: k, + range + })), + ...AUTOMATIC_VARIABLES.map((v) => ({ + label: v, + kind: kinds.Variable, + insertText: v, + range + })), + ...SNIPPETS.map((s) => ({ + label: s.label, + kind: kinds.Snippet, + detail: s.detail, + insertText: s.insert, + insertTextRules: monaco.languages.CompletionItemInsertTextRule.InsertAsSnippet, + range + })), + ...context.parameterNames().map((p) => ({ + label: `$${p}`, + kind: kinds.Variable, + detail: 'Script parameter', + insertText: `$${p}`, + range + })), + ...context.secretNames().map((s) => ({ + label: `$${context.secretsVariable()}.${s}`, + kind: kinds.Variable, + detail: 'Secret binding', + insertText: `$${context.secretsVariable()}.${s}`, + range + })) + ]; + + return { suggestions }; + } + }); +} diff --git a/src/WebUI/src/routes/functions/+page.svelte b/src/WebUI/src/routes/functions/+page.svelte index 20a880a..8c4cf06 100644 --- a/src/WebUI/src/routes/functions/+page.svelte +++ b/src/WebUI/src/routes/functions/+page.svelte @@ -55,7 +55,7 @@ async function remove() { if (!selected) return; - if (!confirm(`Delete function module “${selected.name}”?`)) return; + if (!confirm(`Delete function “${selected.name}”?`)) return; await api.deleteFunction(selected.id); selected = null; name = ''; @@ -65,7 +65,7 @@
-

Function modules

+

Functions

@@ -81,7 +81,7 @@ {#each Array(3) as _, i (i)}
loading…
{/each} {:else if modules.length === 0} - + {:else}