refactor: migrate legacy wire namespace to wrn
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@wrnexus/rpc",
|
||||
"version": "0.8.8",
|
||||
"version": "0.8.9",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"main": "./src/index.ts",
|
||||
|
||||
@@ -62,7 +62,7 @@ export class ServiceError extends Error {
|
||||
/**
|
||||
* `retryable` defaults to the code-derived value for callers that
|
||||
* construct a `ServiceError` directly. Pass it explicitly when relaying a
|
||||
* wire result: the transport already computed the authoritative value
|
||||
* wrn result: the transport already computed the authoritative value
|
||||
* (e.g. a bounded HTTP-status check), and recomputing it here from the
|
||||
* code alone would silently flip it — `RPC_TRANSPORT` derives to `true`,
|
||||
* even for a non-retryable 403.
|
||||
@@ -75,7 +75,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.
|
||||
*/
|
||||
|
||||
@@ -190,11 +190,11 @@ describe("serviceClient", () => {
|
||||
expect(seenTarget?.service).toBe("billing");
|
||||
});
|
||||
|
||||
test("a wire-level non-retryable failure (e.g. a 403) surfaces at the client as retryable: false", async () => {
|
||||
test("a wrn-level non-retryable failure (e.g. a 403) surfaces at the client as retryable: false", async () => {
|
||||
// RPC_TRANSPORT recomputes to retryable: true from the code alone — that
|
||||
// is correct for a 5xx, but the transport already determined a 403 is
|
||||
// NOT retryable via the bounded status check. The client must pass that
|
||||
// wire value through rather than recompute it from the code.
|
||||
// wrn value through rather than recompute it from the code.
|
||||
const client = serviceClient(billing, {
|
||||
transport: {
|
||||
call: async () => ({
|
||||
|
||||
@@ -151,7 +151,7 @@ describe("subject context token", () => {
|
||||
});
|
||||
await expect(importSubjectContext(token, "billing")).rejects.toThrow();
|
||||
// Same token, wider explicit bound: proves maxAgeSeconds is actually
|
||||
// wired through rather than the guard being a hardcoded rejection.
|
||||
// connected through rather than the guard being a hardcoded rejection.
|
||||
await expect(
|
||||
importSubjectContext(token, "billing", { maxAgeSeconds: 1000 }),
|
||||
).resolves.toBeDefined();
|
||||
|
||||
@@ -30,7 +30,7 @@ const billing = defineService({
|
||||
},
|
||||
});
|
||||
|
||||
function wire(allowed: boolean) {
|
||||
function wrn(allowed: boolean) {
|
||||
const service = implement(
|
||||
billing,
|
||||
{
|
||||
@@ -47,7 +47,7 @@ function wire(allowed: boolean) {
|
||||
});
|
||||
}
|
||||
|
||||
function httpWire(allowed: boolean) {
|
||||
function createHttpTransport(allowed: boolean) {
|
||||
const service = implement(
|
||||
billing,
|
||||
{
|
||||
@@ -122,7 +122,7 @@ describe("RPC integration", () => {
|
||||
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",
|
||||
@@ -136,7 +136,7 @@ describe("RPC integration", () => {
|
||||
const client = serviceClient(billing, {
|
||||
app: "billing",
|
||||
as: { user: { id: "u1" }, locals: {} } as unknown as Context,
|
||||
transport: wire(false),
|
||||
transport: wrn(false),
|
||||
});
|
||||
await expect(client.createInvoice({ amountCents: 1 })).rejects.toMatchObject({
|
||||
code: RPC_ERROR_CODES.denied,
|
||||
@@ -149,7 +149,7 @@ describe("RPC integration", () => {
|
||||
const client = serviceClient(billing, {
|
||||
app: "billing",
|
||||
as: { user: { id: "u1" }, locals: {} } as unknown as Context,
|
||||
transport: httpWire(true),
|
||||
transport: createHttpTransport(true),
|
||||
});
|
||||
expect(await client.createInvoice({ amountCents: 7 })).toEqual({
|
||||
invoiceId: "inv_7",
|
||||
|
||||
Reference in New Issue
Block a user