From b2df674a2a619040a6eecbba26c37c262f5b597d Mon Sep 17 00:00:00 2001 From: ivanauth Date: Thu, 9 Jul 2026 15:17:23 -0400 Subject: [PATCH] feat: add v1 subpath export Allows importing the v1 client module directly via '@authzed/authzed-node/v1' in addition to the existing v1 namespace re-export from the package root. typesVersions covers resolution for consumers on node10-style module resolution. Signed-off-by: ivanauth --- README.md | 8 ++++++++ package.json | 18 +++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 42eecf0..e24cd71 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,14 @@ import { v1 } from "@authzed/authzed-node"; const client = v1.NewClient("t_your_token_here_1234567deadbeef"); ``` +Each API version is also available as a subpath export, so its members can be imported directly: + +```js +import { NewClient, ClientSecurity } from "@authzed/authzed-node/v1"; + +const client = NewClient("t_your_token_here_1234567deadbeef"); +``` + Or to use a custom certificate authority, load the CA certificate and pass the file reference to `NewClientWithCustomCert`. ```js diff --git a/package.json b/package.json index 9201cb0..467c412 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,13 @@ "main": "dist/src/index.cjs", "module": "dist/src/index.js", "types": "dist/src/index.d.ts", + "typesVersions": { + "*": { + "v1": [ + "./dist/src/v1.d.ts" + ] + } + }, "exports": { "./package.json": "./package.json", ".": { @@ -35,6 +42,15 @@ }, "require": "./dist/src/index.cjs", "import": "./dist/src/index.js" + }, + "./v1": { + "types": { + "import": "./dist/src/v1.d.ts", + "require": "./dist/src/v1.d.cts", + "default": "./dist/src/v1.d.ts" + }, + "require": "./dist/src/v1.cjs", + "import": "./dist/src/v1.js" } }, "scripts": { @@ -46,7 +62,7 @@ "format": "pnpm oxfmt", "format:check": "pnpm oxfmt --check", "build": "pnpm tsc", - "postbuild": "rollup dist/src/index.js --file dist/src/index.cjs --format cjs && cp dist/src/index.d.ts dist/src/index.d.cts", + "postbuild": "rollup dist/src/index.js --file dist/src/index.cjs --format cjs && cp dist/src/index.d.ts dist/src/index.d.cts && rollup dist/src/v1.js --file dist/src/v1.cjs --format cjs && cp dist/src/v1.d.ts dist/src/v1.d.cts", "prepublishOnly": "pnpm build", "build-js-client": "pnpm tsc --declaration false --outDir js-dist" },