Feat/org epic (#1634)
* fix(postgres): scope OpenPRs to the caller's org A principal-carrying caller read every org's pr_open tasks. The query now honours the request scope; the daemon's unscoped review scan still sees all orgs. Issue: archie-core-kgxw.23 * fix(statestore): serve task logs only to the task's org ReadTaskLog and StreamTaskLogContent took a task ID and read the file with no org check. The State Store's task-log reader now confirms the task is visible under the caller's scope first; unscoped services read as before. Issue: archie-core-kgxw.24 * fix(postgres): scope ListPolicies to the caller's org Every org's policy text reached any principal-carrying caller. A scoped read now sees its own org's policies, plus instance policies when scoped to the system org. The engines and the lockout guard decide for every org, so they read the full chain unscoped: the dashboard engine loads without the request's principal and the guard lifts the caller's scope. Issue: archie-core-kgxw.25 * fix(postgres): scope identity reads to the caller's org ListIdentities and GetIdentity (and its alias fallback) returned every identity to any caller. A caller scoped to an org now sees only that org's members and assigned agents; the system org and unscoped services still see the whole instance. Issue: archie-core-kgxw.26 * fix(postgres): hide instance status from other orgs ListPresence, ListChannelStatus, ListApplyStatus and GetConfigSnapshot answered any org principal with instance-wide state. They now return nothing unless the request is unscoped or scoped to the system org. The dashboard reads the published config as itself, since its handlers project it for callers of every org. Issue: archie-core-kgxw.27 * feat(postgres): assign new agents an org and role at creation A bot or service account created through the API served no org until the next State Store boot granted it one. Create now assigns it to the org the request acts in with the developer role in the same transaction, so it is authorized immediately. Issue: archie-core-kgxw.14 * feat(edastore): create event records in a chosen workspace Sources are created in a workspace of the caller's org, the default one when none is named; event types and bindings take their source's workspace and mappings their event type's, the same rule the org backfill applied. The binding, mapping and event type contracts carry the workspace, the four list endpoints accept ?workspace=, and the Events page has a workspace selector that filters every step and picks where a new source goes. Issue: archie-core-kgxw.11 * feat(webui): authorize a record in its workspace The API built every access request with no workspace, so workspace policies and per-workspace roles never applied. A request naming a source, binding, mapping, event type or task now reads the record's workspace under the caller's scope and authorizes in it; tasks carry their workspace on the State Store contract for this. Issue: archie-core-kgxw.9 * feat(access): expose workspace environment to policies Policies can test resource.workspace.environment. The workspace attribute is the workspace entity, which carries its environment; the principal brings its org's workspaces from the State Store, so the dashboard and the daemon's run checks describe a resource's workspace without another lookup, and the daemon now authorizes runs in the task's or binding's workspace. Issue: archie-core-kgxw.10 * fix(webui): ask read_secret when a source secret is read Rotating a source's secret returns its value, but the route asked update, which every developer holds, so no policy could narrow who reads a secret. It now asks read_secret on the secret, which the shipped roles give admins and an object policy can narrow further. Issue: archie-core-kgxw.17 * refactor(org): delete the unused upgrade-incomplete sentinel Nothing returns org.ErrUpgradeIncomplete: the State Store finishes the org upgrade before it serves. Issue: archie-core-kgxw.18
This commit is contained in:
1 parent
8540c9f7c8
commit
f34f60f9c7
60 files changed
+1695
-828
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
import { eventsWorkspace } from "@/events/workspace";
|
||||
import { api, ApiError } from "@/lib/api";
|
||||
import type { EventType } from "@/captures/event-types";
|
||||
import {
|
||||
@@ -55,7 +56,7 @@ export function useBindings() {
|
||||
failure.value = null;
|
||||
try {
|
||||
const [b, m, w, t] = await Promise.all([
|
||||
api.bindings<{ bindings?: Binding[] }>(),
|
||||
api.bindings<{ bindings?: Binding[] }>(eventsWorkspace.value),
|
||||
api.mappings<{ mappings?: MappingOption[] }>(),
|
||||
api.workflows<{ definitions?: WorkflowOption[] }>(),
|
||||
api.eventTypes<{ event_types?: EventType[] }>(),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
import { eventsWorkspace } from "@/events/workspace";
|
||||
import { api } from "@/lib/api";
|
||||
import { captures } from "./state";
|
||||
import {
|
||||
@@ -47,7 +48,7 @@ export const saveError = ref<string | null>(null);
|
||||
|
||||
export async function loadEventTypes(): Promise<void> {
|
||||
try {
|
||||
const res = await api.eventTypes<EventTypesResponse>();
|
||||
const res = await api.eventTypes<EventTypesResponse>(eventsWorkspace.value);
|
||||
eventTypesEnabled.value = res.enabled !== false;
|
||||
eventTypes.value = res.event_types || [];
|
||||
proposals.value = res.proposals || [];
|
||||
|
||||
@@ -7,6 +7,15 @@ import { useRoute, useRouter } from "vue-router";
|
||||
|
||||
import PageHeader from "@/base/PageHeader.vue";
|
||||
import { Empty, EmptyHeader, EmptyTitle } from "@/components/ui/empty";
|
||||
import {
|
||||
Select,
|
||||
SelectContent,
|
||||
SelectGroup,
|
||||
SelectItem,
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/components/ui/select";
|
||||
import { homeOrg, loadOrg, type OrgWorkspace } from "@/org/org";
|
||||
import BindingsPage from "@/bindings/BindingsPage.vue";
|
||||
import CapturesPage from "@/captures/CapturesPage.vue";
|
||||
import { sections } from "@/lib/capabilities";
|
||||
@@ -15,6 +24,7 @@ import { useLiveResource } from "@/stores/live-updates";
|
||||
import MappingsPage from "@/mappings/MappingsPage.vue";
|
||||
import { activeTab, availableTabs, stepsFor } from "./tab-selection";
|
||||
import { loadEventCounts, type EventsCounts } from "./counts";
|
||||
import { eventsWorkspace } from "./workspace";
|
||||
|
||||
/**
|
||||
* The Events surfaces: what arrived, how its fields are read, and which workflow
|
||||
@@ -67,11 +77,44 @@ watch(active, (tab) => show(tab), { immediate: true });
|
||||
// read one source rather than three.
|
||||
const counts = ref<EventsCounts>({});
|
||||
async function loadCounts() {
|
||||
counts.value = await loadEventCounts(api);
|
||||
const workspace = eventsWorkspace.value;
|
||||
counts.value = await loadEventCounts({
|
||||
captures: api.captures,
|
||||
mappings: () => api.mappings(workspace),
|
||||
bindings: () => api.bindings(workspace),
|
||||
});
|
||||
}
|
||||
onMounted(() => void loadCounts());
|
||||
useLiveResource(null, () => void loadCounts(), 1000);
|
||||
|
||||
// The workspace the lists show rides in the query string (`?workspace=`) like
|
||||
// the step, so a filtered view is a link. "All" needs a sentinel: an empty
|
||||
// string is how a Select spells "nothing selected".
|
||||
const ALL = "__all__";
|
||||
const workspaces = ref<OrgWorkspace[]>([]);
|
||||
watch(
|
||||
() => String(route.query.workspace ?? ""),
|
||||
(workspace) => {
|
||||
eventsWorkspace.value = workspace;
|
||||
void loadCounts();
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
function pickWorkspace(value: unknown): void {
|
||||
const workspace = String(value) === ALL ? undefined : String(value);
|
||||
void router.replace({ query: { ...route.query, workspace } });
|
||||
}
|
||||
onMounted(async () => {
|
||||
try {
|
||||
await loadOrg();
|
||||
workspaces.value = (
|
||||
await api.orgWorkspaces<{ workspaces: OrgWorkspace[] }>(homeOrg.value)
|
||||
).workspaces;
|
||||
} catch {
|
||||
// Without the list there is nothing to pick; every workspace shows.
|
||||
workspaces.value = [];
|
||||
}
|
||||
});
|
||||
|
||||
const steps = computed(() => stepsFor(tabs.value));
|
||||
|
||||
/** The panel the active step shows. Undefined when this composition backs none
|
||||
@@ -82,6 +125,23 @@ const panel = computed(() => PANELS[active.value]);
|
||||
<template>
|
||||
<div>
|
||||
<PageHeader title="Events">
|
||||
<Select
|
||||
v-if="workspaces.length > 1"
|
||||
:model-value="eventsWorkspace || ALL"
|
||||
@update:model-value="pickWorkspace"
|
||||
>
|
||||
<SelectTrigger size="sm" aria-label="Show records from workspace">
|
||||
<SelectValue />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectGroup>
|
||||
<SelectItem :value="ALL">All workspaces</SelectItem>
|
||||
<SelectItem v-for="workspace in workspaces" :key="workspace.id" :value="workspace.id">
|
||||
{{ workspace.name }}
|
||||
</SelectItem>
|
||||
</SelectGroup>
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<template v-if="!captureLoading">
|
||||
<StatusPill v-if="captureEnabled" dot="live">Listening</StatusPill>
|
||||
<StatusPill v-else>Capture off</StatusPill>
|
||||
@@ -108,7 +168,7 @@ const panel = computed(() => PANELS[active.value]);
|
||||
</li>
|
||||
</ol>
|
||||
|
||||
<component :is="panel" v-if="panel" :key="active" />
|
||||
<component :is="panel" v-if="panel" :key="`${active}:${eventsWorkspace}`" />
|
||||
<Empty v-else>
|
||||
<EmptyHeader>
|
||||
<EmptyTitle>Event automation is not enabled</EmptyTitle>
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
/**
|
||||
* The workspace the Events pages list records from and create sources in.
|
||||
* Empty lists every workspace and creates in the org's default one. Event
|
||||
* types and bindings take their source's workspace, mappings their event
|
||||
* type's, so the source is the one record this picks for.
|
||||
*/
|
||||
export const eventsWorkspace = ref("");
|
||||
+12
-6
@@ -280,7 +280,8 @@ export const api = {
|
||||
}),
|
||||
captures: <T = unknown>(limit?: number) =>
|
||||
request<T>("/api/captures" + qs({ limit })),
|
||||
eventTypes: <T = unknown>() => request<T>("/api/event-types"),
|
||||
eventTypes: <T = unknown>(workspace?: string) =>
|
||||
request<T>("/api/event-types" + qs({ workspace })),
|
||||
eventTypeCreate: <T = unknown>(eventType: Payload) =>
|
||||
request<T>("/api/event-types", { method: "POST", body: eventType }),
|
||||
eventTypeUpdate: <T = unknown>(id: string, eventType: Payload) =>
|
||||
@@ -293,7 +294,8 @@ export const api = {
|
||||
method: "DELETE",
|
||||
parse: false,
|
||||
}),
|
||||
mappings: <T = unknown>() => request<T>("/api/mappings"),
|
||||
mappings: <T = unknown>(workspace?: string) =>
|
||||
request<T>("/api/mappings" + qs({ workspace })),
|
||||
mappingCreate: <T = unknown>(mapping: Payload) =>
|
||||
request<T>("/api/mappings", { method: "POST", body: mapping }),
|
||||
mappingUpdate: <T = unknown>(id: string, mapping: Payload) =>
|
||||
@@ -312,7 +314,8 @@ export const api = {
|
||||
method: "POST",
|
||||
body: { capture_id: captureId, fields },
|
||||
}),
|
||||
bindings: <T = unknown>() => request<T>("/api/bindings"),
|
||||
bindings: <T = unknown>(workspace?: string) =>
|
||||
request<T>("/api/bindings" + qs({ workspace })),
|
||||
dispatches: <T = unknown>(kind: "bindings" | "captures" | "tasks", id: string) =>
|
||||
request<T>(`/api/${kind}/${encodeURIComponent(id)}/dispatches`),
|
||||
bindingCreate: <T = unknown>(binding: Payload) =>
|
||||
@@ -338,9 +341,12 @@ export const api = {
|
||||
bindingResume: <T = unknown>(id: string) =>
|
||||
request<T>(`/api/bindings/${encodeURIComponent(id)}/resume`, { method: "POST" }),
|
||||
harnessBindings: <T = unknown>() => request<T>("/api/harness/bindings"),
|
||||
sources: <T = unknown>() => request<T>("/api/sources"),
|
||||
sourceCreate: <T = unknown>(path: string) =>
|
||||
request<T>("/api/sources", { method: "POST", body: { path } }),
|
||||
sources: <T = unknown>(workspace?: string) =>
|
||||
request<T>("/api/sources" + qs({ workspace })),
|
||||
// sourceCreate makes a source in one of the org's workspaces; an empty
|
||||
// workspace is the default one.
|
||||
sourceCreate: <T = unknown>(path: string, workspace = "") =>
|
||||
request<T>("/api/sources", { method: "POST", body: { path, workspace } }),
|
||||
sourceSigning: <T = unknown>(path: string, signed: boolean) =>
|
||||
request<T>(`/api/sources/${encodeURIComponent(path)}/signing`, {
|
||||
method: "POST",
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
import { eventsWorkspace } from "@/events/workspace";
|
||||
import { api, classifyActionError, type ActionErrorKind } from "@/lib/api";
|
||||
import type { EventType } from "@/captures/event-types";
|
||||
import {
|
||||
@@ -138,7 +139,7 @@ export async function loadMappings(): Promise<void> {
|
||||
// mappings without it -- so a failing capture leg degrades to an empty
|
||||
// picker instead of taking the mappings list down with it.
|
||||
const [listed, captured, types] = await Promise.all([
|
||||
api.mappings<{ mappings?: Mapping[] }>(),
|
||||
api.mappings<{ mappings?: Mapping[] }>(eventsWorkspace.value),
|
||||
api
|
||||
.captures<{ captures?: Capture[]; enabled?: boolean }>(100)
|
||||
.catch(() => null),
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { ref } from "vue";
|
||||
|
||||
import { eventsWorkspace } from "@/events/workspace";
|
||||
import { api } from "@/lib/api";
|
||||
import type { Source, SourceRefusals } from "./source-signing";
|
||||
|
||||
@@ -25,7 +26,7 @@ export function useSources() {
|
||||
const res = await api.sources<{
|
||||
sources?: Source[];
|
||||
refusals?: Record<string, SourceRefusals>;
|
||||
}>();
|
||||
}>(eventsWorkspace.value);
|
||||
sources.value = res.sources || [];
|
||||
refusals.value = res.refusals || {};
|
||||
failure.value = null;
|
||||
@@ -55,7 +56,8 @@ export function useSources() {
|
||||
refusals,
|
||||
busy,
|
||||
load,
|
||||
create: (path: string) => run(() => api.sourceCreate<Source>(path.trim())),
|
||||
create: (path: string) =>
|
||||
run(() => api.sourceCreate<Source>(path.trim(), eventsWorkspace.value)),
|
||||
newSecret: (source: Source) =>
|
||||
run(() => api.sourceSecret<Source>(source.path)),
|
||||
requestUnsigned: (source: Source) =>
|
||||
|
||||
Reference in new issue
Block a user