{"_id":"@ataylorme/ghec-openapi-fetch-client","name":"@ataylorme/ghec-openapi-fetch-client","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"@ataylorme/ghec-openapi-fetch-client","description":"An openapi-fetch client for the GitHub Enterprise Cloud REST API generated from GitHub's REST API OpenAPI Description","type":"module","version":"1.0.0","license":"MIT","author":{"name":"Andrew Taylor"},"repository":{"type":"git","url":"git+https://github.com/ataylorme/ghec-openapi-fetch-client.git"},"publishConfig":{"access":"public"},"scripts":{"biome":"biome check --write","lint":"npm run biome","test":"vitest","prebuild":"npm run generate:types","build":"tsup","download:openapi-spec":"curl -o ./src/lib/ghec/api/openapi-spec.yaml https://raw.githubusercontent.com/github/rest-api-description/refs/heads/main/descriptions/ghec/ghec.2022-11-28.yaml","pregenerate:types":"npm run download:openapi-spec","generate:types":"openapi-typescript ./src/lib/ghec/api/openapi-spec.yaml -o ./src/lib/ghec/api/types/v1.d.ts","prepare":"husky","check-exports":"attw --profile node16 --pack . --ignore-rules=cjs-resolves-to-esm","changeset:version":"changeset version","changeset:publish":"changeset publish","local-release":"npm run changeset:version && npm run changeset:publish","prepublishOnly":"npm run build"},"exports":{"./package.json":"./package.json",".":{"import":"./dist/index.js","default":"./dist/index.cjs"}},"engines":{"node":">=22"},"dependencies":{"openapi-fetch":"^0.13.4"},"devDependencies":{"@arethetypeswrong/cli":"^0.17.4","@biomejs/biome":"1.9.4","@changesets/cli":"^2.28.1","husky":"^9.1.7","openapi-typescript":"^7.5.2","tsup":"^8.4.0","typescript":"^5.7.3","vitest":"^3.0.8"},"_id":"@ataylorme/ghec-openapi-fetch-client@1.0.0","gitHead":"beb19398871c7474ab659b0b92ed4e5658cc4911","bugs":{"url":"https://github.com/ataylorme/ghec-openapi-fetch-client/issues"},"homepage":"https://github.com/ataylorme/ghec-openapi-fetch-client#readme","_nodeVersion":"22.9.0","_npmVersion":"10.8.3","dist":{"integrity":"sha512-STO3DlPo1xEImZ3pvSfwT9NG8xSmBiWnPi9nT4bG9a8Ul870spK2QqRIL6Bbp6rMgEJ4P5JTro1fqaIHTAOhCg==","shasum":"f5545d4776ca6ec05be3d5e29d0c2e864db92b04","tarball":"https://registry.npmjs.org/@ataylorme/ghec-openapi-fetch-client/-/ghec-openapi-fetch-client-1.0.0.tgz","fileCount":7,"unpackedSize":12026932,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCICHNw3GdEIOfasjPzqsg+1dRXIu+LOJColokxakfKy1QAiALTg/c2Ob2RSJqdaFRB+nKfgX8szbSGJ5YeOVHv3wFhA=="}]},"_npmUser":{"name":"ataylorme","email":"andrew@ataylor.me"},"directories":{},"maintainers":[{"name":"ataylorme","email":"andrew@ataylor.me"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ghec-openapi-fetch-client_1.0.0_1741293979976_0.48877963604568087"},"_hasShrinkwrap":false}},"time":{"created":"2025-03-06T20:46:19.910Z","1.0.0":"2025-03-06T20:46:20.240Z","modified":"2025-03-06T20:46:20.453Z"},"maintainers":[{"name":"ataylorme","email":"andrew@ataylor.me"}],"description":"An openapi-fetch client for the GitHub Enterprise Cloud REST API generated from GitHub's REST API OpenAPI Description","homepage":"https://github.com/ataylorme/ghec-openapi-fetch-client#readme","repository":{"type":"git","url":"git+https://github.com/ataylorme/ghec-openapi-fetch-client.git"},"author":{"name":"Andrew Taylor"},"bugs":{"url":"https://github.com/ataylorme/ghec-openapi-fetch-client/issues"},"license":"MIT","readme":"# ghec-openapi-fetch-client\n\n[An openapi-fetch client](https://openapi-ts.dev/openapi-fetch) for the GitHub\nEnterprise Cloud REST API generated from\n[GitHub's REST API OpenAPI Description](https://github.com/github/rest-api-description/)\n\n## Why not octokit?\n\nOctokit doesn't have TypeScript types for GitHub Enterprise Cloud. See [this issue](https://github.com/octokit/types.ts/issues/522) as an example.\n\n## Usage\nFor public API calls the client can be used as-is.\n\n```ts\nimport client from \"@ataylorme/ghec-openapi-fetch-client\";\n\nconst { data: helloWorldRepo, error: errorResponse } = await client.GET(\"/repos/{owner}/{repo}\", {\n  params: {\n    path: { owner: \"octocat\", repo: \"Hello-World\" },\n  }\n});\n```\n\n\n## Authentication\n\nFor authenticated API calls, there are 2 options:\n\n### 1) attach an [authentication middleware to the client](https://openapi-ts.dev/openapi-fetch/middleware-auth#basic-auth).\n\n```ts\nimport { type Middleware } from \"openapi-fetch\";\nimport client from \"@ataylorme/ghec-openapi-fetch-client\";\n\n// logic to get a GitHub token here\nconst ghToken: string = \"\";\n\n// Create a middleware to add an Authorization header to every request\n// https://openapi-ts.dev/openapi-fetch/middleware-auth\nconst authMiddleware: Middleware = {\n  async onRequest({ request }) {\n    // https://docs.github.com/en/enterprise-cloud@latest/rest/authentication/authenticating-to-the-rest-api?apiVersion=2022-11-28\n    request.headers.set(\"Authorization\", `Bearer ${ghToken}`);\n    return request;\n  },\n};\n\nclient.use(authMiddleware);\n\nconst { data: currentUser, error: errorResponse } = await client.GET(\"/user\");\n\n// (optional) eject the authentication middleware\nclient.eject(authMiddleware);\n```\n\n### 2) send an auth header for a single request\n\n```ts\nimport client from \"@ataylorme/ghec-openapi-fetch-client\";\n\n// logic to get a GitHub token here\nconst ghToken: string = \"\";\n\nconst { data: currentUser, error: errorResponse } = await client.GET(\n  \"/user\",\n  {\n    // https://docs.github.com/en/enterprise-cloud@latest/rest/authentication/authenticating-to-the-rest-api?apiVersion=2022-11-28\n    // add an Authorization header to this request only\n    headers: {\n      Authorization: `Bearer ${ghToken}`,\n    },\n  },\n);\n```\n\n## Pagination\n\n```ts\nimport client, {paginationMiddleware} from \"@ataylorme/ghec-openapi-fetch-client\";\n\n// attach the paginaton middleware\nclient.use(paginationMiddleware);\n\n// make an API call to a paginated endpoint\nconst { data: reposResponse, error: errorResponse } = await client.GET(\n  \"/orgs/{org}/repos\",\n  {\n    params: {\n      path: { org: \"octokit\" },\n      query: {\n        // per_page: 100,\n      },\n    },\n  },\n);\n\n// (optional) eject the pagination middleware\nclient.eject(paginationMiddleware);\n```","readmeFilename":"README.md","_rev":"1-dbe2eec14f5c9a0e5f1d166a5fe90ad2"}