docs: make the component sections executable in one pass
Expands 3.1 and 3.2 so the work can be done without re-deriving anything. 3.1 now records what 0.8.6 already fixed, separated into the ten components that were miswired and the five that gained outputs they had been firing undeclared, with the caveat that Map's three were converted but never confirmed in a browser. For the 22 that remain it adds the finding that changes the decision: all nine are pure scaffolds with no state, functions or handlers, and five of them duplicate a component that already works -- FileUpload against FileInput and FileUploadProgress, Toast and ToastNotifications against Toaster, AdvancedDatePicker against DatePicker, AdvancedRangeSlider against RangeSlider. Superseding those is a migration entry rather than new code, and leaves Chart, TreeView, Confetti and CopyMarkup as the only ones needing to be built. 3.2 corrects the scaffold count from 23 to 28; the earlier figure used a looser rule. Nine of the 28 are the 3.1 components, so the two items must be planned together, and several of the rest are primitives that need only their styles moved out of ui.css rather than any behaviour. Also corrects the dead-output component count from 11 to 9 in both documents. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,60 +0,0 @@
|
||||
import type { Context } from "@wrnexus/core";
|
||||
import { httpTransport, serviceClient } from "@wrnexus/rpc";
|
||||
import { auditService, catalogService } from "../lib/contracts.ts";
|
||||
|
||||
interface GitHubRepository {
|
||||
full_name?: unknown;
|
||||
stargazers_count?: unknown;
|
||||
}
|
||||
|
||||
function requestedSku(ctx: Context): string {
|
||||
return new URL(ctx.req.url).searchParams.get("sku")?.trim() || "starter";
|
||||
}
|
||||
|
||||
/** GET /api/product-summary?sku=starter */
|
||||
export async function GET(ctx: Context): Promise<Response> {
|
||||
const sku = requestedSku(ctx);
|
||||
const transport = httpTransport();
|
||||
|
||||
// Inter-app call #1: query the catalog app. `{ as: ctx }` forwards the
|
||||
// signed subject/tenant context; catalog still authorizes independently.
|
||||
const catalog = serviceClient(catalogService, { app: "catalog", as: ctx, transport });
|
||||
const product = await catalog.getProduct({ sku });
|
||||
|
||||
// External API call: GitHub's public repository endpoint. Do not send the
|
||||
// user's RPC identity token or internal headers to external services.
|
||||
let githubResponse: Response;
|
||||
try {
|
||||
githubResponse = await fetch("https://api.github.com/repos/octocat/Hello-World", {
|
||||
headers: { accept: "application/vnd.github+json", "user-agent": "wrnexus-example" },
|
||||
signal: ctx.req.signal,
|
||||
});
|
||||
} catch {
|
||||
return Response.json({ error: "External repository lookup failed." }, { status: 502 });
|
||||
}
|
||||
if (!githubResponse.ok) {
|
||||
return Response.json({ error: "External repository lookup failed." }, { status: 502 });
|
||||
}
|
||||
const github = (await githubResponse.json()) as GitHubRepository;
|
||||
if (typeof github.full_name !== "string" || typeof github.stargazers_count !== "number") {
|
||||
return Response.json(
|
||||
{ error: "External repository returned an unexpected response." },
|
||||
{ status: 502 },
|
||||
);
|
||||
}
|
||||
|
||||
// Inter-app call #2: record the completed lookup in the audit app. This is
|
||||
// intentionally awaited: callers learn whether the audit record was saved.
|
||||
const audit = serviceClient(auditService, { app: "audit", as: ctx, transport });
|
||||
const receipt = await audit.recordLookup({
|
||||
sku: product.sku,
|
||||
repository: github.full_name,
|
||||
stars: github.stargazers_count,
|
||||
});
|
||||
|
||||
return Response.json({
|
||||
product,
|
||||
external: { repository: github.full_name, stars: github.stargazers_count },
|
||||
audit: receipt,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user