@depup/octokit__plugin-paginate-rest 14.0.0-depup.0
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/LICENSE +7 -0
- package/README.md +25 -0
- package/changes.json +5 -0
- package/dist-bundle/index.js +415 -0
- package/dist-bundle/index.js.map +7 -0
- package/dist-src/compose-paginate.js +8 -0
- package/dist-src/generated/paginating-endpoints.js +276 -0
- package/dist-src/index.js +22 -0
- package/dist-src/iterator.js +46 -0
- package/dist-src/normalize-paginated-list-response.js +33 -0
- package/dist-src/paginate.js +34 -0
- package/dist-src/paginating-endpoints.js +15 -0
- package/dist-src/version.js +4 -0
- package/dist-types/compose-paginate.d.ts +2 -0
- package/dist-types/generated/paginating-endpoints.d.ts +2039 -0
- package/dist-types/index.d.ts +15 -0
- package/dist-types/iterator.d.ts +3 -0
- package/dist-types/normalize-paginated-list-response.d.ts +18 -0
- package/dist-types/paginate.d.ts +3 -0
- package/dist-types/paginating-endpoints.d.ts +3 -0
- package/dist-types/types.d.ts +248 -0
- package/dist-types/version.d.ts +1 -0
- package/package.json +69 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
const paginatingEndpoints = [
|
|
2
|
+
"GET /advisories",
|
|
3
|
+
"GET /app/hook/deliveries",
|
|
4
|
+
"GET /app/installation-requests",
|
|
5
|
+
"GET /app/installations",
|
|
6
|
+
"GET /assignments/{assignment_id}/accepted_assignments",
|
|
7
|
+
"GET /classrooms",
|
|
8
|
+
"GET /classrooms/{classroom_id}/assignments",
|
|
9
|
+
"GET /enterprises/{enterprise}/code-security/configurations",
|
|
10
|
+
"GET /enterprises/{enterprise}/code-security/configurations/{configuration_id}/repositories",
|
|
11
|
+
"GET /enterprises/{enterprise}/dependabot/alerts",
|
|
12
|
+
"GET /enterprises/{enterprise}/teams",
|
|
13
|
+
"GET /enterprises/{enterprise}/teams/{enterprise-team}/memberships",
|
|
14
|
+
"GET /enterprises/{enterprise}/teams/{enterprise-team}/organizations",
|
|
15
|
+
"GET /events",
|
|
16
|
+
"GET /gists",
|
|
17
|
+
"GET /gists/public",
|
|
18
|
+
"GET /gists/starred",
|
|
19
|
+
"GET /gists/{gist_id}/comments",
|
|
20
|
+
"GET /gists/{gist_id}/commits",
|
|
21
|
+
"GET /gists/{gist_id}/forks",
|
|
22
|
+
"GET /installation/repositories",
|
|
23
|
+
"GET /issues",
|
|
24
|
+
"GET /licenses",
|
|
25
|
+
"GET /marketplace_listing/plans",
|
|
26
|
+
"GET /marketplace_listing/plans/{plan_id}/accounts",
|
|
27
|
+
"GET /marketplace_listing/stubbed/plans",
|
|
28
|
+
"GET /marketplace_listing/stubbed/plans/{plan_id}/accounts",
|
|
29
|
+
"GET /networks/{owner}/{repo}/events",
|
|
30
|
+
"GET /notifications",
|
|
31
|
+
"GET /organizations",
|
|
32
|
+
"GET /organizations/{org}/dependabot/repository-access",
|
|
33
|
+
"GET /orgs/{org}/actions/cache/usage-by-repository",
|
|
34
|
+
"GET /orgs/{org}/actions/hosted-runners",
|
|
35
|
+
"GET /orgs/{org}/actions/permissions/repositories",
|
|
36
|
+
"GET /orgs/{org}/actions/permissions/self-hosted-runners/repositories",
|
|
37
|
+
"GET /orgs/{org}/actions/runner-groups",
|
|
38
|
+
"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/hosted-runners",
|
|
39
|
+
"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/repositories",
|
|
40
|
+
"GET /orgs/{org}/actions/runner-groups/{runner_group_id}/runners",
|
|
41
|
+
"GET /orgs/{org}/actions/runners",
|
|
42
|
+
"GET /orgs/{org}/actions/secrets",
|
|
43
|
+
"GET /orgs/{org}/actions/secrets/{secret_name}/repositories",
|
|
44
|
+
"GET /orgs/{org}/actions/variables",
|
|
45
|
+
"GET /orgs/{org}/actions/variables/{name}/repositories",
|
|
46
|
+
"GET /orgs/{org}/attestations/repositories",
|
|
47
|
+
"GET /orgs/{org}/attestations/{subject_digest}",
|
|
48
|
+
"GET /orgs/{org}/blocks",
|
|
49
|
+
"GET /orgs/{org}/campaigns",
|
|
50
|
+
"GET /orgs/{org}/code-scanning/alerts",
|
|
51
|
+
"GET /orgs/{org}/code-security/configurations",
|
|
52
|
+
"GET /orgs/{org}/code-security/configurations/{configuration_id}/repositories",
|
|
53
|
+
"GET /orgs/{org}/codespaces",
|
|
54
|
+
"GET /orgs/{org}/codespaces/secrets",
|
|
55
|
+
"GET /orgs/{org}/codespaces/secrets/{secret_name}/repositories",
|
|
56
|
+
"GET /orgs/{org}/copilot/billing/seats",
|
|
57
|
+
"GET /orgs/{org}/copilot/metrics",
|
|
58
|
+
"GET /orgs/{org}/dependabot/alerts",
|
|
59
|
+
"GET /orgs/{org}/dependabot/secrets",
|
|
60
|
+
"GET /orgs/{org}/dependabot/secrets/{secret_name}/repositories",
|
|
61
|
+
"GET /orgs/{org}/events",
|
|
62
|
+
"GET /orgs/{org}/failed_invitations",
|
|
63
|
+
"GET /orgs/{org}/hooks",
|
|
64
|
+
"GET /orgs/{org}/hooks/{hook_id}/deliveries",
|
|
65
|
+
"GET /orgs/{org}/insights/api/route-stats/{actor_type}/{actor_id}",
|
|
66
|
+
"GET /orgs/{org}/insights/api/subject-stats",
|
|
67
|
+
"GET /orgs/{org}/insights/api/user-stats/{user_id}",
|
|
68
|
+
"GET /orgs/{org}/installations",
|
|
69
|
+
"GET /orgs/{org}/invitations",
|
|
70
|
+
"GET /orgs/{org}/invitations/{invitation_id}/teams",
|
|
71
|
+
"GET /orgs/{org}/issues",
|
|
72
|
+
"GET /orgs/{org}/members",
|
|
73
|
+
"GET /orgs/{org}/members/{username}/codespaces",
|
|
74
|
+
"GET /orgs/{org}/migrations",
|
|
75
|
+
"GET /orgs/{org}/migrations/{migration_id}/repositories",
|
|
76
|
+
"GET /orgs/{org}/organization-roles/{role_id}/teams",
|
|
77
|
+
"GET /orgs/{org}/organization-roles/{role_id}/users",
|
|
78
|
+
"GET /orgs/{org}/outside_collaborators",
|
|
79
|
+
"GET /orgs/{org}/packages",
|
|
80
|
+
"GET /orgs/{org}/packages/{package_type}/{package_name}/versions",
|
|
81
|
+
"GET /orgs/{org}/personal-access-token-requests",
|
|
82
|
+
"GET /orgs/{org}/personal-access-token-requests/{pat_request_id}/repositories",
|
|
83
|
+
"GET /orgs/{org}/personal-access-tokens",
|
|
84
|
+
"GET /orgs/{org}/personal-access-tokens/{pat_id}/repositories",
|
|
85
|
+
"GET /orgs/{org}/private-registries",
|
|
86
|
+
"GET /orgs/{org}/projects",
|
|
87
|
+
"GET /orgs/{org}/projectsV2",
|
|
88
|
+
"GET /orgs/{org}/projectsV2/{project_number}/fields",
|
|
89
|
+
"GET /orgs/{org}/projectsV2/{project_number}/items",
|
|
90
|
+
"GET /orgs/{org}/properties/values",
|
|
91
|
+
"GET /orgs/{org}/public_members",
|
|
92
|
+
"GET /orgs/{org}/repos",
|
|
93
|
+
"GET /orgs/{org}/rulesets",
|
|
94
|
+
"GET /orgs/{org}/rulesets/rule-suites",
|
|
95
|
+
"GET /orgs/{org}/rulesets/{ruleset_id}/history",
|
|
96
|
+
"GET /orgs/{org}/secret-scanning/alerts",
|
|
97
|
+
"GET /orgs/{org}/security-advisories",
|
|
98
|
+
"GET /orgs/{org}/settings/immutable-releases/repositories",
|
|
99
|
+
"GET /orgs/{org}/settings/network-configurations",
|
|
100
|
+
"GET /orgs/{org}/team/{team_slug}/copilot/metrics",
|
|
101
|
+
"GET /orgs/{org}/teams",
|
|
102
|
+
"GET /orgs/{org}/teams/{team_slug}/discussions",
|
|
103
|
+
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments",
|
|
104
|
+
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/comments/{comment_number}/reactions",
|
|
105
|
+
"GET /orgs/{org}/teams/{team_slug}/discussions/{discussion_number}/reactions",
|
|
106
|
+
"GET /orgs/{org}/teams/{team_slug}/invitations",
|
|
107
|
+
"GET /orgs/{org}/teams/{team_slug}/members",
|
|
108
|
+
"GET /orgs/{org}/teams/{team_slug}/projects",
|
|
109
|
+
"GET /orgs/{org}/teams/{team_slug}/repos",
|
|
110
|
+
"GET /orgs/{org}/teams/{team_slug}/teams",
|
|
111
|
+
"GET /projects/{project_id}/collaborators",
|
|
112
|
+
"GET /repos/{owner}/{repo}/actions/artifacts",
|
|
113
|
+
"GET /repos/{owner}/{repo}/actions/caches",
|
|
114
|
+
"GET /repos/{owner}/{repo}/actions/organization-secrets",
|
|
115
|
+
"GET /repos/{owner}/{repo}/actions/organization-variables",
|
|
116
|
+
"GET /repos/{owner}/{repo}/actions/runners",
|
|
117
|
+
"GET /repos/{owner}/{repo}/actions/runs",
|
|
118
|
+
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/artifacts",
|
|
119
|
+
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/attempts/{attempt_number}/jobs",
|
|
120
|
+
"GET /repos/{owner}/{repo}/actions/runs/{run_id}/jobs",
|
|
121
|
+
"GET /repos/{owner}/{repo}/actions/secrets",
|
|
122
|
+
"GET /repos/{owner}/{repo}/actions/variables",
|
|
123
|
+
"GET /repos/{owner}/{repo}/actions/workflows",
|
|
124
|
+
"GET /repos/{owner}/{repo}/actions/workflows/{workflow_id}/runs",
|
|
125
|
+
"GET /repos/{owner}/{repo}/activity",
|
|
126
|
+
"GET /repos/{owner}/{repo}/assignees",
|
|
127
|
+
"GET /repos/{owner}/{repo}/attestations/{subject_digest}",
|
|
128
|
+
"GET /repos/{owner}/{repo}/branches",
|
|
129
|
+
"GET /repos/{owner}/{repo}/check-runs/{check_run_id}/annotations",
|
|
130
|
+
"GET /repos/{owner}/{repo}/check-suites/{check_suite_id}/check-runs",
|
|
131
|
+
"GET /repos/{owner}/{repo}/code-scanning/alerts",
|
|
132
|
+
"GET /repos/{owner}/{repo}/code-scanning/alerts/{alert_number}/instances",
|
|
133
|
+
"GET /repos/{owner}/{repo}/code-scanning/analyses",
|
|
134
|
+
"GET /repos/{owner}/{repo}/codespaces",
|
|
135
|
+
"GET /repos/{owner}/{repo}/codespaces/devcontainers",
|
|
136
|
+
"GET /repos/{owner}/{repo}/codespaces/secrets",
|
|
137
|
+
"GET /repos/{owner}/{repo}/collaborators",
|
|
138
|
+
"GET /repos/{owner}/{repo}/comments",
|
|
139
|
+
"GET /repos/{owner}/{repo}/comments/{comment_id}/reactions",
|
|
140
|
+
"GET /repos/{owner}/{repo}/commits",
|
|
141
|
+
"GET /repos/{owner}/{repo}/commits/{commit_sha}/comments",
|
|
142
|
+
"GET /repos/{owner}/{repo}/commits/{commit_sha}/pulls",
|
|
143
|
+
"GET /repos/{owner}/{repo}/commits/{ref}/check-runs",
|
|
144
|
+
"GET /repos/{owner}/{repo}/commits/{ref}/check-suites",
|
|
145
|
+
"GET /repos/{owner}/{repo}/commits/{ref}/status",
|
|
146
|
+
"GET /repos/{owner}/{repo}/commits/{ref}/statuses",
|
|
147
|
+
"GET /repos/{owner}/{repo}/compare/{basehead}",
|
|
148
|
+
"GET /repos/{owner}/{repo}/compare/{base}...{head}",
|
|
149
|
+
"GET /repos/{owner}/{repo}/contributors",
|
|
150
|
+
"GET /repos/{owner}/{repo}/dependabot/alerts",
|
|
151
|
+
"GET /repos/{owner}/{repo}/dependabot/secrets",
|
|
152
|
+
"GET /repos/{owner}/{repo}/deployments",
|
|
153
|
+
"GET /repos/{owner}/{repo}/deployments/{deployment_id}/statuses",
|
|
154
|
+
"GET /repos/{owner}/{repo}/environments",
|
|
155
|
+
"GET /repos/{owner}/{repo}/environments/{environment_name}/deployment-branch-policies",
|
|
156
|
+
"GET /repos/{owner}/{repo}/environments/{environment_name}/deployment_protection_rules/apps",
|
|
157
|
+
"GET /repos/{owner}/{repo}/environments/{environment_name}/secrets",
|
|
158
|
+
"GET /repos/{owner}/{repo}/environments/{environment_name}/variables",
|
|
159
|
+
"GET /repos/{owner}/{repo}/events",
|
|
160
|
+
"GET /repos/{owner}/{repo}/forks",
|
|
161
|
+
"GET /repos/{owner}/{repo}/hooks",
|
|
162
|
+
"GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries",
|
|
163
|
+
"GET /repos/{owner}/{repo}/invitations",
|
|
164
|
+
"GET /repos/{owner}/{repo}/issues",
|
|
165
|
+
"GET /repos/{owner}/{repo}/issues/comments",
|
|
166
|
+
"GET /repos/{owner}/{repo}/issues/comments/{comment_id}/reactions",
|
|
167
|
+
"GET /repos/{owner}/{repo}/issues/events",
|
|
168
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/comments",
|
|
169
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocked_by",
|
|
170
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/dependencies/blocking",
|
|
171
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/events",
|
|
172
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/labels",
|
|
173
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/reactions",
|
|
174
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/sub_issues",
|
|
175
|
+
"GET /repos/{owner}/{repo}/issues/{issue_number}/timeline",
|
|
176
|
+
"GET /repos/{owner}/{repo}/keys",
|
|
177
|
+
"GET /repos/{owner}/{repo}/labels",
|
|
178
|
+
"GET /repos/{owner}/{repo}/milestones",
|
|
179
|
+
"GET /repos/{owner}/{repo}/milestones/{milestone_number}/labels",
|
|
180
|
+
"GET /repos/{owner}/{repo}/notifications",
|
|
181
|
+
"GET /repos/{owner}/{repo}/pages/builds",
|
|
182
|
+
"GET /repos/{owner}/{repo}/projects",
|
|
183
|
+
"GET /repos/{owner}/{repo}/pulls",
|
|
184
|
+
"GET /repos/{owner}/{repo}/pulls/comments",
|
|
185
|
+
"GET /repos/{owner}/{repo}/pulls/comments/{comment_id}/reactions",
|
|
186
|
+
"GET /repos/{owner}/{repo}/pulls/{pull_number}/comments",
|
|
187
|
+
"GET /repos/{owner}/{repo}/pulls/{pull_number}/commits",
|
|
188
|
+
"GET /repos/{owner}/{repo}/pulls/{pull_number}/files",
|
|
189
|
+
"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews",
|
|
190
|
+
"GET /repos/{owner}/{repo}/pulls/{pull_number}/reviews/{review_id}/comments",
|
|
191
|
+
"GET /repos/{owner}/{repo}/releases",
|
|
192
|
+
"GET /repos/{owner}/{repo}/releases/{release_id}/assets",
|
|
193
|
+
"GET /repos/{owner}/{repo}/releases/{release_id}/reactions",
|
|
194
|
+
"GET /repos/{owner}/{repo}/rules/branches/{branch}",
|
|
195
|
+
"GET /repos/{owner}/{repo}/rulesets",
|
|
196
|
+
"GET /repos/{owner}/{repo}/rulesets/rule-suites",
|
|
197
|
+
"GET /repos/{owner}/{repo}/rulesets/{ruleset_id}/history",
|
|
198
|
+
"GET /repos/{owner}/{repo}/secret-scanning/alerts",
|
|
199
|
+
"GET /repos/{owner}/{repo}/secret-scanning/alerts/{alert_number}/locations",
|
|
200
|
+
"GET /repos/{owner}/{repo}/security-advisories",
|
|
201
|
+
"GET /repos/{owner}/{repo}/stargazers",
|
|
202
|
+
"GET /repos/{owner}/{repo}/subscribers",
|
|
203
|
+
"GET /repos/{owner}/{repo}/tags",
|
|
204
|
+
"GET /repos/{owner}/{repo}/teams",
|
|
205
|
+
"GET /repos/{owner}/{repo}/topics",
|
|
206
|
+
"GET /repositories",
|
|
207
|
+
"GET /search/code",
|
|
208
|
+
"GET /search/commits",
|
|
209
|
+
"GET /search/issues",
|
|
210
|
+
"GET /search/labels",
|
|
211
|
+
"GET /search/repositories",
|
|
212
|
+
"GET /search/topics",
|
|
213
|
+
"GET /search/users",
|
|
214
|
+
"GET /teams/{team_id}/discussions",
|
|
215
|
+
"GET /teams/{team_id}/discussions/{discussion_number}/comments",
|
|
216
|
+
"GET /teams/{team_id}/discussions/{discussion_number}/comments/{comment_number}/reactions",
|
|
217
|
+
"GET /teams/{team_id}/discussions/{discussion_number}/reactions",
|
|
218
|
+
"GET /teams/{team_id}/invitations",
|
|
219
|
+
"GET /teams/{team_id}/members",
|
|
220
|
+
"GET /teams/{team_id}/projects",
|
|
221
|
+
"GET /teams/{team_id}/repos",
|
|
222
|
+
"GET /teams/{team_id}/teams",
|
|
223
|
+
"GET /user/blocks",
|
|
224
|
+
"GET /user/codespaces",
|
|
225
|
+
"GET /user/codespaces/secrets",
|
|
226
|
+
"GET /user/emails",
|
|
227
|
+
"GET /user/followers",
|
|
228
|
+
"GET /user/following",
|
|
229
|
+
"GET /user/gpg_keys",
|
|
230
|
+
"GET /user/installations",
|
|
231
|
+
"GET /user/installations/{installation_id}/repositories",
|
|
232
|
+
"GET /user/issues",
|
|
233
|
+
"GET /user/keys",
|
|
234
|
+
"GET /user/marketplace_purchases",
|
|
235
|
+
"GET /user/marketplace_purchases/stubbed",
|
|
236
|
+
"GET /user/memberships/orgs",
|
|
237
|
+
"GET /user/migrations",
|
|
238
|
+
"GET /user/migrations/{migration_id}/repositories",
|
|
239
|
+
"GET /user/orgs",
|
|
240
|
+
"GET /user/packages",
|
|
241
|
+
"GET /user/packages/{package_type}/{package_name}/versions",
|
|
242
|
+
"GET /user/public_emails",
|
|
243
|
+
"GET /user/repos",
|
|
244
|
+
"GET /user/repository_invitations",
|
|
245
|
+
"GET /user/social_accounts",
|
|
246
|
+
"GET /user/ssh_signing_keys",
|
|
247
|
+
"GET /user/starred",
|
|
248
|
+
"GET /user/subscriptions",
|
|
249
|
+
"GET /user/teams",
|
|
250
|
+
"GET /users",
|
|
251
|
+
"GET /users/{username}/attestations/{subject_digest}",
|
|
252
|
+
"GET /users/{username}/events",
|
|
253
|
+
"GET /users/{username}/events/orgs/{org}",
|
|
254
|
+
"GET /users/{username}/events/public",
|
|
255
|
+
"GET /users/{username}/followers",
|
|
256
|
+
"GET /users/{username}/following",
|
|
257
|
+
"GET /users/{username}/gists",
|
|
258
|
+
"GET /users/{username}/gpg_keys",
|
|
259
|
+
"GET /users/{username}/keys",
|
|
260
|
+
"GET /users/{username}/orgs",
|
|
261
|
+
"GET /users/{username}/packages",
|
|
262
|
+
"GET /users/{username}/projects",
|
|
263
|
+
"GET /users/{username}/projectsV2",
|
|
264
|
+
"GET /users/{username}/projectsV2/{project_number}/fields",
|
|
265
|
+
"GET /users/{username}/projectsV2/{project_number}/items",
|
|
266
|
+
"GET /users/{username}/received_events",
|
|
267
|
+
"GET /users/{username}/received_events/public",
|
|
268
|
+
"GET /users/{username}/repos",
|
|
269
|
+
"GET /users/{username}/social_accounts",
|
|
270
|
+
"GET /users/{username}/ssh_signing_keys",
|
|
271
|
+
"GET /users/{username}/starred",
|
|
272
|
+
"GET /users/{username}/subscriptions"
|
|
273
|
+
];
|
|
274
|
+
export {
|
|
275
|
+
paginatingEndpoints
|
|
276
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { VERSION } from "./version.js";
|
|
2
|
+
import { paginate } from "./paginate.js";
|
|
3
|
+
import { iterator } from "./iterator.js";
|
|
4
|
+
import { composePaginateRest } from "./compose-paginate.js";
|
|
5
|
+
import {
|
|
6
|
+
isPaginatingEndpoint,
|
|
7
|
+
paginatingEndpoints
|
|
8
|
+
} from "./paginating-endpoints.js";
|
|
9
|
+
function paginateRest(octokit) {
|
|
10
|
+
return {
|
|
11
|
+
paginate: Object.assign(paginate.bind(null, octokit), {
|
|
12
|
+
iterator: iterator.bind(null, octokit)
|
|
13
|
+
})
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
paginateRest.VERSION = VERSION;
|
|
17
|
+
export {
|
|
18
|
+
composePaginateRest,
|
|
19
|
+
isPaginatingEndpoint,
|
|
20
|
+
paginateRest,
|
|
21
|
+
paginatingEndpoints
|
|
22
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { normalizePaginatedListResponse } from "./normalize-paginated-list-response.js";
|
|
2
|
+
function iterator(octokit, route, parameters) {
|
|
3
|
+
const options = typeof route === "function" ? route.endpoint(parameters) : octokit.request.endpoint(route, parameters);
|
|
4
|
+
const requestMethod = typeof route === "function" ? route : octokit.request;
|
|
5
|
+
const method = options.method;
|
|
6
|
+
const headers = options.headers;
|
|
7
|
+
let url = options.url;
|
|
8
|
+
return {
|
|
9
|
+
[Symbol.asyncIterator]: () => ({
|
|
10
|
+
async next() {
|
|
11
|
+
if (!url) return { done: true };
|
|
12
|
+
try {
|
|
13
|
+
const response = await requestMethod({ method, url, headers });
|
|
14
|
+
const normalizedResponse = normalizePaginatedListResponse(response);
|
|
15
|
+
url = ((normalizedResponse.headers.link || "").match(
|
|
16
|
+
/<([^<>]+)>;\s*rel="next"/
|
|
17
|
+
) || [])[1];
|
|
18
|
+
if (!url && "total_commits" in normalizedResponse.data) {
|
|
19
|
+
const parsedUrl = new URL(normalizedResponse.url);
|
|
20
|
+
const params = parsedUrl.searchParams;
|
|
21
|
+
const page = parseInt(params.get("page") || "1", 10);
|
|
22
|
+
const per_page = parseInt(params.get("per_page") || "250", 10);
|
|
23
|
+
if (page * per_page < normalizedResponse.data.total_commits) {
|
|
24
|
+
params.set("page", String(page + 1));
|
|
25
|
+
url = parsedUrl.toString();
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return { value: normalizedResponse };
|
|
29
|
+
} catch (error) {
|
|
30
|
+
if (error.status !== 409) throw error;
|
|
31
|
+
url = "";
|
|
32
|
+
return {
|
|
33
|
+
value: {
|
|
34
|
+
status: 200,
|
|
35
|
+
headers: {},
|
|
36
|
+
data: []
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
})
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
iterator
|
|
46
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function normalizePaginatedListResponse(response) {
|
|
2
|
+
if (!response.data) {
|
|
3
|
+
return {
|
|
4
|
+
...response,
|
|
5
|
+
data: []
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
const responseNeedsNormalization = ("total_count" in response.data || "total_commits" in response.data) && !("url" in response.data);
|
|
9
|
+
if (!responseNeedsNormalization) return response;
|
|
10
|
+
const incompleteResults = response.data.incomplete_results;
|
|
11
|
+
const repositorySelection = response.data.repository_selection;
|
|
12
|
+
const totalCount = response.data.total_count;
|
|
13
|
+
const totalCommits = response.data.total_commits;
|
|
14
|
+
delete response.data.incomplete_results;
|
|
15
|
+
delete response.data.repository_selection;
|
|
16
|
+
delete response.data.total_count;
|
|
17
|
+
delete response.data.total_commits;
|
|
18
|
+
const namespaceKey = Object.keys(response.data)[0];
|
|
19
|
+
const data = response.data[namespaceKey];
|
|
20
|
+
response.data = data;
|
|
21
|
+
if (typeof incompleteResults !== "undefined") {
|
|
22
|
+
response.data.incomplete_results = incompleteResults;
|
|
23
|
+
}
|
|
24
|
+
if (typeof repositorySelection !== "undefined") {
|
|
25
|
+
response.data.repository_selection = repositorySelection;
|
|
26
|
+
}
|
|
27
|
+
response.data.total_count = totalCount;
|
|
28
|
+
response.data.total_commits = totalCommits;
|
|
29
|
+
return response;
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
normalizePaginatedListResponse
|
|
33
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { iterator } from "./iterator.js";
|
|
2
|
+
function paginate(octokit, route, parameters, mapFn) {
|
|
3
|
+
if (typeof parameters === "function") {
|
|
4
|
+
mapFn = parameters;
|
|
5
|
+
parameters = void 0;
|
|
6
|
+
}
|
|
7
|
+
return gather(
|
|
8
|
+
octokit,
|
|
9
|
+
[],
|
|
10
|
+
iterator(octokit, route, parameters)[Symbol.asyncIterator](),
|
|
11
|
+
mapFn
|
|
12
|
+
);
|
|
13
|
+
}
|
|
14
|
+
function gather(octokit, results, iterator2, mapFn) {
|
|
15
|
+
return iterator2.next().then((result) => {
|
|
16
|
+
if (result.done) {
|
|
17
|
+
return results;
|
|
18
|
+
}
|
|
19
|
+
let earlyExit = false;
|
|
20
|
+
function done() {
|
|
21
|
+
earlyExit = true;
|
|
22
|
+
}
|
|
23
|
+
results = results.concat(
|
|
24
|
+
mapFn ? mapFn(result.value, done) : result.value.data
|
|
25
|
+
);
|
|
26
|
+
if (earlyExit) {
|
|
27
|
+
return results;
|
|
28
|
+
}
|
|
29
|
+
return gather(octokit, results, iterator2, mapFn);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
export {
|
|
33
|
+
paginate
|
|
34
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
paginatingEndpoints
|
|
3
|
+
} from "./generated/paginating-endpoints.js";
|
|
4
|
+
import { paginatingEndpoints as paginatingEndpoints2 } from "./generated/paginating-endpoints.js";
|
|
5
|
+
function isPaginatingEndpoint(arg) {
|
|
6
|
+
if (typeof arg === "string") {
|
|
7
|
+
return paginatingEndpoints.includes(arg);
|
|
8
|
+
} else {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
export {
|
|
13
|
+
isPaginatingEndpoint,
|
|
14
|
+
paginatingEndpoints2 as paginatingEndpoints
|
|
15
|
+
};
|