Something went wrong. Try again.
[READ-ONLY]
a fast, modern browser for the npm registry forked from npmx.dev/npmx.dev
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159import './node-pty.d.ts'
export interface ConnectorConfig { port: number host: string}
export interface ConnectorSession { token: string connectedAt: number npmUser: string | null /** Base64 data URL of the user's avatar */ avatar: string | null}
export type OperationType = | 'org:add-user' | 'org:rm-user' | 'org:set-role' | 'team:create' | 'team:destroy' | 'team:add-user' | 'team:rm-user' | 'access:grant' | 'access:revoke' | 'owner:add' | 'owner:rm' | 'package:init'
export type OperationStatus = | 'pending' | 'approved' | 'running' | 'completed' | 'failed' | 'cancelled'
export interface OperationResult { stdout: string stderr: string exitCode: number /** True if the operation failed due to missing/invalid OTP */ requiresOtp?: boolean /** True if the operation failed due to authentication failure (not logged in or token expired) */ authFailure?: boolean /** URLs detected in the command output (stdout + stderr) */ urls?: string[]}
export interface PendingOperation { id: string type: OperationType params: Record<string, string> description: string command: string status: OperationStatus createdAt: number result?: OperationResult /** ID of operation this depends on (must complete successfully first) */ dependsOn?: string /** Auth URL detected during interactive execution (set while operation is still running) */ authUrl?: string}
export interface ConnectorState { session: ConnectorSession operations: PendingOperation[]}
export interface ApiResponse<T = unknown> { success: boolean data?: T error?: string}
// -- Connector API contract (shared by real + mock server) -------------------
export type OrgRole = 'developer' | 'admin' | 'owner'
export type AccessPermission = 'read-only' | 'read-write'
/** POST /connect response data */export interface ConnectResponseData { npmUser: string | null avatar: string | null connectedAt: number}
/** GET /state response data */export interface StateResponseData { npmUser: string | null avatar: string | null operations: PendingOperation[]}
/** POST /execute response data */export interface ExecuteResponseData { results: Array<{ id: string; result: OperationResult }> otpRequired?: boolean authFailure?: boolean urls?: string[]}
/** POST /approve-all response data */export interface ApproveAllResponseData { approved: number}
/** DELETE /operations/all response data */export interface ClearOperationsResponseData { removed: number}
/** Request body for POST /operations */export interface CreateOperationBody { type: OperationType params: Record<string, string> description: string command: string dependsOn?: string}
/** * Connector API endpoint contract. Both server.ts and mock-app.ts must * conform to these shapes, enforced via `satisfies` and `AssertEndpointsImplemented`. */export interface ConnectorEndpoints { 'POST /connect': { body: { token: string }; data: ConnectResponseData } 'GET /state': { body: never; data: StateResponseData } 'POST /operations': { body: CreateOperationBody; data: PendingOperation } 'POST /operations/batch': { body: CreateOperationBody[]; data: PendingOperation[] } 'DELETE /operations': { body: never; data: void } 'DELETE /operations/all': { body: never; data: ClearOperationsResponseData } 'POST /approve': { body: never; data: PendingOperation } 'POST /approve-all': { body: never; data: ApproveAllResponseData } 'POST /retry': { body: never; data: PendingOperation } 'POST /execute': { body: { otp?: string; interactive?: boolean; openUrls?: boolean } data: ExecuteResponseData } 'GET /org/:org/users': { body: never; data: Record<string, OrgRole> } 'GET /org/:org/teams': { body: never; data: string[] } 'GET /team/:scopeTeam/users': { body: never; data: string[] } 'GET /package/:pkg/collaborators': { body: never; data: Record<string, AccessPermission> } 'GET /user/packages': { body: never; data: Record<string, AccessPermission> } 'GET /user/orgs': { body: never; data: string[] }}
/** Compile-time check that a server implements exactly the ConnectorEndpoints keys. */type IsExact<A, B> = [A] extends [B] ? ([B] extends [A] ? true : false) : falseexport type AssertEndpointsImplemented<Implemented extends string> = IsExact<Implemented, keyof ConnectorEndpoints> extends true ? true : { error: 'Endpoint mismatch' missing: Exclude<keyof ConnectorEndpoints, Implemented> extra: Exclude<Implemented, keyof ConnectorEndpoints> }