@octokit/types 2.16.1 → 2.16.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-node/index.js +8 -0
- package/dist-node/index.js.map +1 -0
- package/dist-src/AuthInterface.js +0 -0
- package/dist-src/EndpointDefaults.js +0 -0
- package/dist-src/EndpointInterface.js +0 -0
- package/dist-src/EndpointOptions.js +0 -0
- package/dist-src/Fetch.js +0 -0
- package/dist-src/GetResponseTypeFromEndpointMethod.js +0 -0
- package/dist-src/OctokitResponse.js +0 -0
- package/dist-src/RequestHeaders.js +0 -0
- package/dist-src/RequestInterface.js +0 -0
- package/dist-src/RequestMethod.js +0 -0
- package/dist-src/RequestOptions.js +0 -0
- package/dist-src/RequestParameters.js +0 -0
- package/dist-src/RequestRequestOptions.js +0 -0
- package/dist-src/ResponseHeaders.js +0 -0
- package/dist-src/Route.js +0 -0
- package/dist-src/Signal.js +0 -0
- package/dist-src/StrategyInterface.js +0 -0
- package/dist-src/Url.js +0 -0
- package/dist-src/VERSION.js +1 -0
- package/dist-src/generated/Endpoints.js +0 -0
- package/dist-src/index.js +1 -0
- package/dist-types/AuthInterface.d.ts +31 -0
- package/{src/EndpointDefaults.ts → dist-types/EndpointDefaults.d.ts} +12 -13
- package/dist-types/EndpointInterface.d.ts +65 -0
- package/{src/EndpointOptions.ts → dist-types/EndpointOptions.d.ts} +3 -4
- package/{src/Fetch.ts → dist-types/Fetch.d.ts} +1 -1
- package/dist-types/GetResponseTypeFromEndpointMethod.d.ts +5 -0
- package/dist-types/OctokitResponse.d.ts +17 -0
- package/dist-types/RequestHeaders.d.ts +15 -0
- package/dist-types/RequestInterface.d.ts +34 -0
- package/dist-types/RequestMethod.d.ts +4 -0
- package/{src/RequestOptions.ts → dist-types/RequestOptions.d.ts} +6 -7
- package/dist-types/RequestParameters.d.ts +45 -0
- package/dist-types/RequestRequestOptions.d.ts +26 -0
- package/dist-types/ResponseHeaders.d.ts +20 -0
- package/{src/Route.ts → dist-types/Route.d.ts} +1 -1
- package/{src/Signal.ts → dist-types/Signal.d.ts} +1 -1
- package/dist-types/StrategyInterface.d.ts +4 -0
- package/{src/Url.ts → dist-types/Url.d.ts} +1 -1
- package/dist-types/VERSION.d.ts +1 -0
- package/dist-types/generated/Endpoints.d.ts +41416 -0
- package/{src/index.ts → dist-types/index.d.ts} +0 -0
- package/dist-web/index.js +4 -0
- package/dist-web/index.js.map +1 -0
- package/package.json +18 -57
- package/.github/ISSUE_TEMPLATE/01_help.md +0 -5
- package/.github/ISSUE_TEMPLATE/02_bug.md +0 -19
- package/.github/ISSUE_TEMPLATE/03_feature_request.md +0 -19
- package/.github/ISSUE_TEMPLATE/04_thanks.md +0 -19
- package/.github/workflows/release.yml +0 -29
- package/.github/workflows/routes-update.yml +0 -39
- package/.github/workflows/test.yml +0 -19
- package/CODE_OF_CONDUCT.md +0 -75
- package/CONTRIBUTING.md +0 -59
- package/scripts/update-endpoints/fetch-json.js +0 -65
- package/scripts/update-endpoints/generated/README.md +0 -3
- package/scripts/update-endpoints/generated/endpoints.json +0 -41962
- package/scripts/update-endpoints/templates/endpoints.ts.template +0 -49
- package/scripts/update-endpoints/typescript.js +0 -268
- package/src/AuthInterface.ts +0 -43
- package/src/EndpointInterface.ts +0 -99
- package/src/GetResponseTypeFromEndpointMethod.ts +0 -9
- package/src/OctokitResponse.ts +0 -18
- package/src/RequestHeaders.ts +0 -15
- package/src/RequestInterface.ts +0 -46
- package/src/RequestMethod.ts +0 -10
- package/src/RequestParameters.ts +0 -46
- package/src/RequestRequestOptions.ts +0 -27
- package/src/ResponseHeaders.ts +0 -21
- package/src/StrategyInterface.ts +0 -9
- package/src/VERSION.ts +0 -1
- package/src/generated/Endpoints.ts +0 -42909
- package/src/generated/README.md +0 -3
- package/test.ts +0 -90
- package/tsconfig.json +0 -10
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
// DO NOT EDIT THIS FILE
|
|
2
|
-
import { OctokitResponse } from "../OctokitResponse";
|
|
3
|
-
import { RequestHeaders } from "../RequestHeaders";
|
|
4
|
-
import { RequestRequestOptions } from "../RequestRequestOptions";
|
|
5
|
-
|
|
6
|
-
type RequiredPreview<T> = {
|
|
7
|
-
mediaType: {
|
|
8
|
-
previews: [T, ...string[]];
|
|
9
|
-
};
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
export interface Endpoints {
|
|
13
|
-
{{#each endpointsByRoute}}
|
|
14
|
-
/**
|
|
15
|
-
* @see {{documentationUrl}}
|
|
16
|
-
*/
|
|
17
|
-
"{{@key}}": {
|
|
18
|
-
parameters: {{optionsTypeName}},
|
|
19
|
-
request: {{requestOptionsTypeName}},
|
|
20
|
-
response: OctokitResponse<{{responseTypeName}}>,
|
|
21
|
-
},
|
|
22
|
-
{{/each}}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
{{#each options}}
|
|
26
|
-
type {{parameters.name}} = {
|
|
27
|
-
{{#each parameters.parameters}}
|
|
28
|
-
{{&jsdoc}}
|
|
29
|
-
{{{name this}}}: {{{type this}}}
|
|
30
|
-
{{/each}}
|
|
31
|
-
}
|
|
32
|
-
{{#requiredPreview}} & RequiredPreview<"{{this}}"> {{/requiredPreview}}
|
|
33
|
-
{{#headers}} & {{{headersType this}}} {{/headers}}
|
|
34
|
-
type {{request.name}} = {
|
|
35
|
-
method: "{{request.method}}",
|
|
36
|
-
url: "{{request.url}}",
|
|
37
|
-
headers: RequestHeaders,
|
|
38
|
-
request: RequestRequestOptions
|
|
39
|
-
}
|
|
40
|
-
{{&response}}
|
|
41
|
-
{{/each}}
|
|
42
|
-
|
|
43
|
-
{{#childParams}}
|
|
44
|
-
type {{paramTypeName}} = {
|
|
45
|
-
{{#params}}
|
|
46
|
-
{{{name this}}}: {{{type this}}}
|
|
47
|
-
{{/params}}
|
|
48
|
-
};
|
|
49
|
-
{{/childParams}}
|
|
@@ -1,268 +0,0 @@
|
|
|
1
|
-
const { readFileSync, writeFileSync } = require("fs");
|
|
2
|
-
const { resolve } = require("path");
|
|
3
|
-
|
|
4
|
-
const Handlebars = require("handlebars");
|
|
5
|
-
const set = require("lodash.set");
|
|
6
|
-
const { pascalCase } = require("pascal-case");
|
|
7
|
-
const prettier = require("prettier");
|
|
8
|
-
const { stringToJsdocComment } = require("string-to-jsdoc-comment");
|
|
9
|
-
const sortKeys = require("sort-keys");
|
|
10
|
-
const TypeWriter = require("@gimenete/type-writer");
|
|
11
|
-
|
|
12
|
-
const ENDPOINTS = require("./generated/endpoints.json");
|
|
13
|
-
const ENDPOINTS_PATH = resolve(
|
|
14
|
-
process.cwd(),
|
|
15
|
-
"src",
|
|
16
|
-
"generated",
|
|
17
|
-
"Endpoints.ts"
|
|
18
|
-
);
|
|
19
|
-
const ENDPOINTS_TEMPLATE_PATH = resolve(
|
|
20
|
-
process.cwd(),
|
|
21
|
-
"scripts",
|
|
22
|
-
"update-endpoints",
|
|
23
|
-
"templates",
|
|
24
|
-
"endpoints.ts.template"
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
Handlebars.registerHelper("name", function (parameter) {
|
|
28
|
-
let name = parameter.key;
|
|
29
|
-
|
|
30
|
-
if (/[.\[]/.test(name)) {
|
|
31
|
-
name = `"${name}"`;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (parameter.required) {
|
|
35
|
-
return name;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return `${name}?`;
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
Handlebars.registerHelper("type", function (parameter) {
|
|
42
|
-
const type = typeMap[parameter.type] || parameter.type;
|
|
43
|
-
|
|
44
|
-
if (parameter.allowNull) {
|
|
45
|
-
return `${type} | null`;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return type;
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
Handlebars.registerHelper("headersType", function (headers) {
|
|
52
|
-
const result = JSON.stringify(headers);
|
|
53
|
-
|
|
54
|
-
return `{ headers: ${result.replace(/\bnull\b/g, "string")}}`;
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
const template = Handlebars.compile(
|
|
58
|
-
readFileSync(ENDPOINTS_TEMPLATE_PATH, "utf8")
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
const endpointsByRoute = {};
|
|
62
|
-
|
|
63
|
-
const typeMap = {
|
|
64
|
-
integer: "number",
|
|
65
|
-
"integer[]": "number[]",
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
for (const endpoint of ENDPOINTS) {
|
|
69
|
-
if (endpoint.renamed) continue;
|
|
70
|
-
|
|
71
|
-
const url = endpointToNormalizedUrl(endpoint);
|
|
72
|
-
const route = `${endpoint.method} ${url}`;
|
|
73
|
-
|
|
74
|
-
endpointsByRoute[route] = {
|
|
75
|
-
documentationUrl: endpoint.documentationUrl,
|
|
76
|
-
optionsTypeName: pascalCase(`${endpoint.scope} ${endpoint.id} Endpoint`),
|
|
77
|
-
requestOptionsTypeName: pascalCase(
|
|
78
|
-
`${endpoint.scope} ${endpoint.id} RequestOptions`
|
|
79
|
-
),
|
|
80
|
-
responseTypeName: endpointToResponseTypeName(endpoint),
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const options = [];
|
|
85
|
-
const childParams = {};
|
|
86
|
-
|
|
87
|
-
for (const endpoint of ENDPOINTS) {
|
|
88
|
-
if (endpoint.renamed) continue;
|
|
89
|
-
|
|
90
|
-
const typeWriter = new TypeWriter();
|
|
91
|
-
const { method, parameters } = endpoint;
|
|
92
|
-
const url = endpointToNormalizedUrl(endpoint);
|
|
93
|
-
|
|
94
|
-
const optionsTypeName = pascalCase(
|
|
95
|
-
`${endpoint.scope} ${endpoint.id} Endpoint`
|
|
96
|
-
);
|
|
97
|
-
const requestOptionsTypeName = pascalCase(
|
|
98
|
-
`${endpoint.scope} ${endpoint.id} RequestOptions`
|
|
99
|
-
);
|
|
100
|
-
|
|
101
|
-
const responses =
|
|
102
|
-
endpoint.responses.length && endpoint.responses[0].examples
|
|
103
|
-
? endpoint.responses[0].examples.map((example) =>
|
|
104
|
-
JSON.parse(example.data)
|
|
105
|
-
)
|
|
106
|
-
: undefined;
|
|
107
|
-
if (responses) {
|
|
108
|
-
typeWriter.add(responses, {
|
|
109
|
-
rootTypeName: endpointToResponseTypeName(endpoint),
|
|
110
|
-
});
|
|
111
|
-
|
|
112
|
-
typeWriter.generate("typescript");
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const headers = endpoint.headers.reduce((result, header) => {
|
|
116
|
-
// accept header is set via mediatype
|
|
117
|
-
if (header.name === "accept") {
|
|
118
|
-
return result;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
// content-length is set by fetch
|
|
122
|
-
if (header.name === "content-length") {
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// // ignore headers with null values. THese can be required headers that must be set by the user,
|
|
127
|
-
// // such as `headers['content-type']` for `octokit.repos.uploadReleaseAsset()`
|
|
128
|
-
// if (header.value === null) {
|
|
129
|
-
// return result;
|
|
130
|
-
// }
|
|
131
|
-
|
|
132
|
-
if (!result) {
|
|
133
|
-
result = {};
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
result[header.name] = header.value;
|
|
137
|
-
return result;
|
|
138
|
-
}, undefined);
|
|
139
|
-
|
|
140
|
-
const extraParameters = [];
|
|
141
|
-
// baseUrl must be set for "Upload a release asset"
|
|
142
|
-
if (optionsTypeName === "ReposUploadReleaseAssetEndpoint") {
|
|
143
|
-
extraParameters.push({
|
|
144
|
-
name: "baseUrl",
|
|
145
|
-
type: "string",
|
|
146
|
-
description:
|
|
147
|
-
"For https://api.github.com, set `baseUrl` to `https://uploads.github.com`. For GitHub Enterprise Server, set it to `<your hostname>/api/uploads`",
|
|
148
|
-
required: true,
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
options.push({
|
|
153
|
-
requiredPreview: endpoint.previews.length
|
|
154
|
-
? endpoint.previews[0].name
|
|
155
|
-
: null,
|
|
156
|
-
headers,
|
|
157
|
-
parameters: {
|
|
158
|
-
name: optionsTypeName,
|
|
159
|
-
parameters: parameters
|
|
160
|
-
.concat(extraParameters)
|
|
161
|
-
.map(parameterize)
|
|
162
|
-
// handle "object" & "object[]" types
|
|
163
|
-
.map((parameter) => {
|
|
164
|
-
if (parameter.deprecated) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const namespacedParamsName = pascalCase(
|
|
169
|
-
`${endpoint.scope}.${endpoint.id}.Params`
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
if (parameter.type === "object" || parameter.type === "object[]") {
|
|
173
|
-
const childParamsName = pascalCase(
|
|
174
|
-
`${namespacedParamsName}.${parameter.key}`
|
|
175
|
-
);
|
|
176
|
-
|
|
177
|
-
parameter.type = parameter.type.replace("object", childParamsName);
|
|
178
|
-
|
|
179
|
-
if (!childParams[childParamsName]) {
|
|
180
|
-
childParams[childParamsName] = {};
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
if (!/\./.test(parameter.key)) {
|
|
185
|
-
return parameter;
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
const childKey = parameter.key.split(".").pop();
|
|
189
|
-
const parentKey = parameter.key.replace(/\.[^.]+$/, "");
|
|
190
|
-
|
|
191
|
-
parameter.key = childKey;
|
|
192
|
-
|
|
193
|
-
const childParamsName = pascalCase(
|
|
194
|
-
`${namespacedParamsName}.${parentKey}`
|
|
195
|
-
);
|
|
196
|
-
set(childParams, `${childParamsName}.${childKey}`, parameter);
|
|
197
|
-
})
|
|
198
|
-
.filter(Boolean),
|
|
199
|
-
},
|
|
200
|
-
request: {
|
|
201
|
-
name: requestOptionsTypeName,
|
|
202
|
-
method,
|
|
203
|
-
url,
|
|
204
|
-
},
|
|
205
|
-
response: responses ? typeWriter.generate("typescript") : "",
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
process.stdout.write(".");
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
console.log("\ndone.");
|
|
212
|
-
|
|
213
|
-
const result = template({
|
|
214
|
-
endpointsByRoute: sortKeys(endpointsByRoute, { deep: true }),
|
|
215
|
-
options,
|
|
216
|
-
childParams: Object.keys(childParams).map((key) => {
|
|
217
|
-
return {
|
|
218
|
-
paramTypeName: key,
|
|
219
|
-
params: Object.values(childParams[key]),
|
|
220
|
-
};
|
|
221
|
-
}),
|
|
222
|
-
});
|
|
223
|
-
|
|
224
|
-
writeFileSync(
|
|
225
|
-
ENDPOINTS_PATH,
|
|
226
|
-
prettier.format(result, { parser: "typescript" })
|
|
227
|
-
);
|
|
228
|
-
console.log(`${ENDPOINTS_PATH} updated.`);
|
|
229
|
-
|
|
230
|
-
function parameterize(parameter) {
|
|
231
|
-
const key = parameter.name;
|
|
232
|
-
const type = typeMap[parameter.type] || parameter.type;
|
|
233
|
-
const enums = parameter.enum
|
|
234
|
-
? parameter.enum.map(JSON.stringify).join("|")
|
|
235
|
-
: null;
|
|
236
|
-
|
|
237
|
-
return {
|
|
238
|
-
name: pascalCase(key),
|
|
239
|
-
key: key,
|
|
240
|
-
required: parameter.required,
|
|
241
|
-
type: enums || type,
|
|
242
|
-
alias: parameter.alias,
|
|
243
|
-
deprecated: parameter.deprecated,
|
|
244
|
-
allowNull: parameter.allowNull,
|
|
245
|
-
jsdoc: stringToJsdocComment(parameter.description),
|
|
246
|
-
};
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function endpointToResponseTypeName(endpoint) {
|
|
250
|
-
const hasResponses =
|
|
251
|
-
endpoint.responses.length && endpoint.responses[0].examples;
|
|
252
|
-
|
|
253
|
-
if (hasResponses) {
|
|
254
|
-
return pascalCase(`${endpoint.scope} ${endpoint.id} ResponseData`);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
return "any";
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function endpointToNormalizedUrl(endpoint) {
|
|
261
|
-
return (
|
|
262
|
-
endpoint.url
|
|
263
|
-
// replace {param} with :param
|
|
264
|
-
.replace(/\{([^?][^}]+)}/g, ":$1")
|
|
265
|
-
// stecial case for "Upload a release asset": remove ":origin" prefix
|
|
266
|
-
.replace(/^:origin/, "")
|
|
267
|
-
);
|
|
268
|
-
}
|
package/src/AuthInterface.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { EndpointOptions } from "./EndpointOptions";
|
|
2
|
-
import { OctokitResponse } from "./OctokitResponse";
|
|
3
|
-
import { RequestInterface } from "./RequestInterface";
|
|
4
|
-
import { RequestParameters } from "./RequestParameters";
|
|
5
|
-
import { Route } from "./Route";
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Interface to implement complex authentication strategies for Octokit.
|
|
9
|
-
* An object Implementing the AuthInterface can directly be passed as the
|
|
10
|
-
* `auth` option in the Octokit constructor.
|
|
11
|
-
*
|
|
12
|
-
* For the official implementations of the most common authentication
|
|
13
|
-
* strategies, see https://github.com/octokit/auth.js
|
|
14
|
-
*/
|
|
15
|
-
export interface AuthInterface<
|
|
16
|
-
AuthOptions extends any[],
|
|
17
|
-
Authentication extends any
|
|
18
|
-
> {
|
|
19
|
-
(...args: AuthOptions): Promise<Authentication>;
|
|
20
|
-
|
|
21
|
-
hook: {
|
|
22
|
-
/**
|
|
23
|
-
* Sends a request using the passed `request` instance
|
|
24
|
-
*
|
|
25
|
-
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
26
|
-
*/
|
|
27
|
-
<T = any>(request: RequestInterface, options: EndpointOptions): Promise<
|
|
28
|
-
OctokitResponse<T>
|
|
29
|
-
>;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Sends a request using the passed `request` instance
|
|
33
|
-
*
|
|
34
|
-
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
|
|
35
|
-
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
36
|
-
*/
|
|
37
|
-
<T = any>(
|
|
38
|
-
request: RequestInterface,
|
|
39
|
-
route: Route,
|
|
40
|
-
parameters?: RequestParameters
|
|
41
|
-
): Promise<OctokitResponse<T>>;
|
|
42
|
-
};
|
|
43
|
-
}
|
package/src/EndpointInterface.ts
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { EndpointDefaults } from "./EndpointDefaults";
|
|
2
|
-
import { RequestOptions } from "./RequestOptions";
|
|
3
|
-
import { RequestParameters } from "./RequestParameters";
|
|
4
|
-
import { Route } from "./Route";
|
|
5
|
-
|
|
6
|
-
import { Endpoints } from "./generated/Endpoints";
|
|
7
|
-
|
|
8
|
-
export interface EndpointInterface<D extends object = object> {
|
|
9
|
-
/**
|
|
10
|
-
* Transforms a GitHub REST API endpoint into generic request options
|
|
11
|
-
*
|
|
12
|
-
* @param {object} endpoint Must set `url` unless it's set defaults. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
13
|
-
*/
|
|
14
|
-
<O extends RequestParameters = RequestParameters>(
|
|
15
|
-
options: O & { method?: string } & ("url" extends keyof D
|
|
16
|
-
? { url?: string }
|
|
17
|
-
: { url: string })
|
|
18
|
-
): RequestOptions & Pick<D & O, keyof RequestOptions>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Transforms a GitHub REST API endpoint into generic request options
|
|
22
|
-
*
|
|
23
|
-
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
|
|
24
|
-
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
25
|
-
*/
|
|
26
|
-
<
|
|
27
|
-
R extends Route,
|
|
28
|
-
P extends RequestParameters = R extends keyof Endpoints
|
|
29
|
-
? Endpoints[R]["parameters"] & RequestParameters
|
|
30
|
-
: RequestParameters
|
|
31
|
-
>(
|
|
32
|
-
route: keyof Endpoints | R,
|
|
33
|
-
parameters?: P
|
|
34
|
-
): (R extends keyof Endpoints ? Endpoints[R]["request"] : RequestOptions) &
|
|
35
|
-
Pick<P, keyof RequestOptions>;
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Object with current default route and parameters
|
|
39
|
-
*/
|
|
40
|
-
DEFAULTS: D & EndpointDefaults;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Returns a new `endpoint` interface with new defaults
|
|
44
|
-
*/
|
|
45
|
-
defaults: <O extends RequestParameters = RequestParameters>(
|
|
46
|
-
newDefaults: O
|
|
47
|
-
) => EndpointInterface<D & O>;
|
|
48
|
-
|
|
49
|
-
merge: {
|
|
50
|
-
/**
|
|
51
|
-
* Merges current endpoint defaults with passed route and parameters,
|
|
52
|
-
* without transforming them into request options.
|
|
53
|
-
*
|
|
54
|
-
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
|
|
55
|
-
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
56
|
-
*
|
|
57
|
-
*/
|
|
58
|
-
<
|
|
59
|
-
R extends Route,
|
|
60
|
-
P extends RequestParameters = R extends keyof Endpoints
|
|
61
|
-
? Endpoints[R]["parameters"] & RequestParameters
|
|
62
|
-
: RequestParameters
|
|
63
|
-
>(
|
|
64
|
-
route: keyof Endpoints | R,
|
|
65
|
-
parameters?: P
|
|
66
|
-
): D &
|
|
67
|
-
(R extends keyof Endpoints
|
|
68
|
-
? Endpoints[R]["request"] & Endpoints[R]["parameters"]
|
|
69
|
-
: EndpointDefaults) &
|
|
70
|
-
P;
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Merges current endpoint defaults with passed route and parameters,
|
|
74
|
-
* without transforming them into request options.
|
|
75
|
-
*
|
|
76
|
-
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
77
|
-
*/
|
|
78
|
-
<P extends RequestParameters = RequestParameters>(
|
|
79
|
-
options: P
|
|
80
|
-
): EndpointDefaults & D & P;
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Returns current default options.
|
|
84
|
-
*
|
|
85
|
-
* @deprecated use endpoint.DEFAULTS instead
|
|
86
|
-
*/
|
|
87
|
-
(): D & EndpointDefaults;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
/**
|
|
91
|
-
* Stateless method to turn endpoint options into request options.
|
|
92
|
-
* Calling `endpoint(options)` is the same as calling `endpoint.parse(endpoint.merge(options))`.
|
|
93
|
-
*
|
|
94
|
-
* @param {object} options `method`, `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
95
|
-
*/
|
|
96
|
-
parse: <O extends EndpointDefaults = EndpointDefaults>(
|
|
97
|
-
options: O
|
|
98
|
-
) => RequestOptions & Pick<O, keyof RequestOptions>;
|
|
99
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
type Unwrap<T> = T extends Promise<infer U> ? U : T;
|
|
2
|
-
type AnyFunction = (...args: any[]) => any;
|
|
3
|
-
|
|
4
|
-
export type GetResponseTypeFromEndpointMethod<T extends AnyFunction> = Unwrap<
|
|
5
|
-
ReturnType<T>
|
|
6
|
-
>;
|
|
7
|
-
export type GetResponseDataTypeFromEndpointMethod<
|
|
8
|
-
T extends AnyFunction
|
|
9
|
-
> = Unwrap<ReturnType<T>>["data"];
|
package/src/OctokitResponse.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ResponseHeaders } from "./ResponseHeaders";
|
|
2
|
-
import { Url } from "./Url";
|
|
3
|
-
|
|
4
|
-
export type OctokitResponse<T> = {
|
|
5
|
-
headers: ResponseHeaders;
|
|
6
|
-
/**
|
|
7
|
-
* http response code
|
|
8
|
-
*/
|
|
9
|
-
status: number;
|
|
10
|
-
/**
|
|
11
|
-
* URL of response after all redirects
|
|
12
|
-
*/
|
|
13
|
-
url: Url;
|
|
14
|
-
/**
|
|
15
|
-
* This is the data you would see in https://developer.Octokit.com/v3/
|
|
16
|
-
*/
|
|
17
|
-
data: T;
|
|
18
|
-
};
|
package/src/RequestHeaders.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
export type RequestHeaders = {
|
|
2
|
-
/**
|
|
3
|
-
* Avoid setting `headers.accept`, use `mediaType.{format|previews}` option instead.
|
|
4
|
-
*/
|
|
5
|
-
accept?: string;
|
|
6
|
-
/**
|
|
7
|
-
* Use `authorization` to send authenticated request, remember `token ` / `bearer ` prefixes. Example: `token 1234567890abcdef1234567890abcdef12345678`
|
|
8
|
-
*/
|
|
9
|
-
authorization?: string;
|
|
10
|
-
/**
|
|
11
|
-
* `user-agent` is set do a default and can be overwritten as needed.
|
|
12
|
-
*/
|
|
13
|
-
"user-agent"?: string;
|
|
14
|
-
[header: string]: string | number | undefined;
|
|
15
|
-
};
|
package/src/RequestInterface.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { EndpointInterface } from "./EndpointInterface";
|
|
2
|
-
import { OctokitResponse } from "./OctokitResponse";
|
|
3
|
-
import { RequestParameters } from "./RequestParameters";
|
|
4
|
-
import { Route } from "./Route";
|
|
5
|
-
|
|
6
|
-
import { Endpoints } from "./generated/Endpoints";
|
|
7
|
-
|
|
8
|
-
export interface RequestInterface<D extends object = object> {
|
|
9
|
-
/**
|
|
10
|
-
* Sends a request based on endpoint options
|
|
11
|
-
*
|
|
12
|
-
* @param {object} endpoint Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
13
|
-
*/
|
|
14
|
-
<T = any, O extends RequestParameters = RequestParameters>(
|
|
15
|
-
options: O & { method?: string } & ("url" extends keyof D
|
|
16
|
-
? { url?: string }
|
|
17
|
-
: { url: string })
|
|
18
|
-
): Promise<OctokitResponse<T>>;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Sends a request based on endpoint options
|
|
22
|
-
*
|
|
23
|
-
* @param {string} route Request method + URL. Example: `'GET /orgs/:org'`
|
|
24
|
-
* @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.{format|previews}`, `request`, or `baseUrl`.
|
|
25
|
-
*/
|
|
26
|
-
<R extends Route>(
|
|
27
|
-
route: keyof Endpoints | R,
|
|
28
|
-
options?: R extends keyof Endpoints
|
|
29
|
-
? Endpoints[R]["parameters"] & RequestParameters
|
|
30
|
-
: RequestParameters
|
|
31
|
-
): R extends keyof Endpoints
|
|
32
|
-
? Promise<Endpoints[R]["response"]>
|
|
33
|
-
: Promise<OctokitResponse<any>>;
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Returns a new `request` with updated route and parameters
|
|
37
|
-
*/
|
|
38
|
-
defaults: <O extends RequestParameters = RequestParameters>(
|
|
39
|
-
newDefaults: O
|
|
40
|
-
) => RequestInterface<D & O>;
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* Octokit endpoint API, see {@link https://github.com/octokit/endpoint.js|@octokit/endpoint}
|
|
44
|
-
*/
|
|
45
|
-
endpoint: EndpointInterface<D>;
|
|
46
|
-
}
|
package/src/RequestMethod.ts
DELETED
package/src/RequestParameters.ts
DELETED
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { RequestRequestOptions } from "./RequestRequestOptions";
|
|
2
|
-
import { RequestHeaders } from "./RequestHeaders";
|
|
3
|
-
import { Url } from "./Url";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Parameters that can be passed into `request(route, parameters)` or `endpoint(route, parameters)` methods
|
|
7
|
-
*/
|
|
8
|
-
export type RequestParameters = {
|
|
9
|
-
/**
|
|
10
|
-
* Base URL to be used when a relative URL is passed, such as `/orgs/:org`.
|
|
11
|
-
* If `baseUrl` is `https://enterprise.acme-inc.com/api/v3`, then the request
|
|
12
|
-
* will be sent to `https://enterprise.acme-inc.com/api/v3/orgs/:org`.
|
|
13
|
-
*/
|
|
14
|
-
baseUrl?: Url;
|
|
15
|
-
/**
|
|
16
|
-
* HTTP headers. Use lowercase keys.
|
|
17
|
-
*/
|
|
18
|
-
headers?: RequestHeaders;
|
|
19
|
-
/**
|
|
20
|
-
* Media type options, see {@link https://developer.github.com/v3/media/|GitHub Developer Guide}
|
|
21
|
-
*/
|
|
22
|
-
mediaType?: {
|
|
23
|
-
/**
|
|
24
|
-
* `json` by default. Can be `raw`, `text`, `html`, `full`, `diff`, `patch`, `sha`, `base64`. Depending on endpoint
|
|
25
|
-
*/
|
|
26
|
-
format?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Custom media type names of {@link https://developer.github.com/v3/media/|API Previews} without the `-preview` suffix.
|
|
29
|
-
* Example for single preview: `['squirrel-girl']`.
|
|
30
|
-
* Example for multiple previews: `['squirrel-girl', 'mister-fantastic']`.
|
|
31
|
-
*/
|
|
32
|
-
previews?: string[];
|
|
33
|
-
};
|
|
34
|
-
/**
|
|
35
|
-
* Pass custom meta information for the request. The `request` object will be returned as is.
|
|
36
|
-
*/
|
|
37
|
-
request?: RequestRequestOptions;
|
|
38
|
-
/**
|
|
39
|
-
* Any additional parameter will be passed as follows
|
|
40
|
-
* 1. URL parameter if `':parameter'` or `{parameter}` is part of `url`
|
|
41
|
-
* 2. Query parameter if `method` is `'GET'` or `'HEAD'`
|
|
42
|
-
* 3. Request body if `parameter` is `'data'`
|
|
43
|
-
* 4. JSON in the request body in the form of `body[parameter]` unless `parameter` key is `'data'`
|
|
44
|
-
*/
|
|
45
|
-
[parameter: string]: unknown;
|
|
46
|
-
};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { Agent } from "http";
|
|
2
|
-
import { Fetch } from "./Fetch";
|
|
3
|
-
import { Signal } from "./Signal";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Octokit-specific request options which are ignored for the actual request, but can be used by Octokit or plugins to manipulate how the request is sent or how a response is handled
|
|
7
|
-
*/
|
|
8
|
-
export type RequestRequestOptions = {
|
|
9
|
-
/**
|
|
10
|
-
* Node only. Useful for custom proxy, certificate, or dns lookup.
|
|
11
|
-
*/
|
|
12
|
-
agent?: Agent;
|
|
13
|
-
/**
|
|
14
|
-
* Custom replacement for built-in fetch method. Useful for testing or request hooks.
|
|
15
|
-
*/
|
|
16
|
-
fetch?: Fetch;
|
|
17
|
-
/**
|
|
18
|
-
* Use an `AbortController` instance to cancel a request. In node you can only cancel streamed requests.
|
|
19
|
-
*/
|
|
20
|
-
signal?: Signal;
|
|
21
|
-
/**
|
|
22
|
-
* Node only. Request/response timeout in ms, it resets on redirect. 0 to disable (OS limit applies). `options.request.signal` is recommended instead.
|
|
23
|
-
*/
|
|
24
|
-
timeout?: number;
|
|
25
|
-
|
|
26
|
-
[option: string]: any;
|
|
27
|
-
};
|
package/src/ResponseHeaders.ts
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export type ResponseHeaders = {
|
|
2
|
-
"cache-control"?: string;
|
|
3
|
-
"content-length"?: number;
|
|
4
|
-
"content-type"?: string;
|
|
5
|
-
date?: string;
|
|
6
|
-
etag?: string;
|
|
7
|
-
"last-modified"?: string;
|
|
8
|
-
link?: string;
|
|
9
|
-
location?: string;
|
|
10
|
-
server?: string;
|
|
11
|
-
status?: string;
|
|
12
|
-
vary?: string;
|
|
13
|
-
"x-github-mediatype"?: string;
|
|
14
|
-
"x-github-request-id"?: string;
|
|
15
|
-
"x-oauth-scopes"?: string;
|
|
16
|
-
"x-ratelimit-limit"?: string;
|
|
17
|
-
"x-ratelimit-remaining"?: string;
|
|
18
|
-
"x-ratelimit-reset"?: string;
|
|
19
|
-
|
|
20
|
-
[header: string]: string | number | undefined;
|
|
21
|
-
};
|
package/src/StrategyInterface.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AuthInterface } from "./AuthInterface";
|
|
2
|
-
|
|
3
|
-
export interface StrategyInterface<
|
|
4
|
-
StrategyOptions extends any[],
|
|
5
|
-
AuthOptions extends any[],
|
|
6
|
-
Authentication extends object
|
|
7
|
-
> {
|
|
8
|
-
(...args: StrategyOptions): AuthInterface<AuthOptions, Authentication>;
|
|
9
|
-
}
|
package/src/VERSION.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const VERSION = "0.0.0-development";
|