# @wyattjoh/jsr [![JSR](https://jsr.io/badges/@wyattjoh/jsr)](https://jsr.io/@wyattjoh/jsr) [![JSR Score](https://jsr.io/badges/@wyattjoh/jsr/score)](https://jsr.io/@wyattjoh/jsr) [![JSR Scope](https://jsr.io/badges/@wyattjoh)](https://jsr.io/@wyattjoh) A Deno library for interacting with the JSR (JavaScript Registry) API. This package provides a clean, type-safe API for searching packages, managing versions, and accessing registry metadata. ## Installation ```bash deno add @wyattjoh/jsr ``` ## Usage ```typescript import { createJSRConfig, getPackage, getPackageVersion, listPackageVersions, searchPackages, } from "@wyattjoh/jsr"; // Create a configuration const config = createJSRConfig({ apiToken: "your-api-token", // optional, for authenticated operations }); // Search for packages const results = await searchPackages(config, "react", 10); // Get package details const pkg = await getPackage(config, "deno", "std"); // Get specific version const version = await getPackageVersion(config, "deno", "std", "1.0.0"); // List all versions const versions = await listPackageVersions(config, "deno", "std"); ``` ## Features - **Package Search**: Full-text search across the JSR registry - **Package Management**: Create, update, and delete packages (with auth) - **Version Control**: Manage package versions and dependencies - **Scope Management**: Create and manage JSR scopes - **Member Management**: Invite and manage scope members - **Type-Safe**: Full TypeScript support with Zod validation - **Comprehensive API**: Complete coverage of JSR API endpoints ## API Reference ### Configuration ```typescript createJSRConfig(options?: ConfigOptions): JSRConfig testConnection(config: JSRConfig): Promise ``` ### Packages ```typescript searchPackages(config: JSRConfig, query?: string, limit?: number, page?: number): Promise getPackage(config: JSRConfig, scope: string, name: string): Promise getPackageVersion(config: JSRConfig, scope: string, name: string, version: string): Promise listPackageVersions(config: JSRConfig, scope: string, name: string, limit?: number, page?: number): Promise getPackageMetadata(config: JSRConfig, scope: string, name: string): Promise getPackageDependencies(config: JSRConfig, scope: string, name: string, version: string): Promise getPackageScore(config: JSRConfig, scope: string, name: string): Promise getPackageDependents(config: JSRConfig, scope: string, name: string, options?: DependentsOptions): Promise createPackage(config: JSRConfig, scope: string, name: string, description?: string): Promise updatePackage(config: JSRConfig, scope: string, name: string, updates: PackageUpdates): Promise deletePackage(config: JSRConfig, scope: string, name: string): Promise ``` ### Package Versions ```typescript createPackageVersion(config: JSRConfig, scope: string, name: string, version: string, config?: object, files?: File[]): Promise updatePackageVersion(config: JSRConfig, scope: string, name: string, version: string, yanked: boolean): Promise ``` ### Scopes ```typescript getScope(config: JSRConfig, scope: string): Promise listScopePackages(config: JSRConfig, scope: string, limit?: number, page?: number): Promise createScope(config: JSRConfig, scope: string, description?: string): Promise updateScope(config: JSRConfig, scope: string, settings: ScopeSettings): Promise deleteScope(config: JSRConfig, scope: string): Promise ``` ### Members & Invites ```typescript listScopeMembers(config: JSRConfig, scope: string): Promise addScopeMember(config: JSRConfig, scope: string, githubLogin: string): Promise updateScopeMember(config: JSRConfig, scope: string, userId: string, isAdmin: boolean): Promise removeScopeMember(config: JSRConfig, scope: string, userId: string): Promise listScopeInvites(config: JSRConfig, scope: string): Promise deleteScopeInvite(config: JSRConfig, scope: string, userId: string): Promise acceptScopeInvite(config: JSRConfig, scope: string): Promise declineScopeInvite(config: JSRConfig, scope: string): Promise ``` ### Users ```typescript getCurrentUser(config: JSRConfig): Promise getCurrentUserScopes(config: JSRConfig): Promise getCurrentUserScopeMember(config: JSRConfig, scope: string): Promise getCurrentUserInvites(config: JSRConfig): Promise getUser(config: JSRConfig, id: string): Promise getUserScopes(config: JSRConfig, id: string): Promise ``` ### Registry ```typescript listPackages(config: JSRConfig, options?: ListOptions): Promise getStats(config: JSRConfig): Promise ``` ### Publishing ```typescript getPublishingTask(config: JSRConfig, taskId: string): Promise ``` ### Authorization ```typescript createAuthorization(config: JSRConfig, params: AuthorizationParams): Promise getAuthorizationDetails(config: JSRConfig, code: string): Promise approveAuthorization(config: JSRConfig, code: string): Promise denyAuthorization(config: JSRConfig, code: string): Promise exchangeAuthorizationCode(config: JSRConfig, code: string, exchangeToken: string): Promise ``` ## Authentication Some operations require authentication via JSR API token: ```typescript import { createJSRConfig, createPackage } from "@wyattjoh/jsr"; // Create a config with your JSR API token const config = createJSRConfig({ apiToken: "your-api-token", }); // Now you can perform authenticated operations await createPackage(config, "my-scope", "my-package", "Package description"); ``` ## Configuration The client can be configured with custom URLs: ```typescript import { createJSRConfig } from "@wyattjoh/jsr"; const config = createJSRConfig({ apiUrl: "https://api.jsr.io", registryUrl: "https://jsr.io", apiToken: "your-api-token", // optional }); ``` ## Requirements - Deno 2.x or later - Network access to JSR API - JSR API token for authenticated operations ## License MIT