Skip to content

Commit

Permalink
feat: types-rest-api-ghes-3.2-compatible and `types-rest-api-github…
Browse files Browse the repository at this point in the history
….ae-compatible` (#35)
  • Loading branch information
gr2m authored Sep 15, 2021
1 parent d4deeab commit e365d4b
Show file tree
Hide file tree
Showing 15 changed files with 460 additions and 97 deletions.
49 changes: 45 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/types-rest-api-ghes-3.0-compatible/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ declare module "@octokit-next/types" {
namespace Octokit {
interface ApiVersions {
"ghes-3.0-compatible": {
ResponseHeaders: EndpointsCompatible;
ResponseHeaders: ResponseHeadersCompatible;

Endpoints: {
[route in keyof EndpointsCompatible]: {
Expand Down
29 changes: 14 additions & 15 deletions packages/types-rest-api-ghes-3.0-compatible/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"name": "@octokit-next/types-rest-api-ghes-3.0-compatible",
"publishConfig": {
"access": "public"
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"dependencies": {
"@octokit-next/types": "0.0.0-development",
"@octokit-next/types-openapi-ghes-3.0": "0.0.0-development"
},
"type": "module",
"version": "0.0.0-development",
"description": "Types for GHES 3.0 (compatible) REST API requests and responses",
"types": "./index.d.ts",
"homepage": "https://github.com/octokit/octokit-next.js/tree/main/packages/types-rest-api-ghes-3.0-compatible#readme",
"license": "MIT",
"name": "@octokit-next/types-rest-api-ghes-3.0-compatible",
"octokit": { "openapi-version": "5.2.2" },
"publishConfig": { "access": "public" },
"repository": {
"directory": "packages/types-rest-api-ghes-3.0-compatible",
"type": "git",
"url": "https://github.com/octokit/octokit-next.js.git",
"directory": "packages/types-rest-api-ghes-3.0-compatible"
"url": "https://github.com/octokit/octokit-next.js.git"
},
"homepage": "https://github.com/octokit/octokit-next.js/tree/main/packages/types-rest-api-ghes-3.0-compatible#readme",
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"license": "MIT",
"dependencies": {
"@octokit-next/types": "0.0.0-development",
"@octokit-next/types-rest-api": "0.0.0-development"
}
"type": "module",
"types": "index.d.ts",
"version": "0.0.0-development"
}
24 changes: 13 additions & 11 deletions packages/types-rest-api-ghes-3.0/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"name": "@octokit-next/types-rest-api-ghes-3.0",
"description": "Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com",
"repository": {
"type": "git",
"url": "https://github.com/octokit/octokit-next.js.git",
"directory": "packages/types-rest-api-ghes-3.0"
},
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"dependencies": {
"@octokit-next/types": "0.0.0-development",
"@octokit-next/types-openapi-ghes-3.0": "0.0.0-development",
"@octokit-next/types-rest-api": "0.0.0-development",
"@octokit-next/types-rest-api-ghes-3.1": "0.0.0-development",
"type-fest": "^2.0.0"
},
"description": "Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com",
"homepage": "https://github.com/octokit/octokit-next.js/tree/main/packages/types-rest-api-ghes-3.0#readme",
"license": "MIT",
"name": "@octokit-next/types-rest-api-ghes-3.0",
"octokit": { "openapi-version": "5.2.2" },
"publishConfig": { "access": "public" },
"version": "0.0.0-development",
"repository": {
"directory": "packages/types-rest-api-ghes-3.0",
"type": "git",
"url": "https://github.com/octokit/octokit-next.js.git"
},
"type": "module",
"types": "index.d.ts",
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"license": "MIT",
"octokit": { "openapi-version": "5.2.2" }
"version": "0.0.0-development"
}
29 changes: 14 additions & 15 deletions packages/types-rest-api-ghes-3.1-compatible/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
{
"name": "@octokit-next/types-rest-api-ghes-3.1-compatible",
"publishConfig": {
"access": "public"
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"dependencies": {
"@octokit-next/types": "0.0.0-development",
"@octokit-next/types-openapi-ghes-3.1": "0.0.0-development"
},
"type": "module",
"version": "0.0.0-development",
"description": "Types for GHES 3.1 (compatible) REST API requests and responses",
"types": "./index.d.ts",
"homepage": "https://github.com/octokit/octokit-next.js/tree/main/packages/types-rest-api-ghes-3.1-compatible#readme",
"license": "MIT",
"name": "@octokit-next/types-rest-api-ghes-3.1-compatible",
"octokit": { "openapi-version": "5.2.2" },
"publishConfig": { "access": "public" },
"repository": {
"directory": "packages/types-rest-api-ghes-3.1-compatible",
"type": "git",
"url": "https://github.com/octokit/octokit-next.js.git",
"directory": "packages/types-rest-api-ghes-3.1-compatible"
"url": "https://github.com/octokit/octokit-next.js.git"
},
"homepage": "https://github.com/octokit/octokit-next.js/tree/main/packages/types-rest-api-ghes-3.1-compatible#readme",
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"license": "MIT",
"dependencies": {
"@octokit-next/types": "0.0.0-development",
"@octokit-next/types-rest-api": "0.0.0-development"
}
"type": "module",
"types": "index.d.ts",
"version": "0.0.0-development"
}
24 changes: 13 additions & 11 deletions packages/types-rest-api-ghes-3.1/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"name": "@octokit-next/types-rest-api-ghes-3.1",
"description": "Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com",
"repository": {
"type": "git",
"url": "https://github.com/octokit/octokit-next.js.git",
"directory": "packages/types-rest-api-ghes-3.1"
},
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"dependencies": {
"@octokit-next/types": "0.0.0-development",
"@octokit-next/types-openapi-ghes-3.1": "0.0.0-development",
"@octokit-next/types-rest-api": "0.0.0-development",
"@octokit-next/types-rest-api-ghes-3.2": "0.0.0-development",
"type-fest": "^2.0.0"
},
"description": "Generated TypeScript definitions based on GitHub's OpenAPI spec for api.github.com",
"homepage": "https://github.com/octokit/octokit-next.js/tree/main/packages/types-rest-api-ghes-3.1#readme",
"license": "MIT",
"name": "@octokit-next/types-rest-api-ghes-3.1",
"octokit": { "openapi-version": "5.2.2" },
"publishConfig": { "access": "public" },
"version": "0.0.0-development",
"repository": {
"directory": "packages/types-rest-api-ghes-3.1",
"type": "git",
"url": "https://github.com/octokit/octokit-next.js.git"
},
"type": "module",
"types": "index.d.ts",
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"license": "MIT",
"octokit": { "openapi-version": "5.2.2" }
"version": "0.0.0-development"
}
32 changes: 32 additions & 0 deletions packages/types-rest-api-ghes-3.2-compatible/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# `@octokit-next/types-rest-api-ghes-3.2-compatible`

> Types for GHES 3.2 (compatible) REST API requests and responses
🚫⚠️ This package is part of an experimental Octokit SDK for testing purpose only - DO NOT USE

[learn more](https://github.com/octokit/octokit-next.js)

The goal for this package is to enable developers to build code that will work in both environments: github.com and GHES 3.2. Only endpoints and properties that exist in both have types by default.

The version can be overwritten on a per-request basis as needed.

## Usage

```ts
const octokit = new Octokit({
version: "ghes-3.2-compatible",
});
const response = await octokit.request("GET /");
```

The routes suggested for `octokit.request(route)` are only the ones that exist for `version: "github.com"` and have no overrides for `version: "ghes-3.2"`. The same is true for `response.headers`.

To override the version specified in the constructor it can be set using the `request.version` option

```ts
const ghesOnlyResponse = await octokit.request("GET /admins/users", {
request: {
version: "ghes-3.2",
},
});
```
34 changes: 34 additions & 0 deletions packages/types-rest-api-ghes-3.2-compatible/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { Octokit } from "@octokit-next/types";

import {
EndpointsDiff,
ResponseHeadersDiff,
} from "@octokit-next/types-rest-api-ghes-3.2";

export type ResponseHeadersCompatible = Omit<
Octokit.ResponseHeaders,
keyof ResponseHeadersDiff
>;

export type EndpointsCompatible = Omit<Octokit.Endpoints, keyof EndpointsDiff>;

declare module "@octokit-next/types" {
namespace Octokit {
interface ApiVersions {
"ghes-3.2-compatible": {
ResponseHeaders: ResponseHeadersCompatible;

Endpoints: {
[route in keyof EndpointsCompatible]: {
parameters: EndpointsCompatible[route]["parameters"];
response: Octokit.Response<
EndpointsCompatible[route]["response"]["data"],
EndpointsCompatible[route]["response"]["status"],
ResponseHeadersCompatible
>;
};
};
};
}
}
}
21 changes: 21 additions & 0 deletions packages/types-rest-api-ghes-3.2-compatible/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"author": "Gregor Martynus (https://twitter.com/gr2m)",
"dependencies": {
"@octokit-next/types": "0.0.0-development",
"@octokit-next/types-openapi-ghes-3.2": "0.0.0-development"
},
"description": "Types for GHES 3.2 (compatible) REST API requests and responses",
"homepage": "https://github.com/octokit/octokit-next.js/tree/main/packages/types-rest-api-ghes-3.2-compatible#readme",
"license": "MIT",
"name": "@octokit-next/types-rest-api-ghes-3.2-compatible",
"octokit": { "openapi-version": "5.2.2" },
"publishConfig": { "access": "public" },
"repository": {
"directory": "packages/types-rest-api-ghes-3.2-compatible",
"type": "git",
"url": "https://github.com/octokit/octokit-next.js.git"
},
"type": "module",
"types": "index.d.ts",
"version": "0.0.0-development"
}
Loading

0 comments on commit e365d4b

Please sign in to comment.