@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.
@@ -0,0 +1,15 @@
1
+ import type { Octokit } from "@octokit/core";
2
+ import type { PaginateInterface } from "./types.js";
3
+ export type { PaginateInterface, PaginatingEndpoints } from "./types.js";
4
+ export { composePaginateRest } from "./compose-paginate.js";
5
+ export { isPaginatingEndpoint, paginatingEndpoints, } from "./paginating-endpoints.js";
6
+ /**
7
+ * @param octokit Octokit instance
8
+ * @param options Options passed to Octokit constructor
9
+ */
10
+ export declare function paginateRest(octokit: Octokit): {
11
+ paginate: PaginateInterface;
12
+ };
13
+ export declare namespace paginateRest {
14
+ var VERSION: string;
15
+ }
@@ -0,0 +1,3 @@
1
+ import type { Octokit } from "@octokit/core";
2
+ import type { RequestInterface, RequestParameters, Route } from "./types.js";
3
+ export declare function iterator(octokit: Octokit, route: Route | RequestInterface, parameters?: RequestParameters): AsyncIterable<any>;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Some “list” response that can be paginated have a different response structure
3
+ *
4
+ * They have a `total_count` key in the response (search also has `incomplete_results`,
5
+ * /installation/repositories also has `repository_selection`), as well as a key with
6
+ * the list of the items which name varies from endpoint to endpoint.
7
+ *
8
+ * Octokit normalizes these responses so that paginated results are always returned following
9
+ * the same structure. One challenge is that if the list response has only one page, no Link
10
+ * header is provided, so this header alone is not sufficient to check wether a response is
11
+ * paginated or not.
12
+ *
13
+ * We check if a "total_count" key is present in the response data, but also make sure that
14
+ * a "url" property is not, as the "Get the combined status for a specific ref" endpoint would
15
+ * otherwise match: https://developer.github.com/v3/repos/statuses/#get-the-combined-status-for-a-specific-ref
16
+ */
17
+ import type { OctokitResponse } from "./types.js";
18
+ export declare function normalizePaginatedListResponse(response: OctokitResponse<any>): OctokitResponse<any>;
@@ -0,0 +1,3 @@
1
+ import type { Octokit } from "@octokit/core";
2
+ import type { MapFunction, PaginationResults, RequestParameters, Route, RequestInterface } from "./types.js";
3
+ export declare function paginate(octokit: Octokit, route: Route | RequestInterface, parameters?: RequestParameters, mapFn?: MapFunction): Promise<PaginationResults>;
@@ -0,0 +1,3 @@
1
+ import { type PaginatingEndpoints } from "./generated/paginating-endpoints.js";
2
+ export { paginatingEndpoints } from "./generated/paginating-endpoints.js";
3
+ export declare function isPaginatingEndpoint(arg: unknown): arg is keyof PaginatingEndpoints;
@@ -0,0 +1,248 @@
1
+ import type { Octokit } from "@octokit/core";
2
+ import type * as OctokitTypes from "@octokit/types";
3
+ export type { EndpointOptions, RequestInterface, OctokitResponse, RequestParameters, Route, } from "@octokit/types";
4
+ export type { PaginatingEndpoints } from "./generated/paginating-endpoints.js";
5
+ import type { PaginatingEndpoints } from "./generated/paginating-endpoints.js";
6
+ type PaginationMetadataKeys = "repository_selection" | "total_count" | "total_commits" | "incomplete_results";
7
+ type KnownKeys<T> = Extract<{
8
+ [K in keyof T]: string extends K ? never : number extends K ? never : K;
9
+ } extends {
10
+ [_ in keyof T]: infer U;
11
+ } ? U : never, Exclude<keyof T, PaginationMetadataKeys>>;
12
+ type KeysMatching<T, V> = {
13
+ [K in keyof T]: T[K] extends V ? K : never;
14
+ }[keyof T];
15
+ type KnownKeysMatching<T, V> = KeysMatching<Pick<T, KnownKeys<T>>, V>;
16
+ type GetResultsType<T> = T extends {
17
+ data: any[];
18
+ } ? T["data"] : T extends {
19
+ data: object;
20
+ } ? T["data"][KnownKeysMatching<T["data"], any[]>] : never;
21
+ type GetPaginationKeys<T> = T extends {
22
+ data: any[];
23
+ } ? {} : T extends {
24
+ data: object;
25
+ } ? Pick<T["data"], Extract<keyof T["data"], PaginationMetadataKeys>> : never;
26
+ type NormalizeResponse<T> = Omit<T, "data"> & {
27
+ data: GetResultsType<T> & GetPaginationKeys<T>;
28
+ };
29
+ type DataType<T> = "data" extends keyof T ? T["data"] : unknown;
30
+ export interface MapFunction<T = OctokitTypes.OctokitResponse<PaginationResults<unknown>>, M = unknown[]> {
31
+ (response: T, done: () => void): M;
32
+ }
33
+ export type PaginationResults<T = unknown> = T[];
34
+ export interface PaginateInterface {
35
+ /**
36
+ * Paginate a request using endpoint options and map each response to a custom array
37
+ *
38
+ * @param {object} options Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
39
+ * @param {function} mapFn Optional method to map each response to a custom array
40
+ */
41
+ <T, M>(options: OctokitTypes.EndpointOptions, mapFn: MapFunction<OctokitTypes.OctokitResponse<PaginationResults<T>>, M[]>): Promise<PaginationResults<M>>;
42
+ /**
43
+ * Paginate a request using endpoint options
44
+ *
45
+ * @param {object} options Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
46
+ */
47
+ <T>(options: OctokitTypes.EndpointOptions): Promise<PaginationResults<T>>;
48
+ /**
49
+ * Paginate a request using a known endpoint route string and map each response to a custom array
50
+ *
51
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
52
+ * @param {function} mapFn Optional method to map each response to a custom array
53
+ */
54
+ <R extends keyof PaginatingEndpoints, M extends unknown[]>(route: R, mapFn: MapFunction<PaginatingEndpoints[R]["response"], M>): Promise<M>;
55
+ /**
56
+ * Paginate a request using a known endpoint route string and parameters, and map each response to a custom array
57
+ *
58
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
59
+ * @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
60
+ * @param {function} mapFn Optional method to map each response to a custom array
61
+ */
62
+ <R extends keyof PaginatingEndpoints, M extends unknown[]>(route: R, parameters: PaginatingEndpoints[R]["parameters"], mapFn: MapFunction<PaginatingEndpoints[R]["response"], M>): Promise<M>;
63
+ /**
64
+ * Paginate a request using an known endpoint route string
65
+ *
66
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
67
+ * @param {object} parameters? URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
68
+ */
69
+ <R extends keyof PaginatingEndpoints>(route: R, parameters?: PaginatingEndpoints[R]["parameters"]): Promise<DataType<PaginatingEndpoints[R]["response"]>>;
70
+ /**
71
+ * Paginate a request using an unknown endpoint route string
72
+ *
73
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
74
+ * @param {object} parameters? URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
75
+ */
76
+ <T, R extends OctokitTypes.Route = OctokitTypes.Route>(route: R, parameters?: R extends keyof PaginatingEndpoints ? PaginatingEndpoints[R]["parameters"] : OctokitTypes.RequestParameters): Promise<T[]>;
77
+ /**
78
+ * Paginate a request using an endpoint method and a map function
79
+ *
80
+ * @param {string} request Request method (`octokit.request` or `@octokit/request`)
81
+ * @param {function} mapFn? Optional method to map each response to a custom array
82
+ */
83
+ <R extends OctokitTypes.RequestInterface, M extends unknown[]>(request: R, mapFn: MapFunction<NormalizeResponse<OctokitTypes.GetResponseTypeFromEndpointMethod<R>>, M>): Promise<M>;
84
+ /**
85
+ * Paginate a request using an endpoint method, parameters, and a map function
86
+ *
87
+ * @param {string} request Request method (`octokit.request` or `@octokit/request`)
88
+ * @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
89
+ * @param {function} mapFn? Optional method to map each response to a custom array
90
+ */
91
+ <R extends OctokitTypes.RequestInterface, M extends unknown[]>(request: R, parameters: Parameters<R>[0], mapFn: MapFunction<NormalizeResponse<OctokitTypes.GetResponseTypeFromEndpointMethod<R>>, M>): Promise<M>;
92
+ /**
93
+ * Paginate a request using an endpoint method and parameters
94
+ *
95
+ * @param {string} request Request method (`octokit.request` or `@octokit/request`)
96
+ * @param {object} parameters? URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
97
+ */
98
+ <R extends OctokitTypes.RequestInterface>(request: R, parameters?: Parameters<R>[0]): Promise<NormalizeResponse<OctokitTypes.GetResponseTypeFromEndpointMethod<R>>["data"]>;
99
+ iterator: {
100
+ /**
101
+ * Get an async iterator to paginate a request using endpoint options
102
+ *
103
+ * @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
104
+ * @param {object} options Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
105
+ */
106
+ <T>(options: OctokitTypes.EndpointOptions): AsyncIterable<OctokitTypes.OctokitResponse<PaginationResults<T>>>;
107
+ /**
108
+ * Get an async iterator to paginate a request using a known endpoint route string and optional parameters
109
+ *
110
+ * @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
111
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
112
+ * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
113
+ */
114
+ <R extends keyof PaginatingEndpoints>(route: R, parameters?: PaginatingEndpoints[R]["parameters"]): AsyncIterable<OctokitTypes.OctokitResponse<DataType<PaginatingEndpoints[R]["response"]>>>;
115
+ /**
116
+ * Get an async iterator to paginate a request using an unknown endpoint route string and optional parameters
117
+ *
118
+ * @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
119
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
120
+ * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
121
+ */
122
+ <T, R extends OctokitTypes.Route = OctokitTypes.Route>(route: R, parameters?: R extends keyof PaginatingEndpoints ? PaginatingEndpoints[R]["parameters"] : OctokitTypes.RequestParameters): AsyncIterable<OctokitTypes.OctokitResponse<PaginationResults<T>>>;
123
+ /**
124
+ * Get an async iterator to paginate a request using a request method and optional parameters
125
+ *
126
+ * @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
127
+ * @param {string} request `@octokit/request` or `octokit.request` method
128
+ * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
129
+ */
130
+ <R extends OctokitTypes.RequestInterface>(request: R, parameters?: Parameters<R>[0]): AsyncIterable<NormalizeResponse<OctokitTypes.GetResponseTypeFromEndpointMethod<R>>>;
131
+ };
132
+ }
133
+ export interface ComposePaginateInterface {
134
+ /**
135
+ * Paginate a request using endpoint options and map each response to a custom array
136
+ *
137
+ * @param {object} octokit Octokit instance
138
+ * @param {object} options Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
139
+ * @param {function} mapFn Optional method to map each response to a custom array
140
+ */
141
+ <T, M>(octokit: Octokit, options: OctokitTypes.EndpointOptions, mapFn: MapFunction<OctokitTypes.OctokitResponse<PaginationResults<T>>, M[]>): Promise<PaginationResults<M>>;
142
+ /**
143
+ * Paginate a request using endpoint options
144
+ *
145
+ * @param {object} octokit Octokit instance
146
+ * @param {object} options Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
147
+ */
148
+ <T>(octokit: Octokit, options: OctokitTypes.EndpointOptions): Promise<PaginationResults<T>>;
149
+ /**
150
+ * Paginate a request using a known endpoint route string and map each response to a custom array
151
+ *
152
+ * @param {object} octokit Octokit instance
153
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
154
+ * @param {function} mapFn Optional method to map each response to a custom array
155
+ */
156
+ <R extends keyof PaginatingEndpoints, M extends unknown[]>(octokit: Octokit, route: R, mapFn: MapFunction<PaginatingEndpoints[R]["response"], M>): Promise<M>;
157
+ /**
158
+ * Paginate a request using a known endpoint route string and parameters, and map each response to a custom array
159
+ *
160
+ * @param {object} octokit Octokit instance
161
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
162
+ * @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
163
+ * @param {function} mapFn Optional method to map each response to a custom array
164
+ */
165
+ <R extends keyof PaginatingEndpoints, M extends unknown[]>(octokit: Octokit, route: R, parameters: PaginatingEndpoints[R]["parameters"], mapFn: MapFunction<PaginatingEndpoints[R]["response"], M>): Promise<M>;
166
+ /**
167
+ * Paginate a request using an known endpoint route string
168
+ *
169
+ * @param {object} octokit Octokit instance
170
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
171
+ * @param {object} parameters? URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
172
+ */
173
+ <R extends keyof PaginatingEndpoints>(octokit: Octokit, route: R, parameters?: PaginatingEndpoints[R]["parameters"]): Promise<DataType<PaginatingEndpoints[R]["response"]>>;
174
+ /**
175
+ * Paginate a request using an unknown endpoint route string
176
+ *
177
+ * @param {object} octokit Octokit instance
178
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
179
+ * @param {object} parameters? URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
180
+ */
181
+ <T, R extends OctokitTypes.Route = OctokitTypes.Route>(octokit: Octokit, route: R, parameters?: R extends keyof PaginatingEndpoints ? PaginatingEndpoints[R]["parameters"] : OctokitTypes.RequestParameters): Promise<T[]>;
182
+ /**
183
+ * Paginate a request using an endpoint method and a map function
184
+ *
185
+ * @param {object} octokit Octokit instance
186
+ * @param {string} request Request method (`octokit.request` or `@octokit/request`)
187
+ * @param {function} mapFn? Optional method to map each response to a custom array
188
+ */
189
+ <R extends OctokitTypes.RequestInterface, M extends unknown[]>(octokit: Octokit, request: R, mapFn: MapFunction<NormalizeResponse<OctokitTypes.GetResponseTypeFromEndpointMethod<R>>, M>): Promise<M>;
190
+ /**
191
+ * Paginate a request using an endpoint method, parameters, and a map function
192
+ *
193
+ * @param {object} octokit Octokit instance
194
+ * @param {string} request Request method (`octokit.request` or `@octokit/request`)
195
+ * @param {object} parameters URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
196
+ * @param {function} mapFn? Optional method to map each response to a custom array
197
+ */
198
+ <R extends OctokitTypes.RequestInterface, M extends unknown[]>(octokit: Octokit, request: R, parameters: Parameters<R>[0], mapFn: MapFunction<NormalizeResponse<OctokitTypes.GetResponseTypeFromEndpointMethod<R>>, M>): Promise<M>;
199
+ /**
200
+ * Paginate a request using an endpoint method and parameters
201
+ *
202
+ * @param {object} octokit Octokit instance
203
+ * @param {string} request Request method (`octokit.request` or `@octokit/request`)
204
+ * @param {object} parameters? URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
205
+ */
206
+ <R extends OctokitTypes.RequestInterface>(octokit: Octokit, request: R, parameters?: Parameters<R>[0]): Promise<NormalizeResponse<OctokitTypes.GetResponseTypeFromEndpointMethod<R>>["data"]>;
207
+ iterator: {
208
+ /**
209
+ * Get an async iterator to paginate a request using endpoint options
210
+ *
211
+ * @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
212
+ *
213
+ * @param {object} octokit Octokit instance
214
+ * @param {object} options Must set `method` and `url`. Plus URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
215
+ */
216
+ <T>(octokit: Octokit, options: OctokitTypes.EndpointOptions): AsyncIterable<OctokitTypes.OctokitResponse<PaginationResults<T>>>;
217
+ /**
218
+ * Get an async iterator to paginate a request using a known endpoint route string and optional parameters
219
+ *
220
+ * @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
221
+ *
222
+ * @param {object} octokit Octokit instance
223
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
224
+ * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
225
+ */
226
+ <R extends keyof PaginatingEndpoints>(octokit: Octokit, route: R, parameters?: PaginatingEndpoints[R]["parameters"]): AsyncIterable<OctokitTypes.OctokitResponse<DataType<PaginatingEndpoints[R]["response"]>>>;
227
+ /**
228
+ * Get an async iterator to paginate a request using an unknown endpoint route string and optional parameters
229
+ *
230
+ * @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
231
+ *
232
+ * @param {object} octokit Octokit instance
233
+ * @param {string} route Request method + URL. Example: `'GET /orgs/{org}'`
234
+ * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
235
+ */
236
+ <T, R extends OctokitTypes.Route = OctokitTypes.Route>(octokit: Octokit, route: R, parameters?: R extends keyof PaginatingEndpoints ? PaginatingEndpoints[R]["parameters"] : OctokitTypes.RequestParameters): AsyncIterable<OctokitTypes.OctokitResponse<PaginationResults<T>>>;
237
+ /**
238
+ * Get an async iterator to paginate a request using a request method and optional parameters
239
+ *
240
+ * @see {link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of} for await...of
241
+ *
242
+ * @param {object} octokit Octokit instance
243
+ * @param {string} request `@octokit/request` or `octokit.request` method
244
+ * @param {object} [parameters] URL, query or body parameters, as well as `headers`, `mediaType.format`, `request`, or `baseUrl`.
245
+ */
246
+ <R extends OctokitTypes.RequestInterface>(octokit: Octokit, request: R, parameters?: Parameters<R>[0]): AsyncIterable<NormalizeResponse<OctokitTypes.GetResponseTypeFromEndpointMethod<R>>>;
247
+ };
248
+ }
@@ -0,0 +1 @@
1
+ export declare const VERSION = "14.0.0";
package/package.json ADDED
@@ -0,0 +1,69 @@
1
+ {
2
+ "name": "@depup/octokit__plugin-paginate-rest",
3
+ "type": "module",
4
+ "version": "14.0.0-depup.0",
5
+ "description": "[DepUp] Octokit plugin to paginate REST API endpoint responses",
6
+ "repository": "github:octokit/plugin-paginate-rest.js",
7
+ "keywords": [
8
+ "depup",
9
+ "dependency-bumped",
10
+ "updated-deps",
11
+ "@octokit/plugin-paginate-rest",
12
+ "github",
13
+ "api",
14
+ "sdk",
15
+ "toolkit"
16
+ ],
17
+ "license": "MIT",
18
+ "dependencies": {
19
+ "@octokit/types": "^16.0.0"
20
+ },
21
+ "peerDependencies": {
22
+ "@octokit/core": ">=6"
23
+ },
24
+ "devDependencies": {
25
+ "@octokit/core": "^7.0.6",
26
+ "@octokit/plugin-rest-endpoint-methods": "^17.0.0",
27
+ "@octokit/tsconfig": "^4.0.0",
28
+ "@types/node": "^24.0.0",
29
+ "@vitest/coverage-v8": "^3.0.0",
30
+ "esbuild": "^0.25.0",
31
+ "fetch-mock": "^12.0.0",
32
+ "github-openapi-graphql-query": "^5.0.0",
33
+ "glob": "^11.0.0",
34
+ "npm-run-all2": "^8.0.0",
35
+ "prettier": "3.6.2",
36
+ "semantic-release-plugin-update-version-in-files": "^2.0.0",
37
+ "typescript": "^5.0.0",
38
+ "vitest": "^3.0.0"
39
+ },
40
+ "engines": {
41
+ "node": ">= 20"
42
+ },
43
+ "files": [
44
+ "dist-*/**",
45
+ "bin/**",
46
+ "changes.json",
47
+ "README.md"
48
+ ],
49
+ "types": "dist-types/index.d.ts",
50
+ "exports": {
51
+ ".": {
52
+ "types": "./dist-types/index.d.ts",
53
+ "import": "./dist-bundle/index.js",
54
+ "default": "./dist-bundle/index.js"
55
+ },
56
+ "./types": {
57
+ "types": "./dist-types/.d.ts"
58
+ }
59
+ },
60
+ "sideEffects": false,
61
+ "depup": {
62
+ "changes": {},
63
+ "depsUpdated": 0,
64
+ "originalPackage": "@octokit/plugin-paginate-rest",
65
+ "originalVersion": "14.0.0",
66
+ "processedAt": "2026-03-17T16:32:28.954Z",
67
+ "smokeTest": "passed"
68
+ }
69
+ }