Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@octokit-next/types

Package Overview
Dependencies
Maintainers
2
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@octokit-next/types - npm Package Compare versions

Comparing version 1.3.1 to 1.4.0

22

index.d.ts
import { RequestInterface } from "./request";
export { RequestInterface } from "./request";

@@ -8,2 +9,4 @@ /**

interface Options {
version?: keyof Octokit.ApiVersions;
/**

@@ -23,10 +26,17 @@ * GitHub's REST API base URL. Defaults to https://api.github.com

request?: {
/**
* override the built-in fetch method, e.g. for testing
*/
fetch?: (resource: any, init?: any) => Promise<{}>;
};
request?: RequestOptions;
}
interface RequestOptions {
/**
* Override API version on a per-request basis.
*/
version?: keyof Octokit.ApiVersions;
/**
* override the built-in fetch method, e.g. for testing
*/
fetch?: (resource: any, init?: any) => Promise<any>;
}
interface ResponseHeaders {

@@ -33,0 +43,0 @@ "cache-control": string;

import { expectType } from "tsd";
import { Octokit, Plugin } from "./index.js";
import "@octokit-next/types-rest-api-github.com";
export async function test() {

@@ -29,3 +31,3 @@ // TODO:

// @ts-expect-error - ghes-only does not exist
emojisResponseDotcom.data["ghes-only"];
type test = typeof emojisResponseDotcom["data"]["ghes-only"];

@@ -32,0 +34,0 @@ const OctokitWithEmptyDefaults = Octokit.withDefaults({

@@ -7,3 +7,3 @@ {

"type": "module",
"version": "1.3.1",
"version": "1.4.0",
"description": "Shared TypeScript definitions for upcoming Octokit SDK",

@@ -10,0 +10,0 @@ "types": "./index.d.ts",

import { Octokit } from "./index.js";
type RequestParameters = Record<string, unknown>;
type EndpointParameters = { request: Octokit.RequestOptions } & Record<
string,
unknown
>;
export interface RequestInterface<TVersion extends keyof Octokit.ApiVersions> {
type UnknownResponse = {
/**
* Sends a request based on endpoint options
* http response headers
*/
headers: Record<string, unknown>;
/**
* http response code
*/
status: number;
/**
* URL of response after all redirects
*/
url: string;
/**
* Response data as documented in the REST API reference documentation at https://docs.github.com/rest/reference
*/
data: unknown;
};
/**
* The `RequestInterface` is used for both the standalone `@octokit-next/request` module
* as well as `@octokit-next/core`'s `.request()` method.
*
* It has 3 overrides
*
* 1. When passing `{ request: { version }}` as part of the parameters, the passed version
* is used as a base for the types of the remaining parameters and the response
* 2. When a known route is passed, the types for the parameters and the response are
* derived from the version passed in `RequestInterface<version>`, which defaults to `"github.com"`
* 3. When an unknown route is passed, any parameters can be passed, and the response is unknown.
*/
export interface RequestInterface<
TVersion extends keyof Octokit.ApiVersions = "github.com"
> {
/**
* Send a request to a known endpoint using a version specified in `request.version`.
*
* @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
* @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<
RVersion extends keyof Octokit.ApiVersions,
Route extends keyof Octokit.ApiVersions[RVersion]["Endpoints"],
Endpoint = Octokit.ApiVersions[RVersion]["Endpoints"][Route]
>(
route: Route,
options: {
request: {
version: RVersion;
};
} & ("parameters" extends keyof Endpoint
? Endpoint["parameters"] & EndpointParameters
: never)
): "response" extends keyof Endpoint ? Promise<Endpoint["response"]> : never;
/**
* Send a request to a known endpoint
*
* @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<
Route extends keyof Octokit.ApiVersions[TVersion]["Endpoints"],
Endpoint = Octokit.ApiVersions[TVersion]["Endpoints"][Route]
>(
route: Route,
options?: "parameters" extends keyof Endpoint
? Endpoint["parameters"] & EndpointParameters
: never
): "response" extends keyof Endpoint ? Promise<Endpoint["response"]> : never;
/**
* Send a request to an unknown endpoint
*
* @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
*/
<Route extends string>(
route: keyof Octokit.ApiVersions[TVersion]["Endpoints"] | Route,
options?: Route extends keyof Octokit.ApiVersions[TVersion]["Endpoints"]
? "parameters" extends keyof Octokit.ApiVersions[TVersion]["Endpoints"][Route]
? Octokit.ApiVersions[TVersion]["Endpoints"][Route]["parameters"] &
RequestParameters
: never
: RequestParameters
): Route extends keyof Octokit.ApiVersions[TVersion]["Endpoints"]
? "response" extends keyof Octokit.ApiVersions[TVersion]["Endpoints"][Route]
? Promise<Octokit.ApiVersions[TVersion]["Endpoints"][Route]["response"]>
: never
: Promise<
Octokit.Response<
unknown,
Octokit.ApiVersions[TVersion]["ResponseHeaders"]
>
>;
route: Route,
options?: EndpointParameters
): Promise<UnknownResponse>;
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc