From 46b9c0e4e3be7d4b19aaa4ffd1eef82c1ff87788 Mon Sep 17 00:00:00 2001 From: "sascha.koenig" Date: Wed, 11 Feb 2026 14:14:55 +0100 Subject: [PATCH] fix: list_outline_collections.sh - correct jq parsing to output valid JSON array --- .../scripts/list_outline_collections.sh | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 skills/doc-translator/scripts/list_outline_collections.sh diff --git a/skills/doc-translator/scripts/list_outline_collections.sh b/skills/doc-translator/scripts/list_outline_collections.sh new file mode 100755 index 0000000..03dabca --- /dev/null +++ b/skills/doc-translator/scripts/list_outline_collections.sh @@ -0,0 +1,32 @@ +#!/usr/bin/env bash +# List all collections available in Outline +# +# Usage: +# list_outline_collections.sh +# +# Environment: +# OUTLINE_API_KEY - Bearer token for wiki.az-gruppe.com API +# +# Output (JSON): +# [{"id": "...", "name": "...", "url": "..."}, ...] + +set -euo pipefail + +# List collections +RESPONSE=$(curl -s -X POST "https://wiki.az-gruppe.com/api/collections.list" \ + -H "Authorization: Bearer $OUTLINE_API_KEY" \ + -H "Content-Type: application/json" \ + -d '{}') + +# Check for errors +if echo "$RESPONSE" | jq -e '.error' > /dev/null 2>&1; then + ERROR_MSG=$(echo "$RESPONSE" | jq -r '.message // "Failed to list collections"') + echo "{\"success\": false, \"error\": \"$ERROR_MSG\", \"response\": \"$RESPONSE\"}" >&2 + exit 1 +fi + +# Extract collection list +COLLECTIONS=$(echo "$RESPONSE" | jq -r '.data[] | {id: .id, name: .name, url: .url}') + +# Output as JSON array +echo "$COLLECTIONS" | jq -s '.'