diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml new file mode 100644 index 0000000000..ccb5214668 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.yml @@ -0,0 +1,41 @@ +name: Bug +description: File a bug report +title: "[BUG]: " +labels: ["Type: Bug", "Status: Triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill out this bug report! + - type: textarea + id: what-happened + attributes: + label: What happened? + description: What did you do? What happened? What did you expect to happen? + placeholder: Put your description of the bug here. + validations: + required: true + - type: textarea + id: versions + attributes: + label: Versions + description: What versions of the relevant software are you running? + placeholder: Octokit.js v2.0.10, Node v16.18.0 + validations: + required: true + - type: textarea + id: logs + attributes: + label: Relevant log output + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Please check your logs before submission to ensure sensitive information is redacted. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/documentation.yml b/.github/ISSUE_TEMPLATE/documentation.yml new file mode 100644 index 0000000000..64c1fc0754 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/documentation.yml @@ -0,0 +1,49 @@ +name: Documentation +description: Update or add documentation +title: "[DOCS]: " +labels: ["Type: Documentation", "Status: Triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill this out! + - type: textarea + id: describe-need + attributes: + label: Describe the need + description: What do you wish was different about our docs? + placeholder: Describe the need for documentation updates here. + validations: + required: true + - type: input + id: sdk_version + attributes: + label: SDK Version + description: Do these docs apply to a specific SDK version? + placeholder: Octokit.NET v4.0.1 + validations: + required: false + - type: input + id: api_version + attributes: + label: API Version + description: Do these docs apply to a specific version of the GitHub REST API or GraphQL API? + placeholder: ex. v1.1.1 + validations: + required: false + - type: textarea + id: logs + attributes: + label: Relevant log output + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Please check your logs before submission to ensure sensitive information is redacted. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/feature.yml b/.github/ISSUE_TEMPLATE/feature.yml new file mode 100644 index 0000000000..453cdfda4e --- /dev/null +++ b/.github/ISSUE_TEMPLATE/feature.yml @@ -0,0 +1,49 @@ +name: Feature +description: Suggest an idea for a new feature or enhancement +title: "[FEAT]: " +labels: ["Type: Feature", "Status: Triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill this out! + - type: textarea + id: describe-need + attributes: + label: Describe the need + description: What do you want to happen? What problem are you trying to solve? + placeholder: Describe the need for the feature. + validations: + required: true + - type: input + id: sdk_version + attributes: + label: SDK Version + description: Does this feature suggestion apply to a specific SDK version? + placeholder: Octokit.rb v6.0.0 + validations: + required: false + - type: input + id: api_version + attributes: + label: API Version + description: Does this feature suggestion apply to a specific version of the GitHub REST API or GraphQL API? + placeholder: ex. v1.1.1 + validations: + required: false + - type: textarea + id: logs + attributes: + label: Relevant log output + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Please check your logs before submission to ensure sensitive information is redacted. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/ISSUE_TEMPLATE/maintenance.yml b/.github/ISSUE_TEMPLATE/maintenance.yml new file mode 100644 index 0000000000..0c5221e2c1 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/maintenance.yml @@ -0,0 +1,49 @@ +name: Maintenance +description: Dependencies, cleanup, refactoring, reworking of code +title: "[MAINT]: " +labels: ["Type: Maintenance", "Status: Triage"] +body: + - type: markdown + attributes: + value: | + Thanks for taking the time to fill this out! + - type: textarea + id: describe-need + attributes: + label: Describe the need + description: What do you want to happen? + placeholder: Describe the maintenance need here. + validations: + required: true + - type: input + id: sdk_version + attributes: + label: SDK Version + description: Does this maintenance apply to a specific SDK version? + placeholder: terraform-provider-github v5.7.0 + validations: + required: false + - type: input + id: api_version + attributes: + label: API Version + description: Does this maintenance apply to a specific version of the GitHub REST API or GraphQL API? + placeholder: ex. v1.1.1 + validations: + required: false + - type: textarea + id: logs + attributes: + label: Relevant log output + description: | + Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks. + Please check your logs before submission to ensure sensitive information is redacted. + render: shell + - type: checkboxes + id: terms + attributes: + label: Code of Conduct + description: By submitting this issue, you agree to follow our [Code of Conduct](CODE_OF_CONDUCT.md) + options: + - label: I agree to follow this project's Code of Conduct + required: true diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md new file mode 100644 index 0000000000..0aa1f03b63 --- /dev/null +++ b/.github/pull_request_template.md @@ -0,0 +1,30 @@ + + +Resolves #ISSUE_NUMBER + +---- + +### Before the change? + + +* + +### After the change? + + +* + +### Pull request checklist +- [ ] Tests for the changes have been added (for bug fixes / features) +- [ ] Docs have been reviewed and added / updated if needed (for bug fixes / features) + +### Does this introduce a breaking change? + + +Please see our docs on [breaking changes](https://github.com/octokit/.github/blob/master/community/breaking_changes.md) to help! + +- [ ] Yes +- [ ] No + +---- + diff --git a/.github/renovate.json b/.github/renovate.json new file mode 100644 index 0000000000..dd7a80645d --- /dev/null +++ b/.github/renovate.json @@ -0,0 +1,5 @@ +{ + "extends": [ + "github>octokit/.github" + ] +} diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml new file mode 100644 index 0000000000..8621996e47 --- /dev/null +++ b/.github/workflows/add_to_octokit_project.yml @@ -0,0 +1,20 @@ +name: Add PRs and issues to Octokit org project + +on: + issues: + types: [reopened, opened] + pull_request_target: + types: [reopened, opened] + +jobs: + add-to-project: + name: Add issue to project + runs-on: ubuntu-latest + continue-on-error: true + steps: + - uses: actions/add-to-project@v1.0.2 + with: + project-url: https://github.com/orgs/octokit/projects/10 + github-token: ${{ secrets.OCTOKITBOT_PROJECT_ACTION_TOKEN }} + labeled: "Status: Stale" + label-operator: NOT diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml new file mode 100644 index 0000000000..59d7753d2f --- /dev/null +++ b/.github/workflows/codeql.yml @@ -0,0 +1,41 @@ +name: "CodeQL" + +on: + push: + branches: [ "main", beta ] + pull_request: + # The branches below must be a subset of the branches above + branches: [ "main" ] + schedule: + - cron: '19 5 * * 1' + +jobs: + analyze: + name: Analyze + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + security-events: write + + strategy: + fail-fast: false + matrix: + language: [ 'javascript' ] + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: ${{ matrix.language }} + + - name: Autobuild + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 + with: + category: "/language:${{matrix.language}}" diff --git a/.github/workflows/immediate-response.yml b/.github/workflows/immediate-response.yml new file mode 100644 index 0000000000..8a29b200fc --- /dev/null +++ b/.github/workflows/immediate-response.yml @@ -0,0 +1,29 @@ +name: Issue/PR response +permissions: + issues: write + pull-requests: write +on: + issues: + types: + - opened + pull_request_target: + types: + - opened +jobs: + respond-to-issue: + if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'renovate[bot]' && github.actor != 'githubactions[bot]' && github.actor != 'octokitbot' }} + runs-on: ubuntu-latest + steps: + - name: Determine issue or PR number + id: extract + run: echo "NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}" >> "$GITHUB_OUTPUT" + + - name: Respond to issue or PR + uses: peter-evans/create-or-update-comment@v4 + with: + issue-number: ${{ steps.extract.outputs.NUMBER }} + body: > + 👋 Hi! Thank you for this contribution! Just to let you know, our GitHub SDK team does a round of issue and PR reviews twice a week, every Monday and Friday! + We have a [process in place](https://github.com/octokit/.github/blob/main/community/prioritization_response.md#overview) for prioritizing and responding to your input. + Because you are a part of this community please feel free to comment, add to, or pick up any issues/PRs that are labeled with `Status: Up for grabs`. + You & others like you are the reason all of this works! So thank you & happy coding! 🚀 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000000..412df7b5af --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,32 @@ +name: Release +"on": + push: + branches: + - main + - next + - beta + - "*.x" + - debug +# These are recommended by the semantic-release docs: https://github.com/semantic-release/npm#npm-provenance +permissions: + contents: write # to be able to publish a GitHub release + issues: write # to be able to comment on released issues + pull-requests: write # to be able to comment on released pull requests + id-token: write # to enable use of OIDC for npm provenance + +jobs: + release: + name: release + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: lts/* + cache: npm + - run: npm ci + - run: npm run build + - run: npx semantic-release + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NPM_TOKEN: ${{ secrets.OCTOKITBOT_NPM_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000000..41d839506e --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,43 @@ +name: Test +"on": + push: + branches: + - main + pull_request: + types: + - opened + - synchronize +jobs: + test_matrix: + runs-on: ubuntu-latest + strategy: + matrix: + node_version: + - 18 + - 20 + - 22 + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node_version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node_version }} + cache: npm + - run: npm ci + - run: npm test + test: + runs-on: ubuntu-latest + needs: test_matrix + steps: + - run: exit 1 + if: ${{ needs.test_matrix.result != 'success' }} + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: "lts/*" + cache: npm + - run: npm ci + - run: npm run test:typescript + - run: npm run lint + - run: npm run build + if: ${{ always() }} diff --git a/.github/workflows/update-prettier.yml b/.github/workflows/update-prettier.yml new file mode 100644 index 0000000000..951bc7d7e7 --- /dev/null +++ b/.github/workflows/update-prettier.yml @@ -0,0 +1,25 @@ +name: Update Prettier +"on": + push: + branches: + - renovate/prettier-* + workflow_dispatch: {} +jobs: + update_prettier: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + cache: npm + node-version: 16 + - run: npm ci + - run: npm run lint:fix + - uses: gr2m/create-or-update-pull-request-action@v1.x + env: + GITHUB_TOKEN: ${{ secrets.OCTOKITBOT_PAT }} + with: + title: Prettier updated + body: An update to prettier required updates to your code. + branch: ${{ github.ref }} + commit-message: "style: prettier" diff --git a/.gitignore b/.gitignore index 7f913291a6..59ef6c06c5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,4 @@ -.DS_Store -0.0.1.seed -node_modules -.settings.xml -.settings -.c9revisions -/nbproject/private/ \ No newline at end of file +coverage/ +node_modules/ +pkg/ +.idea/ diff --git a/.npmignore b/.npmignore deleted file mode 100644 index 988771c171..0000000000 --- a/.npmignore +++ /dev/null @@ -1,5 +0,0 @@ -.settings.xml -.settings -.c9revisions -doc/ -node_modules/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..42366f02cb --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,74 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +nationality, personal appearance, race, religion, or sexual identity and +orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +- Using welcoming and inclusive language +- Being respectful of differing viewpoints and experiences +- Gracefully accepting constructive criticism +- Focusing on what is best for the community +- Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +- The use of sexualized language or imagery and unwelcome sexual attention or + advances +- Trolling, insulting/derogatory comments, and personal or political attacks +- Public or private harassment +- Publishing others' private information, such as a physical or electronic + address, without explicit permission +- Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at opensource+octokit@github.com. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at [https://contributor-covenant.org/version/1/4][version] + +[homepage]: https://contributor-covenant.org +[version]: https://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..13417cbd9d --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,56 @@ +# How to contribute + +Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). +By participating in this project you agree to abide by its terms. + +We appreciate you taking the time to contribute to `octokit` or any of the projects in Octokit's ecosystem. Especially as a new contributor, you have a valuable perspective that we lost a long time ago: you will find things confusing and run into problems that no longer occur to us. Please share them with us, so we can make the experience for future contributors the best it could be. + +Thank you 💖 + +## Creating an Issue + +Before you create a new Issue: + +1. Please make sure there is no open issue in the **Issues Section** of the repository you are working on yet. i.e. +2. If it is a bug report, include the steps to reproduce the issue, and please create a reproducible test case on [runkit.com](https://runkit.com/). Example: +3. If it is a feature request, please share the motivation for the new feature, what alternatives you tried, and how you would implement it. +4. Please include links to the corresponding GitHub documentation. + +## Set up the repository locally + +First, fork the repository. + +Set up the repository locally. Replace `` with the name of the account you forked to and `` with the repository name you forked. + +```shell +git clone https://github.com//.git +cd +npm install +``` + +Run the tests before making changes to make sure the local setup is working as expected + +```shell +npm test +``` + +## Submitting the Pull Request + +- Create a new branch locally. +- Make your changes in that branch and push them to your fork +- Submit a pull request from your topic branch to the main branch on the `octokit/` repository. +- Be sure to tag any issues your pull request is taking care of / contributing to. Adding "Closes #123" to a pull request description will automatically close the issue once the pull request is merged in. + +## Testing a pull request from GitHub repo locally + +You can install `@octokit/` from each pull request. Replace `[PULL REQUEST NUMBER]`: + +``` +npm install https://github.pika.dev/octokit//pr/[PULL REQUEST NUMBER] +``` + +Once you are done testing, you can revert to the default module `@octokit/` from npm with `npm install @octokit/` + +## Maintainers + +See [MAINTAINING.md](MAINTAINING.md) diff --git a/LICENSE b/LICENSE index 277d0573da..e0b76da6b9 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2012 Cloud9 IDE, Inc. (Mike de Boer) +Copyright (c) 2023 Octokit contributors Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/MAINTAINING.md b/MAINTAINING.md new file mode 100644 index 0000000000..75c7971e18 --- /dev/null +++ b/MAINTAINING.md @@ -0,0 +1,110 @@ +# Maintenance releases + +## Merging the Pull Request & releasing a new version + +Releases are automated using [semantic-release](https://github.com/semantic-release/semantic-release). +The following commit message conventions determine which version is released: + +1. `fix: ...` or `fix(scope name): ...` prefix in subject: bumps fix version, e.g. `1.2.3` → `1.2.4` +2. `feat: ...` or `feat(scope name): ...` prefix in subject: bumps feature version, e.g. `1.2.3` → `1.3.0` +3. `BREAKING CHANGE:` in body: bumps breaking version, e.g. `1.2.3` → `2.0.0` + +Only one version number is bumped at a time, the highest version change trumps the others. +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. + +If the pull request looks good but does not follow the commit conventions, use the Squash & merge button. + +> ⚠️ making sure the message is semantic-release compliant before clicking Confirm squash and merge: + +![Screenshot of GitHub's Squash and Merge confirm dialog](assets/squash-and-merge-dialog.png)] + +## Breaking changes + +When merging a breaking change using the PR body as specified above, extra care must be taken. Breaking changes must first be merged into the `beta` branch, where further testing may be conducted and additional breaking changes may be combined before cutting a release. The `beta` branch should be created for this purpose and based on `main`. Once the first commit to the branch is landed, a draft PR should be created from `beta` to `main` with the title vX, where X is the next major version. After changes are combined and tested, mark the PR as ready for review, get it reviewed, and merge the `beta` branch into `main` as documented above. `beta` branches are intended to be short-lived. + +Note the repository for the change: if it's dependent on other repos where the same change must be made, merge the leaf nodes first before the nodes higher up the tree. Your merge order should look something like: + +1. octokit/types (when type changes are required) +1. endpoint +1. request +1. plugins +1. auth strategies +1. core +1. \*-methods +1. oauth-app +1. webhooks +1. app +1. octokit/octokit.js +1. octokit/rest.js + +## Maintenance releases + +### 0. Requirements + +`semantic-release` is configured in the `package.json` of each repository. If `release.branches` is set, make sure that it includes the line for maintenance releases, for example + +```js + "release": { + "branches": [ + "+([0-9]).x", + "main", + "beta" + ], +``` + +`semantic-release` is run in the`.github/workflows/release.yml` GitHub Action workflow. Make sure it's triggered on push in the `*.x` release branches. + +```yml +name: Release +"on": + push: + branches: + - main + - next + - beta + - "*.x" +``` + +### 1. Create a branch for the maintenance version + +Find the latest version that was released on the maintenance version. For example, if the current version is 3.1, and you want to release maintenance versions for 2.x, then find the latest 2.x version. Say that's 2.10.9. In that example, create a branch based on this tag + +``` +git checkout -b 2.x v2.10.9 +``` + +Then push the new `2.x` branch to GitHub + +``` +git push -u origin HEAD +``` + +### 2. Create a pull request with the changes for the new maintenance release + +Checkout a branch based on the latest maintenance branch, for example + +``` +git checkout -b 2.x-my-fix 2.x +``` + +Commit your changes, then push the branch to GitHub and create a pull request with the maintenance branch as base. + +### 3. Merge the pull request with the correct commit message + +Note that maintenance versions only support `fix: ...` and `feat: ...` commits, no breaking versions can be released from a maintenance release. + +The `.github/workflows/release.yml` action should pick up the commit and release the correct version to both GitHub and npm. The npm release will use a `@release-*.x` tag so that the new release is not picked up as `@latest`. + +## Troubleshooting + +
+ What can I do if I squashed and merged with a commit message which is not semantic-release compliant? + +1. After merging, do a follow up on `https://github.com/octokit//actions/workflows/release.yml` to assure your commit is not triggering any release. You can find an example of a commit squashed and merged with a non semantic-release commit message [here](https://github.com/octokit/plugin-throttling.js/runs/5390685684?check_suite_focus=true) +2. Mention (`@username`) the maintainers of the project in your merged _Pull Request_ to let them know there was an issue with your merged _Pull Request_. We need to make sure no _Pull Request_ is merged until this issue is addressed. +3. Open a new _Pull Request_ with an [empty commit](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---allow-empty). In the description, link to the previous merged _Pull Request_ to give context to the reviewers and request a Review from the maintainers. This time make sure the message is [semantic-release](https://github.com/semantic-release/semantic-release) compliant. + +
diff --git a/README.md b/README.md index 378fdd4386..bdd5020e1c 100644 --- a/README.md +++ b/README.md @@ -1,173 +1,977 @@ -# JavaScript GitHub API for Node.JS +# octokit.js + +> The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno. + +The `octokit` package integrates the three main Octokit libraries + +1. **API client** (REST API requests, GraphQL API queries, Authentication) +2. **App client** (GitHub App & installations, Webhooks, OAuth) +3. **Action client** (Pre-authenticated API client for single repository) + +## Table of contents + + + +- [octokit.js](#octokitjs) + - [Features](#features) + - [Usage](#usage) + - [`Octokit` API Client](#octokit-api-client) + - [Constructor options](#constructor-options) + - [Authentication](#authentication) + - [Proxy Servers (Node.js only)](#proxy-servers-nodejs-only) + - [Fetch missing](#fetch-missing) + - [REST API](#rest-api) + - [`octokit.rest` endpoint methods](#octokitrest-endpoint-methods) + - [`octokit.request()`](#octokitrequest) + - [Pagination](#pagination) + - [Media Type formats](#media-type-formats) + - [Request error handling](#request-error-handling) + - [GraphQL API queries](#graphql-api-queries) + - [Pagination](#pagination-1) + - [Schema previews](#schema-previews) + - [App client](#app-client) + - [GitHub App](#github-app) + - [Webhooks](#webhooks) + - [OAuth](#oauth) + - [App Server](#app-server) + - [OAuth for browser apps](#oauth-for-browser-apps) + - [Action client](#action-client) + - [LICENSE](#license) + + + +## Features + +- **Complete**. All features of GitHub's platform APIs are covered. +- **Prescriptive**. All recommended best practices are implemented. +- **Universal**. Works in all modern browsers, [Node.js](https://nodejs.org/), and [Deno](https://deno.land/). +- **Tested**. All libraries have a 100% test coverage. +- **Typed**. All libraries have extensive TypeScript declarations. +- **Decomposable**. Use only the code you need. You can build your own Octokit in only a few lines of code or use the underlying static methods. Make your own tradeoff between functionality and bundle size. +- **Extendable**. A feature missing? Add functionalities with plugins, hook into the request or webhook lifecycle or implement your own authentication strategy. + +## Usage + + + + + + + +
+Browsers + +Load octokit directly from esm.sh + +```html + +``` -A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API. +
+Deno + +Load octokit directly from esm.sh + +```ts +import { Octokit, App } from "https://esm.sh/octokit?dts"; +``` -## Installation +
+Node + - Install with the Node.JS package manager [npm](http://npmjs.org/) ![NPM version](https://badge.fury.io/js/github.svg): +Install with npm/pnpm install octokit, or yarn add octokit - $ npm install github +```js +import { Octokit, App } from "octokit"; +``` -or +
- Install via git clone: +> [!IMPORTANT] +> As we use [conditional exports](https://nodejs.org/api/packages.html#conditional-exports), you will need to adapt your `tsconfig.json` by setting `"moduleResolution": "node16", "module": "node16"`. +> +> See the TypeScript docs on [package.json "exports"](https://www.typescriptlang.org/docs/handbook/modules/reference.html#packagejson-exports).
+> See this [helpful guide on transitioning to ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c) from [@sindresorhus](https://github.com/sindresorhus) - $ git clone git://github.com/mikedeboer/node-github.git - $ cd node-github - $ npm install +## `Octokit` API Client -## Documentation +**standalone minimal Octokit**: [`@octokit/core`](https://github.com/octokit/core.js/#readme). -You can find the docs for the API of this client at [http://mikedeboer.github.com/node-github/](http://mikedeboer.github.com/node-github/) +The `Octokit` client can be used to send requests to [GitHub's REST API](https://docs.github.com/rest/) and queries to [GitHub's GraphQL API](https://docs.github.com/graphql). -Additionally, the [official Github documentation](https://developer.github.com/v3/) -is a very useful resource. +**Example**: Get the username for the authenticated user. -## Example +```js +// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo +const octokit = new Octokit({ auth: `personal-access-token123` }); -Print all followers of the user "mikedeboer" to the console. -```javascript -var GitHubApi = require("github"); +// Compare: https://docs.github.com/en/rest/reference/users#get-the-authenticated-user +const { + data: { login }, +} = await octokit.rest.users.getAuthenticated(); +console.log("Hello, %s", login); +``` -var github = new GitHubApi({ - // required - version: "3.0.0", - // optional - debug: true, - protocol: "https", - host: "github.my-GHE-enabled-company.com", // should be api.github.com for GitHub - pathPrefix: "/api/v3", // for some GHEs; none for GitHub - timeout: 5000, - headers: { - "user-agent": "My-Cool-GitHub-App" // GitHub is happy with a unique user agent +### Constructor options + +The most commonly used options are + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ name + + type + + description +
+ userAgent + + String + + +Setting a user agent is required for all requests sent to GitHub's Platform APIs. The user agent defaults to something like this: `octokit.js/v1.2.3 Node.js/v8.9.4 (macOS High Sierra; x64)`. It is recommend to set your own user agent, which will prepend the default one. + +```js +const octokit = new Octokit({ + userAgent: "my-app/v1.2.3", +}); +``` + +
+ authStrategy + + Function + + +Defaults to [`@octokit/auth-token`](https://github.com/octokit/auth-token.js#readme). + +See [Authentication](#authentication) below. + +
+ auth + + String or Object + + +Set to a [personal access token](https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token) unless you changed the `authStrategy` option. + +See [Authentication](#authentication) below. + +
+ baseUrl + + String + + +When using with GitHub Enterprise Server, set `options.baseUrl` to the root URL of the API. For example, if your GitHub Enterprise Server's hostname is `github.acme-inc.com`, then set `options.baseUrl` to `https://github.acme-inc.com/api/v3`. Example + +```js +const octokit = new Octokit({ + baseUrl: "https://github.acme-inc.com/api/v3", +}); +``` + +
+ +Advanced options + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ name + + type + + description +
+ request + + Object + + +- `request.signal`: Use an [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController) instance to cancel a request. [`abort-controller`](https://www.npmjs.com/package/abort-controller) is an implementation for Node. +- `request.fetch`: Replacement for [built-in fetch method](). + +Node only + +- `request.timeout` sets a request timeout, defaults to 0 + +The `request` option can also be set on a per-request basis. + +
+ timeZone + + String + + +Sets the `Time-Zone` header which defines a timezone according to the [list of names from the Olson database](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones). + +```js +const octokit = new Octokit({ + timeZone: "America/Los_Angeles", +}); +``` + +The time zone header will determine the timezone used for generating the timestamp when creating commits. See [GitHub's Timezones documentation](https://developer.github.com/v3/#timezones). + +
+ throttle + + Object + + +`Octokit` implements request throttling using [`@octokit/plugin-throttling`](https://github.com/octokit/plugin-throttling.js/#readme) + +By default, requests are retried once and warnings are logged in case of hitting a rate or secondary rate limit. + +```js +{ + onRateLimit: (retryAfter, options, octokit) => { + octokit.log.warn( + `Request quota exhausted for request ${options.method} ${options.url}` + ); + + if (options.request.retryCount === 0) { + // only retries once + octokit.log.info(`Retrying after ${retryAfter} seconds!`); + return true; + } + }, + onSecondaryRateLimit: (retryAfter, options, octokit) => { + octokit.log.warn( + `SecondaryRateLimit detected for request ${options.method} ${options.url}` + ); + + if (options.request.retryCount === 0) { + // only retries once + octokit.log.info(`Retrying after ${retryAfter} seconds!`); + return true; } + }, +}; +``` + +To opt-out of this feature: + +```js +new Octokit({ throttle: { enabled: false } }); +``` + +Throttling in a cluster is supported using a Redis backend. See [`@octokit/plugin-throttling` Clustering](https://github.com/octokit/plugin-throttling.js/#clustering) + +
+ retry + + Object + + +`Octokit` implements request retries using [`@octokit/plugin-retry`](https://github.com/octokit/plugin-retry.js/#readme) + +To opt-out of this feature: + +```js +new Octokit({ retry: { enabled: false } }); +``` + +
+ +### Authentication + +By default, the `Octokit` API client supports authentication using a static token. + +There are different means of authentication that are supported by GitHub, that are described in detail at [octokit/authentication-strategies.js](https://github.com/octokit/authentication-strategies.js/#readme). You can set each of them as the `authStrategy` constructor option, and pass the strategy options as the `auth` constructor option. + +For example, in order to authenticate as a GitHub App Installation: + +```js +import { createAppAuth } from "@octokit/auth-app"; +const octokit = new Octokit({ + authStrategy: createAppAuth, + auth: { + appId: 1, + privateKey: "-----BEGIN PRIVATE KEY-----\n...", + installationId: 123, + }, +}); + +// authenticates as app based on request URLs +const { + data: { slug }, +} = await octokit.rest.apps.getAuthenticated(); + +// creates an installation access token as needed +// assumes that installationId 123 belongs to @octocat, otherwise the request will fail +await octokit.rest.issues.create({ + owner: "octocat", + repo: "hello-world", + title: "Hello world from " + slug, +}); +``` + +You can use the [`App`](#github-app) or [`OAuthApp`](#oauth-app) SDKs which provide APIs and internal wiring to cover most use cases. + +For example, to implement the above using `App` + +```js +const app = new App({ appId, privateKey }); +const { data: slug } = await app.octokit.rest.apps.getAuthenticated(); +const octokit = await app.getInstallationOctokit(123); +await octokit.rest.issues.create({ + owner: "octocat", + repo: "hello-world", + title: "Hello world from " + slug, +}); +``` + +Learn more about [how authentication strategies work](https://github.com/octokit/authentication-strategies.js/#how-authentication-strategies-work) or how to [create your own](https://github.com/octokit/authentication-strategies.js/#create-your-own-octokit-authentication-strategy-module). + +### Proxy Servers (Node.js only) + +By default, the `Octokit` API client does not make use of the standard proxy server environment variables. To add support for proxy servers you will need to provide an https client that supports them such as [`undici.ProxyAgent()`](https://undici.nodejs.org/#/docs/api/ProxyAgent). + +For example, this would use a `ProxyAgent` to make requests through a proxy server: + +```js +import { fetch as undiciFetch, ProxyAgent } from 'undici'; + +const myFetch = (url, options) => { + return undiciFetch(url, { + ...options, + dispatcher: new ProxyAgent() + }) +} + +const octokit = new Octokit({ + request: { + fetch: myFetch + }, +}); +``` + +If you are writing a module that uses `Octokit` and is designed to be used by other people, you should ensure that consumers can provide an alternative agent for your `Octokit` or as a parameter to specific calls such as: + +```js +import { fetch as undiciFetch, ProxyAgent } from 'undici'; + +const myFetch = (url, options) => { + return undiciFetch(url, { + ...options, + dispatcher: new ProxyAgent() + }) +} + +octokit.rest.repos.get({ + owner, + repo, + request: { + fetch: myFetch + }, }); -github.user.getFollowingFromUser({ - // optional: - // headers: { - // "cookie": "blahblah" - // }, - user: "mikedeboer" -}, function(err, res) { - console.log(JSON.stringify(res)); +``` + +#### Fetch missing + +If you get the following error: + +> fetch is not set. Please pass a fetch implementation as new Octokit({ request: { fetch }}). + +It probably means you are trying to run Octokit with an unsupported version of NodeJS. Octokit requires Node 18 or higher, [which includes a native fetch API](). + +To bypass this problem you can provide your own `fetch` implementation (or a built-in version like `node-fetch`) like this: + +```js +import fetch from "node-fetch"; + +const octokit = new Octokit({ + request: { + fetch: fetch, + }, }); ``` -First the _GitHubApi_ class is imported from the _node-github_ module. This class provides -access to all of GitHub's APIs (e.g. user, issues or repo APIs). The _getFollowingFromUser_ -method lists all followers of a given GitHub user. Is is part of the user API. It -takes the user name as first argument and a callback as last argument. Once the -follower list is returned from the server, the callback is called. +### REST API -Like in Node.JS, callbacks are always the last argument. If the functions fails an -error object is passed as first argument to the callback. +There are two ways of using the GitHub REST API, the [`octokit.rest.*` endpoint methods](#octokitrest-endpoint-methods) and [`octokit.request`](#octokitrequest). Both act the same way, the `octokit.rest.*` methods are just added for convenience, they use `octokit.request` internally. -## Authentication +For example -Most GitHub API calls don't require authentication. As a rule of thumb: If you -can see the information by visiting the site without being logged in, you don't -have to be authenticated to retrieve the same information through the API. Of -course calls, which change data or read sensitive information have to be authenticated. +```js +await octokit.rest.issues.create({ + owner: "octocat", + repo: "hello-world", + title: "Hello, world!", + body: "I created this issue using Octokit!", +}); +``` -You need the GitHub user name and the API key for authentication. The API key can -be found in the user's _Account Settings_ page. +Is the same as -This example shows how to authenticate and then change _location_ field of the -account settings to _Argentina_: -```javascript -github.authenticate({ - type: "basic", - username: username, - password: password +```js +await octokit.request("POST /repos/{owner}/{repo}/issues", { + owner: "octocat", + repo: "hello-world", + title: "Hello, world!", + body: "I created this issue using Octokit!", }); -github.user.update({ - location: "Argentina" -}, function(err) { - console.log("done!"); +``` + +In both cases a given request is authenticated, retried, and throttled transparently by the `octokit` instance which also manages the `accept` and `user-agent` headers as needed. + +`octokit.request` can be used to send requests to other domains by passing a full URL and to send requests to endpoints that are not (yet) documented in [GitHub's REST API documentation](https://docs.github.com/rest). + +#### `octokit.rest` endpoint methods + +Every GitHub REST API endpoint has an associated `octokit.rest` endpoint method for better code readability and developer convenience. See [`@octokit/plugin-rest-endpoint-methods`](https://github.com/octokit/plugin-rest-endpoint-methods.js/#readme) for full details. + +Example: [Create an issue](https://docs.github.com/en/rest/reference/issues#create-an-issue) + +```js +await octokit.rest.issues.create({ + owner: "octocat", + repo: "hello-world", + title: "Hello, world!", + body: "I created this issue using Octokit!", }); ``` -Note that the _authenticate_ method is synchronous because it only stores the -credentials for the next request. -Other examples for the various authentication methods: -```javascript -// OAuth2 -github.authenticate({ - type: "oauth", - token: token +The `octokit.rest` endpoint methods are generated automatically from [GitHub's OpenAPI specification](https://github.com/github/rest-api-description/). We track operation ID and parameter name changes in order to implement deprecation warnings and reduce the frequency of breaking changes. + +Under the covers, every endpoint method is just `octokit.request` with defaults set, so it supports the same parameters as well as the `.endpoint()` API. + +#### `octokit.request()` + +You can call the GitHub REST API directly using `octokit.request`. The `request` API matches GitHub's REST API documentation 1:1 so anything you see there, you can call using `request`. See [`@octokit/request`](https://github.com/octokit/request.js#readme) for all the details. + +Example: [Create an issue](https://docs.github.com/en/rest/reference/issues#create-an-issue) + +[![Screenshot of REST API reference documentation for Create an issue](assets/create-an-issue-reference.png)](https://docs.github.com/en/rest/reference/issues#create-an-issue) + +The `octokit.request` API call corresponding to that issue creation documentation looks like this: + +```js +// https://docs.github.com/en/rest/reference/issues#create-an-issue +await octokit.request("POST /repos/{owner}/{repo}/issues", { + owner: "octocat", + repo: "hello-world", + title: "Hello, world!", + body: "I created this issue using Octokit!", }); +``` + +The 1st argument is the REST API route as listed in GitHub's API documentation. The 2nd argument is an object with all parameters, independent of whether they are used in the path, query, or body. + +#### Pagination -// OAuth2 Key/Secret -github.authenticate({ - type: "oauth", - key: "clientID", - secret: "clientSecret" -}) +All REST API endpoints that paginate return the first 30 items by default. If you want to retrieve all items, you can use the pagination API. The pagination API expects the REST API route as first argument, but you can also pass any of the `octokit.rest.*.list*` methods for convenience and better code readability. -// Deprecated Gihub API token (seems not to be working with the v3 API) -github.authenticate({ - type: "token", - token: token +Example: iterate through all issues in a repository + +```js +const iterator = octokit.paginate.iterator(octokit.rest.issues.listForRepo, { + owner: "octocat", + repo: "hello-world", + per_page: 100, }); + +// iterate through each response +for await (const { data: issues } of iterator) { + for (const issue of issues) { + console.log("Issue #%d: %s", issue.number, issue.title); + } +} ``` -### Creating tokens for your application -[Create a new authorization](http://developer.github.com/v3/oauth/#create-a-new-authorization) for your application giving it access to the wanted scopes you need instead of relying on username / password and is the way to go if you have [two-factor authentication](https://github.com/blog/1614-two-factor-authentication) on. +Using the [async iterator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) is the most memory efficient way to iterate through all items. But you can also retrieve all items in a single call + +```js +const issues = await octokit.paginate(octokit.rest.issues.listForRepo, { + owner: "octocat", + repo: "hello-world", + per_page: 100, +}); +``` -For example: +#### Media Type formats -1. Use github.authenticate() to auth with GitHub using your username / password -2. Create an application token programmatically with the scopes you need and, if you use two-factor authentication send the `X-GitHub-OTP` header with the one-time-password you get on your token device. +Media type formats can be set using `mediaType: { format }` on every request. -```javascript -github.authorization.create({ - scopes: ["user", "public_repo", "repo", "repo:status", "gist"], - note: "what this auth is for", - note_url: "http://url-to-this-auth-app", - headers: { - "X-GitHub-OTP": "two-factor-code" +Example: retrieve the raw content of a `package.json` file + +```js +const { data } = await octokit.rest.repos.getContent({ + mediaType: { + format: "raw", + }, + owner: "octocat", + repo: "hello-world", + path: "package.json", +}); +console.log("package name: %s", JSON.parse(data).name); +``` + +Learn more about [Media type formats](https://docs.github.com/en/rest/overview/media-types). + +#### Request error handling + +**Standalone module:** [`@octokit/request-error`](https://github.com/octokit/request-error.js/#readme) + +For request error handling, import `RequestError` and use `try...catch` statement. + +```typescript +import { RequestError } from "octokit"; +``` + +```typescript +try { + // your code here that sends at least one Octokit request + await octokit.request("GET /"); +} catch (error) { + // Octokit errors are instances of RequestError, so they always have an `error.status` property containing the HTTP response code. + if (error instanceof RequestError) { + // handle Octokit error + // error.message; // Oops + // error.status; // 500 + // error.request; // { method, url, headers, body } + // error.response; // { url, status, headers, data } + } else { + // handle all other errors + throw error; + } +} +``` + +### GraphQL API queries + +Octokit also supports GitHub's GraphQL API directly -- you can use the same queries shown in the documentation and available in the GraphQL explorer in your calls with `octokit.graphql`. + +Example: get the login of the authenticated user + +```js +const { + viewer: { login }, +} = await octokit.graphql(`{ + viewer { + login + } +}`); +``` + +Variables can be passed as 2nd argument + +```js +const { lastIssues } = await octokit.graphql( + ` + query lastIssues($owner: String!, $repo: String!, $num: Int = 3) { + repository(owner: $owner, name: $repo) { + issues(last: $num) { + edges { + node { + title + } + } + } + } } -}, function(err, res) { - if (res.token) { - //save and use res.token as in the Oauth process above from now on + `, + { + owner: "octokit", + repo: "graphql.js", + }, +); +``` + +#### Pagination + +GitHub's GraphQL API returns a maximum of 100 items. If you want to retrieve all items, you can use the pagination API. + +Example: get all issues + +```js +const { allIssues } = await octokit.graphql.paginate( + ` + query allIssues($owner: String!, $repo: String!, $num: Int = 10, $cursor: String) { + repository(owner: $owner, name: $repo) { + issues(first: $num, after: $cursor) { + edges { + node { + title + } + } + pageInfo { + hasNextPage + endCursor + } + } + } } + `, + { + owner: "octokit", + repo: "graphql.js", + }, +); +``` + +Learn more about [GitHub's GraphQL Pagination](https://github.com/octokit/plugin-paginate-graphql.js#readme) usage. + +#### Schema previews + +Previews can be enabled using the `{mediaType: previews: [] }` option. + +Example: create a label + +```js +await octokit.graphql( + `mutation createLabel($repositoryId:ID!,name:String!,color:String!) { + createLabel(input:{repositoryId:$repositoryId,name:$name}) { + label: { + id + } + } +}`, + { + repositoryId: 1, + name: "important", + color: "cc0000", + mediaType: { + previews: ["bane"], + }, + }, +); +``` + +Learn more about [GitHub's GraphQL schema previews](https://docs.github.com/en/graphql/overview/schema-previews) + +## App client + +The `App` client combines features for GitHub Apps, Webhooks, and OAuth + +### GitHub App + +**Standalone module**: [`@octokit/app`](https://github.com/octokit/app.js/#readme) + +For integrators, GitHub Apps are a means of authentication and authorization. A GitHub app can be registered on a GitHub user or organization account. A GitHub App registration defines a set of permissions and webhooks events it wants to receive and provides a set of credentials in return. Users can grant access to repositories by installing them. + +Some API endpoints require the GitHub app to authenticate as itself using a JSON Web Token (JWT). For requests affecting an installation, an installation access token has to be created using the app's credentials and the installation ID. + +The `App` client takes care of all that for you. + +Example: Dispatch a repository event in every repository the app is installed on + +```js +import { App } from "octokit"; + +const app = new App({ appId, privateKey }); + +for await (const { octokit, repository } of app.eachRepository.iterator()) { + // https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event + await octokit.rest.repos.createDispatchEvent({ + owner: repository.owner.login, + repo: repository.name, + event_type: "my_event", + client_payload: { + foo: "bar", + }, + }); + console.log("Event dispatched for %s", repository.full_name); +} +``` + +Example: Get an `octokit` instance authenticated as an installation + +```js +const octokit = await app.getInstallationOctokit(123); +``` + +Learn more about [apps](https://docs.github.com/apps). + +### Webhooks + +**Standalone module**: [`@octokit/webhooks`](https://github.com/octokit/webhooks.js/#readme) + +When installing an app, events that the app registration requests will be sent as requests to the webhook URL set in the app's registration. + +Webhook event requests are signed using the webhook secret, which is also part of the app's registration. You must verify that secret before handling the request payload. + +The `app.webhooks.*` APIs provide methods to receiving, verifying, and handling webhook events. + +Example: create a comment on new issues + +```js +import { createServer } from "node:http"; +import { App, createNodeMiddleware } from "octokit"; + +const app = new App({ + appId, + privateKey, + webhooks: { secret }, +}); + +app.webhooks.on("issues.opened", ({ octokit, payload }) => { + return octokit.rest.issues.createComment({ + owner: payload.repository.owner.login, + repo: payload.repository.name, + issue_number: payload.issue.number, + body: "Hello, World!", + }); +}); + +// Your app can now receive webhook events at `/api/github/webhooks` +createServer(createNodeMiddleware(app)).listen(3000); +``` + +For serverless environments, you can explicitly verify and receive an event + +```js +await app.webhooks.verifyAndReceive({ + id: request.headers["x-github-delivery"], + name: request.headers["x-github-event"], + signature: request.headers["x-hub-signature-256"], + payload: request.body, +}); +``` + +Learn more about [GitHub webhooks](https://docs.github.com/webhooks). + +### OAuth + +**Standalone module:** [`@octokit/oauth-app`](https://github.com/octokit/oauth-app.js/#readme) + +Both OAuth Apps and GitHub Apps support authenticating GitHub users using OAuth, see [Authorizing OAuth Apps](https://docs.github.com/en/developers/apps/authorizing-oauth-apps) and [Identifying and authorizing users for GitHub Apps](https://docs.github.com/en/developers/apps/identifying-and-authorizing-users-for-github-apps). + +There are some differences: + +- Only OAuth Apps support scopes. GitHub apps have permissions, and access is granted via installations of the app on repositories. +- Only GitHub Apps support expiring user tokens +- Only GitHub Apps support creating a scoped token to reduce the permissions and repository access + +`App` is for GitHub Apps. If you need OAuth App-specific functionality, use [`OAuthApp` instead](https://github.com/octokit/oauth-app.js/). + +Example: Watch a repository when a user logs in using the OAuth web flow + +```js +import { createServer } from "node:http"; +import { App, createNodeMiddleware } from "octokit"; + +const app = new App({ + oauth: { clientId, clientSecret }, }); + +app.oauth.on("token.created", async ({ token, octokit }) => { + await octokit.rest.activity.setRepoSubscription({ + owner: "octocat", + repo: "hello-world", + subscribed: true, + }); +}); + +// Your app can receive the OAuth redirect at /api/github/oauth/callback +// Users can initiate the OAuth web flow by opening /api/github/oauth/login +createServer(createNodeMiddleware(app)).listen(3000); ``` -## Implemented GitHub APIs +For serverless environments, you can explicitly exchange the `code` from the OAuth web flow redirect for an access token. +`app.oauth.createToken()` returns an authentication object and emits the "token.created" event. -* Gists: 100% -* Git Data: 100% -* Issues: 100% -* Orgs: 100% -* Pull Requests: 100% -* Repos: 100% -* Users: 100% -* Events: 100% -* Search: 100% -* Markdown: 100% -* Rate Limit: 100% -* Releases: 100% -* Gitignore: 100% -* Meta: 100% -* Emojis: 100% +```js +const { token } = await app.oauth.createToken({ + code: request.query.code, +}); +``` + +Example: create a token using the device flow. + +```js +const { token } = await app.oauth.createToken({ + async onVerification(verification) { + await sendMessageToUser( + request.body.phoneNumber, + `Your code is ${verification.user_code}. Enter it at ${verification.verification_uri}`, + ); + }, +}); +``` -## Running the Tests +Example: Create an OAuth App Server with default scopes -The unit tests are based on the [mocha](http://visionmedia.github.com/mocha/) -module, which may be installed via npm. To run the tests make sure that the -npm dependencies are installed by running `npm install` from the project directory. +```js +import { createServer } from "node:http"; +import { OAuthApp, createNodeMiddleware } from "octokit"; -Before running unit tests: -```shell -npm install mocha -g +const app = new OAuthApp({ + clientId, + clientSecret, + defaultScopes: ["repo", "gist"], +}); + +app.oauth.on("token", async ({ token, octokit }) => { + await octokit.rest.gists.create({ + description: "I created this gist using Octokit!", + public: true, + files: { + "example.js": `/* some code here */`, + }, + }); +}); + +// Your app can receive the OAuth redirect at /api/github/oauth/callback +// Users can initiate the OAuth web flow by opening /api/oauth/login +createServer(createNodeMiddleware(app)).listen(3000); ``` -At the moment, test classes can only be run separately. This will e.g. run the Issues Api test: -```shell -mocha api/v3.0.0/issuesTest.js + +### App Server + +After registering your GitHub app, you need to create and deploy a server which can retrieve the webhook event requests from GitHub as well as accept redirects from the OAuth user web flow. + +The simplest way to create such a server is to use `createNodeMiddleware()`, it works with both, Node's [`http.createServer()`](https://nodejs.org/api/http.html#http_http_createserver_options_requestlistener) method as well as an [Express middleware](https://expressjs.com/en/guide/using-middleware.html). + +The default routes that the middleware exposes are + +| Route | Route Description | +| --------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `POST /api/github/webhooks` | Endpoint to receive GitHub Webhook Event requests | +| `GET /api/github/oauth/login` | Redirects to GitHub's authorization endpoint. Accepts optional `?state` and `?scopes` query parameters. `?scopes` is a comma-separated list of [supported OAuth scope names](https://docs.github.com/en/developers/apps/scopes-for-oauth-apps#available-scopes) | +| `GET /api/github/oauth/callback` | The client's redirect endpoint. This is where the `token` event gets triggered | +| `POST /api/github/oauth/token` | Exchange an authorization code for an OAuth Access token. If successful, the `token` event gets triggered. | +| `GET /api/github/oauth/token` | Check if token is valid. Must authenticate using token in `Authorization` header. Uses GitHub's [`POST /applications/{client_id}/token`](https://docs.github.com/en/rest/reference/apps#check-a-token) endpoint | +| `PATCH /api/github/oauth/token` | Resets a token (invalidates current one, returns new token). Must authenticate using token in `Authorization` header. Uses GitHub's [`PATCH /applications/{client_id}/token`](https://docs.github.com/en/rest/reference/apps#reset-a-token) endpoint. | +| `PATCH /api/github/oauth/refresh-token` | Refreshes an expiring token (invalidates current one, returns new access token and refresh token). Must authenticate using token in `Authorization` header. Uses GitHub's [`POST https://github.com/login/oauth/access_token`](https://docs.github.com/en/developers/apps/refreshing-user-to-server-access-tokens#renewing-a-user-token-with-a-refresh-token) OAuth endpoint. | +| `POST /api/github/oauth/token/scoped` | Creates a scoped token (does not invalidate the current one). Must authenticate using token in `Authorization` header. Uses GitHub's [`POST /applications/{client_id}/token/scoped`](https://docs.github.com/en/rest/reference/apps#create-a-scoped-access-token) endpoint. | +| `DELETE /api/github/oauth/token` | Invalidates current token, basically the equivalent of a logout. Must authenticate using token in `Authorization` header. | +| `DELETE /api/github/oauth/grant` | Revokes the user's grant, basically the equivalent of an uninstall. must authenticate using token in `Authorization` header. | + +Example: create a GitHub server with express + +```js +import express from "express"; +import { App, createNodeMiddleware } from "octokit"; + +const expressApp = express(); +const octokitApp = new App({ + appId, + privateKey, + webhooks: { secret }, + oauth: { clientId, clientSecret }, +}); + +expressApp.use(createNodeMiddleware(app)); + +expressApp.listen(3000, () => { + console.log(`Example app listening at http://localhost:3000`); +}); +``` + +### OAuth for browser apps + +You must not expose your app's client secret to the user, so you cannot use the `App` constructor. Instead, you have to create a server using the `App` constructor which exposes the `/api/github/oauth/*` routes, through which you can safely implement an OAuth login for apps running in a web browser. + +If you set `(User) Authorization callback URL` to your own app, than you need to read out the `?code=...&state=...` query parameters, compare the `state` parameter to the value returned by `app.oauthLoginUrl()` earlier to protect against forgery attacks, then exchange the `code` for an OAuth Authorization token. + +If you run an [app server](#app-server) as described above, the default route to do that is `POST /api/github/oauth/token`. + +Once you successfully retrieved the token, it is also recommended to remove the `?code=...&state=...` query parameters from the browser's URL + +```js +const code = new URL(location.href).searchParams.get("code"); +if (code) { + // remove ?code=... from URL + const path = + location.pathname + + location.search.replace(/\b(code|state)=\w+/g, "").replace(/[?&]+$/, ""); + history.replaceState({}, "", path); + + // exchange the code for a token with your backend. + // If you use https://github.com/octokit/oauth-app.js + // the exchange would look something like this + const response = await fetch("/api/github/oauth/token", { + method: "POST", + headers: { + "content-type": "application/json", + }, + body: JSON.stringify({ code }), + }); + const { token } = await response.json(); + // `token` is the OAuth Access Token that can be use + + const { Octokit } = await import("https://esm.sh/@octokit/core"); + const octokit = new Octokit({ auth: token }); + + const { + data: { login }, + } = await octokit.request("GET /user"); + alert("Hi there, " + login); +} ``` -Note that a connection to the internet is required to run the tests. + +🚧 We are working on [`@octokit/auth-oauth-user-client`](https://github.com/octokit/auth-oauth-user-client.js#readme) to provide a simple API for all methods related to OAuth user tokens. + +The plan is to add an new `GET /api/github/oauth/octokit.js` route to the node middleware which will return a JavaScript file that can be imported into an HTML file. It will make a pre-authenticated `octokit` Instance available. + +## Action client + +**standalone module:** [`@octokit/action`](https://github.com/octokit/action.js#readme) + +🚧 A fully fledged `Action` client is pending. You can use [`@actions/github`](https://github.com/actions/toolkit/tree/main/packages/github) for the time being ## LICENSE -MIT license. See the LICENSE file for details. +[MIT](LICENSE) diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..4b7f6d06b7 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,11 @@ +# Security Policy + +Thanks for helping make GitHub Open Source Software safe for everyone. + +GitHub takes the security of our software products and services seriously, including all of the open source code repositories managed through our GitHub organizations, such as [Octokit](https://github.com/octokit). + +Even though [open source repositories are outside of the scope of our bug bounty program](https://bounty.github.com/index.html#scope) and therefore not eligible for bounty rewards, we want to make sure that your finding gets passed along to the maintainers of this project for remediation. + +## Reporting a Vulnerability + +Since this source is part of [Octokit](https://github.com/octokit) (a GitHub organization) we ask that you follow the guidelines [here](https://github.com/github/.github/blob/master/SECURITY.md#reporting-security-issues) to report anything that you might've found. diff --git a/api/v2.0.0/routes.json b/api/v2.0.0/routes.json deleted file mode 100644 index 49d1a202ff..0000000000 --- a/api/v2.0.0/routes.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - -} diff --git a/api/v3.0.0/authorization.js b/api/v3.0.0/authorization.js deleted file mode 100644 index 41ca7e0c3d..0000000000 --- a/api/v3.0.0/authorization.js +++ /dev/null @@ -1,265 +0,0 @@ -/** - * mixin authorization - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var authorization = module.exports = { - authorization: {} -}; - -(function() { - /** section: github - * authorization#getAll(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/oauth_authorizations/#list-your-authorizations - **/ - this.getAll = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * authorization#get(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - * https://developer.github.com/v3/oauth_authorizations/#get-a-single-authorization - **/ - this.get = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * authorization#create(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - scopes (Array): Optional. A list of scopes that this authorization is in. - * - note (String): Optional. A note to remind you what the OAuth token is for. - * - note_url (String): Optional. A URL to remind you what app the OAuth token is for. - * - * https://developer.github.com/v3/oauth_authorizations/#create-a-new-authorization - **/ - this.create = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * authorization#update(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - scopes (Array): Optional. A list of scopes that this authorization is in. - * - add_scopes (Array): Optional. A list of scopes to add to this authorization. - * - remove_scopes (Array): Optional. A list of scopes to remove from this authorization. - * - note (String): Optional. A note to remind you what the OAuth token is for. - * - note_url (String): Optional. A URL to remind you what app the OAuth token is for. - * - * https://developer.github.com/v3/oauth_authorizations/#update-an-existing-authorization - **/ - this.update = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * authorization#delete(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - * https://developer.github.com/v3/oauth_authorizations/#delete-an-authorization - **/ - this.delete = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(authorization.authorization); diff --git a/api/v3.0.0/authorizationTest.js b/api/v3.0.0/authorizationTest.js deleted file mode 100644 index 29b0b8dab2..0000000000 --- a/api/v3.0.0/authorizationTest.js +++ /dev/null @@ -1,258 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[authorization]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - this.timeout(10000); - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "basic", - username: "mikedeboertest", - password: "test1324" - }); - }); - - it("should successfully execute GET /authorizations (getAll)", function(next) { - client.authorization.create( - { - scopes: ["user", "public_repo", "repo", "repo:status", "delete_repo", "gist"], - note: "Authorization created to unit tests auth", - note_url: "https://github.com/ajaxorg/node-github" - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.authorization.getAll( - { - page: "1", - per_page: "100" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 1); - - client.authorization["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.authorization.getAll( - { - page: "1", - per_page: "100" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 0); - - next(); - } - ); - } - ); - } - ); - } - ); - }); - - it("should successfully execute GET /authorizations/:id (get)", function(next) { - client.authorization.create( - { - scopes: ["user", "public_repo", "repo", "repo:status", "delete_repo", "gist"], - note: "Authorization created to unit tests auth", - note_url: "https://github.com/ajaxorg/node-github" - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.authorization.get( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.id, id); - Assert.equal(res.note, "Authorization created to unit tests auth"); - Assert.equal(res.note_url, "https://github.com/ajaxorg/node-github"); - - client.authorization["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.authorization.get( - { - id: id - }, - function(err, res) { - Assert.equal(err.code, 404); - next(); - } - ); - } - ); - } - ); - } - ); - }); - - it("should successfully execute POST /authorizations (create)", function(next) { - client.authorization.create( - { - scopes: ["user", "public_repo", "repo", "repo:status", "delete_repo", "gist"], - note: "Authorization created to unit tests auth", - note_url: "https://github.com/ajaxorg/node-github" - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.authorization.get( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.id, id); - Assert.equal(res.note, "Authorization created to unit tests auth"); - Assert.equal(res.note_url, "https://github.com/ajaxorg/node-github"); - - client.authorization["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.authorization.get( - { - id: id - }, - function(err, res) { - Assert.equal(err.code, 404); - next(); - } - ); - } - ); - } - ); - } - ); - }); - - it("should successfully execute PATCH /authorizations/:id (update)", function(next) { - client.authorization.create( - { - scopes: ["user", "public_repo", "repo", "repo:status", "delete_repo", "gist"], - note: "Authorization created to unit tests auth", - note_url: "https://github.com/ajaxorg/node-github" - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.authorization.update( - { - id: id, - remove_scopes: ["repo"], - note: "changed" - }, - function(err, res) { - Assert.equal(err, null); - - client.authorization.get( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.id, id); - Assert.ok(res.scopes.indexOf("repo") === -1); - Assert.equal(res.note, "changed"); - Assert.equal(res.note_url, "https://github.com/ajaxorg/node-github"); - - client.authorization["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.authorization.get( - { - id: id - }, - function(err, res) { - Assert.equal(err.code, 404); - next(); - } - ); - } - ); - } - ); - } - ); - } - ); - }); - - it("should successfully execute DELETE /authorizations/:id (delete)", function(next) { - client.authorization.create( - { - scopes: ["user", "public_repo", "repo", "repo:status", "delete_repo", "gist"], - note: "Authorization created to unit tests auth", - note_url: "https://github.com/ajaxorg/node-github" - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.authorization["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.authorization.get( - { - id: id - }, - function(err, res) { - Assert.equal(err.code, 404); - next(); - } - ); - } - ); - } - ); - }); -}); diff --git a/api/v3.0.0/events.js b/api/v3.0.0/events.js deleted file mode 100644 index f0dfbb1efe..0000000000 --- a/api/v3.0.0/events.js +++ /dev/null @@ -1,495 +0,0 @@ -/** - * mixin events - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var events = module.exports = { - events: {} -}; - -(function() { - /** section: github - * events#get(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.get = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getFromRepo(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromRepo = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getFromRepoIssues(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromRepoIssues = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getFromRepoNetwork(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromRepoNetwork = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getFromOrg(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromOrg = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getReceived(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getReceived = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getReceivedPublic(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getReceivedPublic = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getFromUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getFromUserPublic(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromUserPublic = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * events#getFromUserOrg(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - org (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromUserOrg = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(events.events); diff --git a/api/v3.0.0/eventsTest.js b/api/v3.0.0/eventsTest.js deleted file mode 100644 index 0c4a7320bc..0000000000 --- a/api/v3.0.0/eventsTest.js +++ /dev/null @@ -1,212 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[events]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /events (get)", function(next) { - client.events.get( - { - page: 1, - per_page: 30 - }, - function(err, res) { - // other assertions go here - Assert.equal(err, null); - Assert.ok(res.length > 1); - Assert.equal(typeof res[0].type, "string"); - Assert.equal(typeof res[0].created_at, "string"); - Assert.equal(typeof res[0]["public"], "boolean"); - Assert.equal(typeof res[0].id, "string"); - Assert.ok("actor" in res[0]); - Assert.ok("repo" in res[0]); - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/events (getFromRepo)", function(next) { - client.events.getFromRepo( - { - user: "mikedeboertest", - repo: "node_chat" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 5); - // this is the lastly listed event - var last = res.pop(); - Assert.equal(last.type, "ForkEvent"); - Assert.equal(last.created_at, "2012-10-05T15:03:11Z"); - Assert.equal(last.id, "1607304921"); - Assert.equal(last["public"], true); - Assert.equal(last.actor.login, "mikedeboer"); - Assert.equal(last.repo.name, "mikedeboertest/node_chat"); - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/issues/events (getFromRepoIssues)", function(next) { - client.events.getFromRepoIssues( - { - user: "mikedeboertest", - repo: "node_chat" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 4); - // this is the lastly listed event - var last = res.pop(); - Assert.equal(last.event, "referenced"); - Assert.equal(last.created_at, "2012-10-05T15:05:31Z"); - Assert.equal(last.id, "26276344"); - Assert.equal(last.actor.login, "mikedeboertest"); - Assert.equal(last.issue.title, "Macaroni"); - Assert.equal(last.issue.number, 1); - Assert.equal(last.issue.state, "closed"); - next(); - } - ); - }); - - it("should successfully execute GET /networks/:user/:repo/events (getFromRepoNetwork)", function(next) { - client.events.getFromRepoNetwork( - { - user: "mikedeboertest", - repo: "node_chat" - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res.length > 1); - var last = res.pop(); - Assert.equal(typeof last.id, "string"); - Assert.equal(typeof last.created_at, "string"); - Assert.equal(typeof last.actor, "object"); - next(); - } - ); - }); - - it("should successfully execute GET /orgs/:org/events (getFromOrg)", function(next) { - client.events.getFromOrg( - { - org: "ajaxorg" - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res.length > 1); - var last = res.pop(); - Assert.equal(typeof last.id, "string"); - Assert.equal(typeof last.created_at, "string"); - Assert.equal(typeof last.actor, "object"); - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/received_events (getReceived)", function(next) { - client.events.getReceived( - { - user: "mikedeboertest" - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res.length > 0); - var last = res.pop(); - Assert.equal(typeof last.id, "string"); - Assert.equal(typeof last.created_at, "string"); - Assert.equal(typeof last.actor, "object"); - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/received_events/public (getReceivedPublic)", function(next) { - client.events.getReceivedPublic( - { - user: "mikedeboertest" - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res.length > 0); - var last = res.pop(); - Assert.equal(typeof last.id, "string"); - Assert.equal(typeof last.created_at, "string"); - Assert.equal(typeof last.actor, "object"); - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/events (getFromUser)", function(next) { - client.events.getFromUser( - { - user: "mikedeboertest" - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res.length > 1); - var last = res.pop(); - Assert.equal(typeof last.id, "string"); - Assert.equal(typeof last.created_at, "string"); - Assert.equal(typeof last.actor, "object"); - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/events/public (getFromUserPublic)", function(next) { - client.events.getFromUserPublic( - { - user: "mikedeboertest" - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res.length > 1); - var last = res.pop(); - Assert.equal(typeof last.id, "string"); - Assert.equal(typeof last.created_at, "string"); - Assert.equal(typeof last.actor, "object"); - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/events/orgs/:org (getFromUserOrg)", function(next) { - client.events.getFromUserOrg( - { - user: "mikedeboer", - org: "ajaxorg" - }, - function(err, res) { - // we're not logged in as `mikedeboer` right now, so github API does not allow - // us to see the resource. - Assert.equal(err.code, 404); - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/gists.js b/api/v3.0.0/gists.js deleted file mode 100644 index d3297ec64c..0000000000 --- a/api/v3.0.0/gists.js +++ /dev/null @@ -1,823 +0,0 @@ -/** - * mixin gists - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var gists = module.exports = { - gists: {} -}; - -(function() { - /** section: github - * gists#getAll(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - since (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - * - * https://developer.github.com/v3/gists/#list-gists - **/ - this.getAll = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#getFromUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - since (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - **/ - this.getFromUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#create(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - description (String): Optional. - * - public (Boolean): Required. - * - files (Json): Required. Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters: 'content' - * - * https://developer.github.com/v3/gists/#create-a-gist - **/ - this.create = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#edit(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - description (String): Optional. - * - files (Json): Required. Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters: 'content' - * - * https://developer.github.com/v3/gists/#edit-a-gist - **/ - this.edit = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#public(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - since (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - * - * https://developer.github.com/v3/gists/#list-gists - **/ - this.public = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#starred(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - since (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - * - * https://developer.github.com/v3/gists/#list-gists - **/ - this.starred = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#get(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - * https://developer.github.com/v3/gists/#get-a-single-gist - **/ - this.get = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#star(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - * https://developer.github.com/v3/gists/#star-a-gist - **/ - this.star = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#deleteStar(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - * https://developer.github.com/v3/gists/#unstar-a-gist - **/ - this.deleteStar = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#checkStar(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - * https://developer.github.com/v3/gists/#check-if-a-gist-is-starred - **/ - this.checkStar = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#fork(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - * https://developer.github.com/v3/gists/#fork-a-gist - **/ - this.fork = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#delete(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - * https://developer.github.com/v3/gists/#unstar-a-gist - **/ - this.delete = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#getComments(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - gist_id (String): Required. Id (SHA1 hash) of the gist. - **/ - this.getComments = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#getComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - gist_id (String): Required. Id (SHA1 hash) of the gist. - * - id (String): Required. - **/ - this.getComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#createComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - gist_id (String): Required. Id (SHA1 hash) of the gist. - * - body (String): Required. - **/ - this.createComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#editComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - gist_id (String): Required. Id (SHA1 hash) of the gist. - * - id (String): Required. - * - body (String): Required. - **/ - this.editComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gists#deleteComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - gist_id (String): Required. Id (SHA1 hash) of the gist. - * - id (String): Required. - **/ - this.deleteComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(gists.gists); diff --git a/api/v3.0.0/gistsTest.js b/api/v3.0.0/gistsTest.js deleted file mode 100644 index d47d28f371..0000000000 --- a/api/v3.0.0/gistsTest.js +++ /dev/null @@ -1,605 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[gists]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - timeout(5000); - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /gists (getAll)", function(next) { - client.gists.getAll( - {}, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 1); - var gist = res.pop(); - Assert.equal(gist.user.login, "mikedeboertest"); - Assert.equal(gist.html_url, "https://gist.github.com/77dc15615eab09a79b61"); - Assert.equal(gist.created_at, "2012-10-05T16:10:40Z"); - Assert.equal(gist.public, false); - Assert.equal(gist.id, "77dc15615eab09a79b61"); - - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/gists (getFromUser)", function(next) { - client.gists.getFromUser( - { - user: "mikedeboertest" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 1); - var gist = res.pop(); - Assert.equal(gist.user.login, "mikedeboertest"); - Assert.equal(gist.html_url, "https://gist.github.com/77dc15615eab09a79b61"); - Assert.equal(gist.created_at, "2012-10-05T16:10:40Z"); - Assert.equal(gist.public, false); - Assert.equal(gist.id, "77dc15615eab09a79b61"); - next(); - } - ); - }); - - it("should successfully execute POST /gists (create)", function(next) { - client.gists.create( - { - description: "Another bowl of pasta", - public: "false", - files: { - "ravioli.js": { - "content": "alert(\"want some ketchup with that?\");" - } - } - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.get( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.user.login, "mikedeboertest"); - Assert.equal(res.html_url, "https://gist.github.com/" + id); - Assert.equal(res.public, false); - Assert.equal(res.id, id); - Assert.equal(res.description, "Another bowl of pasta"); - - client.gists["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - }); - - it("should successfully execute PATCH /gists/:id (edit)", function(next) { - client.gists.create( - { - description: "Another bowl of pasta", - public: "false", - files: { - "ravioli.js": { - "content": "alert(\"want some ketchup with that?\");" - } - } - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.edit( - { - id: id, - description: "changed", - files: { - "ravioli.js": { - "content": "alert(\"no ketchup, please.\");" - } - } - }, - function(err, res) { - Assert.equal(err, null); - - client.gists.get( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.user.login, "mikedeboertest"); - Assert.equal(res.html_url, "https://gist.github.com/" + id); - Assert.equal(res.public, false); - Assert.equal(res.id, id); - Assert.equal(res.description, "changed"); - Assert.equal(res.files["ravioli.js"].content, "alert(\"no ketchup, please.\");"); - - client.gists["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - } - ); - }); -/* - it("should successfully execute GET /gists/public (public)", function(next) { - client.gists.public( - {}, - function(err, res) { - Assert.equal(err, null); - console.log(res); - next(); - } - ); - }); -*/ - it("should successfully execute GET /gists/starred (starred)", function(next) { - client.gists.starred( - {}, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 1); - var gist = res.pop(); - Assert.equal(gist.user.login, "mikedeboertest"); - Assert.equal(gist.html_url, "https://gist.github.com/77dc15615eab09a79b61"); - Assert.equal(gist.created_at, "2012-10-05T16:10:40Z"); - Assert.equal(gist.public, false); - Assert.equal(gist.id, "77dc15615eab09a79b61"); - - next(); - } - ); - }); - - it("should successfully execute GET /gists/:id (get)", function(next) { - client.gists.create( - { - description: "Another bowl of pasta", - public: "false", - files: { - "ravioli.js": { - "content": "alert(\"want some ketchup with that?\");" - } - } - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.get( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.user.login, "mikedeboertest"); - Assert.equal(res.html_url, "https://gist.github.com/" + id); - Assert.equal(res.public, false); - Assert.equal(res.id, id); - Assert.equal(res.description, "Another bowl of pasta"); - - client.gists["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - }); - - it("should successfully execute PUT /gists/:id/star (star)", function(next) { - client.gists.create( - { - description: "Another bowl of pasta", - public: "false", - files: { - "ravioli.js": { - "content": "alert(\"want some ketchup with that?\");" - } - } - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.star( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.gists.checkStar( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - //TODO: NO RESULT HERE??? - - client.gists["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - } - ); - }); - - it("should successfully execute DELETE /gists/:id/star (deleteStar)", function(next) { - client.gists.create( - { - description: "Another bowl of pasta", - public: "false", - files: { - "ravioli.js": { - "content": "alert(\"want some ketchup with that?\");" - } - } - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.star( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.gists.deleteStar( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.gists["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - } - ); - }); - - it("should successfully execute GET /gists/:id/star (checkStar)", function(next) { - client.gists.create( - { - description: "Another bowl of pasta", - public: "false", - files: { - "ravioli.js": { - "content": "alert(\"want some ketchup with that?\");" - } - } - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.star( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - - client.gists["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - }); - - it("should successfully execute POST /gists/:id/fork (fork)", function(next) { - client.gists.fork( - { - id: "3047099" - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - Assert.equal(res.git_pull_url, "git://gist.github.com/" + id + ".git"); - Assert.equal(res.git_push_url, "git@gist.github.com:" + id + ".git"); - Assert.equal(res.description, "Why to call resume() after next()"); - Assert.equal(typeof res.files["resume_after_next.md"], "object"); - - client.gists["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - }); - - it("should successfully execute DELETE /gists/:id (delete)", function(next) { - client.gists.create( - { - description: "Another bowl of pasta", - public: "false", - files: { - "ravioli.js": { - "content": "alert(\"want some ketchup with that?\");" - } - } - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists["delete"]( - { - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - }); - - it("should successfully execute GET /gists/:gist_id/comments/:id (getComments)", function(next) { - client.gists.createComment( - { - gist_id: "3047099", - body: "This is a test comment.", - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.getComments( - { - gist_id: "3047099" - }, - function(err, res) { - var comment = res.pop(); - Assert.equal(err, null); - Assert.equal(comment.user.login, "mikedeboertest"); - Assert.equal(comment.id, id); - Assert.equal(comment.body, "This is a test comment."); - - client.gists["deleteComment"]( - { - gist_id: "3047099", - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - }); - - it("should successfully execute GET /gists/:gist_id/comments/:id (getComment)", function(next) { - client.gists.createComment( - { - gist_id: "3047099", - body: "This is a test comment.", - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.getComment( - { - gist_id: "3047099", - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.user.login, "mikedeboertest"); - Assert.equal(res.id, id); - Assert.equal(res.body, "This is a test comment."); - - client.gists["deleteComment"]( - { - gist_id: "3047099", - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - }); - - it("should successfully execute POST /gists/:gist_id/comments (createComment)", function(next) { - client.gists.createComment( - { - gist_id: "3047099", - body: "This is a test comment.", - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.getComment( - { - gist_id: "3047099", - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.user.login, "mikedeboertest"); - Assert.equal(res.id, id); - Assert.equal(res.body, "This is a test comment."); - - client.gists["deleteComment"]( - { - gist_id: "3047099", - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - }); - - it("should successfully execute PATCH /gists/:gist_id/comments/:id (editComment)", function(next) { - client.gists.createComment( - { - gist_id: "3047099", - body: "This is a test comment.", - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists.editComment( - { - gist_id: "3047099", - id: id, - body: "This comment has been edited." - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - client.gists.getComment( - { - gist_id: "3047099", - id: id - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.user.login, "mikedeboertest"); - Assert.equal(res.id, id); - Assert.equal(res.body, "This comment has been edited."); - - client.gists["deleteComment"]( - { - gist_id: "3047099", - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - } - ); - } - ); - }); - - it("should successfully execute DELETE /gists/:gist_id/comments/:id (deleteComment)", function(next) { - client.gists.createComment( - { - gist_id: "3047099", - body: "This is a test comment.", - }, - function(err, res) { - Assert.equal(err, null); - var id = res.id; - - client.gists["deleteComment"]( - { - gist_id: "3047099", - id: id - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - } - ); - }); -}); diff --git a/api/v3.0.0/gitdata.js b/api/v3.0.0/gitdata.js deleted file mode 100644 index 584cc123b1..0000000000 --- a/api/v3.0.0/gitdata.js +++ /dev/null @@ -1,650 +0,0 @@ -/** - * mixin gitdata - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var gitdata = module.exports = { - gitdata: {} -}; - -(function() { - /** section: github - * gitdata#getBlob(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getBlob = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#createBlob(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - content (String): Required. - * - encoding (String): Required. - **/ - this.createBlob = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#getCommit(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - **/ - this.getCommit = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#createCommit(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - message (String): Required. String of the commit message - * - tree (String): Required. String of the SHA of the tree object this commit points to - * - parents (Array): Required. Array of the SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided, for a merge commit, an array of more than one should be provided. - * - author (Json): Optional. - * - committer (Json): Optional. - **/ - this.createCommit = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#getReference(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - ref (String): Required. String of the name of the fully qualified reference (ie: heads/master). If it doesn’t have at least one slash, it will be rejected. - **/ - this.getReference = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#getAllReferences(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getAllReferences = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#createReference(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - ref (String): Required. String of the name of the fully qualified reference (ie: heads/master). If it doesn’t have at least one slash, it will be rejected. - * - sha (String): Required. - **/ - this.createReference = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#updateReference(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - ref (String): Required. String of the name of the fully qualified reference (ie: heads/master). If it doesn’t have at least one slash, it will be rejected. - * - sha (String): Required. - * - force (Boolean): Optional. Boolean indicating whether to force the update or to make sure the update is a fast-forward update. The default is false, so leaving this out or setting it to false will make sure you’re not overwriting work. - **/ - this.updateReference = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#deleteReference(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - ref (String): Required. String of the name of the fully qualified reference (ie: heads/master). If it doesn’t have at least one slash, it will be rejected. - **/ - this.deleteReference = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#getTag(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - **/ - this.getTag = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#createTag(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - tag (String): Required. String of the tag - * - message (String): Required. String of the tag message - * - object (String): Required. String of the SHA of the git object this is tagging - * - type (String): Required. String of the type of the object we’re tagging. Normally this is a commit but it can also be a tree or a blob. - * - tagger (Json): Required. JSON object that contains the following keys: `name` - String of the name of the author of the tag, `email` - String of the email of the author of the tag, `date` - Timestamp of when this object was tagged - **/ - this.createTag = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#getTree(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - * - recursive (Boolean): Optional. - **/ - this.getTree = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitdata#createTree(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - tree (Json): Required. Array of Hash objects (of path, mode, type and sha) specifying a tree structure - * - base_tree (String): Optional. String of the SHA1 of the tree you want to update with new data - **/ - this.createTree = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(gitdata.gitdata); diff --git a/api/v3.0.0/gitdataTest.js b/api/v3.0.0/gitdataTest.js deleted file mode 100644 index c9f7fbce0e..0000000000 --- a/api/v3.0.0/gitdataTest.js +++ /dev/null @@ -1,480 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[gitdata]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /repos/:user/:repo/git/blobs/:sha (getBlob)", function(next) { - // found an object after executing: - // git rev-list --all | xargs -l1 git diff-tree -r -c -M -C --no-commit-id | awk '{print $3}' - client.gitdata.getBlob( - { - user: "mikedeboertest", - repo: "node_chat", - sha: "8433b682c95edf3fd81f5ee217dc9c874db35e4b" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.sha, "8433b682c95edf3fd81f5ee217dc9c874db35e4b"); - Assert.equal(res.size, 2654); - Assert.equal(res.encoding, "base64"); - - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/git/blobs (createBlob)", function(next) { - client.gitdata.createBlob( - { - user: "mikedeboertest", - repo: "node_chat", - content: "test", - encoding: "utf-8" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(typeof res.sha, "string"); - var sha = res.sha; - - client.gitdata.getBlob( - { - user: "mikedeboertest", - repo: "node_chat", - sha: sha - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.sha, sha); - Assert.equal(res.size, 4); - Assert.equal(res.encoding, "base64"); - - next(); - } - ); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/git/commits/:sha (getCommit)", function(next) { - client.gitdata.getCommit( - { - user: "mikedeboertest", - repo: "node_chat", - sha: "17e0734295ffd8174f91f04ba8e8f8e51954b793" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.author.date, "2012-10-05T08:05:31-07:00"); - Assert.equal(res.author.name, "Mike de Boer"); - Assert.equal(res.parents[0].sha, "221140b288a3c64949594c58420cb4ab289b0756"); - Assert.equal(res.parents[1].sha, "d2836429f4ff7de033c8bc0d16d22d55f2ea39c3"); - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/git/commits (createCommit)", function(next) { - // got valid tree reference by executing - // git cat-file -p HEAD - client.gitdata.createCommit( - { - user: "mikedeboertest", - repo: "node_chat", - message: "test", - tree: "8ce4393a319b60bc6179509e0c46dee83c179f9f", - parents: [], - author: { - name: "test-chef", - email: "test-chef@pasta-nirvana.it", - date: "2008-07-09T16:13:30+12:00" - }, - committer: { - name: "test-minion", - email: "test-minion@pasta-nirvana.it", - date: "2008-07-09T16:13:30+12:00" - } - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.author.name, "test-chef"); - Assert.equal(res.author.email, "test-chef@pasta-nirvana.it"); - Assert.equal(res.committer.name, "test-minion"); - Assert.equal(res.committer.email, "test-minion@pasta-nirvana.it"); - Assert.equal(res.message, "test"); - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/git/refs/:ref (getReference)", function(next) { - client.gitdata.getReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "heads/master" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.ref, "refs/heads/master"); - Assert.equal(res.object.type, "commit"); - Assert.equal(res.object.sha, "17e0734295ffd8174f91f04ba8e8f8e51954b793"); - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/git/refs (getAllReferences)", function(next) { - client.gitdata.getAllReferences( - { - user: "mikedeboertest", - repo: "node_chat" - }, - function(err, res) { - Assert.equal(err, null); - var ref = res[0]; - Assert.equal(ref.ref, "refs/heads/master"); - Assert.equal(ref.object.type, "commit"); - Assert.equal(ref.object.sha, "17e0734295ffd8174f91f04ba8e8f8e51954b793"); - next(); - } - ); - }); -/* -DISABLED temporarily due to Internal Server Error from Github! - - it("should successfully execute POST /repos/:user/:repo/git/refs (createReference)", function(next) { - client.gitdata.createReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "heads/tagliatelle", - sha: "17e0734295ffd8174f91f04ba8e8f8e51954b793" - }, - function(err, res) { - Assert.equal(err, null); - console.log(res); - - // other assertions go here - client.gitdata.deleteReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "heads/tagliatelle" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - } - ); - });*/ - - it("should successfully execute PATCH /repos/:user/:repo/git/refs/:ref (updateReference)", function(next) { - client.gitdata.getReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "heads/master" - }, - function(err, res) { - Assert.equal(err, null); - var sha = res.object.sha; - - // do `force=true` because we go backward in history, which yields a warning - // that it's not a reference that can be fast-forwarded to. - client.gitdata.updateReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "heads/master", - sha: "221140b288a3c64949594c58420cb4ab289b0756", - force: true - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.ref, "refs/heads/master"); - Assert.equal(res.object.type, "commit"); - Assert.equal(res.object.sha, "221140b288a3c64949594c58420cb4ab289b0756"); - - client.gitdata.updateReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "heads/master", - sha: sha, - force: false - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.ref, "refs/heads/master"); - Assert.equal(res.object.type, "commit"); - Assert.equal(res.object.sha, sha); - - next(); - } - ); - } - ); - } - ); - - }); -/* -DISABLED temporarily due to Internal Server Error from Github! - - it("should successfully execute DELETE /repos/:user/:repo/git/refs/:ref (deleteReference)", function(next) { - client.gitdata.createReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "heads/tagliatelle", - sha: "17e0734295ffd8174f91f04ba8e8f8e51954b793" - }, - function(err, res) { - Assert.equal(err, null); - console.log(res); - - // other assertions go here - client.gitdata.deleteReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "heads/tagliatelle" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - } - ); - });*/ - - it("should successfully execute GET /repos/:user/:repo/git/tags/:sha (getTag)", function(next) { - client.gitdata.createTag( - { - user: "mikedeboertest", - repo: "node_chat", - tag: "test-pasta", - message: "Grandma's secret sauce", - object: "17e0734295ffd8174f91f04ba8e8f8e51954b793", - type: "commit", - tagger: { - name: "test-chef", - email: "test-chef@pasta-nirvana.it", - date: "2008-07-09T16:13:30+12:00" - } - }, - function(err, res) { - Assert.equal(err, null); - var sha = res.sha; - - client.gitdata.getTag( - { - user: "mikedeboertest", - repo: "node_chat", - sha: sha - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.tag, "test-pasta"); - Assert.equal(res.message, "Grandma's secret sauce"); - Assert.equal(res.sha, sha); - Assert.equal(res.tagger.name, "test-chef"); - Assert.equal(res.tagger.email, "test-chef@pasta-nirvana.it"); - - // other assertions go here - client.gitdata.deleteReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "tags/" + sha - }, - function(err, res) { - //Assert.equal(err, null); - // NOTE: Github return 'Validation Failed' error codes back, which makes no sense to me. - // ask the guys what's up here... - Assert.equal(err.code, 422); - - next(); - } - ); - } - ); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/git/tags (createTag)", function(next) { - client.gitdata.createTag( - { - user: "mikedeboertest", - repo: "node_chat", - tag: "test-pasta", - message: "Grandma's secret sauce", - object: "17e0734295ffd8174f91f04ba8e8f8e51954b793", - type: "commit", - tagger: { - name: "test-chef", - email: "test-chef@pasta-nirvana.it", - date: "2008-07-09T16:13:30+12:00" - } - }, - function(err, res) { - Assert.equal(err, null); - var sha = res.sha; - - client.gitdata.getTag( - { - user: "mikedeboertest", - repo: "node_chat", - sha: sha - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.tag, "test-pasta"); - Assert.equal(res.message, "Grandma's secret sauce"); - Assert.equal(res.sha, sha); - Assert.equal(res.tagger.name, "test-chef"); - Assert.equal(res.tagger.email, "test-chef@pasta-nirvana.it"); - - // other assertions go here - client.gitdata.deleteReference( - { - user: "mikedeboertest", - repo: "node_chat", - ref: "tags/" + sha - }, - function(err, res) { - //Assert.equal(err, null); - // NOTE: Github return 'Validation Failed' error codes back, which makes no sense to me. - // ask the guys what's up here... - Assert.equal(err.code, 422); - - next(); - } - ); - } - ); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/git/trees/:sha (getTree)", function(next) { - client.gitdata.getTree( - { - user: "mikedeboertest", - repo: "node_chat", - sha: "8ce4393a319b60bc6179509e0c46dee83c179f9f", - recursive: false - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.tree[0].type, "blob"); - Assert.equal(res.tree[0].path, "LICENSE-MIT"); - Assert.equal(res.tree[0].sha, "f30a31de94635399f42fd05f91f6ed3ff2f013d6"); - Assert.equal(res.tree[0].mode, "100644"); - Assert.equal(res.tree[0].size, 1075); - - client.gitdata.getTree( - { - user: "mikedeboertest", - repo: "node_chat", - sha: "8ce4393a319b60bc6179509e0c46dee83c179f9f", - recursive: true - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.tree[0].type, "blob"); - Assert.equal(res.tree[0].path, "LICENSE-MIT"); - Assert.equal(res.tree[0].sha, "f30a31de94635399f42fd05f91f6ed3ff2f013d6"); - Assert.equal(res.tree[0].mode, "100644"); - Assert.equal(res.tree[0].size, 1075); - - next(); - } - ); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/git/trees (createTree)", function(next) { - client.gitdata.getTree( - { - user: "mikedeboertest", - repo: "node_chat", - sha: "8ce4393a319b60bc6179509e0c46dee83c179f9f", - recursive: false - }, - function(err, res) { - Assert.equal(err, null); - var file = res.tree[0]; - - client.gitdata.createTree( - { - base_tree: "8ce4393a319b60bc6179509e0c46dee83c179f9f", - user: "mikedeboertest", - repo: "node_chat", - tree: [ - { - path: file.path, - mode: "100755", - type: file.type, - sha: file.sha - } - ] - }, - function(err, res) { - Assert.equal(err, null); - var sha = res.sha; - - client.gitdata.getTree( - { - user: "mikedeboertest", - repo: "node_chat", - sha: sha, - recursive: true - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.tree[0].type, "blob"); - Assert.equal(res.tree[0].path, "LICENSE-MIT"); - Assert.equal(res.tree[0].sha, "f30a31de94635399f42fd05f91f6ed3ff2f013d6"); - Assert.equal(res.tree[0].mode, "100755"); - Assert.equal(res.tree[0].size, 1075); - - next(); - } - ); - } - ); - } - ); - }); -}); diff --git a/api/v3.0.0/gitignore.js b/api/v3.0.0/gitignore.js deleted file mode 100644 index ebc9bbc1a5..0000000000 --- a/api/v3.0.0/gitignore.js +++ /dev/null @@ -1,114 +0,0 @@ -/** - * mixin gitignore - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var gitignore = module.exports = { - gitignore: {} -}; - -(function() { - /** section: github - * gitignore#templates(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * No other params, simply pass an empty Object literal `{}` - * - * https://developer.github.com/v3/gitignore/#listing-available-templates - **/ - this.templates = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * gitignore#template(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - name (String): Required. The name of the .gitignore template to get - **/ - this.template = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(gitignore.gitignore); diff --git a/api/v3.0.0/gitignoreTest.js b/api/v3.0.0/gitignoreTest.js deleted file mode 100644 index e533eb4c88..0000000000 --- a/api/v3.0.0/gitignoreTest.js +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[gitignore]", function() { - var client; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - }); - - it("should successfully execute GET /gitignore/templates (templates)", function(next) { - client.gitignore.templates( - {}, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - Assert.ifError(err); - Assert(Array.isArray(res)); - Assert(res.length > 10); - next(); - } - ); - }); - - it("should successfully execute GET /gitignore/templates/:name (template)", function(next) { - client.gitignore.template( - { - name: "C" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - Assert.ifError(err); - Assert('name' in res); - Assert('source' in res); - Assert(typeof res.source === 'string'); - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/index.js b/api/v3.0.0/index.js deleted file mode 100644 index 5ce2480f28..0000000000 --- a/api/v3.0.0/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * class Github - * - * A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API. - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var Fs = require("fs"); -var Util = require("./../../util"); -var error = require("./../../error"); - -var GithubHandler = module.exports = function(client) { - this.client = client; - this.routes = JSON.parse(Fs.readFileSync(__dirname + "/routes.json", "utf8")); -}; - -var proto = { - sendError: function(err, block, msg, callback) { - if (this.client.debug) - Util.log(err, block, msg.user, "error"); - if (typeof err == "string") - err = new error.InternalServerError(err); - if (callback) - callback(err); - } -}; - -["gists", "gitdata", "issues", "authorization", "orgs", "statuses", "pullRequests", "repos", "user", "events", "releases", "search", "markdown", "gitignore", "misc"].forEach(function(api) { - Util.extend(proto, require("./" + api)); -}); - -GithubHandler.prototype = proto; diff --git a/api/v3.0.0/issues.js b/api/v3.0.0/issues.js deleted file mode 100644 index 66213e30d9..0000000000 --- a/api/v3.0.0/issues.js +++ /dev/null @@ -1,1256 +0,0 @@ -/** - * mixin issues - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var issues = module.exports = { - issues: {} -}; - -(function() { - /** section: github - * issues#getAll(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - filter (String): Optional. Validation rule: ` ^(all|assigned|created|mentioned|subscribed)$ `. - * - state (String): Optional. open, closed, or all Validation rule: ` ^(open|closed|all)$ `. - * - labels (String): Optional. String list of comma separated Label names. Example: bug,ui,@high - * - sort (String): Optional. Validation rule: ` ^(created|updated|comments)$ `. - * - direction (String): Optional. Validation rule: ` ^(asc|desc)$ `. - * - since (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/issues/#list-issues - **/ - this.getAll = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#repoIssues(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - milestone (String): Optional. Validation rule: ` ^([0-9]+|none|\*)$ `. - * - state (String): Optional. open, closed, or all Validation rule: ` ^(open|closed|all)$ `. - * - assignee (String): Optional. String User login, `none` for Issues with no assigned User. `*` for Issues with any assigned User. - * - creator (String): Optional. The user that created the issue. - * - mentioned (String): Optional. String User login. - * - labels (String): Optional. String list of comma separated Label names. Example: bug,ui,@high - * - sort (String): Optional. Validation rule: ` ^(created|updated|comments)$ `. - * - direction (String): Optional. Validation rule: ` ^(asc|desc)$ `. - * - since (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/issues/#list-issues-for-a-repository - **/ - this.repoIssues = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getRepoIssue(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/issues/#get-a-single-issue - **/ - this.getRepoIssue = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#create(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - title (String): Required. - * - body (String): Optional. - * - assignee (String): Optional. Login for the user that this issue should be assigned to. - * - milestone (Number): Optional. Milestone to associate this issue with. Validation rule: ` ^[0-9]+$ `. - * - labels (Json): Optional. Array of strings - Labels to associate with this issue. - * - * https://developer.github.com/v3/issues/#create-an-issue - **/ - this.create = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#edit(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - title (String): Optional. - * - body (String): Optional. - * - assignee (String): Optional. Login for the user that this issue should be assigned to. - * - milestone (Number): Optional. Milestone to associate this issue with. Validation rule: ` ^[0-9]+$ `. - * - labels (Json): Optional. Array of strings - Labels to associate with this issue. - * - state (String): Optional. open or closed Validation rule: ` ^(open|closed)$ `. - * - * https://developer.github.com/v3/issues/#edit-an-issue - **/ - this.edit = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#repoComments(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sort (String): Optional. Validation rule: ` ^(created|updated)$ `. - * - direction (String): Optional. Validation rule: ` ^(asc|desc)$ `. - * - since (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.repoComments = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getComments(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getComments = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.getComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#createComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - body (String): Required. - **/ - this.createComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#editComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - * - body (String): Required. - **/ - this.editComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#deleteComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.deleteComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getEvents(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getEvents = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getRepoEvents(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getRepoEvents = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getEvent(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.getEvent = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getLabels(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getLabels = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getLabel(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - name (String): Required. - **/ - this.getLabel = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#createLabel(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - name (String): Required. - * - color (String): Required. 6 character hex code, without a leading #. - **/ - this.createLabel = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#updateLabel(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - name (String): Required. - * - color (String): Required. 6 character hex code, without a leading #. - **/ - this.updateLabel = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#deleteLabel(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - name (String): Required. - **/ - this.deleteLabel = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getIssueLabels(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - **/ - this.getIssueLabels = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getAllMilestones(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - state (String): Optional. Validation rule: ` ^(open|closed)$ `. - * - sort (String): Optional. due_date, completeness, default: due_date Validation rule: ` ^(due_date|completeness)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getAllMilestones = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#getMilestone(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - **/ - this.getMilestone = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#createMilestone(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - title (String): Required. - * - state (String): Optional. Validation rule: ` ^(open|closed)$ `. - * - description (String): Optional. - * - due_on (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - **/ - this.createMilestone = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#updateMilestone(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - title (String): Required. - * - state (String): Optional. Validation rule: ` ^(open|closed)$ `. - * - description (String): Optional. - * - due_on (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - **/ - this.updateMilestone = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * issues#deleteMilestone(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - **/ - this.deleteMilestone = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(issues.issues); diff --git a/api/v3.0.0/issuesTest.js b/api/v3.0.0/issuesTest.js deleted file mode 100644 index c9f217bff9..0000000000 --- a/api/v3.0.0/issuesTest.js +++ /dev/null @@ -1,423 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[issues]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /issues (getAll)", function(next) { - client.issues.getAll( - { - filter: "created", - state: "open", - labels: "", - sort: "updated", - direction: "asc" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 1); - var issue = res[0]; - Assert.equal(issue.title, "My First Issue"); - Assert.equal(issue.number, 2); - Assert.equal(issue.state, "open"); - Assert.equal(issue.body, "Willing to start a debate on the best recipe of macaroni."); - Assert.equal(issue.assignee.login, "mikedeboertest"); - - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/issues (repoIssues)", function(next) { - client.issues.repoIssues( - { - user: "mikedeboertest", - repo: "node_chat", - state: "open", - sort: "updated", - direction: "asc" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.length, 1); - var issue = res[0]; - Assert.equal(issue.title, "My First Issue"); - Assert.equal(issue.number, 2); - Assert.equal(issue.state, "open"); - Assert.equal(issue.body, "Willing to start a debate on the best recipe of macaroni."); - Assert.equal(issue.assignee.login, "mikedeboertest"); - - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/issues/:number (getRepoIssue)", function(next) { - client.issues.getRepoIssue( - { - user: "mikedeboertest", - repo: "node_chat", - number: 2 - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.title, "My First Issue"); - Assert.equal(res.number, 2); - Assert.equal(res.state, "open"); - Assert.equal(res.body, "Willing to start a debate on the best recipe of macaroni."); - Assert.equal(res.assignee.login, "mikedeboertest"); - - next(); - } - ); - }); -/* - it("should successfully execute POST /repos/:user/:repo/issues (create)", function(next) { - client.issues.create( - { - user: "String", - repo: "String", - title: "String", - body: "String", - assignee: "String", - milestone: "Number", - labels: "Json" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:user/:repo/issues/:number (edit)", function(next) { - client.issues.edit( - { - user: "String", - repo: "String", - number: "Number", - title: "String", - body: "String", - assignee: "String", - milestone: "Number", - labels: "Json" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/issues/:number/comments (getComments)", function(next) { - client.issues.getComments( - { - user: "String", - repo: "String", - number: "Number", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/issues/comments/:id (getComment)", function(next) { - client.issues.getComment( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/issues/:number/comments (createComment)", function(next) { - client.issues.createComment( - { - user: "String", - repo: "String", - number: "Number", - body: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:user/:repo/issues/comments/:id (editComment)", function(next) { - client.issues.editComment( - { - user: "String", - repo: "String", - id: "String", - body: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/issues/comments/:id (deleteComment)", function(next) { - client.issues.deleteComment( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/issues/:number/events (getEvents)", function(next) { - client.issues.getEvents( - { - user: "String", - repo: "String", - number: "Number", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/issues/events (getRepoEvents)", function(next) { - client.issues.getRepoEvents( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/issues/events/:id (getEvent)", function(next) { - client.issues.getEvent( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/labels (getLabels)", function(next) { - client.issues.getLabels( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/labels/:name (getLabel)", function(next) { - client.issues.getLabel( - { - user: "String", - repo: "String", - name: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/labels (createLabel)", function(next) { - client.issues.createLabel( - { - user: "String", - repo: "String", - name: "String", - color: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/labels/:name (updateLabel)", function(next) { - client.issues.updateLabel( - { - user: "String", - repo: "String", - name: "String", - color: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/labels/:name (deleteLabel)", function(next) { - client.issues.deleteLabel( - { - user: "String", - repo: "String", - name: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/milestones (getAllMilestones)", function(next) { - client.issues.getAllMilestones( - { - user: "String", - repo: "String", - state: "String", - sort: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/milestones/:number (getMilestone)", function(next) { - client.issues.getMilestone( - { - user: "String", - repo: "String", - number: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/milestones (createMilestone)", function(next) { - client.issues.createMilestone( - { - user: "String", - repo: "String", - title: "String", - state: "String", - description: "String", - due_on: "Date" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:user/:repo/milestones/:number (updateMilestone)", function(next) { - client.issues.updateMilestone( - { - user: "String", - repo: "String", - number: "Number", - title: "String", - state: "String", - description: "String", - due_on: "Date" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/milestones/:number (deleteMilestone)", function(next) { - client.issues.deleteMilestone( - { - user: "String", - repo: "String", - number: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - });*/ -}); diff --git a/api/v3.0.0/markdown.js b/api/v3.0.0/markdown.js deleted file mode 100644 index 90d7271baf..0000000000 --- a/api/v3.0.0/markdown.js +++ /dev/null @@ -1,118 +0,0 @@ -/** - * mixin markdown - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var markdown = module.exports = { - markdown: {} -}; - -(function() { - /** section: github - * markdown#render(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - text (String): Required. The Markdown text to render - * - mode (String): Optional. The rendering mode, `markdown` to render a document as plain Markdown, just like README files are rendered. `gfm` to render a document as user-content, e.g. like user comments or issues are rendered. In GFM mode, hard line breaks are always taken into account, and issue and user mentions are linked accordingly. Validation rule: ` ^(markdown|gfm)$ `. - * - context (String): Optional. The repository context, only taken into account when rendering as `gfm` - * - * https://developer.github.com/v3/markdown/#render-an-arbitrary-markdown-document - **/ - this.render = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * markdown#renderRaw(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - data (String): Required. Raw data to send as the body of the request - * - * https://developer.github.com/v3/markdown/#render-a-markdown-document-in-raw-mode - **/ - this.renderRaw = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(markdown.markdown); diff --git a/api/v3.0.0/markdownTest.js b/api/v3.0.0/markdownTest.js deleted file mode 100644 index 29846a0fd3..0000000000 --- a/api/v3.0.0/markdownTest.js +++ /dev/null @@ -1,56 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[markdown]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - /*client.authenticate({ - type: "oauth", - token: token - });*/ - }); - - it("should successfully execute POST /markdown (render)", function(next) { - client.markdown.render( - { - text: "Hello world github/linguist#1 **cool**, and #1!", - mode: "gfm", - context: "github/gollem" - }, - function(err, res) { - Assert.equal(err, null); - console.log(res); - next(); - } - ); - }); - - it("should successfully execute POST /markdown/raw (render)", function(next) { - client.markdown.renderRaw( - { - data: "Hello world github/linguist#1 **cool**, and #1!" - }, - function(err, res) { - Assert.equal(err, null); - console.log(res); - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/misc.js b/api/v3.0.0/misc.js deleted file mode 100644 index 6d3723b211..0000000000 --- a/api/v3.0.0/misc.js +++ /dev/null @@ -1,157 +0,0 @@ -/** - * mixin misc - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var misc = module.exports = { - misc: {} -}; - -(function() { - /** section: github - * misc#emojis(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * No other params, simply pass an empty Object literal `{}` - **/ - this.emojis = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * misc#meta(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * No other params, simply pass an empty Object literal `{}` - **/ - this.meta = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * misc#rateLimit(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * No other params, simply pass an empty Object literal `{}` - **/ - this.rateLimit = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(misc.misc); diff --git a/api/v3.0.0/miscTest.js b/api/v3.0.0/miscTest.js deleted file mode 100644 index 6cee44f2f7..0000000000 --- a/api/v3.0.0/miscTest.js +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[misc]", function() { - var client; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - }); - - it("should successfully execute GET /emojis (emojis)", function(next) { - client.misc.emojis( - {}, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - Assert.ifError(err); - // A common emoji on github - Assert('shipit' in res); - next(); - } - ); - }); - - it("should successfully execute GET /meta (meta)", function(next) { - client.misc.meta( - {}, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - Assert('hooks' in res); - Assert('git' in res); - next(); - } - ); - }); - - it("should successfully execute GET /rate_limit (rateLimit)", function(next) { - client.misc.rateLimit( - {}, - function(err, res) { - Assert.equal(err, null); - Assert('resources' in res); - Assert('core' in res.resources); - Assert(typeof res.resources.core.limit === 'number'); - Assert(typeof res.resources.core.remaining === 'number'); - Assert(typeof res.resources.core.reset === 'number'); - Assert('search' in res.resources); - Assert(typeof res.resources.search.limit === 'number'); - Assert(typeof res.resources.search.remaining === 'number'); - Assert(typeof res.resources.search.reset === 'number'); - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/orgs.js b/api/v3.0.0/orgs.js deleted file mode 100644 index de2e89f5ec..0000000000 --- a/api/v3.0.0/orgs.js +++ /dev/null @@ -1,1144 +0,0 @@ -/** - * mixin orgs - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var orgs = module.exports = { - orgs: {} -}; - -(function() { - /** section: github - * orgs#getFromUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#get(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/orgs/#get-an-organization - **/ - this.get = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#update(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - billing_email (String): Optional. Billing email address. This address is not publicized. - * - company (String): Optional. - * - email (String): Optional. Publicly visible email address. - * - location (String): Optional. - * - name (String): Optional. - * - * https://developer.github.com/v3/orgs/#edit-an-organization - **/ - this.update = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getMembers(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - filter (String): Optional. Validation rule: ` ^(all|2fa_disabled)$ `. - **/ - this.getMembers = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getMember(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - user (String): Required. - **/ - this.getMember = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#removeMember(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - user (String): Required. - **/ - this.removeMember = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getPublicMembers(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - **/ - this.getPublicMembers = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getPublicMember(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - user (String): Required. - **/ - this.getPublicMember = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#publicizeMembership(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - user (String): Required. - **/ - this.publicizeMembership = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#concealMembership(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - user (String): Required. - **/ - this.concealMembership = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getTeams(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getTeams = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getTeam(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - **/ - this.getTeam = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#createTeam(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - name (String): Required. - * - repo_names (Array): Optional. Array of strings - * - permission (String): Optional. `pull` - team members can pull, but not push or administer this repositories (Default), `push` - team members can pull and push, but not administer this repositores, `admin` - team members can pull, push and administer these repositories. Validation rule: ` ^(pull|push|admin)$ `. - **/ - this.createTeam = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#updateTeam(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - name (String): Required. - * - permission (String): Optional. `pull` - team members can pull, but not push or administer this repositories (Default), `push` - team members can pull and push, but not administer this repositores, `admin` - team members can pull, push and administer these repositories. Validation rule: ` ^(pull|push|admin)$ `. - **/ - this.updateTeam = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#deleteTeam(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - **/ - this.deleteTeam = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getTeamMembers(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getTeamMembers = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getTeamMember(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - user (String): Required. - **/ - this.getTeamMember = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#addTeamMember(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - user (String): Required. - **/ - this.addTeamMember = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#deleteTeamMember(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - user (String): Required. - **/ - this.deleteTeamMember = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#addTeamMembership(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - user (String): Required. - **/ - this.addTeamMembership = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getTeamRepos(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getTeamRepos = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#getTeamRepo(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - user (String): Required. - * - repo (String): Required. - **/ - this.getTeamRepo = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#addTeamRepo(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - user (String): Required. - * - repo (String): Required. - **/ - this.addTeamRepo = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * orgs#deleteTeamRepo(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - user (String): Required. - * - repo (String): Required. - **/ - this.deleteTeamRepo = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(orgs.orgs); diff --git a/api/v3.0.0/orgsTest.js b/api/v3.0.0/orgsTest.js deleted file mode 100644 index 44faeed898..0000000000 --- a/api/v3.0.0/orgsTest.js +++ /dev/null @@ -1,361 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[orgs]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /users/:user/orgs (getFromUser)", function(next) { - client.orgs.getFromUser( - { - user: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /orgs/:org (get)", function(next) { - client.orgs.get( - { - org: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /orgs/:org (update)", function(next) { - client.orgs.update( - { - org: "String", - billing_email: "String", - company: "String", - email: "String", - location: "String", - name: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /orgs/:org/members (getMembers)", function(next) { - client.orgs.getMembers( - { - org: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /orgs/:org/members/:user (getMember)", function(next) { - client.orgs.getMember( - { - org: "String", - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /orgs/:org/members/:user (removeMember)", function(next) { - client.orgs.removeMember( - { - org: "String", - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /orgs/:org/public_members (getPublicMembers)", function(next) { - client.orgs.getPublicMembers( - { - org: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /orgs/:org/public_members/:user (getPublicMember)", function(next) { - client.orgs.getPublicMember( - { - org: "String", - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /orgs/:org/public_members/:user (publicizeMembership)", function(next) { - client.orgs.publicizeMembership( - { - org: "String", - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /orgs/:org/public_members/:user (concealMembership)", function(next) { - client.orgs.concealMembership( - { - org: "String", - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /orgs/:org/teams (getTeams)", function(next) { - client.orgs.getTeams( - { - org: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /teams/:id (getTeam)", function(next) { - client.orgs.getTeam( - { - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /orgs/:org/teams (createTeam)", function(next) { - client.orgs.createTeam( - { - org: "String", - name: "String", - repo_names: "Array", - permission: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /teams/:id (updateTeam)", function(next) { - client.orgs.updateTeam( - { - id: "String", - name: "String", - permission: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /teams/:id (deleteTeam)", function(next) { - client.orgs.deleteTeam( - { - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /teams/:id/members (getTeamMembers)", function(next) { - client.orgs.getTeamMembers( - { - id: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /teams/:id/members/:user (getTeamMember)", function(next) { - client.orgs.getTeamMember( - { - id: "String", - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /teams/:id/members/:user (addTeamMember)", function(next) { - client.orgs.addTeamMember( - { - id: "String", - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /teams/:id/members/:user (deleteTeamMember)", function(next) { - client.orgs.deleteTeamMember( - { - id: "String", - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /teams/:id/repos (getTeamRepos)", function(next) { - client.orgs.getTeamRepos( - { - id: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /teams/:id/repos/:user/:repo (getTeamRepo)", function(next) { - client.orgs.getTeamRepo( - { - id: "String", - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /teams/:id/repos/:user/:repo (addTeamRepo)", function(next) { - client.orgs.addTeamRepo( - { - id: "String", - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /teams/:id/repos/:user/:repo (deleteTeamRepo)", function(next) { - client.orgs.deleteTeamRepo( - { - id: "String", - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/pullRequests.js b/api/v3.0.0/pullRequests.js deleted file mode 100644 index 96af44685c..0000000000 --- a/api/v3.0.0/pullRequests.js +++ /dev/null @@ -1,775 +0,0 @@ -/** - * mixin pullRequests - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var pullRequests = module.exports = { - pullRequests: {} -}; - -(function() { - /** section: github - * pullRequests#getAll(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - state (String): Optional. open, closed, or all Validation rule: ` ^(open|closed|all)$ `. - * - head (String): Optional. - * - base (String): Optional. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - sort (String): Optional. Possible values are: `created`, `updated`, `popularity`, `long-running`, Default: `created` Validation rule: ` ^(created|updated|popularity|long-running)$ `. - * - direction (String): Optional. Validation rule: ` ^(asc|desc)$ `. - * - * https://developer.github.com/v3/pulls/#list-pull-requests - **/ - this.getAll = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#get(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/pulls/#get-a-single-pull-request - **/ - this.get = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#create(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - title (String): Required. - * - body (String): Optional. - * - base (String): Required. The branch (or git ref) you want your changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repo that requests a merge to a base of another repo. - * - head (String): Required. The branch (or git ref) where your changes are implemented. - * - * https://developer.github.com/v3/pulls/#create-a-pull-request - **/ - this.create = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#createFromIssue(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - issue (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - base (String): Required. The branch (or git ref) you want your changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repo that requests a merge to a base of another repo. - * - head (String): Required. The branch (or git ref) where your changes are implemented. - * - * https://developer.github.com/v3/pulls/#create-a-pull-request - **/ - this.createFromIssue = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#update(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - state (String): Optional. Validation rule: ` ^(open|closed)$ `. - * - title (String): Required. - * - body (String): Optional. - * - * https://developer.github.com/v3/pulls/#update-a-pull-request - **/ - this.update = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#getCommits(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request - **/ - this.getCommits = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#getFiles(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/pulls/#list-pull-requests-files - **/ - this.getFiles = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#getMerged(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged - **/ - this.getMerged = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#merge(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - commit_message (String): Optional. The message that will be used for the merge commit - * - * https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button - **/ - this.merge = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#getComments(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getComments = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#getComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - **/ - this.getComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#createComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - body (String): Required. - * - commit_id (String): Required. Sha of the commit to comment on. - * - path (String): Required. Relative path of the file to comment on. - * - position (Number): Required. Column index in the diff to comment on. - **/ - this.createComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#createCommentReply(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - body (String): Required. - * - in_reply_to (Number): Required. - **/ - this.createCommentReply = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#updateComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - * - body (String): Required. - **/ - this.updateComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * pullRequests#deleteComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - number (Number): Required. Validation rule: ` ^[0-9]+$ `. - **/ - this.deleteComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(pullRequests.pullRequests); diff --git a/api/v3.0.0/pullRequestsTest.js b/api/v3.0.0/pullRequestsTest.js deleted file mode 100644 index 0b47fe8e89..0000000000 --- a/api/v3.0.0/pullRequestsTest.js +++ /dev/null @@ -1,281 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[pullRequests]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /repos/:user/:repo/pulls (getAll)", function(next) { - client.pullRequests.getAll( - { - user: "String", - repo: "String", - base: "String", - head: "String", - state: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/pulls/:number (get)", function(next) { - client.pullRequests.get( - { - user: "String", - repo: "String", - number: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/pulls (create)", function(next) { - client.pullRequests.create( - { - user: "String", - repo: "String", - title: "String", - body: "String", - base: "String", - head: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/pulls (createFromIssue)", function(next) { - client.pullRequests.createFromIssue( - { - user: "String", - repo: "String", - issue: "Number", - base: "String", - head: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:user/:repo/pulls/:number (update)", function(next) { - client.pullRequests.update( - { - user: "String", - repo: "String", - number: "Number", - state: "String", - title: "String", - body: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/pulls/:number/commits (getCommits)", function(next) { - client.pullRequests.getCommits( - { - user: "String", - repo: "String", - number: "Number", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/pulls/:number/files (getFiles)", function(next) { - client.pullRequests.getFiles( - { - user: "String", - repo: "String", - number: "Number", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/pulls/:number/merge (getMerged)", function(next) { - client.pullRequests.getMerged( - { - user: "String", - repo: "String", - number: "Number", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /repos/:user/:repo/pulls/:number/merge (merge)", function(next) { - client.pullRequests.merge( - { - user: "String", - repo: "String", - number: "Number", - commit_message: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/pulls/:number/comments (getComments)", function(next) { - client.pullRequests.getComments( - { - user: "String", - repo: "String", - number: "Number", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/pulls/comments/:number (getComment)", function(next) { - client.pullRequests.getComment( - { - user: "String", - repo: "String", - number: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/pulls/:number/comments (createComment)", function(next) { - client.pullRequests.createComment( - { - user: "String", - repo: "String", - number: "Number", - body: "String", - commit_id: "String", - path: "String", - position: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/pulls/:number/comments (createCommentReply)", function(next) { - client.pullRequests.createCommentReply( - { - user: "String", - repo: "String", - number: "Number", - body: "String", - in_reply_to: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:user/:repo/pulls/comments/:number (updateComment)", function(next) { - client.pullRequests.updateComment( - { - user: "String", - repo: "String", - number: "Number", - body: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/pulls/comments/:number (deleteComment)", function(next) { - client.pullRequests.deleteComment( - { - user: "String", - repo: "String", - number: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/releases.js b/api/v3.0.0/releases.js deleted file mode 100644 index 9e94c634f1..0000000000 --- a/api/v3.0.0/releases.js +++ /dev/null @@ -1,525 +0,0 @@ -/** - * mixin releases - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var releases = module.exports = { - releases: {} -}; - -(function() { - /** section: github - * releases#listReleases(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository - **/ - this.listReleases = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#getRelease(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - id (Number): Required. - * - repo (String): Required. - * - * https://developer.github.com/v3/repos/releases/#get-a-single-release - **/ - this.getRelease = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#createRelease(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - repo (String): Required. - * - tag_name (String): Required. String of the tag - * - target_commitish (String): Optional. Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master). - * - name (String): Optional. - * - body (String): Optional. - * - draft (Boolean): Optional. true to create a draft (unpublished) release, false to create a published one. Default: false - * - prerelease (Boolean): Optional. true to identify the release as a prerelease. false to identify the release as a full release. Default: false - * - * https://developer.github.com/v3/repos/releases/#create-a-release - **/ - this.createRelease = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#editRelease(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - id (Number): Required. - * - repo (String): Required. - * - tag_name (String): Required. String of the tag - * - target_commitish (String): Optional. Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master). - * - name (String): Optional. - * - body (String): Optional. - * - draft (Boolean): Optional. true to create a draft (unpublished) release, false to create a published one. Default: false - * - prerelease (Boolean): Optional. true to identify the release as a prerelease. false to identify the release as a full release. Default: false - * - * https://developer.github.com/v3/repos/releases/#edit-a-release - **/ - this.editRelease = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#deleteRelease(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - id (Number): Required. - * - repo (String): Required. - * - * https://developer.github.com/v3/repos/releases/#delete-a-release - **/ - this.deleteRelease = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#listAssets(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - id (Number): Required. - * - repo (String): Required. - * - * https://developer.github.com/v3/repos/releases/#list-assets-for-a-release - **/ - this.listAssets = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#getAsset(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - id (Number): Required. - * - repo (String): Required. - * - * https://developer.github.com/v3/repos/releases/#get-a-single-release-asset - **/ - this.getAsset = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#uploadAsset(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - id (Number): Required. - * - repo (String): Required. - * - name (String): Required. the file name of the asset - **/ - this.uploadAsset = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#editAsset(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - id (Number): Required. - * - repo (String): Required. - * - name (String): Required. - * - label (String): Optional. An alternate short description of the asset. Used in place of the filename. - * - * https://developer.github.com/v3/repos/releases/#edit-a-release-asset - **/ - this.editAsset = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * releases#deleteAsset(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - owner (String): Required. - * - id (Number): Required. - * - repo (String): Required. - * - * https://developer.github.com/v3/repos/releases/#delete-a-release-asset - **/ - this.deleteAsset = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(releases.releases); diff --git a/api/v3.0.0/releasesTest.js b/api/v3.0.0/releasesTest.js deleted file mode 100644 index 9b7e44e1f1..0000000000 --- a/api/v3.0.0/releasesTest.js +++ /dev/null @@ -1,262 +0,0 @@ - /* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); -var fs = require("fs"); -var mime = require("mime"); - -describe("[releases]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - var owner = "greggman"; - var repo = "test"; - var haveWriteAccess = true; // set to false if the authenticated person below does not have write access to the repo above - var releaseIdWithAsset = 393621; // Some release id from the repo above that has at least 1 asset. - var filePathToUpload = __filename; - var fileSizeToUpload = fs.statSync(filePathToUpload).size; - - var releaseId; // release id found when listing releases. Used for get release - var newReleaseId; // release id created when creating release, used for edit and delete release - var assetId; // asset id found when listing assets. Used for get asset - var newAssetId; // asset id used when creating asset. Used for edit and delete asset - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /repos/:owner/:repo/releases (listReleases)", function(next) { - client.releases.listReleases( - { - owner: owner, - repo: repo, - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res instanceof Array); - if (res instanceof Array && res.length > 0) { - releaseId = res[0].id; - } - next(); - } - ); - }); - - it("should successfully execute GET /repos/:owner/:repo/releases/:id (getRelease)", function(next) { - if (!releaseId) { - next(); - return; - } - client.releases.getRelease( - { - owner: owner, - id: releaseId, - repo: repo - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.id, releaseId); - next(); - } - ); - }); - - it("should successfully execute POST /repos/:owner/:repo/releases (createRelease)", function(next) { - if (!haveWriteAccess) { - next(); - return; - } - client.releases.createRelease( - { - owner: owner, - repo: repo, - tag_name: "node-github-tag", - target_commitish: "master", - name: "node-github-name", - body: "node-github-body", - draft: false, - prerelease: true, - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.tag_name, "node-github-tag"); - Assert.equal(res.target_commitish, "master"); - Assert.equal(res.name, "node-github-name"); - Assert.equal(res.body, "node-github-body"); - Assert.equal(res.assets.length, 0); - Assert.ok(res.prerelease); - Assert.ok(!res.draft); - newReleaseId = res.id; - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:owner/:repo/releases/:id (editRelease)", function(next) { - if (!haveWriteAccess) { - next(); - return; - } - client.releases.editRelease( - { - owner: owner, - id: newReleaseId, - repo: repo, - tag_name: "node-github-new-tag", - target_commitish: "master", - name: "node-github-new-name", - body: "node-github-new-body", - draft: true, - prerelease: true, - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.id, newReleaseId); - Assert.equal(res.tag_name, "node-github-new-tag"); - Assert.equal(res.target_commitish, "master"); - Assert.equal(res.name, "node-github-new-name"); - Assert.equal(res.body, "node-github-new-body"); - Assert.equal(res.assets.length, 0); - Assert.ok(res.prerelease); - Assert.ok(res.draft); - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:owner/:repo/releases/:id (deleteRelease)", function(next) { - if (!haveWriteAccess) { - next(); - return; - } - client.releases.deleteRelease( - { - owner: owner, - repo: repo, - id: newReleaseId, - }, - function(err, res) { - Assert.equal(err, null); - next(); - } - ); - }); - - it("should successfully execute GET /repos/:owner/:repo/releases/:id/assets (listAssets)", function(next) { - client.releases.listAssets( - { - owner: owner, - id: releaseIdWithAsset, - repo: repo - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res instanceof Array); - if (res instanceof Array && res.length > 0) { - assetId = res[0].id; - } - next(); - } - ); - }); - - it("should successfully execute GET /repos/:owner/:repo/releases/assets/:id (getAsset)", function(next) { - if (!assetId) { - next(); - return; - } - client.releases.getAsset( - { - owner: owner, - id: assetId, - repo: repo - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.id, assetId); - next(); - } - ); - }); - - it("should successfully execute POST /repos/:owner/:repo/releases/:id/assets (uploadAsset)", function(next) { - var name = "somenameornot.zip"; - client.releases.uploadAsset( - { - owner: owner, - id: releaseIdWithAsset, - repo: repo, - name: name, - filePath: filePathToUpload - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.content_type, mime.lookup(name)); // matches extension of name, not filePath - Assert.equal(res.state, "uploaded"); - Assert.equal(res.size, fileSizeToUpload); - Assert.equal(res.name, name); - newAssetId = res.id; - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:owner/:repo/releases/assets/:id (editAsset)", function(next) { - if (!newAssetId) { - next(); - return; - } - var newName = "somenewname.zip"; - client.releases.editAsset( - { - owner: owner, - id: newAssetId, - repo: repo, - name: newName, - label: "foo" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.state, "uploaded"); - Assert.equal(res.size, fileSizeToUpload); - Assert.equal(res.name, newName); - Assert.equal(res.label, "foo"); - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:owner/:repo/releases/assets/:id (deleteAsset)", function(next) { - if (!newAssetId) { - next(); - return; - } - client.releases.deleteAsset( - { - owner: owner, - id: newAssetId, - repo: repo - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/repos.js b/api/v3.0.0/repos.js deleted file mode 100644 index 6efa54233a..0000000000 --- a/api/v3.0.0/repos.js +++ /dev/null @@ -1,3574 +0,0 @@ -/** - * mixin repos - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var repos = module.exports = { - repos: {} -}; - -(function() { - /** section: github - * repos#getAll(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - type (String): Optional. Possible values: `all`, `owner`, `public`, `private`, `member`. Default: `all`. Validation rule: ` ^(all|owner|public|private|member)$ `. - * - sort (String): Optional. Possible values: `created`, `updated`, `pushed`, `full_name`. Default: `full_name`. Validation rule: ` ^(created|updated|pushed|full_name)$ `. - * - direction (String): Optional. Validation rule: ` ^(asc|desc)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#list-your-repositories - **/ - this.getAll = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getFromUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - type (String): Optional. Possible values: `all`, `owner`, `member`. Default: `public`. Validation rule: ` ^(all|owner|member)$ `. - * - sort (String): Optional. Possible values: `created`, `updated`, `pushed`, `full_name`. Default: `full_name`. Validation rule: ` ^(created|updated|pushed|full_name)$ `. - * - direction (String): Optional. Validation rule: ` ^(asc|desc)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFromUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getFromOrg(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - type (String): Optional. Possible values: `all`, `public`, `member`. Default: `all`. Validation rule: ` ^(all|public|member)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#list-organization-repositories - **/ - this.getFromOrg = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#create(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - name (String): Required. - * - description (String): Optional. - * - homepage (String): Optional. - * - private (Boolean): Optional. True to create a private repository, false to create a public one. Creating private repositories requires a paid GitHub account. Default is false. - * - has_issues (Boolean): Optional. True to enable issues for this repository, false to disable them. Default is true. - * - has_wiki (Boolean): Optional. True to enable the wiki for this repository, false to disable it. Default is true. - * - has_downloads (Boolean): Optional. True to enable downloads for this repository, false to disable them. Default is true. - * - auto_init (Boolean): Optional. True to create an initial commit with empty README. Default is false - * - gitignore_template (String): Optional. Desired language or platform .gitignore template to apply. Ignored if auto_init parameter is not provided. - * - * https://developer.github.com/v3/repos/#create - **/ - this.create = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#createFromOrg(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - name (String): Required. - * - description (String): Optional. - * - homepage (String): Optional. - * - private (Boolean): Optional. True to create a private repository, false to create a public one. Creating private repositories requires a paid GitHub account. Default is false. - * - has_issues (Boolean): Optional. True to enable issues for this repository, false to disable them. Default is true. - * - has_wiki (Boolean): Optional. True to enable the wiki for this repository, false to disable it. Default is true. - * - has_downloads (Boolean): Optional. True to enable downloads for this repository, false to disable them. Default is true. - * - auto_init (Boolean): Optional. True to create an initial commit with empty README. Default is false - * - gitignore_template (String): Optional. Desired language or platform .gitignore template to apply. Ignored if auto_init parameter is not provided. - * - team_id (Number): Optional. The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#create - **/ - this.createFromOrg = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#get(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - * https://developer.github.com/v3/repos/#get - **/ - this.get = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#one(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - **/ - this.one = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#update(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - name (String): Required. - * - description (String): Optional. - * - homepage (String): Optional. - * - private (Boolean): Optional. True to create a private repository, false to create a public one. Creating private repositories requires a paid GitHub account. Default is false. - * - has_issues (Boolean): Optional. True to enable issues for this repository, false to disable them. Default is true. - * - has_wiki (Boolean): Optional. True to enable the wiki for this repository, false to disable it. Default is true. - * - has_downloads (Boolean): Optional. True to enable downloads for this repository, false to disable them. Default is true. - * - default_branch (String): Optional. Updates the default branch for this repository. - * - * https://developer.github.com/v3/repos/#edit - **/ - this.update = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#delete(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - * https://developer.github.com/v3/repos/#delete-a-repository - **/ - this.delete = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#merge(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - base (String): Required. The branch (or git ref) you want your changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repo that requests a merge to a base of another repo. - * - head (String): Required. The branch (or git ref) where your changes are implemented. - * - commit_message (String): Optional. Commit message to use for the merge commit. If omitted, a default message will be used. - **/ - this.merge = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getContributors(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - anon (Boolean): Optional. Set to 1 or true to include anonymous contributors in results. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#list-contributors - **/ - this.getContributors = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getLanguages(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#list-languages - **/ - this.getLanguages = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getTeams(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#list-teams - **/ - this.getTeams = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getTags(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#list-tags - **/ - this.getTags = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getBranches(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#list-branches - **/ - this.getBranches = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getBranch(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - branch (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/repos/#get-branch - **/ - this.getBranch = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getCollaborators(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getCollaborators = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getCollaborator(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - collabuser (String): Required. - **/ - this.getCollaborator = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#addCollaborator(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - collabuser (String): Required. - **/ - this.addCollaborator = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#removeCollaborator(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - collabuser (String): Required. - **/ - this.removeCollaborator = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getCommits(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Optional. Sha or branch to start listing commits from. - * - path (String): Optional. Only commits containing this file path will be returned. - * - author (String): Optional. GitHub login or email address by which to filter by commit author. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - since (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - * - until (Date): Optional. Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ - **/ - this.getCommits = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getCommit(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - **/ - this.getCommit = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getAllCommitComments(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getAllCommitComments = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getCommitComments(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getCommitComments = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#createCommitComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - * - body (String): Required. - * - commit_id (String): Required. Sha of the commit to comment on. - * - path (String): Optional. Relative path of the file to comment on. - * - position (Number): Optional. Line index in the diff to comment on. - * - line (Number): Optional. Line number in the file to comment on. Defaults to 1. - **/ - this.createCommitComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getCommitComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.getCommitComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#updateCommitComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - * - body (String): Required. - **/ - this.updateCommitComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#compareCommits(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - base (String): Required. The branch (or git ref) you want your changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repo that requests a merge to a base of another repo. - * - head (String): Required. The branch (or git ref) where your changes are implemented. - **/ - this.compareCommits = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#deleteCommitComment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.deleteCommitComment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getReadme(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - ref (String): Optional. The String name of the Commit/Branch/Tag. Defaults to master. - **/ - this.getReadme = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getContent(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - path (String): Optional. The content path. - * - ref (String): Optional. The String name of the Commit/Branch/Tag. Defaults to master. - **/ - this.getContent = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#createContent(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - content (String): Optional. - * - message (String): Optional. - * - path (String): Optional. The content path. - * - ref (String): Optional. The String name of the Commit/Branch/Tag. Defaults to master. - **/ - this.createContent = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#createFile(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - path (String): Required. The content path. - * - message (String): Required. The commit message. - * - content (String): Required. The new file content, Base64 encoded. - * - branch (String): Optional. The branch name. If not provided, uses the repository’s default branch (usually master). - * - author (Json): Optional. - * - committer (Json): Optional. - **/ - this.createFile = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#updateFile(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - path (String): Required. The content path. - * - message (String): Required. The commit message. - * - content (String): Required. The updated file content, Base64 encoded. - * - sha (String): Required. The blob SHA of the file being replaced. - * - branch (String): Optional. The branch name. If not provided, uses the repository’s default branch (usually master). - * - author (Json): Optional. - * - committer (Json): Optional. - **/ - this.updateFile = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#deleteFile(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - path (String): Required. The content path. - * - message (String): Required. The commit message. - * - sha (String): Required. The blob SHA of the file being removed. - * - branch (String): Optional. The branch name. If not provided, uses the repository’s default branch (usually master). - * - author (Json): Optional. - * - committer (Json): Optional. - **/ - this.deleteFile = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getArchiveLink(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - ref (String): Optional. String of the name of the fully qualified reference (ie: heads/master). If it doesn’t have at least one slash, it will be rejected. - * - archive_format (String): Required. Either tarball or zipball Validation rule: ` ^(tarball|zipball)$ `. - **/ - this.getArchiveLink = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getDownloads(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getDownloads = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getDownload(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.getDownload = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#deleteDownload(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.deleteDownload = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getForks(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sort (String): Optional. Possible values: `newest`, `oldest`, `watchers`, default: `newest`. Validation rule: ` ^(newest|oldest|watchers)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getForks = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#fork(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - organization (String): Optional. Organization login. The repository will be forked into this organization. - **/ - this.fork = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getKeys(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getKeys = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getKey(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.getKey = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#createKey(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - title (String): Required. - * - key (String): Required. - **/ - this.createKey = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#updateKey(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - * - title (String): Required. - * - key (String): Required. - **/ - this.updateKey = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#deleteKey(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.deleteKey = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStargazers(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getStargazers = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStarred(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getStarred = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStarredFromUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getStarredFromUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStarring(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getStarring = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#star(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.star = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#unStar(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.unStar = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getWatchers(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getWatchers = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getWatched(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getWatched = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getWatchedFromUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getWatchedFromUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getWatching(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getWatching = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#watch(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.watch = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#unWatch(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.unWatch = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getHooks(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getHooks = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getHook(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.getHook = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#createHook(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - name (String): Required. - * - config (Json): Required. A Hash containing key/value pairs to provide settings for this hook. These settings vary between the services and are defined in the github-services repo. Booleans are stored internally as `1` for true, and `0` for false. Any JSON true/false values will be converted automatically. - * - events (Array): Optional. Determines what events the hook is triggered for. Default: `['push']`. - * - active (Boolean): Optional. Determines whether the hook is actually triggered on pushes. - **/ - this.createHook = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#updateHook(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - * - name (String): Required. - * - config (Json): Required. A Hash containing key/value pairs to provide settings for this hook. Modifying this will replace the entire config object. These settings vary between the services and are defined in the github-services repo. Booleans are stored internally as `1` for true, and `0` for false. Any JSON true/false values will be converted automatically. - * - events (Array): Optional. Determines what events the hook is triggered for. This replaces the entire array of events. Default: `['push']`. - * - add_events (Array): Optional. Determines a list of events to be added to the list of events that the Hook triggers for. - * - remove_events (Array): Optional. Determines a list of events to be removed from the list of events that the Hook triggers for. - * - active (Boolean): Optional. Determines whether the hook is actually triggered on pushes. - **/ - this.updateHook = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#testHook(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.testHook = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#deleteHook(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.deleteHook = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStatsContributors(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.getStatsContributors = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStatsCommitActivity(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.getStatsCommitActivity = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStatsCodeFrequency(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.getStatsCodeFrequency = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStatsParticipation(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.getStatsParticipation = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getStatsPunchCard(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - **/ - this.getStatsPunchCard = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getDeployments(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - sha (String): Optional. The short or long sha that was recorded at creation time. Default: none. - * - ref (String): Optional. The name of the ref. This can be a branch, tag, or sha. Default: none. - * - task (String): Optional. The name of the task for the deployment. e.g. deploy or deploy:migrations. Default: none. - * - environment (String): Optional. The name of the environment that was deployed to. e.g. staging or production. Default: none. - * - user (String): Required. - * - repo (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getDeployments = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#createDeployment(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - ref (String): Required. The ref to deploy. This can be a branch, tag, or sha. - * - task (String): Required. The named task to execute. e.g. deploy or deploy:migrations. Default: deploy - * - auto_merge (Boolean): Optional. Optional parameter to merge the default branch into the requested ref if it is behind the default branch. Default: true - * - required_contexts (Array): Optional. Optional array of status contexts verified against commit status checks. If this parameter is omitted from the parameters then all unique contexts will be verified before a deployment is created. To bypass checking entirely pass an empty array. Defaults to all unique contexts. - * - payload (String): Optional. Optional JSON payload with extra information about the deployment. Default: '' - * - environment (String): Optional. The name of the environment that was deployed to. e.g. staging or production. Default: none. - * - description (String): Optional. Optional short description. Default: '' - * - user (String): Required. - * - repo (String): Required. - **/ - this.createDeployment = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#getDeploymentStatuses(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.getDeploymentStatuses = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * repos#createDeploymentStatus(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - state (String): Optional. The state of the status. Can be one of pending, success, error, or failure. - * - target_url (String): Optional. The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Default: '' - * - description (String): Optional. A short description of the status. Default: '' - * - user (String): Required. - * - repo (String): Required. - * - id (String): Required. - **/ - this.createDeploymentStatus = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(repos.repos); diff --git a/api/v3.0.0/reposTest.js b/api/v3.0.0/reposTest.js deleted file mode 100644 index 356fab65be..0000000000 --- a/api/v3.0.0/reposTest.js +++ /dev/null @@ -1,1126 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[repos]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /user/repos (getAll)", function(next) { - client.repos.getAll( - { - type: "String", - sort: "String", - direction: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/repos (getFromUser)", function(next) { - client.repos.getFromUser( - { - user: "String", - type: "String", - sort: "String", - direction: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /orgs/:org/repos (getFromOrg)", function(next) { - client.repos.getFromOrg( - { - org: "String", - type: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /user/repos (create)", function(next) { - client.repos.create( - { - name: "String", - description: "String", - homepage: "String", - private: "Boolean", - has_issues: "Boolean", - has_wiki: "Boolean", - has_downloads: "Boolean", - auto_init: "Boolean", - gitignore_template: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /orgs/:org/repos (createFromOrg)", function(next) { - client.repos.createFromOrg( - { - org: "String", - name: "String", - description: "String", - homepage: "String", - private: "Boolean", - has_issues: "Boolean", - has_wiki: "Boolean", - has_downloads: "Boolean", - auto_init: "Boolean", - gitignore_template: "String", - team_id: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo (get)", function(next) { - client.repos.get( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:user/:repo (update)", function(next) { - client.repos.update( - { - user: "String", - repo: "String", - name: "String", - description: "String", - homepage: "String", - private: "Boolean", - has_issues: "Boolean", - has_wiki: "Boolean", - has_downloads: "Boolean" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo (delete)", function(next) { - client.repos.delete( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/merges (merge)", function(next) { - client.repos.merge( - { - user: "String", - repo: "String", - base: "String", - head: "String", - commit_message: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/contributors (getContributors)", function(next) { - client.repos.getContributors( - { - user: "String", - repo: "String", - anon: "Boolean", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/languages (getLanguages)", function(next) { - client.repos.getLanguages( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/teams (getTeams)", function(next) { - client.repos.getTeams( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/tags (getTags)", function(next) { - client.repos.getTags( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/branches (getBranches)", function(next) { - client.repos.getBranches( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/branches/:branch (getBranch)", function(next) { - client.repos.getBranches( - { - user: "String", - repo: "String", - branch: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/collaborators (getCollaborators)", function(next) { - client.repos.getCollaborators( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/collaborators/:collabuser (getCollaborator)", function(next) { - client.repos.getCollaborator( - { - user: "String", - repo: "String", - collabuser: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /repos/:user/:repo/collaborators/:collabuser (addCollaborator)", function(next) { - client.repos.addCollaborator( - { - user: "String", - repo: "String", - collabuser: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/collaborators/:collabuser (removeCollaborator)", function(next) { - client.repos.removeCollaborator( - { - user: "String", - repo: "String", - collabuser: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/commits (getCommits)", function(next) { - client.repos.getCommits( - { - user: "String", - repo: "String", - sha: "String", - path: "String", - page: "Number", - per_page: "Number", - author: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/commits/:sha (getCommit)", function(next) { - client.repos.getCommit( - { - user: "String", - repo: "String", - sha: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/comments (getAllCommitComments)", function(next) { - client.repos.getAllCommitComments( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/commits/:sha/comments (getCommitComments)", function(next) { - client.repos.getCommitComments( - { - user: "String", - repo: "String", - sha: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/commits/:sha/comments (createCommitComment)", function(next) { - client.repos.createCommitComment( - { - user: "String", - repo: "String", - sha: "String", - body: "String", - commit_id: "String", - path: "String", - position: "Number", - line: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/comments/:id (getCommitComment)", function(next) { - client.repos.getCommitComment( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:user/:repo/comments/:id (updateCommitComment)", function(next) { - client.repos.updateCommitComment( - { - user: "String", - repo: "String", - id: "String", - body: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/compare/:base...:head (compareCommits)", function(next) { - client.repos.compareCommits( - { - user: "String", - repo: "String", - base: "String", - head: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/comments/:id (deleteCommitComment)", function(next) { - client.repos.deleteCommitComment( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/readme (getReadme)", function(next) { - client.repos.getReadme( - { - user: "String", - repo: "String", - ref: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/contents/:path (getContent)", function(next) { - client.repos.getContent( - { - user: "String", - repo: "String", - path: "String", - ref: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - it("should successfully execute GET /repos/:user/:repo/contents/:path (createContent)", function(next) { - client.repos.getContent( - { - user: "String", - repo: "String", - path: "String", - ref: "String", - content:"String", - message:"String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /repos/:user/:repo/contents/:path (createFile)", function(next) { - client.repos.createFile( - { - user: "String", - repo: "String", - path: "String", - message: "String", - content: "String", - branch: "String", - author: "Json", - committer: "Json" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /repos/:user/:repo/contents/:path (updateFile)", function(next) { - client.repos.updateFile( - { - user: "String", - repo: "String", - path: "String", - message: "String", - content: "String", - sha: "String", - branch: "String", - author: "Json", - committer: "Json" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/contents/:path (deleteFile)", function(next) { - client.repos.deleteFile( - { - user: "String", - repo: "String", - path: "String", - message: "String", - sha: "String", - branch: "String", - author: "Json", - committer: "Json" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/:archive_format/:ref (getArchiveLink)", function(next) { - client.repos.getArchiveLink( - { - user: "String", - repo: "String", - archive_format: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/downloads (getDownloads)", function(next) { - client.repos.getDownloads( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/downloads/:id (getDownload)", function(next) { - client.repos.getDownload( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/downloads/:id (deleteDownload)", function(next) { - client.repos.deleteDownload( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/forks (getForks)", function(next) { - client.repos.getForks( - { - user: "String", - repo: "String", - sort: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/forks (fork)", function(next) { - client.repos.fork( - { - user: "String", - repo: "String", - organization: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/keys (getKeys)", function(next) { - client.repos.getKeys( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/keys/:id (getKey)", function(next) { - client.repos.getKey( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/keys (createKey)", function(next) { - client.repos.createKey( - { - user: "String", - repo: "String", - title: "String", - key: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /repos/:user/:repo/keys/:id (updateKey)", function(next) { - client.repos.updateKey( - { - user: "String", - repo: "String", - id: "String", - title: "String", - key: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/keys/:id (deleteKey)", function(next) { - client.repos.deleteKey( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/stargazers (getStargazers)", function(next) { - client.repos.getStargazers( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/starred (getStarred)", function(next) { - client.repos.getStarred( - { - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/starred (getStarredFromUser)", function(next) { - client.repos.getStarredFromUser( - { - user: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/starred/:user/:repo (getStarring)", function(next) { - client.repos.getStarring( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /user/starred/:user/:repo (watch)", function(next) { - client.repos.watch( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /user/starred/:user/:repo (unWatch)", function(next) { - client.repos.unWatch( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/watchers (getWatchers)", function(next) { - client.repos.getWatchers( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/watched (getWatched)", function(next) { - client.repos.getWatched( - { - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/watched (getWatchedFromUser)", function(next) { - client.repos.getWatchedFromUser( - { - user: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/watched/:user/:repo (getWatching)", function(next) { - client.repos.getWatching( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /user/watched/:user/:repo (watch)", function(next) { - client.repos.watch( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /user/watched/:user/:repo (unWatch)", function(next) { - client.repos.unWatch( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/hooks (getHooks)", function(next) { - client.repos.getHooks( - { - user: "String", - repo: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/hooks/:id (getHook)", function(next) { - client.repos.getHook( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/hooks (createHook)", function(next) { - client.repos.createHook( - { - user: "String", - repo: "String", - name: "String", - config: "Json", - events: "Array", - active: "Boolean" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /repos/:user/:repo/hooks/:id (updateHook)", function(next) { - client.repos.updateHook( - { - user: "String", - repo: "String", - id: "String", - name: "String", - config: "Json", - events: "Array", - add_events: "Array", - remove_events: "Array", - active: "Boolean" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/hooks/:id/test (testHook)", function(next) { - client.repos.testHook( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /repos/:user/:repo/hooks/:id (deleteHook)", function(next) { - client.repos.deleteHook( - { - user: "String", - repo: "String", - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/stats/contributors (getStatsContributors)", function(next) { - client.repos.getStatsContributors( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/stats/commit_activity (getStatsCommitActivity)", function(next) { - client.repos.getStatsCommitActivity( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/stats/code_frequency (getStatsCodeFrequency)", function(next) { - client.repos.getStatsCodeFrequency( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/stats/participation (getStatsParticipation)", function(next) { - client.repos.getStatsParticipation( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/stats/punch_card (getStatsPunchCard)", function(next) { - client.repos.getStatsPunchCard( - { - user: "String", - repo: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/routes.json b/api/v3.0.0/routes.json deleted file mode 100644 index dc9b2165fe..0000000000 --- a/api/v3.0.0/routes.json +++ /dev/null @@ -1,3915 +0,0 @@ -{ - "defines": { - "constants": { - "name": "Github", - "description": "A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API.", - "protocol": "https", - "host": "api.github.com", - "port": 443, - "documentation": "https://developer.github.com/v3", - "dateFormat": "YYYY-MM-DDTHH:MM:SSZ", - "requestFormat": "json", - "requestMedia": "application/vnd.github.v3+json" - }, - "response-headers": [ - "X-RateLimit-Limit", - "X-RateLimit-Remaining", - "X-RateLimit-Reset", - "X-Oauth-Scopes", - "Link", - "Location", - "Last-Modified", - "Etag", - "Status" - ], - "request-headers": [ - "If-Modified-Since", - "If-None-Match", - "Cookie", - "User-Agent", - "Accept", - "X-GitHub-OTP" - ], - "params": { - "files": { - "type": "Json", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters: 'content'" - }, - "user": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "org": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "repo": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "branch": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "sha": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "description": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "gist_id": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "Id (SHA1 hash) of the gist." - }, - "ref": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the name of the fully qualified reference (ie: heads/master). If it doesn’t have at least one slash, it will be rejected." - }, - "number": { - "type": "Number", - "required": true, - "validation": "^[0-9]+$", - "invalidmsg": "", - "description": "" - }, - "name": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "direction": { - "type": "String", - "required": false, - "validation": "^(asc|desc)$", - "invalidmsg": "asc or desc, default: desc.", - "description": "" - }, - "since": { - "type": "Date", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ" - }, - "until": { - "type": "Date", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ" - }, - "state": { - "type": "String", - "required": false, - "validation": "^(open|closed)$", - "invalidmsg": "open, closed, default: open", - "description": "" - }, - "color": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "6 character hex code, without a leading #.", - "description": "6 character hex code, without a leading #." - }, - "permission": { - "type": "String", - "required": false, - "validation": "^(pull|push|admin)$", - "invalidmsg": "", - "description": "`pull` - team members can pull, but not push or administer this repositories (Default), `push` - team members can pull and push, but not administer this repositores, `admin` - team members can pull, push and administer these repositories." - }, - "base": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The branch (or git ref) you want your changes pulled into. This should be an existing branch on the current repository. You cannot submit a pull request to one repo that requests a merge to a base of another repo." - }, - "head": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The branch (or git ref) where your changes are implemented." - }, - "commit_id": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "Sha of the commit to comment on.", - "description": "Sha of the commit to comment on." - }, - "line": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "Line index in the diff to comment on.", - "description": "Line index in the diff to comment on." - }, - "path": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "Relative path of the file to comment on.", - "description": "Relative path of the file to comment on." - }, - "position": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "Column index in the diff to comment on.", - "description": "Column index in the diff to comment on." - }, - "body": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "homepage": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "private": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "True to create a private repository, false to create a public one. Creating private repositories requires a paid GitHub account. Default is false." - }, - "has_issues": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "True to enable issues for this repository, false to disable them. Default is true." - }, - "has_wiki": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "True to enable the wiki for this repository, false to disable it. Default is true." - }, - "has_downloads": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "True to enable downloads for this repository, false to disable them. Default is true." - }, - "default_branch": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Updates the default branch for this repository." - }, - "collabuser": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "title": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "key": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "page": { - "type": "Number", - "required": false, - "validation": "^[0-9]+$", - "invalidmsg": "", - "description": "Page number of the results to fetch." - }, - "per_page": { - "type": "Number", - "required": false, - "validation": "^[0-9]+$", - "invalidmsg": "", - "description": "A custom page size up to 100. Default is 30." - }, - "scopes": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "A list of scopes that this authorization is in." - }, - "note": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "A note to remind you what the OAuth token is for." - }, - "note_url": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "A URL to remind you what app the OAuth token is for." - }, - "auto_init": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "True to create an initial commit with empty README. Default is false" - }, - "gitignore_template": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Desired language or platform .gitignore template to apply. Ignored if auto_init parameter is not provided." - }, - "content": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "message": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "order": { - "type": "String", - "required": false, - "validation": "^(asc|desc)$", - "invalidmsg": "The sort order if sort parameter is provided. One of asc or desc. Default: desc", - "description": "asc or desc" - }, - "q": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "Search Term", - "combined": true - }, - "data": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "Raw data to send as the body of the request" - } - } - }, - - "gists": { - "get-all": { - "url": "/gists", - "method": "GET", - "params": { - "$page": null, - "$per_page": null, - "$since": null - } - }, - - "get-from-user": { - "url": "/users/:user/gists", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null, - "$since": null - } - }, - - "create": { - "url": "/gists", - "method": "POST", - "params": { - "$description": null, - "public": { - "type": "Boolean", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$files": null - } - }, - - "edit": { - "url": "/gists/:id", - "method": "PATCH", - "params": { - "$id": null, - "$description": null, - "$files": null - } - }, - - "public": { - "url": "/gists/public", - "method": "GET", - "params": { - "$since": null - } - }, - - "starred": { - "url": "/gists/starred", - "method": "GET", - "params": { - "$since": null - } - }, - - "get": { - "url": "/gists/:id", - "method": "GET", - "params": { - "$id": null - } - }, - - "star": { - "url": "/gists/:id/star", - "method": "PUT", - "params": { - "$id": null - } - }, - - "delete-star": { - "url": "/gists/:id/star", - "method": "DELETE", - "params": { - "$id": null - } - }, - - "check-star": { - "url": "/gists/:id/star", - "method": "GET", - "params": { - "$id": null - } - }, - - "fork": { - "url": "/gists/:id/fork", - "method": "POST", - "params": { - "$id": null - } - }, - - "delete": { - "url": "/gists/:id", - "method": "DELETE", - "params": { - "$id": null - } - }, - - "get-comments": { - "url": "/gists/:gist_id/comments", - "method": "GET", - "params": { - "$gist_id": null - } - }, - - "get-comment": { - "url": "/gists/:gist_id/comments/:id", - "method": "GET", - "params": { - "$gist_id": null, - "$id": null - } - }, - - "create-comment": { - "url": "/gists/:gist_id/comments", - "method": "POST", - "params": { - "$gist_id": null, - "$body": null - } - }, - - "edit-comment": { - "url": "/gists/:gist_id/comments/:id", - "method": "PATCH", - "params": { - "$gist_id": null, - "$id": null, - "$body": null - } - }, - - "delete-comment": { - "url": "/gists/:gist_id/comments/:id", - "method": "DELETE", - "params": { - "$gist_id": null, - "$id": null - } - } - }, - - "gitdata": { - "get-blob": { - "url": "/repos/:user/:repo/git/blobs/:sha", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$sha": null, - "$page": null, - "$per_page": null - } - }, - - "create-blob": { - "url": "/repos/:user/:repo/git/blobs", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "content": { - "type": "String", - "required": true, - "allow-empty": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "encoding": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "get-commit": { - "url": "/repos/:user/:repo/git/commits/:sha", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$sha": null - } - }, - - "create-commit": { - "url": "/repos/:user/:repo/git/commits", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "message": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the commit message" - }, - "tree": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the SHA of the tree object this commit points to" - }, - "parents": { - "type": "Array", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "Array of the SHAs of the commits that were the parents of this commit. If omitted or empty, the commit will be written as a root commit. For a single parent, an array of one SHA should be provided, for a merge commit, an array of more than one should be provided." - }, - "author": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "committer": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "get-reference": { - "url": "/repos/:user/:repo/git/refs/:ref", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$ref": null - } - }, - - "get-all-references": { - "url": "/repos/:user/:repo/git/refs", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "create-reference": { - "url": "/repos/:user/:repo/git/refs", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$ref": null, - "$sha": null - } - }, - - "update-reference": { - "url": "/repos/:user/:repo/git/refs/:ref", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$ref": null, - "$sha": null, - "force": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Boolean indicating whether to force the update or to make sure the update is a fast-forward update. The default is false, so leaving this out or setting it to false will make sure you’re not overwriting work." - } - } - }, - - "delete-reference": { - "url": "/repos/:user/:repo/git/refs/:ref", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$ref": null - } - }, - - "get-tag": { - "url": "/repos/:user/:repo/git/tags/:sha", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$sha": null - } - }, - - "create-tag": { - "url": "/repos/:user/:repo/git/tags", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "tag": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the tag" - }, - "message": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the tag message" - }, - "object": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the SHA of the git object this is tagging" - }, - "type": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the type of the object we’re tagging. Normally this is a commit but it can also be a tree or a blob." - }, - "tagger": { - "type": "Json", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "JSON object that contains the following keys: `name` - String of the name of the author of the tag, `email` - String of the email of the author of the tag, `date` - Timestamp of when this object was tagged" - } - } - }, - - "get-tree": { - "url": "/repos/:user/:repo/git/trees/:sha", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$sha": null, - "recursive": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "create-tree": { - "url": "/repos/:user/:repo/git/trees", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "tree": { - "type": "Json", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "Array of Hash objects (of path, mode, type and sha) specifying a tree structure" - }, - "base_tree": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "String of the SHA1 of the tree you want to update with new data" - } - } - } - }, - - "issues": { - "get-all": { - "url": "/issues", - "method": "GET", - "params": { - "filter": { - "type": "String", - "required": false, - "validation": "^(all|assigned|created|mentioned|subscribed)$", - "invalidmsg": "", - "description": "" - }, - "state": { - "type": "String", - "required": false, - "validation": "^(open|closed|all)$", - "invalidmsg": "open, closed, all, default: open", - "description": "open, closed, or all" - }, - "labels": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "String list of comma separated Label names. Example: bug,ui,@high" - }, - "sort": { - "type": "String", - "required": false, - "validation": "^(created|updated|comments)$", - "invalidmsg": "created, updated, comments, default: created.", - "description": "" - }, - "$direction": null, - "$since": null, - "$page": null, - "$per_page": null - } - }, - - "repo-issues": { - "url": "/repos/:user/:repo/issues", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "milestone": { - "type": "String", - "required": false, - "validation": "^([0-9]+|none|\\*)$", - "invalidmsg": "", - "description": "" - }, - "state": { - "type": "String", - "required": false, - "validation": "^(open|closed|all)$", - "invalidmsg": "open, closed, all, default: open", - "description": "open, closed, or all" - }, - "assignee": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "String User login, `none` for Issues with no assigned User. `*` for Issues with any assigned User." - }, - "creator": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The user that created the issue." - }, - "mentioned": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "String User login." - }, - "labels": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "String list of comma separated Label names. Example: bug,ui,@high" - }, - "sort": { - "type": "String", - "required": false, - "validation": "^(created|updated|comments)$", - "invalidmsg": "created, updated, comments, default: created.", - "description": "" - }, - "$direction": null, - "$since": null, - "$page": null, - "$per_page": null - } - }, - - "get-repo-issue": { - "url": "/repos/:user/:repo/issues/:number", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null - } - }, - - "create": { - "url": "/repos/:user/:repo/issues", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "title": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "body": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "assignee": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Login for the user that this issue should be assigned to." - }, - "milestone": { - "type": "Number", - "required": false, - "validation": "^[0-9]+$", - "invalidmsg": "", - "description": "Milestone to associate this issue with." - }, - "labels": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Array of strings - Labels to associate with this issue." - } - } - }, - - "edit": { - "url": "/repos/:user/:repo/issues/:number", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "title": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "body": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "assignee": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Login for the user that this issue should be assigned to." - }, - "milestone": { - "type": "Number", - "required": false, - "validation": "^[0-9]+$", - "invalidmsg": "", - "description": "Milestone to associate this issue with." - }, - "labels": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Array of strings - Labels to associate with this issue." - }, - "state": { - "type": "String", - "required": false, - "validation": "^(open|closed)$", - "invalidmsg": "open, closed, default: open", - "description": "open or closed" - } - } - }, - - "repo-comments": { - "url": "/repos/:user/:repo/issues/comments", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "sort": { - "type": "String", - "required": false, - "validation": "^(created|updated)$", - "invalidmsg": "created, updated, default: created.", - "description": "" - }, - "$direction": null, - "$since": null, - "$page": null, - "$per_page": null - } - }, - - "get-comments": { - "url": "/repos/:user/:repo/issues/:number/comments", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$page": null, - "$per_page": null - } - }, - - "get-comment": { - "url": "/repos/:user/:repo/issues/comments/:id", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "create-comment": { - "url": "/repos/:user/:repo/issues/:number/comments", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "body": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "edit-comment": { - "url": "/repos/:user/:repo/issues/comments/:id", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$id": null, - "body": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "delete-comment": { - "url": "/repos/:user/:repo/issues/comments/:id", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "get-events": { - "url": "/repos/:user/:repo/issues/:number/events", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$page": null, - "$per_page": null - } - }, - - "get-repo-events": { - "url": "/repos/:user/:repo/issues/events", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-event": { - "url": "/repos/:user/:repo/issues/events/:id", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "get-labels": { - "url": "/repos/:user/:repo/labels", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-label": { - "url": "/repos/:user/:repo/labels/:name", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$name": null - } - }, - - "create-label": { - "url": "/repos/:user/:repo/labels", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$name": null, - "$color": null - } - }, - - "update-label": { - "url": "/repos/:user/:repo/labels/:name", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$name": null, - "$color": null - } - }, - - "delete-label": { - "url": "/repos/:user/:repo/labels/:name", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$name": null - } - }, - - "get-issue-labels": { - "url": "/repos/:user/:repo/issues/:number/labels", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null - } - }, - - "get-all-milestones": { - "url": "/repos/:user/:repo/milestones", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$state": null, - "sort": { - "type": "String", - "required": false, - "validation": "^(due_date|completeness)$", - "invalidmsg": "due_date, completeness, default: due_date", - "description": "due_date, completeness, default: due_date" - }, - "$page": null, - "$per_page": null - } - }, - - "get-milestone": { - "url": "/repos/:user/:repo/milestones/:number", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null - } - }, - - "create-milestone": { - "url": "/repos/:user/:repo/milestones", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "title": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$state": null, - "$description": null, - "due_on": { - "type": "Date", - "required": false, - "validation": "", - "invalidmsg": "Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ", - "description": "Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ" - } - } - }, - - "update-milestone": { - "url": "/repos/:user/:repo/milestones/:number", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "title": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$state": null, - "$description": null, - "due_on": { - "type": "Date", - "required": false, - "validation": "", - "invalidmsg": "Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ", - "description": "Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ" - } - } - }, - - "delete-milestone": { - "url": "/repos/:user/:repo/milestones/:number", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$number": null - } - } - }, - - "authorization": { - "get-all": { - "url": "/authorizations", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - "get": { - "url": "/authorizations/:id", - "method": "GET", - "params": { - "$id": null - } - }, - "create": { - "url": "/authorizations", - "method": "POST", - "params": { - "$scopes": null, - "$note": null, - "$note_url": null - } - }, - "update": { - "url": "/authorizations/:id", - "method": "PATCH", - "params": { - "$id": null, - "$scopes": null, - "add_scopes": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "A list of scopes to add to this authorization." - }, - "remove_scopes": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "A list of scopes to remove from this authorization." - }, - "$note": null, - "$note_url": null - } - }, - "delete": { - "url": "/authorizations/:id", - "method": "DELETE", - "params": { - "$id": null - } - } - }, - - "orgs": { - "get-from-user": { - "url": "/users/:user/orgs", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get": { - "url": "/orgs/:org", - "method": "GET", - "params": { - "$org": null, - "$page": null, - "$per_page": null - } - }, - - "update": { - "url": "/orgs/:org", - "method": "PATCH", - "params": { - "$org": null, - "billing_email": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Billing email address. This address is not publicized." - }, - "company": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "email": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Publicly visible email address." - }, - "location": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "name": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "get-members": { - "url": "/orgs/:org/members", - "method": "GET", - "params": { - "$org": null, - "$page": null, - "$per_page": null, - "filter": { - "type": "String", - "required": false, - "validation": "^(all|2fa_disabled)$", - "invalidmsg": "all, 2fa_disabled, default: all", - "description": "" - } - } - }, - - "get-member": { - "url": "/orgs/:org/members/:user", - "method": "GET", - "params": { - "$org": null, - "$user": null - } - }, - - "remove-member": { - "url": "/orgs/:org/members/:user", - "method": "DELETE", - "params": { - "$org": null, - "$user": null - } - }, - - "get-public-members": { - "url": "/orgs/:org/public_members", - "method": "GET", - "params": { - "$org": null - } - }, - - "get-public-member": { - "url": "/orgs/:org/public_members/:user", - "method": "GET", - "params": { - "$org": null, - "$user": null - } - }, - - "publicize-membership": { - "url": "/orgs/:org/public_members/:user", - "method": "PUT", - "params": { - "$org": null, - "$user": null - } - }, - - "conceal-membership": { - "url": "/orgs/:org/public_members/:user", - "method": "DELETE", - "params": { - "$org": null, - "$user": null - } - }, - - "get-teams": { - "url": "/orgs/:org/teams", - "method": "GET", - "params": { - "$org": null, - "$page": null, - "$per_page": null - } - }, - - "get-team": { - "url": "/teams/:id", - "method": "GET", - "params": { - "$id": null - } - }, - - "create-team": { - "url": "/orgs/:org/teams", - "method": "POST", - "params": { - "$org": null, - "$name": null, - "repo_names": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Array of strings" - }, - "$permission": null - } - }, - - "update-team": { - "url": "/teams/:id", - "method": "PATCH", - "params": { - "$id": null, - "$name": null, - "$permission": null - } - }, - - "delete-team": { - "url": "/teams/:id", - "method": "DELETE", - "params": { - "$id": null - } - }, - - "get-team-members": { - "url": "/teams/:id/members", - "method": "GET", - "params": { - "$id": null, - "$page": null, - "$per_page": null - } - }, - - "get-team-member": { - "url": "/teams/:id/members/:user", - "method": "GET", - "params": { - "$id": null, - "$user": null - } - }, - - "add-team-member": { - "url": "/teams/:id/members/:user", - "method": "PUT", - "params": { - "$id": null, - "$user": null - } - }, - - "delete-team-member": { - "url": "/teams/:id/members/:user", - "method": "DELETE", - "params": { - "$id": null, - "$user": null - } - }, - - "add-team-membership": { - "url": "/teams/:id/memberships/:user", - "method": "PUT", - "params": { - "$id": null, - "$user": null - } - }, - - "get-team-repos": { - "url": "/teams/:id/repos", - "method": "GET", - "params": { - "$id": null, - "$page": null, - "$per_page": null - } - }, - - "get-team-repo": { - "url": "/teams/:id/repos/:user/:repo", - "method": "GET", - "params": { - "$id": null, - "$user": null, - "$repo": null - } - }, - - "add-team-repo": { - "url": "/teams/:id/repos/:user/:repo", - "method": "PUT", - "params": { - "$id": null, - "$user": null, - "$repo": null - } - }, - - "delete-team-repo": { - "url": "/teams/:id/repos/:user/:repo", - "method": "DELETE", - "params": { - "$id": null, - "$user": null, - "$repo": null - } - } - }, - - "statuses": { - "get": { - "url": "/repos/:user/:repo/commits/:sha/statuses", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$sha": null - } - }, - - "get-combined": { - "url": "/repos/:user/:repo/commits/:sha/status", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$sha": null - } - }, - - "create": { - "url": "/repos/:user/:repo/statuses/:sha", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$sha": null, - "state": { - "type": "String", - "required": true, - "validation": "^(pending|success|error|failure)$", - "invalidmsg": "", - "description": "State of the status - can be one of pending, success, error, or failure." - }, - "target_url": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Target url to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the ‘source’ of the Status." - }, - "description": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Short description of the status." - }, - "context": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "A string label to differentiate this status from the status of other systems." - } - } - } - }, - - "pull-requests": { - "get-all": { - "url": "/repos/:user/:repo/pulls", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "state": { - "type": "String", - "required": false, - "validation": "^(open|closed|all)$", - "invalidmsg": "open, closed, all, default: open", - "description": "open, closed, or all" - }, - "head": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "base": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$page": null, - "$per_page": null, - "sort": { - "type": "String", - "required": false, - "validation": "^(created|updated|popularity|long-running)$", - "invalidmsg": "Possible values are: `created`, `updated`, `popularity`, `long-running`, Default: `created`", - "description": "Possible values are: `created`, `updated`, `popularity`, `long-running`, Default: `created`" - }, - "$direction": null - } - }, - - "get": { - "url": "/repos/:user/:repo/pulls/:number", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null - } - }, - - "create": { - "url": "/repos/:user/:repo/pulls", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "title": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "body": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$base": null, - "$head": null - } - }, - - "create-from-issue": { - "url": "/repos/:user/:repo/pulls", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "issue": { - "type": "Number", - "required": true, - "validation": "^[0-9]+$", - "invalidmsg": "", - "description": "" - }, - "$base": null, - "$head": null - } - }, - - "update": { - "url": "/repos/:user/:repo/pulls/:number", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$state": null, - "title": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "body": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "get-commits": { - "url": "/repos/:user/:repo/pulls/:number/commits", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$page": null, - "$per_page": null - } - }, - - "get-files": { - "url": "/repos/:user/:repo/pulls/:number/files", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$page": null, - "$per_page": null - } - }, - - "get-merged": { - "url": "/repos/:user/:repo/pulls/:number/merge", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$page": null, - "$per_page": null - } - }, - - "merge": { - "url": "/repos/:user/:repo/pulls/:number/merge", - "method": "PUT", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "commit_message": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The message that will be used for the merge commit" - } - } - }, - - "get-comments": { - "url": "/repos/:user/:repo/pulls/:number/comments", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$page": null, - "$per_page": null - } - }, - - "get-comment": { - "url": "/repos/:user/:repo/pulls/comments/:number", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$number": null - } - }, - - "create-comment": { - "url": "/repos/:user/:repo/pulls/:number/comments", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$body": null, - "$commit_id": null, - "$path": null, - "$position": null - } - }, - - "create-comment-reply": { - "url": "/repos/:user/:repo/pulls/:number/comments", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$body": null, - "in_reply_to": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "update-comment": { - "url": "/repos/:user/:repo/pulls/comments/:number", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$number": null, - "$body": null - } - }, - - "delete-comment": { - "url": "/repos/:user/:repo/pulls/comments/:number", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$number": null - } - } - }, - - "repos": { - "get-all": { - "url": "/user/repos", - "method": "GET", - "params": { - "type": { - "type": "String", - "required": false, - "validation": "^(all|owner|public|private|member)$", - "invalidmsg": "Possible values: `all`, `owner`, `public`, `private`, `member`. Default: `all`.", - "description": "Possible values: `all`, `owner`, `public`, `private`, `member`. Default: `all`." - }, - "sort": { - "type": "String", - "required": false, - "validation": "^(created|updated|pushed|full_name)$", - "invalidmsg": "Possible values: `created`, `updated`, `pushed`, `full_name`. Default: `full_name`.", - "description": "Possible values: `created`, `updated`, `pushed`, `full_name`. Default: `full_name`." - }, - "$direction": null, - "$page": null, - "$per_page": null - } - }, - - "get-from-user": { - "url": "/users/:user/repos", - "method": "GET", - "params": { - "$user": null, - "type": { - "type": "String", - "required": false, - "validation": "^(all|owner|member)$", - "invalidmsg": "Possible values: `all`, `owner`, `member`. Default: `public`.", - "description": "Possible values: `all`, `owner`, `member`. Default: `public`." - }, - "sort": { - "type": "String", - "required": false, - "validation": "^(created|updated|pushed|full_name)$", - "invalidmsg": "Possible values: `created`, `updated`, `pushed`, `full_name`. Default: `full_name`.", - "description": "Possible values: `created`, `updated`, `pushed`, `full_name`. Default: `full_name`." - }, - "$direction": null, - "$page": null, - "$per_page": null - } - }, - - "get-from-org": { - "url": "/orgs/:org/repos", - "method": "GET", - "params": { - "$org": null, - "type": { - "type": "String", - "required": false, - "validation": "^(all|public|member)$", - "invalidmsg": "Possible values: `all`, `public`, `member`. Default: `all`.", - "description": "Possible values: `all`, `public`, `member`. Default: `all`." - }, - "$page": null, - "$per_page": null - } - }, - - "create": { - "url": "/user/repos", - "method": "POST", - "params": { - "$name": null, - "$description": null, - "$homepage": null, - "$private": null, - "$has_issues": null, - "$has_wiki": null, - "$has_downloads": null, - "$auto_init": null, - "$gitignore_template": null - } - }, - - "create-from-org": { - "url": "/orgs/:org/repos", - "method": "POST", - "params": { - "$org": null, - "$name": null, - "$description": null, - "$homepage": null, - "$private": null, - "$has_issues": null, - "$has_wiki": null, - "$has_downloads": null, - "$auto_init": null, - "$gitignore_template": null, - "team_id": { - "type": "Number", - "required": false, - "validation": "^[0-9]+$", - "invalidmsg": "", - "description": "The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization." - } - } - }, - - "get": { - "url": "/repos/:user/:repo", - "method": "GET", - "params": { - "$user": null, - "$repo": null - } - }, - - "one": { - "url": "/repositories/:id", - "method": "GET", - "params": { - "$id": null - } - }, - - "update": { - "url": "/repos/:user/:repo", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$name": null, - "$description": null, - "$homepage": null, - "$private": null, - "$has_issues": null, - "$has_wiki": null, - "$has_downloads": null, - "$default_branch": null - } - }, - - "delete": { - "url": "/repos/:user/:repo", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null - } - }, - - "merge": { - "url": "/repos/:user/:repo/merges", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$base": null, - "$head": null, - "commit_message": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Commit message to use for the merge commit. If omitted, a default message will be used." - } - } - }, - - "get-contributors": { - "url": "/repos/:user/:repo/contributors", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "anon": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Set to 1 or true to include anonymous contributors in results." - }, - "$page": null, - "$per_page": null - } - }, - - "get-languages": { - "url": "/repos/:user/:repo/languages", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-teams": { - "url": "/repos/:user/:repo/teams", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-tags": { - "url": "/repos/:user/:repo/tags", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-branches": { - "url": "/repos/:user/:repo/branches", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-branch": { - "url": "/repos/:user/:repo/branches/:branch", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$branch": null, - "$page": null, - "$per_page": null - } - }, - - "get-collaborators": { - "url": "/repos/:user/:repo/collaborators", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-collaborator": { - "url": "/repos/:user/:repo/collaborators/:collabuser", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$collabuser": null - } - }, - - "add-collaborator": { - "url": "/repos/:user/:repo/collaborators/:collabuser", - "method": "PUT", - "params": { - "$user": null, - "$repo": null, - "$collabuser": null - } - }, - - "remove-collaborator": { - "url": "/repos/:user/:repo/collaborators/:collabuser", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$collabuser": null - } - }, - - "get-commits": { - "url": "/repos/:user/:repo/commits", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "sha": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Sha or branch to start listing commits from." - }, - "path": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Only commits containing this file path will be returned." - }, - "author": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "GitHub login or email address by which to filter by commit author." - }, - "$page": null, - "$per_page": null, - "$since": null, - "$until": null - } - }, - - "get-commit": { - "url": "/repos/:user/:repo/commits/:sha", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$sha": null - } - }, - - "get-all-commit-comments": { - "url": "/repos/:user/:repo/comments", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-commit-comments": { - "url": "/repos/:user/:repo/commits/:sha/comments", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$sha": null, - "$page": null, - "$per_page": null - } - }, - - "create-commit-comment": { - "url": "/repos/:user/:repo/commits/:sha/comments", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$sha": null, - "$body": null, - "$commit_id": null, - "path": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Relative path of the file to comment on." - }, - "position": { - "type": "Number", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Line index in the diff to comment on." - }, - "line": { - "type": "Number", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Line number in the file to comment on. Defaults to 1." - } - } - }, - - "get-commit-comment": { - "url": "/repos/:user/:repo/comments/:id", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "update-commit-comment": { - "url": "/repos/:user/:repo/comments/:id", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$id": null, - "$body": null - } - }, - - "compare-commits": { - "url": "/repos/:user/:repo/compare/:base...:head", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$base": null, - "$head": null - } - }, - - "delete-commit-comment": { - "url": "/repos/:user/:repo/comments/:id", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "get-readme": { - "url": "/repos/:user/:repo/readme", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "ref": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The String name of the Commit/Branch/Tag. Defaults to master." - } - } - }, - - "get-content": { - "url": "/repos/:user/:repo/contents/:path", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "path": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The content path." - }, - "ref": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The String name of the Commit/Branch/Tag. Defaults to master." - } - } - }, - "create-content": { - "url": "/repos/:user/:repo/contents/:path", - "method": "PUT", - "params": { - "$user": null, - "$repo": null, - "$content":null, - "$message":null, - "path": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The content path." - }, - "ref": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The String name of the Commit/Branch/Tag. Defaults to master." - } - } - }, - - "create-file": { - "url": "/repos/:user/:repo/contents/:path", - "method": "PUT", - "params": { - "$user": null, - "$repo": null, - "path": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The content path." - }, - "message": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The commit message." - }, - "content": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The new file content, Base64 encoded." - }, - "branch": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The branch name. If not provided, uses the repository’s default branch (usually master)." - }, - "author": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "committer": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "update-file": { - "url": "/repos/:user/:repo/contents/:path", - "method": "PUT", - "params": { - "$user": null, - "$repo": null, - "path": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The content path." - }, - "message": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The commit message." - }, - "content": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The updated file content, Base64 encoded." - }, - "sha": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The blob SHA of the file being replaced." - }, - "branch": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The branch name. If not provided, uses the repository’s default branch (usually master)." - }, - "author": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "committer": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "delete-file": { - "url": "/repos/:user/:repo/contents/:path", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "path": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The content path." - }, - "message": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The commit message." - }, - "sha": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The blob SHA of the file being removed." - }, - "branch": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The branch name. If not provided, uses the repository’s default branch (usually master)." - }, - "author": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "committer": { - "type": "Json", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "get-archive-link": { - "url": "/repos/:user/:repo/:archive_format/:ref", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "ref": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "String of the name of the fully qualified reference (ie: heads/master). If it doesn’t have at least one slash, it will be rejected." - }, - "archive_format": { - "type": "String", - "required": true, - "validation": "^(tarball|zipball)$", - "invalidmsg": "Either tarball or zipball", - "description": "Either tarball or zipball" - } - } - }, - - "get-downloads": { - "url": "/repos/:user/:repo/downloads", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-download": { - "url": "/repos/:user/:repo/downloads/:id", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "delete-download": { - "url": "/repos/:user/:repo/downloads/:id", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "get-forks": { - "url": "/repos/:user/:repo/forks", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "sort": { - "type": "String", - "required": false, - "validation": "^(newest|oldest|watchers)$", - "invalidmsg": "Possible values: `newest`, `oldest`, `watchers`, default: `newest`.", - "description": "Possible values: `newest`, `oldest`, `watchers`, default: `newest`." - }, - "$page": null, - "$per_page": null - } - }, - - "fork": { - "url": "/repos/:user/:repo/forks", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "organization": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Organization login. The repository will be forked into this organization." - } - } - }, - - "get-keys": { - "url": "/repos/:user/:repo/keys", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-key": { - "url": "/repos/:user/:repo/keys/:id", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "create-key": { - "url": "/repos/:user/:repo/keys", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$title": null, - "$key": null - } - }, - - "update-key": { - "url": "/repos/:user/:repo/keys/:id", - "method": "PUT", - "params": { - "$user": null, - "$repo": null, - "$id": null, - "$title": null, - "$key": null - } - }, - - "delete-key": { - "url": "/repos/:user/:repo/keys/:id", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "get-stargazers": { - "url": "/repos/:user/:repo/stargazers", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-starred": { - "url": "/user/starred", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - - "get-starred-from-user": { - "url": "/users/:user/starred", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-starring": { - "url": "/user/starred/:user/:repo", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "star": { - "url": "/user/starred/:user/:repo", - "method": "PUT", - "params": { - "$user": null, - "$repo": null - } - }, - - "un-star": { - "url": "/user/starred/:user/:repo", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null - } - }, - - "get-watchers": { - "url": "/repos/:user/:repo/watchers", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-watched": { - "url": "/user/watched", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - - "get-watched-from-user": { - "url": "/users/:user/watched", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-watching": { - "url": "/user/watched/:user/:repo", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "watch": { - "url": "/user/watched/:user/:repo", - "method": "PUT", - "params": { - "$user": null, - "$repo": null - } - }, - - "un-watch": { - "url": "/user/watched/:user/:repo", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null - } - }, - - "get-hooks": { - "url": "/repos/:user/:repo/hooks", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-hook": { - "url": "/repos/:user/:repo/hooks/:id", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "create-hook": { - "url": "/repos/:user/:repo/hooks", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$name": null, - "config": { - "type": "Json", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "A Hash containing key/value pairs to provide settings for this hook. These settings vary between the services and are defined in the github-services repo. Booleans are stored internally as `1` for true, and `0` for false. Any JSON true/false values will be converted automatically." - }, - "events": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Determines what events the hook is triggered for. Default: `['push']`." - }, - "active": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Determines whether the hook is actually triggered on pushes." - } - } - }, - - "update-hook": { - "url": "/repos/:user/:repo/hooks/:id", - "method": "PATCH", - "params": { - "$user": null, - "$repo": null, - "$id": null, - "$name": null, - "config": { - "type": "Json", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "A Hash containing key/value pairs to provide settings for this hook. Modifying this will replace the entire config object. These settings vary between the services and are defined in the github-services repo. Booleans are stored internally as `1` for true, and `0` for false. Any JSON true/false values will be converted automatically." - }, - "events": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Determines what events the hook is triggered for. This replaces the entire array of events. Default: `['push']`." - }, - "add_events": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Determines a list of events to be added to the list of events that the Hook triggers for." - }, - "remove_events": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Determines a list of events to be removed from the list of events that the Hook triggers for." - }, - "active": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Determines whether the hook is actually triggered on pushes." - } - } - }, - - "test-hook": { - "url": "/repos/:user/:repo/hooks/:id/test", - "method": "POST", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "delete-hook": { - "url": "/repos/:user/:repo/hooks/:id", - "method": "DELETE", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "get-stats-contributors": { - "url": "/repos/:user/:repo/stats/contributors", - "method": "GET", - "params": { - "$user": null, - "$repo": null - } - }, - - "get-stats-commit-activity": { - "url": "/repos/:user/:repo/stats/commit_activity", - "method": "GET", - "params": { - "$user": null, - "$repo": null - } - }, - - "get-stats-code-frequency": { - "url": "/repos/:user/:repo/stats/code_frequency", - "method": "GET", - "params": { - "$user": null, - "$repo": null - } - }, - - "get-stats-participation": { - "url": "/repos/:user/:repo/stats/participation", - "method": "GET", - "params": { - "$user": null, - "$repo": null - } - }, - - "get-stats-punch-card": { - "url": "/repos/:user/:repo/stats/punch_card", - "method": "GET", - "params": { - "$user": null, - "$repo": null - } - }, - - "get-deployments": { - "url": "/repos/:user/:repo/deployments", - "method": "GET", - "params": { - "sha": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The short or long sha that was recorded at creation time. Default: none." - }, - "ref": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The name of the ref. This can be a branch, tag, or sha. Default: none." - }, - "task": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The name of the task for the deployment. e.g. deploy or deploy:migrations. Default: none." - }, - "environment": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The name of the environment that was deployed to. e.g. staging or production. Default: none." - }, - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "create-deployment": { - "url": "/repos/:user/:repo/deployments", - "method": "POST", - "params": { - "ref": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The ref to deploy. This can be a branch, tag, or sha." - }, - "task": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The named task to execute. e.g. deploy or deploy:migrations. Default: deploy" - }, - "auto_merge": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Optional parameter to merge the default branch into the requested ref if it is behind the default branch. Default: true" - }, - "required_contexts": { - "type": "Array", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Optional array of status contexts verified against commit status checks. If this parameter is omitted from the parameters then all unique contexts will be verified before a deployment is created. To bypass checking entirely pass an empty array. Defaults to all unique contexts." - }, - "payload": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Optional JSON payload with extra information about the deployment. Default: ''" - }, - "environment": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The name of the environment that was deployed to. e.g. staging or production. Default: none." - }, - "description": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Optional short description. Default: ''" - }, - "$user": null, - "$repo": null - } - }, - - "get-deployment-statuses": { - "url": "/repos/:user/:repo/deployments/:id/statuses", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$id": null - } - }, - - "create-deployment-status": { - "url": "/repos/:user/:repo/deployments/:id/statuses", - "method": "POST", - "params": { - "state": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The state of the status. Can be one of pending, success, error, or failure." - }, - "target_url": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The target URL to associate with this status. This URL should contain output to keep the user updated while the task is running or serve as historical information for what happened in the deployment. Default: ''" - }, - "description": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "A short description of the status. Default: ''" - }, - "$user": null, - "$repo": null, - "$id": null - } - } - }, - - "user": { - "get-all": { - "url": "/users", - "method": "GET", - "params": { - "since":{ - "type": "Number", - "required": false, - "validation": "", - "description": "The integer ID of the last User that you’ve seen." - } - } - - }, - - "get-from": { - "url": "/users/:user", - "method": "GET", - "params": { - "$user": null - } - }, - - "get": { - "url": "/user", - "method": "GET", - "params": {} - }, - - "update": { - "url": "/user", - "method": "PATCH", - "params": { - "name": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "email": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "blog": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "company": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "location": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "hireable": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "bio": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - } - } - }, - - "get-orgs": { - "url": "/user/orgs", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - - "edit-organization-membership": { - "url": "/user/memberships/orgs/:org", - "method": "PATCH", - "params": { - "$org": null, - "state": { - "type": "String", - "required": true, - "validation": "^(open|closed|active)$", - "invalidmsg": "", - "description": "" - } - } - }, - - "get-teams": { - "url": "/user/teams", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - - "get-emails": { - "url": "/user/emails", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - - "add-emails": { - "url": "/user/emails", - "method": "POST", - "params": {} - }, - - "delete-emails": { - "url": "/user/emails", - "method": "DELETE", - "params": {} - }, - - "get-followers": { - "url": "/users/:user/followers", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-following-from-user": { - "url": "/users/:user/following", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-following": { - "url": "/user/following", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - - "get-follow-user": { - "url": "/user/following/:user", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "follow-user": { - "url": "/user/following/:user", - "method": "PUT", - "params": { - "$user": null - } - }, - - "un-follow-user": { - "url": "/user/following/:user", - "method": "DELETE", - "params": { - "$user": null - } - }, - - "get-keys": { - "url": "/user/keys", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - - "get-keys-from-user": { - "url": "/users/:user/keys", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-key": { - "url": "/user/keys/:id", - "method": "GET", - "params": { - "$id": null - } - }, - - "create-key": { - "url": "/user/keys", - "method": "POST", - "params": { - "$title": null, - "$key": null - } - }, - - "update-key": { - "url": "/user/keys/:id", - "method": "PATCH", - "params": { - "$id": null, - "$title": null, - "$key": null - } - }, - - "delete-key": { - "url": "/user/keys/:id", - "method": "DELETE", - "params": { - "$id": null - } - } - }, - - "events": { - "get": { - "url": "/events", - "method": "GET", - "params": { - "$page": null, - "$per_page": null - } - }, - - "get-from-repo": { - "url": "/repos/:user/:repo/events", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-from-repo-issues": { - "url": "/repos/:user/:repo/issues/events", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-from-repo-network": { - "url": "/networks/:user/:repo/events", - "method": "GET", - "params": { - "$user": null, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - - "get-from-org": { - "url": "/orgs/:org/events", - "method": "GET", - "params": { - "$org": null, - "$page": null, - "$per_page": null - } - }, - - "get-received": { - "url": "/users/:user/received_events", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-received-public": { - "url": "/users/:user/received_events/public", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-from-user": { - "url": "/users/:user/events", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-from-user-public": { - "url": "/users/:user/events/public", - "method": "GET", - "params": { - "$user": null, - "$page": null, - "$per_page": null - } - }, - - "get-from-user-org": { - "url": "/users/:user/events/orgs/:org", - "method": "GET", - "params": { - "$user": null, - "$org": null, - "$page": null, - "$per_page": null - } - } - }, - - "releases": { - "list-releases": { - "url": "/repos/:owner/:repo/releases", - "method": "GET", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null, - "$page": null, - "$per_page": null - } - }, - "get-release": { - "url": "/repos/:owner/:repo/releases/:id", - "method": "GET", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null - } - }, - "create-release": { - "url": "/repos/:owner/:repo/releases", - "method": "POST", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null, - "tag_name": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the tag" - }, - "target_commitish": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master)." - }, - "name": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "body": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "draft": { - "type": "Boolean", - "validation": "", - "invalidmsg": "", - "description": "true to create a draft (unpublished) release, false to create a published one. Default: false" - }, - "prerelease": { - "type": "Boolean", - "validation": "", - "invalidmsg": "", - "description": "true to identify the release as a prerelease. false to identify the release as a full release. Default: false" - } - } - }, - "edit-release": { - "url": "/repos/:owner/:repo/releases/:id", - "method": "PATCH", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null, - "tag_name": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "String of the tag" - }, - "target_commitish": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "Specifies the commitish value that determines where the Git tag is created from. Can be any branch or commit SHA. Unused if the Git tag already exists. Default: the repository's default branch (usually master)." - }, - "name": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "body": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "draft": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "true to create a draft (unpublished) release, false to create a published one. Default: false" - }, - "prerelease": { - "type": "Boolean", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "true to identify the release as a prerelease. false to identify the release as a full release. Default: false" - } - } - }, - "delete-release": { - "url": "/repos/:owner/:repo/releases/:id", - "method": "DELETE", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null - } - }, - "list-assets": { - "url": "/repos/:owner/:repo/releases/:id/assets", - "method": "GET", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null - } - }, - "get-asset": { - "url": "/repos/:owner/:repo/releases/assets/:id", - "method": "GET", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null - } - }, - "upload-asset": { - "url": "/repos/:owner/:repo/releases/:id/assets", - "method": "POST", - "host": "uploads.github.com", - "hasFileBody": true, - "timeout": 0, - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null, - "name": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "the file name of the asset" - } - } - }, - "edit-asset": { - "url": "/repos/:owner/:repo/releases/assets/:id", - "method": "PATCH", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null, - "$name": null, - "label": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "An alternate short description of the asset. Used in place of the filename." - } - } - }, - "delete-asset": { - "url": "/repos/:owner/:repo/releases/assets/:id", - "method": "DELETE", - "params": { - "owner": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "id": { - "type": "Number", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "" - }, - "$repo": null - } - } - }, - - "search": { - "code": { - "url": "/search/code", - "method": "GET", - "params": { - "$q": null, - "sort": { - "type": "String", - "required": false, - "validation": "^indexed$", - "invalidmsg": "indexed only", - "description": "indexed only" - }, - "$order": null, - "$page": null, - "$per_page": null - } - }, - - "issues": { - "url": "/search/issues", - "method": "GET", - "params": { - "$q": null, - "sort": { - "type": "String", - "required": false, - "validation": "^(comments|created|updated)$", - "invalidmsg": "comments, created, or updated", - "description": "comments, created, or updated" - }, - "$order": null, - "$page": null, - "$per_page": null - } - }, - - "repos": { - "url": "/search/repositories", - "method": "GET", - "params": { - "$q": null, - "sort": { - "type": "String", - "required": false, - "validation": "^(stars|forks|updated)$", - "invalidmsg": "One of stars, forks, or updated. Default: results are sorted by best match.", - "description": "stars, forks, or updated" - }, - "$order": null, - "$page": null, - "$per_page": null - } - }, - - "users": { - "url": "/search/users", - "method": "GET", - "params": { - "$q": null, - "sort": { - "type": "String", - "required": false, - "validation": "^(followers|repositories|joined)$", - "invalidmsg": "Can be followers, repositories, or joined. Default: results are sorted by best match.", - "description": "followers, repositories, or joined" - }, - "$order": null, - "$page": null, - "$per_page": null - } - }, - - "email": { - "url": "/legacy/user/email/:email", - "method": "GET", - "params": { - "email": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "Email address" - } - } - } - }, - - "markdown": { - "render": { - "url": "/markdown", - "method": "POST", - "params": { - "text": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The Markdown text to render" - }, - "mode": { - "type": "String", - "required": false, - "validation": "^(markdown|gfm)$", - "invalidmsg": "", - "description": "The rendering mode, `markdown` to render a document as plain Markdown, just like README files are rendered. `gfm` to render a document as user-content, e.g. like user comments or issues are rendered. In GFM mode, hard line breaks are always taken into account, and issue and user mentions are linked accordingly." - }, - "context": { - "type": "String", - "required": false, - "validation": "", - "invalidmsg": "", - "description": "The repository context, only taken into account when rendering as `gfm`" - } - } - }, - - "render-raw": { - "url": "/markdown/raw", - "method": "POST", - "requestFormat": "raw", - "params": { - "$data": null - } - } - }, - - "gitignore": { - "templates": { - "url": "/gitignore/templates", - "method": "GET", - "params": { } - }, - "template": { - "url": "/gitignore/templates/:name", - "method": "GET", - "params": { - "name": { - "type": "String", - "required": true, - "validation": "", - "invalidmsg": "", - "description": "The name of the .gitignore template to get" - } - } - } - }, - - "misc": { - "emojis": { - "url": "/emojis", - "method": "GET", - "params": { } - }, - "meta": { - "url": "/meta", - "method": "GET", - "params": { } - }, - "rate-limit": { - "url": "/rate_limit", - "method": "GET", - "params": { } - } - } -} diff --git a/api/v3.0.0/search.js b/api/v3.0.0/search.js deleted file mode 100644 index ae91ca0fa7..0000000000 --- a/api/v3.0.0/search.js +++ /dev/null @@ -1,271 +0,0 @@ -/** - * mixin search - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var search = module.exports = { - search: {} -}; - -(function() { - /** section: github - * search#code(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - q (String): Required. Search Term - * - sort (String): Optional. indexed only Validation rule: ` ^indexed$ `. - * - order (String): Optional. asc or desc Validation rule: ` ^(asc|desc)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/search/#search-code - **/ - this.code = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * search#issues(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - q (String): Required. Search Term - * - sort (String): Optional. comments, created, or updated Validation rule: ` ^(comments|created|updated)$ `. - * - order (String): Optional. asc or desc Validation rule: ` ^(asc|desc)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/search/#search-issues - **/ - this.issues = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * search#repos(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - q (String): Required. Search Term - * - sort (String): Optional. stars, forks, or updated Validation rule: ` ^(stars|forks|updated)$ `. - * - order (String): Optional. asc or desc Validation rule: ` ^(asc|desc)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/search/#search-repositories - **/ - this.repos = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * search#users(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - q (String): Required. Search Term - * - sort (String): Optional. followers, repositories, or joined Validation rule: ` ^(followers|repositories|joined)$ `. - * - order (String): Optional. asc or desc Validation rule: ` ^(asc|desc)$ `. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - * - * https://developer.github.com/v3/search/#search-users - **/ - this.users = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * search#email(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - email (String): Required. Email address - **/ - this.email = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(search.search); diff --git a/api/v3.0.0/searchTest.js b/api/v3.0.0/searchTest.js deleted file mode 100644 index f95bc2d141..0000000000 --- a/api/v3.0.0/searchTest.js +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[search]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - /*client.authenticate({ - type: "oauth", - token: token - });*/ - }); - - it("should successfully execute GET /search/code/:q (code)", function(next) { - client.search.code( - { - q: ['test', 'repo:mikedeboertest/1423836276146'].join('+') - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.items.length, 1); - var file = res.items[0]; - Assert.equal(file.name, "TEST.md"); - - next(); - } - ); - }); - - it("should successfully execute GET /search/issues/:q (issues)", function(next) { - client.search.issues( - { - q: ['debate', 'repo:mikedeboertest/node_chat', 'state:open'].join('+') - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.items.length, 1); - var issue = res.items[0]; - Assert.equal(issue.title, "My First Issue"); - Assert.equal(issue.state, "open"); - - next(); - } - ); - }); - - it("should successfully execute GET /search/repositories/:q (repos)", function(next) { - client.search.repos( - { - q: ['pasta', 'language:JavaScript'].join('+') - }, - function(err, res) { - Assert.equal(err, null); - Assert.ok(res.items.length > 0); - Assert.equal(res.items[0].language, "JavaScript"); - - next(); - } - ); - }); - - it("should successfully execute GET /search/users/:q (users)", function(next) { - client.search.users( - { - q: "mikedeboer" - }, - function(err, res) { - Assert.equal(err, null); - Assert.equal(res.items.length, 2); - var user = res.items[0]; - Assert.equal(user.login, "mikedeboer"); - - client.search.users( - { - q: "location:Jyväskylä" - }, - function(err, res) { - Assert.equal(err, null); - //XXX: this is likely to change often. I added this for - // issue #159. - Assert.equal(res.items.length, 30); - var user = res.items[0]; - Assert.equal(user.login, "bebraw"); - - next(); - } - ); - } - ); - }); - - /*it("should successfully execute GET /search/user/email/:email (email)", function(next) { - client.search.email( - { - email: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - });*/ -}); diff --git a/api/v3.0.0/statuses.js b/api/v3.0.0/statuses.js deleted file mode 100644 index 1a376afd47..0000000000 --- a/api/v3.0.0/statuses.js +++ /dev/null @@ -1,167 +0,0 @@ -/** - * mixin statuses - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var statuses = module.exports = { - statuses: {} -}; - -(function() { - /** section: github - * statuses#get(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - **/ - this.get = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * statuses#getCombined(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - **/ - this.getCombined = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * statuses#create(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - repo (String): Required. - * - sha (String): Required. - * - state (String): Required. State of the status - can be one of pending, success, error, or failure. Validation rule: ` ^(pending|success|error|failure)$ `. - * - target_url (String): Optional. Target url to associate with this status. This URL will be linked from the GitHub UI to allow users to easily see the ‘source’ of the Status. - * - description (String): Optional. Short description of the status. - * - context (String): Optional. A string label to differentiate this status from the status of other systems. - **/ - this.create = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(statuses.statuses); diff --git a/api/v3.0.0/statusesTest.js b/api/v3.0.0/statusesTest.js deleted file mode 100644 index 5c23b4c7f3..0000000000 --- a/api/v3.0.0/statusesTest.js +++ /dev/null @@ -1,76 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[statuses]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /repos/:user/:repo/commits/:sha/statuses (get)", function(next) { - client.statuses.get( - { - user: "mikedeboer", - repo: "node-github", - sha: "30d607d8fd8002427b61273f25d442c233cbf631" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /repos/:user/:repo/commits/:sha/status (get)", function(next) { - client.statuses.getCombined( - { - user: "mikedeboer", - repo: "node-github", - sha: "30d607d8fd8002427b61273f25d442c233cbf631" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /repos/:user/:repo/statuses/:sha (create)", function(next) { - client.statuses.create( - { - user: "String", - repo: "String", - sha: "String", - state: "String", - target_url: "String", - description: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); -}); diff --git a/api/v3.0.0/user.js b/api/v3.0.0/user.js deleted file mode 100644 index d4d4f19a9f..0000000000 --- a/api/v3.0.0/user.js +++ /dev/null @@ -1,1043 +0,0 @@ -/** - * mixin user - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var user = module.exports = { - user: {} -}; - -(function() { - /** section: github - * user#getAll(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - since (Number): Optional. The integer ID of the last User that you’ve seen. - * - * https://developer.github.com/v3/users/#get-a-single-user - **/ - this.getAll = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getFrom(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - * https://developer.github.com/v3/users/#get-a-single-user - **/ - this.getFrom = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#get(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * No other params, simply pass an empty Object literal `{}` - * - * https://developer.github.com/v3/users/#get-a-single-user - **/ - this.get = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#update(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - name (String): Optional. - * - email (String): Optional. - * - blog (String): Optional. - * - company (String): Optional. - * - location (String): Optional. - * - hireable (Boolean): Optional. - * - bio (String): Optional. - * - * https://developer.github.com/v3/users/#update-the-authenticated-user - **/ - this.update = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getOrgs(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getOrgs = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#editOrganizationMembership(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - org (String): Required. - * - state (String): Required. Validation rule: ` ^(open|closed|active)$ `. - **/ - this.editOrganizationMembership = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getTeams(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getTeams = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getEmails(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getEmails = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#addEmails(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * No other params, simply pass an empty Object literal `{}` - **/ - this.addEmails = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#deleteEmails(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * No other params, simply pass an empty Object literal `{}` - **/ - this.deleteEmails = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getFollowers(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFollowers = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getFollowingFromUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFollowingFromUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getFollowing(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFollowing = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getFollowUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getFollowUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#followUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - **/ - this.followUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#unFollowUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - **/ - this.unFollowUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getKeys(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getKeys = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getKeysFromUser(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - user (String): Required. - * - page (Number): Optional. Page number of the results to fetch. Validation rule: ` ^[0-9]+$ `. - * - per_page (Number): Optional. A custom page size up to 100. Default is 30. Validation rule: ` ^[0-9]+$ `. - **/ - this.getKeysFromUser = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#getKey(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - **/ - this.getKey = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#createKey(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - title (String): Required. - * - key (String): Required. - **/ - this.createKey = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#updateKey(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - * - title (String): Required. - * - key (String): Required. - **/ - this.updateKey = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - - /** section: github - * user#deleteKey(msg, callback) -> null - * - msg (Object): Object that contains the parameters and their values to be sent to the server. - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * ##### Params on the `msg` object: - * - * - headers (Object): Optional. Key/ value pair of request headers to pass along with the HTTP request. Valid headers are: 'If-Modified-Since', 'If-None-Match', 'Cookie', 'User-Agent', 'Accept', 'X-GitHub-OTP'. - * - id (String): Required. - **/ - this.deleteKey = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "x-ratelimit-reset", "x-oauth-scopes", "link", "location", "last-modified", "etag", "status"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - }; - -}).call(user.user); diff --git a/api/v3.0.0/userTest.js b/api/v3.0.0/userTest.js deleted file mode 100644 index c7b7a1061e..0000000000 --- a/api/v3.0.0/userTest.js +++ /dev/null @@ -1,304 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[user]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - - it("should successfully execute GET /users/:user (getFrom)", function(next) { - client.user.getFrom( - { - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user (get)", function(next) { - client.user.get( - {}, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /user (update)", function(next) { - client.user.update( - { - name: "String", - email: "String", - blog: "String", - company: "String", - location: "String", - hireable: "Boolean", - bio: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/orgs (getOrgs)", function(next) { - client.user.getOrgs( - { - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/teams (getTeams)", function(next) { - client.user.getTeams( - { - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/emails (getEmails)", function(next) { - client.user.getEmails( - { - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /user/emails (addEmails)", function(next) { - client.user.addEmails( - {}, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /user/emails (deleteEmails)", function(next) { - client.user.deleteEmails( - {}, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/followers (getFollowers)", function(next) { - client.user.getFollowers( - { - user: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/following (getFollowingFromUser)", function(next) { - client.user.getFollowingFromUser( - { - user: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/following (getFollowing)", function(next) { - client.user.getFollowing( - { - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/following/:user (getFollowUser)", function(next) { - client.user.getFollowUser( - { - user: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PUT /user/following/:user (followUser)", function(next) { - client.user.followUser( - { - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /user/following/:user (unFollowUser)", function(next) { - client.user.unFollowUser( - { - user: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/keys (getKeys)", function(next) { - client.user.getKeys( - { - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /users/:user/keys (getKeysFromUser)", function(next) { - client.user.getKeysFromUser( - { - user: "String", - page: "Number", - per_page: "Number" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute GET /user/keys/:id (getKey)", function(next) { - client.user.getKey( - { - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute POST /user/keys (createKey)", function(next) { - client.user.createKey( - { - title: "String", - key: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute PATCH /user/keys/:id (updateKey)", function(next) { - client.user.updateKey( - { - id: "String", - title: "String", - key: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); - - it("should successfully execute DELETE /user/keys/:id (deleteKey)", function(next) { - client.user.deleteKey( - { - id: "String" - }, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); -}); diff --git a/assets/create-an-issue-reference.png b/assets/create-an-issue-reference.png new file mode 100644 index 0000000000..a9754a764a Binary files /dev/null and b/assets/create-an-issue-reference.png differ diff --git a/assets/squash-and-merge-dialog.png b/assets/squash-and-merge-dialog.png new file mode 100644 index 0000000000..3d4ff90023 Binary files /dev/null and b/assets/squash-and-merge-dialog.png differ diff --git a/error.js b/error.js deleted file mode 100644 index 2da83f2984..0000000000 --- a/error.js +++ /dev/null @@ -1,117 +0,0 @@ -/** section: github - * class HttpError - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -var Util = require("util"); - -exports.HttpError = function(message, code) { - Error.call(this, message); - //Error.captureStackTrace(this, arguments.callee); - this.message = message; - this.code = code; -}; -Util.inherits(exports.HttpError, Error); - -(function() { - /** - * HttpError#toString() -> String - * - * Returns the stringified version of the error (i.e. the message). - **/ - this.toString = function() { - return this.message; - }; - - /** - * HttpError#toJSON() -> Object - * - * Returns a JSON object representation of the error. - **/ - this.toJSON = function() { - return { - code: this.code, - status: this.defaultMessage, - message: this.message - }; - }; - -}).call(exports.HttpError.prototype); - - -var statusCodes = { - 400: "Bad Request", - 401: "Unauthorized", - 402: "Payment Required", - 403: "Forbidden", - 404: "Not Found", - 405: "Method Not Allowed", - 406: "Not Acceptable", - 407: "Proxy Authentication Required", - 408: "Request Timeout", - 409: "Conflict", - 410: "Gone", - 411: "Length Required", - 412: "Precondition Failed", - 413: "Request Entity Too Large", - 414: "Request-URI Too Long", - 415: "Unsupported Media Type", - 416: "Requested Range Not Satisfiable", - 417: "Expectation Failed", - 420: "Enhance Your Calm", - 422: "Unprocessable Entity", - 423: "Locked", - 424: "Failed Dependency", - 425: "Unordered Collection", - 426: "Upgrade Required", - 428: "Precondition Required", - 429: "Too Many Requests", - 431: "Request Header Fields Too Large", - 444: "No Response", - 449: "Retry With", - 499: "Client Closed Request", - 500: "Internal Server Error", - 501: "Not Implemented", - 502: "Bad Gateway", - 503: "Service Unavailable", - 504: "Gateway Timeout", - 505: "HTTP Version Not Supported", - 506: "Variant Also Negotiates", - 507: "Insufficient Storage", - 508: "Loop Detected", - 509: "Bandwidth Limit Exceeded", - 510: "Not Extended", - 511: "Network Authentication Required" -}; - -for (var status in statusCodes) { - var defaultMsg = statusCodes[status]; - - var error = (function(defaultMsg, status) { - return function(msg) { - this.defaultMessage = defaultMsg; - exports.HttpError.call(this, msg || status + ": " + defaultMsg, status); - - if (status >= 500) - Error.captureStackTrace(this, arguments.callee); - }; - })(defaultMsg, status); - - Util.inherits(error, exports.HttpError); - - var className = toCamelCase(defaultMsg); - exports[className] = error; - exports[status] = error; -} - -function toCamelCase(str) { - return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function(match) { - return match.charAt(match.length-1).toUpperCase(); - }); -} \ No newline at end of file diff --git a/generate.js b/generate.js deleted file mode 100755 index a5e553dc60..0000000000 --- a/generate.js +++ /dev/null @@ -1,471 +0,0 @@ -#!/usr/bin/env node -/** section: github, internal - * class ApiGenerator - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var Fs = require("fs"); -var Path = require("path"); -var Url = require("url"); - -var Async = require("async"); -var Optimist = require("optimist"); -var Util = require("./util"); - -var IndexTpl = Fs.readFileSync(__dirname + "/templates/index.js.tpl", "utf8"); -var SectionTpl = Fs.readFileSync(__dirname + "/templates/section.js.tpl", "utf8"); -var HandlerTpl = Fs.readFileSync(__dirname + "/templates/handler.js.tpl", "utf8"); -var AfterRequestTpl = Fs.readFileSync(__dirname + "/templates/after_request.js.tpl", "utf8"); -var TestSectionTpl = Fs.readFileSync(__dirname + "/templates/test_section.js.tpl", "utf8"); -var TestHandlerTpl = Fs.readFileSync(__dirname + "/templates/test_handler.js.tpl", "utf8"); - -var DocSectionsMap = { - "authorization": "oauth_authorizations", - "gitdata": "git", - "pull-requests": "pulls", - "pullRequests": "pulls", - "releases": "repos/releases", - "user": "users" -}; - -var main = module.exports = function(versions, tests, restore) { - Util.log("Generating for versions", Object.keys(versions)); - - Async.each(Object.keys(versions), function(version, versionDone) { - var dir = Path.join(__dirname, "api", version); - - // If we're in restore mode, move .bak file back to their original position - // and short-circuit. - if (restore) { - var bakRE = /\.bak$/; - var files = Fs.readdirSync(dir).filter(function(file) { - return bakRE.test(file); - }).forEach(function(file) { - var from = Path.join(dir, file); - var to = Path.join(dir, file.replace(/\.bak$/, "")); - Fs.renameSync(from, to); - Util.log("Restored '" + file + "' (" + version + ")"); - }); - - versionDone(); - return; - } - - var routes = versions[version]; - var defines = routes.defines; - delete routes.defines; - var headers = defines["response-headers"]; - // cast header names to lowercase. - if (headers && headers.length) - headers = headers.map(function(header) { return header.toLowerCase(); }); - var sections = {}; - var testSections = {}; - - // First fetch and cache the documentation sections, but only if the site - // can be reached at the moment. - var addDocLink = false; - var docsUrl = defines.constants.documentation; - pingDocumentationUrl(docsUrl, function(success) { - if (success) { - Util.log("Using '" + docsUrl + "' to generate links to online documentation."); - addDocLink = true; - Async.each(Object.keys(routes), function(section, sectionDone) { - section = DocSectionsMap[section] || section; - getSectionDocument(docsUrl + "/" + section + "/", function(err) { - // Ignore errors here... - sectionDone(); - }); - }, generateFiles); - return; - } - - Util.log("Could not reach documentation site, continuing without " + - "adding links to online documentation."); - generateFiles(); - }); - - function generateFiles() { - function createComment(block, section, funcName, indent) { - var paramsStruct = block.params; - var params = Object.keys(paramsStruct); - var comment = [ - indent + "/** section: github", - indent + " * " + section + "#" + funcName + "(msg, callback) -> null", - indent + " * - msg (Object): Object that contains the parameters and their values to be sent to the server.", - indent + " * - callback (Function): function to call when the request is finished " + - "with an error as first argument and result data as second argument.", - indent + " *", - indent + " * ##### Params on the `msg` object:", - indent + " *" - ]; - comment.push(indent + " * - headers (Object): Optional. Key/ value pair " - + "of request headers to pass along with the HTTP request. Valid headers are: " - + "'" + defines["request-headers"].join("', '") + "'."); - if (!params.length) - comment.push(indent + " * No other params, simply pass an empty Object literal `{}`"); - var paramName, def, line; - for (var i = 0, l = params.length; i < l; ++i) { - paramName = params[i]; - if (paramName.charAt(0) == "$") { - paramName = paramName.substr(1); - if (!defines.params[paramName]) { - Util.log("Invalid variable parameter name substitution; param '" + - paramName + "' not found in defines block", "fatal"); - process.exit(1); - } - else - def = defines.params[paramName]; - } - else - def = paramsStruct[paramName]; - - line = indent + " * - " + paramName + " (" + (def.type || "mixed") + "): " + - (def.required ? "Required. " : "Optional. "); - if (def.description) - line += def.description; - if (def.validation) - line += " Validation rule: ` " + def.validation + " `."; - - comment.push(line); - } - - if (addDocLink) { - var docSection = DocSectionsMap[section] || section; - var url = searchSectionUrl(docsUrl + "/" + docSection + "/", - block.method + " " + block.url); - - if (url) { - comment.push( - indent + " *", - indent + " * " + url); - } - else { - Util.log("No documentation link found for '" + block.url + - "' on '" + docsUrl + "/" + docSection + "/'"); - } - } - - return comment.join("\n") + "\n" + indent + " **/"; - } - - function getParams(paramsStruct, indent) { - var params = Object.keys(paramsStruct); - if (!params.length) - return "{}"; - var values = []; - var paramName, def; - for (var i = 0, l = params.length; i < l; ++i) { - paramName = params[i]; - if (paramName.charAt(0) == "$") { - paramName = paramName.substr(1); - if (!defines.params[paramName]) { - Util.log("Invalid variable parameter name substitution; param '" + - paramName + "' not found in defines block", "fatal"); - process.exit(1); - } - else - def = defines.params[paramName]; - } - else - def = paramsStruct[paramName]; - - values.push(indent + " " + paramName + ": \"" + def.type + "\""); - } - return "{\n" + values.join(",\n") + "\n" + indent + "}"; - } - - function prepareApi(struct, baseType) { - if (!baseType) - baseType = ""; - - Object.keys(struct).forEach(function(routePart) { - var block = struct[routePart]; - if (!block) - return; - var messageType = baseType + "/" + routePart; - if (block.url && block.params) { - // we ended up at an API definition part! - var parts = messageType.split("/"); - var section = Util.toCamelCase(parts[1].toLowerCase()); - if (!block.method) { - throw new Error("No HTTP method specified for " + messageType + - "in section " + section); - } - - parts.splice(0, 2); - var funcName = Util.toCamelCase(parts.join("-")); - var comment = createComment(block, section, funcName, " "); - - // add the handler to the sections - if (!sections[section]) - sections[section] = []; - - var afterRequest = ""; - if (headers && headers.length) { - afterRequest = AfterRequestTpl.replace("<%headers%>", "\"" + - headers.join("\", \"") + "\""); - } - sections[section].push(HandlerTpl - .replace("<%funcName%>", funcName) - .replace("<%comment%>", comment) - .replace("<%afterRequest%>", afterRequest) - ); - - // add test to the testSections - if (!testSections[section]) - testSections[section] = []; - testSections[section].push(TestHandlerTpl - .replace("<%name%>", block.method + " " + block.url + " (" + funcName + ")") - .replace("<%funcName%>", section + "." + funcName) - .replace("<%params%>", getParams(block.params, " ")) - ); - } - else { - // recurse into this block next: - prepareApi(block, messageType); - } - }); - } - - Util.log("Converting routes to functions"); - prepareApi(routes); - - Util.log("Writing files to version dir"); - var sectionNames = Object.keys(sections); - - Util.log("Writing index.js file for version " + version); - Fs.writeFileSync(Path.join(dir, "index.js"), - IndexTpl - .replace("<%name%>", defines.constants.name) - .replace("<%description%>", defines.constants.description) - .replace("<%scripts%>", "\"" + sectionNames.join("\", \"") + "\""), - "utf8"); - - Object.keys(sections).forEach(function(section) { - var def = sections[section]; - Util.log("Writing '" + section + ".js' file for version " + version); - Fs.writeFileSync(Path.join(dir, section + ".js"), SectionTpl - .replace(/<%sectionName%>/g, section) - .replace("<%sectionBody%>", def.join("\n")), - "utf8" - ); - - // When we don't need to generate tests, bail out here. - if (!tests) - return; - - def = testSections[section]; - // test if previous tests already contained implementations by checking - // if the difference in character count between the current test file - // and the newly generated one is more than twenty characters. - var body = TestSectionTpl - .replace("<%version%>", version.replace("v", "")) - .replace(/<%sectionName%>/g, section) - .replace("<%testBody%>", def.join("\n\n")); - var path = Path.join(dir, section + "Test.js"); - if (Fs.existsSync(path) && Math.abs(Fs.readFileSync(path, "utf8").length - body.length) >= 20) { - Util.log("Moving old test file to '" + path + ".bak' to preserve tests " + - "that were already implemented. \nPlease be sure te check this file " + - "and move all implemented tests back into the newly generated test!", "error"); - Fs.renameSync(path, path + ".bak"); - } - - Util.log("Writing test file for " + section + ", version " + version); - Fs.writeFileSync(path, body, "utf8"); - }); - - versionDone(); - } - }, function() {}); -}; - -function getRequestOptions(url, method) { - var parsedUrl = Url.parse(url); - var protocol = parsedUrl.protocol.replace(/[:\/]+/, ""); - return { - options: { - hostname: parsedUrl.hostname, - method: method || "GET", - path: parsedUrl.pathname, - port: parsedUrl.port || protocol == "https" ? 443 : 80 - }, - protocol: protocol - }; -} - -function pingDocumentationUrl(url, callback) { - if (!url) { - callback(false); - return; - } - - var options = getRequestOptions(url, "HEAD"); - - function callCallback(result) { - if (!callback) - return; - var cb = callback; - callback = undefined; - cb(result); - } - - var req = require(options.protocol).request(options.options, function(res) { - if (res.statusCode >= 400 && res.statusCode < 600 || res.statusCode < 10) { - callCallback(false); - } else { - callCallback(true); - } - }); - req.on("error", function(err) { - callCallback(false); - }); - req.end(); -} - -function searchSectionUrl(url, needle) { - var doc = sectionDocCache[url]; - if (!doc) - return null; - - var idx = doc.indexOf(needle); - var userIdx = needle.indexOf(":user"); - // GH uses ':owner' to identify the :user param for clearer documentation, - // so we attempt to substitute that here to search for instead. - if (idx == -1 && userIdx != -1) { - needle = needle.substr(0, userIdx) + ":owner" + needle.substr(userIdx + 5); - idx = doc.indexOf(needle); - } - - // We tried. - if (idx == -1) - return null; - - var subDoc = doc.substr(0, idx); - // Search for the first header with an ID attribute. - var headerIdx = -1; - for (var i = 2; i >= 1 && headerIdx == -1; --i) { - headerIdx = subDoc.lastIndexOf("]*)/); - if (!id || !id.length) - return null; - - return url + "#" + id[1]; -} - -var sectionDocCache = {}; - -function getSectionDocument(url, callback) { - // First try to fetch the section document from cache. - if (sectionDocCache[url]) { - callCallback(null, sectionDocCache[url]); - return; - } - - var options = getRequestOptions(url); - - function callCallback(err, result) { - if (callback) { - var cb = callback; - callback = undefined; - cb(err, result); - } - } - - Util.log("Fetching documentation section '" + url + "'"); - var req = require(options.protocol).request(options.options, function(res) { - res.setEncoding("utf8"); - var data = ""; - res.on("data", function(chunk) { - data += chunk; - }); - res.on("error", function(err) { - callCallback(err); - }); - res.on("end", function() { - if (res.statusCode >= 400 && res.statusCode < 600 || res.statusCode < 10) { - callCallback(data, res.statusCode); - } else { - sectionDocCache[url] = data; - callCallback(null, data); - } - }); - }); - req.on("error", function(e) { - callCallback(e.message); - }); - req.on("timeout", function() { - callCallback("Gateway timed out for '" + url + "'"); - }); - req.end(); -} - -if (!module.parent) { - var argv = Optimist - .wrap(80) - .usage("Generate the implementation of the node-github module, including " - + "unit-test scaffolds.\nUsage: $0 [-r] [-v VERSION]") - .alias("r", "restore") - .describe("r", "Restore .bak files, generated by a previous run, to the original") - .alias("v", "version") - .describe("v", "Semantic version number of the API to generate. Example: '3.0.0'") - .alias("t", "tests") - .describe("t", "Also generate unit test scaffolds") - .alias("h", "help") - .describe("h", "Display this usage information") - .boolean(["r", "t", "h"]) - .argv; - - if (argv.help) { - Util.log(Optimist.help()); - process.exit(); - } - - var baseDir = Path.join(__dirname, "api"); - var availVersions = {}; - Fs.readdirSync(baseDir).forEach(function(version) { - var path = Path.join(baseDir, version, "routes.json"); - if (!Fs.existsSync(path)) - return; - var routes = JSON.parse(Fs.readFileSync(path, "utf8")); - if (!routes.defines) - return; - availVersions[version] = routes; - }); - - if (!Object.keys(availVersions).length) { - Util.log("No versions available to generate.", "fatal"); - process.exit(1); - } - var versions = {}; - if (argv.version) { - if (argv.version.charAt(0) != "v") - argv.version = argv.v = "v" + argv.version; - if (!availVersions[argv.version]) { - Util.log("Version '" + argv.version + "' is not available", "fatal"); - process.exit(1); - } - versions[argv.version] = availVersions[argv.version]; - } - if (!Object.keys(versions).length) { - Util.log("No versions specified via the command line, generating for all available versions."); - versions = availVersions; - } - - Util.log("Starting up..."); - main(versions, argv.tests, argv.restore); -} diff --git a/index.js b/index.js deleted file mode 100644 index 0c062efcf8..0000000000 --- a/index.js +++ /dev/null @@ -1,847 +0,0 @@ -"use strict"; - -var error = require("./error"); -var fs = require("fs"); -var mime = require("mime"); -var Util = require("./util"); -var Url = require("url"); - -/** section: github - * class Client - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - * - * [[Client]] can load any version of the [[github]] client API, with the - * requirement that a valid routes.json definition file is present in the - * `api/[VERSION]` directory and that the routes found in this file are - * implemented as well. - * - * Upon instantiation of the [[Client]] class, the routes.json file is loaded - * from the API version specified in the configuration and, parsed and from it - * the routes for HTTP requests are extracted. For each HTTP endpoint to the - * HTTP server, a method is generated which accepts a Javascript Object - * with parameters and an optional callback to be invoked when the API request - * returns from the server or when the parameters could not be validated. - * - * When an HTTP endpoint is processed and a method is generated as described - * above, [[Client]] also sets up parameter validation with the rules as - * defined in the routes.json. A full example that illustrates how this works - * is shown below: - * - * ##### Example - * - * First, we look at a listing of a sample routes.json routes definition file: - * - * { - * "defines": { - * "constants": { - * "name": "Github", - * "description": "A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API.", - * "protocol": "https", - * "host": "api.github.com", - * "port": 443, - * "dateFormat": "YYYY-MM-DDTHH:MM:SSZ", - * "requestFormat": "json" - * }, - * "response-headers": [ - * "X-RateLimit-Limit", - * "X-RateLimit-Remaining", - * "Link" - * ], - * "params": { - * "files": { - * "type": "Json", - * "required": true, - * "validation": "", - * "invalidmsg": "", - * "description": "Files that make up this gist. The key of which should be a required string filename and the value another required hash with parameters: 'content'" - * }, - * "user": { - * "type": "String", - * "required": true, - * "validation": "", - * "invalidmsg": "", - * "description": "" - * }, - * "description": { - * "type": "String", - * "required": false, - * "validation": "", - * "invalidmsg": "", - * "description": "" - * }, - * "page": { - * "type": "Number", - * "required": false, - * "validation": "^[0-9]+$", - * "invalidmsg": "", - * "description": "Page number of the results to fetch." - * }, - * "per_page": { - * "type": "Number", - * "required": false, - * "validation": "^[0-9]+$", - * "invalidmsg": "", - * "description": "A custom page size up to 100. Default is 30." - * } - * } - * }, - * - * "gists": { - * "get-from-user": { - * "url": ":user/gists", - * "method": "GET", - * "params": { - * "$user": null, - * "$page": null, - * "$per_page": null - * } - * }, - * - * "create": { - * "url": "/gists", - * "method": "POST", - * "params": { - * "$description": null, - * "public": { - * "type": "Boolean", - * "required": true, - * "validation": "", - * "invalidmsg": "", - * "description": "" - * }, - * "$files": null - * } - * } - * } - * } - * - * You probably noticed that the definition is quite verbose and the decision - * for its design was made to be verbose whilst still allowing for basic variable - * definitions and substitions for request parameters. - * - * There are two sections; 'defines' and 'gists' in this example. - * - * The `defines` section contains a list of `constants` that will be used by the - * [[Client]] to make requests to the right URL that hosts the API. - * The `gists` section defines the endpoints for calls to the API server, for - * gists specifically in this example, but the other API sections are defined in - * the exact same way. - * These definitions are parsed and methods are created that the client can call - * to make an HTTP request to the server. - * there is one endpoint defined: . - * In this example, the endpoint `gists/get-from-user` will be exposed as a member - * on the [[Client]] object and may be invoked with - * - * client.getFromUser({ - * "user": "bob" - * }, function(err, ret) { - * // do something with the result here. - * }); - * - * // or to fetch a specfic page: - * client.getFromUser({ - * "user": "bob", - * "page": 2, - * "per_page": 100 - * }, function(err, ret) { - * // do something with the result here. - * }); - * - * All the parameters as specified in the Object that is passed to the function - * as first argument, will be validated according to the rules in the `params` - * block of the route definition. - * Thus, in the case of the `user` parameter, according to the definition in - * the `params` block, it's a variable that first needs to be looked up in the - * `params` block of the `defines` section (at the top of the JSON file). Params - * that start with a `$` sign will be substituted with the param with the same - * name from the `defines/params` section. - * There we see that it is a required parameter (needs to hold a value). In other - * words, if the validation requirements are not met, an HTTP error is passed as - * first argument of the callback. - * - * Implementation Notes: the `method` is NOT case sensitive, whereas `url` is. - * The `url` parameter also supports denoting parameters inside it as follows: - * - * "get-from-user": { - * "url": ":user/gists", - * "method": "GET" - * ... - * } - **/ -var Client = module.exports = function(config) { - config.headers = config.headers || {}; - this.config = config; - this.debug = Util.isTrue(config.debug); - - this.version = config.version; - var cls = require("./api/v" + this.version); - this[this.version] = new cls(this); - - var pathPrefix = ""; - // Check if a prefix is passed in the config and strip any leading or trailing slashes from it. - if (typeof config.pathPrefix == "string") { - pathPrefix = "/" + config.pathPrefix.replace(/(^[\/]+|[\/]+$)/g, ""); - this.config.pathPrefix = pathPrefix; - } - - this.setupRoutes(); -}; - -(function() { - /** - * Client#setupRoutes() -> null - * - * Configures the routes as defined in a routes.json file of an API version - * - * [[Client#setupRoutes]] is invoked by the constructor, takes the - * contents of the JSON document that contains the definitions of all the - * available API routes and iterates over them. - * - * It first recurses through each definition block until it reaches an API - * endpoint. It knows that an endpoint is found when the `url` and `param` - * definitions are found as a direct member of a definition block. - * Then the availability of an implementation by the API is checked; if it's - * not present, this means that a portion of the API as defined in the routes.json - * file is not implemented properly, thus an exception is thrown. - * After this check, a method is attached to the [[Client]] instance - * and becomes available for use. Inside this method, the parameter validation - * and typecasting is done, according to the definition of the parameters in - * the `params` block, upon invocation. - * - * This mechanism ensures that the handlers ALWAYS receive normalized data - * that is of the correct format and type. JSON parameters are parsed, Strings - * are trimmed, Numbers and Floats are casted and checked for NaN after that. - * - * Note: Query escaping for usage with SQL products is something that can be - * implemented additionally by adding an additional parameter type. - **/ - this.setupRoutes = function() { - var self = this; - var api = this[this.version]; - var routes = api.routes; - var defines = routes.defines; - this.constants = defines.constants; - this.requestHeaders = defines["request-headers"].map(function(header) { - return header.toLowerCase(); - }); - delete routes.defines; - - function trim(s) { - if (typeof s != "string") - return s; - return s.replace(/^[\s\t\r\n]+/, "").replace(/[\s\t\r\n]+$/, ""); - } - - function parseParams(msg, paramsStruct) { - var params = Object.keys(paramsStruct); - var paramName, def, value, type; - for (var i = 0, l = params.length; i < l; ++i) { - paramName = params[i]; - if (paramName.charAt(0) == "$") { - paramName = paramName.substr(1); - if (!defines.params[paramName]) { - throw new error.BadRequest("Invalid variable parameter name substitution; param '" + - paramName + "' not found in defines block", "fatal"); - } - else { - def = paramsStruct[paramName] = defines.params[paramName]; - delete paramsStruct["$" + paramName]; - } - } - else - def = paramsStruct[paramName]; - - value = trim(msg[paramName]); - if (typeof value != "boolean" && !value) { - // we don't need to validation for undefined parameter values - // that are not required. - if (!def.required || (def["allow-empty"] && value === "")) - continue; - throw new error.BadRequest("Empty value for parameter '" + - paramName + "': " + value); - } - - // validate the value and type of parameter: - if (def.validation) { - if (!new RegExp(def.validation).test(value)) { - throw new error.BadRequest("Invalid value for parameter '" + - paramName + "': " + value); - } - } - - if (def.type) { - type = def.type.toLowerCase(); - if (type == "number") { - value = parseInt(value, 10); - if (isNaN(value)) { - throw new error.BadRequest("Invalid value for parameter '" + - paramName + "': " + msg[paramName] + " is NaN"); - } - } - else if (type == "float") { - value = parseFloat(value); - if (isNaN(value)) { - throw new error.BadRequest("Invalid value for parameter '" + - paramName + "': " + msg[paramName] + " is NaN"); - } - } - else if (type == "json") { - if (typeof value == "string") { - try { - value = JSON.parse(value); - } - catch(ex) { - throw new error.BadRequest("JSON parse error of value for parameter '" + - paramName + "': " + value); - } - } - } - else if (type == "date") { - value = new Date(value); - } - } - msg[paramName] = value; - } - } - - function prepareApi(struct, baseType) { - if (!baseType) - baseType = ""; - Object.keys(struct).forEach(function(routePart) { - var block = struct[routePart]; - if (!block) - return; - var messageType = baseType + "/" + routePart; - if (block.url && block.params) { - // we ended up at an API definition part! - var endPoint = messageType.replace(/^[\/]+/g, ""); - var parts = messageType.split("/"); - var section = Util.toCamelCase(parts[1].toLowerCase()); - parts.splice(0, 2); - var funcName = Util.toCamelCase(parts.join("-")); - - if (!api[section]) { - throw new Error("Unsupported route section, not implemented in version " + - self.version + " for route '" + endPoint + "' and block: " + - JSON.stringify(block)); - } - - if (!api[section][funcName]) { - if (self.debug) - Util.log("Tried to call " + funcName); - throw new Error("Unsupported route, not implemented in version " + - self.version + " for route '" + endPoint + "' and block: " + - JSON.stringify(block)); - } - - if (!self[section]) { - self[section] = {}; - // add a utility function 'getFooApi()', which returns the - // section to which functions are attached. - self[Util.toCamelCase("get-" + section + "-api")] = function() { - return self[section]; - }; - } - - self[section][funcName] = function(msg, callback) { - try { - parseParams(msg, block.params); - } - catch (ex) { - // when the message was sent to the client, we can - // reply with the error directly. - api.sendError(ex, block, msg, callback); - if (self.debug) - Util.log(ex.message, "fatal"); - // on error, there's no need to continue. - return; - } - - api[section][funcName].call(api, msg, block, callback); - }; - } - else { - // recurse into this block next: - prepareApi(block, messageType); - } - }); - } - - prepareApi(routes); - }; - - /** - * Client#authenticate(options) -> null - * - options (Object): Object containing the authentication type and credentials - * - type (String): One of the following: `basic` or `oauth` - * - username (String): Github username - * - password (String): Password to your account - * - token (String): OAuth2 token - * - * Set an authentication method to have access to protected resources. - * - * ##### Example - * - * // basic - * github.authenticate({ - * type: "basic", - * username: "mikedeboertest", - * password: "test1324" - * }); - * - * // or oauth - * github.authenticate({ - * type: "oauth", - * token: "e5a4a27487c26e571892846366de023349321a73" - * }); - * - * // or oauth key/ secret - * github.authenticate({ - * type: "oauth", - * key: "clientID", - * secret: "clientSecret" - * }); - * - * // or token - * github.authenticate({ - * type: "token", - * token: "userToken", - * }); - **/ - this.authenticate = function(options) { - if (!options) { - this.auth = false; - return; - } - if (!options.type || "basic|oauth|client|token".indexOf(options.type) === -1) - throw new Error("Invalid authentication type, must be 'basic', 'oauth' or 'client'"); - if (options.type == "basic" && (!options.username || !options.password)) - throw new Error("Basic authentication requires both a username and password to be set"); - if (options.type == "oauth") { - if (!options.token && !(options.key && options.secret)) - throw new Error("OAuth2 authentication requires a token or key & secret to be set"); - } - if (options.type == "token" && !options.token) - throw new Error("Token authentication requires a token to be set"); - - this.auth = options; - }; - - function getPageLinks(link) { - if (typeof link == "object" && (link.link || link.meta.link)) - link = link.link || link.meta.link; - - var links = {}; - if (typeof link != "string") - return links; - - // link format: - // '; rel="next", ; rel="last"' - link.replace(/<([^>]*)>;\s*rel="([\w]*)\"/g, function(m, uri, type) { - links[type] = uri; - }); - return links; - } - - /** - * Client#hasNextPage(link) -> null - * - link (mixed): response of a request or the contents of the Link header - * - * Check if a request result contains a link to the next page - **/ - this.hasNextPage = function(link) { - return getPageLinks(link).next; - }; - - /** - * Client#hasPreviousPage(link) -> null - * - link (mixed): response of a request or the contents of the Link header - * - * Check if a request result contains a link to the previous page - **/ - this.hasPreviousPage = function(link) { - return getPageLinks(link).prev; - }; - - /** - * Client#hasLastPage(link) -> null - * - link (mixed): response of a request or the contents of the Link header - * - * Check if a request result contains a link to the last page - **/ - this.hasLastPage = function(link) { - return getPageLinks(link).last; - }; - - /** - * Client#hasFirstPage(link) -> null - * - link (mixed): response of a request or the contents of the Link header - * - * Check if a request result contains a link to the first page - **/ - this.hasFirstPage = function(link) { - return getPageLinks(link).first; - }; - - function getPage(link, which, callback) { - var url = getPageLinks(link)[which]; - if (!url) - return callback(new error.NotFound("No " + which + " page found")); - - var api = this[this.version]; - var parsedUrl = Url.parse(url, true); - var block = { - url: parsedUrl.pathname, - method: "GET", - params: parsedUrl.query - }; - this.httpSend(parsedUrl.query, block, function(err, res) { - if (err) - return api.sendError(err, null, parsedUrl.query, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - ["x-ratelimit-limit", "x-ratelimit-remaining", "link"].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } - - if (callback) - callback(null, ret); - }); - } - - /** - * Client#getNextPage(link, callback) -> null - * - link (mixed): response of a request or the contents of the Link header - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * Get the next page, based on the contents of the `Link` header - **/ - this.getNextPage = function(link, callback) { - getPage.call(this, link, "next", callback); - }; - - /** - * Client#getPreviousPage(link, callback) -> null - * - link (mixed): response of a request or the contents of the Link header - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * Get the previous page, based on the contents of the `Link` header - **/ - this.getPreviousPage = function(link, callback) { - getPage.call(this, link, "prev", callback); - }; - - /** - * Client#getLastPage(link, callback) -> null - * - link (mixed): response of a request or the contents of the Link header - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * Get the last page, based on the contents of the `Link` header - **/ - this.getLastPage = function(link, callback) { - getPage.call(this, link, "last", callback); - }; - - /** - * Client#getFirstPage(link, callback) -> null - * - link (mixed): response of a request or the contents of the Link header - * - callback (Function): function to call when the request is finished with an error as first argument and result data as second argument. - * - * Get the first page, based on the contents of the `Link` header - **/ - this.getFirstPage = function(link, callback) { - getPage.call(this, link, "first", callback); - }; - - function getRequestFormat(hasBody, block) { - if (hasBody) - return block.requestFormat || this.constants.requestFormat; - - return "query"; - } - - function getQueryAndUrl(msg, def, format, config) { - var url = def.url; - if (config.pathPrefix && url.indexOf(config.pathPrefix) !== 0) { - url = config.pathPrefix + def.url; - } - var ret = { - query: format == "json" ? {} : format == "raw" ? msg.data : [] - }; - if (!def || !def.params) { - ret.url = url; - return ret; - } - - Object.keys(def.params).forEach(function(paramName) { - paramName = paramName.replace(/^[$]+/, ""); - if (!(paramName in msg)) - return; - - var isUrlParam = url.indexOf(":" + paramName) !== -1; - var valFormat = isUrlParam || format != "json" ? "query" : format; - var val; - if (valFormat != "json") { - if (typeof msg[paramName] == "object") { - try { - msg[paramName] = JSON.stringify(msg[paramName]); - val = encodeURIComponent(msg[paramName]); - } - catch (ex) { - return Util.log("httpSend: Error while converting object to JSON: " - + (ex.message || ex), "error"); - } - } - else if (def.params[paramName] && def.params[paramName].combined) { - // Check if this is a combined (search) string. - val = msg[paramName].split(/[\s\t\r\n]*\+[\s\t\r\n]*/) - .map(function(part) { - return encodeURIComponent(part); - }) - .join("+"); - } - else - val = encodeURIComponent(msg[paramName]); - } - else - val = msg[paramName]; - - if (isUrlParam) { - url = url.replace(":" + paramName, val); - } - else { - if (format == "json") - ret.query[paramName] = val; - else if (format != "raw") - ret.query.push(paramName + "=" + val); - } - }); - ret.url = url; - return ret; - } - - /** - * Client#httpSend(msg, block, callback) -> null - * - msg (Object): parameters to send as the request body - * - block (Object): parameter definition from the `routes.json` file that - * contains validation rules - * - callback (Function): function to be called when the request returns. - * If the the request returns with an error, the error is passed to - * the callback as its first argument (NodeJS-style). - * - * Send an HTTP request to the server and pass the result to a callback. - **/ - this.httpSend = function(msg, block, callback) { - var self = this; - var method = block.method.toLowerCase(); - var hasFileBody = block.hasFileBody; - var hasBody = !hasFileBody && ("head|get|delete".indexOf(method) === -1); - var format = getRequestFormat.call(this, hasBody, block); - var obj = getQueryAndUrl(msg, block, format, self.config); - var query = obj.query; - var url = this.config.url ? this.config.url + obj.url : obj.url; - - var path = url; - var protocol = this.config.protocol || this.constants.protocol || "http"; - var host = block.host || this.config.host || this.constants.host; - var port = this.config.port || this.constants.port || (protocol == "https" ? 443 : 80); - var proxyUrl; - if (this.config.proxy !== undefined) { - proxyUrl = this.config.proxy; - } else { - proxyUrl = process.env.HTTPS_PROXY || process.env.HTTP_PROXY; - } - if (proxyUrl) { - path = Url.format({ - protocol: protocol, - hostname: host, - port: port, - pathname: path - }); - - if (!/^(http|https):\/\//.test(proxyUrl)) - proxyUrl = "https://" + proxyUrl; - - var parsedUrl = Url.parse(proxyUrl); - protocol = parsedUrl.protocol.replace(":", ""); - host = parsedUrl.hostname; - port = parsedUrl.port || (protocol == "https" ? 443 : 80); - } - if (!hasBody && query.length) - path += "?" + query.join("&"); - - var headers = { - "host": host, - "content-length": "0" - }; - if (hasBody) { - if (format == "json") - query = JSON.stringify(query); - else if (format != "raw") - query = query.join("&"); - headers["content-length"] = Buffer.byteLength(query, "utf8"); - headers["content-type"] = format == "json" - ? "application/json; charset=utf-8" - : format == "raw" - ? "text/plain; charset=utf-8" - : "application/x-www-form-urlencoded; charset=utf-8"; - } - if (this.auth) { - var basic; - switch (this.auth.type) { - case "oauth": - if (this.auth.token) { - path += (path.indexOf("?") === -1 ? "?" : "&") + - "access_token=" + encodeURIComponent(this.auth.token); - } else { - path += (path.indexOf("?") === -1 ? "?" : "&") + - "client_id=" + encodeURIComponent(this.auth.key) + - "&client_secret=" + encodeURIComponent(this.auth.secret); - } - break; - case "token": - headers.authorization = "token " + this.auth.token; - break; - case "basic": - basic = new Buffer(this.auth.username + ":" + this.auth.password, "ascii").toString("base64"); - headers.authorization = "Basic " + basic; - break; - default: - break; - } - } - - function callCallback(err, result) { - if (callback) { - var cb = callback; - callback = undefined; - cb(err, result); - } - } - - function addCustomHeaders(customHeaders) { - Object.keys(customHeaders).forEach(function(header) { - var headerLC = header.toLowerCase(); - if (self.requestHeaders.indexOf(headerLC) == -1) - return; - headers[headerLC] = customHeaders[header]; - }); - } - addCustomHeaders(Util.extend(msg.headers || {}, this.config.headers)); - - if (!headers["user-agent"]) - headers["user-agent"] = "NodeJS HTTP Client"; - - if (!("accept" in headers)) - headers.accept = this.config.requestMedia || this.constants.requestMedia; - - var options = { - host: host, - port: port, - path: path, - method: method, - headers: headers - }; - - if (this.config.rejectUnauthorized !== undefined) - options.rejectUnauthorized = this.config.rejectUnauthorized; - - if (this.debug) - console.log("REQUEST: ", options); - - function httpSendRequest() { - var req = require(protocol).request(options, function(res) { - if (self.debug) { - console.log("STATUS: " + res.statusCode); - console.log("HEADERS: " + JSON.stringify(res.headers)); - } - res.setEncoding("utf8"); - var data = ""; - res.on("data", function(chunk) { - data += chunk; - }); - res.on("error", function(err) { - callCallback(err); - }); - res.on("end", function() { - if (res.statusCode >= 400 && res.statusCode < 600 || res.statusCode < 10) { - callCallback(new error.HttpError(data, res.statusCode)); - } else { - res.data = data; - callCallback(null, res); - } - }); - }); - - var timeout = (block.timeout !== undefined) ? block.timeout : self.config.timeout; - if (timeout) { - req.setTimeout(timeout); - } - - req.on("error", function(e) { - if (self.debug) - console.log("problem with request: " + e.message); - callCallback(e.message); - }); - - req.on("timeout", function() { - if (self.debug) - console.log("problem with request: timed out"); - callCallback(new error.GatewayTimeout()); - }); - - // write data to request body - if (hasBody && query.length) { - if (self.debug) - console.log("REQUEST BODY: " + query + "\n"); - req.write(query + "\n"); - } - - if (block.hasFileBody) { - var stream = fs.createReadStream(msg.filePath); - stream.pipe(req); - } else { - req.end(); - } - }; - - if (hasFileBody) { - fs.stat(msg.filePath, function(err, stat) { - if (err) { - callCallback(err); - } else { - headers["content-length"] = stat.size; - headers["content-type"] = mime.lookup(msg.name); - httpSendRequest(); - } - }); - } else { - httpSendRequest(); - } - }; -}).call(Client.prototype); diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000000..5133edbb79 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,2919 @@ +{ + "name": "octokit", + "version": "0.0.0-development", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "octokit", + "version": "0.0.0-development", + "license": "MIT", + "dependencies": { + "@octokit/app": "^15.1.4", + "@octokit/core": "^6.1.4", + "@octokit/oauth-app": "^7.1.6", + "@octokit/plugin-paginate-graphql": "^5.2.4", + "@octokit/plugin-paginate-rest": "^11.4.2", + "@octokit/plugin-rest-endpoint-methods": "^13.3.1", + "@octokit/plugin-retry": "^7.1.4", + "@octokit/plugin-throttling": "^9.4.0", + "@octokit/request-error": "^6.1.7", + "@octokit/types": "^13.7.0" + }, + "devDependencies": { + "@octokit/tsconfig": "^4.0.0", + "@types/node": "^22.0.0", + "@vitest/coverage-v8": "^3.0.0", + "esbuild": "^0.25.0", + "fetch-mock": "^11.0.0", + "glob": "^11.0.0", + "mockdate": "^3.0.5", + "prettier": "3.5.3", + "semantic-release-plugin-update-version-in-files": "^2.0.0", + "typescript": "^5.0.0", + "vitest": "^3.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@ampproject/remapping": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", + "integrity": "sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "@jridgewell/gen-mapping": "^0.3.5", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/helper-string-parser": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.25.9.tgz", + "integrity": "sha512-4A/SCr/2KLd5jrtOMFzaKjVtAei3+2r/NChoBNoZ3EyP/+GlhoaEGoWOZUmFmoITP7zOJyHIMm+DYRd8o3PvHA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/helper-validator-identifier": { + "version": "7.25.9", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.25.9.tgz", + "integrity": "sha512-Ed61U6XJc3CVRfkERJWDz4dJwKe7iLmmJsbOGu9wSloNSFttHV0I8g6UAgb7qnK5ly5bGLPd4oXZlxCdANBOWQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@babel/parser": { + "version": "7.26.9", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.26.9.tgz", + "integrity": "sha512-81NWa1njQblgZbQHxWHpxxCzNsa3ZwvFqpUg7P+NNUU6f3UU2jBEg4OlF/J6rl8+PQGh1q6/zWScd001YwcA5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/types": "^7.26.9" + }, + "bin": { + "parser": "bin/babel-parser.js" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@babel/types": { + "version": "7.26.9", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.26.9.tgz", + "integrity": "sha512-Y3IR1cRnOxOCDvMmNiym7XpXQ93iGDDPHx+Zj+NM+rg0fBaShfQLkg+hKPaZCEvg5N/LeCo4+Rj/i3FuJsIQaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/helper-string-parser": "^7.25.9", + "@babel/helper-validator-identifier": "^7.25.9" + }, + "engines": { + "node": ">=6.9.0" + } + }, + "node_modules/@bcoe/v8-coverage": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/@bcoe/v8-coverage/-/v8-coverage-1.0.2.tgz", + "integrity": "sha512-6zABk/ECA/QYSCQ1NGiVwwbQerUCZ+TQbp64Q3AgmfNvurHH0j8TtXa1qbShXA6qqkpAj4V5W8pP6mLe1mcMqA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/aix-ppc64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.25.0.tgz", + "integrity": "sha512-O7vun9Sf8DFjH2UtqK8Ku3LkquL9SZL8OLY1T5NZkA34+wG3OQF7cl4Ql8vdNzM6fzBbYfLaiRLIOZ+2FOCgBQ==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "aix" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.25.0.tgz", + "integrity": "sha512-PTyWCYYiU0+1eJKmw21lWtC+d08JDZPQ5g+kFyxP0V+es6VPPSUhM6zk8iImp2jbV6GwjX4pap0JFbUQN65X1g==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-arm64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.25.0.tgz", + "integrity": "sha512-grvv8WncGjDSyUBjN9yHXNt+cq0snxXbDxy5pJtzMKGmmpPxeAmAhWxXI+01lU5rwZomDgD3kJwulEnhTRUd6g==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/android-x64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.25.0.tgz", + "integrity": "sha512-m/ix7SfKG5buCnxasr52+LI78SQ+wgdENi9CqyCXwjVR2X4Jkz+BpC3le3AoBPYTC9NHklwngVXvbJ9/Akhrfg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-arm64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.25.0.tgz", + "integrity": "sha512-mVwdUb5SRkPayVadIOI78K7aAnPamoeFR2bT5nszFUZ9P8UpK4ratOdYbZZXYSqPKMHfS1wdHCJk1P1EZpRdvw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/darwin-x64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.25.0.tgz", + "integrity": "sha512-DgDaYsPWFTS4S3nWpFcMn/33ZZwAAeAFKNHNa1QN0rI4pUjgqf0f7ONmXf6d22tqTY+H9FNdgeaAa+YIFUn2Rg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-arm64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.25.0.tgz", + "integrity": "sha512-VN4ocxy6dxefN1MepBx/iD1dH5K8qNtNe227I0mnTRjry8tj5MRk4zprLEdG8WPyAPb93/e4pSgi1SoHdgOa4w==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/freebsd-x64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.25.0.tgz", + "integrity": "sha512-mrSgt7lCh07FY+hDD1TxiTyIHyttn6vnjesnPoVDNmDfOmggTLXRv8Id5fNZey1gl/V2dyVK1VXXqVsQIiAk+A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.25.0.tgz", + "integrity": "sha512-vkB3IYj2IDo3g9xX7HqhPYxVkNQe8qTK55fraQyTzTX/fxaDtXiEnavv9geOsonh2Fd2RMB+i5cbhu2zMNWJwg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-arm64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.25.0.tgz", + "integrity": "sha512-9QAQjTWNDM/Vk2bgBl17yWuZxZNQIF0OUUuPZRKoDtqF2k4EtYbpyiG5/Dk7nqeK6kIJWPYldkOcBqjXjrUlmg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ia32": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.25.0.tgz", + "integrity": "sha512-43ET5bHbphBegyeqLb7I1eYn2P/JYGNmzzdidq/w0T8E2SsYL1U6un2NFROFRg1JZLTzdCoRomg8Rvf9M6W6Gg==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-loong64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.25.0.tgz", + "integrity": "sha512-fC95c/xyNFueMhClxJmeRIj2yrSMdDfmqJnyOY4ZqsALkDrrKJfIg5NTMSzVBr5YW1jf+l7/cndBfP3MSDpoHw==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-mips64el": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.25.0.tgz", + "integrity": "sha512-nkAMFju7KDW73T1DdH7glcyIptm95a7Le8irTQNO/qtkoyypZAnjchQgooFUDQhNAy4iu08N79W4T4pMBwhPwQ==", + "cpu": [ + "mips64el" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-ppc64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.25.0.tgz", + "integrity": "sha512-NhyOejdhRGS8Iwv+KKR2zTq2PpysF9XqY+Zk77vQHqNbo/PwZCzB5/h7VGuREZm1fixhs4Q/qWRSi5zmAiO4Fw==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-riscv64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.25.0.tgz", + "integrity": "sha512-5S/rbP5OY+GHLC5qXp1y/Mx//e92L1YDqkiBbO9TQOvuFXM+iDqUNG5XopAnXoRH3FjIUDkeGcY1cgNvnXp/kA==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-s390x": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.25.0.tgz", + "integrity": "sha512-XM2BFsEBz0Fw37V0zU4CXfcfuACMrppsMFKdYY2WuTS3yi8O1nFOhil/xhKTmE1nPmVyvQJjJivgDT+xh8pXJA==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/linux-x64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.25.0.tgz", + "integrity": "sha512-9yl91rHw/cpwMCNytUDxwj2XjFpxML0y9HAOH9pNVQDpQrBxHy01Dx+vaMu0N1CKa/RzBD2hB4u//nfc+Sd3Cw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-arm64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.25.0.tgz", + "integrity": "sha512-RuG4PSMPFfrkH6UwCAqBzauBWTygTvb1nxWasEJooGSJ/NwRw7b2HOwyRTQIU97Hq37l3npXoZGYMy3b3xYvPw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/netbsd-x64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.25.0.tgz", + "integrity": "sha512-jl+qisSB5jk01N5f7sPCsBENCOlPiS/xptD5yxOx2oqQfyourJwIKLRA2yqWdifj3owQZCL2sn6o08dBzZGQzA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "netbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-arm64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.25.0.tgz", + "integrity": "sha512-21sUNbq2r84YE+SJDfaQRvdgznTD8Xc0oc3p3iW/a1EVWeNj/SdUCbm5U0itZPQYRuRTW20fPMWMpcrciH2EJw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/openbsd-x64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.25.0.tgz", + "integrity": "sha512-2gwwriSMPcCFRlPlKx3zLQhfN/2WjJ2NSlg5TKLQOJdV0mSxIcYNTMhk3H3ulL/cak+Xj0lY1Ym9ysDV1igceg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "openbsd" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/sunos-x64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.25.0.tgz", + "integrity": "sha512-bxI7ThgLzPrPz484/S9jLlvUAHYMzy6I0XiU1ZMeAEOBcS0VePBFxh1JjTQt3Xiat5b6Oh4x7UC7IwKQKIJRIg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "sunos" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-arm64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.25.0.tgz", + "integrity": "sha512-ZUAc2YK6JW89xTbXvftxdnYy3m4iHIkDtK3CLce8wg8M2L+YZhIvO1DKpxrd0Yr59AeNNkTiic9YLf6FTtXWMw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-ia32": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.25.0.tgz", + "integrity": "sha512-eSNxISBu8XweVEWG31/JzjkIGbGIJN/TrRoiSVZwZ6pkC6VX4Im/WV2cz559/TXLcYbcrDN8JtKgd9DJVIo8GA==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@esbuild/win32-x64": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.25.0.tgz", + "integrity": "sha512-ZENoHJBxA20C2zFzh6AI4fT6RraMzjYw4xKWemRTRmRVtN9c5DcH9r/f2ihEkMjOW5eGgrwCslG/+Y/3bL+DHQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=18" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "license": "ISC", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@istanbuljs/schema": { + "version": "0.1.3", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.3.tgz", + "integrity": "sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/@jridgewell/gen-mapping": { + "version": "0.3.8", + "resolved": "https://registry.npmjs.org/@jridgewell/gen-mapping/-/gen-mapping-0.3.8.tgz", + "integrity": "sha512-imAbBGkb+ebQyxKgzv5Hu2nmROxoDOXHh80evxdoXNOrvAnVx7zimzc1Oo5h9RlfV4vPXaE2iM5pOFbvOCClWA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/set-array": "^1.2.1", + "@jridgewell/sourcemap-codec": "^1.4.10", + "@jridgewell/trace-mapping": "^0.3.24" + }, + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/resolve-uri": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/@jridgewell/resolve-uri/-/resolve-uri-3.1.2.tgz", + "integrity": "sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/set-array": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/@jridgewell/set-array/-/set-array-1.2.1.tgz", + "integrity": "sha512-R8gLRTZeyp03ymzP/6Lil/28tGeGEzhx1q2k703KGWRAI1VdvPIXdG70VJc2pAMw3NA6JKL5hhFu1sJX0Mnn/A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6.0.0" + } + }, + "node_modules/@jridgewell/sourcemap-codec": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", + "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/@jridgewell/trace-mapping": { + "version": "0.3.25", + "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.25.tgz", + "integrity": "sha512-vNk6aEwybGtawWmy/PzwnGDOjCkLWSD2wqvjGGAgOAwCGWySYXfYoxt00IJkTF+8Lb57DwOb3Aa0o9CApepiYQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/resolve-uri": "^3.1.0", + "@jridgewell/sourcemap-codec": "^1.4.14" + } + }, + "node_modules/@octokit/app": { + "version": "15.1.5", + "resolved": "https://registry.npmjs.org/@octokit/app/-/app-15.1.5.tgz", + "integrity": "sha512-6cxLT9U8x7GGQ7lNWsKtFr4ccg9oLkGvowk373sX9HvX5U37kql5d55SzaQUxPE8PwgX2cqkzDm5NF5aPKevqg==", + "license": "MIT", + "dependencies": { + "@octokit/auth-app": "^7.1.5", + "@octokit/auth-unauthenticated": "^6.1.2", + "@octokit/core": "^6.1.4", + "@octokit/oauth-app": "^7.1.6", + "@octokit/plugin-paginate-rest": "^11.4.2", + "@octokit/types": "^13.8.0", + "@octokit/webhooks": "^13.6.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-app": { + "version": "7.1.5", + "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-7.1.5.tgz", + "integrity": "sha512-boklS4E6LpbA3nRx+SU2fRKRGZJdOGoSZne/i3Y0B5rfHOcGwFgcXrwDLdtbv4igfDSnAkZaoNBv1GYjPDKRNw==", + "license": "MIT", + "dependencies": { + "@octokit/auth-oauth-app": "^8.1.3", + "@octokit/auth-oauth-user": "^5.1.3", + "@octokit/request": "^9.2.1", + "@octokit/request-error": "^6.1.7", + "@octokit/types": "^13.8.0", + "toad-cache": "^3.7.0", + "universal-github-app-jwt": "^2.2.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-oauth-app": { + "version": "8.1.3", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-8.1.3.tgz", + "integrity": "sha512-4e6OjVe5rZ8yBe8w7byBjpKtSXFuro7gqeGAAZc7QYltOF8wB93rJl2FE0a4U1Mt88xxPv/mS+25/0DuLk0Ewg==", + "license": "MIT", + "dependencies": { + "@octokit/auth-oauth-device": "^7.1.3", + "@octokit/auth-oauth-user": "^5.1.3", + "@octokit/request": "^9.2.1", + "@octokit/types": "^13.6.2", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-oauth-device": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-7.1.3.tgz", + "integrity": "sha512-BECO/N4B/Uikj0w3GCvjf/odMujtYTP3q82BJSjxC2J3rxTEiZIJ+z2xnRlDb0IE9dQSaTgRqUPVOieSbFcVzg==", + "license": "MIT", + "dependencies": { + "@octokit/oauth-methods": "^5.1.4", + "@octokit/request": "^9.2.1", + "@octokit/types": "^13.6.2", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-oauth-user": { + "version": "5.1.3", + "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-5.1.3.tgz", + "integrity": "sha512-zNPByPn9K7TC+OOHKGxU+MxrE9SZAN11UHYEFLsK2NRn3akJN2LHRl85q+Eypr3tuB2GrKx3rfj2phJdkYCvzw==", + "license": "MIT", + "dependencies": { + "@octokit/auth-oauth-device": "^7.1.3", + "@octokit/oauth-methods": "^5.1.3", + "@octokit/request": "^9.2.1", + "@octokit/types": "^13.6.2", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-token": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-5.1.2.tgz", + "integrity": "sha512-JcQDsBdg49Yky2w2ld20IHAlwr8d/d8N6NiOXbtuoPCqzbsiJgF633mVUw3x4mo0H5ypataQIX7SFu3yy44Mpw==", + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/auth-unauthenticated": { + "version": "6.1.2", + "resolved": "https://registry.npmjs.org/@octokit/auth-unauthenticated/-/auth-unauthenticated-6.1.2.tgz", + "integrity": "sha512-07DlUGcz/AAVdzu3EYfi/dOyMSHp9YsOxPl/MPmtlVXWiD//GlV8HgZsPhud94DEyx+RfrW0wSl46Lx+AWbOlg==", + "license": "MIT", + "dependencies": { + "@octokit/request-error": "^6.1.7", + "@octokit/types": "^13.6.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/core": { + "version": "6.1.4", + "resolved": "https://registry.npmjs.org/@octokit/core/-/core-6.1.4.tgz", + "integrity": "sha512-lAS9k7d6I0MPN+gb9bKDt7X8SdxknYqAMh44S5L+lNqIN2NuV8nvv3g8rPp7MuRxcOpxpUIATWprO0C34a8Qmg==", + "license": "MIT", + "dependencies": { + "@octokit/auth-token": "^5.0.0", + "@octokit/graphql": "^8.1.2", + "@octokit/request": "^9.2.1", + "@octokit/request-error": "^6.1.7", + "@octokit/types": "^13.6.2", + "before-after-hook": "^3.0.2", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/endpoint": { + "version": "10.1.3", + "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-10.1.3.tgz", + "integrity": "sha512-nBRBMpKPhQUxCsQQeW+rCJ/OPSMcj3g0nfHn01zGYZXuNDvvXudF/TYY6APj5THlurerpFN4a/dQAIAaM6BYhA==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.6.2", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/graphql": { + "version": "8.2.1", + "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-8.2.1.tgz", + "integrity": "sha512-n57hXtOoHrhwTWdvhVkdJHdhTv0JstjDbDRhJfwIRNfFqmSo1DaK/mD2syoNUoLCyqSjBpGAKOG0BuwF392slw==", + "license": "MIT", + "dependencies": { + "@octokit/request": "^9.2.2", + "@octokit/types": "^13.8.0", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/oauth-app": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/@octokit/oauth-app/-/oauth-app-7.1.6.tgz", + "integrity": "sha512-OMcMzY2WFARg80oJNFwWbY51TBUfLH4JGTy119cqiDawSFXSIBujxmpXiKbGWQlvfn0CxE6f7/+c6+Kr5hI2YA==", + "license": "MIT", + "dependencies": { + "@octokit/auth-oauth-app": "^8.1.3", + "@octokit/auth-oauth-user": "^5.1.3", + "@octokit/auth-unauthenticated": "^6.1.2", + "@octokit/core": "^6.1.4", + "@octokit/oauth-authorization-url": "^7.1.1", + "@octokit/oauth-methods": "^5.1.4", + "@types/aws-lambda": "^8.10.83", + "universal-user-agent": "^7.0.0" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/oauth-authorization-url": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-7.1.1.tgz", + "integrity": "sha512-ooXV8GBSabSWyhLUowlMIVd9l1s2nsOGQdlP2SQ4LnkEsGXzeCvbSbCPdZThXhEFzleGPwbapT0Sb+YhXRyjCA==", + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/oauth-methods": { + "version": "5.1.4", + "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-5.1.4.tgz", + "integrity": "sha512-Jc/ycnePClOvO1WL7tlC+TRxOFtyJBGuTDsL4dzXNiVZvzZdrPuNw7zHI3qJSUX2n6RLXE5L0SkFmYyNaVUFoQ==", + "license": "MIT", + "dependencies": { + "@octokit/oauth-authorization-url": "^7.0.0", + "@octokit/request": "^9.2.1", + "@octokit/request-error": "^6.1.7", + "@octokit/types": "^13.6.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/openapi-types": { + "version": "23.0.1", + "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-23.0.1.tgz", + "integrity": "sha512-izFjMJ1sir0jn0ldEKhZ7xegCTj/ObmEDlEfpFrx4k/JyZSMRHbO3/rBwgE7f3m2DHt+RrNGIVw4wSmwnm3t/g==", + "license": "MIT" + }, + "node_modules/@octokit/openapi-webhooks-types": { + "version": "10.1.1", + "resolved": "https://registry.npmjs.org/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-10.1.1.tgz", + "integrity": "sha512-qBfqQVIDQaCFeGCofXieJDwvXcGgDn17+UwZ6WW6lfEvGYGreLFzTiaz9xjet9Us4zDf8iasoW3ixUj/R5lMhA==", + "license": "MIT" + }, + "node_modules/@octokit/plugin-paginate-graphql": { + "version": "5.2.4", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-5.2.4.tgz", + "integrity": "sha512-pLZES1jWaOynXKHOqdnwZ5ULeVR6tVVCMm+AUbp0htdcyXDU95WbkYdU4R2ej1wKj5Tu94Mee2Ne0PjPO9cCyA==", + "license": "MIT", + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-paginate-rest": { + "version": "11.4.3", + "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-11.4.3.tgz", + "integrity": "sha512-tBXaAbXkqVJlRoA/zQVe9mUdb8rScmivqtpv3ovsC5xhje/a+NOCivs7eUhWBwCApJVsR4G5HMeaLbq7PxqZGA==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.7.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-rest-endpoint-methods": { + "version": "13.3.1", + "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-13.3.1.tgz", + "integrity": "sha512-o8uOBdsyR+WR8MK9Cco8dCgvG13H1RlM1nWnK/W7TEACQBFux/vPREgKucxUfuDQ5yi1T3hGf4C5ZmZXAERgwQ==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.8.0" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-retry": { + "version": "7.1.4", + "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-7.1.4.tgz", + "integrity": "sha512-7AIP4p9TttKN7ctygG4BtR7rrB0anZqoU9ThXFk8nETqIfvgPUANTSYHqWYknK7W3isw59LpZeLI8pcEwiJdRg==", + "license": "MIT", + "dependencies": { + "@octokit/request-error": "^6.1.7", + "@octokit/types": "^13.6.2", + "bottleneck": "^2.15.3" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": ">=6" + } + }, + "node_modules/@octokit/plugin-throttling": { + "version": "9.4.0", + "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-9.4.0.tgz", + "integrity": "sha512-IOlXxXhZA4Z3m0EEYtrrACkuHiArHLZ3CvqWwOez/pURNqRuwfoFlTPbN5Muf28pzFuztxPyiUiNwz8KctdZaQ==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.7.0", + "bottleneck": "^2.15.3" + }, + "engines": { + "node": ">= 18" + }, + "peerDependencies": { + "@octokit/core": "^6.1.3" + } + }, + "node_modules/@octokit/request": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/@octokit/request/-/request-9.2.2.tgz", + "integrity": "sha512-dZl0ZHx6gOQGcffgm1/Sf6JfEpmh34v3Af2Uci02vzUYz6qEN6zepoRtmybWXIGXFIK8K9ylE3b+duCWqhArtg==", + "license": "MIT", + "dependencies": { + "@octokit/endpoint": "^10.1.3", + "@octokit/request-error": "^6.1.7", + "@octokit/types": "^13.6.2", + "fast-content-type-parse": "^2.0.0", + "universal-user-agent": "^7.0.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/request-error": { + "version": "6.1.7", + "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-6.1.7.tgz", + "integrity": "sha512-69NIppAwaauwZv6aOzb+VVLwt+0havz9GT5YplkeJv7fG7a40qpLt/yZKyiDxAhgz0EtgNdNcb96Z0u+Zyuy2g==", + "license": "MIT", + "dependencies": { + "@octokit/types": "^13.6.2" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/tsconfig": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@octokit/tsconfig/-/tsconfig-4.0.0.tgz", + "integrity": "sha512-hRd6UhX19m+8WhfrEpNLtm9TjuizYSG/dE0a+ivU71ylSxABVe4mEK+JMAGdjj6/gIQ+5DPegTPofi4P8VC5IA==", + "dev": true, + "license": "MIT" + }, + "node_modules/@octokit/types": { + "version": "13.8.0", + "resolved": "https://registry.npmjs.org/@octokit/types/-/types-13.8.0.tgz", + "integrity": "sha512-x7DjTIbEpEWXK99DMd01QfWy0hd5h4EN+Q7shkdKds3otGQP+oWE/y0A76i1OvH9fygo4ddvNf7ZvF0t78P98A==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-types": "^23.0.1" + } + }, + "node_modules/@octokit/webhooks": { + "version": "13.7.4", + "resolved": "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-13.7.4.tgz", + "integrity": "sha512-f386XyLTieQbgKPKS6ZMlH4dq8eLsxNddwofiKRZCq0bZ2gikoFwMD99K6l1oAwqe/KZNzrEziGicRgnzplplQ==", + "license": "MIT", + "dependencies": { + "@octokit/openapi-webhooks-types": "10.1.1", + "@octokit/request-error": "^6.1.7", + "@octokit/webhooks-methods": "^5.1.1" + }, + "engines": { + "node": ">= 18" + } + }, + "node_modules/@octokit/webhooks-methods": { + "version": "5.1.1", + "resolved": "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-5.1.1.tgz", + "integrity": "sha512-NGlEHZDseJTCj8TMMFehzwa9g7On4KJMPVHDSrHxCQumL6uSQR8wIkP/qesv52fXqV1BPf4pTxwtS31ldAt9Xg==", + "license": "MIT", + "engines": { + "node": ">= 18" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "license": "MIT", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@rollup/rollup-android-arm-eabi": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm-eabi/-/rollup-android-arm-eabi-4.34.9.tgz", + "integrity": "sha512-qZdlImWXur0CFakn2BJ2znJOdqYZKiedEPEVNTBrpfPjc/YuTGcaYZcdmNFTkUj3DU0ZM/AElcM8Ybww3xVLzA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-android-arm64": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-android-arm64/-/rollup-android-arm64-4.34.9.tgz", + "integrity": "sha512-4KW7P53h6HtJf5Y608T1ISKvNIYLWRKMvfnG0c44M6In4DQVU58HZFEVhWINDZKp7FZps98G3gxwC1sb0wXUUg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "android" + ] + }, + "node_modules/@rollup/rollup-darwin-arm64": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-arm64/-/rollup-darwin-arm64-4.34.9.tgz", + "integrity": "sha512-0CY3/K54slrzLDjOA7TOjN1NuLKERBgk9nY5V34mhmuu673YNb+7ghaDUs6N0ujXR7fz5XaS5Aa6d2TNxZd0OQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-darwin-x64": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-darwin-x64/-/rollup-darwin-x64-4.34.9.tgz", + "integrity": "sha512-eOojSEAi/acnsJVYRxnMkPFqcxSMFfrw7r2iD9Q32SGkb/Q9FpUY1UlAu1DH9T7j++gZ0lHjnm4OyH2vCI7l7Q==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@rollup/rollup-freebsd-arm64": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-arm64/-/rollup-freebsd-arm64-4.34.9.tgz", + "integrity": "sha512-2lzjQPJbN5UnHm7bHIUKFMulGTQwdvOkouJDpPysJS+QFBGDJqcfh+CxxtG23Ik/9tEvnebQiylYoazFMAgrYw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-freebsd-x64": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-freebsd-x64/-/rollup-freebsd-x64-4.34.9.tgz", + "integrity": "sha512-SLl0hi2Ah2H7xQYd6Qaiu01kFPzQ+hqvdYSoOtHYg/zCIFs6t8sV95kaoqjzjFwuYQLtOI0RZre/Ke0nPaQV+g==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "freebsd" + ] + }, + "node_modules/@rollup/rollup-linux-arm-gnueabihf": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-gnueabihf/-/rollup-linux-arm-gnueabihf-4.34.9.tgz", + "integrity": "sha512-88I+D3TeKItrw+Y/2ud4Tw0+3CxQ2kLgu3QvrogZ0OfkmX/DEppehus7L3TS2Q4lpB+hYyxhkQiYPJ6Mf5/dPg==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm-musleabihf": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm-musleabihf/-/rollup-linux-arm-musleabihf-4.34.9.tgz", + "integrity": "sha512-3qyfWljSFHi9zH0KgtEPG4cBXHDFhwD8kwg6xLfHQ0IWuH9crp005GfoUUh/6w9/FWGBwEHg3lxK1iHRN1MFlA==", + "cpu": [ + "arm" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-gnu": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-gnu/-/rollup-linux-arm64-gnu-4.34.9.tgz", + "integrity": "sha512-6TZjPHjKZUQKmVKMUowF3ewHxctrRR09eYyvT5eFv8w/fXarEra83A2mHTVJLA5xU91aCNOUnM+DWFMSbQ0Nxw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-arm64-musl": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-arm64-musl/-/rollup-linux-arm64-musl-4.34.9.tgz", + "integrity": "sha512-LD2fytxZJZ6xzOKnMbIpgzFOuIKlxVOpiMAXawsAZ2mHBPEYOnLRK5TTEsID6z4eM23DuO88X0Tq1mErHMVq0A==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-loongarch64-gnu": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-loongarch64-gnu/-/rollup-linux-loongarch64-gnu-4.34.9.tgz", + "integrity": "sha512-dRAgTfDsn0TE0HI6cmo13hemKpVHOEyeciGtvlBTkpx/F65kTvShtY/EVyZEIfxFkV5JJTuQ9tP5HGBS0hfxIg==", + "cpu": [ + "loong64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-powerpc64le-gnu": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-powerpc64le-gnu/-/rollup-linux-powerpc64le-gnu-4.34.9.tgz", + "integrity": "sha512-PHcNOAEhkoMSQtMf+rJofwisZqaU8iQ8EaSps58f5HYll9EAY5BSErCZ8qBDMVbq88h4UxaNPlbrKqfWP8RfJA==", + "cpu": [ + "ppc64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-riscv64-gnu": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-riscv64-gnu/-/rollup-linux-riscv64-gnu-4.34.9.tgz", + "integrity": "sha512-Z2i0Uy5G96KBYKjeQFKbbsB54xFOL5/y1P5wNBsbXB8yE+At3oh0DVMjQVzCJRJSfReiB2tX8T6HUFZ2k8iaKg==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-s390x-gnu": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-s390x-gnu/-/rollup-linux-s390x-gnu-4.34.9.tgz", + "integrity": "sha512-U+5SwTMoeYXoDzJX5dhDTxRltSrIax8KWwfaaYcynuJw8mT33W7oOgz0a+AaXtGuvhzTr2tVKh5UO8GVANTxyQ==", + "cpu": [ + "s390x" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-gnu": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-gnu/-/rollup-linux-x64-gnu-4.34.9.tgz", + "integrity": "sha512-FwBHNSOjUTQLP4MG7y6rR6qbGw4MFeQnIBrMe161QGaQoBQLqSUEKlHIiVgF3g/mb3lxlxzJOpIBhaP+C+KP2A==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-linux-x64-musl": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-linux-x64-musl/-/rollup-linux-x64-musl-4.34.9.tgz", + "integrity": "sha512-cYRpV4650z2I3/s6+5/LONkjIz8MBeqrk+vPXV10ORBnshpn8S32bPqQ2Utv39jCiDcO2eJTuSlPXpnvmaIgRA==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@rollup/rollup-win32-arm64-msvc": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-arm64-msvc/-/rollup-win32-arm64-msvc-4.34.9.tgz", + "integrity": "sha512-z4mQK9dAN6byRA/vsSgQiPeuO63wdiDxZ9yg9iyX2QTzKuQM7T4xlBoeUP/J8uiFkqxkcWndWi+W7bXdPbt27Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-ia32-msvc": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-ia32-msvc/-/rollup-win32-ia32-msvc-4.34.9.tgz", + "integrity": "sha512-KB48mPtaoHy1AwDNkAJfHXvHp24H0ryZog28spEs0V48l3H1fr4i37tiyHsgKZJnCmvxsbATdZGBpbmxTE3a9w==", + "cpu": [ + "ia32" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@rollup/rollup-win32-x64-msvc": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/@rollup/rollup-win32-x64-msvc/-/rollup-win32-x64-msvc-4.34.9.tgz", + "integrity": "sha512-AyleYRPU7+rgkMWbEh71fQlrzRfeP6SyMnRf9XX4fCdDPAJumdSBqYEcWPMzVQ4ScAl7E4oFfK0GUVn77xSwbw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@types/aws-lambda": { + "version": "8.10.147", + "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.147.tgz", + "integrity": "sha512-nD0Z9fNIZcxYX5Mai2CTmFD7wX7UldCkW2ezCF8D1T5hdiLsnTWDGRpfRYntU6VjTdLQjOvyszru7I1c1oCQew==", + "license": "MIT" + }, + "node_modules/@types/estree": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.6.tgz", + "integrity": "sha512-AYnb1nQyY49te+VRAVgmzfcgjYS91mY5P0TKUDCLEM+gNnA+3T6rWITXRLYCpahpqSQbN5cE+gHpnPyXjHWxcw==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/glob-to-regexp": { + "version": "0.4.4", + "resolved": "https://registry.npmjs.org/@types/glob-to-regexp/-/glob-to-regexp-0.4.4.tgz", + "integrity": "sha512-nDKoaKJYbnn1MZxUY0cA1bPmmgZbg0cTq7Rh13d0KWYNOiKbqoR+2d89SnRPszGh7ROzSwZ/GOjZ4jPbmmZ6Eg==", + "dev": true, + "license": "MIT" + }, + "node_modules/@types/node": { + "version": "22.13.8", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.13.8.tgz", + "integrity": "sha512-G3EfaZS+iOGYWLLRCEAXdWK9my08oHNZ+FHluRiggIYJPOXzhOiDgpVCUHaUvyIC5/fj7C/p637jdzC666AOKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "undici-types": "~6.20.0" + } + }, + "node_modules/@vitest/coverage-v8": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-3.0.7.tgz", + "integrity": "sha512-Av8WgBJLTrfLOer0uy3CxjlVuWK4CzcLBndW1Nm2vI+3hZ2ozHututkfc7Blu1u6waeQ7J8gzPK/AsBRnWA5mQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@ampproject/remapping": "^2.3.0", + "@bcoe/v8-coverage": "^1.0.2", + "debug": "^4.4.0", + "istanbul-lib-coverage": "^3.2.2", + "istanbul-lib-report": "^3.0.1", + "istanbul-lib-source-maps": "^5.0.6", + "istanbul-reports": "^3.1.7", + "magic-string": "^0.30.17", + "magicast": "^0.3.5", + "std-env": "^3.8.0", + "test-exclude": "^7.0.1", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@vitest/browser": "3.0.7", + "vitest": "3.0.7" + }, + "peerDependenciesMeta": { + "@vitest/browser": { + "optional": true + } + } + }, + "node_modules/@vitest/expect": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-3.0.7.tgz", + "integrity": "sha512-QP25f+YJhzPfHrHfYHtvRn+uvkCFCqFtW9CktfBxmB+25QqWsx7VB2As6f4GmwllHLDhXNHvqedwhvMmSnNmjw==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "3.0.7", + "@vitest/utils": "3.0.7", + "chai": "^5.2.0", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/mocker": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-3.0.7.tgz", + "integrity": "sha512-qui+3BLz9Eonx4EAuR/i+QlCX6AUZ35taDQgwGkK/Tw6/WgwodSrjN1X2xf69IA/643ZX5zNKIn2svvtZDrs4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/spy": "3.0.7", + "estree-walker": "^3.0.3", + "magic-string": "^0.30.17" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "msw": "^2.4.9", + "vite": "^5.0.0 || ^6.0.0" + }, + "peerDependenciesMeta": { + "msw": { + "optional": true + }, + "vite": { + "optional": true + } + } + }, + "node_modules/@vitest/pretty-format": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-3.0.7.tgz", + "integrity": "sha512-CiRY0BViD/V8uwuEzz9Yapyao+M9M008/9oMOSQydwbwb+CMokEq3XVaF3XK/VWaOK0Jm9z7ENhybg70Gtxsmg==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/runner": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-3.0.7.tgz", + "integrity": "sha512-WeEl38Z0S2ZcuRTeyYqaZtm4e26tq6ZFqh5y8YD9YxfWuu0OFiGFUbnxNynwLjNRHPsXyee2M9tV7YxOTPZl2g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/utils": "3.0.7", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/snapshot": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-3.0.7.tgz", + "integrity": "sha512-eqTUryJWQN0Rtf5yqCGTQWsCFOQe4eNz5Twsu21xYEcnFJtMU5XvmG0vgebhdLlrHQTSq5p8vWHJIeJQV8ovsA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.0.7", + "magic-string": "^0.30.17", + "pathe": "^2.0.3" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/spy": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-3.0.7.tgz", + "integrity": "sha512-4T4WcsibB0B6hrKdAZTM37ekuyFZt2cGbEGd2+L0P8ov15J1/HUsUaqkXEQPNAWr4BtPPe1gI+FYfMHhEKfR8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "tinyspy": "^3.0.2" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/@vitest/utils": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-3.0.7.tgz", + "integrity": "sha512-xePVpCRfooFX3rANQjwoditoXgWb1MaFbzmGuPP59MK6i13mrnDw/yEIyJudLeW6/38mCNcwCiJIGmpDPibAIg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/pretty-format": "3.0.7", + "loupe": "^3.1.3", + "tinyrainbow": "^2.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/assertion-error": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-2.0.1.tgz", + "integrity": "sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", + "dev": true, + "license": "MIT" + }, + "node_modules/before-after-hook": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-3.0.2.tgz", + "integrity": "sha512-Nik3Sc0ncrMK4UUdXQmAnRtzmNQTAAXmXIopizwZ1W1t8QmfJj+zL4OA2I7XPTPW5z5TDqv4hRo/JzouDJnX3A==", + "license": "Apache-2.0" + }, + "node_modules/bottleneck": { + "version": "2.19.5", + "resolved": "https://registry.npmjs.org/bottleneck/-/bottleneck-2.19.5.tgz", + "integrity": "sha512-VHiNCbI1lKdl44tGrhNfU3lup0Tj/ZBMJB5/2ZbNXRCPuRCO7ed2mgcK4r17y+KB2EfuYuRaVlwNbAeaWGSpbw==", + "license": "MIT" + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/cac": { + "version": "6.7.14", + "resolved": "https://registry.npmjs.org/cac/-/cac-6.7.14.tgz", + "integrity": "sha512-b6Ilus+c3RrdDk+JhLKUAQfzzgLEPy6wcXqS7f/xe1EETvsDP6GORG7SFuOs6cID5YkqchW/LXZbX5bc8j7ZcQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/chai": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-5.2.0.tgz", + "integrity": "sha512-mCuXncKXk5iCLhfhwTc0izo0gtEmpz5CtG2y8GiOINBlMVS6v8TMRc5TaLWKS6692m9+dVVfzgeVxR5UxWHTYw==", + "dev": true, + "license": "MIT", + "dependencies": { + "assertion-error": "^2.0.1", + "check-error": "^2.1.1", + "deep-eql": "^5.0.1", + "loupe": "^3.1.0", + "pathval": "^2.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/check-error": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-2.1.1.tgz", + "integrity": "sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 16" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true, + "license": "MIT" + }, + "node_modules/cross-spawn": { + "version": "7.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz", + "integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==", + "dev": true, + "license": "MIT", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.0.tgz", + "integrity": "sha512-6WTZ/IxCY/T6BALoZHaE4ctp9xm+Z5kY/pzYaCHRFeyVhojxlrm+46y68HA6hr0TcwEssoxNiDEUJQjfPZ/RYA==", + "dev": true, + "license": "MIT", + "dependencies": { + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/deep-eql": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-5.0.2.tgz", + "integrity": "sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/dequal": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/dequal/-/dequal-2.0.3.tgz", + "integrity": "sha512-0je+qPKHEMohvfRTCEo3CrPG6cAzAYgmzKyxRiYSSDkS6eGJdyVJm7WaYA5ECaAD9wLB2T4EEeymA5aFVcYXCA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=6" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", + "dev": true, + "license": "MIT" + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", + "dev": true, + "license": "MIT" + }, + "node_modules/es-module-lexer": { + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-1.6.0.tgz", + "integrity": "sha512-qqnD1yMU6tk/jnaMosogGySTZP8YtUgAffA9nMN+E/rjxcfRQ6IEk7IiozUjgxKoFHBGjTLnrHB/YC45r/59EQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/esbuild": { + "version": "0.25.0", + "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.25.0.tgz", + "integrity": "sha512-BXq5mqc8ltbaN34cDqWuYKyNhX8D/Z0J1xdtdQ8UcIIIyJyz+ZMKUt58tF3SrZ85jcfN/PZYhjR5uDQAYNVbuw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "esbuild": "bin/esbuild" + }, + "engines": { + "node": ">=18" + }, + "optionalDependencies": { + "@esbuild/aix-ppc64": "0.25.0", + "@esbuild/android-arm": "0.25.0", + "@esbuild/android-arm64": "0.25.0", + "@esbuild/android-x64": "0.25.0", + "@esbuild/darwin-arm64": "0.25.0", + "@esbuild/darwin-x64": "0.25.0", + "@esbuild/freebsd-arm64": "0.25.0", + "@esbuild/freebsd-x64": "0.25.0", + "@esbuild/linux-arm": "0.25.0", + "@esbuild/linux-arm64": "0.25.0", + "@esbuild/linux-ia32": "0.25.0", + "@esbuild/linux-loong64": "0.25.0", + "@esbuild/linux-mips64el": "0.25.0", + "@esbuild/linux-ppc64": "0.25.0", + "@esbuild/linux-riscv64": "0.25.0", + "@esbuild/linux-s390x": "0.25.0", + "@esbuild/linux-x64": "0.25.0", + "@esbuild/netbsd-arm64": "0.25.0", + "@esbuild/netbsd-x64": "0.25.0", + "@esbuild/openbsd-arm64": "0.25.0", + "@esbuild/openbsd-x64": "0.25.0", + "@esbuild/sunos-x64": "0.25.0", + "@esbuild/win32-arm64": "0.25.0", + "@esbuild/win32-ia32": "0.25.0", + "@esbuild/win32-x64": "0.25.0" + } + }, + "node_modules/estree-walker": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-3.0.3.tgz", + "integrity": "sha512-7RUKfXgSMMkzt6ZuXmqapOurLGPPfgj6l9uRZ7lRGolvk0y2yocc35LdcxKC5PQZdn2DMqioAQ2NoWcrTKmm6g==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "^1.0.0" + } + }, + "node_modules/expect-type": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.2.0.tgz", + "integrity": "sha512-80F22aiJ3GLyVnS/B3HzgR6RelZVumzj9jkL0Rhz4h0xYbNW9PjlQz5h3J/SShErbXBc295vseR4/MIbVmUbeA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/fast-content-type-parse": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-2.0.1.tgz", + "integrity": "sha512-nGqtvLrj5w0naR6tDPfB4cUmYCqouzyQiz6C5y/LtcDllJdrcc6WaWW6iXyIIOErTa/XRybj28aasdn4LkVk6Q==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/fastify" + }, + { + "type": "opencollective", + "url": "https://opencollective.com/fastify" + } + ], + "license": "MIT" + }, + "node_modules/fetch-mock": { + "version": "11.1.5", + "resolved": "https://registry.npmjs.org/fetch-mock/-/fetch-mock-11.1.5.tgz", + "integrity": "sha512-KHmZDnZ1ry0pCTrX4YG5DtThHi0MH+GNI9caESnzX/nMJBrvppUHMvLx47M0WY9oAtKOMiPfZDRpxhlHg89BOA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/glob-to-regexp": "^0.4.4", + "dequal": "^2.0.3", + "glob-to-regexp": "^0.4.1", + "is-subset": "^0.1.1", + "regexparam": "^3.0.0" + }, + "engines": { + "node": ">=8.0.0" + }, + "peerDependenciesMeta": { + "node-fetch": { + "optional": true + } + } + }, + "node_modules/foreground-child": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.1.tgz", + "integrity": "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw==", + "dev": true, + "license": "ISC", + "dependencies": { + "cross-spawn": "^7.0.6", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/fsevents": { + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz", + "integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": "^8.16.0 || ^10.6.0 || >=11.0.0" + } + }, + "node_modules/glob": { + "version": "11.0.1", + "resolved": "https://registry.npmjs.org/glob/-/glob-11.0.1.tgz", + "integrity": "sha512-zrQDm8XPnYEKawJScsnM0QzobJxlT/kHOOlRTio8IH/GrmxRE5fjllkzdaHclIuNjUQTJYH2xHNIGfdpJkDJUw==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^4.0.1", + "minimatch": "^10.0.0", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^2.0.0" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob-to-regexp": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz", + "integrity": "sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw==", + "dev": true, + "license": "BSD-2-Clause" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/is-subset": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/is-subset/-/is-subset-0.1.1.tgz", + "integrity": "sha512-6Ybun0IkarhmEqxXCNw/C0bna6Zb/TkfUX9UbwJtK6ObwAVCxmAP308WWTHviM/zAqXk05cdhYsUsZeGQh99iw==", + "dev": true, + "license": "MIT" + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, + "node_modules/istanbul-lib-coverage": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.2.2.tgz", + "integrity": "sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=8" + } + }, + "node_modules/istanbul-lib-report": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.1.tgz", + "integrity": "sha512-GCfE1mtsHGOELCU8e/Z7YWzpmybrx/+dSTfLrvY8qRmaY6zXTKWn6WQIjaAFw069icm6GVMNkgu0NzI4iPZUNw==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^4.0.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-lib-source-maps": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-5.0.6.tgz", + "integrity": "sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "@jridgewell/trace-mapping": "^0.3.23", + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/istanbul-reports": { + "version": "3.1.7", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.1.7.tgz", + "integrity": "sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==", + "dev": true, + "license": "BSD-3-Clause", + "dependencies": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/jackspeak": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-4.1.0.tgz", + "integrity": "sha512-9DDdhb5j6cpeitCbvLO7n7J4IxnbM6hoF6O1g4HQ5TfhvvKN8ywDM7668ZhMHRqVmxqhps/F6syWK2KcPxYlkw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/loupe": { + "version": "3.1.3", + "resolved": "https://registry.npmjs.org/loupe/-/loupe-3.1.3.tgz", + "integrity": "sha512-kkIp7XSkP78ZxJEsSxW3712C6teJVoeHHwgo9zJ380de7IYyJ2ISlxojcH2pC5OFLewESmnRi/+XCDIEEVyoug==", + "dev": true, + "license": "MIT" + }, + "node_modules/lru-cache": { + "version": "11.0.2", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.0.2.tgz", + "integrity": "sha512-123qHRfJBmo2jXDbo/a5YOQrJoHF/GNQTLzQ5+IdK5pWpceK17yRc6ozlWd25FxvGKQbIUs91fDFkXmDHTKcyA==", + "dev": true, + "license": "ISC", + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/magic-string": { + "version": "0.30.17", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.17.tgz", + "integrity": "sha512-sNPKHvyjVf7gyjwS4xGTaW/mCnF8wnjtifKBEhxfZ7E/S8tQ0rssrwGNn6q8JH/ohItJfSQp9mBtQYuTlH5QnA==", + "dev": true, + "license": "MIT", + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.5.0" + } + }, + "node_modules/magicast": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.3.5.tgz", + "integrity": "sha512-L0WhttDl+2BOsybvEOLK7fW3UA0OQ0IQ2d6Zl2x/a6vVRs3bAY0ECOSHHeL5jD+SbOpOCUEi0y1DgHEn9Qn1AQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@babel/parser": "^7.25.4", + "@babel/types": "^7.25.4", + "source-map-js": "^1.2.0" + } + }, + "node_modules/make-dir": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-4.0.0.tgz", + "integrity": "sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==", + "dev": true, + "license": "MIT", + "dependencies": { + "semver": "^7.5.3" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/minimatch": { + "version": "10.0.1", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.0.1.tgz", + "integrity": "sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.2.tgz", + "integrity": "sha512-qOOzS1cBTWYF4BH8fVePDBOO9iptMnGUEZwNc/cMWnTV2nVLZ7VoNWEPHkYczZA0pdoA7dl6e7FL659nX9S2aw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=16 || 14 >=14.17" + } + }, + "node_modules/mockdate": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/mockdate/-/mockdate-3.0.5.tgz", + "integrity": "sha512-iniQP4rj1FhBdBYS/+eQv7j1tadJ9lJtdzgOpvsOHng/GbcDh2Fhdeq+ZRldrPYdXvCyfFUmFeEwEGXZB5I/AQ==", + "dev": true, + "license": "MIT" + }, + "node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true, + "license": "MIT" + }, + "node_modules/nanoid": { + "version": "3.3.8", + "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.8.tgz", + "integrity": "sha512-WNLf5Sd8oZxOm+TzppcYk8gVOgP+l58xNy58D0nbUnOxOWRWvlcCV4kUF7ltmI6PsrLl/BgKEyS4mqsGChFN0w==", + "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "bin": { + "nanoid": "bin/nanoid.cjs" + }, + "engines": { + "node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1" + } + }, + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true, + "license": "BlueOak-1.0.0" + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.0.tgz", + "integrity": "sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/pathe": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", + "integrity": "sha512-WUjGcAqP1gQacoQe+OBJsFA7Ld4DyXuUIjZ5cc75cLHvJ7dtNsTugphxIADwspS+AraAUePCKrSVtPLFj/F88w==", + "dev": true, + "license": "MIT" + }, + "node_modules/pathval": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-2.0.0.tgz", + "integrity": "sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 14.16" + } + }, + "node_modules/picocolors": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", + "dev": true, + "license": "ISC" + }, + "node_modules/postcss": { + "version": "8.5.3", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.3.tgz", + "integrity": "sha512-dle9A3yYxlBSrt8Fu+IpjGT8SY8hN0mlaA6GY8t0P5PjIOZemULz/E2Bnm/2dcUOena75OTNkHI76uZBNUUq3A==", + "dev": true, + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/postcss/" + }, + { + "type": "tidelift", + "url": "https://tidelift.com/funding/github/npm/postcss" + }, + { + "type": "github", + "url": "https://github.com/sponsors/ai" + } + ], + "license": "MIT", + "dependencies": { + "nanoid": "^3.3.8", + "picocolors": "^1.1.1", + "source-map-js": "^1.2.1" + }, + "engines": { + "node": "^10 || ^12 || >=14" + } + }, + "node_modules/prettier": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", + "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", + "dev": true, + "license": "MIT", + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } + }, + "node_modules/regexparam": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/regexparam/-/regexparam-3.0.0.tgz", + "integrity": "sha512-RSYAtP31mvYLkAHrOlh25pCNQ5hWnT106VukGaaFfuJrZFkGRX5GhUAdPqpSDXxOhA2c4akmRuplv1mRqnBn6Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/rollup": { + "version": "4.34.9", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-4.34.9.tgz", + "integrity": "sha512-nF5XYqWWp9hx/LrpC8sZvvvmq0TeTjQgaZHYmAgwysT9nh8sWnZhBnM8ZyVbbJFIQBLwHDNoMqsBZBbUo4U8sQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/estree": "1.0.6" + }, + "bin": { + "rollup": "dist/bin/rollup" + }, + "engines": { + "node": ">=18.0.0", + "npm": ">=8.0.0" + }, + "optionalDependencies": { + "@rollup/rollup-android-arm-eabi": "4.34.9", + "@rollup/rollup-android-arm64": "4.34.9", + "@rollup/rollup-darwin-arm64": "4.34.9", + "@rollup/rollup-darwin-x64": "4.34.9", + "@rollup/rollup-freebsd-arm64": "4.34.9", + "@rollup/rollup-freebsd-x64": "4.34.9", + "@rollup/rollup-linux-arm-gnueabihf": "4.34.9", + "@rollup/rollup-linux-arm-musleabihf": "4.34.9", + "@rollup/rollup-linux-arm64-gnu": "4.34.9", + "@rollup/rollup-linux-arm64-musl": "4.34.9", + "@rollup/rollup-linux-loongarch64-gnu": "4.34.9", + "@rollup/rollup-linux-powerpc64le-gnu": "4.34.9", + "@rollup/rollup-linux-riscv64-gnu": "4.34.9", + "@rollup/rollup-linux-s390x-gnu": "4.34.9", + "@rollup/rollup-linux-x64-gnu": "4.34.9", + "@rollup/rollup-linux-x64-musl": "4.34.9", + "@rollup/rollup-win32-arm64-msvc": "4.34.9", + "@rollup/rollup-win32-ia32-msvc": "4.34.9", + "@rollup/rollup-win32-x64-msvc": "4.34.9", + "fsevents": "~2.3.2" + } + }, + "node_modules/semantic-release-plugin-update-version-in-files": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/semantic-release-plugin-update-version-in-files/-/semantic-release-plugin-update-version-in-files-2.0.0.tgz", + "integrity": "sha512-ovpBKjkygkbiTH0CG+vJb62O+eGFoI7PM5KCVuuy2I5Xaj5t9JzmwMtAAls3Ie+R06IQu556P4gIKjJ9FIDJZQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "debug": "^4.1.1", + "glob": "^10.0.0" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/semantic-release-plugin-update-version-in-files/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/semantic-release-plugin-update-version-in-files/node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/semantic-release-plugin-update-version-in-files/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/semantic-release-plugin-update-version-in-files/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/semantic-release-plugin-update-version-in-files/node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/semver": { + "version": "7.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.1.tgz", + "integrity": "sha512-hlq8tAfn0m/61p4BVRcPzIGr6LKiMwo4VM6dGi6pt4qcRkmNzTcWq6eCEjEh+qXjkMDvPlOFFSGwQjoEa6gyMA==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/siginfo": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/siginfo/-/siginfo-2.0.0.tgz", + "integrity": "sha512-ybx0WO1/8bSBLEWXZvEd7gMW3Sn3JFlW3TvX1nREbDLRNQNaeNN8WK0meBwPdAaOI7TtRRRJn/Es1zhrrCHu7g==", + "dev": true, + "license": "ISC" + }, + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "license": "ISC", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/source-map-js": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/source-map-js/-/source-map-js-1.2.1.tgz", + "integrity": "sha512-UXWMKhLOwVKb728IUtQPXxfYU+usdybtUrK/8uGE8CQMvrhOpwvzDBwj0QhSL7MQc7vIsISBG8VQ8+IDQxpfQA==", + "dev": true, + "license": "BSD-3-Clause", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/stackback": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/stackback/-/stackback-0.0.2.tgz", + "integrity": "sha512-1XMJE5fQo1jGH6Y/7ebnwPOBEkIEnT4QF32d5R1+VXdXveM0IBMJt8zfaxX1P3QhVwrYe+576+jkANtSS2mBbw==", + "dev": true, + "license": "MIT" + }, + "node_modules/std-env": { + "version": "3.8.0", + "resolved": "https://registry.npmjs.org/std-env/-/std-env-3.8.0.tgz", + "integrity": "sha512-Bc3YwwCB+OzldMxOXJIIvC6cPRWr/LxOp48CdQTOkPyk/t4JWWJbrilwBd7RJzKV8QW7tJkcgAmeuLLJugl5/w==", + "dev": true, + "license": "MIT" + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "license": "MIT", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/test-exclude": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-7.0.1.tgz", + "integrity": "sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==", + "dev": true, + "license": "ISC", + "dependencies": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^10.4.1", + "minimatch": "^9.0.4" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/test-exclude/node_modules/glob": { + "version": "10.4.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.4.5.tgz", + "integrity": "sha512-7Bv8RF0k6xjo7d4A/PxYLbUCfb6c+Vpd2/mB2yRDlew7Jb5hEXiCD9ibfO7wpk8i4sevK6DFny9h7EYbM3/sHg==", + "dev": true, + "license": "ISC", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/test-exclude/node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/test-exclude/node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/test-exclude/node_modules/minimatch": { + "version": "9.0.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.5.tgz", + "integrity": "sha512-G6T0ZX48xgozx7587koeX9Ys2NYy6Gmv//P89sEte9V9whIapMNF4idKxnW2QtCcLiTWlb/wfCabAtAFWhhBow==", + "dev": true, + "license": "ISC", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/test-exclude/node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "license": "BlueOak-1.0.0", + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/tinybench": { + "version": "2.9.0", + "resolved": "https://registry.npmjs.org/tinybench/-/tinybench-2.9.0.tgz", + "integrity": "sha512-0+DUvqWMValLmha6lr4kD8iAMK1HzV0/aKnCtWb9v9641TnP/MFb7Pc2bxoxQjTXAErryXVgUOfv2YqNllqGeg==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinyexec": { + "version": "0.3.2", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-0.3.2.tgz", + "integrity": "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA==", + "dev": true, + "license": "MIT" + }, + "node_modules/tinypool": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/tinypool/-/tinypool-1.0.2.tgz", + "integrity": "sha512-al6n+QEANGFOMf/dmUMsuS5/r9B06uwlyNjZZql/zv8J7ybHCgoihBNORZCY2mzUuAnomQa2JdhyHKzZxPCrFA==", + "dev": true, + "license": "MIT", + "engines": { + "node": "^18.0.0 || >=20.0.0" + } + }, + "node_modules/tinyrainbow": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-2.0.0.tgz", + "integrity": "sha512-op4nsTR47R6p0vMUUoYl/a+ljLFVtlfaXkLQmqfLR1qHma1h/ysYk4hEXZ880bf2CYgTskvTa/e196Vd5dDQXw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/tinyspy": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/tinyspy/-/tinyspy-3.0.2.tgz", + "integrity": "sha512-n1cw8k1k0x4pgA2+9XrOkFydTerNcJ1zWCO5Nn9scWHTD+5tp8dghT2x1uduQePZTZgd3Tupf+x9BxJjeJi77Q==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/toad-cache": { + "version": "3.7.0", + "resolved": "https://registry.npmjs.org/toad-cache/-/toad-cache-3.7.0.tgz", + "integrity": "sha512-/m8M+2BJUpoJdgAHoG+baCwBT+tf2VraSfkBgl0Y00qIWt41DJ8R5B8nsEw0I58YwF5IZH6z24/2TobDKnqSWw==", + "license": "MIT", + "engines": { + "node": ">=12" + } + }, + "node_modules/typescript": { + "version": "5.8.2", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.2.tgz", + "integrity": "sha512-aJn6wq13/afZp/jT9QZmwEjDqqvSGp1VT5GVg+f/t6/oVyrgXM6BY1h9BRh/O5p3PlUPAe+WuiEZOmb/49RqoQ==", + "dev": true, + "license": "Apache-2.0", + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, + "node_modules/undici-types": { + "version": "6.20.0", + "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.20.0.tgz", + "integrity": "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg==", + "dev": true, + "license": "MIT" + }, + "node_modules/universal-github-app-jwt": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-2.2.0.tgz", + "integrity": "sha512-G5o6f95b5BggDGuUfKDApKaCgNYy2x7OdHY0zSMF081O0EJobw+1130VONhrA7ezGSV2FNOGyM+KQpQZAr9bIQ==", + "license": "MIT" + }, + "node_modules/universal-user-agent": { + "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==", + "license": "ISC" + }, + "node_modules/vite": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/vite/-/vite-6.2.0.tgz", + "integrity": "sha512-7dPxoo+WsT/64rDcwoOjk76XHj+TqNTIvHKcuMQ1k4/SeHDaQt5GFAeLYzrimZrMpn/O6DtdI03WUjdxuPM0oQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "esbuild": "^0.25.0", + "postcss": "^8.5.3", + "rollup": "^4.30.1" + }, + "bin": { + "vite": "bin/vite.js" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://github.com/vitejs/vite?sponsor=1" + }, + "optionalDependencies": { + "fsevents": "~2.3.3" + }, + "peerDependencies": { + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "jiti": ">=1.21.0", + "less": "*", + "lightningcss": "^1.21.0", + "sass": "*", + "sass-embedded": "*", + "stylus": "*", + "sugarss": "*", + "terser": "^5.16.0", + "tsx": "^4.8.1", + "yaml": "^2.4.2" + }, + "peerDependenciesMeta": { + "@types/node": { + "optional": true + }, + "jiti": { + "optional": true + }, + "less": { + "optional": true + }, + "lightningcss": { + "optional": true + }, + "sass": { + "optional": true + }, + "sass-embedded": { + "optional": true + }, + "stylus": { + "optional": true + }, + "sugarss": { + "optional": true + }, + "terser": { + "optional": true + }, + "tsx": { + "optional": true + }, + "yaml": { + "optional": true + } + } + }, + "node_modules/vite-node": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/vite-node/-/vite-node-3.0.7.tgz", + "integrity": "sha512-2fX0QwX4GkkkpULXdT1Pf4q0tC1i1lFOyseKoonavXUNlQ77KpW2XqBGGNIm/J4Ows4KxgGJzDguYVPKwG/n5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "cac": "^6.7.14", + "debug": "^4.4.0", + "es-module-lexer": "^1.6.0", + "pathe": "^2.0.3", + "vite": "^5.0.0 || ^6.0.0" + }, + "bin": { + "vite-node": "vite-node.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + } + }, + "node_modules/vitest": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/vitest/-/vitest-3.0.7.tgz", + "integrity": "sha512-IP7gPK3LS3Fvn44x30X1dM9vtawm0aesAa2yBIZ9vQf+qB69NXC5776+Qmcr7ohUXIQuLhk7xQR0aSUIDPqavg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@vitest/expect": "3.0.7", + "@vitest/mocker": "3.0.7", + "@vitest/pretty-format": "^3.0.7", + "@vitest/runner": "3.0.7", + "@vitest/snapshot": "3.0.7", + "@vitest/spy": "3.0.7", + "@vitest/utils": "3.0.7", + "chai": "^5.2.0", + "debug": "^4.4.0", + "expect-type": "^1.1.0", + "magic-string": "^0.30.17", + "pathe": "^2.0.3", + "std-env": "^3.8.0", + "tinybench": "^2.9.0", + "tinyexec": "^0.3.2", + "tinypool": "^1.0.2", + "tinyrainbow": "^2.0.0", + "vite": "^5.0.0 || ^6.0.0", + "vite-node": "3.0.7", + "why-is-node-running": "^2.3.0" + }, + "bin": { + "vitest": "vitest.mjs" + }, + "engines": { + "node": "^18.0.0 || ^20.0.0 || >=22.0.0" + }, + "funding": { + "url": "https://opencollective.com/vitest" + }, + "peerDependencies": { + "@edge-runtime/vm": "*", + "@types/debug": "^4.1.12", + "@types/node": "^18.0.0 || ^20.0.0 || >=22.0.0", + "@vitest/browser": "3.0.7", + "@vitest/ui": "3.0.7", + "happy-dom": "*", + "jsdom": "*" + }, + "peerDependenciesMeta": { + "@edge-runtime/vm": { + "optional": true + }, + "@types/debug": { + "optional": true + }, + "@types/node": { + "optional": true + }, + "@vitest/browser": { + "optional": true + }, + "@vitest/ui": { + "optional": true + }, + "happy-dom": { + "optional": true + }, + "jsdom": { + "optional": true + } + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/why-is-node-running": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/why-is-node-running/-/why-is-node-running-2.3.0.tgz", + "integrity": "sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==", + "dev": true, + "license": "MIT", + "dependencies": { + "siginfo": "^2.0.0", + "stackback": "0.0.2" + }, + "bin": { + "why-is-node-running": "cli.js" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true, + "license": "MIT" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "license": "MIT", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + } + } +} diff --git a/package.json b/package.json index ec46d02972..9c9c821c80 100644 --- a/package.json +++ b/package.json @@ -1,36 +1,90 @@ { - "name" : "github", - "version" : "0.2.4", - "description" : "NodeJS wrapper for the GitHub API", - "author": "Mike de Boer ", - "contributors": [ - { "name": "Mike de Boer", "email": "info@mikedeboer.nl" }, - { "name": "Fabian Jakobs", "email": "fabian@c9.io" } + "name": "octokit", + "version": "0.0.0-development", + "type": "module", + "description": "The all-batteries-included GitHub SDK for Browsers, Node.js, and Deno", + "keywords": [ + "github", + "api", + "sdk", + "octokit" + ], + "author": "Gregor Martynus (https://github.com/gr2m)", + "repository": "github:octokit/octokit.js", + "license": "MIT", + "scripts": { + "build": "node scripts/build.mjs && tsc -p tsconfig.json", + "lint": "prettier --check \"{src,test,scripts}/**/*.{js,json,ts}\" \"*.{md,json}\"", + "lint:fix": "prettier --write \"{src,test,scripts}/**/*.{js,json,ts,mjs}\" \"*.{md,json}\"", + "pretest": "npm run -s lint", + "test": "vitest run --coverage", + "test:typescript": "npx tsc --noEmit --declaration --noUnusedLocals --esModuleInterop --module node16 --strict --allowImportingTsExtensions --exactOptionalPropertyTypes test/typescript-validate.ts" + }, + "dependencies": { + "@octokit/app": "^15.1.4", + "@octokit/core": "^6.1.4", + "@octokit/oauth-app": "^7.1.6", + "@octokit/plugin-paginate-graphql": "^5.2.4", + "@octokit/plugin-paginate-rest": "^11.4.2", + "@octokit/plugin-rest-endpoint-methods": "^13.3.1", + "@octokit/plugin-retry": "^7.1.4", + "@octokit/plugin-throttling": "^9.4.0", + "@octokit/request-error": "^6.1.7", + "@octokit/types": "^13.7.0" + }, + "devDependencies": { + "@octokit/tsconfig": "^4.0.0", + "@types/node": "^22.0.0", + "@vitest/coverage-v8": "^3.0.0", + "esbuild": "^0.25.0", + "fetch-mock": "^11.0.0", + "glob": "^11.0.0", + "mockdate": "^3.0.5", + "prettier": "3.5.3", + "semantic-release-plugin-update-version-in-files": "^2.0.0", + "typescript": "^5.0.0", + "vitest": "^3.0.0" + }, + "release": { + "branches": [ + "+([0-9]).x", + "main", + "next", + { + "name": "beta", + "prerelease": true + }, + { + "name": "debug", + "prerelease": true + } ], - "homepage": "http://github.com/mikedeboer/node-github", - "repository" : { - "type" : "git", - "url" : "http://github.com/mikedeboer/node-github.git" - }, - "engine" : { - "node": ">=0.4.0" - }, - "dependencies": { - "mime": "^1.2.11" - }, - "devDependencies": { - "async": "^0.9.0", - "oauth": "~0.9.7", - "optimist": "~0.6.0", - "mocha": "~1.13.0" - }, - "main" : ".", - "scripts": { - "test": "node ./test/all.js" - }, - "license": "MIT", - "licenses": [{ - "type": "The MIT License", - "url": "http://www.opensource.org/licenses/mit-license.php" - }] + "plugins": [ + "@semantic-release/commit-analyzer", + "@semantic-release/release-notes-generator", + "@semantic-release/github", + [ + "@semantic-release/npm", + { + "pkgRoot": "./pkg" + } + ], + [ + "semantic-release-plugin-update-version-in-files", + { + "files": [ + "pkg/dist-web/*", + "pkg/dist-node/*", + "pkg/*/version.*" + ] + } + ] + ] + }, + "engines": { + "node": ">= 18" + }, + "publishConfig": { + "provenance": true + } } diff --git a/scripts/build.mjs b/scripts/build.mjs new file mode 100644 index 0000000000..2d31efac2a --- /dev/null +++ b/scripts/build.mjs @@ -0,0 +1,83 @@ +// @ts-check +import esbuild from "esbuild"; +import { copyFile, readFile, writeFile, rm } from "node:fs/promises"; +import { glob } from "glob"; + +/** + * @type {esbuild.BuildOptions} + */ +const sharedOptions = { + sourcemap: "external", + sourcesContent: true, + minify: false, + allowOverwrite: true, + packages: "external", + platform: "neutral", + format: "esm", + target: "es2022", +}; + +async function main() { + // Start with a clean slate + await rm("pkg", { recursive: true, force: true }); + // Build the source code for a neutral platform as ESM + await esbuild.build({ + entryPoints: await glob(["./src/*.ts", "./src/**/*.ts"]), + outdir: "pkg/dist-src", + bundle: false, + ...sharedOptions, + sourcemap: false, + }); + + // Remove the types file from the dist-src folder + const typeFiles = await glob([ + "./pkg/dist-src/**/types.js.map", + "./pkg/dist-src/**/types.js", + ]); + for (const typeFile of typeFiles) { + await rm(typeFile); + } + + const entryPoints = ["./pkg/dist-src/index.js"]; + + // Build an ESM bundle + await esbuild.build({ + entryPoints, + outdir: "pkg/dist-bundle", + bundle: true, + ...sharedOptions, + }); + + // Copy the README, LICENSE to the pkg folder + await copyFile("LICENSE", "pkg/LICENSE"); + await copyFile("README.md", "pkg/README.md"); + + // Handle the package.json + let pkg = JSON.parse((await readFile("package.json", "utf8")).toString()); + // Remove unnecessary fields from the package.json + delete pkg.scripts; + delete pkg.prettier; + delete pkg.release; + delete pkg.jest; + await writeFile( + "pkg/package.json", + JSON.stringify( + { + ...pkg, + files: ["dist-*/**", "bin/**"], + types: "./dist-types/index.d.ts", + exports: { + ".": { + types: "./dist-types/index.d.ts", + import: "./dist-bundle/index.js", + default: "./dist-bundle/index.js", + }, + }, + sideEffects: false, + }, + null, + 2, + ), + ); +} +main(); diff --git a/seed.yml b/seed.yml deleted file mode 100644 index 80315da0f8..0000000000 --- a/seed.yml +++ /dev/null @@ -1,5 +0,0 @@ ---- - name: node-github - description: NodeJS wrapper for the GitHub API - tags: git github web - version: 0.2.4 diff --git a/src/app.ts b/src/app.ts new file mode 100644 index 0000000000..fc5998f448 --- /dev/null +++ b/src/app.ts @@ -0,0 +1,12 @@ +import { App as DefaultApp } from "@octokit/app"; +import { OAuthApp as DefaultOAuthApp } from "@octokit/oauth-app"; + +import { Octokit } from "./octokit.js"; + +export const App = DefaultApp.defaults({ Octokit }); +export type App = InstanceType; + +export const OAuthApp = DefaultOAuthApp.defaults({ Octokit }); +export type OAuthApp = InstanceType; + +export { createNodeMiddleware } from "@octokit/app"; diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000000..2c566b5ba7 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,3 @@ +export { Octokit, RequestError } from "./octokit.js"; +export type { PageInfoForward, PageInfoBackward } from "./octokit.js"; +export { App, OAuthApp, createNodeMiddleware } from "./app.js"; diff --git a/src/octokit.ts b/src/octokit.ts new file mode 100644 index 0000000000..9fcdbecfb3 --- /dev/null +++ b/src/octokit.ts @@ -0,0 +1,64 @@ +import { Octokit as OctokitCore } from "@octokit/core"; +import { paginateRest } from "@octokit/plugin-paginate-rest"; +import { paginateGraphQL } from "@octokit/plugin-paginate-graphql"; +import { restEndpointMethods } from "@octokit/plugin-rest-endpoint-methods"; +import { retry } from "@octokit/plugin-retry"; +import { throttling } from "@octokit/plugin-throttling"; + +import { VERSION } from "./version.js"; +import type { EndpointDefaults } from "@octokit/types"; + +export { RequestError } from "@octokit/request-error"; +export type { + PageInfoForward, + PageInfoBackward, +} from "@octokit/plugin-paginate-graphql"; + +export const Octokit = OctokitCore.plugin( + restEndpointMethods, + paginateRest, + paginateGraphQL, + retry, + throttling, +).defaults({ + userAgent: `octokit.js/${VERSION}`, + throttle: { + onRateLimit, + onSecondaryRateLimit, + }, +}); + +export type Octokit = InstanceType; + +/* v8 ignore start no need to test internals of the throttle plugin */ +function onRateLimit( + retryAfter: number, + options: Required, + octokit: InstanceType, +) { + octokit.log.warn( + `Request quota exhausted for request ${options.method} ${options.url}`, + ); + + if (options.request.retryCount === 0) { + // only retries once + octokit.log.info(`Retrying after ${retryAfter} seconds!`); + return true; + } +} + +function onSecondaryRateLimit( + retryAfter: number, + options: Required, + octokit: InstanceType, +) { + octokit.log.warn( + `SecondaryRateLimit detected for request ${options.method} ${options.url}`, + ); + + if (options.request.retryCount === 0) { + // only retries once + octokit.log.info(`Retrying after ${retryAfter} seconds!`); + return true; + } +} diff --git a/src/version.ts b/src/version.ts new file mode 100644 index 0000000000..86383b116d --- /dev/null +++ b/src/version.ts @@ -0,0 +1 @@ +export const VERSION = "0.0.0-development"; diff --git a/templates/after_request.js.tpl b/templates/after_request.js.tpl deleted file mode 100644 index 0e8277ccc2..0000000000 --- a/templates/after_request.js.tpl +++ /dev/null @@ -1,11 +0,0 @@ - - if (!ret) - ret = {}; - if (typeof ret == "object") { - if (!ret.meta) - ret.meta = {}; - [<%headers%>].forEach(function(header) { - if (res.headers[header]) - ret.meta[header] = res.headers[header]; - }); - } diff --git a/templates/handler.js.tpl b/templates/handler.js.tpl deleted file mode 100644 index b76033e69d..0000000000 --- a/templates/handler.js.tpl +++ /dev/null @@ -1,24 +0,0 @@ -<%comment%> - this.<%funcName%> = function(msg, block, callback) { - var self = this; - this.client.httpSend(msg, block, function(err, res) { - if (err) - return self.sendError(err, null, msg, callback); - - var ret; - try { - ret = res.data; - var contentType = res.headers["content-type"]; - if (contentType && contentType.indexOf("application/json") !== -1) - ret = JSON.parse(ret); - } - catch (ex) { - if (callback) - callback(new error.InternalServerError(ex.message), res); - return; - } -<%afterRequest%> - if (callback) - callback(null, ret); - }); - }; diff --git a/templates/index.js.tpl b/templates/index.js.tpl deleted file mode 100644 index b5a585ff41..0000000000 --- a/templates/index.js.tpl +++ /dev/null @@ -1,40 +0,0 @@ -/** - * class <%name%> - * - * <%description%> - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var Fs = require("fs"); -var Util = require("./../../util"); -var error = require("./../../error"); - -var GithubHandler = module.exports = function(client) { - this.client = client; - this.routes = JSON.parse(Fs.readFileSync(__dirname + "/routes.json", "utf8")); -}; - -var proto = { - sendError: function(err, block, msg, callback) { - if (this.client.debug) - Util.log(err, block, msg.user, "error"); - if (typeof err == "string") - err = new error.InternalServerError(err); - if (callback) - callback(err); - } -}; - -[<%scripts%>].forEach(function(api) { - Util.extend(proto, require("./" + api)); -}); - -GithubHandler.prototype = proto; diff --git a/templates/section.js.tpl b/templates/section.js.tpl deleted file mode 100644 index 82a7c5ea58..0000000000 --- a/templates/section.js.tpl +++ /dev/null @@ -1,23 +0,0 @@ -/** - * mixin <%sectionName%> - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var error = require("./../../error"); -var Util = require("./../../util"); - -var <%sectionName%> = module.exports = { - <%sectionName%>: {} -}; - -(function() { -<%sectionBody%> -}).call(<%sectionName%>.<%sectionName%>); diff --git a/templates/test_handler.js.tpl b/templates/test_handler.js.tpl deleted file mode 100644 index f6287660a9..0000000000 --- a/templates/test_handler.js.tpl +++ /dev/null @@ -1,10 +0,0 @@ - it("should successfully execute <%name%>", function(next) { - client.<%funcName%>( - <%params%>, - function(err, res) { - Assert.equal(err, null); - // other assertions go here - next(); - } - ); - }); \ No newline at end of file diff --git a/templates/test_section.js.tpl b/templates/test_section.js.tpl deleted file mode 100644 index bde8fbfec0..0000000000 --- a/templates/test_section.js.tpl +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../../index"); - -describe("[<%sectionName%>]", function() { - var client; - var token = "c286e38330e15246a640c2cf32a45ea45d93b2ba"; - - beforeEach(function() { - client = new Client({ - version: "<%version%>" - }); - client.authenticate({ - type: "oauth", - token: token - }); - }); - -<%testBody%> -}); diff --git a/test/app.test.ts b/test/app.test.ts new file mode 100644 index 0000000000..2eb92f2388 --- /dev/null +++ b/test/app.test.ts @@ -0,0 +1,251 @@ +import { beforeEach, describe, expect, test } from "vitest"; +import { createServer } from "node:http"; + +import fetchMock from "fetch-mock"; +import MockDate from "mockdate"; + +import { App, Octokit, createNodeMiddleware } from "../src/index.ts"; + +const APP_ID = 1; +const PRIVATE_KEY = `-----BEGIN RSA PRIVATE KEY----- +MIIEpAIBAAKCAQEA1c7+9z5Pad7OejecsQ0bu3aozN3tihPmljnnudb9G3HECdnH +lWu2/a1gB9JW5TBQ+AVpum9Okx7KfqkfBKL9mcHgSL0yWMdjMfNOqNtrQqKlN4kE +p6RD++7sGbzbfZ9arwrlD/HSDAWGdGGJTSOBM6pHehyLmSC3DJoR/CTu0vTGTWXQ +rO64Z8tyXQPtVPb/YXrcUhbBp8i72b9Xky0fD6PkEebOy0Ip58XVAn2UPNlNOSPS +ye+Qjtius0Md4Nie4+X8kwVI2Qjk3dSm0sw/720KJkdVDmrayeljtKBx6AtNQsSX +gzQbeMmiqFFkwrG1+zx6E7H7jqIQ9B6bvWKXGwIDAQABAoIBAD8kBBPL6PPhAqUB +K1r1/gycfDkUCQRP4DbZHt+458JlFHm8QL6VstKzkrp8mYDRhffY0WJnYJL98tr4 +4tohsDbqFGwmw2mIaHjl24LuWXyyP4xpAGDpl9IcusjXBxLQLp2m4AKXbWpzb0OL +Ulrfc1ZooPck2uz7xlMIZOtLlOPjLz2DuejVe24JcwwHzrQWKOfA11R/9e50DVse +hnSH/w46Q763y4I0E3BIoUMsolEKzh2ydAAyzkgabGQBUuamZotNfvJoDXeCi1LD +8yNCWyTlYpJZJDDXooBU5EAsCvhN1sSRoaXWrlMSDB7r/E+aQyKua4KONqvmoJuC +21vSKeECgYEA7yW6wBkVoNhgXnk8XSZv3W+Q0xtdVpidJeNGBWnczlZrummt4xw3 +xs6zV+rGUDy59yDkKwBKjMMa42Mni7T9Fx8+EKUuhVK3PVQyajoyQqFwT1GORJNz +c/eYQ6VYOCSC8OyZmsBM2p+0D4FF2/abwSPMmy0NgyFLCUFVc3OECpkCgYEA5OAm +I3wt5s+clg18qS7BKR2DuOFWrzNVcHYXhjx8vOSWV033Oy3yvdUBAhu9A1LUqpwy +Ma+unIgxmvmUMQEdyHQMcgBsVs10dR/g2xGjMLcwj6kn+xr3JVIZnbRT50YuPhf+ +ns1ScdhP6upo9I0/sRsIuN96Gb65JJx94gQ4k9MCgYBO5V6gA2aMQvZAFLUicgzT +u/vGea+oYv7tQfaW0J8E/6PYwwaX93Y7Q3QNXCoCzJX5fsNnoFf36mIThGHGiHY6 +y5bZPPWFDI3hUMa1Hu/35XS85kYOP6sGJjf4kTLyirEcNKJUWH7CXY+00cwvTkOC +S4Iz64Aas8AilIhRZ1m3eQKBgQCUW1s9azQRxgeZGFrzC3R340LL530aCeta/6FW +CQVOJ9nv84DLYohTVqvVowdNDTb+9Epw/JDxtDJ7Y0YU0cVtdxPOHcocJgdUGHrX +ZcJjRIt8w8g/s4X6MhKasBYm9s3owALzCuJjGzUKcDHiO2DKu1xXAb0SzRcTzUCn +7daCswKBgQDOYPZ2JGmhibqKjjLFm0qzpcQ6RPvPK1/7g0NInmjPMebP0K6eSPx0 +9/49J6WTD++EajN7FhktUSYxukdWaCocAQJTDNYP0K88G4rtC2IYy5JFn9SWz5oh +x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w== +-----END RSA PRIVATE KEY-----`; +const CLIENT_ID = "lv1.1234567890abcdef"; +const CLIENT_SECRET = "1234567890abcdef1234567890abcdef12345678"; +const WEBHOOK_SECRET = "secret"; +// see https://runkit.com/gr2m/reproducable-jwt +const BEARER = + "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOi0zMCwiZXhwIjo1NzAsImlzcyI6MX0.q3foRa78U3WegM5PrWLEh5N0bH1SD62OqW66ZYzArp95JBNiCbo8KAlGtiRENCIfBZT9ibDUWy82cI4g3F09mdTq3bD1xLavIfmTksIQCz5EymTWR5v6gL14LSmQdWY9lSqkgUG0XCFljWUglEP39H4yeHbFgdjvAYg3ifDS12z9oQz2ACdSpvxPiTuCC804HkPVw8Qoy0OSXvCkFU70l7VXCVUxnuhHnk8-oCGcKUspmeP6UdDnXk-Aus-eGwDfJbU2WritxxaXw6B4a3flTPojkYLSkPBr6Pi0H2-mBsW_Nvs0aLPVLKobQd4gqTkosX3967DoAG8luUMhrnxe8Q"; + +describe("App", () => { + let app: InstanceType; + let mock: typeof fetchMock; + + beforeEach(() => { + MockDate.set(0); + mock = fetchMock.sandbox(); + + app = new App({ + appId: APP_ID, + privateKey: PRIVATE_KEY, + oauth: { + clientId: CLIENT_ID, + clientSecret: CLIENT_SECRET, + }, + webhooks: { + secret: WEBHOOK_SECRET, + }, + Octokit: Octokit.defaults({ + request: { + fetch: mock, + }, + throttle: { enabled: false }, + }), + }); + }); + + test("Readme example: `app.eachRepository.iterator`", async () => { + mock + .getOnce( + "path:/app/installations", + [ + { + id: "123", + }, + ], + { + headers: { + authorization: `bearer ${BEARER}`, + }, + }, + ) + .postOnce( + "path:/app/installations/123/access_tokens", + { + token: "secret123", + expires_at: "1970-01-01T01:00:00.000Z", + permissions: { + metadata: "read", + }, + repository_selection: "all", + }, + { + headers: { + authorization: `bearer ${BEARER}`, + }, + }, + ) + .getOnce("path:/installation/repositories", { + total_count: 1, + repositories: [ + { + owner: { + login: "octokit", + }, + name: "octokit.js", + full_name: "octokit/octokit.js", + }, + ], + }) + .postOnce("path:/repos/octokit/octokit.js/dispatches", 204, { + body: { event_type: "my_event", client_payload: { foo: "bar" } }, + }); + + for await (const { octokit, repository } of app.eachRepository.iterator()) { + // https://docs.github.com/en/rest/reference/repos#create-a-repository-dispatch-event + await octokit.request("POST /repos/{owner}/{repo}/dispatches", { + owner: repository.owner.login, + repo: repository.name, + event_type: "my_event", + client_payload: { + foo: "bar", + }, + }); + + expect(repository.full_name).toEqual("octokit/octokit.js"); + } + + expect(mock.done()).toBe(true); + }); + + test("README example: app.getInstallationOctokit", async () => { + mock + .postOnce( + "path:/app/installations/123/access_tokens", + { + token: "secret123", + expires_at: "1970-01-01T01:00:00.000Z", + permissions: { + metadata: "read", + }, + repository_selection: "all", + }, + { + headers: { + authorization: `bearer ${BEARER}`, + }, + }, + ) + .postOnce( + "path:/repos/octokit/octokit.js/issues", + { id: 1 }, + { + body: { + title: "Hello, world!", + }, + }, + ); + const octokit = await app.getInstallationOctokit(123); + + // https://docs.github.com/en/rest/reference/issues#create-an-issue + await octokit.request("POST /repos/{owner}/{repo}/issues", { + owner: "octokit", + repo: "octokit.js", + title: "Hello, world!", + }); + + expect(mock.done()).toBe(true); + }); + + test("README example: createNodeMiddleware(app)", async () => { + expect.assertions(3); + + mock + .postOnce( + "path:/app/installations/123/access_tokens", + { + token: "secret123", + expires_at: "1970-01-01T01:00:00.000Z", + permissions: { + metadata: "read", + }, + repository_selection: "all", + }, + { + headers: { + authorization: `bearer ${BEARER}`, + }, + }, + ) + .postOnce( + "path:/repos/octokit/octokit.js/issues/1/comments", + { body: 1 }, + { + body: { + body: "Hello, World!", + }, + }, + ); + + app.webhooks.on("issues.opened", async ({ octokit, payload }) => { + await octokit.rest.issues.createComment({ + owner: payload.repository.owner.login, + repo: payload.repository.name, + issue_number: payload.issue.number, + body: "Hello, World!", + }); + + expect(mock.done()).toBe(true); + }); + + // Your app can now receive webhook events at `/api/github/webhooks` + const server = createServer(createNodeMiddleware(app)).listen(); + + // @ts-expect-error - port is typed as undefined + const port = server.address().port; + const issuePayload = JSON.stringify({ + repository: { + owner: { + login: "octokit", + }, + name: "octokit.js", + }, + action: "opened", + installation: { id: 123 }, + issue: { number: 1 }, + }); + + const response = await fetch( + `http://localhost:${port}/api/github/webhooks`, + { + method: "POST", + headers: { + "content-type": "application/json", + "x-github-event": "issues", + "x-github-delivery": "1", + "x-hub-signature-256": await app.webhooks.sign(issuePayload), + }, + body: issuePayload, + }, + ); + + expect(await response.text()).toEqual("ok\n"); + expect(response.status).toEqual(200); + + server.close(); + }); +}); diff --git a/test/client_test.js b/test/client_test.js deleted file mode 100644 index 85305895ba..0000000000 --- a/test/client_test.js +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - */ - -"use strict"; - -var Assert = require("assert"); -var Client = require("./../index"); - -describe("[client]", function() { - var client; - var token = "e5a4a27487c26e571892846366de023349321a73"; - - beforeEach(function() { - client = new Client({ - version: "3.0.0" - }); - /*client.authenticate({ - type: "oauth", - token: token - });*/ - }); - - it("should successfully execute GET /authorizations (getAll)", function(next) { - // `aseemk` has two pages of followers right now. - client.user.getFollowers( - { - user: "aseemk" - }, - function(err, res) { - Assert.equal(err, null); - - Assert.ok(!!client.hasNextPage(res)); - Assert.ok(!!client.hasLastPage(res)); - Assert.ok(!client.hasPreviousPage(res)); - - client.getNextPage(res, function(err, res) { - Assert.equal(err, null); - - Assert.ok(!!client.hasPreviousPage(res)); - Assert.ok(!!client.hasFirstPage(res)); - Assert.ok(!client.hasNextPage(res)); - Assert.ok(!client.hasLastPage(res)); - - client.getPreviousPage(res.meta.link, function(err, res) { - Assert.equal(err, null); - - Assert.ok(!!client.hasNextPage(res)); - Assert.ok(!!client.hasLastPage(res)); - Assert.ok(!client.hasPreviousPage(res)); - next(); - }); - }); - } - ); - }); -}); diff --git a/test/example.js b/test/example.js deleted file mode 100644 index 4c28886244..0000000000 --- a/test/example.js +++ /dev/null @@ -1,37 +0,0 @@ -/** section: github, internal - * Example - * - * Github API usage example. - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -"use strict"; - -var Client = require("./../index"); - -var github = new Client({ - debug: true, - version: "3.0.0" -}); - -github.authenticate({ - type: "basic", - username: "mikedeboer", - password: "mysecretpass" -}); - -github.user.get({}, function(err, res) { - console.log("GOT ERR?", err); - console.log("GOT RES?", res); - - github.repos.getAll({}, function(err, res) { - console.log("GOT ERR?", err); - console.log("GOT RES?", res); - }); -}); diff --git a/test/oauth.js b/test/oauth.js deleted file mode 100644 index 3fbeadd663..0000000000 --- a/test/oauth.js +++ /dev/null @@ -1,95 +0,0 @@ -/** section: github, internal - * OAuth - * - * OAuth usage example. - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -var http = require("http"); -var Url = require("url"); -var querystring = require("querystring"); - -var Client = require("../index"); -var OAuth2 = require("oauth").OAuth2; - -var github = new Client({ - version: "3.0.0" -}); - -var clientId = "e8c434a1c92e9de7ff8d"; -var secret = "1d0fcbb060e1dd86a0aa3d12265419c9bb19a333"; -var oauth = new OAuth2(clientId, secret, "https://github.com/", "login/oauth/authorize", "login/oauth/access_token"); - -// for demo purposes use one global access token -// in production this has to be stored in a user session -var accessToken = ""; - -http.createServer(function(req, res) { - var url = Url.parse(req.url); - var path = url.pathname; - var query = querystring.parse(url.query); - - if (path == "/" || path.match(/^\/user\/?$/)) { - // redirect to github if there is no access token - if (!accessToken) { - res.writeHead(303, { - Location: oauth.getAuthorizeUrl({ - redirect_uri: 'http://localhost:7878/github-callback', - scope: "user,repo,gist" - }) - }); - res.end(); - return; - } - - // use github API - github.user.get({}, function(err, user) { - if (err) { - res.writeHead(err.code); - res.end(err + ""); - return; - } - res.writeHead(200); - res.end(JSON.stringify(user)); - }); - return; - } - // URL called by github after authenticating - else if (path.match(/^\/github-callback\/?$/)) { - // upgrade the code to an access token - oauth.getOAuthAccessToken(query.code, {}, function (err, access_token, refresh_token) { - if (err) { - console.log(err); - res.writeHead(500); - res.end(err + ""); - return; - } - - accessToken = access_token; - - // authenticate github API - github.authenticate({ - type: "oauth", - token: accessToken - }); - - //redirect back - res.writeHead(303, { - Location: "/" - }); - res.end(); - }); - return; - } - - res.writeHead(404); - res.end("404 - Not found"); -}).listen(7878); - -console.log("listening at http://localhost:7878"); diff --git a/test/oauth_server.js b/test/oauth_server.js deleted file mode 100644 index 1a2e7cf73b..0000000000 --- a/test/oauth_server.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; - -var GitHubApi = require("./../index"); - -var github = new GitHubApi({ - version: "3.0.0" -}); - -/* -!!!UNCOMMENT THE FOLLOWING TO MAKE THIS SCRIPT WORK, BUT CHANGE THE CREDENTIALS TO YOUR OWN!!! -github.authenticate({ - type: "basic", - username: "mikedeboertest", - password: "test1324" -}); -*/ - -github.authorization.getAll({}, function(err, res) { - if (err) - throw err; - - var ids = res.map(function(app) { return app.id; }); - - function next(id) { - github.authorization["delete"]({ - id: id - }, function(err, res) { - if (err) - throw err; - if (ids.length) - next(ids.shift()); - else - allRemoved(); - }); - } - - next(ids.shift()); - - function allRemoved() { - github.authorization.create({ - scopes: ["user", "public_repo", "repo", "repo:status", "delete_repo", "gist"], - note: "Authorization created to create unit tests", - note_url: "https://github.com/ajaxorg/node-github" - }, function(err, res) { - if (err) - throw err; - - // you can use the token within server-side apps. - // use it by doing: - // github.authenticate({ - // type: "oauth", - // token: e5a4a27487c26e571892846366de023349321a73 - // }); - console.log("TOKEN:", res.token); - console.log(res); - }); - } - -}); \ No newline at end of file diff --git a/test/smoke.test.ts b/test/smoke.test.ts new file mode 100644 index 0000000000..2cb104f7de --- /dev/null +++ b/test/smoke.test.ts @@ -0,0 +1,69 @@ +import { describe, expect, it } from "vitest"; +import { Octokit, App, OAuthApp, RequestError } from "../src/index.ts"; + +describe("Smoke tests", () => { + it("Octokit is a function", () => { + expect(Octokit).toBeInstanceOf(Function); + expect(() => new Octokit()).not.toThrow(); + }); + + it("Octokit can be used as a type", () => { + let octokit: Octokit; + octokit = new Octokit(); + expect(octokit.rest.repos.get).toBeInstanceOf(Function); + }); + + it("App is a function", () => { + expect(App).toBeInstanceOf(Function); + expect( + () => + new App({ + appId: 123, + privateKey: "private key here", + }), + ).not.toThrow(); + }); + + it("App can be used as a type", () => { + let app: App; + app = new App({ + appId: 123, + privateKey: "private key here", + }); + + expect(app.octokit.request).toBeInstanceOf(Function); + }); + + it("OAuthApp is a function", () => { + expect(OAuthApp).toBeInstanceOf(Function); + expect( + () => + new OAuthApp({ + clientId: "", + clientSecret: "", + }), + ).not.toThrow(); + }); + + it("OAuthApp can be used as a type", () => { + let app: OAuthApp; + app = new OAuthApp({ + clientId: "", + clientSecret: "", + }); + + expect(app.octokit.request).toBeInstanceOf(Function); + }); + + it("RequestError inherits from Error", () => { + const error = new RequestError("test", 123, { + request: { + method: "GET", + url: "https://api.github.com/", + headers: {}, + }, + }); + + expect(error).toBeInstanceOf(RequestError); + }); +}); diff --git a/test/tsconfig.test.json b/test/tsconfig.test.json new file mode 100644 index 0000000000..5e8dc24879 --- /dev/null +++ b/test/tsconfig.test.json @@ -0,0 +1,10 @@ +{ + "extends": "../tsconfig.json", + "compilerOptions": { + "emitDeclarationOnly": false, + "noEmit": true, + "verbatimModuleSyntax": false, + "allowImportingTsExtensions": true + }, + "include": ["src/**/*"] +} diff --git a/test/typescript-validate.ts b/test/typescript-validate.ts new file mode 100644 index 0000000000..acd0540edf --- /dev/null +++ b/test/typescript-validate.ts @@ -0,0 +1,43 @@ +// ************************************************************ +// THIS CODE IS NOT EXECUTED. IT IS JUST FOR TYPECHECKING +// ************************************************************ + +import { App, OAuthApp, Octokit, RequestError } from "../src/index.ts"; + +function expect(what: T) {} + +export async function OctokitTest() { + const app = new App({ + appId: 1, + privateKey: "", + }); + + expect(app.octokit); + + const oauthApp = new OAuthApp({ + clientId: "", + clientSecret: "", + }); + + expect(oauthApp.octokit); + + const installationOctokit = await app.getInstallationOctokit(1); + const issues = await installationOctokit.paginate( + installationOctokit.rest.issues.listForRepo, + { + owner: "", + repo: "", + }, + ); + expect(issues[0].id); + + const error = new RequestError("test", 123, { + request: { + method: "GET", + url: "https://api.github.com/", + headers: {}, + }, + }); + + expect(error); +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000000..afade4c1bc --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "@octokit/tsconfig", + "include": ["src/**/*"], + "compilerOptions": { + "esModuleInterop": true, + "declaration": true, + "outDir": "pkg/dist-types", + "emitDeclarationOnly": true, + "sourceMap": true + } +} diff --git a/util.js b/util.js deleted file mode 100644 index 7d536d6a1a..0000000000 --- a/util.js +++ /dev/null @@ -1,140 +0,0 @@ -/** section: github - * class Util - * - * Copyright 2012 Cloud9 IDE, Inc. - * - * This product includes software developed by - * Cloud9 IDE, Inc (http://c9.io). - * - * Author: Mike de Boer - **/ - -var Util = require("util"); - -/** - * Util#extend(dest, src, noOverwrite) -> Object - * - dest (Object): destination object - * - src (Object): source object - * - noOverwrite (Boolean): set to `true` to overwrite values in `src` - * - * Shallow copy of properties from the `src` object to the `dest` object. If the - * `noOverwrite` argument is set to to `true`, the value of a property in `src` - * will not be overwritten if it already exists. - **/ -exports.extend = function(dest, src, noOverwrite) { - for (var prop in src) { - if (!noOverwrite || typeof dest[prop] == "undefined") - dest[prop] = src[prop]; - } - return dest; -}; - -/** - * Util#escapeRegExp(str) -> String - * - str (String): string to escape - * - * Escapes characters inside a string that will an error when it is used as part - * of a regex upon instantiation like in `new RegExp("[0-9" + str + "]")` - **/ -exports.escapeRegExp = function(str) { - return str.replace(/([.*+?^${}()|[\]\/\\])/g, '\\$1'); -}; - -/** - * Util#toCamelCase(str, [upper]) -> String - * - str (String): string to transform - * - upper (Boolean): set to `true` to transform to CamelCase - * - * Transform a string that contains spaces or dashes to camelCase. If `upper` is - * set to `true`, the string will be transformed to CamelCase. - * - * Example: - * - * Util.toCamelCase("why U no-work"); // returns 'whyUNoWork' - * Util.toCamelCase("I U no-work", true); // returns 'WhyUNoWork' - **/ -exports.toCamelCase = function(str, upper) { - str = str.toLowerCase().replace(/(?:(^.)|(\s+.)|(-.))/g, function(match) { - return match.charAt(match.length - 1).toUpperCase(); - }); - if (upper) - return str; - return str.charAt(0).toLowerCase() + str.substr(1); -}; - -/** - * Util#isTrue(c) -> Boolean - * - c (mixed): value the variable to check. Possible values: - * true The function returns true. - * 'true' The function returns true. - * 'on' The function returns true. - * 1 The function returns true. - * '1' The function returns true. - * - * Determines whether a string is true in the html attribute sense. - **/ -exports.isTrue = function(c){ - return (c === true || c === "true" || c === "on" || typeof c == "number" && c > 0 || c === "1"); -}; - -/** - * Util#isFalse(c) -> Boolean - * - c (mixed): value the variable to check. Possible values: - * false The function returns true. - * 'false' The function returns true. - * 'off' The function returns true. - * 0 The function returns true. - * '0' The function returns true. - * - * Determines whether a string is false in the html attribute sense. - **/ -exports.isFalse = function(c){ - return (c === false || c === "false" || c === "off" || c === 0 || c === "0"); -}; - -var levels = { - "info": ["\033[90m", "\033[39m"], // grey - "error": ["\033[31m", "\033[39m"], // red - "fatal": ["\033[35m", "\033[39m"], // magenta - "exit": ["\033[36m", "\033[39m"] // cyan -}; -var _slice = Array.prototype.slice; - -/** - * Util#log(arg1, [arg2], [type]) -> null - * - arg1 (mixed): messages to be printed to the standard output - * - type (String): type denotation of the message. Possible values: - * 'info', 'error', 'fatal', 'exit'. Optional, defaults to 'info'. - * - * Unified logging to the console; arguments passed to this function will put logged - * to the standard output of the current process and properly formatted. - * Any non-String object will be inspected by the NodeJS util#inspect utility - * function. - * Messages will be prefixed with its type (with corresponding font color), like so: - * - * [info] informational message - * [error] error message - * [fatal] fatal error message - * [exit] program exit message (not an error) - * - * The type of message can be defined by passing it to this function as the last/ - * final argument. If the type can not be found, this last/ final argument will be - * regarded as yet another message. - **/ -exports.log = function() { - var args = _slice.call(arguments); - var lastArg = args[args.length - 1]; - - var level = levels[lastArg] ? args.pop() : "info"; - if (!args.length) - return; - - var msg = args.map(function(arg) { - return typeof arg != "string" ? Util.inspect(arg) : arg; - }).join(" "); - var pfx = levels[level][0] + "[" + level + "]" + levels[level][1]; - - msg.split("\n").forEach(function(line) { - console.log(pfx + " " + line); - }); -}; diff --git a/vite.config.js b/vite.config.js new file mode 100644 index 0000000000..516c9dfe3c --- /dev/null +++ b/vite.config.js @@ -0,0 +1,13 @@ +import { defineConfig } from "vite"; + +export default defineConfig({ + test: { + coverage: { + include: ["src/**/*.ts"], + reporter: ["html"], + thresholds: { + 100: true, + }, + }, + }, +});