Skip to content

Commit 826d376

Browse files
committed
refactor: clean up API v2 before release
1 parent 152a2fe commit 826d376

41 files changed

Lines changed: 1707 additions & 849 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

api/openapi-v2.json

Lines changed: 1324 additions & 472 deletions
Large diffs are not rendered by default.

frontend/src/lib/api/actions.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,6 @@ export const actions = {
5050
fetchV2Data(`/workspaces/${workspaceId}/actions/${id}`, {
5151
method: 'DELETE',
5252
}),
53-
toggle: (workspaceId, id, isEnabled) =>
54-
fetchV2Data(`/workspaces/${workspaceId}/actions/${id}/toggle`, {
55-
method: 'POST',
56-
body: JSON.stringify({ is_enabled: isEnabled }),
57-
}),
5853
execute: (workspaceId, actionId, itemId) =>
5954
fetchV2Data(`/workspaces/${workspaceId}/actions/${actionId}/execute`, {
6055
method: 'POST',

frontend/src/lib/api/pages.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { buildQueryString } from './utils.js';
77
* (core.js sets credentials: 'same-origin').
88
*/
99
export const pages = {
10-
/** Fetch the workspace page tree + flat list. */
11-
getTree: (workspaceId) => fetchV2Data(`/workspaces/${workspaceId}/pages/tree`),
10+
/** Fetch every visible page as an ordered, flat metadata list. */
11+
getAll: (workspaceId) => fetchV2Data(`/workspaces/${workspaceId}/pages`),
1212

1313
/** Fetch a single page (404 on missing or no view permission). */
1414
getPage: (workspaceId, pageId) => fetchV2Data(`/workspaces/${workspaceId}/pages/${pageId}`),

frontend/src/lib/api/tests/index.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,11 @@ import { testPlans } from './testPlans.js';
1010
import { testResults } from './testResults.js';
1111
import { testRuns } from './testRuns.js';
1212
import { testRunTemplates } from './testRunTemplates.js';
13-
import { testSets } from './testSets.js';
1413

1514
export const tests = {
1615
testFolders,
1716
testLabels,
1817
testCases,
19-
testSets,
2018
testPlans,
2119
testRunTemplates,
2220
testRuns,

frontend/src/lib/api/tests/testCases.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { fetchAllV2Pages, fetchV2Data } from '../core.js';
1+
import { fetchAllV2Pages, fetchAPIV2, fetchV2Data } from '../core.js';
22
import { createCrudClient } from '../createCrudClient.js';
33

44
export const testCases = {
@@ -23,7 +23,10 @@ export const testCases = {
2323
const endpoint = `/workspaces/${workspaceId}/test-cases${queryString ? `?${queryString}` : ''}`;
2424
return params.all ? fetchAllV2Pages(endpoint) : fetchV2Data(endpoint);
2525
},
26-
count: (workspaceId) => fetchV2Data(`/workspaces/${workspaceId}/test-cases/count`),
26+
count: async (workspaceId) => {
27+
const document = await fetchAPIV2(`/workspaces/${workspaceId}/test-cases?page=1&page_size=1`);
28+
return { count: document?.pagination?.total_items ?? 0 };
29+
},
2730
move: (workspaceId, id, data) =>
2831
fetchV2Data(`/workspaces/${workspaceId}/test-cases/${id}/move`, {
2932
method: 'POST',

frontend/src/lib/api/tests/testPlans.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { fetchV2Data } from '../core.js';
22
import { createCrudClient } from '../createCrudClient.js';
33

4-
// Test Plans (preferred terminology, same as testSets)
54
export const testPlans = {
65
...createCrudClient('/test-plans', { parentPath: '/workspaces', v2: true, allV2: true }),
76
getTestCases: (workspaceId, id) =>

frontend/src/lib/api/tests/testSets.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

frontend/src/lib/api/workflows.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ export const statuses = {
3030
get: async (...args) => normalizeStatus(await statusCRUD.get(...args)),
3131
create: async (...args) => normalizeStatus(await statusCRUD.create(...args)),
3232
update: async (...args) => normalizeStatus(await statusCRUD.update(...args)),
33-
getNonDoneIds: () => fetchV2Data('/statuses/non-completed-ids'),
3433
};
3534

3635
const workflowCRUD = createCrudClient('/workflows', { v2: true });
@@ -73,6 +72,4 @@ export const workflows = {
7372
method: 'PUT',
7473
body: JSON.stringify({ transitions: data }),
7574
}),
76-
getAvailableTransitions: (id, statusId) =>
77-
fetchV2Data(`/workflows/${id}/statuses/${statusId}/transitions`),
7875
};

frontend/src/lib/features/actions/ActionsSettings.svelte

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@
136136
137137
async function handleToggle(action) {
138138
try {
139-
await api.actions.toggle(workspaceId, action.id, !action.is_enabled);
139+
await api.actions.update(workspaceId, action.id, { is_enabled: !action.is_enabled });
140140
await loadActions();
141141
successToast(action.is_enabled ? t('actions.disabled') : t('actions.enabled'));
142142
} catch (error) {

frontend/src/lib/features/api-docs/ApiOperation.svelte

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,19 @@
22
import MethodBadge from './MethodBadge.svelte';
33
import ApiSchema from './ApiSchema.svelte';
44
import { renderMarkdown } from '../../utils/render-markdown.js';
5-
import { resolveRef } from './openapi-store.svelte.js';
5+
import {
6+
operationRequiredScopes,
7+
resolveOperationParameters,
8+
resolveRef,
9+
} from './openapi-store.svelte.js';
610
711
let { spec, entry } = $props();
812
913
// entry = { tag, path, method, operation, id }
1014
const op = $derived(entry.operation);
11-
const params = $derived(op.parameters || []);
15+
const params = $derived(resolveOperationParameters(spec, entry));
1216
const grouped = $derived(groupParams(params));
17+
const requiredScopes = $derived(operationRequiredScopes(op));
1318
1419
function groupParams(list) {
1520
const buckets = { path: [], query: [], header: [], cookie: [] };
@@ -82,12 +87,15 @@
8287
{#each Object.keys(req) as scheme}
8388
<span class="security-pill">
8489
{scheme}
85-
{#if req[scheme] && req[scheme].length > 0}
86-
<span class="security-scopes">({req[scheme].join(', ')})</span>
87-
{/if}
8890
</span>
8991
{/each}
9092
{/each}
93+
{#if requiredScopes.length > 0}
94+
<span class="security-pill">
95+
Required scopes
96+
<span class="security-scopes">({requiredScopes.join(', ')})</span>
97+
</span>
98+
{/if}
9199
</div>
92100
</section>
93101
{/if}

0 commit comments

Comments
 (0)