From c6cc5fd9566b751dadb19cb9f244ac1b9858a9a9 Mon Sep 17 00:00:00 2001
From: Josh Soref <2119212+jsoref@users.noreply.github.com>
Date: Mon, 4 Mar 2024 13:37:52 -0500
Subject: [PATCH 1/3] maint: spelling (#167)
Signed-off-by: Josh Soref <2119212+jsoref@users.noreply.github.com>
BREAKING CHANGE: change spelling of `paginateGraphql` export to `paginateGraphQL`
---
CONTRIBUTING.md | 2 +-
README.md | 18 +++++++++---------
src/index.ts | 2 +-
test/paginate-graphql.e2e.ts | 4 ++--
test/paginate.test.ts | 2 +-
test/testHelpers/mock-octokit.ts | 4 ++--
test/typescript-validate.ts | 6 +++---
7 files changed, 19 insertions(+), 19 deletions(-)
diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index deba43e..c2b4306 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -56,6 +56,6 @@ Only one version number is bumped at a time, the highest version change trumps t
Besides publishing a new version to npm, semantic-release also creates a git tag and release
on GitHub, generates changelogs from the commit messages and puts them into the release notes.
-Before the publish it runs the `npm run build` script which creates a `pkg/` folder with distributions for browsers, node and Typescript definitions. The contents of the `pkg/` folder are published to the npm registry.
+Before the publish it runs the `npm run build` script which creates a `pkg/` folder with distributions for browsers, node and TypeScript definitions. The contents of the `pkg/` folder are published to the npm registry.
If the pull request looks good but does not follow the commit conventions, use the Squash & merge button.
diff --git a/README.md b/README.md
index 6fc6e6b..f7dcb23 100644
--- a/README.md
+++ b/README.md
@@ -18,7 +18,7 @@ Load `@octokit/plugin-paginate-graphql` and [`@octokit/core`](https://github.com
```html
```
@@ -31,7 +31,7 @@ Install with `npm install @octokit/core @octokit/plugin-paginate-graphql`. Optio
```js
const { Octokit } = require("@octokit/core");
-const { paginateGraphql } = require("@octokit/plugin-paginate-graphql");
+const { paginateGraphQL } = require("@octokit/plugin-paginate-graphql");
```
@@ -39,7 +39,7 @@ const { paginateGraphql } = require("@octokit/plugin-paginate-graphql");
```js
-const MyOctokit = Octokit.plugin(paginateGraphql);
+const MyOctokit = Octokit.plugin(paginateGraphQL);
const octokit = new MyOctokit({ auth: "secret123" });
const { repository } = await octokit.graphql.paginate(
@@ -61,18 +61,18 @@ const { repository } = await octokit.graphql.paginate(
console.log(`Found ${repository.issues.nodes.length} issues!`);
```
-There are two convetions this plugin relies on:
+There are two conventions this plugin relies on:
1. The name of the cursor variable must be `$cursor`
2. You must include a valid `pageInfo` object in the paginated resource (see [Pagination Direction](#pagination-direction) for more info on what is considered valid)
## `octokit.graphql.paginate()`
-The `paginateGraphql` plugin adds a new `octokit.graphql.paginate()` method which accepts a query with a single `$cursor` variable that is used to paginate.
+The `paginateGraphQL` plugin adds a new `octokit.graphql.paginate()` method which accepts a query with a single `$cursor` variable that is used to paginate.
The query gets passed over to the `octokit.graphql()`-function. The response is then scanned for the required `pageInfo`-object. If `hasNextPage` is `true`, it will automatically use the `endCursor` to execute the next query until `hasNextPage` is `false`.
-While iterating, it ongoingly merges all `nodes` and/or `edges` of all responses and returns a combined response in the end.
+While iterating, it continually merges all `nodes` and/or `edges` of all responses and returns a combined response in the end.
> **Warning**
> Please note that this plugin only supports pagination of a single resource - so you can **not** execute queries with parallel or nested pagination. You can find more details in [the chapter below](#unsupported-nested-pagination).
@@ -159,7 +159,7 @@ await octokit.graphql.paginate(
### Pagination Direction
-You can control the pagination direction by the properties deinfed in the `pageInfo` resource.
+You can control the pagination direction by the properties defined in the `pageInfo` resource.
For a forward pagination, use:
@@ -183,7 +183,7 @@ If you provide all 4 properties in a `pageInfo`, the plugin will default to forw
### Unsupported: Nested pagination
-Nested pagination with GraphlQL is complicated, so the following **is not supported**:
+Nested pagination with GraphQL is complicated, so the following **is not supported**:
```js
await octokit.graphql.paginate((cursor) => {
@@ -218,7 +218,7 @@ There is a great video from GitHub Universe 2019 [Advanced patterns for GitHub's
### TypeScript Support
-You can type the response of the `paginateGraphql()` and `iterator()` functions like this:
+You can type the response of the `paginateGraphQL()` and `iterator()` functions like this:
```ts
await octokit.graphql.paginate((cursor) => {
diff --git a/src/index.ts b/src/index.ts
index cad271b..9be4bcd 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,7 +3,7 @@ import { createIterator } from "./iterator";
import { createPaginate } from "./paginate";
export type { PageInfoForward, PageInfoBackward } from "./page-info";
-export function paginateGraphql(octokit: Octokit) {
+export function paginateGraphQL(octokit: Octokit) {
octokit.graphql;
return {
graphql: Object.assign(octokit.graphql, {
diff --git a/test/paginate-graphql.e2e.ts b/test/paginate-graphql.e2e.ts
index c3642f9..fb67e50 100644
--- a/test/paginate-graphql.e2e.ts
+++ b/test/paginate-graphql.e2e.ts
@@ -1,7 +1,7 @@
import { Octokit } from "@octokit/core";
-import { paginateGraphql } from "../src";
+import { paginateGraphQL } from "../src";
-const PatchedOctokit = Octokit.plugin(paginateGraphql);
+const PatchedOctokit = Octokit.plugin(paginateGraphQL);
const token = process.env.E2E_GITHUB_TOKEN;
if (!token) {
diff --git a/test/paginate.test.ts b/test/paginate.test.ts
index 0628cc0..26ef8f0 100644
--- a/test/paginate.test.ts
+++ b/test/paginate.test.ts
@@ -106,7 +106,7 @@ describe("pagination", () => {
`
query paginate($cursor: String, $organization: String!) {
repository(owner: $organization, name: "rest.js") {
- issues(first: 10, after: $curosr) {
+ issues(first: 10, after: $cursor) {
nodes {
title
}
diff --git a/test/testHelpers/mock-octokit.ts b/test/testHelpers/mock-octokit.ts
index d9a960e..3a13cd4 100644
--- a/test/testHelpers/mock-octokit.ts
+++ b/test/testHelpers/mock-octokit.ts
@@ -1,8 +1,8 @@
import { Octokit } from "@octokit/core";
-import { paginateGraphql } from "../../src/index";
+import { paginateGraphQL } from "../../src/index";
import fetchMock from "fetch-mock";
-const PatchedOctokit = Octokit.plugin(paginateGraphql);
+const PatchedOctokit = Octokit.plugin(paginateGraphQL);
const MockOctokit = ({ responses = [{}] }: { responses?: any[] } = {}) => {
let calledQueries: string[] = [];
diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts
index f266959..6cb73ac 100644
--- a/test/typescript-validate.ts
+++ b/test/typescript-validate.ts
@@ -3,10 +3,10 @@
// ************************************************************
import { Octokit } from "@octokit/core";
-import { paginateGraphql, PageInfoBackward, PageInfoForward } from "../src";
+import { paginateGraphQL, PageInfoBackward, PageInfoForward } from "../src";
import { TestResponseType } from "./testHelpers/mock-response";
-const MyOctokit = Octokit.plugin(paginateGraphql);
+const MyOctokit = Octokit.plugin(paginateGraphQL);
const octokit = new MyOctokit();
const query = `
@@ -37,7 +37,7 @@ export async function typedIterator() {
}
}
-export function pageInfoBackwaredExported(): PageInfoBackward {
+export function pageInfoBackwardExported(): PageInfoBackward {
return {
hasPreviousPage: true,
startCursor: "startCursor",
From 1f19786f1ff803b6f3fa9fa7248066908fa0654f Mon Sep 17 00:00:00 2001
From: wolfy1339
Date: Mon, 4 Mar 2024 13:59:48 -0500
Subject: [PATCH 2/3] feat: package is now ESM
BREAKING CHANGE: package is now ESM
---
README.md | 4 +-
package-lock.json | 104 ++++++++++++++----------------
package.json | 25 ++++---
scripts/build.mjs | 8 ++-
src/errors.ts | 2 +-
src/extract-page-info.ts | 4 +-
src/index.ts | 8 +--
src/iterator.ts | 8 +--
src/merge-responses.ts | 2 +-
src/object-helpers.ts | 2 +-
src/paginate.ts | 6 +-
test/extract-page-infos.test.ts | 4 +-
test/merge-responses.test.ts | 2 +-
test/paginate-graphql.e2e.ts | 2 +-
test/paginate.test.ts | 10 +--
test/testHelpers/mock-octokit.ts | 2 +-
test/testHelpers/mock-response.ts | 2 +-
test/tsconfig.test.json | 3 +-
test/typescript-validate.ts | 8 ++-
19 files changed, 106 insertions(+), 100 deletions(-)
diff --git a/README.md b/README.md
index f7dcb23..48b094d 100644
--- a/README.md
+++ b/README.md
@@ -30,8 +30,8 @@ Node
Install with `npm install @octokit/core @octokit/plugin-paginate-graphql`. Optionally replace `@octokit/core` with a core-compatible module
```js
-const { Octokit } = require("@octokit/core");
-const { paginateGraphQL } = require("@octokit/plugin-paginate-graphql");
+import { Octokit } from "@octokit/core";
+import { paginateGraphQL } from "@octokit/plugin-paginate-graphql";
```
diff --git a/package-lock.json b/package-lock.json
index a1f07f4..f7b7043 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -9,9 +9,9 @@
"version": "0.0.0-development",
"license": "MIT",
"devDependencies": {
- "@octokit/core": "^5.0.0",
- "@octokit/plugin-rest-endpoint-methods": "^10.0.0",
- "@octokit/tsconfig": "^2.0.0",
+ "@octokit/core": "^6.0.0",
+ "@octokit/plugin-rest-endpoint-methods": "^11.0.0",
+ "@octokit/tsconfig": "^3.0.0",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^29.0.0",
"@types/node": "^20.0.0",
@@ -29,7 +29,7 @@
"node": ">= 18"
},
"peerDependencies": {
- "@octokit/core": ">=5"
+ "@octokit/core": ">=6"
}
},
"node_modules/@ampproject/remapping": {
@@ -1708,54 +1708,54 @@
}
},
"node_modules/@octokit/auth-token": {
- "version": "4.0.0",
- "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-4.0.0.tgz",
- "integrity": "sha512-tY/msAuJo6ARbK6SPIxZrPBms3xPbfwBrulZe0Wtr/DIY9lje2HeV1uoebShn6mx7SjCHif6EjMvoREj+gZ+SA==",
+ "version": "5.0.1",
+ "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-5.0.1.tgz",
+ "integrity": "sha512-RTmWsLfig8SBoiSdgvCht4BXl1CHU89Co5xiQ5JF19my/sIRDFCQ1RPrmK0exgqUZuNm39C/bV8+/83+MJEjGg==",
"dev": true,
"engines": {
"node": ">= 18"
}
},
"node_modules/@octokit/core": {
- "version": "5.1.0",
- "resolved": "https://registry.npmjs.org/@octokit/core/-/core-5.1.0.tgz",
- "integrity": "sha512-BDa2VAMLSh3otEiaMJ/3Y36GU4qf6GI+VivQ/P41NC6GHcdxpKlqV0ikSZ5gdQsmS3ojXeRx5vasgNTinF0Q4g==",
+ "version": "6.0.1",
+ "resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.0.1.tgz",
+ "integrity": "sha512-MIpPQXu8Y8GjHwXM81JLveiV+DHJZtLMcB5nKekBGOl3iAtk0HT3i12Xl8Biybu+bCS1+k4qbuKEq5d0RxNRnQ==",
"dev": true,
"dependencies": {
- "@octokit/auth-token": "^4.0.0",
- "@octokit/graphql": "^7.0.0",
- "@octokit/request": "^8.0.2",
- "@octokit/request-error": "^5.0.0",
+ "@octokit/auth-token": "^5.0.0",
+ "@octokit/graphql": "^8.0.0",
+ "@octokit/request": "^9.0.0",
+ "@octokit/request-error": "^6.0.1",
"@octokit/types": "^12.0.0",
- "before-after-hook": "^2.2.0",
- "universal-user-agent": "^6.0.0"
+ "before-after-hook": "^3.0.2",
+ "universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/@octokit/endpoint": {
- "version": "9.0.4",
- "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-9.0.4.tgz",
- "integrity": "sha512-DWPLtr1Kz3tv8L0UvXTDP1fNwM0S+z6EJpRcvH66orY6Eld4XBMCSYsaWp4xIm61jTWxK68BrR7ibO+vSDnZqw==",
+ "version": "10.0.0",
+ "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.0.0.tgz",
+ "integrity": "sha512-emBcNDxBdC1y3+knJonS5zhUB/CG6TihubxM2U1/pG/Z1y3a4oV0Gzz3lmkCvWWQI6h3tqBAX9MgCBFp+M68Jw==",
"dev": true,
"dependencies": {
"@octokit/types": "^12.0.0",
- "universal-user-agent": "^6.0.0"
+ "universal-user-agent": "^7.0.2"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/@octokit/graphql": {
- "version": "7.0.2",
- "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-7.0.2.tgz",
- "integrity": "sha512-OJ2iGMtj5Tg3s6RaXH22cJcxXRi7Y3EBqbHTBRq+PQAqfaS8f/236fUrWhfSn8P4jovyzqucxme7/vWSSZBX2Q==",
+ "version": "8.0.1",
+ "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-8.0.1.tgz",
+ "integrity": "sha512-lLDb6LhC1gBj2CxEDa5Xk10+H/boonhs+3Mi6jpRyetskDKNHe6crMeKmUE2efoLofMP8ruannLlCUgpTFmVzQ==",
"dev": true,
"dependencies": {
- "@octokit/request": "^8.0.1",
+ "@octokit/request": "^9.0.0",
"@octokit/types": "^12.0.0",
- "universal-user-agent": "^6.0.0"
+ "universal-user-agent": "^7.0.0"
},
"engines": {
"node": ">= 18"
@@ -1768,9 +1768,9 @@
"dev": true
},
"node_modules/@octokit/plugin-rest-endpoint-methods": {
- "version": "10.4.0",
- "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-10.4.0.tgz",
- "integrity": "sha512-INw5rGXWlbv/p/VvQL63dhlXr38qYTHkQ5bANi9xofrF9OraqmjHsIGyenmjmul1JVRHpUlw5heFOj1UZLEolA==",
+ "version": "11.0.1",
+ "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-11.0.1.tgz",
+ "integrity": "sha512-OcuMW0Ftkhad14vPfE0pK7uQK9qzvIZUvcMy71GZOAqlE39hvPwOUz4ylCPgr4YUVdFUc7bY8SjdcG1r8dVGDA==",
"dev": true,
"dependencies": {
"@octokit/types": "^12.6.0"
@@ -1779,42 +1779,40 @@
"node": ">= 18"
},
"peerDependencies": {
- "@octokit/core": ">=5"
+ "@octokit/core": ">=6"
}
},
"node_modules/@octokit/request": {
- "version": "8.2.0",
- "resolved": "https://registry.npmjs.org/@octokit/request/-/request-8.2.0.tgz",
- "integrity": "sha512-exPif6x5uwLqv1N1irkLG1zZNJkOtj8bZxuVHd71U5Ftuxf2wGNvAJyNBcPbPC+EBzwYEbBDdSFb8EPcjpYxPQ==",
+ "version": "9.0.1",
+ "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.0.1.tgz",
+ "integrity": "sha512-kL+cAcbSl3dctYLuJmLfx6Iku2MXXy0jszhaEIjQNaCp4zjHXrhVAHeuaRdNvJjW9qjl3u1MJ72+OuBP0YW/pg==",
"dev": true,
"dependencies": {
- "@octokit/endpoint": "^9.0.0",
- "@octokit/request-error": "^5.0.0",
+ "@octokit/endpoint": "^10.0.0",
+ "@octokit/request-error": "^6.0.1",
"@octokit/types": "^12.0.0",
- "universal-user-agent": "^6.0.0"
+ "universal-user-agent": "^7.0.2"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/@octokit/request-error": {
- "version": "5.0.1",
- "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-5.0.1.tgz",
- "integrity": "sha512-X7pnyTMV7MgtGmiXBwmO6M5kIPrntOXdyKZLigNfQWSEQzVxR4a4vo49vJjTWX70mPndj8KhfT4Dx+2Ng3vnBQ==",
+ "version": "6.0.2",
+ "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.0.2.tgz",
+ "integrity": "sha512-WtRVpoHcNXs84+s9s/wqfHaxM68NGMg8Av7h59B50OVO0PwwMx+2GgQ/OliUd0iQBSNWgR6N8afi/KjSHbXHWw==",
"dev": true,
"dependencies": {
- "@octokit/types": "^12.0.0",
- "deprecation": "^2.0.0",
- "once": "^1.4.0"
+ "@octokit/types": "^12.0.0"
},
"engines": {
"node": ">= 18"
}
},
"node_modules/@octokit/tsconfig": {
- "version": "2.0.0",
- "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-2.0.0.tgz",
- "integrity": "sha512-tWnrai3quGt8+gRN2edzo9fmraWekeryXPeXDomMw2oFSpu/lH3VSWGn/q4V+rwjTRMeeXk/ci623/01Zet4VQ==",
+ "version": "3.0.0",
+ "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-3.0.0.tgz",
+ "integrity": "sha512-tQLwgXYfBq9iUbOq26kWCzsJL6DY7qjOLzqcg5tCFQ4ob48H47iX98NudHW7S5OQ/fpSKYJhb3eQehyBNzYjfA==",
"dev": true
},
"node_modules/@octokit/types": {
@@ -2225,9 +2223,9 @@
"dev": true
},
"node_modules/before-after-hook": {
- "version": "2.2.3",
- "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.3.tgz",
- "integrity": "sha512-NzUnlZexiaH/46WDhANlyR2bXRopNg4F/zuSA3OpZnllCUgRaOF2znDioDWrmbNVsuZk6l9pMquQB38cfBZwkQ==",
+ "version": "3.0.2",
+ "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-3.0.2.tgz",
+ "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==",
"dev": true
},
"node_modules/brace-expansion": {
@@ -2696,12 +2694,6 @@
"node": ">=0.10.0"
}
},
- "node_modules/deprecation": {
- "version": "2.3.1",
- "resolved": "https://registry.npmjs.org/deprecation/-/deprecation-2.3.1.tgz",
- "integrity": "sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==",
- "dev": true
- },
"node_modules/detect-newline": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/detect-newline/-/detect-newline-3.1.0.tgz",
@@ -6302,9 +6294,9 @@
"dev": true
},
"node_modules/universal-user-agent": {
- "version": "6.0.1",
- "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-6.0.1.tgz",
- "integrity": "sha512-yCzhz6FN2wU1NiiQRogkTQszlQSlpWaw8SvVegAc+bDxbzHgh1vX8uIe8OYyMH6DwH+sdTJsgMl36+mSMdRJIQ==",
+ "version": "7.0.2",
+ "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.2.tgz",
+ "integrity": "sha512-0JCqzSKnStlRRQfCdowvqy3cy0Dvtlb8xecj/H8JFZuCze4rwjPZQOgvFvn0Ws/usCHQFGpyr+pB9adaGwXn4Q==",
"dev": true
},
"node_modules/update-browserslist-db": {
diff --git a/package.json b/package.json
index bdf9aba..cb85656 100644
--- a/package.json
+++ b/package.json
@@ -3,18 +3,18 @@
"publishConfig": {
"access": "public"
},
+ "type": "module",
"version": "0.0.0-development",
"description": "Octokit plugin to paginate GraphQL API endpoint responses",
- "main": "index.js",
"scripts": {
"build": "node scripts/build.mjs && tsc -p tsconfig.json",
"lint": "prettier --check '{src,test}/**/*' README.md package.json",
"lint:fix": "prettier --write '{src,test}/**/*' README.md package.json",
"pretest": "npm run -s lint",
- "test": "jest --coverage",
+ "test": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --coverage",
"test:typescript": "npx tsc --noEmit --declaration --noUnusedLocals --esModuleInterop --strict test/typescript-validate.ts",
- "test:watch": "jest --watch",
- "test:e2e": "jest --testRegex test/*.e2e.ts"
+ "test:watch": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --watch",
+ "test:e2e": "NODE_OPTIONS=\"$NODE_OPTIONS --experimental-vm-modules\" npx jest --testRegex test/*.e2e.ts"
},
"repository": "github:octokit/plugin-paginate-graphql.js",
"keywords": [
@@ -25,12 +25,12 @@
],
"license": "MIT",
"peerDependencies": {
- "@octokit/core": ">=5"
+ "@octokit/core": ">=6"
},
"devDependencies": {
- "@octokit/core": "^5.0.0",
- "@octokit/plugin-rest-endpoint-methods": "^10.0.0",
- "@octokit/tsconfig": "^2.0.0",
+ "@octokit/core": "^6.0.0",
+ "@octokit/plugin-rest-endpoint-methods": "^11.0.0",
+ "@octokit/tsconfig": "^3.0.0",
"@types/fetch-mock": "^7.3.1",
"@types/jest": "^29.0.0",
"@types/node": "^20.0.0",
@@ -46,11 +46,15 @@
},
"jest": {
"preset": "ts-jest",
+ "extensionsToTreatAsEsm": [
+ ".ts"
+ ],
"transform": {
"^.+\\.(ts|tsx)$": [
"ts-jest",
{
- "tsconfig": "test/tsconfig.test.json"
+ "tsconfig": "test/tsconfig.test.json",
+ "useESM": true
}
]
},
@@ -64,6 +68,9 @@
"functions": 100,
"lines": 100
}
+ },
+ "moduleNameMapper": {
+ "^(.+)\\.jsx?$": "$1"
}
},
"release": {
diff --git a/scripts/build.mjs b/scripts/build.mjs
index 67f82f1..7cc375e 100644
--- a/scripts/build.mjs
+++ b/scripts/build.mjs
@@ -75,9 +75,13 @@ async function main() {
...pkg,
files: ["dist-*/**", "bin/**"],
main: "dist-node/index.js",
- browser: "dist-web/index.js",
types: "dist-types/index.d.ts",
- module: "dist-src/index.js",
+ exports: {
+ ".": {
+ types: "./dist-types/index.d.ts",
+ import: "./dist-node/index.js",
+ }
+ },
sideEffects: false,
},
null,
diff --git a/src/errors.ts b/src/errors.ts
index cf56d2e..63125dd 100644
--- a/src/errors.ts
+++ b/src/errors.ts
@@ -1,4 +1,4 @@
-import type { CursorValue, PageInfoContext } from "./page-info";
+import type { CursorValue, PageInfoContext } from "./page-info.js";
// Todo: Add link to explanation
const generateMessage = (path: string[], cursorValue: CursorValue): string =>
diff --git a/src/extract-page-info.ts b/src/extract-page-info.ts
index bf36172..b5a6060 100644
--- a/src/extract-page-info.ts
+++ b/src/extract-page-info.ts
@@ -1,5 +1,5 @@
-import type { PageInfoContext } from "./page-info";
-import { findPaginatedResourcePath, get } from "./object-helpers";
+import type { PageInfoContext } from "./page-info.js";
+import { findPaginatedResourcePath, get } from "./object-helpers.js";
const extractPageInfos = (responseData: any): PageInfoContext => {
const pageInfoPath = findPaginatedResourcePath(responseData);
diff --git a/src/index.ts b/src/index.ts
index 9be4bcd..3646d0b 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -1,7 +1,7 @@
-import { Octokit } from "@octokit/core";
-import { createIterator } from "./iterator";
-import { createPaginate } from "./paginate";
-export type { PageInfoForward, PageInfoBackward } from "./page-info";
+import type { Octokit } from "@octokit/core";
+import { createIterator } from "./iterator.js";
+import { createPaginate } from "./paginate.js";
+export type { PageInfoForward, PageInfoBackward } from "./page-info.js";
export function paginateGraphQL(octokit: Octokit) {
octokit.graphql;
diff --git a/src/iterator.ts b/src/iterator.ts
index fdd9f4b..643ee09 100644
--- a/src/iterator.ts
+++ b/src/iterator.ts
@@ -1,7 +1,7 @@
-import { extractPageInfos } from "./extract-page-info";
-import { Octokit } from "@octokit/core";
-import { getCursorFrom, hasAnotherPage } from "./page-info";
-import { MissingCursorChange } from "./errors";
+import { extractPageInfos } from "./extract-page-info.js";
+import type { Octokit } from "@octokit/core";
+import { getCursorFrom, hasAnotherPage } from "./page-info.js";
+import { MissingCursorChange } from "./errors.js";
const createIterator = (octokit: Octokit) => {
return (
diff --git a/src/merge-responses.ts b/src/merge-responses.ts
index d2a3ae2..479a8f7 100644
--- a/src/merge-responses.ts
+++ b/src/merge-responses.ts
@@ -1,4 +1,4 @@
-import { findPaginatedResourcePath, get, set } from "./object-helpers";
+import { findPaginatedResourcePath, get, set } from "./object-helpers.js";
const mergeResponses = (
response1: ResponseType,
diff --git a/src/object-helpers.ts b/src/object-helpers.ts
index d6b6f13..8c9714d 100644
--- a/src/object-helpers.ts
+++ b/src/object-helpers.ts
@@ -1,4 +1,4 @@
-import { MissingPageInfo } from "./errors";
+import { MissingPageInfo } from "./errors.js";
const isObject = (value: any) =>
Object.prototype.toString.call(value) === "[object Object]";
diff --git a/src/paginate.ts b/src/paginate.ts
index 5c4f930..36d2c8c 100644
--- a/src/paginate.ts
+++ b/src/paginate.ts
@@ -1,6 +1,6 @@
-import { Octokit } from "@octokit/core";
-import { mergeResponses } from "./merge-responses";
-import { createIterator } from "./iterator";
+import type { Octokit } from "@octokit/core";
+import { mergeResponses } from "./merge-responses.js";
+import { createIterator } from "./iterator.js";
const createPaginate = (octokit: Octokit) => {
const iterator = createIterator(octokit);
diff --git a/test/extract-page-infos.test.ts b/test/extract-page-infos.test.ts
index 9320d49..2963a09 100644
--- a/test/extract-page-infos.test.ts
+++ b/test/extract-page-infos.test.ts
@@ -1,5 +1,5 @@
-import { extractPageInfos } from "../src/extract-page-info";
-import { PageInfoContext } from "../src/page-info";
+import { extractPageInfos } from "../src/extract-page-info.js";
+import type { PageInfoContext } from "../src/page-info.js";
describe("extractPageInfos()", (): void => {
it("returns throws if no pageInfo object exists", async (): Promise => {
diff --git a/test/merge-responses.test.ts b/test/merge-responses.test.ts
index bb20468..956d25b 100644
--- a/test/merge-responses.test.ts
+++ b/test/merge-responses.test.ts
@@ -1,4 +1,4 @@
-import { mergeResponses } from "../src/merge-responses";
+import { mergeResponses } from "../src/merge-responses.js";
describe(".mergeResponses()", (): void => {
it('merges the "nodes" array of a response if it exists.', async (): Promise => {
diff --git a/test/paginate-graphql.e2e.ts b/test/paginate-graphql.e2e.ts
index fb67e50..508c935 100644
--- a/test/paginate-graphql.e2e.ts
+++ b/test/paginate-graphql.e2e.ts
@@ -1,5 +1,5 @@
import { Octokit } from "@octokit/core";
-import { paginateGraphQL } from "../src";
+import { paginateGraphQL } from "../src/index.js";
const PatchedOctokit = Octokit.plugin(paginateGraphQL);
diff --git a/test/paginate.test.ts b/test/paginate.test.ts
index 26ef8f0..86b308d 100644
--- a/test/paginate.test.ts
+++ b/test/paginate.test.ts
@@ -1,11 +1,11 @@
import fetchMock from "fetch-mock";
-import { MissingCursorChange, MissingPageInfo } from "../src/errors";
-import { PageInfo } from "../src/page-info";
-import { MockOctokit, PatchedOctokit } from "./testHelpers/mock-octokit";
+import { MissingCursorChange, MissingPageInfo } from "../src/errors.js";
+import type { PageInfo } from "../src/page-info.js";
+import { MockOctokit, PatchedOctokit } from "./testHelpers/mock-octokit.js";
import {
createResponsePages,
- TestResponseType,
-} from "./testHelpers/mock-response";
+ type TestResponseType,
+} from "./testHelpers/mock-response.js";
describe("pagination", () => {
it(".paginate() returns the response data if only one page exists.", async (): Promise => {
diff --git a/test/testHelpers/mock-octokit.ts b/test/testHelpers/mock-octokit.ts
index 3a13cd4..bd01b41 100644
--- a/test/testHelpers/mock-octokit.ts
+++ b/test/testHelpers/mock-octokit.ts
@@ -1,5 +1,5 @@
import { Octokit } from "@octokit/core";
-import { paginateGraphQL } from "../../src/index";
+import { paginateGraphQL } from "../../src/index.js";
import fetchMock from "fetch-mock";
const PatchedOctokit = Octokit.plugin(paginateGraphQL);
diff --git a/test/testHelpers/mock-response.ts b/test/testHelpers/mock-response.ts
index 8bb4138..64ce21f 100644
--- a/test/testHelpers/mock-response.ts
+++ b/test/testHelpers/mock-response.ts
@@ -1,4 +1,4 @@
-import { PageInfo } from "../../src/page-info";
+import type { PageInfo } from "../../src/page-info.js";
type TestResponseType = {
repository: {
diff --git a/test/tsconfig.test.json b/test/tsconfig.test.json
index b0961e1..fe99a4e 100644
--- a/test/tsconfig.test.json
+++ b/test/tsconfig.test.json
@@ -2,8 +2,7 @@
"extends": "../tsconfig.json",
"compilerOptions": {
"emitDeclarationOnly": false,
- "noEmit": true,
- "verbatimModuleSyntax": false
+ "noEmit": true
},
"include": ["src/**/*"]
}
diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts
index 6cb73ac..c7f6398 100644
--- a/test/typescript-validate.ts
+++ b/test/typescript-validate.ts
@@ -3,8 +3,12 @@
// ************************************************************
import { Octokit } from "@octokit/core";
-import { paginateGraphQL, PageInfoBackward, PageInfoForward } from "../src";
-import { TestResponseType } from "./testHelpers/mock-response";
+import {
+ paginateGraphQL,
+ PageInfoBackward,
+ PageInfoForward,
+} from "../src/index.js";
+import { TestResponseType } from "./testHelpers/mock-response.js";
const MyOctokit = Octokit.plugin(paginateGraphQL);
const octokit = new MyOctokit();
From 9841aaff28dc5f3608e135bf1d8092b920b95f52 Mon Sep 17 00:00:00 2001
From: wolfy1339
Date: Mon, 4 Mar 2024 14:05:07 -0500
Subject: [PATCH 3/3] fix: add return type annotation
---
src/index.ts | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/index.ts b/src/index.ts
index 3646d0b..1f78317 100644
--- a/src/index.ts
+++ b/src/index.ts
@@ -3,8 +3,15 @@ import { createIterator } from "./iterator.js";
import { createPaginate } from "./paginate.js";
export type { PageInfoForward, PageInfoBackward } from "./page-info.js";
-export function paginateGraphQL(octokit: Octokit) {
- octokit.graphql;
+type paginateGraphQLInterface = {
+ graphql: Octokit["graphql"] & {
+ paginate: ReturnType & {
+ iterator: ReturnType;
+ };
+ };
+};
+
+export function paginateGraphQL(octokit: Octokit): paginateGraphQLInterface {
return {
graphql: Object.assign(octokit.graphql, {
paginate: Object.assign(createPaginate(octokit), {