refactor: migrate legacy wire namespace to wrn
This commit is contained in:
@@ -418,7 +418,7 @@ export class ServiceError extends Error {
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert to a wire result. The message is replaced unless explicitly
|
||||
* Convert to a wrn result. The message is replaced unless explicitly
|
||||
* exposed: a handler's error text routinely names tables, hosts, or
|
||||
* credentials, and this value crosses an app boundary.
|
||||
*/
|
||||
@@ -1296,7 +1296,7 @@ describe("implement", () => {
|
||||
expect(result).toEqual({ ok: true, value: { sum: 3 } });
|
||||
});
|
||||
|
||||
test("coerces through the schema rather than trusting the wire", async () => {
|
||||
test("coerces through the schema rather than trusting the wrn", async () => {
|
||||
// "3" arrives as a string over JSON from a sloppy caller; the schema coerces.
|
||||
const result = await impl().invoke("add", { a: 1, b: "3" });
|
||||
expect(result).toEqual({ ok: true, value: { sum: 4 } });
|
||||
@@ -1360,7 +1360,7 @@ describe("implement", () => {
|
||||
|
||||
test("a guarded procedure with NO permission checker configured denies", async () => {
|
||||
// Fail closed: a contract that declares a permission must not run
|
||||
// unguarded just because the app forgot to wire a checker.
|
||||
// unguarded just because the app forgot to wrn a checker.
|
||||
const result = await impl(undefined).invoke("guarded", {});
|
||||
expect(result.ok).toBe(false);
|
||||
if (!result.ok) expect(result.code).toBe(RPC_ERROR_CODES.denied);
|
||||
@@ -1439,7 +1439,7 @@ export interface ImplementOptions {
|
||||
/** This app's name, used as the identity token's expected audience. */
|
||||
selfApp: string;
|
||||
/**
|
||||
* Resolve whether the subject holds a permission. Wire this to
|
||||
* Resolve whether the subject holds a permission. WrNexus this to
|
||||
* `@wrnexus/authz`. A procedure that DECLARES a permission but finds no
|
||||
* checker configured is denied — never run unguarded.
|
||||
*/
|
||||
@@ -2345,7 +2345,7 @@ export async function handleRpcRequest(
|
||||
Run: `bun test packages/dev-server/test/rpc-endpoint.test.ts`
|
||||
Expected: PASS, 9 tests
|
||||
|
||||
- [ ] **Step 5: Wire the dispatcher into the request pipeline**
|
||||
- [ ] **Step 5: WrNexus the dispatcher into the request pipeline**
|
||||
|
||||
In `packages/dev-server/src/runtime.ts`, inside the main `fetch` handler, call `handleRpcRequest` BEFORE normal page/API routing and return its result when non-null. Build the `Map<string, ServiceImplementation>` from `router.services` at boot, importing each module's default export. Follow the pattern `loadAppAuthzCatalog` uses for importing discovered modules, including routing hot-reload re-imports through `loadModule`.
|
||||
|
||||
@@ -2411,7 +2411,7 @@ const billing = defineService({
|
||||
},
|
||||
});
|
||||
|
||||
function wire(allowed: boolean) {
|
||||
function wrn(allowed: boolean) {
|
||||
const service = implement(
|
||||
billing,
|
||||
{
|
||||
@@ -2434,7 +2434,7 @@ describe("end to end", () => {
|
||||
const client = serviceClient(billing, {
|
||||
app: "billing",
|
||||
as: { user: { id: "u1" }, tenant: { id: "acme" }, locals: {} } as unknown as Context,
|
||||
transport: wire(true),
|
||||
transport: wrn(true),
|
||||
});
|
||||
expect(await client.createInvoice({ amountCents: 250 })).toEqual({
|
||||
invoiceId: "inv_250",
|
||||
@@ -2448,7 +2448,7 @@ describe("end to end", () => {
|
||||
const client = serviceClient(billing, {
|
||||
app: "billing",
|
||||
as: { user: { id: "u1" }, locals: {} } as unknown as Context,
|
||||
transport: wire(false),
|
||||
transport: wrn(false),
|
||||
});
|
||||
try {
|
||||
await client.createInvoice({ amountCents: 1 });
|
||||
@@ -2459,7 +2459,7 @@ describe("end to end", () => {
|
||||
});
|
||||
|
||||
test("invalid input never reaches the handler", async () => {
|
||||
const client = serviceClient(billing, { app: "billing", transport: wire(true) });
|
||||
const client = serviceClient(billing, { app: "billing", transport: wrn(true) });
|
||||
try {
|
||||
await client.createInvoice({ amountCents: "abc" } as never);
|
||||
throw new Error("should not reach here");
|
||||
|
||||
Reference in New Issue
Block a user