mirror of
https://github.com/morluto/rea.git
synced 2026-12-04 05:51:06 +00:00
61 lines
2.1 KiB
TypeScript
61 lines
2.1 KiB
TypeScript
import type { Logger } from "pino";
|
|
import type { CliInstance } from "./types.js";
|
|
import { API_CONTRACT_TOOL_CONTRACTS } from "../contracts/apiContractToolContracts.js";
|
|
import {
|
|
API_CONTRACT_OPERATION as operation,
|
|
API_CONTRACT_PROVIDER,
|
|
} from "../domain/apiContract/apiContract.js";
|
|
import { contractNamed } from "./contractCliDescription.js";
|
|
import { registerContractCommand } from "./contractCommand.js";
|
|
import {
|
|
deliverWithService,
|
|
createArtifactInspectionService,
|
|
} from "./contractCommandRunners.js";
|
|
|
|
/** Standard one-shot publication keeps complete inventory Evidence for later offline pages. */
|
|
export const registerApiContractCommand = (
|
|
cli: CliInstance,
|
|
logger: Logger,
|
|
): void =>
|
|
registerContractCommand(
|
|
cli,
|
|
logger,
|
|
contractNamed(API_CONTRACT_TOOL_CONTRACTS, operation),
|
|
{
|
|
description:
|
|
"Inspect local OpenAPI JSON or GraphQL SDL declarations and field bindings offline",
|
|
positionals: ["path"],
|
|
callerPaths: ["path", "operations_path"],
|
|
evidenceDelivery: true,
|
|
viewDelivery: { invalidJson: "view must be valid JSON" },
|
|
fields: {
|
|
path: { description: "Local OpenAPI JSON or GraphQL SDL path" },
|
|
format: {
|
|
name: "contractFormat",
|
|
description: "Input API contract syntax: OpenAPI JSON or GraphQL SDL",
|
|
},
|
|
operations_path: {
|
|
description:
|
|
"Local operation/fragment document, only with --contract-format graphql-sdl",
|
|
},
|
|
view: {
|
|
description:
|
|
"JSON api-contract or graphql-contract page; requires --detail summary and --evidence_output",
|
|
},
|
|
},
|
|
},
|
|
deliverWithService(createApiContractService, API_CONTRACT_PROVIDER.id),
|
|
);
|
|
|
|
/** One-shot contract inventory that owns the documents it opens. */
|
|
const createApiContractService = () =>
|
|
createArtifactInspectionService(
|
|
API_CONTRACT_PROVIDER,
|
|
operation,
|
|
async (input, resources, signal) => {
|
|
const { inspectApiContractEvidence } =
|
|
await import("../application/apiContract/ApiContractService.js");
|
|
return inspectApiContractEvidence(input, resources, { signal });
|
|
},
|
|
);
|