diff --git a/package-lock.json b/package-lock.json index 6b9d30b7..4f44ba2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,7 +22,7 @@ "github-openapi-graphql-query": "^4.0.0", "glob": "^11.0.0", "npm-run-all2": "^7.0.0", - "prettier": "3.4.2", + "prettier": "3.5.1", "semantic-release-plugin-update-version-in-files": "^1.0.0", "typescript": "^5.0.0", "vitest": "^3.0.0" @@ -2286,9 +2286,9 @@ } }, "node_modules/prettier": { - "version": "3.4.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.4.2.tgz", - "integrity": "sha512-e9MewbtFo+Fevyuxn/4rrcDAaq0IYxPGLvObpQjiZBMAzB9IGmzlnG9RZy3FFas+eBMu2vA0CszMeduow5dIuQ==", + "version": "3.5.1", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.1.tgz", + "integrity": "sha512-hPpFQvHwL3Qv5AdRvBFMhnKo4tYxp0ReXiPn2bxkiohEX6mBeBwEpBSQTkD458RaaDKQMYSp4hX4UtfUTA5wDw==", "dev": true, "license": "MIT", "bin": { diff --git a/package.json b/package.json index 1e95e9ec..8444a6fa 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "github-openapi-graphql-query": "^4.0.0", "glob": "^11.0.0", "npm-run-all2": "^7.0.0", - "prettier": "3.4.2", + "prettier": "3.5.1", "semantic-release-plugin-update-version-in-files": "^1.0.0", "typescript": "^5.0.0", "vitest": "^3.0.0" diff --git a/src/types.ts b/src/types.ts index 862a2aa8..a46cf192 100644 --- a/src/types.ts +++ b/src/types.ts @@ -54,9 +54,23 @@ type GetResultsType = T extends { data: any[] } ? T["data"][KnownKeysMatching] : never; -// Ensure that the type always returns the paginated results and not a mix of paginated results and the response object -type NormalizeResponse = Omit & { data: GetResultsType }; +// Extract the pagination keys from the response object in order to return them alongside the paginated results +type GetPaginationKeys = T extends { data: any[] } + ? T + : T extends { data: object } + ? Pick< + T["data"], + Extract< + keyof T["data"], + "repository_selection" | "total_count" | "incomplete_results" + > + > + : never; +// Ensure that the type always returns the paginated results and not a mix of paginated results and the response object +type NormalizeResponse = Omit & { + data: GetResultsType & GetPaginationKeys; +}; type DataType = "data" extends keyof T ? T["data"] : unknown; export interface MapFunction<