Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: v3 #2456

Merged
merged 7 commits into from
Jul 11, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ jobs:
strategy:
matrix:
node_version:
- 14
- 16
- 18
- 20
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node_version }}
Expand Down
23 changes: 4 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ The `octokit` package integrates the three main Octokit libraries
- [`octokit.rest` endpoint methods](#octokitrest-endpoint-methods)
- [`octokit.request()`](#octokitrequest)
- [Pagination](#pagination)
- [Media Type previews and formats](#media-type-previews-and-formats)
- [Media Type formats](#media-type-formats)
- [Request error handling](#request-error-handling)
- [GraphQL API queries](#graphql-api-queries)
- [Schema previews](#schema-previews)
Expand Down Expand Up @@ -515,11 +515,9 @@ const issues = await octokit.paginate(octokit.rest.issues.listForRepo, {
});
```

#### Media Type previews and formats
#### Media Type formats

**Note**: The concept of _preview headers_ has been deprecated from REST API endpoints hosted via `api.github.com` but it still exists in GHES (GitHub Enterprise Server) version 3.2 and below. Instead of using _preview headers_ going forward, new features are now being tested using beta previews that users will have to opt-in to.

Media type previews and formats can be set using `mediaType: { format, previews }` on every request. Required API previews are set automatically on the respective REST API endpoint methods.
Media type formats can be set using `mediaType: { format }` on every request.

Example: retrieve the raw content of a `package.json` file

Expand All @@ -535,20 +533,7 @@ const { data } = await octokit.rest.repos.getContent({
console.log("package name: %s", JSON.parse(data).name);
```

Example: retrieve a repository with topics

```js
const { data } = await octokit.rest.repos.getContent({
mediaType: {
previews: ["mercy"],
},
owner: "octocat",
repo: "hello-world",
});
console.log("topics on octocat/hello-world: %j", data.topics);
```

Learn more about [Media type formats](https://docs.github.com/en/rest/overview/media-types) and [previews](https://docs.github.com/en/[email protected]/rest/overview/api-previews) used on GitHub Enterprise Server.
Learn more about [Media type formats](https://docs.github.com/en/rest/overview/media-types).

#### Request error handling

Expand Down
18 changes: 9 additions & 9 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"@octokit/oauth-app": "^4.2.1",
"@octokit/plugin-paginate-rest": "^6.1.0",
"@octokit/plugin-rest-endpoint-methods": "^7.1.1",
"@octokit/plugin-retry": "^4.1.3",
"@octokit/plugin-retry": "^5.0.0",
"@octokit/plugin-throttling": "^5.2.2",
"@octokit/types": "^9.2.2",
"@octokit/request-error": "^v3.0.3"
Expand Down Expand Up @@ -105,6 +105,6 @@
]
},
"engines": {
"node": ">= 14"
"node": ">= 18"
}
}
2 changes: 1 addition & 1 deletion scripts/build.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function main() {
outdir: "pkg/dist-node",
bundle: true,
platform: "node",
target: "node14",
target: "node18",
format: "cjs",
...sharedOptions,
}),
Expand Down