AP0.6: Kairo Workspace UX mit Frontend Widget/View Registry und Vitest.
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 29s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 12s
Deploy Development / deploy (push) Successful in 43s
Test Suite / pytest-backend (push) Successful in 29s
Test Suite / lint-backend (push) Successful in 2s
Test Suite / compose-smoke (push) Has been skipped
Test Suite / k6 /api/health Baseline (push) Successful in 18s
Test Suite / playwright-smoke (push) Successful in 12s
This commit is contained in:
1 parent
802c9259dc
commit
0e7184a59e
38 files changed
+2362
-386
No files matched your search
@@ -0,0 +1,32 @@
|
||||
import { apiFetch } from './client.js'
|
||||
|
||||
export function getAction(id) {
|
||||
return apiFetch(`/api/actions/${id}`)
|
||||
}
|
||||
|
||||
export function updateAction(id, payload) {
|
||||
return apiFetch(`/api/actions/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export function setActionAssignments(id, actorIds) {
|
||||
return apiFetch(`/api/actions/${id}/assignments`, {
|
||||
method: 'PUT',
|
||||
body: JSON.stringify({ actor_ids: actorIds }),
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteAction(id) {
|
||||
return apiFetch(`/api/actions/${id}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
export function listMyOpenActions() {
|
||||
return apiFetch('/api/actions/me/open')
|
||||
}
|
||||
|
||||
/** Offene Maßnahmen = open, in_progress, blocked (Backend-Filter). */
|
||||
export function countOpenActions(actions) {
|
||||
return actions.filter((a) => ['open', 'in_progress', 'blocked'].includes(a.status)).length
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
/**
|
||||
* AP0.6: Kein GET /api/actors im Backend.
|
||||
* Actor-Zuweisung nutzt TenantContext (aktueller Human Actor).
|
||||
* Siehe Abschlussbericht AP0.6 §9.
|
||||
*/
|
||||
|
||||
export function actorsFromContext(context) {
|
||||
if (!context?.actor?.id) return []
|
||||
return [
|
||||
{
|
||||
id: context.actor.id,
|
||||
name: context.display_name || 'Aktueller Actor',
|
||||
actor_type: context.actor.type || 'human',
|
||||
},
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
const TOKEN_KEY = 'kairo_auth_token'
|
||||
|
||||
export { TOKEN_KEY }
|
||||
|
||||
export function getToken() {
|
||||
return localStorage.getItem(TOKEN_KEY) || ''
|
||||
}
|
||||
|
||||
export function setToken(token) {
|
||||
if (token) localStorage.setItem(TOKEN_KEY, token)
|
||||
else localStorage.removeItem(TOKEN_KEY)
|
||||
}
|
||||
|
||||
export function apiHeaders(token = getToken()) {
|
||||
const headers = { 'Content-Type': 'application/json' }
|
||||
if (token) headers['X-Auth-Token'] = token
|
||||
return headers
|
||||
}
|
||||
|
||||
export function parseError(body, fallback) {
|
||||
if (!body) return fallback
|
||||
if (typeof body.detail === 'string') return body.detail
|
||||
if (Array.isArray(body.detail)) {
|
||||
return body.detail.map((d) => d.msg || JSON.stringify(d)).join(', ')
|
||||
}
|
||||
return fallback
|
||||
}
|
||||
|
||||
export async function apiFetch(path, options = {}) {
|
||||
const token = options.token ?? getToken()
|
||||
const res = await fetch(path, {
|
||||
...options,
|
||||
headers: { ...apiHeaders(token), ...options.headers },
|
||||
})
|
||||
const body = await res.json().catch(() => null)
|
||||
if (!res.ok) {
|
||||
const message = parseError(body, `Anfrage fehlgeschlagen (${res.status})`)
|
||||
const err = new Error(message)
|
||||
err.status = res.status
|
||||
err.body = body
|
||||
throw err
|
||||
}
|
||||
return body
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
import { apiFetch } from './client.js'
|
||||
|
||||
export function listInitiatives() {
|
||||
return apiFetch('/api/initiatives')
|
||||
}
|
||||
|
||||
export function getInitiative(id) {
|
||||
return apiFetch(`/api/initiatives/${id}`)
|
||||
}
|
||||
|
||||
export function createInitiative(payload) {
|
||||
return apiFetch('/api/initiatives', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export function updateInitiative(id, payload) {
|
||||
return apiFetch(`/api/initiatives/${id}`, {
|
||||
method: 'PATCH',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteInitiative(id) {
|
||||
return apiFetch(`/api/initiatives/${id}`, { method: 'DELETE' })
|
||||
}
|
||||
|
||||
export function listInitiativeActions(initiativeId) {
|
||||
return apiFetch(`/api/initiatives/${initiativeId}/actions`)
|
||||
}
|
||||
|
||||
export function createInitiativeAction(initiativeId, payload) {
|
||||
return apiFetch(`/api/initiatives/${initiativeId}/actions`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
import { apiFetch } from './client.js'
|
||||
|
||||
export function fetchMe() {
|
||||
return apiFetch('/api/me')
|
||||
}
|
||||
|
||||
export function fetchContext() {
|
||||
return apiFetch('/api/me/context')
|
||||
}
|
||||
|
||||
export function fetchEntitlements() {
|
||||
return apiFetch('/api/me/entitlements')
|
||||
}
|
||||
|
||||
export function login(email, password) {
|
||||
return apiFetch('/api/auth/login', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify({ email, password }),
|
||||
token: null,
|
||||
})
|
||||
}
|
||||
|
||||
export function register(payload) {
|
||||
return apiFetch('/api/auth/register', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
token: null,
|
||||
})
|
||||
}
|
||||
|
||||
export function logout() {
|
||||
return apiFetch('/api/auth/logout', { method: 'POST' })
|
||||
}
|
||||
|
||||
export function fetchSetupStatus() {
|
||||
return apiFetch('/api/auth/setup-status', { token: null })
|
||||
}
|
||||
Reference in new issue
Block a user