release: WRNexusJS 0.5.10

This commit is contained in:
2026-07-30 13:36:29 +05:30
parent 8fc6f15402
commit d1b0c55b53
159 changed files with 7509 additions and 604 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "@wrnexus/helpers",
"version": "0.5.1",
"version": "0.5.10",
"private": true,
"type": "module",
"description": "Safe convenience helpers for WrNexus request contexts and common application flows.",
+1
View File
@@ -144,6 +144,7 @@ export {
currentAppName,
currentAppOrigin,
workspaceAppOrigins,
workspaceRootDomain,
} from "./workspace.ts";
export {
backoffDelay,
+23
View File
@@ -56,3 +56,26 @@ export function currentAppOrigin(): string | undefined {
export function workspaceAppOrigins(): Readonly<Record<string, string>> {
return Object.freeze({ ...workspaceOrigins() });
}
/** Shared DNS suffix for configured workspace apps (for example `staging.example.com`). */
export function workspaceRootDomain(): string {
const hosts = Object.values(workspaceOrigins()).map((origin) =>
new URL(origin).hostname.toLowerCase(),
);
if (!hosts.length) {
throw new Error("Workspace origins are unavailable.");
}
const labels = hosts.map((host) => host.split(".").reverse());
const common: string[] = [];
for (let index = 0; index < labels[0]!.length; index++) {
const label = labels[0]![index];
if (!labels.every((parts) => parts[index] === label)) break;
common.push(label!);
}
if (!common.length) {
throw new Error(`Workspace apps do not share a root domain: ${hosts.join(", ")}.`);
}
return common.reverse().join(".");
}
+16
View File
@@ -9,6 +9,22 @@ import {
stableStringify,
} from "../src/index.ts";
test("derives the shared workspace root domain from configured public app origins", async () => {
const previous = process.env.WRNEXUS_WORKSPACE_ORIGINS;
process.env.WRNEXUS_WORKSPACE_ORIGINS = JSON.stringify({
admin: "https://admin.staging.example.com",
citizen: "https://citizen.staging.example.com",
sso: "https://sso.staging.example.com",
});
try {
const { workspaceRootDomain } = await import("../src/workspace.ts");
expect(workspaceRootDomain()).toBe("staging.example.com");
} finally {
if (previous === undefined) delete process.env.WRNEXUS_WORKSPACE_ORIGINS;
else process.env.WRNEXUS_WORKSPACE_ORIGINS = previous;
}
});
function context(url: string, headers: HeadersInit = {}) {
const parsed = new URL(url);
return createContext(new Request(parsed, { headers }), parsed);