octokit / core.js Goto Github PK
View Code? Open in Web Editor NEWExtendable client for GitHub's REST & GraphQL APIs
License: MIT License
Extendable client for GitHub's REST & GraphQL APIs
License: MIT License
1.18.2
to 1.19.0
.This version is covered by your current version range and after updating it in your project the build failed.
prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
semantic-release cannot push the version tag to the branch master
on the remote Git repository with URL https://x-access-token:[secure]@github.com/octokit/core.js
.
This can be caused by:
Good luck with your project ✨
Your semantic-release bot 📦🚀
8.2.1
to 8.3.0
.This version is covered by your current version range and after updating it in your project the build failed.
fetch-mock is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 22 commits.
6290ca4
Merge pull request #491 from wheresrhys/matcher-object
e7e6503
reorg
a613d8f
update types
110e001
improve exaples
a2f75f6
better documentation of complex matcher patterns
84c95a4
documentation update
3b239cc
Merge pull request #492 from wheresrhys/refactor-for-obj-matcher
125a178
tidy
3294162
fixed all tests
815eb1b
begininng to refactor tests
a6a3c80
fix test ad lint
befeef4
remove logs
fbadda5
converted most behaviour to separate url from other matchers
7680d9e
tests for a matcher object
96a76f2
Update resetHistory.md
There are 22 commits in total.
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Bug
No type information is added to an Octokit instance when using an array of plugins where one of the plugins return value is set to void
or an empty object {}
.
Example
import { Octokit } from '@octokit/core'
declare function requestLog(octokit: Octokit): void;
declare function paginateRest(octokit: Octokit): { paginate: ...};
declare function queueWorker(octokit: Octokit): { add: ...};
// TypeScript is able to add methods provided by `paginateRest` and `queueWorker` plugins to the API instance for type-hinting/checking.
const API = new (Octokit.plugin(requestLog).plugin([paginateRest, queueWorker]))()
// API below is missing methods provided by `paginateRest` and `queueWorker` plugins.
const API = new (Octokit.plugin([requestLog, paginateRest, queueWorker]))()
Explanation
Because () => void
is a supertype of any plugin that returns an object, TypeScript will widen/simplify the type of plugins
to () => void
, resulting in a loss of type information.
Minimal repro on TS Playground.
Workarounds
To prevent a loss of type information when adding plugins to your Octokit instance: do not mix plugins that return an object filled with properties with non-object-property-filled plugins (e.g. void
or empty objects {}
) in the same .plugin()
call.
Turn this: Octokit.plugin([() => void, () => {}, paginateRest, queueWorker])
into: Octokit.plugin([() => void, () => {}]).plugin([paginateRest, queueWorker])
Solutions
We could add an overload to the This won't solve the issue because plugins returning an empty object will continue to widen the array of plugin type information to plugin
function to separate plugins returning void from plugins returning filled objects.() => {}
and I don't think TypeScript is able to separate an empty object from a filled object.
Similar to above, add an overload for No way in TypeScript to differentiate between a filled object and an empty object.void
plugins. For .plugin([])
calls that mix filled objects with empty objects, log an error to the console that returning empty objects messes up the type information and that the empty object must be placed in its own .plugin()
call.
This issue contains a list of Renovate updates and their statuses.
These updates are awaiting their schedule. Click on a checkbox to ignore the schedule.
12.12.0
to 12.12.1
.This version is covered by your current version range and after updating it in your project the build failed.
@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io
13.13.2
to 13.13.3
.This version is covered by your current version range and after updating it in your project the build failed.
@types/node is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
When purposfully attempting to instantiate a class with a bad token, i expect to be able to catch the error and handle accordingly. However this is not the case, while i do catch the error... the node error UnhandledPromiseRejectionWarning
is thrown from inside the core.js
module.
To illustrate, this is a snippet in the auth check im performing.
Worst case scenario: Set state to error and reject.
Best case scenario: Set state to ready and resolve.
this.octokit = await new Octokit({
auth: this.config.GITHUB_TOKEN,
});
this.octokit.request('/user')
.then((data) => {
this.user = data;
this.setState('ready');
resolve();
})
.catch((err) => {
this.setState('error', {
message: err.message,
data: err,
});
// Catch errors
reject(err);
});
The result is neither, the rejection is not caught. Instead node throws an the error mentioned above.
Very curious into the workarounds with this, not noticing this error on some other repos i've tracked down. Possibly a babel mis-configuration on my end? Regardless i can't be the only one looking to auth check tokens prior to making a bunch of requests hoping the tokens are valid.
What happened?
What did you expect to happen?
What the problem might be
What happened?
What did you expect to happen?
What the problem might be
What’s missing?
Why?
Alternatives you tried
The baseUrl
field exists in OctokitOptions
and provides the base URL to be used for both GraphQL and Rest.
The urls for hosted are the same api.github.com
However, in GHES, these expect different values. The documentation shows the differing formats.
https://github.acme-inc.com/api/v3
https://github.acme-inc.com/api
Ideally, I would like to
import {Core} from '@octokit/core'
const octokit = new Core({
baseUrl: "https://github.acme-inc.com/api/v3",
graphQLBaseUrl: "https://github.acme-inc.com/api"
})
// Call v3 and graphql apis
// or
import {Core} from '@octokit/core'
const MyOctokit = Core.defaults({
baseUrl: "https://github.acme-inc.com/api/v3",
graphQLBaseUrl: "https://github.acme-inc.com/api"
})
But any way to set the baseUrl for both of these via defaults
and have them correctly work on GHES would be fantastic 🙏
What’s missing?
Why?
Alternatives you tried
☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io
9.3.0
to 9.3.1
.This version is covered by your current version range and after updating it in your project the build failed.
fetch-mock is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
The new version differs by 7 commits.
d22e983
linked to cheatsheet EVERYWHERE
1d2557d
Merge pull request #524 from wheresrhys/cheatsheet
1dfc6c2
completed cheatsheet
7efa6c5
cheatsheet formatting
438c835
refined set up/teardown section of cheatsheet
6a2d449
midway through writing cheatsheet content
633cf3e
improve documentation for when to use a named matcher
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
There is an error with this repository's Renovate configuration that needs to be fixed. As a precaution, Renovate will stop PRs until it is resolved.
Location: package.json
Error type: The renovate configuration file contains some invalid settings
Message: Invalid configuration option: @pika/pack, Invalid configuration option: author, Invalid configuration option: jest, Invalid configuration option: keywords, Invalid configuration option: license, Invalid configuration option: name, Invalid configuration option: packageRules[0].@octokit/auth-token, Invalid configuration option: packageRules[0].@octokit/graphql, Invalid configuration option: packageRules[0].@octokit/request, Invalid configuration option: packageRules[0].@octokit/request-error, Invalid configuration option: packageRules[0].@octokit/types, Invalid configuration option: packageRules[0].before-after-hook, Invalid configuration option: packageRules[0].universal-user-agent, Invalid configuration option: packageRules[1].@octokit/auth, Invalid configuration option: packageRules[1].@pika/pack, Invalid configuration option: packageRules[1].@pika/plugin-build-node, Invalid configuration option: packageRules[1].@pika/plugin-build-web, Invalid configuration option: packageRules[1].@pika/plugin-ts-standard-pkg, Invalid configuration option: packageRules[1].@types/fetch-mock, Invalid configuration option: packageRules[1].@types/jest, Invalid configuration option: packageRules[1].@types/lolex, Invalid configuration option: packageRules[1].@types/node, Invalid configuration option: packageRules[1].@types/node-fetch, Invalid configuration option: packageRules[1].fetch-mock, Invalid configuration option: packageRules[1].http-proxy-agent, Invalid configuration option: packageRules[1].jest, Invalid configuration option: packageRules[1].lolex, Invalid configuration option: packageRules[1].prettier, Invalid configuration option: packageRules[1].proxy, Invalid configuration option: packageRules[1].semantic-release, Invalid configuration option: packageRules[1].semantic-release-plugin-update-version-in-files, Invalid configuration option: packageRules[1].ts-jest, Invalid configuration option: packageRules[1].typescript, Invalid configuration option: publishConfig, Invalid configuration option: release, Invalid configuration option: renovate, Invalid configuration option: scripts, Invalid configuration option: version
☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io
2.5.6
to 2.5.7
.This version is covered by your current version range and after updating it in your project the build failed.
@types/node-fetch is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Compare implimentation in e.g. https://github.com/octokit/plugin-paginate-rest.js
What’s missing?
Why?
Alternatives you tried
HI,
I`m using the @octokit/core version 3.1.2 to execute this request:
await octokit.request('GET /repos/{owner}/{repo}/vulnerability-alerts', {
owner: 'myorg',
repo: 'myrepo',
mediaType: {
previews: [
'dorian'
]
}
})
And I'm getting this error:
RequestError [HttpError]: Resource not accessible by integration
at /Users/myuser/dev/github_vor/node_modules/@octokit/request/dist-src/fetch-wrapper.js:49:31
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at sendRequestWithRetries (/Users/myuser/dev/github_vor/node_modules/@octokit/auth-app/dist-src/hook.js:56:16)
at Object.getRepoInfo (/Users/myuser/dev/github_vor/src/github/repo.js:98:7)
at Object.<anonymous> (/Users/myuser/dev/github_vor/tests/integration/github.test.js:42:20) {
status: 403,
headers: {
'access-control-allow-origin': '*',
'access-control-expose-headers': 'ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, Deprecation, Sunset',
connection: 'close',
'content-encoding': 'gzip',
'content-security-policy': "default-src 'none'",
'content-type': 'application/json; charset=utf-8',
date: 'Fri, 09 Oct 2020 21:30:59 GMT',
'referrer-policy': 'origin-when-cross-origin, strict-origin-when-cross-origin',
server: 'GitHub.com',
status: '403 Forbidden',
'strict-transport-security': 'max-age=31536000; includeSubdomains; preload',
'transfer-encoding': 'chunked',
vary: 'Accept-Encoding, Accept, X-Requested-With',
'x-content-type-options': 'nosniff',
'x-frame-options': 'deny',
'x-github-media-type': 'github.dorian-preview; format=json',
'x-github-request-id': 'DE70:16FC:3DD981:66C6C5:5F80D693',
'x-ratelimit-limit': '15000',
'x-ratelimit-remaining': '14997',
'x-ratelimit-reset': '1602282658',
'x-ratelimit-used': '3',
'x-xss-protection': '1; mode=block'
},
request: {
method: 'GET',
url: 'https://api.github.com/repos/myorg/myrepo/vulnerability-alerts',
headers: {
accept: 'application/vnd.github.dorian-preview+json',
'user-agent': 'octokit-core.js/3.1.2 Mozilla/5.0 (darwin) AppleWebKit/537.36 (KHTML, like Gecko) jsdom/16.4.0',
authorization: 'token [REDACTED]'
},
request: { hook: [Function: bound bound register] }
},
documentation_url: 'https://docs.github.com/rest/reference/repos#check-if-vulnerability-alerts-are-enabled-for-a-repository'
}
When I use the same logic on the postman interface it works just fine:
https://api.github.com/repos/myorg/myrepo/vulnerability-alerts
The difference between both requests are:
For reference, the request below works fine:
const repo = await github.app.request('GET /repos/:owner/:repo/topics', {
owner: temp[0],
repo: temp[1],
mediaType: {
previews: [
'mercy'
]
}
})
master
branch failed. 🚨I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.
You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this 💪.
Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.
Once all the errors are resolved, semantic-release will release your package the next time you push a commit to the master
branch. You can also manually restart the failed CI job that runs semantic-release.
If you are not sure how to resolve this, here is some links that can help you:
If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.
package.json
file.A package.json file at the root of your project is required to release on npm.
Please follow the npm guideline to create a valid package.json
file.
Good luck with your project ✨
Your semantic-release bot 📦🚀
see documentation at https://developer.github.com/v3/#timezones
It's already implemented
Lines 93 to 95 in 97f9642
Hello,
Is there any JSON in pulls that gives check-run-id or check-suite-id ?
Basically, I need checks status for a particular PR.
I read PR doc but couldn't find it.
Thanks in advance 🙏
Thanks to Pika.dev for providing an easy way to use this library from the browser.
I'm following this pattern
<script type="module">
import { Octokit } from "https://cdn.pika.dev/@octokit/core";
</script>
And it works.
However, I don't seem to be able to use any plugins this way. require()
doesn't exist browser-side.
import { Octokit } from 'https://cdn.pika.dev/@octokit/core'
const octokit = new Octokit({
auth: '1234',
baseUrl: 'https://mygithubenterprise.com/api/graphql',
previews: ['cloak-preview', 'mercy-preview']
}).plugin([
require('@octokit/graphql')
])
Result:
Uncaught ReferenceError: require is not defined
How can I use plugins from the browser?
What happened?
What did you expect to happen?
What the problem might be
☝️ Important announcement: Greenkeeper will be saying goodbye 👋 and passing the torch to Snyk on June 3rd, 2020! Find out how to migrate to Snyk and more at greenkeeper.io
2.0.2
to 2.0.3
.This version is covered by your current version range and after updating it in your project the build failed.
prettier is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
What’s missing?
To add javascript
as topic
Why?
When filtering Octokit repos by javascript
topic would be nice to get all the ones using JS as language
Alternatives you tried
Nothing to try
🚨 Reminder! Less than one month left to migrate your repositories over to Snyk before Greenkeeper says goodbye on June 3rd! 💜 🚚💨 💚
Find out how to migrate to Snyk at greenkeeper.io
4.3.1
to 4.4.0
.This version is covered by your current version range and after updating it in your project the build failed.
@octokit/graphql is a direct dependency of this project, and it is very likely causing it to break. If other packages depend on yours, this update is probably also breaking those in turn.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
What’s missing?
Why?
Alternatives you tried
What’s missing?
Why?
Alternatives you tried
What happened?
I am trying to run the tsc
command on my Firebase functions directory as I have written my functions in TypeScript.
Here is my package.json:
{
"name": "functions",
"scripts": {
"build": "tsc",
"config": "firebase functions:config:get > .runtimeconfig.json",
"serve": "npm run build && firebase emulators:start --only functions,hosting",
"test": "cd ../frontend && npm run generate && cd ../functions && npm run serve",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "12"
},
"main": "lib/index.js",
"dependencies": {
"@octokit/core": "^3.4.0",
"@types/js-yaml": "^4.0.0",
"firebase-admin": "^8.6.0",
"firebase-backend": "^0.1.3",
"firebase-functions": "^3.11.0",
"js-yaml": "^4.0.0",
"nuxt": "^2.15.4",
"stripe": "^8.138.0"
},
"devDependencies": {
"@types/request": "^2.48.5",
"firebase-functions-test": "^0.1.6",
"firebase-tools": "^9.6.1",
"typescript": "^3.2.2"
},
"private": true
}
I have @octokit/core as a dependency. When I run the command, I get a bunch of errors from the octokit module, including:
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:7:17 - error TS2536: Type '"parameters"' cannot be used to index type 'T'.
7 [K in keyof T["parameters"]]: T["parameters"][K];
~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:7:35 - error TS2536: Type '"parameters"' cannot be used to index type 'T'.
7 [K in keyof T["parameters"]]: T["parameters"][K];
~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:8:9 - error TS2536: Type '"parameters"' cannot be used to index type 'T'.
8 }[keyof T["parameters"]]> : {};
~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:9:94 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
9 declare type ExtractRequestBody<T> = "requestBody" extends keyof T ? "content" extends keyof T["requestBody"] ? "application/json" extends keyof T["requestBody"]["content"] ? T["requestBody"]["content"]["application/json"] : {
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:9:146 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
9 declare type ExtractRequestBody<T> = "requestBody" extends keyof T ? "content" extends keyof T["requestBody"] ? "application/json" extends keyof T["requestBody"]["content"] ? T["requestBody"]["content"]["application/json"] : {
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:9:146 - error TS2536: Type '"content"' cannot be used to index type 'T["requestBody"]'.
9 declare type ExtractRequestBody<T> = "requestBody" extends keyof T ? "content" extends keyof T["requestBody"] ? "application/json" extends keyof T["requestBody"]["content"] ? T["requestBody"]["content"]["application/json"] : {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:9:176 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
9 declare type ExtractRequestBody<T> = "requestBody" extends keyof T ? "content" extends keyof T["requestBody"] ? "application/json" extends keyof T["requestBody"]["content"] ? T["requestBody"]["content"]["application/json"] : {
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:9:176 - error TS2536: Type '"content"' cannot be used to index type 'T["requestBody"]'.
9 declare type ExtractRequestBody<T> = "requestBody" extends keyof T ? "content" extends keyof T["requestBody"] ? "application/json" extends keyof T["requestBody"]["content"] ? T["requestBody"]["content"]["application/json"] : {
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:9:176 - error TS2536: Type '"application/json"' cannot be used to index type 'T["requestBody"]["content"]'.
9 declare type ExtractRequestBody<T> = "requestBody" extends keyof T ? "content" extends keyof T["requestBody"] ? "application/json" extends keyof T["requestBody"]["content"] ? T["requestBody"]["content"]["application/json"] : {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:11:21 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
11 [K in keyof T["requestBody"]["content"]]: T["requestBody"]["content"][K];
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:11:21 - error TS2536: Type '"content"' cannot be used to index type 'T["requestBody"]'.
11 [K in keyof T["requestBody"]["content"]]: T["requestBody"]["content"][K];
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:11:51 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
11 [K in keyof T["requestBody"]["content"]]: T["requestBody"]["content"][K];
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:11:51 - error TS2536: Type '"content"' cannot be used to index type 'T["requestBody"]'.
11 [K in keyof T["requestBody"]["content"]]: T["requestBody"]["content"][K];
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:12:13 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
12 }[keyof T["requestBody"]["content"]];
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:12:13 - error TS2536: Type '"content"' cannot be used to index type 'T["requestBody"]'.
12 }[keyof T["requestBody"]["content"]];
~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:13:38 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
13 } : "application/json" extends keyof T["requestBody"] ? T["requestBody"]["application/json"] : {
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:13:57 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
13 } : "application/json" extends keyof T["requestBody"] ? T["requestBody"]["application/json"] : {
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:13:57 - error TS2536: Type '"application/json"' cannot be used to index type 'T["requestBody"]'.
13 } : "application/json" extends keyof T["requestBody"] ? T["requestBody"]["application/json"] : {
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:15:21 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
15 [K in keyof T["requestBody"]]: T["requestBody"][K];
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:15:40 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
15 [K in keyof T["requestBody"]]: T["requestBody"][K];
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:16:13 - error TS2536: Type '"requestBody"' cannot be used to index type 'T'.
16 }[keyof T["requestBody"]];
~~~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:54:79 - error TS2536: Type '"content"' cannot be used to index type 'T'.
54 declare type GetContentKeyIfPresent<T> = "content" extends keyof T ? DataType<T["content"]> : DataType<T>;
~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:58:96 - error TS2536: Type '"responses"' cannot be used to index type 'R'.
58 declare type ExtractOctokitResponse<R> = "responses" extends keyof R ? SuccessResponseDataType<R["responses"]> extends never ? RedirectResponseDataType<R["responses"]> extends never ? EmptyResponseDataType<R["responses"]> : RedirectResponseDataType<R["responses"]> : SuccessResponseDataType<R["responses"]> : unknown;
~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:58:153 - error TS2536: Type '"responses"' cannot be used to index type 'R'.
58 declare type ExtractOctokitResponse<R> = "responses" extends keyof R ? SuccessResponseDataType<R["responses"]> extends never ? RedirectResponseDataType<R["responses"]> extends never ? EmptyResponseDataType<R["responses"]> : RedirectResponseDataType<R["responses"]> : SuccessResponseDataType<R["responses"]> : unknown;
~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:58:207 - error TS2536: Type '"responses"' cannot be used to index type 'R'.
58 declare type ExtractOctokitResponse<R> = "responses" extends keyof R ? SuccessResponseDataType<R["responses"]> extends never ? RedirectResponseDataType<R["responses"]> extends never ? EmptyResponseDataType<R["responses"]> : RedirectResponseDataType<R["responses"]> : SuccessResponseDataType<R["responses"]> : unknown;
~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:58:250 - error TS2536: Type '"responses"' cannot be used to index type 'R'.
58 declare type ExtractOctokitResponse<R> = "responses" extends keyof R ? SuccessResponseDataType<R["responses"]> extends never ? RedirectResponseDataType<R["responses"]> extends never ? EmptyResponseDataType<R["responses"]> : RedirectResponseDataType<R["responses"]> : SuccessResponseDataType<R["responses"]> : unknown;
~~~~~~~~~~~~~~
node_modules/@octokit/types/dist-types/generated/Endpoints.d.ts:58:292 - error TS2536: Type '"responses"' cannot be used to index type 'R'.
58 declare type ExtractOctokitResponse<R> = "responses" extends keyof R ? SuccessResponseDataType<R["responses"]> extends never ? RedirectResponseDataType<R["responses"]> extends never ? EmptyResponseDataType<R["responses"]> : RedirectResponseDataType<R["responses"]> : SuccessResponseDataType<R["responses"]> : unknown;
What did you expect to happen?
I expected it to compile properly.
Example
// app-octokit.js
const { Octokit } = require("@octokit/core");
const { createAppAuth } = require("@octokit/auth-app");
module.exports = Octokit.defaults({
userAgent: `rename-master-branch-app/${version}`,
authStrategy: createAppAuth,
auth: {
id: process.env.APP_ID,
privateKey: process.env.APP_PRIVATE_KEY,
},
});
// index.js
const AppOctokit =require('./app-octokit.js')
const octokit = new AppOctokit({
auth: {
installationId: 123
}
})
I expect options.auth
to be set to { id, privateKey, installationId }
, but it's set to just { installationId }
instead.
Instead of deep merging, we cold support passing an option
function, which would retrieve the current options as parameter and return the new options, leaving the merging up to the user.
I'm trying to implement this https://api.github.com/user/emails , currently with postman.
However, when including my bearer token, I get a
{
"message": "Not Found",
"documentation_url": "https://docs.github.com/rest/reference/users#list-email-addresses-for-the-authenticated-user"
}
I can make a request using the same bearer token to https://api.github.com/user and get results.
What did you expect to happen?
I expected to get a result like
[
{
"email": "[email protected]",
"verified": true,
"primary": true,
"visibility": "public"
}
]
What happened?
What did you expect to happen?
What the problem might be
What happened?
I'm running this, following the create a gist section.
const octokit = new Octokit({
auth: token
});
await octokit.request('POST /gists', {
files: saveGist
});
This returns: HttpError: Bad credentials
What did you expect to happen?
This is a straight forward use case. What am I missing?
Skskxkkxmsmmx
Hi Team,
I'm trying to access github api via browser from my react web based application. I Installed npm octokit/core.
I followed this procedure https://docs.github.com/en/rest/reference/repos#download-a-repository-archive to download the zip artifact from a public repository.
The image shows the request headers which has origin null.
Error: Access to fetch at 'https://codeload.github.com/{owner}/{repo}/legacy.zip/master' (redirected from 'https://api.github.com/repos/{owner}/{repo}/zipball/master') from origin 'http://localhost:3001' has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header has a value 'https://render.githubusercontent.com' that is not equal to the supplied origin. Have the server send the header with a valid value, or, if an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
Please let me know if you require any details
Regards,
Muthu.
Blocked by octokit/octokit.js#2127
What’s missing?
THere is currently no way to define types for authentication strategy options:
new Octokit({
authStrategy: createMyAuth,
auth: myAuthOptions
})
Why?
It would be great to get the same intellisense as for the other options
Alternatives you tried
@weswigham layed out how this is possible to do in octokit/rest.js#13 (comment)
We plan to implement endpoints the same way, so we can remove the endpoint types from @octokit/types
, and instead move it to an optional library, or multiple libraries even, so that we can provide the correct types for each GitHub Enterprise Server version.
This is going to be a bigger project.
What happened?
@octokit/auth-app
introduced a new log
option, similar to Octokit's logging via octokit/auth-app.js#190. But when I pass a custom logger as options.log
to Octokit, it is not passed down to the configured authentication strategy.
Example:
const { Octokit } = require("@octokit/core")
const { createAppAuth } = require("@octokit/auth-app");
const octokit = new Octokit({
log: myCustomLogger
authStrategy: createAppAuth,
auth: {
id: 1,
privateKey: PRIVATE_KEY,
installationId: 2
}
})
octokit.request('GET /repos/octokit/core.js')
If GitHub responds with a 401
(usually due to a replication lag), @octokit/auth-app
is logging a warning:
[@octokit/auth-app] Retrying after 401 response to account for token replication delay (retry: 1, wait: 1s)
But it logs using the default console.warn
.
Test case that reproduces the problem:
https://runkit.com/gr2m/octokit-core-authstrategy-custom-logger/1.0.0
What did you expect to happen?
I expected that myCustomLogger
from the Octokit
constructor options is passed down to createAppAuth({ log })
, so that myCustomLogger.log.warn
is used to log the warning instead of console.warn
.
What the problem might be
We do pass the internal request
method as options.request
to createAppAuth(options)
by default, see
Lines 141 to 148 in 4582982
We have to do the same with the internal log
object
How to contribute
Comment below if you would like to work on this issue. Then follow the instructions in our contributing guidelines
What happened?
What did you expect to happen?
What the problem might be
What’s missing?
Why?
Alternatives you tried
What’s missing?
It would be awesome if core.js can be downloaded and used as a local JS file.
Why?
Chrome extensions Manifest V3 (MV3) has a new security restriction prohibiting linking to external scripts. Fortunately MV3 is still in a preview state, but when it's finally enforced we should be prepared for it. This is causing a headache for many extension developers who rely on third-party libraries, including Google's own GAPI.
More info here: https://developer.chrome.com/docs/extensions/mv3/intro/mv3-migration/#remotely-hosted-code
In order to use authentication strategies other than a simple token such as Basic Authentication or GitHub App authentication without significantly increasing the bundle size of @octokit/core
, I want to add support for @octokit/auth.js
.
Here is an example using @octokit/auth-app
(the GitHub App authentication strategy).
import { Octokit } from "@octokit/core";
import { createAppAuth } from "@octokit/auth-app";
const octokit = new Octokit({
auth: createAppAuth({
id: 123,
privateKey: process.env.PRIVATE_KEY
)}
})
octokit.request('/app').then(response => console.log(response.data))
What’s missing?
my branchWhy?
noneAlternatives you tried
Hi there,
I'm trying to handle the errors from Octokit but I'm not able to find docs (or better: types) for the errors that can be thrown.
As an example, this is how I hoped I'd be able to get a typed error:
try {
const octokit = new Octokit(...);
return await octokit.search.commits(...);
} catch(e) {
if(e instanceof OctokitError) {
// `e` will now be typed
}
}
But I can't find anything like OctokitError
in the types. I can add my own error type like:
type OctokitError = {
name: string;
status: number;
documentation_url: string;
errors?: Array<{
resource: string;
code: string;
field: string;
message?: string;
}>;
};
Is there a concrete contract for errors I can see somewhere to ensure above type is correct? I looked in the docs and they seem incorrect (or out of date):
See for example this error I got back from octokit.search.commits
:
Notice how there is a message
in: e.errors[i].message
where the docs only mentions e.message
.
What’s missing?
Why?
Alternatives you tried
What happened?
I'm have an error when i compiled, when i'm import the package the result is this :
Failed to compile.
./node_modules/@octokit/core/dist-web/index.js
Module not found: Can't resolve 'C:\Users\Aisak\Documents\Shelly test\test1\node_modules\react-scripts\node_modules\babel-loader\lib\index.js' in 'C:\Users\Aisak\Documents\Shelly test\test1'
i need use this api to my job.
What did you expect to happen?
What the problem might be
What happened?
What did you expect to happen?
What the problem might be
What’s missing?
Why?
Alternatives you tried
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.