diff --git a/.github/ISSUE_TEMPLATE/bug.yml b/.github/ISSUE_TEMPLATE/bug.yml deleted file mode 100644 index ccb5214668..0000000000 --- a/.github/ISSUE_TEMPLATE/bug.yml +++ /dev/null @@ -1,41 +0,0 @@ -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 deleted file mode 100644 index 64c1fc0754..0000000000 --- a/.github/ISSUE_TEMPLATE/documentation.yml +++ /dev/null @@ -1,49 +0,0 @@ -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 deleted file mode 100644 index 453cdfda4e..0000000000 --- a/.github/ISSUE_TEMPLATE/feature.yml +++ /dev/null @@ -1,49 +0,0 @@ -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 deleted file mode 100644 index 0c5221e2c1..0000000000 --- a/.github/ISSUE_TEMPLATE/maintenance.yml +++ /dev/null @@ -1,49 +0,0 @@ -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 deleted file mode 100644 index 0aa1f03b63..0000000000 --- a/.github/pull_request_template.md +++ /dev/null @@ -1,30 +0,0 @@ - - -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 deleted file mode 100644 index dd7a80645d..0000000000 --- a/.github/renovate.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "extends": [ - "github>octokit/.github" - ] -} diff --git a/.github/workflows/add_to_octokit_project.yml b/.github/workflows/add_to_octokit_project.yml deleted file mode 100644 index 8621996e47..0000000000 --- a/.github/workflows/add_to_octokit_project.yml +++ /dev/null @@ -1,20 +0,0 @@ -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 deleted file mode 100644 index 394f8bf58f..0000000000 --- a/.github/workflows/codeql.yml +++ /dev/null @@ -1,41 +0,0 @@ -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@v6 - - - name: Initialize CodeQL - uses: github/codeql-action/init@v4 - with: - languages: ${{ matrix.language }} - - - name: Autobuild - uses: github/codeql-action/autobuild@v4 - - - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v4 - with: - category: "/language:${{matrix.language}}" diff --git a/.github/workflows/immediate-response.yml b/.github/workflows/immediate-response.yml deleted file mode 100644 index 601b2b6747..0000000000 --- a/.github/workflows/immediate-response.yml +++ /dev/null @@ -1,29 +0,0 @@ -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@v5 - 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 deleted file mode 100644 index 4a3f40226d..0000000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,32 +0,0 @@ -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@v6 - - uses: actions/setup-node@v6 - 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 deleted file mode 100644 index 8ea0ed16bc..0000000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,43 +0,0 @@ -name: Test -"on": - push: - branches: - - main - pull_request: - types: - - opened - - synchronize -jobs: - test_matrix: - runs-on: ubuntu-latest - strategy: - matrix: - node_version: - - 20 - - 22 - - 24 - steps: - - uses: actions/checkout@v6 - - name: Use Node.js ${{ matrix.node_version }} - uses: actions/setup-node@v6 - 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@v6 - - uses: actions/setup-node@v6 - 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 deleted file mode 100644 index 0c4dafa69b..0000000000 --- a/.github/workflows/update-prettier.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Update Prettier -"on": - push: - branches: - - renovate/prettier-* - workflow_dispatch: {} -jobs: - update_prettier: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v6 - - uses: actions/setup-node@v6 - with: - cache: npm - node-version: lts/* - - 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 59ef6c06c5..7f913291a6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,7 @@ -coverage/ -node_modules/ -pkg/ -.idea/ +.DS_Store +0.0.1.seed +node_modules +.settings.xml +.settings +.c9revisions +/nbproject/private/ \ No newline at end of file diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000000..988771c171 --- /dev/null +++ b/.npmignore @@ -0,0 +1,5 @@ +.settings.xml +.settings +.c9revisions +doc/ +node_modules/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md deleted file mode 100644 index 42366f02cb..0000000000 --- a/CODE_OF_CONDUCT.md +++ /dev/null @@ -1,74 +0,0 @@ -# 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 deleted file mode 100644 index 13417cbd9d..0000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,56 +0,0 @@ -# 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 e0b76da6b9..277d0573da 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License -Copyright (c) 2023 Octokit contributors +Copyright (c) 2012 Cloud9 IDE, Inc. (Mike de Boer) 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 deleted file mode 100644 index 75c7971e18..0000000000 --- a/MAINTAINING.md +++ /dev/null @@ -1,110 +0,0 @@ -# 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 bdd5020e1c..7535f3676c 100644 --- a/README.md +++ b/README.md @@ -1,977 +1,170 @@ -# 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 - -``` - -
-Deno - -Load octokit directly from esm.sh - -```ts -import { Octokit, App } from "https://esm.sh/octokit?dts"; -``` - -
-Node - - -Install with npm/pnpm install octokit, or yarn add octokit - -```js -import { Octokit, App } from "octokit"; -``` - -
- -> [!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) - -## `Octokit` API Client - -**standalone minimal Octokit**: [`@octokit/core`](https://github.com/octokit/core.js/#readme). - -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). - -**Example**: Get the username for the authenticated user. - -```js -// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo -const octokit = new Octokit({ auth: `personal-access-token123` }); - -// 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); -``` - -### 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. +# JavaScript GitHub API for Node.JS -For example, to implement the above using `App` +A Node.JS module, which provides an object oriented wrapper for the GitHub v3 API. -```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, -}); -``` +## Installation -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). + Install with the Node.JS package manager [npm](http://npmjs.org/) ![NPM version](https://badge.fury.io/js/github.png): -### Proxy Servers (Node.js only) + $ npm install github -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). +or -For example, this would use a `ProxyAgent` to make requests through a proxy server: + Install via git clone: -```js -import { fetch as undiciFetch, ProxyAgent } from 'undici'; + $ git clone git://github.com/mikedeboer/node-github.git + $ cd node-github + $ npm install -const myFetch = (url, options) => { - return undiciFetch(url, { - ...options, - dispatcher: new ProxyAgent() - }) -} +## Documentation -const octokit = new Octokit({ - request: { - fetch: myFetch - }, -}); -``` +You can find the docs for the API of this client at [http://mikedeboer.github.com/node-github/](http://mikedeboer.github.com/node-github/) -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: +Additionally, the [official Github documentation](http://developer.github.com/) +is a very useful resource. -```js -import { fetch as undiciFetch, ProxyAgent } from 'undici'; +## Example -const myFetch = (url, options) => { - return undiciFetch(url, { - ...options, - dispatcher: new ProxyAgent() - }) -} +Print all followers of the user "mikedeboer" to the console. +```javascript +var GitHubApi = require("github"); -octokit.rest.repos.get({ - owner, - repo, - request: { - fetch: myFetch - }, +var github = new GitHubApi({ + // required + version: "3.0.0", + // optional + debug: true, + protocol: "https", + host: "github.my-GHE-enabled-company.com", + pathPrefix: "/api/v3", // for some GHEs + timeout: 5000 }); -``` - -#### 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, - }, +github.user.getFollowingFromUser({ + // optional: + // headers: { + // "cookie": "blahblah" + // }, + user: "mikedeboer" +}, function(err, res) { + console.log(JSON.stringify(res)); }); ``` -### REST API +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. -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. +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. -For example +## Authentication -```js -await octokit.rest.issues.create({ - owner: "octocat", - repo: "hello-world", - title: "Hello, world!", - body: "I created this issue using Octokit!", -}); -``` +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. -Is the same as +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. -```js -await octokit.request("POST /repos/{owner}/{repo}/issues", { - owner: "octocat", - repo: "hello-world", - title: "Hello, world!", - body: "I created this issue using Octokit!", +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 }); -``` - -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!", +github.user.update({ + location: "Argentina" +}, function(err) { + console.log("done!"); }); ``` +Note that the _authenticate_ method is synchronous because it only stores the +credentials for the next request. -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 - -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. - -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); - } -} -``` - -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, +Other examples for the various authentication methods: +```javascript +// OAuth2 +github.authenticate({ + type: "oauth", + token: token }); -``` - -#### Media Type formats - -Media type formats can be set using `mediaType: { format }` on every request. -Example: retrieve the raw content of a `package.json` file +// OAuth2 Key/Secret +github.authenticate({ + type: "oauth", + key: "clientID", + secret: "clientSecret" +}) -```js -const { data } = await octokit.rest.repos.getContent({ - mediaType: { - format: "raw", - }, - owner: "octocat", - repo: "hello-world", - path: "package.json", +// Deprecated Gihub API token (seems not to be working with the v3 API) +github.authenticate({ + type: "token", + token: token }); -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 +### 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. -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`. +For example: -Example: get the login of the authenticated user - -```js -const { - viewer: { login }, -} = await octokit.graphql(`{ - viewer { - login - } -}`); -``` +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. -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 - } - } - } - } +```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" } - `, - { - 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 - } - } - } +}, 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", - }, -); -``` - -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); ``` -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. +## Implemented GitHub APIs -```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}`, - ); - }, -}); -``` +* 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: 90% +* Gitignore: 100% +* Meta: 100% +* Emojis: 100% -Example: Create an OAuth App Server with default scopes +## Running the Tests -```js -import { createServer } from "node:http"; -import { OAuthApp, createNodeMiddleware } from "octokit"; +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. -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); +Before running unit tests: +```shell +npm install mocha -g ``` - -### 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); -} +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 ``` - -🚧 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 +Note that a connection to the internet is required to run the tests. ## LICENSE -[MIT](LICENSE) +MIT license. See the LICENSE file for details. diff --git a/SECURITY.md b/SECURITY.md deleted file mode 100644 index 4b7f6d06b7..0000000000 --- a/SECURITY.md +++ /dev/null @@ -1,11 +0,0 @@ -# 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 new file mode 100644 index 0000000000..49d1a202ff --- /dev/null +++ b/api/v2.0.0/routes.json @@ -0,0 +1,3 @@ +{ + +} diff --git a/api/v3.0.0/authorization.js b/api/v3.0.0/authorization.js new file mode 100644 index 0000000000..f5a63e6836 --- /dev/null +++ b/api/v3.0.0/authorization.js @@ -0,0 +1,230 @@ +/** + * 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..29b0b8dab2 --- /dev/null +++ b/api/v3.0.0/authorizationTest.js @@ -0,0 +1,258 @@ +/* + * 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 new file mode 100644 index 0000000000..ef1e836613 --- /dev/null +++ b/api/v3.0.0/events.js @@ -0,0 +1,445 @@ +/** + * 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..0c4a7320bc --- /dev/null +++ b/api/v3.0.0/eventsTest.js @@ -0,0 +1,212 @@ +/* + * 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 new file mode 100644 index 0000000000..3b270e33e2 --- /dev/null +++ b/api/v3.0.0/gists.js @@ -0,0 +1,716 @@ +/** + * 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 + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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' + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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' + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..d47d28f371 --- /dev/null +++ b/api/v3.0.0/gistsTest.js @@ -0,0 +1,605 @@ +/* + * 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 new file mode 100644 index 0000000000..14d5bd0411 --- /dev/null +++ b/api/v3.0.0/gitdata.js @@ -0,0 +1,585 @@ +/** + * 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..c9f7fbce0e --- /dev/null +++ b/api/v3.0.0/gitdataTest.js @@ -0,0 +1,480 @@ +/* + * 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 new file mode 100644 index 0000000000..b60b86b6fe --- /dev/null +++ b/api/v3.0.0/gitignore.js @@ -0,0 +1,102 @@ +/** + * 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 `{}` + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..e533eb4c88 --- /dev/null +++ b/api/v3.0.0/gitignoreTest.js @@ -0,0 +1,54 @@ +/* + * 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 new file mode 100644 index 0000000000..5ce2480f28 --- /dev/null +++ b/api/v3.0.0/index.js @@ -0,0 +1,40 @@ +/** + * 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 new file mode 100644 index 0000000000..37da2afdae --- /dev/null +++ b/api/v3.0.0/issues.js @@ -0,0 +1,1078 @@ +/** + * 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + * - 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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): Required. Array of strings - Labels to associate with this 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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)$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..c9f217bff9 --- /dev/null +++ b/api/v3.0.0/issuesTest.js @@ -0,0 +1,423 @@ +/* + * 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 new file mode 100644 index 0000000000..c5f7ba2231 --- /dev/null +++ b/api/v3.0.0/markdown.js @@ -0,0 +1,64 @@ +/** + * 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` + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..19271af777 --- /dev/null +++ b/api/v3.0.0/markdownTest.js @@ -0,0 +1,43 @@ +/* + * 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(); + } + ); + }); +}); diff --git a/api/v3.0.0/misc.js b/api/v3.0.0/misc.js new file mode 100644 index 0000000000..b1dc00ba79 --- /dev/null +++ b/api/v3.0.0/misc.js @@ -0,0 +1,142 @@ +/** + * 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..6cee44f2f7 --- /dev/null +++ b/api/v3.0.0/miscTest.js @@ -0,0 +1,69 @@ +/* + * 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 new file mode 100644 index 0000000000..8fe1727975 --- /dev/null +++ b/api/v3.0.0/orgs.js @@ -0,0 +1,978 @@ +/** + * 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..44faeed898 --- /dev/null +++ b/api/v3.0.0/orgsTest.js @@ -0,0 +1,361 @@ +/* + * 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 new file mode 100644 index 0000000000..67175b8214 --- /dev/null +++ b/api/v3.0.0/pullRequests.js @@ -0,0 +1,680 @@ +/** + * 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)$ `. + * - 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)$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..6948680116 --- /dev/null +++ b/api/v3.0.0/pullRequestsTest.js @@ -0,0 +1,279 @@ +/* + * 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", + 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 new file mode 100644 index 0000000000..424b8c6948 --- /dev/null +++ b/api/v3.0.0/releases.js @@ -0,0 +1,414 @@ +/** + * 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..c8175d9b0f --- /dev/null +++ b/api/v3.0.0/releasesTest.js @@ -0,0 +1,232 @@ + /* + * 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("[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 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 PATCH /repos/:owner/:repo/releases/assets/:id (editAsset)", function(next) { + if (!newAssetId) { + next(); + return; + } + client.releases.editAsset( + { + owner: owner, + id: "Number", + repo: repo, + name: "String", + label: "String" + }, + function(err, res) { + Assert.equal(err, null); + // other assertions go here + 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: "Number", + 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 new file mode 100644 index 0000000000..21f97c6ad9 --- /dev/null +++ b/api/v3.0.0/repos.js @@ -0,0 +1,2756 @@ +/** + * 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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]+$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..1b5c5b2f98 --- /dev/null +++ b/api/v3.0.0/reposTest.js @@ -0,0 +1,1056 @@ +/* + * 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(); + } + ); + }); +}); diff --git a/api/v3.0.0/routes.json b/api/v3.0.0/routes.json new file mode 100644 index 0000000000..bcee1fadbb --- /dev/null +++ b/api/v3.0.0/routes.json @@ -0,0 +1,3558 @@ +{ + "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", + "requestMedia": "application/vnd.github.beta+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 + } + } + }, + + "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, + "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": "String User login, `none` for Issues with no assigned User. `*` for Issues with any assigned User.", + "description": "String User login, `none` for Issues with no assigned User. `*` for Issues with any assigned User." + }, + "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": true, + "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-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 + } + }, + + "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 + } + }, + + "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/statuses/:sha", + "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." + } + } + } + }, + + "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" + }, + "$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 + } + }, + + "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 + } + } + }, + + "user": { + "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 + } + }, + + "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 repositorys 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 + } + }, + "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": { + "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 + } + }, + + "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 + } + }, + + "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 + } + }, + + "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`" + } + } + } + }, + + "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 new file mode 100644 index 0000000000..edbf67d1ad --- /dev/null +++ b/api/v3.0.0/search.js @@ -0,0 +1,188 @@ +/** + * 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#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)$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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)$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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)$ `. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..68fefa65c9 --- /dev/null +++ b/api/v3.0.0/searchTest.js @@ -0,0 +1,103 @@ +/* + * 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/issues/:q (issues)", function(next) { + client.search.issues( + { + q: ['macaroni', '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 new file mode 100644 index 0000000000..c924334e18 --- /dev/null +++ b/api/v3.0.0/statuses.js @@ -0,0 +1,109 @@ +/** + * 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..b00d6f6f38 --- /dev/null +++ b/api/v3.0.0/statusesTest.js @@ -0,0 +1,61 @@ +/* + * 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/statuses/:sha (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 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 new file mode 100644 index 0000000000..21a21ba688 --- /dev/null +++ b/api/v3.0.0/user.js @@ -0,0 +1,844 @@ +/** + * 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#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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 `{}` + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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. + **/ + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..c7b7a1061e --- /dev/null +++ b/api/v3.0.0/userTest.js @@ -0,0 +1,304 @@ +/* + * 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 deleted file mode 100644 index a9754a764a..0000000000 Binary files a/assets/create-an-issue-reference.png and /dev/null differ diff --git a/assets/squash-and-merge-dialog.png b/assets/squash-and-merge-dialog.png deleted file mode 100644 index 3d4ff90023..0000000000 Binary files a/assets/squash-and-merge-dialog.png and /dev/null differ diff --git a/error.js b/error.js new file mode 100644 index 0000000000..2da83f2984 --- /dev/null +++ b/error.js @@ -0,0 +1,117 @@ +/** 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 new file mode 100755 index 0000000000..eb1e9bad6c --- /dev/null +++ b/generate.js @@ -0,0 +1,295 @@ +#!/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 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 main = module.exports = function(versions, tests, restore) { + Util.log("Generating for versions", Object.keys(versions)); + + Object.keys(versions).forEach(function(version) { + 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 + ")"); + }); + + 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 = {}; + + function createComment(paramsStruct, section, funcName, indent) { + 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); + } + + 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.params, 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"); + }); + }); +}; + +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; + try { + routes = JSON.parse(Fs.readFileSync(path, "utf8")); + } + catch (ex) { + return; + } + 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 new file mode 100644 index 0000000000..90998079b4 --- /dev/null +++ b/index.js @@ -0,0 +1,804 @@ +"use strict"; + +var error = require("./error"); +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) { + 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) + 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" + * }); + **/ + this.authenticate = function(options) { + if (!options) { + this.auth = false; + return; + } + if (!options.type || "basic|oauth|client".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"); + } + + 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 && JSON.parse(res.data); + } + catch (ex) { + if (callback) + callback(new error.InternalServerError(ex.message), res); + return; + } + + if (!ret) + ret = {}; + 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 getQueryAndUrl(msg, def, format, config) { + var url = def.url; + if (config.pathPrefix) { + url = config.pathPrefix + def.url; + } + var ret = { + query: format == "json" ? {} : [] + }; + 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 + 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 hasBody = ("head|get|delete".indexOf(method) === -1); + var format = hasBody && this.constants.requestFormat + ? this.constants.requestFormat + : "query"; + 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 = 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 + query = query.join("&"); + headers["content-length"] = Buffer.byteLength(query, "utf8"); + headers["content-type"] = format == "json" + ? "application/json; 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": + basic = new Buffer(this.auth.username + "/token:" + this.auth.token, "ascii").toString("base64"); + headers.authorization = "Basic " + basic; + break; + case "basic": + basic = new Buffer(this.auth.username + ":" + this.auth.password, "ascii").toString("base64"); + headers.authorization = "Basic " + basic; + break; + default: + break; + } + } + + if (!msg.headers) + msg.headers = {}; + Object.keys(msg.headers).forEach(function(header) { + var headerLC = header.toLowerCase(); + if (self.requestHeaders.indexOf(headerLC) == -1) + return; + headers[headerLC] = msg.headers[header]; + }); + if (!headers["user-agent"]) + headers["user-agent"] = "NodeJS HTTP Client"; + + if (!headers["accept"]) + headers["accept"] = this.config.requestMedia || this.constants.requestMedia; + + var options = { + host: host, + port: port, + path: path, + method: method, + headers: headers + }; + + if (this.debug) + console.log("REQUEST: ", options); + + var callbackCalled = false + + 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) { + if (!callbackCalled) { + callbackCalled = true; + callback(err); + } + }); + res.on("end", function() { + if (callbackCalled) + return; + + callbackCalled = true; + if (res.statusCode >= 400 && res.statusCode < 600 || res.statusCode < 10) { + callback(new error.HttpError(data, res.statusCode)); + } else { + res.data = data; + callback(null, res); + } + }); + }); + + if (this.config.timeout) { + req.setTimeout(this.config.timeout); + } + + req.on("error", function(e) { + if (self.debug) + console.log("problem with request: " + e.message); + if (!callbackCalled) { + callbackCalled = true; + callback(e.message); + } + }); + + req.on("timeout", function() { + if (self.debug) + console.log("problem with request: timed out"); + if (!callbackCalled) { + callbackCalled = true; + callback(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"); + } + req.end(); + }; +}).call(Client.prototype); diff --git a/package-lock.json b/package-lock.json deleted file mode 100644 index cb9df7e61e..0000000000 --- a/package-lock.json +++ /dev/null @@ -1,3125 +0,0 @@ -{ - "name": "octokit", - "version": "0.0.0-development", - "lockfileVersion": 3, - "requires": true, - "packages": { - "": { - "name": "octokit", - "version": "0.0.0-development", - "license": "MIT", - "dependencies": { - "@octokit/app": "^16.1.2", - "@octokit/core": "^7.0.6", - "@octokit/oauth-app": "^8.0.3", - "@octokit/plugin-paginate-graphql": "^6.0.0", - "@octokit/plugin-paginate-rest": "^14.0.0", - "@octokit/plugin-rest-endpoint-methods": "^17.0.0", - "@octokit/plugin-retry": "^8.0.3", - "@octokit/plugin-throttling": "^11.0.3", - "@octokit/request-error": "^7.0.2", - "@octokit/types": "^16.0.0", - "@octokit/webhooks": "^14.0.0" - }, - "devDependencies": { - "@octokit/tsconfig": "^4.0.0", - "@types/node": "^24.0.0", - "@vitest/coverage-v8": "^4.0.0", - "esbuild": "^0.27.0", - "mockdate": "^3.0.5", - "nock": "^14.0.10", - "prettier": "3.7.4", - "semantic-release-plugin-update-version-in-files": "^2.0.0", - "tinyglobby": "^0.2.15", - "typescript": "^5.0.0", - "vitest": "^4.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@babel/helper-string-parser": { - "version": "7.27.1", - "resolved": "https://registry.npmjs.org/@babel/helper-string-parser/-/helper-string-parser-7.27.1.tgz", - "integrity": "sha512-qMlSxKbpRlAridDExk92nSobyDdpPijUq2DW6oDnUqd0iOGxmQjyqhMIihI9+zv4LPyZdRje2cavWPbCbWm3eA==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/helper-validator-identifier": { - "version": "7.28.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.28.5.tgz", - "integrity": "sha512-qSs4ifwzKJSV39ucNjsvc6WVHs6b7S03sOh2OcHF9UHfVPqWWALUsNUVzhSBiItjRZoLHx7nIarVjqKVusUZ1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=6.9.0" - } - }, - "node_modules/@babel/parser": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.29.0.tgz", - "integrity": "sha512-IyDgFV5GeDUVX4YdF/3CPULtVGSXXMLh1xVIgdCgxApktqnQV0r7/8Nqthg+8YLGaAtdyIlo2qIdZrbCv4+7ww==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/types": "^7.29.0" - }, - "bin": { - "parser": "bin/babel-parser.js" - }, - "engines": { - "node": ">=6.0.0" - } - }, - "node_modules/@babel/types": { - "version": "7.29.0", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.29.0.tgz", - "integrity": "sha512-LwdZHpScM4Qz8Xw2iKSzS+cfglZzJGvofQICy7W7v4caru4EaAmyUuO6BGrbyQ2mYV11W0U8j5mBhd14dd3B0A==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/helper-string-parser": "^7.27.1", - "@babel/helper-validator-identifier": "^7.28.5" - }, - "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/@emnapi/core": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@emnapi/core/-/core-1.9.0.tgz", - "integrity": "sha512-0DQ98G9ZQZOxfUcQn1waV2yS8aWdZ6kJMbYCJB3oUBecjWYO1fqJ+a1DRfPF3O5JEkwqwP1A9QEN/9mYm2Yd0w==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@emnapi/wasi-threads": "1.2.0", - "tslib": "^2.4.0" - } - }, - "node_modules/@emnapi/runtime": { - "version": "1.9.0", - "resolved": "https://registry.npmjs.org/@emnapi/runtime/-/runtime-1.9.0.tgz", - "integrity": "sha512-QN75eB0IH2ywSpRpNddCRfQIhmJYBCJ1x5Lb3IscKAL8bMnVAKnRg8dCoXbHzVLLH7P38N2Z3mtulB7W0J0FKw==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/@emnapi/wasi-threads": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@emnapi/wasi-threads/-/wasi-threads-1.2.0.tgz", - "integrity": "sha512-N10dEJNSsUx41Z6pZsXU8FjPjpBEplgH24sfkmITrBED1/U2Esum9F3lfLrMjKHHjmi557zQn7kR9R+XWXu5Rg==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/@esbuild/aix-ppc64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/aix-ppc64/-/aix-ppc64-0.27.4.tgz", - "integrity": "sha512-cQPwL2mp2nSmHHJlCyoXgHGhbEPMrEEU5xhkcy3Hs/O7nGZqEpZ2sUtLaL9MORLtDfRvVl2/3PAuEkYZH0Ty8Q==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "aix" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm/-/android-arm-0.27.4.tgz", - "integrity": "sha512-X9bUgvxiC8CHAGKYufLIHGXPJWnr0OCdR0anD2e21vdvgCI8lIfqFbnoeOz7lBjdrAGUhqLZLcQo6MLhTO2DKQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-arm64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-arm64/-/android-arm64-0.27.4.tgz", - "integrity": "sha512-gdLscB7v75wRfu7QSm/zg6Rx29VLdy9eTr2t44sfTW7CxwAtQghZ4ZnqHk3/ogz7xao0QAgrkradbBzcqFPasw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/android-x64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/android-x64/-/android-x64-0.27.4.tgz", - "integrity": "sha512-PzPFnBNVF292sfpfhiyiXCGSn9HZg5BcAz+ivBuSsl6Rk4ga1oEXAamhOXRFyMcjwr2DVtm40G65N3GLeH1Lvw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-arm64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-arm64/-/darwin-arm64-0.27.4.tgz", - "integrity": "sha512-b7xaGIwdJlht8ZFCvMkpDN6uiSmnxxK56N2GDTMYPr2/gzvfdQN8rTfBsvVKmIVY/X7EM+/hJKEIbbHs9oA4tQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/darwin-x64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/darwin-x64/-/darwin-x64-0.27.4.tgz", - "integrity": "sha512-sR+OiKLwd15nmCdqpXMnuJ9W2kpy0KigzqScqHI3Hqwr7IXxBp3Yva+yJwoqh7rE8V77tdoheRYataNKL4QrPw==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-arm64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-arm64/-/freebsd-arm64-0.27.4.tgz", - "integrity": "sha512-jnfpKe+p79tCnm4GVav68A7tUFeKQwQyLgESwEAUzyxk/TJr4QdGog9sqWNcUbr/bZt/O/HXouspuQDd9JxFSw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/freebsd-x64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/freebsd-x64/-/freebsd-x64-0.27.4.tgz", - "integrity": "sha512-2kb4ceA/CpfUrIcTUl1wrP/9ad9Atrp5J94Lq69w7UwOMolPIGrfLSvAKJp0RTvkPPyn6CIWrNy13kyLikZRZQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm/-/linux-arm-0.27.4.tgz", - "integrity": "sha512-aBYgcIxX/wd5n2ys0yESGeYMGF+pv6g0DhZr3G1ZG4jMfruU9Tl1i2Z+Wnj9/KjGz1lTLCcorqE2viePZqj4Eg==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-arm64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-arm64/-/linux-arm64-0.27.4.tgz", - "integrity": "sha512-7nQOttdzVGth1iz57kxg9uCz57dxQLHWxopL6mYuYthohPKEK0vU0C3O21CcBK6KDlkYVcnDXY099HcCDXd9dA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ia32": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ia32/-/linux-ia32-0.27.4.tgz", - "integrity": "sha512-oPtixtAIzgvzYcKBQM/qZ3R+9TEUd1aNJQu0HhGyqtx6oS7qTpvjheIWBbes4+qu1bNlo2V4cbkISr8q6gRBFA==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-loong64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-loong64/-/linux-loong64-0.27.4.tgz", - "integrity": "sha512-8mL/vh8qeCoRcFH2nM8wm5uJP+ZcVYGGayMavi8GmRJjuI3g1v6Z7Ni0JJKAJW+m0EtUuARb6Lmp4hMjzCBWzA==", - "cpu": [ - "loong64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-mips64el": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-mips64el/-/linux-mips64el-0.27.4.tgz", - "integrity": "sha512-1RdrWFFiiLIW7LQq9Q2NES+HiD4NyT8Itj9AUeCl0IVCA459WnPhREKgwrpaIfTOe+/2rdntisegiPWn/r/aAw==", - "cpu": [ - "mips64el" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-ppc64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-ppc64/-/linux-ppc64-0.27.4.tgz", - "integrity": "sha512-tLCwNG47l3sd9lpfyx9LAGEGItCUeRCWeAx6x2Jmbav65nAwoPXfewtAdtbtit/pJFLUWOhpv0FpS6GQAmPrHA==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-riscv64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-riscv64/-/linux-riscv64-0.27.4.tgz", - "integrity": "sha512-BnASypppbUWyqjd1KIpU4AUBiIhVr6YlHx/cnPgqEkNoVOhHg+YiSVxM1RLfiy4t9cAulbRGTNCKOcqHrEQLIw==", - "cpu": [ - "riscv64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-s390x": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-s390x/-/linux-s390x-0.27.4.tgz", - "integrity": "sha512-+eUqgb/Z7vxVLezG8bVB9SfBie89gMueS+I0xYh2tJdw3vqA/0ImZJ2ROeWwVJN59ihBeZ7Tu92dF/5dy5FttA==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/linux-x64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/linux-x64/-/linux-x64-0.27.4.tgz", - "integrity": "sha512-S5qOXrKV8BQEzJPVxAwnryi2+Iq5pB40gTEIT69BQONqR7JH1EPIcQ/Uiv9mCnn05jff9umq/5nqzxlqTOg9NA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-arm64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-arm64/-/netbsd-arm64-0.27.4.tgz", - "integrity": "sha512-xHT8X4sb0GS8qTqiwzHqpY00C95DPAq7nAwX35Ie/s+LO9830hrMd3oX0ZMKLvy7vsonee73x0lmcdOVXFzd6Q==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/netbsd-x64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/netbsd-x64/-/netbsd-x64-0.27.4.tgz", - "integrity": "sha512-RugOvOdXfdyi5Tyv40kgQnI0byv66BFgAqjdgtAKqHoZTbTF2QqfQrFwa7cHEORJf6X2ht+l9ABLMP0dnKYsgg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "netbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-arm64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-arm64/-/openbsd-arm64-0.27.4.tgz", - "integrity": "sha512-2MyL3IAaTX+1/qP0O1SwskwcwCoOI4kV2IBX1xYnDDqthmq5ArrW94qSIKCAuRraMgPOmG0RDTA74mzYNQA9ow==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openbsd-x64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/openbsd-x64/-/openbsd-x64-0.27.4.tgz", - "integrity": "sha512-u8fg/jQ5aQDfsnIV6+KwLOf1CmJnfu1ShpwqdwC0uA7ZPwFws55Ngc12vBdeUdnuWoQYx/SOQLGDcdlfXhYmXQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openbsd" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/openharmony-arm64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/openharmony-arm64/-/openharmony-arm64-0.27.4.tgz", - "integrity": "sha512-JkTZrl6VbyO8lDQO3yv26nNr2RM2yZzNrNHEsj9bm6dOwwu9OYN28CjzZkH57bh4w0I2F7IodpQvUAEd1mbWXg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/sunos-x64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/sunos-x64/-/sunos-x64-0.27.4.tgz", - "integrity": "sha512-/gOzgaewZJfeJTlsWhvUEmUG4tWEY2Spp5M20INYRg2ZKl9QPO3QEEgPeRtLjEWSW8FilRNacPOg8R1uaYkA6g==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "sunos" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-arm64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-arm64/-/win32-arm64-0.27.4.tgz", - "integrity": "sha512-Z9SExBg2y32smoDQdf1HRwHRt6vAHLXcxD2uGgO/v2jK7Y718Ix4ndsbNMU/+1Qiem9OiOdaqitioZwxivhXYg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-ia32": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-ia32/-/win32-ia32-0.27.4.tgz", - "integrity": "sha512-DAyGLS0Jz5G5iixEbMHi5KdiApqHBWMGzTtMiJ72ZOLhbu/bzxgAe8Ue8CTS3n3HbIUHQz/L51yMdGMeoxXNJw==", - "cpu": [ - "ia32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">=18" - } - }, - "node_modules/@esbuild/win32-x64": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.27.4.tgz", - "integrity": "sha512-+knoa0BDoeXgkNvvV1vvbZX4+hizelrkwmGJBdT17t8FNPwG2lKemmuMZlmaNQ3ws3DKKCxpb4zRZEIp3UxFCg==", - "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/@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/sourcemap-codec": { - "version": "1.5.5", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", - "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", - "dev": true, - "license": "MIT" - }, - "node_modules/@jridgewell/trace-mapping": { - "version": "0.3.31", - "resolved": "https://registry.npmjs.org/@jridgewell/trace-mapping/-/trace-mapping-0.3.31.tgz", - "integrity": "sha512-zzNR+SdQSDJzc8joaeP8QQoCQr8NuYx2dIIytl1QeBEZHJ9uW6hebsrYgbz8hJwUQao3TWCMtmfV8Nu1twOLAw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/resolve-uri": "^3.1.0", - "@jridgewell/sourcemap-codec": "^1.4.14" - } - }, - "node_modules/@mswjs/interceptors": { - "version": "0.41.3", - "resolved": "https://registry.npmjs.org/@mswjs/interceptors/-/interceptors-0.41.3.tgz", - "integrity": "sha512-cXu86tF4VQVfwz8W1SPbhoRyHJkti6mjH/XJIxp40jhO4j2k1m4KYrEykxqWPkFF3vrK4rgQppBh//AwyGSXPA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@open-draft/deferred-promise": "^2.2.0", - "@open-draft/logger": "^0.3.0", - "@open-draft/until": "^2.0.0", - "is-node-process": "^1.2.0", - "outvariant": "^1.4.3", - "strict-event-emitter": "^0.5.1" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/@napi-rs/wasm-runtime": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.1.tgz", - "integrity": "sha512-p64ah1M1ld8xjWv3qbvFwHiFVWrq1yFvV4f7w+mzaqiR4IlSgkqhcRdHwsGgomwzBH51sRY4NEowLxnaBjcW/A==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@emnapi/core": "^1.7.1", - "@emnapi/runtime": "^1.7.1", - "@tybys/wasm-util": "^0.10.1" - }, - "funding": { - "type": "github", - "url": "https://github.com/sponsors/Brooooooklyn" - } - }, - "node_modules/@octokit/app": { - "version": "16.1.2", - "resolved": "https://registry.npmjs.org/@octokit/app/-/app-16.1.2.tgz", - "integrity": "sha512-8j7sEpUYVj18dxvh0KWj6W/l6uAiVRBl1JBDVRqH1VHKAO/G5eRVl4yEoYACjakWers1DjUkcCHyJNQK47JqyQ==", - "license": "MIT", - "dependencies": { - "@octokit/auth-app": "^8.1.2", - "@octokit/auth-unauthenticated": "^7.0.3", - "@octokit/core": "^7.0.6", - "@octokit/oauth-app": "^8.0.3", - "@octokit/plugin-paginate-rest": "^14.0.0", - "@octokit/types": "^16.0.0", - "@octokit/webhooks": "^14.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/auth-app": { - "version": "8.2.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-app/-/auth-app-8.2.0.tgz", - "integrity": "sha512-vVjdtQQwomrZ4V46B9LaCsxsySxGoHsyw6IYBov/TqJVROrlYdyNgw5q6tQbB7KZt53v1l1W53RiqTvpzL907g==", - "license": "MIT", - "dependencies": { - "@octokit/auth-oauth-app": "^9.0.3", - "@octokit/auth-oauth-user": "^6.0.2", - "@octokit/request": "^10.0.6", - "@octokit/request-error": "^7.0.2", - "@octokit/types": "^16.0.0", - "toad-cache": "^3.7.0", - "universal-github-app-jwt": "^2.2.0", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/auth-oauth-app": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-app/-/auth-oauth-app-9.0.3.tgz", - "integrity": "sha512-+yoFQquaF8OxJSxTb7rnytBIC2ZLbLqA/yb71I4ZXT9+Slw4TziV9j/kyGhUFRRTF2+7WlnIWsePZCWHs+OGjg==", - "license": "MIT", - "dependencies": { - "@octokit/auth-oauth-device": "^8.0.3", - "@octokit/auth-oauth-user": "^6.0.2", - "@octokit/request": "^10.0.6", - "@octokit/types": "^16.0.0", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/auth-oauth-device": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-device/-/auth-oauth-device-8.0.3.tgz", - "integrity": "sha512-zh2W0mKKMh/VWZhSqlaCzY7qFyrgd9oTWmTmHaXnHNeQRCZr/CXy2jCgHo4e4dJVTiuxP5dLa0YM5p5QVhJHbw==", - "license": "MIT", - "dependencies": { - "@octokit/oauth-methods": "^6.0.2", - "@octokit/request": "^10.0.6", - "@octokit/types": "^16.0.0", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/auth-oauth-user": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@octokit/auth-oauth-user/-/auth-oauth-user-6.0.2.tgz", - "integrity": "sha512-qLoPPc6E6GJoz3XeDG/pnDhJpTkODTGG4kY0/Py154i/I003O9NazkrwJwRuzgCalhzyIeWQ+6MDvkUmKXjg/A==", - "license": "MIT", - "dependencies": { - "@octokit/auth-oauth-device": "^8.0.3", - "@octokit/oauth-methods": "^6.0.2", - "@octokit/request": "^10.0.6", - "@octokit/types": "^16.0.0", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/auth-token": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-6.0.0.tgz", - "integrity": "sha512-P4YJBPdPSpWTQ1NU4XYdvHvXJJDxM6YwpS0FZHRgP7YFkdVxsWcpWGy/NVqlAA7PcPCnMacXlRm1y2PFZRWL/w==", - "license": "MIT", - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/auth-unauthenticated": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/@octokit/auth-unauthenticated/-/auth-unauthenticated-7.0.3.tgz", - "integrity": "sha512-8Jb1mtUdmBHL7lGmop9mU9ArMRUTRhg8vp0T1VtZ4yd9vEm3zcLwmjQkhNEduKawOOORie61xhtYIhTDN+ZQ3g==", - "license": "MIT", - "dependencies": { - "@octokit/request-error": "^7.0.2", - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/core": { - "version": "7.0.6", - "resolved": "https://registry.npmjs.org/@octokit/core/-/core-7.0.6.tgz", - "integrity": "sha512-DhGl4xMVFGVIyMwswXeyzdL4uXD5OGILGX5N8Y+f6W7LhC1Ze2poSNrkF/fedpVDHEEZ+PHFW0vL14I+mm8K3Q==", - "license": "MIT", - "dependencies": { - "@octokit/auth-token": "^6.0.0", - "@octokit/graphql": "^9.0.3", - "@octokit/request": "^10.0.6", - "@octokit/request-error": "^7.0.2", - "@octokit/types": "^16.0.0", - "before-after-hook": "^4.0.0", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/endpoint": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-11.0.3.tgz", - "integrity": "sha512-FWFlNxghg4HrXkD3ifYbS/IdL/mDHjh9QcsNyhQjN8dplUoZbejsdpmuqdA76nxj2xoWPs7p8uX2SNr9rYu0Ag==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0", - "universal-user-agent": "^7.0.2" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/graphql": { - "version": "9.0.3", - "resolved": "https://registry.npmjs.org/@octokit/graphql/-/graphql-9.0.3.tgz", - "integrity": "sha512-grAEuupr/C1rALFnXTv6ZQhFuL1D8G5y8CN04RgrO4FIPMrtm+mcZzFG7dcBm+nq+1ppNixu+Jd78aeJOYxlGA==", - "license": "MIT", - "dependencies": { - "@octokit/request": "^10.0.6", - "@octokit/types": "^16.0.0", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/oauth-app": { - "version": "8.0.3", - "resolved": "https://registry.npmjs.org/@octokit/oauth-app/-/oauth-app-8.0.3.tgz", - "integrity": "sha512-jnAjvTsPepyUaMu9e69hYBuozEPgYqP4Z3UnpmvoIzHDpf8EXDGvTY1l1jK0RsZ194oRd+k6Hm13oRU8EoDFwg==", - "license": "MIT", - "dependencies": { - "@octokit/auth-oauth-app": "^9.0.2", - "@octokit/auth-oauth-user": "^6.0.1", - "@octokit/auth-unauthenticated": "^7.0.2", - "@octokit/core": "^7.0.5", - "@octokit/oauth-authorization-url": "^8.0.0", - "@octokit/oauth-methods": "^6.0.1", - "@types/aws-lambda": "^8.10.83", - "universal-user-agent": "^7.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/oauth-authorization-url": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/@octokit/oauth-authorization-url/-/oauth-authorization-url-8.0.0.tgz", - "integrity": "sha512-7QoLPRh/ssEA/HuHBHdVdSgF8xNLz/Bc5m9fZkArJE5bb6NmVkDm3anKxXPmN1zh6b5WKZPRr3697xKT/yM3qQ==", - "license": "MIT", - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/oauth-methods": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/@octokit/oauth-methods/-/oauth-methods-6.0.2.tgz", - "integrity": "sha512-HiNOO3MqLxlt5Da5bZbLV8Zarnphi4y9XehrbaFMkcoJ+FL7sMxH/UlUsCVxpddVu4qvNDrBdaTVE2o4ITK8ng==", - "license": "MIT", - "dependencies": { - "@octokit/oauth-authorization-url": "^8.0.0", - "@octokit/request": "^10.0.6", - "@octokit/request-error": "^7.0.2", - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/openapi-types": { - "version": "27.0.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-types/-/openapi-types-27.0.0.tgz", - "integrity": "sha512-whrdktVs1h6gtR+09+QsNk2+FO+49j6ga1c55YZudfEG+oKJVvJLQi3zkOm5JjiUXAagWK2tI2kTGKJ2Ys7MGA==", - "license": "MIT" - }, - "node_modules/@octokit/openapi-webhooks-types": { - "version": "12.1.0", - "resolved": "https://registry.npmjs.org/@octokit/openapi-webhooks-types/-/openapi-webhooks-types-12.1.0.tgz", - "integrity": "sha512-WiuzhOsiOvb7W3Pvmhf8d2C6qaLHXrWiLBP4nJ/4kydu+wpagV5Fkz9RfQwV2afYzv3PB+3xYgp4mAdNGjDprA==", - "license": "MIT" - }, - "node_modules/@octokit/plugin-paginate-graphql": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-graphql/-/plugin-paginate-graphql-6.0.0.tgz", - "integrity": "sha512-crfpnIoFiBtRkvPqOyLOsw12XsveYuY2ieP6uYDosoUegBJpSVxGwut9sxUgFFcll3VTOTqpUf8yGd8x1OmAkQ==", - "license": "MIT", - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": ">=6" - } - }, - "node_modules/@octokit/plugin-paginate-rest": { - "version": "14.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-paginate-rest/-/plugin-paginate-rest-14.0.0.tgz", - "integrity": "sha512-fNVRE7ufJiAA3XUrha2omTA39M6IXIc6GIZLvlbsm8QOQCYvpq/LkMNGyFlB1d8hTDzsAXa3OKtybdMAYsV/fw==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": ">=6" - } - }, - "node_modules/@octokit/plugin-rest-endpoint-methods": { - "version": "17.0.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-rest-endpoint-methods/-/plugin-rest-endpoint-methods-17.0.0.tgz", - "integrity": "sha512-B5yCyIlOJFPqUUeiD0cnBJwWJO8lkJs5d8+ze9QDP6SvfiXSz1BF+91+0MeI1d2yxgOhU/O+CvtiZ9jSkHhFAw==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": ">=6" - } - }, - "node_modules/@octokit/plugin-retry": { - "version": "8.1.0", - "resolved": "https://registry.npmjs.org/@octokit/plugin-retry/-/plugin-retry-8.1.0.tgz", - "integrity": "sha512-O1FZgXeiGb2sowEr/hYTr6YunGdSAFWnr2fyW39Ah85H8O33ELASQxcvOFF5LE6Tjekcyu2ms4qAzJVhSaJxTw==", - "license": "MIT", - "dependencies": { - "@octokit/request-error": "^7.0.2", - "@octokit/types": "^16.0.0", - "bottleneck": "^2.15.3" - }, - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": ">=7" - } - }, - "node_modules/@octokit/plugin-throttling": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@octokit/plugin-throttling/-/plugin-throttling-11.0.3.tgz", - "integrity": "sha512-34eE0RkFCKycLl2D2kq7W+LovheM/ex3AwZCYN8udpi6bxsyjZidb2McXs69hZhLmJlDqTSP8cH+jSRpiaijBg==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0", - "bottleneck": "^2.15.3" - }, - "engines": { - "node": ">= 20" - }, - "peerDependencies": { - "@octokit/core": "^7.0.0" - } - }, - "node_modules/@octokit/request": { - "version": "10.0.8", - "resolved": "https://registry.npmjs.org/@octokit/request/-/request-10.0.8.tgz", - "integrity": "sha512-SJZNwY9pur9Agf7l87ywFi14W+Hd9Jg6Ifivsd33+/bGUQIjNujdFiXII2/qSlN2ybqUHfp5xpekMEjIBTjlSw==", - "license": "MIT", - "dependencies": { - "@octokit/endpoint": "^11.0.3", - "@octokit/request-error": "^7.0.2", - "@octokit/types": "^16.0.0", - "fast-content-type-parse": "^3.0.0", - "json-with-bigint": "^3.5.3", - "universal-user-agent": "^7.0.2" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/request-error": { - "version": "7.1.0", - "resolved": "https://registry.npmjs.org/@octokit/request-error/-/request-error-7.1.0.tgz", - "integrity": "sha512-KMQIfq5sOPpkQYajXHwnhjCC0slzCNScLHs9JafXc4RAJI+9f+jNDlBNaIMTvazOPLgb4BnlhGJOTbnN0wIjPw==", - "license": "MIT", - "dependencies": { - "@octokit/types": "^16.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "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": "16.0.0", - "resolved": "https://registry.npmjs.org/@octokit/types/-/types-16.0.0.tgz", - "integrity": "sha512-sKq+9r1Mm4efXW1FCk7hFSeJo4QKreL/tTbR0rz/qx/r1Oa2VV83LTA/H/MuCOX7uCIJmQVRKBcbmWoySjAnSg==", - "license": "MIT", - "dependencies": { - "@octokit/openapi-types": "^27.0.0" - } - }, - "node_modules/@octokit/webhooks": { - "version": "14.2.0", - "resolved": "https://registry.npmjs.org/@octokit/webhooks/-/webhooks-14.2.0.tgz", - "integrity": "sha512-da6KbdNCV5sr1/txD896V+6W0iamFWrvVl8cHkBSPT+YlvmT3DwXa4jxZnQc+gnuTEqSWbBeoSZYTayXH9wXcw==", - "license": "MIT", - "dependencies": { - "@octokit/openapi-webhooks-types": "12.1.0", - "@octokit/request-error": "^7.0.0", - "@octokit/webhooks-methods": "^6.0.0" - }, - "engines": { - "node": ">= 20" - } - }, - "node_modules/@octokit/webhooks-methods": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@octokit/webhooks-methods/-/webhooks-methods-6.0.0.tgz", - "integrity": "sha512-MFlzzoDJVw/GcbfzVC1RLR36QqkTLUf79vLVO3D+xn7r0QgxnFoLZgtrzxiQErAjFUOdH6fas2KeQJ1yr/qaXQ==", - "license": "MIT", - "engines": { - "node": ">= 20" - } - }, - "node_modules/@open-draft/deferred-promise": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/@open-draft/deferred-promise/-/deferred-promise-2.2.0.tgz", - "integrity": "sha512-CecwLWx3rhxVQF6V4bAgPS5t+So2sTbPgAzafKkVizyi7tlwpcFpdFqq+wqF2OwNBmqFuu6tOyouTuxgpMfzmA==", - "dev": true, - "license": "MIT" - }, - "node_modules/@open-draft/logger": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@open-draft/logger/-/logger-0.3.0.tgz", - "integrity": "sha512-X2g45fzhxH238HKO4xbSr7+wBS8Fvw6ixhTDuvLd5mqh6bJJCFAPwU9mPDxbcrRtfxv4u5IHCEH77BmxvXmmxQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "is-node-process": "^1.2.0", - "outvariant": "^1.4.0" - } - }, - "node_modules/@open-draft/until": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/@open-draft/until/-/until-2.1.0.tgz", - "integrity": "sha512-U69T3ItWHvLwGg5eJ0n3I62nWuE6ilHlmz7zM0npLBRvPRd7e6NYmg54vvRtP5mZG7kZqZCFVdsTWo7BPtBujg==", - "dev": true, - "license": "MIT" - }, - "node_modules/@oxc-project/runtime": { - "version": "0.115.0", - "resolved": "https://registry.npmjs.org/@oxc-project/runtime/-/runtime-0.115.0.tgz", - "integrity": "sha512-Rg8Wlt5dCbXhQnsXPrkOjL1DTSvXLgb2R/KYfnf1/K+R0k6UMLEmbQXPM+kwrWqSmWA2t0B1EtHy2/3zikQpvQ==", - "dev": true, - "license": "MIT", - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@oxc-project/types": { - "version": "0.115.0", - "resolved": "https://registry.npmjs.org/@oxc-project/types/-/types-0.115.0.tgz", - "integrity": "sha512-4n91DKnebUS4yjUHl2g3/b2T+IUdCfmoZGhmwsovZCDaJSs+QkVAM+0AqqTxHSsHfeiMuueT75cZaZcT/m0pSw==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://github.com/sponsors/Boshen" - } - }, - "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/@rolldown/binding-android-arm64": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-android-arm64/-/binding-android-arm64-1.0.0-rc.9.tgz", - "integrity": "sha512-lcJL0bN5hpgJfSIz/8PIf02irmyL43P+j1pTCfbD1DbLkmGRuFIA4DD3B3ZOvGqG0XiVvRznbKtN0COQVaKUTg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-darwin-arm64": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-arm64/-/binding-darwin-arm64-1.0.0-rc.9.tgz", - "integrity": "sha512-J7Zk3kLYFsLtuH6U+F4pS2sYVzac0qkjcO5QxHS7OS7yZu2LRs+IXo+uvJ/mvpyUljDJ3LROZPoQfgBIpCMhdQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-darwin-x64": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-darwin-x64/-/binding-darwin-x64-1.0.0-rc.9.tgz", - "integrity": "sha512-iwtmmghy8nhfRGeNAIltcNXzD0QMNaaA5U/NyZc1Ia4bxrzFByNMDoppoC+hl7cDiUq5/1CnFthpT9n+UtfFyg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-freebsd-x64": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-freebsd-x64/-/binding-freebsd-x64-1.0.0-rc.9.tgz", - "integrity": "sha512-DLFYI78SCiZr5VvdEplsVC2Vx53lnA4/Ga5C65iyldMVaErr86aiqCoNBLl92PXPfDtUYjUh+xFFor40ueNs4Q==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-arm-gnueabihf": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm-gnueabihf/-/binding-linux-arm-gnueabihf-1.0.0-rc.9.tgz", - "integrity": "sha512-CsjTmTwd0Hri6iTw/DRMK7kOZ7FwAkrO4h8YWKoX/kcj833e4coqo2wzIFywtch/8Eb5enQ/lwLM7w6JX1W5RQ==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-arm64-gnu": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-gnu/-/binding-linux-arm64-gnu-1.0.0-rc.9.tgz", - "integrity": "sha512-2x9O2JbSPxpxMDhP9Z74mahAStibTlrBMW0520+epJH5sac7/LwZW5Bmg/E6CXuEF53JJFW509uP+lSedaUNxg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-arm64-musl": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-arm64-musl/-/binding-linux-arm64-musl-1.0.0-rc.9.tgz", - "integrity": "sha512-JA1QRW31ogheAIRhIg9tjMfsYbglXXYGNPLdPEYrwFxdbkQCAzvpSCSHCDWNl4hTtrol8WeboCSEpjdZK8qrCg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-ppc64-gnu": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-ppc64-gnu/-/binding-linux-ppc64-gnu-1.0.0-rc.9.tgz", - "integrity": "sha512-aOKU9dJheda8Kj8Y3w9gnt9QFOO+qKPAl8SWd7JPHP+Cu0EuDAE5wokQubLzIDQWg2myXq2XhTpOVS07qqvT+w==", - "cpu": [ - "ppc64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-s390x-gnu": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-s390x-gnu/-/binding-linux-s390x-gnu-1.0.0-rc.9.tgz", - "integrity": "sha512-OalO94fqj7IWRn3VdXWty75jC5dk4C197AWEuMhIpvVv2lw9fiPhud0+bW2ctCxb3YoBZor71QHbY+9/WToadA==", - "cpu": [ - "s390x" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-x64-gnu": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-gnu/-/binding-linux-x64-gnu-1.0.0-rc.9.tgz", - "integrity": "sha512-cVEl1vZtBsBZna3YMjGXNvnYYrOJ7RzuWvZU0ffvJUexWkukMaDuGhUXn0rjnV0ptzGVkvc+vW9Yqy6h8YX4pg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-linux-x64-musl": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-linux-x64-musl/-/binding-linux-x64-musl-1.0.0-rc.9.tgz", - "integrity": "sha512-UzYnKCIIc4heAKgI4PZ3dfBGUZefGCJ1TPDuLHoCzgrMYPb5Rv6TLFuYtyM4rWyHM7hymNdsg5ik2C+UD9VDbA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-openharmony-arm64": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-openharmony-arm64/-/binding-openharmony-arm64-1.0.0-rc.9.tgz", - "integrity": "sha512-+6zoiF+RRyf5cdlFQP7nm58mq7+/2PFaY2DNQeD4B87N36JzfF/l9mdBkkmTvSYcYPE8tMh/o3cRlsx1ldLfog==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "openharmony" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-wasm32-wasi": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-wasm32-wasi/-/binding-wasm32-wasi-1.0.0-rc.9.tgz", - "integrity": "sha512-rgFN6sA/dyebil3YTlL2evvi/M+ivhfnyxec7AccTpRPccno/rPoNlqybEZQBkcbZu8Hy+eqNJCqfBR8P7Pg8g==", - "cpu": [ - "wasm32" - ], - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "@napi-rs/wasm-runtime": "^1.1.1" - }, - "engines": { - "node": ">=14.0.0" - } - }, - "node_modules/@rolldown/binding-win32-arm64-msvc": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-arm64-msvc/-/binding-win32-arm64-msvc-1.0.0-rc.9.tgz", - "integrity": "sha512-lHVNUG/8nlF1IQk1C0Ci574qKYyty2goMiPlRqkC5R+3LkXDkL5Dhx8ytbxq35m+pkHVIvIxviD+TWLdfeuadA==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/binding-win32-x64-msvc": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/binding-win32-x64-msvc/-/binding-win32-x64-msvc-1.0.0-rc.9.tgz", - "integrity": "sha512-G0oA4+w1iY5AGi5HcDTxWsoxF509hrFIPB2rduV5aDqS9FtDg1CAfa7V34qImbjfhIcA8C+RekocJZA96EarwQ==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MIT", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": "^20.19.0 || >=22.12.0" - } - }, - "node_modules/@rolldown/pluginutils": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/@rolldown/pluginutils/-/pluginutils-1.0.0-rc.9.tgz", - "integrity": "sha512-w6oiRWgEBl04QkFZgmW+jnU1EC9b57Oihi2ot3HNWIQRqgHp5PnYDia5iZ5FF7rpa4EQdiqMDXjlqKGXBhsoXw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@standard-schema/spec": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/@standard-schema/spec/-/spec-1.1.0.tgz", - "integrity": "sha512-l2aFy5jALhniG5HgqrD6jXLi/rUWrKvqN/qJx6yoJsgKhblVd+iqqU4RCXavm/jPityDo5TCvKMnpjKnOriy0w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@tybys/wasm-util": { - "version": "0.10.1", - "resolved": "https://registry.npmjs.org/@tybys/wasm-util/-/wasm-util-0.10.1.tgz", - "integrity": "sha512-9tTaPJLSiejZKx+Bmog4uSubteqTvFrVrURwkmHixBo0G4seD0zUxp98E1DzUBJxLQ3NPwXrGKDiVjwx/DpPsg==", - "dev": true, - "license": "MIT", - "optional": true, - "dependencies": { - "tslib": "^2.4.0" - } - }, - "node_modules/@types/aws-lambda": { - "version": "8.10.161", - "resolved": "https://registry.npmjs.org/@types/aws-lambda/-/aws-lambda-8.10.161.tgz", - "integrity": "sha512-rUYdp+MQwSFocxIOcSsYSF3YYYC/uUpMbCY/mbO21vGqfrEYvNSoPyKYDj6RhXXpPfS0KstW9RwG3qXh9sL7FQ==", - "license": "MIT" - }, - "node_modules/@types/chai": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@types/chai/-/chai-5.2.3.tgz", - "integrity": "sha512-Mw558oeA9fFbv65/y4mHtXDs9bPnFMZAL/jxdPFUpOHHIXX91mcgEHbS5Lahr+pwZFR8A7GQleRWeI6cGFC2UA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/deep-eql": "*", - "assertion-error": "^2.0.1" - } - }, - "node_modules/@types/deep-eql": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/@types/deep-eql/-/deep-eql-4.0.2.tgz", - "integrity": "sha512-c9h9dVVMigMPc4bwTvC5dxqtqJZwQPePsWjPlpSOnojbor6pGqdk541lfA7AqFQr5pB1BRdq0juY9db81BwyFw==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/estree": { - "version": "1.0.8", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.8.tgz", - "integrity": "sha512-dWHzHa2WqEXI/O1E9OjrocMTKJl2mSrEolh1Iomrv6U+JuNwaHXsXx9bLu5gG7BUWFIN0skIQJQ/L1rIex4X6w==", - "dev": true, - "license": "MIT" - }, - "node_modules/@types/node": { - "version": "24.12.0", - "resolved": "https://registry.npmjs.org/@types/node/-/node-24.12.0.tgz", - "integrity": "sha512-GYDxsZi3ChgmckRT9HPU0WEhKLP08ev/Yfcq2AstjrDASOYCSXeyjDsHg4v5t4jOj7cyDX3vmprafKlWIG9MXQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "undici-types": "~7.16.0" - } - }, - "node_modules/@vitest/coverage-v8": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@vitest/coverage-v8/-/coverage-v8-4.1.0.tgz", - "integrity": "sha512-nDWulKeik2bL2Va/Wl4x7DLuTKAXa906iRFooIRPR+huHkcvp9QDkPQ2RJdmjOFrqOqvNfoSQLF68deE3xC3CQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@bcoe/v8-coverage": "^1.0.2", - "@vitest/utils": "4.1.0", - "ast-v8-to-istanbul": "^1.0.0", - "istanbul-lib-coverage": "^3.2.2", - "istanbul-lib-report": "^3.0.1", - "istanbul-reports": "^3.2.0", - "magicast": "^0.5.2", - "obug": "^2.1.1", - "std-env": "^4.0.0-rc.1", - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "@vitest/browser": "4.1.0", - "vitest": "4.1.0" - }, - "peerDependenciesMeta": { - "@vitest/browser": { - "optional": true - } - } - }, - "node_modules/@vitest/expect": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@vitest/expect/-/expect-4.1.0.tgz", - "integrity": "sha512-EIxG7k4wlWweuCLG9Y5InKFwpMEOyrMb6ZJ1ihYu02LVj/bzUwn2VMU+13PinsjRW75XnITeFrQBMH5+dLvCDA==", - "dev": true, - "license": "MIT", - "dependencies": { - "@standard-schema/spec": "^1.1.0", - "@types/chai": "^5.2.2", - "@vitest/spy": "4.1.0", - "@vitest/utils": "4.1.0", - "chai": "^6.2.2", - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/mocker": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@vitest/mocker/-/mocker-4.1.0.tgz", - "integrity": "sha512-evxREh+Hork43+Y4IOhTo+h5lGmVRyjqI739Rz4RlUPqwrkFFDF6EMvOOYjTx4E8Tl6gyCLRL8Mu7Ry12a13Tw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/spy": "4.1.0", - "estree-walker": "^3.0.3", - "magic-string": "^0.30.21" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "msw": "^2.4.9", - "vite": "^6.0.0 || ^7.0.0 || ^8.0.0-0" - }, - "peerDependenciesMeta": { - "msw": { - "optional": true - }, - "vite": { - "optional": true - } - } - }, - "node_modules/@vitest/pretty-format": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@vitest/pretty-format/-/pretty-format-4.1.0.tgz", - "integrity": "sha512-3RZLZlh88Ib0J7NQTRATfc/3ZPOnSUn2uDBUoGNn5T36+bALixmzphN26OUD3LRXWkJu4H0s5vvUeqBiw+kS0A==", - "dev": true, - "license": "MIT", - "dependencies": { - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/runner": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@vitest/runner/-/runner-4.1.0.tgz", - "integrity": "sha512-Duvx2OzQ7d6OjchL+trw+aSrb9idh7pnNfxrklo14p3zmNL4qPCDeIJAK+eBKYjkIwG96Bc6vYuxhqDXQOWpoQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/utils": "4.1.0", - "pathe": "^2.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/snapshot": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@vitest/snapshot/-/snapshot-4.1.0.tgz", - "integrity": "sha512-0Vy9euT1kgsnj1CHttwi9i9o+4rRLEaPRSOJ5gyv579GJkNpgJK+B4HSv/rAWixx2wdAFci1X4CEPjiu2bXIMg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "4.1.0", - "@vitest/utils": "4.1.0", - "magic-string": "^0.30.21", - "pathe": "^2.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/spy": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@vitest/spy/-/spy-4.1.0.tgz", - "integrity": "sha512-pz77k+PgNpyMDv2FV6qmk5ZVau6c3R8HC8v342T2xlFxQKTrSeYw9waIJG8KgV9fFwAtTu4ceRzMivPTH6wSxw==", - "dev": true, - "license": "MIT", - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/@vitest/utils": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/@vitest/utils/-/utils-4.1.0.tgz", - "integrity": "sha512-XfPXT6a8TZY3dcGY8EdwsBulFCIw+BeeX0RZn2x/BtiY/75YGh8FeWGG8QISN/WhaqSrE2OrlDgtF8q5uhOTmw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/pretty-format": "4.1.0", - "convert-source-map": "^2.0.0", - "tinyrainbow": "^3.0.3" - }, - "funding": { - "url": "https://opencollective.com/vitest" - } - }, - "node_modules/ansi-regex": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.2.2.tgz", - "integrity": "sha512-Bq3SmSpyFHaWjPk8If9yc6svM8c56dB5BAtW4Qbw5jHTwwXXcTLoRMkpDJp6VL0XzlWaCHTXrkFURMYmD0sLqg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/chalk/ansi-regex?sponsor=1" - } - }, - "node_modules/ansi-styles": { - "version": "6.2.3", - "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.3.tgz", - "integrity": "sha512-4Dj6M28JB+oAH8kFkTLUo+a2jwOFkuqb3yucU0CANcRRUbxS0cP0nZYCGjcc3BNXwRIsUVmDGgzawme7zvJHvg==", - "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/ast-v8-to-istanbul": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/ast-v8-to-istanbul/-/ast-v8-to-istanbul-1.0.0.tgz", - "integrity": "sha512-1fSfIwuDICFA4LKkCzRPO7F0hzFf0B7+Xqrl27ynQaa+Rh0e1Es0v6kWHPott3lU10AyAr7oKHa65OppjLn3Rg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/trace-mapping": "^0.3.31", - "estree-walker": "^3.0.3", - "js-tokens": "^10.0.0" - } - }, - "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": "4.0.0", - "resolved": "https://registry.npmjs.org/before-after-hook/-/before-after-hook-4.0.0.tgz", - "integrity": "sha512-q6tR3RPqIB1pMiTRMFcZwuG5T8vwp+vUvEG0vuI6B+Rikh5BfPp2fQ82c925FOs+b0lcFQ8CFrL+KbilfZFhOQ==", - "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.2", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.2.tgz", - "integrity": "sha512-Jt0vHyM+jmUBqojB7E1NIYadt0vI0Qxjxd2TErW94wDz+E2LAm5vKMXXwg6ZZBTHPuUlDgQHKXvjGBdfcF1ZDQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "balanced-match": "^1.0.0" - } - }, - "node_modules/chai": { - "version": "6.2.2", - "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", - "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "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/convert-source-map": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-2.0.0.tgz", - "integrity": "sha512-Kvp459HrV2FEJ1CAsi1Ku+MY3kasH19TFykTz2xWmMeq6bk2NU3XXvfJ+Q61m0xktWwt+1HSYf3JZsTms3aRJg==", - "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.3", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.3.tgz", - "integrity": "sha512-RGwwWnwQvkVfavKVt22FGLw+xYSdzARwm0ru6DhTVA3umU5hZc28V3kO4stgYryrTlLpuvgI9GiijltAjNbcqA==", - "dev": true, - "license": "MIT", - "dependencies": { - "ms": "^2.1.3" - }, - "engines": { - "node": ">=6.0" - }, - "peerDependenciesMeta": { - "supports-color": { - "optional": true - } - } - }, - "node_modules/detect-libc": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.1.2.tgz", - "integrity": "sha512-Btj2BOOO83o3WyH59e8MgXsxEQVcarkUOpEYrubB0urwnN10yQ364rsiByU11nZlqWYZm05i/of7io4mzihBtQ==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=8" - } - }, - "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": "2.0.0", - "resolved": "https://registry.npmjs.org/es-module-lexer/-/es-module-lexer-2.0.0.tgz", - "integrity": "sha512-5POEcUuZybH7IdmGsD8wlf0AI55wMecM9rVBTI/qEAy2c1kTOm3DjFYjrBdI2K3BaJjJYfYFeRtM0t9ssnRuxw==", - "dev": true, - "license": "MIT" - }, - "node_modules/esbuild": { - "version": "0.27.4", - "resolved": "https://registry.npmjs.org/esbuild/-/esbuild-0.27.4.tgz", - "integrity": "sha512-Rq4vbHnYkK5fws5NF7MYTU68FPRE1ajX7heQ/8QXXWqNgqqJ/GkmmyxIzUnf2Sr/bakf8l54716CcMGHYhMrrQ==", - "dev": true, - "hasInstallScript": true, - "license": "MIT", - "bin": { - "esbuild": "bin/esbuild" - }, - "engines": { - "node": ">=18" - }, - "optionalDependencies": { - "@esbuild/aix-ppc64": "0.27.4", - "@esbuild/android-arm": "0.27.4", - "@esbuild/android-arm64": "0.27.4", - "@esbuild/android-x64": "0.27.4", - "@esbuild/darwin-arm64": "0.27.4", - "@esbuild/darwin-x64": "0.27.4", - "@esbuild/freebsd-arm64": "0.27.4", - "@esbuild/freebsd-x64": "0.27.4", - "@esbuild/linux-arm": "0.27.4", - "@esbuild/linux-arm64": "0.27.4", - "@esbuild/linux-ia32": "0.27.4", - "@esbuild/linux-loong64": "0.27.4", - "@esbuild/linux-mips64el": "0.27.4", - "@esbuild/linux-ppc64": "0.27.4", - "@esbuild/linux-riscv64": "0.27.4", - "@esbuild/linux-s390x": "0.27.4", - "@esbuild/linux-x64": "0.27.4", - "@esbuild/netbsd-arm64": "0.27.4", - "@esbuild/netbsd-x64": "0.27.4", - "@esbuild/openbsd-arm64": "0.27.4", - "@esbuild/openbsd-x64": "0.27.4", - "@esbuild/openharmony-arm64": "0.27.4", - "@esbuild/sunos-x64": "0.27.4", - "@esbuild/win32-arm64": "0.27.4", - "@esbuild/win32-ia32": "0.27.4", - "@esbuild/win32-x64": "0.27.4" - } - }, - "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.3.0", - "resolved": "https://registry.npmjs.org/expect-type/-/expect-type-1.3.0.tgz", - "integrity": "sha512-knvyeauYhqjOYvQ66MznSMs83wmHrCycNEN6Ao+2AeYEfxUIkuiVxdEa1qlGEPK+We3n0THiDciYSsCcgW/DoA==", - "dev": true, - "license": "Apache-2.0", - "engines": { - "node": ">=12.0.0" - } - }, - "node_modules/fast-content-type-parse": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/fast-content-type-parse/-/fast-content-type-parse-3.0.0.tgz", - "integrity": "sha512-ZvLdcY8P+N8mGQJahJV5G4U88CSvT1rP8ApL6uETe88MBXrBHAkZlSEySdUlyztF7ccb+Znos3TFqaepHxdhBg==", - "funding": [ - { - "type": "github", - "url": "https://github.com/sponsors/fastify" - }, - { - "type": "opencollective", - "url": "https://opencollective.com/fastify" - } - ], - "license": "MIT" - }, - "node_modules/fdir": { - "version": "6.5.0", - "resolved": "https://registry.npmjs.org/fdir/-/fdir-6.5.0.tgz", - "integrity": "sha512-tIbYtZbucOs0BRGqPJkshJUYdL+SDH7dVM8gjy+ERp3WAUjLEFJE+02kanyHtwjWOnwrKYBiwAmM0p4kLJAnXg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12.0.0" - }, - "peerDependencies": { - "picomatch": "^3 || ^4" - }, - "peerDependenciesMeta": { - "picomatch": { - "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": "10.5.0", - "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", - "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", - "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", - "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/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-node-process": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-node-process/-/is-node-process-1.2.0.tgz", - "integrity": "sha512-Vg4o6/fqPxIjtxgUH5QLJhwZ7gW5diGCVlXpuUfELC62CuxM1iHcRe51f2W1FDy04Ai4KJkagKjx3XaqyfRKXw==", - "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-reports": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.2.0.tgz", - "integrity": "sha512-HGYWWS/ehqTV3xN10i23tkPkpH46MLCIMFNCaaKNavAXTF1RkqxawEPtnjnGZ6XKSInBKkiOA5BKS+aZiY3AvA==", - "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": "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/js-tokens": { - "version": "10.0.0", - "resolved": "https://registry.npmjs.org/js-tokens/-/js-tokens-10.0.0.tgz", - "integrity": "sha512-lM/UBzQmfJRo9ABXbPWemivdCW8V2G8FHaHdypQaIy523snUjog0W71ayWXTjiR+ixeMyVHN2XcpnTd/liPg/Q==", - "dev": true, - "license": "MIT" - }, - "node_modules/json-stringify-safe": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz", - "integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==", - "dev": true, - "license": "ISC" - }, - "node_modules/json-with-bigint": { - "version": "3.5.7", - "resolved": "https://registry.npmjs.org/json-with-bigint/-/json-with-bigint-3.5.7.tgz", - "integrity": "sha512-7ei3MdAI5+fJPVnKlW77TKNKwQ5ppSzWvhPuSuINT/GYW9ZOC1eRKOuhV9yHG5aEsUPj9BBx5JIekkmoLHxZOw==", - "license": "MIT" - }, - "node_modules/lightningcss": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss/-/lightningcss-1.32.0.tgz", - "integrity": "sha512-NXYBzinNrblfraPGyrbPoD19C1h9lfI/1mzgWYvXUTe414Gz/X1FD2XBZSZM7rRTrMA8JL3OtAaGifrIKhQ5yQ==", - "dev": true, - "license": "MPL-2.0", - "dependencies": { - "detect-libc": "^2.0.3" - }, - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - }, - "optionalDependencies": { - "lightningcss-android-arm64": "1.32.0", - "lightningcss-darwin-arm64": "1.32.0", - "lightningcss-darwin-x64": "1.32.0", - "lightningcss-freebsd-x64": "1.32.0", - "lightningcss-linux-arm-gnueabihf": "1.32.0", - "lightningcss-linux-arm64-gnu": "1.32.0", - "lightningcss-linux-arm64-musl": "1.32.0", - "lightningcss-linux-x64-gnu": "1.32.0", - "lightningcss-linux-x64-musl": "1.32.0", - "lightningcss-win32-arm64-msvc": "1.32.0", - "lightningcss-win32-x64-msvc": "1.32.0" - } - }, - "node_modules/lightningcss-android-arm64": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-android-arm64/-/lightningcss-android-arm64-1.32.0.tgz", - "integrity": "sha512-YK7/ClTt4kAK0vo6w3X+Pnm0D2cf2vPHbhOXdoNti1Ga0al1P4TBZhwjATvjNwLEBCnKvjJc2jQgHXH0NEwlAg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "android" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-darwin-arm64": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-arm64/-/lightningcss-darwin-arm64-1.32.0.tgz", - "integrity": "sha512-RzeG9Ju5bag2Bv1/lwlVJvBE3q6TtXskdZLLCyfg5pt+HLz9BqlICO7LZM7VHNTTn/5PRhHFBSjk5lc4cmscPQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-darwin-x64": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-darwin-x64/-/lightningcss-darwin-x64-1.32.0.tgz", - "integrity": "sha512-U+QsBp2m/s2wqpUYT/6wnlagdZbtZdndSmut/NJqlCcMLTWp5muCrID+K5UJ6jqD2BFshejCYXniPDbNh73V8w==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "darwin" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-freebsd-x64": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-freebsd-x64/-/lightningcss-freebsd-x64-1.32.0.tgz", - "integrity": "sha512-JCTigedEksZk3tHTTthnMdVfGf61Fky8Ji2E4YjUTEQX14xiy/lTzXnu1vwiZe3bYe0q+SpsSH/CTeDXK6WHig==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "freebsd" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm-gnueabihf": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm-gnueabihf/-/lightningcss-linux-arm-gnueabihf-1.32.0.tgz", - "integrity": "sha512-x6rnnpRa2GL0zQOkt6rts3YDPzduLpWvwAF6EMhXFVZXD4tPrBkEFqzGowzCsIWsPjqSK+tyNEODUBXeeVHSkw==", - "cpu": [ - "arm" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm64-gnu": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-gnu/-/lightningcss-linux-arm64-gnu-1.32.0.tgz", - "integrity": "sha512-0nnMyoyOLRJXfbMOilaSRcLH3Jw5z9HDNGfT/gwCPgaDjnx0i8w7vBzFLFR1f6CMLKF8gVbebmkUN3fa/kQJpQ==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-arm64-musl": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-arm64-musl/-/lightningcss-linux-arm64-musl-1.32.0.tgz", - "integrity": "sha512-UpQkoenr4UJEzgVIYpI80lDFvRmPVg6oqboNHfoH4CQIfNA+HOrZ7Mo7KZP02dC6LjghPQJeBsvXhJod/wnIBg==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-x64-gnu": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-gnu/-/lightningcss-linux-x64-gnu-1.32.0.tgz", - "integrity": "sha512-V7Qr52IhZmdKPVr+Vtw8o+WLsQJYCTd8loIfpDaMRWGUZfBOYEJeyJIkqGIDMZPwPx24pUMfwSxxI8phr/MbOA==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-linux-x64-musl": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-linux-x64-musl/-/lightningcss-linux-x64-musl-1.32.0.tgz", - "integrity": "sha512-bYcLp+Vb0awsiXg/80uCRezCYHNg1/l3mt0gzHnWV9XP1W5sKa5/TCdGWaR/zBM2PeF/HbsQv/j2URNOiVuxWg==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "linux" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-win32-arm64-msvc": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-arm64-msvc/-/lightningcss-win32-arm64-msvc-1.32.0.tgz", - "integrity": "sha512-8SbC8BR40pS6baCM8sbtYDSwEVQd4JlFTOlaD3gWGHfThTcABnNDBda6eTZeqbofalIJhFx0qKzgHJmcPTnGdw==", - "cpu": [ - "arm64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "node_modules/lightningcss-win32-x64-msvc": { - "version": "1.32.0", - "resolved": "https://registry.npmjs.org/lightningcss-win32-x64-msvc/-/lightningcss-win32-x64-msvc-1.32.0.tgz", - "integrity": "sha512-Amq9B/SoZYdDi1kFrojnoqPLxYhQ4Wo5XiL8EVJrVsB8ARoC1PWW6VGtT0WKCemjy8aC+louJnjS7U18x3b06Q==", - "cpu": [ - "x64" - ], - "dev": true, - "license": "MPL-2.0", - "optional": true, - "os": [ - "win32" - ], - "engines": { - "node": ">= 12.0.0" - }, - "funding": { - "type": "opencollective", - "url": "https://opencollective.com/parcel" - } - }, - "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/magic-string": { - "version": "0.30.21", - "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.30.21.tgz", - "integrity": "sha512-vd2F4YUyEXKGcLHoq+TEyCjxueSeHnFxyyjNp80yg0XV4vUhnDer/lvvlqM/arB5bXQN5K2/3oinyCRyx8T2CQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@jridgewell/sourcemap-codec": "^1.5.5" - } - }, - "node_modules/magicast": { - "version": "0.5.2", - "resolved": "https://registry.npmjs.org/magicast/-/magicast-0.5.2.tgz", - "integrity": "sha512-E3ZJh4J3S9KfwdjZhe2afj6R9lGIN5Pher1pF39UGrXRqq/VDaGVIGN13BjHd2u8B61hArAGOnso7nBOouW3TQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "@babel/parser": "^7.29.0", - "@babel/types": "^7.29.0", - "source-map-js": "^1.2.1" - } - }, - "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": "9.0.9", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", - "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", - "dev": true, - "license": "ISC", - "dependencies": { - "brace-expansion": "^2.0.2" - }, - "engines": { - "node": ">=16 || 14 >=14.17" - }, - "funding": { - "url": "https://github.com/sponsors/isaacs" - } - }, - "node_modules/minipass": { - "version": "7.1.3", - "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", - "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", - "dev": true, - "license": "BlueOak-1.0.0", - "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.11", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.11.tgz", - "integrity": "sha512-N8SpfPUnUp1bK+PMYW8qSWdl9U+wwNWI4QKxOYDy9JAro3WMX7p2OeVRF9v+347pnakNevPmiHhNmZ2HbFA76w==", - "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/nock": { - "version": "14.0.11", - "resolved": "https://registry.npmjs.org/nock/-/nock-14.0.11.tgz", - "integrity": "sha512-u5xUnYE+UOOBA6SpELJheMCtj2Laqx15Vl70QxKo43Wz/6nMHXS7PrEioXLjXAwhmawdEMNImwKCcPhBJWbKVw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@mswjs/interceptors": "^0.41.0", - "json-stringify-safe": "^5.0.1", - "propagate": "^2.0.0" - }, - "engines": { - "node": ">=18.20.0 <20 || >=20.12.1" - } - }, - "node_modules/obug": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/obug/-/obug-2.1.1.tgz", - "integrity": "sha512-uTqF9MuPraAQ+IsnPf366RG4cP9RtUi7MLO1N3KEc+wb0a6yKpeL0lmk2IB1jY5KHPAlTc6T/JRdC/YqxHNwkQ==", - "dev": true, - "funding": [ - "https://github.com/sponsors/sxzz", - "https://opencollective.com/debug" - ], - "license": "MIT" - }, - "node_modules/outvariant": { - "version": "1.4.3", - "resolved": "https://registry.npmjs.org/outvariant/-/outvariant-1.4.3.tgz", - "integrity": "sha512-+Sl2UErvtsoajRDKCE5/dBz4DIvHXQQnAxtQTF04OJxY0+DyZXSo5P5Bb7XYWOh81syohlYL24hbDwxedPUJCA==", - "dev": true, - "license": "MIT" - }, - "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": "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/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/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/picomatch": { - "version": "4.0.3", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-4.0.3.tgz", - "integrity": "sha512-5gTmgEY/sqK6gFXLIsQNH19lWb4ebPDLA4SdLP7dsWkIXHWlG66oPuVvXSGFPppYZz8ZDZq0dYYrbHfBCVUb1Q==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=12" - }, - "funding": { - "url": "https://github.com/sponsors/jonschlinkert" - } - }, - "node_modules/postcss": { - "version": "8.5.8", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.5.8.tgz", - "integrity": "sha512-OW/rX8O/jXnm82Ey1k44pObPtdblfiuWnrd8X7GJ7emImCOstunGbXUpp7HdBrFQX6rJzn3sPT397Wp5aCwCHg==", - "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.11", - "picocolors": "^1.1.1", - "source-map-js": "^1.2.1" - }, - "engines": { - "node": "^10 || ^12 || >=14" - } - }, - "node_modules/prettier": { - "version": "3.7.4", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.7.4.tgz", - "integrity": "sha512-v6UNi1+3hSlVvv8fSaoUbggEM5VErKmmpGA7Pl3HF8V6uKY7rvClBOJlH6yNwQtfTueNkGVpOv/mtWL9L4bgRA==", - "dev": true, - "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, - "node_modules/propagate": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/propagate/-/propagate-2.0.1.tgz", - "integrity": "sha512-vGrhOavPSTz4QVNuBNdcNXePNdNMaO1xj9yBeH1ScQPjk/rhg9sSlCXPhMkFuaNNW/syTvYqsnbIJxMBfRbbag==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">= 8" - } - }, - "node_modules/rolldown": { - "version": "1.0.0-rc.9", - "resolved": "https://registry.npmjs.org/rolldown/-/rolldown-1.0.0-rc.9.tgz", - "integrity": "sha512-9EbgWge7ZH+yqb4d2EnELAntgPTWbfL8ajiTW+SyhJEC4qhBbkCKbqFV4Ge4zmu5ziQuVbWxb/XwLZ+RIO7E8Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@oxc-project/types": "=0.115.0", - "@rolldown/pluginutils": "1.0.0-rc.9" - }, - "bin": { - "rolldown": "bin/cli.mjs" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "optionalDependencies": { - "@rolldown/binding-android-arm64": "1.0.0-rc.9", - "@rolldown/binding-darwin-arm64": "1.0.0-rc.9", - "@rolldown/binding-darwin-x64": "1.0.0-rc.9", - "@rolldown/binding-freebsd-x64": "1.0.0-rc.9", - "@rolldown/binding-linux-arm-gnueabihf": "1.0.0-rc.9", - "@rolldown/binding-linux-arm64-gnu": "1.0.0-rc.9", - "@rolldown/binding-linux-arm64-musl": "1.0.0-rc.9", - "@rolldown/binding-linux-ppc64-gnu": "1.0.0-rc.9", - "@rolldown/binding-linux-s390x-gnu": "1.0.0-rc.9", - "@rolldown/binding-linux-x64-gnu": "1.0.0-rc.9", - "@rolldown/binding-linux-x64-musl": "1.0.0-rc.9", - "@rolldown/binding-openharmony-arm64": "1.0.0-rc.9", - "@rolldown/binding-wasm32-wasi": "1.0.0-rc.9", - "@rolldown/binding-win32-arm64-msvc": "1.0.0-rc.9", - "@rolldown/binding-win32-x64-msvc": "1.0.0-rc.9" - } - }, - "node_modules/semantic-release-plugin-update-version-in-files": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/semantic-release-plugin-update-version-in-files/-/semantic-release-plugin-update-version-in-files-2.0.1.tgz", - "integrity": "sha512-yKPIKFfUOF89vdXkQDDU4D7Ondewn9VNdaW0WHBEhk5iGzDkZKPTDh5d9H4Y/I0s76il4EU00PXktPZWsO6I4A==", - "dev": true, - "license": "ISC", - "dependencies": { - "debug": "^4.1.1", - "glob": "^10.0.0" - }, - "engines": { - "node": ">=18" - } - }, - "node_modules/semver": { - "version": "7.7.4", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.7.4.tgz", - "integrity": "sha512-vFKC2IEtQnVhpT78h1Yp8wzwrf8CM+MzKMHGJZfBtzhZNycRFnXsHk6E5TxIkkMsgNS7mdX3AGB7x2QM2di4lA==", - "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": "4.0.0", - "resolved": "https://registry.npmjs.org/std-env/-/std-env-4.0.0.tgz", - "integrity": "sha512-zUMPtQ/HBY3/50VbpkupYHbRroTRZJPRLvreamgErJVys0ceuzMkD44J/QjqhHjOzK42GQ3QZIeFG1OYfOtKqQ==", - "dev": true, - "license": "MIT" - }, - "node_modules/strict-event-emitter": { - "version": "0.5.1", - "resolved": "https://registry.npmjs.org/strict-event-emitter/-/strict-event-emitter-0.5.1.tgz", - "integrity": "sha512-vMgjE/GGEPEFnhFub6pa4FmJBRBVOLpIII2hvCZ8Kzb7K0hlHo7mQv6xYrBvCL2LtAIBwFUK8wvuJgTVSQ5MFQ==", - "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.2.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.2.0.tgz", - "integrity": "sha512-yDPMNjp4WyfYBkHnjIRLfca1i6KMyGCtsVgoKe/z1+6vukgaENdgGBZt+ZmKPc4gavvEZ5OgHfHdrazhgNyG7w==", - "dev": true, - "license": "MIT", - "dependencies": { - "ansi-regex": "^6.2.2" - }, - "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/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": "1.0.2", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.0.2.tgz", - "integrity": "sha512-W/KYk+NFhkmsYpuHq5JykngiOCnxeVL8v8dFnqxSD8qEEdRfXk1SDM6JzNqcERbcGYj9tMrDQBYV9cjgnunFIg==", - "dev": true, - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "node_modules/tinyglobby": { - "version": "0.2.15", - "resolved": "https://registry.npmjs.org/tinyglobby/-/tinyglobby-0.2.15.tgz", - "integrity": "sha512-j2Zq4NyQYG5XMST4cbs02Ak8iJUdxRM0XI5QyxXuZOzKOINmWurp3smXu3y5wDcJrptwpSjgXHzIQxR0omXljQ==", - "dev": true, - "license": "MIT", - "dependencies": { - "fdir": "^6.5.0", - "picomatch": "^4.0.3" - }, - "engines": { - "node": ">=12.0.0" - }, - "funding": { - "url": "https://github.com/sponsors/SuperchupuDev" - } - }, - "node_modules/tinyrainbow": { - "version": "3.1.0", - "resolved": "https://registry.npmjs.org/tinyrainbow/-/tinyrainbow-3.1.0.tgz", - "integrity": "sha512-Bf+ILmBgretUrdJxzXM0SgXLZ3XfiaUuOj/IKQHuTXip+05Xn+uyEYdVg0kYDipTBcLrCVyUzAPz7QmArb0mmw==", - "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/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "dev": true, - "license": "0BSD", - "optional": true - }, - "node_modules/typescript": { - "version": "5.9.3", - "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.9.3.tgz", - "integrity": "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw==", - "dev": true, - "license": "Apache-2.0", - "bin": { - "tsc": "bin/tsc", - "tsserver": "bin/tsserver" - }, - "engines": { - "node": ">=14.17" - } - }, - "node_modules/undici-types": { - "version": "7.16.0", - "resolved": "https://registry.npmjs.org/undici-types/-/undici-types-7.16.0.tgz", - "integrity": "sha512-Zz+aZWSj8LE6zoxD+xrjh4VfkIG8Ya6LvYkZqtUQGJPZjYl53ypCaUwWqo7eI0x66KBGeRo+mlBEkMSeSZ38Nw==", - "dev": true, - "license": "MIT" - }, - "node_modules/universal-github-app-jwt": { - "version": "2.2.2", - "resolved": "https://registry.npmjs.org/universal-github-app-jwt/-/universal-github-app-jwt-2.2.2.tgz", - "integrity": "sha512-dcmbeSrOdTnsjGjUfAlqNDJrhxXizjAz94ija9Qw8YkZ1uu0d+GoZzyH+Jb9tIIqvGsadUfwg+22k5aDqqwzbw==", - "license": "MIT" - }, - "node_modules/universal-user-agent": { - "version": "7.0.3", - "resolved": "https://registry.npmjs.org/universal-user-agent/-/universal-user-agent-7.0.3.tgz", - "integrity": "sha512-TmnEAEAsBJVZM/AADELsK76llnwcf9vMKuPz8JflO1frO8Lchitr0fNaN9d+Ap0BjKtqWqd/J17qeDnXh8CL2A==", - "license": "ISC" - }, - "node_modules/vite": { - "version": "8.0.0", - "resolved": "https://registry.npmjs.org/vite/-/vite-8.0.0.tgz", - "integrity": "sha512-fPGaRNj9Zytaf8LEiBhY7Z6ijnFKdzU/+mL8EFBaKr7Vw1/FWcTBAMW0wLPJAGMPX38ZPVCVgLceWiEqeoqL2Q==", - "dev": true, - "license": "MIT", - "dependencies": { - "@oxc-project/runtime": "0.115.0", - "lightningcss": "^1.32.0", - "picomatch": "^4.0.3", - "postcss": "^8.5.8", - "rolldown": "1.0.0-rc.9", - "tinyglobby": "^0.2.15" - }, - "bin": { - "vite": "bin/vite.js" - }, - "engines": { - "node": "^20.19.0 || >=22.12.0" - }, - "funding": { - "url": "https://github.com/vitejs/vite?sponsor=1" - }, - "optionalDependencies": { - "fsevents": "~2.3.3" - }, - "peerDependencies": { - "@types/node": "^20.19.0 || >=22.12.0", - "@vitejs/devtools": "^0.0.0-alpha.31", - "esbuild": "^0.27.0", - "jiti": ">=1.21.0", - "less": "^4.0.0", - "sass": "^1.70.0", - "sass-embedded": "^1.70.0", - "stylus": ">=0.54.8", - "sugarss": "^5.0.0", - "terser": "^5.16.0", - "tsx": "^4.8.1", - "yaml": "^2.4.2" - }, - "peerDependenciesMeta": { - "@types/node": { - "optional": true - }, - "@vitejs/devtools": { - "optional": true - }, - "esbuild": { - "optional": true - }, - "jiti": { - "optional": true - }, - "less": { - "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/vitest": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/vitest/-/vitest-4.1.0.tgz", - "integrity": "sha512-YbDrMF9jM2Lqc++2530UourxZHmkKLxrs4+mYhEwqWS97WJ7wOYEkcr+QfRgJ3PW9wz3odRijLZjHEaRLTNbqw==", - "dev": true, - "license": "MIT", - "dependencies": { - "@vitest/expect": "4.1.0", - "@vitest/mocker": "4.1.0", - "@vitest/pretty-format": "4.1.0", - "@vitest/runner": "4.1.0", - "@vitest/snapshot": "4.1.0", - "@vitest/spy": "4.1.0", - "@vitest/utils": "4.1.0", - "es-module-lexer": "^2.0.0", - "expect-type": "^1.3.0", - "magic-string": "^0.30.21", - "obug": "^2.1.1", - "pathe": "^2.0.3", - "picomatch": "^4.0.3", - "std-env": "^4.0.0-rc.1", - "tinybench": "^2.9.0", - "tinyexec": "^1.0.2", - "tinyglobby": "^0.2.15", - "tinyrainbow": "^3.0.3", - "vite": "^6.0.0 || ^7.0.0 || ^8.0.0-0", - "why-is-node-running": "^2.3.0" - }, - "bin": { - "vitest": "vitest.mjs" - }, - "engines": { - "node": "^20.0.0 || ^22.0.0 || >=24.0.0" - }, - "funding": { - "url": "https://opencollective.com/vitest" - }, - "peerDependencies": { - "@edge-runtime/vm": "*", - "@opentelemetry/api": "^1.9.0", - "@types/node": "^20.0.0 || ^22.0.0 || >=24.0.0", - "@vitest/browser-playwright": "4.1.0", - "@vitest/browser-preview": "4.1.0", - "@vitest/browser-webdriverio": "4.1.0", - "@vitest/ui": "4.1.0", - "happy-dom": "*", - "jsdom": "*", - "vite": "^6.0.0 || ^7.0.0 || ^8.0.0-0" - }, - "peerDependenciesMeta": { - "@edge-runtime/vm": { - "optional": true - }, - "@opentelemetry/api": { - "optional": true - }, - "@types/node": { - "optional": true - }, - "@vitest/browser-playwright": { - "optional": true - }, - "@vitest/browser-preview": { - "optional": true - }, - "@vitest/browser-webdriverio": { - "optional": true - }, - "@vitest/ui": { - "optional": true - }, - "happy-dom": { - "optional": true - }, - "jsdom": { - "optional": true - }, - "vite": { - "optional": false - } - } - }, - "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 7fe7939fab..2cf492ad6f 100644 --- a/package.json +++ b/package.json @@ -1,91 +1,31 @@ { - "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": "^16.1.2", - "@octokit/core": "^7.0.6", - "@octokit/oauth-app": "^8.0.3", - "@octokit/plugin-paginate-graphql": "^6.0.0", - "@octokit/plugin-paginate-rest": "^14.0.0", - "@octokit/plugin-rest-endpoint-methods": "^17.0.0", - "@octokit/plugin-retry": "^8.0.3", - "@octokit/plugin-throttling": "^11.0.3", - "@octokit/request-error": "^7.0.2", - "@octokit/types": "^16.0.0", - "@octokit/webhooks": "^14.0.0" - }, - "devDependencies": { - "@octokit/tsconfig": "^4.0.0", - "@types/node": "^24.0.0", - "@vitest/coverage-v8": "^4.0.0", - "esbuild": "^0.27.0", - "mockdate": "^3.0.5", - "nock": "^14.0.10", - "prettier": "3.7.4", - "semantic-release-plugin-update-version-in-files": "^2.0.0", - "tinyglobby": "^0.2.15", - "typescript": "^5.0.0", - "vitest": "^4.0.0" - }, - "release": { - "branches": [ - "+([0-9]).x", - "main", - "next", - { - "name": "beta", - "prerelease": true - }, - { - "name": "debug", - "prerelease": true - } + "name" : "github", + "version" : "0.2.1", + "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" } ], - "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": ">= 20" - }, - "publishConfig": { - "provenance": true - } + "homepage": "http://github.com/mikedeboer/node-github", + "repository" : { + "type" : "git", + "url" : "http://github.com/mikedeboer/node-github.git" + }, + "engine" : { + "node": ">=0.4.0" + }, + "devDependencies": { + "oauth": "~0.9.7", + "optimist": "~0.6.0", + "mocha": "~1.13.0" + }, + "main" : ".", + "scripts": { + "test": "node ./test/all.js" + }, + "licenses": [{ + "type": "The MIT License", + "url": "http://www.opensource.org/licenses/mit-license.php" + }] } diff --git a/scripts/build.mjs b/scripts/build.mjs deleted file mode 100644 index 84f9d4826a..0000000000 --- a/scripts/build.mjs +++ /dev/null @@ -1,83 +0,0 @@ -// @ts-check -import esbuild from "esbuild"; -import { copyFile, readFile, writeFile, rm } from "node:fs/promises"; -import { glob } from "tinyglobby"; - -/** - * @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 new file mode 100644 index 0000000000..13ef4c04e0 --- /dev/null +++ b/seed.yml @@ -0,0 +1,5 @@ +--- + name: node-github + description: NodeJS wrapper for the GitHub API + tags: git github web + version: 0.2.1 diff --git a/src/app.ts b/src/app.ts deleted file mode 100644 index fc5998f448..0000000000 --- a/src/app.ts +++ /dev/null @@ -1,12 +0,0 @@ -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 deleted file mode 100644 index 2c566b5ba7..0000000000 --- a/src/index.ts +++ /dev/null @@ -1,3 +0,0 @@ -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 deleted file mode 100644 index b4451a45e3..0000000000 --- a/src/octokit.ts +++ /dev/null @@ -1,65 +0,0 @@ -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 next no need to test internals of the throttle plugin -- @preserve */ -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; - } -} - -/* v8 ignore next no need to test internals of the throttle plugin -- @preserve */ -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 deleted file mode 100644 index 86383b116d..0000000000 --- a/src/version.ts +++ /dev/null @@ -1 +0,0 @@ -export const VERSION = "0.0.0-development"; diff --git a/templates/after_request.js.tpl b/templates/after_request.js.tpl new file mode 100644 index 0000000000..646272d58d --- /dev/null +++ b/templates/after_request.js.tpl @@ -0,0 +1,9 @@ + + if (!ret) + ret = {}; + 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 new file mode 100644 index 0000000000..0feb4e7fff --- /dev/null +++ b/templates/handler.js.tpl @@ -0,0 +1,21 @@ +<%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 && JSON.parse(res.data); + } + 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 new file mode 100644 index 0000000000..b5a585ff41 --- /dev/null +++ b/templates/index.js.tpl @@ -0,0 +1,40 @@ +/** + * 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 new file mode 100644 index 0000000000..82a7c5ea58 --- /dev/null +++ b/templates/section.js.tpl @@ -0,0 +1,23 @@ +/** + * 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 new file mode 100644 index 0000000000..f6287660a9 --- /dev/null +++ b/templates/test_handler.js.tpl @@ -0,0 +1,10 @@ + 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 new file mode 100644 index 0000000000..bde8fbfec0 --- /dev/null +++ b/templates/test_section.js.tpl @@ -0,0 +1,30 @@ +/* + * 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 deleted file mode 100644 index d43bd5b32e..0000000000 --- a/test/app.test.ts +++ /dev/null @@ -1,217 +0,0 @@ -import { beforeEach, describe, expect, test } from "vitest"; -import { createServer } from "node:http"; - -import nock from "nock"; -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; - const mock = nock("https://api.github.com"); - - beforeEach(() => { - MockDate.set(0); - nock.cleanAll(); - - app = new App({ - appId: APP_ID, - privateKey: PRIVATE_KEY, - oauth: { - clientId: CLIENT_ID, - clientSecret: CLIENT_SECRET, - }, - webhooks: { - secret: WEBHOOK_SECRET, - }, - Octokit: Octokit.defaults({ - throttle: { enabled: false }, - }), - }); - }); - - test("Readme example: `app.eachRepository.iterator`", async () => { - mock - .get("/app/installations", undefined, { - reqheaders: { authorization: `bearer ${BEARER}` }, - }) - .reply(200, [{ id: 123 }]); - mock - .post("/app/installations/123/access_tokens", undefined, { - reqheaders: { authorization: `bearer ${BEARER}` }, - }) - .reply(200, { - token: "secret123", - expires_at: "1970-01-01T01:00:00.000Z", - permissions: { - metadata: "read", - }, - repository_selection: "all", - }); - mock.get("/installation/repositories").reply(200, { - total_count: 1, - repositories: [ - { - owner: { login: "octokit" }, - name: "octokit.js", - full_name: "octokit/octokit.js", - }, - ], - }); - mock - .post("/repos/octokit/octokit.js/dispatches", { - event_type: "my_event", - client_payload: { foo: "bar" }, - }) - .reply(204); - - 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.isDone()).toBe(true); - }); - - test("README example: app.getInstallationOctokit", async () => { - mock - .post("/app/installations/123/access_tokens", undefined, { - reqheaders: { authorization: `bearer ${BEARER}` }, - }) - .reply(200, { - token: "secret123", - expires_at: "1970-01-01T01:00:00.000Z", - permissions: { - metadata: "read", - }, - repository_selection: "all", - }); - mock - .post("/repos/octokit/octokit.js/issues", { title: "Hello, world!" }) - .reply(201, { id: 1 }); - - 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.isDone()).toBe(true); - }); - - test("README example: createNodeMiddleware(app)", async () => { - expect.assertions(3); - - mock - .post("/app/installations/123/access_tokens", undefined, { - reqheaders: { authorization: `bearer ${BEARER}` }, - }) - .reply(200, { - token: "secret123", - expires_at: "1970-01-01T01:00:00.000Z", - permissions: { - metadata: "read", - }, - repository_selection: "all", - }); - mock - .post("/repos/octokit/octokit.js/issues/1/comments", { - body: "Hello, World!", - }) - .reply(200, { body: 1 }); - - 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.isDone()).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 new file mode 100644 index 0000000000..85305895ba --- /dev/null +++ b/test/client_test.js @@ -0,0 +1,62 @@ +/* + * 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 new file mode 100644 index 0000000000..4c28886244 --- /dev/null +++ b/test/example.js @@ -0,0 +1,37 @@ +/** 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 new file mode 100644 index 0000000000..3fbeadd663 --- /dev/null +++ b/test/oauth.js @@ -0,0 +1,95 @@ +/** 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 new file mode 100644 index 0000000000..1a2e7cf73b --- /dev/null +++ b/test/oauth_server.js @@ -0,0 +1,59 @@ +"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 deleted file mode 100644 index 2cb104f7de..0000000000 --- a/test/smoke.test.ts +++ /dev/null @@ -1,69 +0,0 @@ -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 deleted file mode 100644 index 5e8dc24879..0000000000 --- a/test/tsconfig.test.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "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 deleted file mode 100644 index acd0540edf..0000000000 --- a/test/typescript-validate.ts +++ /dev/null @@ -1,43 +0,0 @@ -// ************************************************************ -// 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 deleted file mode 100644 index afade4c1bc..0000000000 --- a/tsconfig.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "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 new file mode 100644 index 0000000000..7d536d6a1a --- /dev/null +++ b/util.js @@ -0,0 +1,140 @@ +/** 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 deleted file mode 100644 index 516c9dfe3c..0000000000 --- a/vite.config.js +++ /dev/null @@ -1,13 +0,0 @@ -import { defineConfig } from "vite"; - -export default defineConfig({ - test: { - coverage: { - include: ["src/**/*.ts"], - reporter: ["html"], - thresholds: { - 100: true, - }, - }, - }, -});