feat: polish protocol-aware operator UI
This commit is contained in:
@@ -1,7 +1,14 @@
|
||||
import { getJson, getText, postJson, postText } from "../../shared/api/client";
|
||||
import {
|
||||
getJson,
|
||||
getText,
|
||||
postBytes,
|
||||
postJson,
|
||||
postText,
|
||||
} from "../../shared/api/client";
|
||||
import type {
|
||||
AuthProfile,
|
||||
DraftGenerationResult,
|
||||
GrpcServiceSummary,
|
||||
OperationRecord,
|
||||
OperationSummary,
|
||||
TestRunResult,
|
||||
@@ -82,3 +89,40 @@ export function importOperationYaml(yamlText: string, mode: "create" | "upsert")
|
||||
export function listAuthProfiles() {
|
||||
return getJson<{ items: AuthProfile[] }>("/api/admin/auth-profiles");
|
||||
}
|
||||
|
||||
export function uploadProtoDescriptor(
|
||||
operationId: string,
|
||||
fileName: string,
|
||||
bytes: ArrayBuffer,
|
||||
) {
|
||||
return postBytes<{ descriptor_id: string; version: number }>(
|
||||
`/api/admin/operations/${operationId}/descriptors/proto`,
|
||||
bytes,
|
||||
{
|
||||
"Content-Type": "application/octet-stream",
|
||||
"x-file-name": fileName,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function uploadDescriptorSet(
|
||||
operationId: string,
|
||||
fileName: string,
|
||||
bytes: ArrayBuffer,
|
||||
) {
|
||||
return postBytes<{ descriptor_id: string; version: number }>(
|
||||
`/api/admin/operations/${operationId}/descriptors/descriptor-set`,
|
||||
bytes,
|
||||
{
|
||||
"Content-Type": "application/octet-stream",
|
||||
"x-file-name": fileName,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
export function listGrpcServices(operationId: string, version?: number) {
|
||||
const query = version === undefined ? "" : `?version=${version}`;
|
||||
return getJson<{ services: GrpcServiceSummary[] }>(
|
||||
`/api/admin/operations/${operationId}/grpc/services${query}`,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,35 @@
|
||||
export type Protocol = "rest" | "graphql" | "grpc";
|
||||
export type OperationStatus = "draft" | "testing" | "published" | "archived";
|
||||
|
||||
export type RestTarget = {
|
||||
kind: "rest";
|
||||
base_url: string;
|
||||
method: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
||||
path_template: string;
|
||||
static_headers?: Record<string, string>;
|
||||
};
|
||||
|
||||
export type GraphqlTarget = {
|
||||
kind: "graphql";
|
||||
endpoint: string;
|
||||
operation_type: "query" | "mutation";
|
||||
operation_name: string;
|
||||
query_template: string;
|
||||
response_path: string;
|
||||
};
|
||||
|
||||
export type GrpcTarget = {
|
||||
kind: "grpc";
|
||||
server_addr: string;
|
||||
package: string;
|
||||
service: string;
|
||||
method: string;
|
||||
descriptor_ref: string;
|
||||
descriptor_set_b64: string;
|
||||
};
|
||||
|
||||
export type OperationTarget = RestTarget | GraphqlTarget | GrpcTarget;
|
||||
|
||||
export type OperationSummary = {
|
||||
id: string;
|
||||
name: string;
|
||||
@@ -31,13 +60,7 @@ export type OperationSnapshot = {
|
||||
protocol: Protocol;
|
||||
status: OperationStatus;
|
||||
version: number;
|
||||
target: {
|
||||
kind: "rest" | "graphql" | "grpc";
|
||||
base_url?: string;
|
||||
method?: string;
|
||||
path_template?: string;
|
||||
static_headers?: Record<string, string>;
|
||||
};
|
||||
target: OperationTarget;
|
||||
input_schema: unknown;
|
||||
output_schema: unknown;
|
||||
input_mapping: unknown;
|
||||
@@ -83,3 +106,16 @@ export type AuthProfile = {
|
||||
created_at: string;
|
||||
updated_at: string;
|
||||
};
|
||||
|
||||
export type GrpcMethodSummary = {
|
||||
name: string;
|
||||
kind: string;
|
||||
input_schema: unknown;
|
||||
output_schema: unknown;
|
||||
};
|
||||
|
||||
export type GrpcServiceSummary = {
|
||||
package: string;
|
||||
service: string;
|
||||
methods: GrpcMethodSummary[];
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user