mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-05-27 00:25:55 +00:00
Gera automaticamente 24 grupos de comandos (170+ operações) em bin/cli/api-commands/ a partir de docs/reference/openapi.yaml via npm run build:cli-api. Integrado em registry.mjs; prepublishOnly regenera antes de publicar.
182 lines
6 KiB
JavaScript
182 lines
6 KiB
JavaScript
// AUTO-GENERATED from docs/reference/openapi.yaml. Do not edit.
|
|
import { apiFetch } from "../api.mjs";
|
|
import { emit } from "../output.mjs";
|
|
import { readFileSync } from "node:fs";
|
|
|
|
export function register_compression(parent) {
|
|
const tag = parent.command("compression").description("Compression endpoints");
|
|
tag
|
|
.command("get-api-settings-compression")
|
|
.description("Get global compression settings")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/settings/compression";
|
|
const res = await apiFetch(url, {
|
|
method: "GET",
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("put-api-settings-compression")
|
|
.description("Update global compression settings")
|
|
.option("--body <jsonOrPath>", "JSON body or @path/to/file.json")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/settings/compression";
|
|
let body;
|
|
if (opts.body) {
|
|
body = opts.body.startsWith("@")
|
|
? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))
|
|
: JSON.parse(opts.body);
|
|
}
|
|
const res = await apiFetch(url, {
|
|
method: "PUT",
|
|
body,
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("post-api-compression-preview")
|
|
.description("Preview compression for a message payload")
|
|
.option("--body <jsonOrPath>", "JSON body or @path/to/file.json")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/compression/preview";
|
|
let body;
|
|
if (opts.body) {
|
|
body = opts.body.startsWith("@")
|
|
? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))
|
|
: JSON.parse(opts.body);
|
|
}
|
|
const res = await apiFetch(url, {
|
|
method: "POST",
|
|
body,
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("get-api-compression-language-packs")
|
|
.description("List Caveman compression language packs")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/compression/language-packs";
|
|
const res = await apiFetch(url, {
|
|
method: "GET",
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("get-api-compression-rules")
|
|
.description("List Caveman compression rule metadata")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/compression/rules";
|
|
const res = await apiFetch(url, {
|
|
method: "GET",
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("get-api-context-rtk-config")
|
|
.description("Get RTK compression settings")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/context/rtk/config";
|
|
const res = await apiFetch(url, {
|
|
method: "GET",
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("put-api-context-rtk-config")
|
|
.description("Update RTK compression settings")
|
|
.option("--body <jsonOrPath>", "JSON body or @path/to/file.json")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/context/rtk/config";
|
|
let body;
|
|
if (opts.body) {
|
|
body = opts.body.startsWith("@")
|
|
? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))
|
|
: JSON.parse(opts.body);
|
|
}
|
|
const res = await apiFetch(url, {
|
|
method: "PUT",
|
|
body,
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("get-api-context-rtk-filters")
|
|
.description("List RTK filters and load diagnostics")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/context/rtk/filters";
|
|
const res = await apiFetch(url, {
|
|
method: "GET",
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("post-api-context-rtk-test")
|
|
.description("Run RTK compression preview for text")
|
|
.option("--body <jsonOrPath>", "JSON body or @path/to/file.json")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/context/rtk/test";
|
|
let body;
|
|
if (opts.body) {
|
|
body = opts.body.startsWith("@")
|
|
? JSON.parse(readFileSync(opts.body.slice(1), "utf8"))
|
|
: JSON.parse(opts.body);
|
|
}
|
|
const res = await apiFetch(url, {
|
|
method: "POST",
|
|
body,
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
tag
|
|
.command("get-api-context-rtk-raw-output-id-")
|
|
.description("Read retained redacted RTK raw output")
|
|
.requiredOption("--id <id>", "")
|
|
.action(async (opts, cmd) => {
|
|
const gOpts = cmd.optsWithGlobals();
|
|
let url = "/api/context/rtk/raw-output/{id}";
|
|
url = url.replace("{id}", encodeURIComponent(opts.id ?? ""));
|
|
const res = await apiFetch(url, {
|
|
method: "GET",
|
|
baseUrl: gOpts.baseUrl,
|
|
apiKey: gOpts.apiKey,
|
|
});
|
|
const data = res.ok ? await res.json() : await res.text();
|
|
emit(data, gOpts);
|
|
});
|
|
}
|