Compare commits

...
8 Commits
Author SHA1 Message Date
ars9 bba6eb2f94 chore: license the project under mit
CI / server (push) Successful in 1m9s
CI / client (push) Successful in 1m23s
CI / version (push) Successful in 6s
CI / image (push) Successful in 2m7s
- add the mit LICENSE and set license and author in all package.json
  files, plus a license section in the readme
- generate the license notices of all shipped production dependencies
  and node.js in a dockerfile stage and serve them at /licenses.txt,
  linked from the sidebar footer
- keep license files when slimming node_modules in the image
- add oci labels, with the version passed in by ci
- document licensing in the development docs
- bump version to 1.22.2
2026-10-01 11:44:51 +03:00
ars9 531754c3fa test(server): stop timing-dependent failures on busy ci runners
- raise the jest test timeout to 30s: building the nest app in
  beforeAll can exceed the 5s default when all suites start at once
- accept any run status when reading back a just-created run, since
  the scheduler may already have picked it up
2026-10-01 11:44:51 +03:00
ars9 cafc126d1b ci: set the image registry explicitly
- use REGISTRY (git.hq.ars9.space) for login and image tags instead of
  deriving it from the server url, which is the runner's registration
  address and may be internal-only
- document how jobs reach gitea when the runner uses an internal address
2026-10-01 11:11:39 +03:00
ars9 f24a1b7dd5 ci: add gitea actions for quality checks and versioned images
- run server lint, type-check, tests and build, and client lint, build
  and storybook tests on master and pull requests
- when a push to master changes the package.json version, build the
  docker image and push it to the gitea registry tagged with the
  version and latest
- document the workflow and the REGISTRY_TOKEN secret
2026-10-01 11:07:42 +03:00
ars9 63c2df96f1 build(docker): slim down the runtime image
- install production dependencies and chromium in a separate stage
- drop source maps, typescript sources and declarations, docs,
  typeorm's browser build, better-sqlite3's c sources and ffmpeg
- base the runtime on debian:bookworm-slim with only the node binary
- document the image layout
- bump version to 1.22.1
2026-10-01 10:52:47 +03:00
ars9 23fa302b25 feat(scenarios): export used snippets with a scenario
- list the snippets a scenario uses in the export dialog, checked by
  default, with the versions the scenario uses
- export each selected snippet once per used version (latest and
  pinned) via the new snippetIds query parameter
- resolve used snippets from the exported version's steps
- show the scenario version in the export dialog
- document the export query parameters
- bump version to 1.22.0
2026-10-01 10:45:39 +03:00
ars9 f43d902297 feat(credentials): hide credential data until revealed
- add a RevealableCodeBlock ui component that renders its code only
  after the user clicks Reveal, with a storybook story
- use it for the data section of the credential page
- bump version to 1.21.1
2026-10-01 10:36:37 +03:00
ars9 2129708819 feat(ui): color-code uuid badges and highlight them on hover
- show a circle colored by the first 6 hex digits of the uuid,
  bordered with the badge text color for contrast in both themes
- lighten the uuid badge background on hover
- let Badge accept a className
- add a storybook story with six sample uuids and a randomize button
- bump version to 1.21.0
2026-10-01 10:23:50 +03:00
34 changed files with 791 additions and 39 deletions

No files matched your search

+106
View File
@@ -0,0 +1,106 @@
# Code quality checks on master and pull requests. On a push to master that
# changes the version in the root package.json, also builds the Docker image
# and pushes it to this Gitea instance's container registry, tagged with that
# version and `latest`.
#
# Needs a repository (or owner) secret REGISTRY_TOKEN: a Gitea access token
# with package write access for the repository owner. The registry host is
# set explicitly below rather than taken from the server URL, which is the
# address the runner was registered with and may be internal-only.
name: CI
on:
push:
branches: [master]
pull_request:
env:
REGISTRY: git.hq.ars9.space
jobs:
server:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- run: npm ci -w server
- name: Lint
run: npm run -w server lint -- --max-warnings=0
- name: Type-check
run: npx tsc --noEmit -p server/tsconfig.json
- name: Test
run: npm test -w server
- name: Build
run: npm run -w server build
client:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: npm
- run: npm ci -w client
- name: Lint
run: npm run -w client lint -- --max-warnings=0
- name: Build
run: npm run -w client build
- name: Install headless Chromium for Storybook tests
run: npx playwright install --with-deps --only-shell chromium
- name: Storybook tests
run: npm run -w client test:storybook
# Compares the root package.json version with the one before the push
version:
if: github.event_name == 'push'
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check.outputs.version }}
changed: ${{ steps.check.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: check
env:
BEFORE: ${{ github.event.before }}
run: |
version=$(node -p "require('./package.json').version")
previous=""
if git cat-file -e "${BEFORE}^{commit}" 2>/dev/null; then
previous=$(git show "${BEFORE}:package.json" | node -p "JSON.parse(require('fs').readFileSync(0, 'utf8')).version")
fi
echo "version: ${previous:-none} -> ${version}"
echo "version=${version}" >> "$GITHUB_OUTPUT"
if [ "$version" != "$previous" ]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
image:
needs: [server, client, version]
if: needs.version.outputs.changed == 'true'
runs-on: ubuntu-latest
env:
VERSION: ${{ needs.version.outputs.version }}
steps:
- uses: actions/checkout@v4
- name: Log in to the registry
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
OWNER: ${{ github.repository_owner }}
run: |
echo "IMAGE=${REGISTRY}/$(echo "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"
echo "$REGISTRY_TOKEN" | docker login "$REGISTRY" -u "$OWNER" --password-stdin
- name: Build
run: docker build --build-arg VERSION="${VERSION}" -t "${IMAGE}:${VERSION}" -t "${IMAGE}:latest" .
- name: Push
run: |
docker push "${IMAGE}:${VERSION}"
docker push "${IMAGE}:latest"
+54
View File
@@ -2,6 +2,60 @@
All notable changes to this project will be documented in this file.
## 1.22.2 - 2026-10-01
Changes since 1.22.1:
### Added
- MIT license (`LICENSE`), declared in all `package.json` files and the README.
- The Docker image includes the license notices of everything it ships: `scripts/third-party-licenses.mjs` collects the license of every production dependency of the client and server, the Node.js license is added, and the result is served at `/licenses.txt`, linked as "Licenses" in the sidebar footer.
- OCI image labels for title, version, license and source; CI passes the version as the `VERSION` build arg.
### Fixed
- The Docker image keeps packages' `LICENSE.md`/`NOTICE.md` files, which the 1.22.1 slimming step deleted along with other Markdown files.
## 1.22.1 - 2026-10-01
Changes since 1.22.0:
### Changed
- The Docker image is about 20% smaller (1.09 GB → 876 MB on disk, 251 MB → 220 MB compressed). Production dependencies and Chromium are installed in a separate stage that drops files nothing loads at runtime (source maps, TypeScript sources and declarations, docs, TypeORM's browser build, better-sqlite3's C sources, Playwright's ffmpeg). The runtime image is `debian:bookworm-slim` with only the `node` binary, so it no longer contains `npm`, `npx`, `yarn` or `corepack`.
## 1.22.0 - 2026-10-01
Changes since 1.21.1:
### Added
- The Export Scenario dialog lists the snippets the scenario uses (including ones used only through other snippets), all checked by default. A selected snippet is exported once per version the scenario uses: the latest for `runSnippet("alias")`, plus each version pinned with `alias@N`. `GET /scenarios/:id/export` takes the new `snippetIds` query parameter for this.
- The Export Scenario dialog shows the scenario version next to its name and id.
## 1.21.1 - 2026-10-01
Changes since 1.21.0:
### Changed
- The credential page hides the credential data when it opens; a Reveal button shows it and Hide hides it again. The data is not rendered on the page until revealed.
### Added
- A `RevealableCodeBlock` UI component (a CodeBlock that starts hidden behind a Reveal/Hide button), with a Storybook story.
## 1.21.0 - 2026-10-01
Changes since 1.20.2:
### Added
- UUID badges show a small colored circle in front of the short id. Its color comes from the first 6 hex digits of the UUID, so the same id always gets the same color, and its border uses the badge text color to stay visible in both themes.
- UUID badges get lighter on hover to show they can be clicked.
- `Badge` accepts an optional `className`.
- A Storybook "Colors" story for UuidBadge with six sample ids and a button to randomize them.
## 1.20.2 - 2026-09-30
Changes since 1.20.1:
+72 -7
View File
@@ -28,8 +28,70 @@ COPY server/tsconfig*.json ./server/
COPY server/src ./server/src
RUN npm run -w server build
# ── Runtime dependencies ──────────────────────────────────────────────────────
FROM node:24-slim AS runtime-deps
WORKDIR /app
COPY package*.json ./
COPY server/package.json ./server/
# Production dependencies and Playwright's headless-only Chromium build,
# matching the installed Playwright version. All browser launches are
# headless, so the full desktop Chromium (GTK, Mesa/LLVM, icon themes) isn't
# needed, and neither is ffmpeg (only used for video recording).
#
# Then drop what nothing loads at runtime: source maps, TypeScript sources and
# declarations, docs (but not license files), TypeORM's browser build and
# better-sqlite3's C sources (the addon is already compiled).
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN npm ci --omit=dev -w server \
&& npx playwright install --only-shell chromium \
&& rm -rf /ms-playwright/ffmpeg-* \
&& find node_modules -type f \( \
-name '*.map' -o -name '*.ts' -o -name '*.mts' -o -name '*.cts' \
-o \( \( -iname '*.md' -o -iname '*.markdown' \) \
! -iname 'licen[cs]e*' ! -iname 'notice*' ! -iname 'copying*' \) \
\) -delete \
&& rm -rf node_modules/typeorm/browser \
node_modules/better-sqlite3/deps \
node_modules/better-sqlite3/src
# ── License notices ───────────────────────────────────────────────────────────
# One file with the project's LICENSE and the license of everything the image
# ships: the production dependencies of both workspaces (the client's are
# bundled into its build, so their license files aren't in the image
# otherwise) and the Node.js binary, whose LICENSE the node image doesn't
# include.
FROM node:24-slim AS licenses
WORKDIR /app
COPY package*.json LICENSE ./
COPY client/package.json ./client/
COPY server/package.json ./server/
COPY scripts/third-party-licenses.mjs ./scripts/
RUN npm ci --omit=dev --ignore-scripts \
&& node scripts/third-party-licenses.mjs > licenses.txt \
&& node -e ' \
const url = `https://raw.githubusercontent.com/nodejs/node/v${process.versions.node}/LICENSE`; \
fetch(url).then(async (r) => { \
if (!r.ok) throw new Error(`${url}: ${r.status}`); \
const rule = "-".repeat(79); \
process.stdout.write(`\n${rule}\n\nnode@${process.versions.node}\nLicense: MIT\n\n${(await r.text()).trim()}\n`); \
}).catch((e) => { console.error(e.message); process.exit(1); });' >> licenses.txt
# ── Runtime ───────────────────────────────────────────────────────────────────
FROM node:24-slim AS runtime
# Plain Debian with just the node binary: npm, yarn, corepack and the C
# headers that come with the node image aren't needed to run the app.
FROM debian:bookworm-slim AS runtime
# Set by CI from the root package.json version
ARG VERSION=dev
LABEL org.opencontainers.image.title="liqa" \
org.opencontainers.image.version="${VERSION}" \
org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.source="https://git.hq.ars9.space/ars9/liqa"
# Runtime only: in the build stages it would make npm ci skip devDependencies
ENV NODE_ENV=production
@@ -63,22 +125,25 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
libxrandr2 \
&& rm -rf /var/lib/apt/lists/*
COPY --from=runtime-deps /usr/local/bin/node /usr/local/bin/node
WORKDIR /app
COPY package*.json ./
COPY server/package.json ./server/
# Playwright's headless-only Chromium build, matching the installed Playwright
# version. All browser launches are headless, so the full desktop Chromium
# (GTK, Mesa/LLVM, icon themes) isn't needed.
ENV PLAYWRIGHT_BROWSERS_PATH=/ms-playwright
RUN npm ci --omit=dev -w server \
&& npx playwright install --only-shell chromium \
&& npm cache clean --force
COPY --from=runtime-deps /ms-playwright /ms-playwright
COPY --from=runtime-deps /app/node_modules ./node_modules
COPY --from=server-build /app/server/dist ./dist
COPY --from=client-build /app/client/dist ./client
# The project's license, and every shipped component's license notices (also
# served by the app at /licenses.txt)
COPY LICENSE ./
COPY --from=licenses /app/licenses.txt ./client/licenses.txt
# Serve the built client at / (see server/src/common/client-static.ts)
ENV CLIENT_DIR=client
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2026 Andrii Arsenin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+8
View File
@@ -38,3 +38,11 @@ Scenarios, snippets, environments and credentials can be exported as YAML and im
- [docs/mcp.md](docs/mcp.md) - MCP tool reference
- [docs/development.md](docs/development.md) - setup, configuration, running, testing, linting, Docker
- [CHANGELOG.md](CHANGELOG.md) - release notes
---
## License
[MIT](LICENSE) © 2026 Andrii Arsenin
Third-party packages keep their own licenses. The Docker image includes all their notices, and the app serves them at `/licenses.txt` (linked as "Licenses" in the sidebar footer). See [docs/development.md](docs/development.md#licenses).
@@ -0,0 +1,33 @@
import type { Meta, StoryObj } from '@storybook/react-vite';
import { expect, userEvent, within } from 'storybook/test';
import { RevealableCodeBlock } from '../../src/ui/RevealableCodeBlock/RevealableCodeBlock';
const meta: Meta<typeof RevealableCodeBlock> = {
title: 'UI/RevealableCodeBlock',
component: RevealableCodeBlock,
parameters: { layout: 'padded' },
tags: ['autodocs'],
};
export default meta;
type Story = StoryObj<typeof RevealableCodeBlock>;
export const Default: Story = {
args: {
language: 'json',
code: JSON.stringify({ username: 'admin', password: 's3cr3t-p4ss' }, null, 2),
},
play: async ({ canvasElement }) => {
// The code is not rendered until revealed, and hidden again on the second click
const canvas = within(canvasElement);
const toggle = canvas.getByRole('button');
await expect(canvasElement).not.toHaveTextContent('s3cr3t-p4ss');
await expect(toggle).toHaveAttribute('aria-expanded', 'false');
await userEvent.click(toggle);
await expect(canvasElement.querySelector('code')).toHaveTextContent('s3cr3t-p4ss');
await expect(toggle).toHaveAttribute('aria-expanded', 'true');
await userEvent.click(toggle);
await expect(canvasElement).not.toHaveTextContent('s3cr3t-p4ss');
},
};
@@ -1,5 +1,7 @@
import type { Meta, StoryObj } from '@storybook/react-vite';
import { useState } from 'react';
import { expect, within } from 'storybook/test';
import { Button } from '../../src/ui/Button/Button';
import { UuidBadge } from '../../src/ui/UuidBadge/UuidBadge';
const meta: Meta<typeof UuidBadge> = {
@@ -19,3 +21,43 @@ export const Default: Story = {
await expect(badge).toHaveTextContent('61d2…0b2e');
},
};
const SAMPLE_IDS = [
'61d2b1c2-7664-4dca-974f-436c2ee90b2e',
'e83f0a5d-1b9c-4f27-8d6e-2a4c9b7f1e03',
'0c7a94f1-3e52-4b8d-a1f6-9d2e5c8b4a70',
'f4b21e8c-9a07-4c63-b5d2-7e1f0a3c6d98',
'8d5e3a10-c4f7-4e29-9b81-5f6a2d0c7e14',
'2a9fc067-58d3-4a1e-86b4-c3e7f19d5b2a',
];
function Gallery() {
const [ids, setIds] = useState(SAMPLE_IDS);
return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'flex-start', gap: 12 }}>
<div style={{ display: 'flex', flexWrap: 'wrap', gap: 16 }}>
{ids.map((id) => (
<UuidBadge key={id} id={id} />
))}
</div>
<Button
size="sm"
variant="secondary"
onClick={() => setIds(ids.map(() => crypto.randomUUID()))}
>
Randomize
</Button>
</div>
);
}
export const Colors: Story = {
render: () => <Gallery />,
play: async ({ canvasElement }) => {
// Each sample id gets its own badge
const canvas = within(canvasElement);
for (const id of SAMPLE_IDS) {
await expect(canvas.getByTitle(id)).toBeInTheDocument();
}
},
};
+2
View File
@@ -1,6 +1,8 @@
{
"name": "liqa-client",
"private": true,
"license": "MIT",
"author": "Andrii Arsenin",
"type": "module",
"scripts": {
"dev": "vite",
+10
View File
@@ -52,6 +52,16 @@
white-space: nowrap;
}
.versionLink {
color: inherit;
text-decoration: none;
}
.versionLink:hover,
.versionLink:focus-visible {
text-decoration: underline;
}
.navItem {
display: flex;
align-items: center;
+11 -1
View File
@@ -140,7 +140,17 @@ export default function App() {
<div className={styles.sideFooter}>
<ThemeSwitcher />
<div className={styles.version}>v{__APP_VERSION__}</div>
<div className={styles.version}>
v{__APP_VERSION__} ·{' '}
<a
className={styles.versionLink}
href="/licenses.txt"
target="_blank"
rel="noopener noreferrer"
>
{t('nav.licenses')}
</a>
</div>
</div>
</div>
</SidePanel>
+5 -1
View File
@@ -247,9 +247,10 @@ export const scenarios = {
},
exportScenario(
id: string,
options: { includeEnvironment: boolean; credentialIds: string[] } = {
options: { includeEnvironment: boolean; credentialIds: string[]; snippetIds: string[] } = {
includeEnvironment: false,
credentialIds: [],
snippetIds: [],
},
): Promise<string> {
const params = new URLSearchParams();
@@ -257,6 +258,9 @@ export const scenarios = {
for (const cid of options.credentialIds) {
params.append('credentialIds', cid);
}
for (const sid of options.snippetIds) {
params.append('snippetIds', sid);
}
return request(`/scenarios/${id}/export?${params.toString()}`);
},
exportE2eTestUrl(id: string): string {
@@ -61,3 +61,8 @@
cursor: pointer;
accent-color: var(--color-primary);
}
.versions {
color: var(--color-text-muted);
font-size: var(--font-size-xs);
}
@@ -1,7 +1,7 @@
import { useTranslation } from 'react-i18next';
import { X, Upload } from 'lucide-react';
import { Modal, Button, UuidBadge } from '../../ui';
import type { Scenario, ScenarioCredential } from '../../api';
import type { Scenario, ScenarioCredential, UsedSnippet } from '../../api';
import styles from './ExportScenarioModal.module.css';
export interface ExportScenarioModalProps {
@@ -13,6 +13,9 @@ export interface ExportScenarioModalProps {
onIncludeEnvironmentChange: (v: boolean) => void;
includedCredentialIds: Set<string>;
onCredentialToggle: (id: string, checked: boolean) => void;
usedSnippets: UsedSnippet[];
includedSnippetIds: Set<string>;
onSnippetToggle: (id: string, checked: boolean) => void;
onClose: () => void;
onExport: () => void;
isExporting: boolean;
@@ -27,12 +30,24 @@ export function ExportScenarioModal({
onIncludeEnvironmentChange,
includedCredentialIds,
onCredentialToggle,
usedSnippets,
includedSnippetIds,
onSnippetToggle,
onClose,
onExport,
isExporting,
}: ExportScenarioModalProps) {
const { t } = useTranslation();
// One row per snippet, listing every version the scenario uses (latest or pinned)
const snippetRows = new Map<string, { alias: string; versions: number[] }>();
for (const s of usedSnippets) {
const row = snippetRows.get(s.id) ?? { alias: s.alias, versions: [] };
const version = s.pinnedVersion ?? s.version;
if (!row.versions.includes(version)) row.versions.push(version);
snippetRows.set(s.id, row);
}
return (
<Modal
open={open}
@@ -64,6 +79,10 @@ export function ExportScenarioModal({
<UuidBadge id={scenario.id} />
</span>
</div>
<div className={styles.metaRow}>
<span className={styles.metaLabel}>{t('scenarios.field_version')}</span>
<span className={styles.metaValue}>v{scenario.version}</span>
</div>
</div>
{environment && (
@@ -95,6 +114,25 @@ export function ExportScenarioModal({
))}
</div>
)}
{snippetRows.size > 0 && (
<div className={styles.section}>
<h4 className={styles.sectionTitle}>{t('scenarios.export_include_snippets')}</h4>
{[...snippetRows].map(([snippetId, row]) => (
<label key={snippetId} className={styles.checkboxRow}>
<input
type="checkbox"
checked={includedSnippetIds.has(snippetId)}
onChange={(e) => onSnippetToggle(snippetId, e.target.checked)}
/>
<span>{row.alias}</span>
<span className={styles.versions}>
{row.versions.map((v) => `v${v}`).join(', ')}
</span>
</label>
))}
</div>
)}
</div>
)}
</Modal>
+8 -3
View File
@@ -22,6 +22,7 @@
"generic": "Something went wrong. Please try again."
},
"nav": {
"licenses": "Licenses",
"environments": "Environments",
"credentials": "Credentials",
"snippets": "Snippets",
@@ -217,11 +218,10 @@
"export_modal_title": "Export Scenario",
"export_include_environment": "Include Environment",
"export_include_credentials": "Include Credentials",
"export_include_snippets": "Include Snippets",
"form_timeout": "Scenario Timeout (seconds)",
"form_timeout_placeholder": "Default: 600",
"form_timeout_hint": "Max seconds for the entire scenario run (default: 600)",
"field_name": "Name",
"field_id": "ID"
"form_timeout_hint": "Max seconds for the entire scenario run (default: 600)"
},
"theme": {
"switch_to_light": "Switch to light theme",
@@ -229,6 +229,11 @@
"light_mode": "Light mode",
"dark_mode": "Dark mode"
},
"revealable": {
"hidden": "Hidden so secrets aren't exposed on screen.",
"reveal": "Reveal",
"hide": "Hide"
},
"pagination": {
"prev": "Previous page",
"next": "Next page",
@@ -3,11 +3,18 @@ import { useNavigate, useParams } from 'react-router-dom';
import { useTranslation } from 'react-i18next';
import { usePageTitle } from '../../hooks/usePageTitle';
import { Upload, Pencil, Trash2, KeyRound } from 'lucide-react';
import { CodeBlock } from '../../ui';
import { stringify as yamlStringify } from 'yaml';
import { credentials } from '../../api';
import type { Credential } from '../../api';
import { Breadcrumbs, Button, Card, DescriptionList, Timestamp, UuidBadge } from '../../ui';
import {
Breadcrumbs,
Button,
Card,
DescriptionList,
RevealableCodeBlock,
Timestamp,
UuidBadge,
} from '../../ui';
import { DeleteConfirmationModal } from '../../components/modals';
import styles from '../Page.module.css';
@@ -117,7 +124,8 @@ export function CredentialDetailPage() {
<div className={styles.stepsSection}>
<h2 className={styles.sectionHeading}>{t('credentials.section_data')}</h2>
<Card>
<CodeBlock
<RevealableCodeBlock
key={credential.id}
language="json"
code={(() => {
try {
@@ -94,6 +94,7 @@ export function ScenarioDetailPage() {
const [exportModalOpen, setExportModalOpen] = useState(false);
const [includeEnvironment, setIncludeEnvironment] = useState(true);
const [includedCredentialIds, setIncludedCredentialIds] = useState<Set<string>>(new Set());
const [includedSnippetIds, setIncludedSnippetIds] = useState<Set<string>>(new Set());
const [isExporting, setIsExporting] = useState(false);
// Files state
@@ -212,8 +213,9 @@ export function ScenarioDetailPage() {
const handleOpenExportModal = () => {
if (!scenario) return;
// Initialise all credential checkboxes to checked
// Initialise all credential and snippet checkboxes to checked
setIncludedCredentialIds(new Set(scenarioCreds.map((sc) => sc.credentialId)));
setIncludedSnippetIds(new Set(usedSnippets.map((s) => s.id)));
setIncludeEnvironment(true);
setExportModalOpen(true);
};
@@ -226,6 +228,7 @@ export function ScenarioDetailPage() {
const yamlContent = await scenarios.exportScenario(scenario.id, {
includeEnvironment,
credentialIds: credIds,
snippetIds: Array.from(includedSnippetIds),
});
const blob = new Blob([yamlContent], { type: 'application/yaml' });
const url = URL.createObjectURL(blob);
@@ -899,6 +902,16 @@ export function ScenarioDetailPage() {
return next;
});
}}
usedSnippets={usedSnippets}
includedSnippetIds={includedSnippetIds}
onSnippetToggle={(snippetId, checked) => {
setIncludedSnippetIds((prev) => {
const next = new Set(prev);
if (checked) next.add(snippetId);
else next.delete(snippetId);
return next;
});
}}
onClose={() => setExportModalOpen(false)}
onExport={handleExport}
isExporting={isExporting}
+3 -2
View File
@@ -6,12 +6,13 @@ export type BadgeVariant = 'success' | 'error' | 'warning' | 'info' | 'neutral'
export interface BadgeProps {
variant?: BadgeVariant;
dot?: boolean;
className?: string;
children: React.ReactNode;
}
export function Badge({ variant = 'neutral', dot = false, children }: BadgeProps) {
export function Badge({ variant = 'neutral', dot = false, className, children }: BadgeProps) {
return (
<span className={[styles.badge, styles[variant]].join(' ')}>
<span className={[styles.badge, styles[variant], className].filter(Boolean).join(' ')}>
{dot && <span className={styles.dot} aria-hidden="true" />}
{children}
</span>
@@ -0,0 +1,17 @@
.wrapper {
display: flex;
align-items: flex-start;
gap: var(--space-3);
}
.content {
flex: 1;
min-width: 0;
}
.placeholder {
margin: 0;
color: var(--color-text-muted);
font-size: var(--font-size-sm);
line-height: 1.6;
}
@@ -0,0 +1,38 @@
import { useState } from 'react';
import { useTranslation } from 'react-i18next';
import { Eye, EyeOff } from 'lucide-react';
import { Button } from '../Button/Button';
import { CodeBlock } from '../CodeBlock/CodeBlock';
import styles from './RevealableCodeBlock.module.css';
export interface RevealableCodeBlockProps {
code: string;
language?: string;
}
/** A CodeBlock that starts hidden; the code is only rendered after the user reveals it. */
export function RevealableCodeBlock({ code, language }: RevealableCodeBlockProps) {
const { t } = useTranslation();
const [revealed, setRevealed] = useState(false);
return (
<div className={styles.wrapper}>
<div className={styles.content}>
{revealed ? (
<CodeBlock code={code} language={language} />
) : (
<p className={styles.placeholder}>{t('revealable.hidden')}</p>
)}
</div>
<Button
variant="secondary"
size="sm"
aria-expanded={revealed}
onClick={() => setRevealed((r) => !r)}
>
{revealed ? <EyeOff size={14} /> : <Eye size={14} />}
{revealed ? t('revealable.hide') : t('revealable.reveal')}
</Button>
</div>
);
}
@@ -4,6 +4,23 @@
position: relative;
}
.badge {
transition: background var(--transition);
}
.badge:hover {
background: color-mix(in srgb, var(--color-neutral-bg) 85%, white);
}
.swatch {
width: 8px;
height: 8px;
border-radius: 50%;
border: 1px solid currentColor;
box-sizing: border-box;
flex-shrink: 0;
}
.button {
all: unset;
cursor: pointer;
+10 -1
View File
@@ -7,9 +7,15 @@ export interface UuidBadgeProps {
id: string;
}
function uuidColor(id: string): string | null {
const hex = id.replace(/-/g, '').slice(0, 6);
return /^[0-9a-f]{6}$/i.test(hex) ? `#${hex}` : null;
}
export function UuidBadge({ id }: UuidBadgeProps) {
const [copied, setCopied] = useState(false);
const short = `${id.slice(0, 4)}…${id.slice(-4)}`;
const color = uuidColor(id);
const handleClick = (e: React.MouseEvent) => {
e.stopPropagation();
@@ -21,7 +27,10 @@ export function UuidBadge({ id }: UuidBadgeProps) {
return (
<span className={styles.wrapper} title={copied ? 'Copied!' : id}>
<Badge variant="neutral">
<Badge variant="neutral" className={styles.badge}>
{color && (
<span className={styles.swatch} style={{ background: color }} aria-hidden="true" />
)}
<button type="button" className={styles.button} onClick={handleClick}>
{short}
</button>
+3
View File
@@ -43,6 +43,9 @@ export type { SearchProps } from './Search/Search';
export { CodeBlock } from './CodeBlock/CodeBlock';
export type { CodeBlockProps } from './CodeBlock/CodeBlock';
export { RevealableCodeBlock } from './RevealableCodeBlock/RevealableCodeBlock';
export type { RevealableCodeBlockProps } from './RevealableCodeBlock/RevealableCodeBlock';
export { CodeEditor } from './CodeEditor/CodeEditor';
export type { CodeEditorProps } from './CodeEditor/CodeEditor';
+39
View File
@@ -204,6 +204,8 @@ The root `Dockerfile` builds a single image with the whole application: it build
The runtime image uses Playwright's headless-only Chromium build (`chromium-headless-shell`) with just the shared libraries it links against, plus DejaVu and Liberation fonts (Liberation is metric-compatible with Arial/Times, so pages lay out as they would with those fonts). All browser launches are headless, so the full desktop Chromium isn't installed. If a new Playwright version needs another library, `ldd` on the `chrome-headless-shell` binary in the image lists what's missing.
To keep the image small, production dependencies and the browser are installed in a separate `runtime-deps` stage, which drops what nothing loads at runtime (source maps, TypeScript sources and declarations, docs, TypeORM's browser build, better-sqlite3's C sources, and Playwright's ffmpeg, which is only used for video recording). The runtime stage is plain `debian:bookworm-slim` with only the `node` binary copied in, so the image has no `npm`, `npx`, `yarn` or `corepack`. If a package starts failing in the image only, check whether it reads one of the deleted file types at runtime.
```bash
docker compose build
```
@@ -216,6 +218,43 @@ docker compose build --no-cache
---
## Licenses
The project is MIT-licensed ([LICENSE](../LICENSE)); the `license` field in all three `package.json` files says the same.
The image ships third-party code: the server's production dependencies, the client's production dependencies (bundled into its build), the Node.js binary, Chromium and Debian packages. Their notices are in the image as follows:
- **npm packages and Node.js**: the `licenses` stage of the Dockerfile runs `scripts/third-party-licenses.mjs`, which writes the project's LICENSE followed by every production dependency of both workspaces with its license files (or, for the few packages that ship none, the declared license, author and source). Node.js's LICENSE for the exact version in the image is fetched from GitHub and appended. The result is `/app/client/licenses.txt`, which the app serves at `/licenses.txt`. The build fails if a package has no license information at all.
- **Server packages' own license files** stay in `node_modules`: the slimming step deletes Markdown files except `LICENSE*`, `NOTICE*` and `COPYING*`.
- **Chromium**: `LICENSE.headless_shell` next to the binary under `/ms-playwright`.
- **Debian packages**: `/usr/share/doc/*/copyright`.
The image also has the OCI labels `org.opencontainers.image.licenses=MIT`, `source`, `title` and `version` (CI passes the version as the `VERSION` build arg).
To check the notices locally, or to review a new dependency's license, run from the repository root:
```bash
node scripts/third-party-licenses.mjs > /tmp/licenses.txt
```
Before adding a dependency, check its license is compatible with MIT distribution (permissive licenses such as MIT, ISC, BSD, Apache-2.0 are; copyleft ones such as GPL or AGPL need a closer look).
---
## CI (Gitea Actions)
`.gitea/workflows/ci.yml` runs on pushes to `master` and on pull requests:
- **server**: lint (no warnings allowed), type-check, tests, build.
- **client**: lint (no warnings allowed), build, Storybook tests in headless Chromium.
- **image** (pushes to `master` only): when the push changes `version` in the root `package.json`, and both check jobs pass, builds the Docker image and pushes it to the Gitea container registry set by `REGISTRY` at the top of the workflow (`git.hq.ars9.space`) as `<registry>/<owner>/<repo>:<version>` and `:latest`.
The image job logs in as the repository owner with the `REGISTRY_TOKEN` secret: a Gitea access token with package write access (Settings → Applications → token with `write:package`), added under the repository's Settings → Actions → Secrets. It runs `docker` on the runner, so the runner must give jobs access to a Docker daemon (act_runner mounts the host's Docker socket into job containers by default).
Jobs clone the repository from the address the runner was registered with. If that's an internal hostname (such as `http://gitea:3000` from Gitea's compose network), job containers can't resolve it: either register the runner with the public URL, or set `container.network` in the act_runner config to Gitea's Docker network so jobs join it.
---
## Running with Docker Compose
Start (detached):
+1 -1
View File
@@ -77,7 +77,7 @@ Exports hold exactly one version and always include its `version` number (the la
- Items are imported in dependency order - environments, credentials, snippets, scenarios - regardless of their order in the file, so a scenario can reference an environment or credential from the same file.
- The response lists what was imported: `{ imported: [{ kind, id, name, version? }] }`.
A scenario export (`GET /scenarios/:id/export`, optionally with its environment and credentials) is in this format, one document per entity, and can be imported back as is.
A scenario export (`GET /scenarios/:id/export`, optionally with its environment, credentials and used snippets) is in this format, one document per entity, and can be imported back as is. Query parameters: `includeEnvironment=true`, `credentialIds` and `snippetIds` (repeat the parameter or separate ids with commas) and `version`. A selected snippet is exported once per version the scenario uses: the latest for plain `runSnippet("alias")` calls, plus each version pinned with `alias@N`. Snippets used only through other snippets count as used.
```yaml
---
+5 -3
View File
@@ -1,12 +1,13 @@
{
"name": "liqa",
"version": "1.20.2",
"version": "1.22.2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "liqa",
"version": "1.20.2",
"version": "1.22.2",
"license": "MIT",
"workspaces": [
"server",
"client"
@@ -17,6 +18,7 @@
},
"client": {
"name": "liqa-client",
"license": "MIT",
"dependencies": {
"@monaco-editor/react": "^4.7.0",
"@tanstack/react-query": "^5.99.0",
@@ -17935,7 +17937,7 @@
},
"server": {
"name": "liqa-server",
"license": "ISC",
"license": "MIT",
"dependencies": {
"@modelcontextprotocol/sdk": "^1.29.0",
"@mozilla/readability": "^0.6.0",
+3 -1
View File
@@ -1,7 +1,9 @@
{
"name": "liqa",
"version": "1.20.2",
"version": "1.22.2",
"private": true,
"license": "MIT",
"author": "Andrii Arsenin",
"engines": {
"node": ">=24"
},
+118
View File
@@ -0,0 +1,118 @@
#!/usr/bin/env node
// Writes the license notices for everything the app ships to stdout: the
// project's own LICENSE, then every production dependency of the client and
// server workspaces with its license text, as installed in node_modules.
//
// node scripts/third-party-licenses.mjs > licenses.txt
//
// Run it from the repository root after `npm ci` (dev dependencies may be
// installed too; only production dependencies are listed). Exits non-zero
// when a package's license can't be determined.
import { execFileSync } from "node:child_process";
import * as fs from "node:fs";
import * as path from "node:path";
const ROOT = process.cwd();
const LICENSE_FILE = /^(licen[cs]e|copying|notice)(\.|-|$)/i;
const tree = JSON.parse(
execFileSync("npm", ["ls", "--omit=dev", "--all", "--long", "--json"], {
cwd: ROOT,
encoding: "utf8",
maxBuffer: 256 * 1024 * 1024,
// npm ls exits non-zero on unmet optional peers; the JSON is still complete
stdio: ["ignore", "pipe", "ignore"],
}).toString() || "{}",
);
const workspaces = new Set(
(
JSON.parse(fs.readFileSync(path.join(ROOT, "package.json"), "utf8"))
.workspaces ?? []
).map((w) => path.resolve(ROOT, w)),
);
/** name@version → { name, version, license, dir } */
const packages = new Map();
const walk = (node) => {
for (const [name, dep] of Object.entries(node.dependencies ?? {})) {
// Unmet optional peers have no path
if (!dep.path) continue;
// Workspace packages are our own code: list only their dependencies
if (!workspaces.has(fs.realpathSync(dep.path))) {
const key = `${name}@${dep.version}`;
if (packages.has(key)) continue;
packages.set(key, { name, version: dep.version, dir: dep.path });
}
walk(dep);
}
};
walk(tree);
const manifestOf = (pkg) =>
JSON.parse(fs.readFileSync(path.join(pkg.dir, "package.json"), "utf8"));
const licenseOf = (pkg) => {
const manifest = manifestOf(pkg);
const field = manifest.license ?? manifest.licenses;
if (typeof field === "string") return field;
if (Array.isArray(field)) return field.map((l) => l.type ?? l).join(" OR ");
if (field?.type) return field.type;
return null;
};
const licenseTexts = (pkg) =>
fs
.readdirSync(pkg.dir)
.filter(
(f) =>
LICENSE_FILE.test(f) && fs.statSync(path.join(pkg.dir, f)).isFile(),
)
.sort()
.map((f) => fs.readFileSync(path.join(pkg.dir, f), "utf8").trim());
// For packages that ship no license file, record who to attribute and where
// the full terms are
const withoutLicenseFile = (pkg, license) => {
const { author, repository, homepage } = manifestOf(pkg);
const authorName = typeof author === "string" ? author : author?.name;
const repo = typeof repository === "string" ? repository : repository?.url;
return [
`The package ships no license file; its package.json declares ${license}.`,
authorName && `Author: ${authorName}`,
(repo || homepage) && `Source: ${repo || homepage}`,
]
.filter(Boolean)
.join("\n");
};
const missing = [];
const sections = [...packages.values()]
.sort(
(a, b) =>
a.name.localeCompare(b.name) || a.version.localeCompare(b.version),
)
.map((pkg) => {
const license = licenseOf(pkg);
const texts = licenseTexts(pkg);
if (!license && texts.length === 0)
missing.push(`${pkg.name}@${pkg.version}`);
const body =
texts.length > 0 ? texts.join("\n\n") : withoutLicenseFile(pkg, license);
return `${pkg.name}@${pkg.version}\nLicense: ${license ?? "see below"}\n\n${body}`;
});
if (missing.length > 0) {
console.error(`No license information for: ${missing.join(", ")}`);
process.exit(1);
}
const rule = "-".repeat(79);
process.stdout.write(
[
fs.readFileSync(path.join(ROOT, "LICENSE"), "utf8").trim(),
`${"=".repeat(79)}\n\nThird-party software\n\nThis application includes the following third-party packages (${sections.length}),\nunder their own licenses:`,
...sections,
].join(`\n\n${rule}\n\n`) + "\n",
);
+4
View File
@@ -12,4 +12,8 @@ module.exports = {
'^@mozilla/readability$': '<rootDir>/test/__mocks__/readability.ts',
},
testEnvironment: 'node',
// Each suite builds a full Nest app in beforeAll. That takes well under a
// second on an idle machine, but several seconds when every suite starts at
// once on a busy CI runner, past Jest's default 5 s.
testTimeout: 30_000,
};
+2 -2
View File
@@ -18,8 +18,8 @@
"test:watch": "jest --watch"
},
"keywords": [],
"author": "",
"license": "ISC",
"author": "Andrii Arsenin",
"license": "MIT",
"dependencies": {
"@modelcontextprotocol/sdk": "^1.29.0",
"@mozilla/readability": "^0.6.0",
@@ -13,6 +13,7 @@ import {
ValidateNested,
} from "class-validator";
import { EnvironmentData } from "../../environment/environment.entity";
import { SnippetExportDto } from "../../snippet/dto/snippet-export.dto";
export class ScenarioStepExportDto {
@ApiPropertyOptional()
@@ -154,4 +155,5 @@ export class ScenarioExportDto {
export type ExportEntity =
| EnvironmentExportInlineDto
| CredentialExportDto
| SnippetExportDto
| ScenarioExportDto;
+11 -7
View File
@@ -135,18 +135,17 @@ export class ScenarioController {
@Param("id", ParseUUIDPipe) id: string,
@Query("includeEnvironment") includeEnvironment: string,
@Query("credentialIds") credentialIds: string | string[] | undefined,
@Query("snippetIds") snippetIds: string | string[] | undefined,
@Query("version", new ParseIntPipe({ optional: true }))
version: number | undefined,
@Res({ passthrough: true }) res: Response,
) {
const credIds: string[] = credentialIds
? Array.isArray(credentialIds)
? credentialIds
: credentialIds.split(",").filter(Boolean)
: [];
const toIds = (ids: string | string[] | undefined): string[] =>
ids ? (Array.isArray(ids) ? ids : ids.split(",").filter(Boolean)) : [];
const entities = await this.scenarioService.exportScenario(id, {
includeEnvironment: includeEnvironment === "true",
credentialIds: credIds,
credentialIds: toIds(credentialIds),
snippetIds: toIds(snippetIds),
version,
});
res.setHeader("Content-Type", "application/yaml; charset=utf-8");
@@ -155,12 +154,17 @@ export class ScenarioController {
const kindLabels: Record<string, string> = {
environment: "Environment",
credential: "Credential",
snippet: "Snippet",
scenario: "Scenario",
};
return (entities as ExportEntity[])
.map((entity) => {
const label = kindLabels[entity.kind ?? ""] ?? entity.kind ?? "Entity";
const comment = `# ${label}: ${entity.name ?? entity.id ?? ""}`;
const title =
entity.kind === "snippet"
? `${entity.alias ?? entity.name} v${entity.version}`
: entity.name;
const comment = `# ${label}: ${title ?? entity.id ?? ""}`;
return `---\n${comment}\n${yamlStringify(entity)}`;
})
.join("");
+32 -4
View File
@@ -486,11 +486,18 @@ export class ScenarioService implements OnModuleInit {
*/
async getUsedSnippets(scenarioId: string): Promise<UsedSnippet[]> {
const scenario = await this.findOne(scenarioId);
const snippetMap = await this.snippetService.buildSnippetMap();
const usedRefs = resolveUsedSnippetAliases(
return this.resolveUsedSnippets(
scenario.steps.map((s) => s.execCode ?? ""),
snippetMap,
).map(parseSnippetRef);
);
}
private async resolveUsedSnippets(
execCodes: string[],
): Promise<UsedSnippet[]> {
const snippetMap = await this.snippetService.buildSnippetMap();
const usedRefs = resolveUsedSnippetAliases(execCodes, snippetMap).map(
parseSnippetRef,
);
if (usedRefs.length === 0) return [];
const snippets = await this.snippetService.findByAliases([
...new Set(usedRefs.map((r) => r.alias)),
@@ -699,6 +706,8 @@ export class ScenarioService implements OnModuleInit {
options: {
includeEnvironment: boolean;
credentialIds: string[];
/** Used snippets to include, at every version the scenario uses. */
snippetIds?: string[];
/** Version to export; defaults to the latest. */
version?: number;
},
@@ -741,6 +750,25 @@ export class ScenarioService implements OnModuleInit {
}
}
// Include selected snippets, once per used version (latest or pinned)
const snippetIds = options.snippetIds ?? [];
if (snippetIds.length > 0) {
const used = await this.resolveUsedSnippets(
content.steps.map((s) => s.execCode ?? ""),
);
const seen = new Set<string>();
for (const snippet of used) {
if (!snippetIds.includes(snippet.id)) continue;
const version = snippet.pinnedVersion ?? snippet.version;
const key = `${snippet.id}@${version}`;
if (seen.has(key)) continue;
seen.add(key);
entities.push(
await this.snippetService.exportSnippet(snippet, version),
);
}
}
// Scenario is always last
const allCreds = scenario.scenarioCredentials ?? [];
const credentialMappings = allCreds
+4 -1
View File
@@ -810,7 +810,10 @@ describe("ScenarioController", () => {
.expect(200);
expect(res.body.id).toBe(runId);
expect(res.body.status).toBe("pending");
// The scheduler may already have picked the run up
expect(["pending", "in_progress", "pass", "fail"]).toContain(
res.body.status,
);
expect(Array.isArray(res.body.stepRuns)).toBe(true);
expect(res.body.stepRuns[0]).toHaveProperty("scenarioStep");
expect(Array.isArray(res.body.logs)).toBe(true);
+41
View File
@@ -277,6 +277,47 @@ describe("Versioning", () => {
expect(first[first.length - 1]).toMatchObject({ version: 1, steps: [] });
});
it("includes selected used snippets at the versions the scenario uses", async () => {
const alias = `exp-snip-${uniq()}`;
const sn = await snippetService.create({
alias,
title: "t",
code: "return 'one';",
});
await snippetService.update(sn.id, { code: "return 'two';" });
const other = await snippetService.create({
alias: `exp-other-${uniq()}`,
title: "t",
code: "return 3;",
});
const sc = await scenarioService.create({ name: `exp-sn-${uniq()}` });
await scenarioService.createStep(sc.id, {
execCode: `await context.runSnippet("${alias}"); await context.runSnippet("${alias}@1"); await context.runSnippet("${alias}"); return context.runSnippet("${other.alias}");`,
});
const withSnippet = await scenarioService.exportScenario(sc.id, {
includeEnvironment: false,
credentialIds: [],
snippetIds: [sn.id],
});
expect(withSnippet.map((e) => e.kind)).toEqual([
"snippet",
"snippet",
"scenario",
]);
expect(withSnippet.slice(0, 2)).toMatchObject([
{ id: sn.id, version: 2, code: "return 'two';" },
{ id: sn.id, version: 1, code: "return 'one';" },
]);
const without = await scenarioService.exportScenario(sc.id, {
includeEnvironment: false,
credentialIds: [],
});
expect(without.map((e) => e.kind)).toEqual(["scenario"]);
});
it("restores exact versions by id + version", async () => {
const id = crypto.randomUUID();
const base = { kind: "scenario" as const, id, name: "imported" };