From da5671f085d2c840537564486423ca03759eb227 Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 28 May 2022 17:06:30 +0200 Subject: [PATCH 1/8] docs: updated code of conduct to the lates version of the contributors covenant --- CODE_OF_CONDUCT.md | 152 +++++++++++++++++++++++++++++++-------------- 1 file changed, 105 insertions(+), 47 deletions(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 7f81ae4c..ac813664 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -1,74 +1,132 @@ -# Contributor Covenant Code of Conduct +# 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. +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. ## Our Standards -Examples of behavior that contributes to creating a positive environment -include: +Examples of behavior that contributes to a positive environment for our +community 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 +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community -Examples of unacceptable behavior by participants include: +Examples of unacceptable behavior include: -* The use of sexualized language or imagery and unwelcome sexual attention or -advances -* Trolling, insulting/derogatory comments, and personal or political attacks +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or 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 +* Publishing others' private information, such as a physical or email address, + without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting -## Our Responsibilities +## Enforcement 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. +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. -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. +Community leaders 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, and will communicate reasons for moderation +decisions when appropriate. ## 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. +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official e-mail address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. ## Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be -reported by contacting the project team at mzabriskie@gmail.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. +reported to the community leaders responsible for enforcement at +[INSERT CONTACT METHOD]. +All complaints will be reviewed and investigated promptly and fairly. -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. +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +## Enforcement Guidelines + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +### 1. Correction + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +### 2. Warning + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +### 3. Temporary Ban + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +### 4. Permanent Ban + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, -available at [http://contributor-covenant.org/version/1/4][version] +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. -[homepage]: http://contributor-covenant.org -[version]: http://contributor-covenant.org/version/1/4/ \ No newline at end of file +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. + +For answers to common questions about this code of conduct, see the FAQ at +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations From a7f24f8eb4b4d52f7dc259ebbe32b222300b033d Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 28 May 2022 17:09:53 +0200 Subject: [PATCH 2/8] docs: fixed markdown issues in changelog --- CHANGELOG.md | 138 +++++++++++++++++++++++++++++---------------------- 1 file changed, 80 insertions(+), 58 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c1995993..0a18f94f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,21 +1,24 @@ # Changelog -### 0.27.2 (April 27, 2022) +## 0.27.2 (April 27, 2022) Fixes and Functionality: + - Fixed FormData posting in browser environment by reverting #3785 ([#4640](https://github.com/axios/axios/pull/4640)) - Enhanced protocol parsing implementation ([#4639](https://github.com/axios/axios/pull/4639)) - Fixed bundle size -### 0.27.1 (April 26, 2022) +## 0.27.1 (April 26, 2022) Fixes and Functionality: + - Removed import of url module in browser build due to huge size overhead and builds being broken ([#4594](https://github.com/axios/axios/pull/4594)) - Bumped follow-redirects to ^1.14.9 ([#4615](https://github.com/axios/axios/pull/4615)) -### 0.27.0 (April 25, 2022) +## 0.27.0 (April 25, 2022) Breaking changes: + - New toFormData helper function that allows the implementor to pass an object and allow axios to convert it to FormData ([#3757](https://github.com/axios/axios/pull/3757)) - Removed functionality that removed the the `Content-Type` request header when passing FormData ([#3785](https://github.com/axios/axios/pull/3785)) - **(*)** Refactored error handling implementing AxiosError as a constructor, this is a large change to error handling on the whole ([#3645](https://github.com/axios/axios/pull/3645)) @@ -23,29 +26,36 @@ Breaking changes: - **(*)** Improved and fixed multiple issues with FormData support ([#4448](https://github.com/axios/axios/pull/4448)) QOL and DevX improvements: + - Added a multipart/form-data testing playground allowing contributors to debug changes easily ([#4465](https://github.com/axios/axios/pull/4465)) Fixes and Functionality: + - Refactored project file structure to avoid circular imports ([#4515](https://github.com/axios/axios/pull/4516)) & ([#4516](https://github.com/axios/axios/pull/4516)) - Bumped follow-redirects to ^1.14.9 ([#4562](https://github.com/axios/axios/pull/4562)) Internal and Tests: + - Updated dev dependencies to latest version Documentation: + - Fixing incorrect link in changelog ([#4551](https://github.com/axios/axios/pull/4551)) Notes: + - **(*)** Please read these pull requests before updating, these changes are very impactful and far reaching. -### 0.26.1 (March 9, 2022) +## 0.26.1 (March 9, 2022) Fixes and Functionality: + - Refactored project file structure to avoid circular imports ([#4220](https://github.com/axios/axios/pull/4220)) -### 0.26.0 (February 13, 2022) +## 0.26.0 (February 13, 2022) Fixes and Functionality: + - Fixed The timeoutErrorMessage property in config not work with Node.js ([#3581](https://github.com/axios/axios/pull/3581)) - Added errors to be displayed when the query parsing process itself fails ([#3961](https://github.com/axios/axios/pull/3961)) - Fix/remove url required ([#4426](https://github.com/axios/axios/pull/4426)) @@ -53,9 +63,10 @@ Fixes and Functionality: - Bump karma from 6.3.11 to 6.3.14 ([#4461](https://github.com/axios/axios/pull/4461)) - Bump follow-redirects from 1.14.7 to 1.14.8 ([#4473](https://github.com/axios/axios/pull/4473)) -### 0.25.0 (January 18, 2022) +## 0.25.0 (January 18, 2022) Breaking changes: + - Fixing maxBodyLength enforcement ([#3786](https://github.com/axios/axios/pull/3786)) - Don't rely on strict mode behavior for arguments ([#3470](https://github.com/axios/axios/pull/3470)) - Adding error handling when missing url ([#3791](https://github.com/axios/axios/pull/3791)) @@ -64,6 +75,7 @@ Breaking changes: - Adding error handling inside stream end callback ([#3967](https://github.com/axios/axios/pull/3967)) Fixes and Functionality: + - Added aborted even handler ([#3916](https://github.com/axios/axios/pull/3916)) - Header types expanded allowing `boolean` and `number` types ([#4144](https://github.com/axios/axios/pull/4144)) - Fix cancel signature allowing cancel message to be `undefined` ([#3153](https://github.com/axios/axios/pull/3153)) @@ -74,12 +86,14 @@ Fixes and Functionality: - Adding responseEncoding prop type in AxiosRequestConfig ([#3918](https://github.com/axios/axios/pull/3918)) Internal and Tests: + - Adding axios-test-instance to ecosystem ([#3496](https://github.com/axios/axios/pull/3496)) - Optimize the logic of isAxiosError ([#3546](https://github.com/axios/axios/pull/3546)) - Add tests and documentation to display how multiple inceptors work ([#3564](https://github.com/axios/axios/pull/3564)) - Updating follow-redirects to version 1.14.7 ([#4379](https://github.com/axios/axios/pull/4379)) Documentation: + - Fixing changelog to show correct pull request ([#4219](https://github.com/axios/axios/pull/4219)) - Update upgrade guide for https proxy setting ([#3604](https://github.com/axios/axios/pull/3604)) @@ -107,9 +121,10 @@ Huge thanks to everyone who contributed to this release via code (authors listed - [Daniel](https://github.com/djs113) - [Gustavo Sales](https://github.com/gussalesdev) -### 0.24.0 (October 25, 2021) +## 0.24.0 (October 25, 2021) Breaking changes: + - Revert: change type of AxiosResponse to any, please read lengthy discussion here: ([#4141](https://github.com/axios/axios/issues/4141)) pull request: ([#4186](https://github.com/axios/axios/pull/4186)) Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: @@ -119,25 +134,29 @@ Huge thanks to everyone who contributed to this release via code (authors listed - [Remco Haszing](https://github.com/remcohaszing) - [Isaiah Thomason](https://github.com/ITenthusiasm) -### 0.23.0 (October 12, 2021) +## 0.23.0 (October 12, 2021) Breaking changes: + - Distinguish request and response data types ([#4116](https://github.com/axios/axios/pull/4116)) - Change never type to unknown ([#4142](https://github.com/axios/axios/pull/4142)) - Fixed TransitionalOptions typings ([#4147](https://github.com/axios/axios/pull/4147)) Fixes and Functionality: + - Adding globalObject: 'this' to webpack config ([#3176](https://github.com/axios/axios/pull/3176)) - Adding insecureHTTPParser type to AxiosRequestConfig ([#4066](https://github.com/axios/axios/pull/4066)) - Fix missing semicolon in typings ([#4115](https://github.com/axios/axios/pull/4115)) - Fix response headers types ([#4136](https://github.com/axios/axios/pull/4136)) Internal and Tests: + - Improve timeout error when timeout is browser default ([#3209](https://github.com/axios/axios/pull/3209)) - Fix node version on CI ([#4069](https://github.com/axios/axios/pull/4069)) - Added testing to TypeScript portion of project ([#4140](https://github.com/axios/axios/pull/4140)) Documentation: + - Rename Angular to AngularJS ([#4114](https://github.com/axios/axios/pull/4114)) Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: @@ -151,9 +170,10 @@ Huge thanks to everyone who contributed to this release via code (authors listed - [Evgeniy](https://github.com/egmen) - [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) -### 0.22.0 (October 01, 2021) +## 0.22.0 (October 01, 2021) Fixes and Functionality: + - Caseless header comparing in HTTP adapter ([#2880](https://github.com/axios/axios/pull/2880)) - Avoid package.json import fixing issues and warnings related to this ([#4041](https://github.com/axios/axios/pull/4041)), ([#4065](https://github.com/axios/axios/pull/4065)) - Fixed cancelToken leakage and added AbortController support ([#3305](https://github.com/axios/axios/pull/3305)) @@ -168,9 +188,10 @@ Huge thanks to everyone who contributed to this release via code (authors listed - [Xianming Zhong](https://github.com/chinesedfan) - [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) -### 0.21.4 (September 6, 2021) +## 0.21.4 (September 6, 2021) Fixes and Functionality: + - Fixing JSON transform when data is stringified. Providing backward compatibility and complying to the JSON RFC standard ([#4020](https://github.com/axios/axios/pull/4020)) Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: @@ -180,9 +201,10 @@ Huge thanks to everyone who contributed to this release via code (authors listed - [Yusuke Kawasaki](https://github.com/kawanet) - [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) -### 0.21.3 (September 4, 2021) +## 0.21.3 (September 4, 2021) Fixes and Functionality: + - Fixing response interceptor not being called when request interceptor is attached ([#4013](https://github.com/axios/axios/pull/4013)) Huge thanks to everyone who contributed to this release via code (authors listed below) or via reviews and triaging on GitHub: @@ -190,7 +212,7 @@ Huge thanks to everyone who contributed to this release via code (authors listed - [Jay](mailto:jasonsaayman@gmail.com) - [Julian Hollmann](https://github.com/nerdbeere) -### 0.21.2 (September 4, 2021) +## 0.21.2 (September 4, 2021) Fixes and Functionality: @@ -259,7 +281,7 @@ Huge thanks to everyone who contributed to this release via code (authors listed - [Matt Czapliński](https://github.com/MattCCC) - [Ziding Zhang](https://github.com/zidingz) -### 0.21.1 (December 21, 2020) +## 0.21.1 (December 21, 2020) Fixes and Functionality: @@ -282,7 +304,7 @@ Huge thanks to everyone who contributed to this release via code (authors listed - Remco Haszing - Xianming Zhong -### 0.21.0 (October 23, 2020) +## 0.21.0 (October 23, 2020) Fixes and Functionality: @@ -312,11 +334,11 @@ Huge thanks to everyone who contributed to this release via code (authors listed - Tim Gates - Xianming Zhong -### 0.20.0 (August 20, 2020) +## 0.20.0 (August 20, 2020) Release of 0.20.0-pre as a full release with no other changes. -### 0.20.0-pre (July 15, 2020) +## 0.20.0-pre (July 15, 2020) Fixes and Functionality: @@ -531,11 +553,11 @@ below) or via reviews and triaging on GitHub: - Yasu Flores - Zac Delventhal -### 0.19.2 (Jan 20, 2020) +## 0.19.2 (Jan 20, 2020) - Remove unnecessary XSS check ([#2679](https://github.com/axios/axios/pull/2679)) (see ([#2646](https://github.com/axios/axios/issues/2646)) for discussion) -### 0.19.1 (Jan 7, 2020) +## 0.19.1 (Jan 7, 2020) Fixes and Functionality: @@ -591,7 +613,7 @@ Documentation: - Fix grammar in README.md ([#2271](https://github.com/axios/axios/pull/2271)) - Doc fixes, minor examples cleanup ([#2198](https://github.com/axios/axios/pull/2198)) -### 0.19.0 (May 30, 2019) +## 0.19.0 (May 30, 2019) Fixes and Functionality: @@ -630,11 +652,11 @@ Documentation: - Add react-hooks-axios to Libraries section of ECOSYSTEM.md ([#1925](https://github.com/axios/axios/pull/1925)) - Cody Chan - Clarify in README that default timeout is 0 (no timeout) ([#1750](https://github.com/axios/axios/pull/1750)) - Ben Standefer -### 0.19.0-beta.1 (Aug 9, 2018) +## 0.19.0-beta.1 (Aug 9, 2018) **NOTE:** This is a beta version of this release. There may be functionality that is broken in certain browsers, though we suspect that builds are hanging and not erroring. See -https://saucelabs.com/u/axios for the most up-to-date information. + for the most up-to-date information. New Functionality: @@ -699,7 +721,7 @@ below) or via reviews and triaging on GitHub: - Tim Johns - Yutaro Miyazaki -### 0.18.0 (Feb 19, 2018) +## 0.18.0 (Feb 19, 2018) - Adding support for UNIX Sockets when running with Node.js ([#1070](https://github.com/axios/axios/pull/1070)) - Fixing typings ([#1177](https://github.com/axios/axios/pull/1177)): @@ -709,32 +731,32 @@ below) or via reviews and triaging on GitHub: - Allowing maxContentLength to pass through to redirected calls as maxBodyLength in follow-redirects config ([#1287](https://github.com/axios/axios/pull/1287)) - Fixing configuration when using an instance - method can now be set ([#1342](https://github.com/axios/axios/pull/1342)) -### 0.17.1 (Nov 11, 2017) +## 0.17.1 (Nov 11, 2017) - Fixing issue with web workers ([#1160](https://github.com/axios/axios/pull/1160)) - Allowing overriding transport ([#1080](https://github.com/axios/axios/pull/1080)) - Updating TypeScript typings ([#1165](https://github.com/axios/axios/pull/1165), [#1125](https://github.com/axios/axios/pull/1125), [#1131](https://github.com/axios/axios/pull/1131)) -### 0.17.0 (Oct 21, 2017) +## 0.17.0 (Oct 21, 2017) - **BREAKING** Fixing issue with `baseURL` and interceptors ([#950](https://github.com/axios/axios/pull/950)) - **BREAKING** Improving handing of duplicate headers ([#874](https://github.com/axios/axios/pull/874)) - Adding support for disabling proxies ([#691](https://github.com/axios/axios/pull/691)) - Updating TypeScript typings with generic type parameters ([#1061](https://github.com/axios/axios/pull/1061)) -### 0.16.2 (Jun 3, 2017) +## 0.16.2 (Jun 3, 2017) - Fixing issue with including `buffer` in bundle ([#887](https://github.com/axios/axios/pull/887)) - Including underlying request in errors ([#830](https://github.com/axios/axios/pull/830)) - Convert `method` to lowercase ([#930](https://github.com/axios/axios/pull/930)) -### 0.16.1 (Apr 8, 2017) +## 0.16.1 (Apr 8, 2017) - Improving HTTP adapter to return last request in case of redirects ([#828](https://github.com/axios/axios/pull/828)) - Updating `follow-redirects` dependency ([#829](https://github.com/axios/axios/pull/829)) - Adding support for passing `Buffer` in node ([#773](https://github.com/axios/axios/pull/773)) -### 0.16.0 (Mar 31, 2017) +## 0.16.0 (Mar 31, 2017) - **BREAKING** Removing `Promise` from axios typings in favor of built-in type declarations ([#480](https://github.com/axios/axios/issues/480)) - Adding `options` shortcut method ([#461](https://github.com/axios/axios/pull/461)) @@ -743,7 +765,7 @@ below) or via reviews and triaging on GitHub: - Fixing `combineURLs` to support empty `relativeURL` ([#581](https://github.com/axios/axios/pull/581)) - Removing `PROTECTION_PREFIX` support ([#561](https://github.com/axios/axios/pull/561)) -### 0.15.3 (Nov 27, 2016) +## 0.15.3 (Nov 27, 2016) - Fixing issue with custom instances and global defaults ([#443](https://github.com/axios/axios/issues/443)) - Renaming `axios.d.ts` to `index.d.ts` ([#519](https://github.com/axios/axios/issues/519)) @@ -753,22 +775,22 @@ below) or via reviews and triaging on GitHub: - Improving HTTP adapter to use `http` protocol by default ([#493](https://github.com/axios/axios/pull/493)) - Fixing proxy issues ([#491](https://github.com/axios/axios/pull/491)) -### 0.15.2 (Oct 17, 2016) +## 0.15.2 (Oct 17, 2016) - Fixing issue with calling `cancel` after response has been received ([#482](https://github.com/axios/axios/issues/482)) -### 0.15.1 (Oct 14, 2016) +## 0.15.1 (Oct 14, 2016) - Fixing issue with UMD ([#485](https://github.com/axios/axios/issues/485)) -### 0.15.0 (Oct 10, 2016) +## 0.15.0 (Oct 10, 2016) - Adding cancellation support ([#452](https://github.com/axios/axios/pull/452)) - Moving default adapter to global defaults ([#437](https://github.com/axios/axios/pull/437)) - Fixing issue with `file` URI scheme ([#440](https://github.com/axios/axios/pull/440)) - Fixing issue with `params` objects that have no prototype ([#445](https://github.com/axios/axios/pull/445)) -### 0.14.0 (Aug 27, 2016) +## 0.14.0 (Aug 27, 2016) - **BREAKING** Updating TypeScript definitions ([#419](https://github.com/axios/axios/pull/419)) - **BREAKING** Replacing `agent` option with `httpAgent` and `httpsAgent` ([#387](https://github.com/axios/axios/pull/387)) @@ -777,11 +799,11 @@ below) or via reviews and triaging on GitHub: - Fixing issue with `auth` config option and `Authorization` header ([#397](https://github.com/axios/axios/pull/397)) - Don't set XSRF header if `xsrfCookieName` is `null` ([#406](https://github.com/axios/axios/pull/406)) -### 0.13.1 (Jul 16, 2016) +## 0.13.1 (Jul 16, 2016) - Fixing issue with response data not being transformed on error ([#378](https://github.com/axios/axios/issues/378)) -### 0.13.0 (Jul 13, 2016) +## 0.13.0 (Jul 13, 2016) - **BREAKING** Improved error handling ([#345](https://github.com/axios/axios/pull/345)) - **BREAKING** Response transformer now invoked in dispatcher not adapter ([10eb238](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)) @@ -791,24 +813,24 @@ below) or via reviews and triaging on GitHub: - Fixing custom instance defaults ([#341](https://github.com/axios/axios/issues/341)) - Fixing instances created from `axios.create` to have same API as default axios ([#217](https://github.com/axios/axios/issues/217)) -### 0.12.0 (May 31, 2016) +## 0.12.0 (May 31, 2016) - Adding support for `URLSearchParams` ([#317](https://github.com/axios/axios/pull/317)) - Adding `maxRedirects` option ([#307](https://github.com/axios/axios/pull/307)) -### 0.11.1 (May 17, 2016) +## 0.11.1 (May 17, 2016) - Fixing IE CORS support ([#313](https://github.com/axios/axios/pull/313)) - Fixing detection of `FormData` ([#325](https://github.com/axios/axios/pull/325)) - Adding `Axios` class to exports ([#321](https://github.com/axios/axios/pull/321)) -### 0.11.0 (Apr 26, 2016) +## 0.11.0 (Apr 26, 2016) - Adding support for Stream with HTTP adapter ([#296](https://github.com/axios/axios/pull/296)) - Adding support for custom HTTP status code error ranges ([#308](https://github.com/axios/axios/pull/308)) - Fixing issue with ArrayBuffer ([#299](https://github.com/axios/axios/pull/299)) -### 0.10.0 (Apr 20, 2016) +## 0.10.0 (Apr 20, 2016) - Fixing issue with some requests sending `undefined` instead of `null` ([#250](https://github.com/axios/axios/pull/250)) - Fixing basic auth for HTTP adapter ([#252](https://github.com/axios/axios/pull/252)) @@ -819,14 +841,14 @@ below) or via reviews and triaging on GitHub: - Fixing XHR support for WebWorker environment ([#279](https://github.com/axios/axios/pull/279)) - Adding request instance to response ([#200](https://github.com/axios/axios/pull/200)) -### 0.9.1 (Jan 24, 2016) +## 0.9.1 (Jan 24, 2016) - Improving handling of request timeout in node ([#124](https://github.com/axios/axios/issues/124)) - Fixing network errors not rejecting ([#205](https://github.com/axios/axios/pull/205)) - Fixing issue with IE rejecting on HTTP 204 ([#201](https://github.com/axios/axios/issues/201)) - Fixing host/port when following redirects ([#198](https://github.com/axios/axios/pull/198)) -### 0.9.0 (Jan 18, 2016) +## 0.9.0 (Jan 18, 2016) - Adding support for custom adapters - Fixing Content-Type header being removed when data is false ([#195](https://github.com/axios/axios/pull/195)) @@ -834,13 +856,13 @@ below) or via reviews and triaging on GitHub: - Improving config merging and order of precedence ([#183](https://github.com/axios/axios/pull/183)) - Fixing XDomainRequest support for only <= IE9 ([#182](https://github.com/axios/axios/pull/182)) -### 0.8.1 (Dec 14, 2015) +## 0.8.1 (Dec 14, 2015) - Adding support for passing XSRF token for cross domain requests when using `withCredentials` ([#168](https://github.com/axios/axios/pull/168)) - Fixing error with format of basic auth header ([#178](https://github.com/axios/axios/pull/173)) - Fixing error with JSON payloads throwing `InvalidStateError` in some cases ([#174](https://github.com/axios/axios/pull/174)) -### 0.8.0 (Dec 11, 2015) +## 0.8.0 (Dec 11, 2015) - Adding support for creating instances of axios ([#123](https://github.com/axios/axios/pull/123)) - Fixing http adapter to use `Buffer` instead of `String` in case of `responseType === 'arraybuffer'` ([#128](https://github.com/axios/axios/pull/128)) @@ -852,7 +874,7 @@ below) or via reviews and triaging on GitHub: - Adding support for HTTP basic auth via Authorization header ([#167](https://github.com/axios/axios/pull/167)) - Adding support for baseURL option ([#160](https://github.com/axios/axios/pull/160)) -### 0.7.0 (Sep 29, 2015) +## 0.7.0 (Sep 29, 2015) - Fixing issue with minified bundle in IE8 ([#87](https://github.com/axios/axios/pull/87)) - Adding support for passing agent in node ([#102](https://github.com/axios/axios/pull/102)) @@ -862,7 +884,7 @@ below) or via reviews and triaging on GitHub: - Adding support for use in web workers, and react-native ([#70](https://github.com/axios/axios/issue/70)), ([#98](https://github.com/axios/axios/pull/98)) - Adding support for fetch like API `axios(url[, config])` ([#116](https://github.com/axios/axios/issues/116)) -### 0.6.0 (Sep 21, 2015) +## 0.6.0 (Sep 21, 2015) - Removing deprecated success/error aliases - Fixing issue with array params not being properly encoded ([#49](https://github.com/axios/axios/pull/49)) @@ -873,40 +895,40 @@ below) or via reviews and triaging on GitHub: - Fixing issue with IE8 ([#85](https://github.com/axios/axios/pull/85)) - Converting build to UMD -### 0.5.4 (Apr 08, 2015) +## 0.5.4 (Apr 08, 2015) - Fixing issue with FormData not being sent ([#53](https://github.com/axios/axios/issues/53)) -### 0.5.3 (Apr 07, 2015) +## 0.5.3 (Apr 07, 2015) - Using JSON.parse unconditionally when transforming response string ([#55](https://github.com/axios/axios/issues/55)) -### 0.5.2 (Mar 13, 2015) +## 0.5.2 (Mar 13, 2015) - Adding support for `statusText` in response ([#46](https://github.com/axios/axios/issues/46)) -### 0.5.1 (Mar 10, 2015) +## 0.5.1 (Mar 10, 2015) - Fixing issue using strict mode ([#45](https://github.com/axios/axios/issues/45)) - Fixing issue with standalone build ([#47](https://github.com/axios/axios/issues/47)) -### 0.5.0 (Jan 23, 2015) +## 0.5.0 (Jan 23, 2015) - Adding support for intercepetors ([#14](https://github.com/axios/axios/issues/14)) - Updating es6-promise dependency -### 0.4.2 (Dec 10, 2014) +## 0.4.2 (Dec 10, 2014) - Fixing issue with `Content-Type` when using `FormData` ([#22](https://github.com/axios/axios/issues/22)) - Adding support for TypeScript ([#25](https://github.com/axios/axios/issues/25)) - Fixing issue with standalone build ([#29](https://github.com/axios/axios/issues/29)) - Fixing issue with verbs needing to be capitalized in some browsers ([#30](https://github.com/axios/axios/issues/30)) -### 0.4.1 (Oct 15, 2014) +## 0.4.1 (Oct 15, 2014) - Adding error handling to request for node.js ([#18](https://github.com/axios/axios/issues/18)) -### 0.4.0 (Oct 03, 2014) +## 0.4.0 (Oct 03, 2014) - Adding support for `ArrayBuffer` and `ArrayBufferView` ([#10](https://github.com/axios/axios/issues/10)) - Adding support for utf-8 for node.js ([#13](https://github.com/axios/axios/issues/13)) @@ -915,29 +937,29 @@ below) or via reviews and triaging on GitHub: - Adding standalone build without bundled es6-promise ([#11](https://github.com/axios/axios/issues/11)) - Deprecating `success`/`error` in favor of `then`/`catch` -### 0.3.1 (Sep 16, 2014) +## 0.3.1 (Sep 16, 2014) - Fixing missing post body when using node.js ([#3](https://github.com/axios/axios/issues/3)) -### 0.3.0 (Sep 16, 2014) +## 0.3.0 (Sep 16, 2014) - Fixing `success` and `error` to properly receive response data as individual arguments ([#8](https://github.com/axios/axios/issues/8)) - Updating `then` and `catch` to receive response data as a single object ([#6](https://github.com/axios/axios/issues/6)) - Fixing issue with `all` not working ([#7](https://github.com/axios/axios/issues/7)) -### 0.2.2 (Sep 14, 2014) +## 0.2.2 (Sep 14, 2014) - Fixing bundling with browserify ([#4](https://github.com/axios/axios/issues/4)) -### 0.2.1 (Sep 12, 2014) +## 0.2.1 (Sep 12, 2014) - Fixing build problem causing ridiculous file sizes -### 0.2.0 (Sep 12, 2014) +## 0.2.0 (Sep 12, 2014) - Adding support for `all` and `spread` - Adding support for node.js ([#1](https://github.com/axios/axios/issues/1)) -### 0.1.0 (Aug 29, 2014) +## 0.1.0 (Aug 29, 2014) - Initial release From 5dedd77cbca50a9e05706c8ed9f35469a04fc114 Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 28 May 2022 17:12:48 +0200 Subject: [PATCH 3/8] docs: updated contributors guide --- CONTRIBUTING.md | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 43dc8fd8..ba3c1172 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,28 +2,23 @@ We are open to, and grateful for, any contributions made by the community. By contributing to axios, you agree to abide by the [code of conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md). -### Code Style +## Code Style Please follow the [node style guide](https://github.com/felixge/node-style-guide). -### Commit Messages +## Commit Messages -Commit messages should be verb based, using the following pattern: +Please follow [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) -- `Fixing ...` -- `Adding ...` -- `Updating ...` -- `Removing ...` - -### Testing +## Testing Please update the tests to reflect your code changes. Pull requests will not be accepted if they are failing on [Travis CI](https://travis-ci.org/axios/axios). -### Documentation +## Documentation Please update the [docs](README.md) accordingly so that there are no discrepancies between the API and the documentation. -### Developing +## Developing - `grunt test` run the jasmine and mocha tests - `grunt build` run webpack and bundle the source @@ -33,34 +28,34 @@ Please update the [docs](README.md) accordingly so that there are no discrepanci Please don't include changes to `dist/` in your pull request. This should only be updated when releasing a new version. -### Releasing +## Releasing Releasing a new version is mostly automated. For now the [CHANGELOG](https://github.com/axios/axios/blob/master/CHANGELOG.md) requires being updated manually. Once this has been done run the commands below. Versions should follow [semantic versioning](http://semver.org/). - `npm version -m "Releasing %s"` - `npm publish` -### Running Examples +## Running Examples Examples are included in part to allow manual testing. Running example ```bash -$ npm run examples +> npm run examples # Open 127.0.0.1:3000 ``` Running sandbox in browser ```bash -$ npm start +> npm start # Open 127.0.0.1:3000 ``` Running sandbox in terminal ```bash -$ npm start -$ node ./sandbox/client +> npm start +> node ./sandbox/client ``` From 8647bda0b62bff968acbb120f2c3fc7013a72028 Mon Sep 17 00:00:00 2001 From: Jay Date: Sat, 28 May 2022 17:19:03 +0200 Subject: [PATCH 4/8] docs: fixed linting errors in docs --- COOKBOOK.md | 16 ++++++++-------- ECOSYSTEM.md | 6 +++--- SECURITY.md | 2 +- UPGRADE_GUIDE.md | 31 ++++++++++++++++--------------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/COOKBOOK.md b/COOKBOOK.md index 3f4debd3..6ce5b10e 100644 --- a/COOKBOOK.md +++ b/COOKBOOK.md @@ -4,10 +4,10 @@ This cookbook contains recipes for some commonly requested features. In order to keep axios as lightweight as possible, it is often necessary to say no to feature requests. Many of these use cases can be supported by augmenting axios with other libraries. -### Promise.prototype.done +## Promise.prototype.done ```bash -$ npm install axios promise --save +> npm install axios promise --save ``` ```js @@ -23,10 +23,10 @@ axios .done(); ``` -### Promise.prototype.finally +## Promise.prototype.finally ```bash -$ npm install axios promise.prototype.finally --save +> npm install axios promise.prototype.finally --save ``` ```js @@ -44,10 +44,10 @@ axios }); ``` -### Inflate/Deflate +## Inflate/Deflate ```bash -$ npm install axios pako --save +> npm install axios pako --save ``` ```js @@ -107,10 +107,10 @@ const server = http.createServer((req, res) => { server.listen(3333); ``` -### JSONP +## JSONP ```bash -$ npm install jsonp --save +> npm install jsonp --save ``` ```js diff --git a/ECOSYSTEM.md b/ECOSYSTEM.md index 8e2176f0..9e55bc21 100644 --- a/ECOSYSTEM.md +++ b/ECOSYSTEM.md @@ -11,14 +11,14 @@ This is a list of axios related libraries and resources. If you have a suggestio * [axios-method-override](https://github.com/jacobbuck/axios-method-override) - Axios http request method override plugin * [axios-cache-plugin](https://github.com/jin5354/axios-cache-plugin) - Help you cache GET request when using axios. * [axios-extensions](https://github.com/kuitos/axios-extensions) - A collection of axios extensions, including throttle and cache GET request plugin. -* [axios-fetch](https://github.com/lifeomic/axios-fetch) - A WebAPI Fetch implementation backed by an Axios client +* [axios-fetch](https://github.com/lifeomic/axios-fetch) - A WebAPI Fetch implementation backed by an Axios client * [axios-actions](https://github.com/davestewart/axios-actions) - Bundle endpoints as callable, reusable services * [axios-api-versioning](https://weffe.github.io/axios-api-versioning) - Add easy to manage api versioning to axios * [axios-data-unpacker](https://github.com/anubhavsrivastava/axios-data-unpacker) - Axios interceptor that unpacks HTTP responses so that you can focus on actual server data. * [r2curl](https://github.com/uyu423/r2curl) - Extracts the cURL command string from the Axios object. (AxiosResponse, AxiosRequestConfig) * [swagger-taxos-codegen](https://github.com/michalzaq12/swagger-taxos-codegen) - Axios based Swagger Codegen (tailored for typescript) -* [axios-endpoints](https://github.com/renancaraujo/axios-endpoints) - Axios endpoints helps you to create a more concise endpoint mapping with axios. -* [axios-multi-api](https://github.com/MattCCC/axios-multi-api) - Easy API handling whenever there are many endpoints to add. It helps to make Axios requests in an easy and declarative manner. +* [axios-endpoints](https://github.com/renancaraujo/axios-endpoints) - Axios endpoints helps you to create a more concise endpoint mapping with axios. +* [axios-multi-api](https://github.com/MattCCC/axios-multi-api) - Easy API handling whenever there are many endpoints to add. It helps to make Axios requests in an easy and declarative manner. * [axios-url-template](https://github.com/rafw87/axios-url-template) - Axios interceptor adding support for URL templates. ### Logging and debugging diff --git a/SECURITY.md b/SECURITY.md index f8e5e92f..7b96aaab 100644 --- a/SECURITY.md +++ b/SECURITY.md @@ -1,4 +1,4 @@ -## Reporting a Vulnerability +# Reporting a Vulnerability If you discover a security vulnerability within axios, please submit a report via [huntr.dev](https://huntr.dev/bounties/?target=https%3A%2F%2Fgithub.com%2Faxios%2Faxios). Bounties and CVEs are automatically managed and allocated via the platform. diff --git a/UPGRADE_GUIDE.md b/UPGRADE_GUIDE.md index fdcff1a6..52a022d4 100644 --- a/UPGRADE_GUIDE.md +++ b/UPGRADE_GUIDE.md @@ -1,20 +1,20 @@ # Upgrade Guide -### 0.18.x -> 0.19.0 +## 0.18.x -> 0.19.0 -#### HTTPS Proxies +### HTTPS Proxies Routing through an https proxy now requires setting the `protocol` attribute of the proxy configuration to `https` -### 0.15.x -> 0.16.0 +## 0.15.x -> 0.16.0 -#### `Promise` Type Declarations +### `Promise` Type Declarations The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details. -### 0.13.x -> 0.14.0 +## 0.13.x -> 0.14.0 -#### TypeScript Definitions +### TypeScript Definitions The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax. @@ -28,7 +28,7 @@ axios.get('/foo') .catch(error => console.log(error)); ``` -#### `agent` Config Option +### `agent` Config Option The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead. @@ -41,7 +41,7 @@ The `agent` config option has been replaced with two new options: `httpAgent` an } ``` -#### `progress` Config Option +### `progress` Config Option The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options. @@ -59,11 +59,11 @@ The `progress` config option has been replaced with the `onUploadProgress` and ` } ``` -### 0.12.x -> 0.13.0 +## 0.12.x -> 0.13.0 The `0.13.0` release contains several changes to custom adapters and error handling. -#### Error Handling +### Error Handling Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response. @@ -77,7 +77,7 @@ axios.get('/user/12345') }); ``` -#### Request Adapters +### Request Adapters This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter. @@ -121,14 +121,15 @@ function myAdapter(config) { ``` See the related commits for more details: + - [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e) - [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a) -### 0.5.x -> 0.6.0 +## 0.5.x -> 0.6.0 The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading. -#### ES6 Promise Polyfill +### ES6 Promise Polyfill Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it. @@ -139,7 +140,7 @@ var axios = require('axios'); This will polyfill the global environment, and only needs to be done once. -#### `axios.success`/`axios.error` +### `axios.success`/`axios.error` The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. @@ -153,7 +154,7 @@ axios.get('some/url') }); ``` -#### UMD +### UMD Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build. From 665db731099314ef6128188a5657bae0a142640d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabian=20B=C3=B6ller?= Date: Sat, 18 Jun 2022 11:20:41 +0200 Subject: [PATCH 5/8] Add resource section (#4767) The description mentions libraries and resources to be referenced on this page. I added a section for resources referencing blog posts with recipes to achieve different outcomes with Axios. --- ECOSYSTEM.md | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/ECOSYSTEM.md b/ECOSYSTEM.md index 9e55bc21..108df445 100644 --- a/ECOSYSTEM.md +++ b/ECOSYSTEM.md @@ -42,3 +42,19 @@ This is a list of axios related libraries and resources. If you have a suggestio * [axios-test-instance](https://github.com/remcohaszing/axios-test-instance) — Test NodeJS backends using Axios * [moxios](https://github.com/axios/moxios) - Mock axios requests for testing * [mocha-axios](https://github.com/jdrydn/mocha-axios) - Streamlined integration testing with Mocha & Axios + +## Resources + +### General + +* [Connection pooling with agentkeepalive](https://traveling-coderman.net/code/node-architecture/connection-pooling/) +* [Error handling in Express.js](https://traveling-coderman.net/code/node-architecture/axios-error-handling/) +* [Request authentication with JWT](https://traveling-coderman.net/code/node-architecture/http-auth/) + +### Logging and debugging + +* [Pino request logging](https://traveling-coderman.net/code/node-architecture/logging-http-requests/) + +### Unit testing + +* [Organizing and testing HTTP requests](https://traveling-coderman.net/code/node-architecture/sending-http-requests/) From 65977f995c7b92aeca26aa1ba50e1d6678389002 Mon Sep 17 00:00:00 2001 From: Willian Agostini Date: Thu, 15 Sep 2022 02:26:58 -0300 Subject: [PATCH 6/8] docs: changed href links from master to main (#4882) --- .github/ISSUE_TEMPLATE.md | 4 ++-- .github/ISSUE_TEMPLATE/---bug-report.md | 2 +- .github/ISSUE_TEMPLATE/---feature-request.md | 2 +- .../ISSUE_TEMPLATE/---support-or-usage-question.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 2 +- COLLABORATOR_GUIDE.md | 2 +- CONTRIBUTING.md | 4 ++-- README.md | 14 +++++++------- UPGRADE_GUIDE.md | 2 +- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/.github/ISSUE_TEMPLATE.md b/.github/ISSUE_TEMPLATE.md index a82e4737..4466336c 100644 --- a/.github/ISSUE_TEMPLATE.md +++ b/.github/ISSUE_TEMPLATE.md @@ -2,11 +2,11 @@ Please read and follow the instructions before submitting an issue: -- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue. +- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/main/README.md). It may contain information that helps you solve your issue. - Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue). - If you aren't sure that the issue is caused by axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios). - If you're reporting a bug, ensure it isn't already fixed in the latest axios version. -- If you need a new feature there's a chance it's already implemented in a [library](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) or you can implement it using [interceptors](https://github.com/axios/axios#interceptors). +- If you need a new feature there's a chance it's already implemented in a [library](https://github.com/axios/axios/blob/main/ECOSYSTEM.md) or you can implement it using [interceptors](https://github.com/axios/axios#interceptors). - Don't remove any title of the issue template, or it will be treated as invalid by the bot. **⚠️👆 Delete the instructions before submitting the issue 👆⚠️** diff --git a/.github/ISSUE_TEMPLATE/---bug-report.md b/.github/ISSUE_TEMPLATE/---bug-report.md index 8af77a3c..461096cf 100644 --- a/.github/ISSUE_TEMPLATE/---bug-report.md +++ b/.github/ISSUE_TEMPLATE/---bug-report.md @@ -11,7 +11,7 @@ assignees: '' Please read and follow the instructions before submitting an issue: -- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue. +- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/main/README.md). It may contain information that helps you solve your issue. - Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue). - If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios). - If you're reporting a bug, ensure it isn't already fixed in the latest Axios version. diff --git a/.github/ISSUE_TEMPLATE/---feature-request.md b/.github/ISSUE_TEMPLATE/---feature-request.md index fe567608..78177f7d 100644 --- a/.github/ISSUE_TEMPLATE/---feature-request.md +++ b/.github/ISSUE_TEMPLATE/---feature-request.md @@ -11,7 +11,7 @@ assignees: '' Please read and follow the instructions before submitting an issue: -- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue. +- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/main/README.md). It may contain information that helps you solve your issue. - Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue). - If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios). - If you're reporting a bug, ensure it isn't already fixed in the latest Axios version. diff --git a/.github/ISSUE_TEMPLATE/---support-or-usage-question.md b/.github/ISSUE_TEMPLATE/---support-or-usage-question.md index e73035fc..27187767 100644 --- a/.github/ISSUE_TEMPLATE/---support-or-usage-question.md +++ b/.github/ISSUE_TEMPLATE/---support-or-usage-question.md @@ -11,7 +11,7 @@ assignees: '' Please read and follow the instructions before submitting an issue: -- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/master/README.md). It may contain information that helps you solve your issue. +- Read all our documentation, especially the [README](https://github.com/axios/axios/blob/main/README.md). It may contain information that helps you solve your issue. - Ensure your issue isn't already [reported](https://github.com/axios/axios/issues?utf8=%E2%9C%93&q=is%3Aissue). - If you aren't sure that the issue is caused by Axios or you just need help, please use [Stack Overflow](https://stackoverflow.com/questions/tagged/axios) or [our chat](https://gitter.im/mzabriskie/axios). - If you're reporting a bug, ensure it isn't already fixed in the latest Axios version. diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 092611e2..46fbae66 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -6,7 +6,7 @@ Please read and follow the instructions before creating and submitting a pull re - Create an issue explaining the feature. It could save you some effort in case we don't consider it should be included in axios. - If you're fixing a bug, try to commit the failing test/s and the code fixing it in different commits. -- Ensure you're following our [contributing guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md). +- Ensure you're following our [contributing guide](https://github.com/axios/axios/blob/main/CONTRIBUTING.md). **⚠️👆 Delete the instructions before submitting the pull request 👆⚠️** diff --git a/COLLABORATOR_GUIDE.md b/COLLABORATOR_GUIDE.md index 973bc67d..dd6bed92 100644 --- a/COLLABORATOR_GUIDE.md +++ b/COLLABORATOR_GUIDE.md @@ -2,7 +2,7 @@ As a collaborator, you will be involved with axios with some administrative responsibilities. This guide will help you understand your role and the responsibilities that come with being a collaborator. -1. __Adhere to and help enforce the Code of Conduct.__ It is expected that you have read the [code of conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md) and that you agree to live by it. This community should be friendly and welcoming. +1. __Adhere to and help enforce the Code of Conduct.__ It is expected that you have read the [code of conduct](https://github.com/axios/axios/blob/main/CODE_OF_CONDUCT.md) and that you agree to live by it. This community should be friendly and welcoming. 1. __Triage issues.__ As a collaborator, you may help sort through the issues that are reported. Issues vary from bugs, regressions, feature requests, questions, etc. Apply the appropriate label(s) and respond as needed. If it is a legitimate request, please address it, otherwise feel free to close the issue and include a comment with a suggestion on where to find support. If an issue has been inactive for more than a week (i.e., the owner of the issue hasn’t responded to you), close the issue with a note indicating stale issues are closed; it can always be reopened if needed. In the case of issues that require a code change, encourage the owner to submit a PR. For less complex code changes, add a very simple and detailed checklist, apply the “first-timers-only” label, and encourage a newcomer to open source to get involved. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index ba3c1172..79b1d937 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Contributing -We are open to, and grateful for, any contributions made by the community. By contributing to axios, you agree to abide by the [code of conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md). +We are open to, and grateful for, any contributions made by the community. By contributing to axios, you agree to abide by the [code of conduct](https://github.com/axios/axios/blob/main/CODE_OF_CONDUCT.md). ## Code Style @@ -30,7 +30,7 @@ Please don't include changes to `dist/` in your pull request. This should only b ## Releasing -Releasing a new version is mostly automated. For now the [CHANGELOG](https://github.com/axios/axios/blob/master/CHANGELOG.md) requires being updated manually. Once this has been done run the commands below. Versions should follow [semantic versioning](http://semver.org/). +Releasing a new version is mostly automated. For now the [CHANGELOG](https://github.com/axios/axios/blob/main/CHANGELOG.md) requires being updated manually. Once this has been done run the commands below. Versions should follow [semantic versioning](http://semver.org/). - `npm version -m "Releasing %s"` - `npm publish` diff --git a/README.md b/README.md index 45b80b2d..8c231306 100755 --- a/README.md +++ b/README.md @@ -598,7 +598,7 @@ instance.defaults.headers.common['Authorization'] = AUTH_TOKEN; ### Config order of precedence -Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults/index.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. +Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/main/lib/defaults/index.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. ```js // Create an instance using the config defaults provided by the library @@ -1159,16 +1159,16 @@ try { You can use Gitpod, an online IDE(which is free for Open Source) for contributing or running the examples online. -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/master/examples/server.js) +[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/main/examples/server.js) ## Resources -* [Changelog](https://github.com/axios/axios/blob/master/CHANGELOG.md) -* [Upgrade Guide](https://github.com/axios/axios/blob/master/UPGRADE_GUIDE.md) -* [Ecosystem](https://github.com/axios/axios/blob/master/ECOSYSTEM.md) -* [Contributing Guide](https://github.com/axios/axios/blob/master/CONTRIBUTING.md) -* [Code of Conduct](https://github.com/axios/axios/blob/master/CODE_OF_CONDUCT.md) +* [Changelog](https://github.com/axios/axios/blob/main/CHANGELOG.md) +* [Upgrade Guide](https://github.com/axios/axios/blob/main/UPGRADE_GUIDE.md) +* [Ecosystem](https://github.com/axios/axios/blob/main/ECOSYSTEM.md) +* [Contributing Guide](https://github.com/axios/axios/blob/main/CONTRIBUTING.md) +* [Code of Conduct](https://github.com/axios/axios/blob/main/CODE_OF_CONDUCT.md) ## Credits diff --git a/UPGRADE_GUIDE.md b/UPGRADE_GUIDE.md index 52a022d4..bf5775db 100644 --- a/UPGRADE_GUIDE.md +++ b/UPGRADE_GUIDE.md @@ -142,7 +142,7 @@ This will polyfill the global environment, and only needs to be done once. ### `axios.success`/`axios.error` -The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. +The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/main/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively. ```js axios.get('some/url') From 9588fcdec8aca45c3ba2f7968988a5d03f23168c Mon Sep 17 00:00:00 2001 From: Remco Haszing Date: Wed, 28 Sep 2022 20:30:21 +0200 Subject: [PATCH 7/8] Fix TypeScript exports (#4884) TypeScript 4.7 introduced the `node16` module option. This requires CommonJS libraries like axios to be properly typed as CommonJS. The proper type for `module.export =` in JavaScript, is to use `exports =` in TypeScript. In order to export additional types, a namespace can be used. However, no values can be exported like this. Values are exported using the `AxiosStatic` interface. This change should be non-breaking. If TypeScript users previously relied on the faux default export, they now need to enable `esModuleInterop`, as they should have been doing in the first place. Co-authored-by: Jay --- index.d.ts | 577 ++++++++++++++++++++------------------- test/typescript/axios.ts | 66 ++--- tsconfig.json | 2 +- 3 files changed, 321 insertions(+), 324 deletions(-) diff --git a/index.d.ts b/index.d.ts index bbf8390f..3a7d5f1e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -2,213 +2,26 @@ type AxiosHeaders = Record; type MethodsHeaders = { - [Key in Method as Lowercase]: AxiosHeaders; + [Key in axios.Method as Lowercase]: AxiosHeaders; }; interface CommonHeaders { common: AxiosHeaders; } -export type AxiosRequestHeaders = Partial; - -export type AxiosResponseHeaders = Record & { - "set-cookie"?: string[] -}; - -export interface AxiosRequestTransformer { - (data: any, headers: AxiosRequestHeaders): any; -} - -export interface AxiosResponseTransformer { - (data: any, headers?: AxiosResponseHeaders, status?: number): any; -} - -export interface AxiosAdapter { - (config: AxiosRequestConfig): AxiosPromise; -} - -export interface AxiosBasicCredentials { - username: string; - password: string; -} - -export interface AxiosProxyConfig { - host: string; - port: number; - auth?: { - username: string; - password: string; - }; - protocol?: string; -} - -export type Method = - | 'get' | 'GET' - | 'delete' | 'DELETE' - | 'head' | 'HEAD' - | 'options' | 'OPTIONS' - | 'post' | 'POST' - | 'put' | 'PUT' - | 'patch' | 'PATCH' - | 'purge' | 'PURGE' - | 'link' | 'LINK' - | 'unlink' | 'UNLINK'; - -export type ResponseType = - | 'arraybuffer' - | 'blob' - | 'document' - | 'json' - | 'text' - | 'stream'; - - export type responseEncoding = - | 'ascii' | 'ASCII' - | 'ansi' | 'ANSI' - | 'binary' | 'BINARY' - | 'base64' | 'BASE64' - | 'base64url' | 'BASE64URL' - | 'hex' | 'HEX' - | 'latin1' | 'LATIN1' - | 'ucs-2' | 'UCS-2' - | 'ucs2' | 'UCS2' - | 'utf-8' | 'UTF-8' - | 'utf8' | 'UTF8' - | 'utf16le' | 'UTF16LE'; - -export interface TransitionalOptions { - silentJSONParsing?: boolean; - forcedJSONParsing?: boolean; - clarifyTimeoutError?: boolean; -} - -export interface GenericAbortSignal { - aborted: boolean; - onabort: ((...args: any) => any) | null; - addEventListener: (...args: any) => any; - removeEventListener: (...args: any) => any; -} - -export interface FormDataVisitorHelpers { - defaultVisitor: SerializerVisitor; - convertValue: (value: any) => any; - isVisitable: (value: any) => boolean; -} - -export interface SerializerVisitor { - ( - this: GenericFormData, - value: any, - key: string | number, - path: null | Array, - helpers: FormDataVisitorHelpers - ): boolean; -} - -export interface SerializerOptions { - visitor?: SerializerVisitor; - dots?: boolean; - metaTokens?: boolean; - indexes?: boolean; -} - -// tslint:disable-next-line -export interface FormSerializerOptions extends SerializerOptions { -} - -export interface ParamEncoder { - (value: any, defaultEncoder: (value: any) => any): any; -} - -export interface ParamsSerializerOptions extends SerializerOptions { - encode?: ParamEncoder; -} - -export interface AxiosRequestConfig { - url?: string; - method?: Method | string; - baseURL?: string; - transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[]; - transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[]; - headers?: AxiosRequestHeaders; - params?: any; - paramsSerializer?: ParamsSerializerOptions; - data?: D; - timeout?: number; - timeoutErrorMessage?: string; - withCredentials?: boolean; - adapter?: AxiosAdapter; - auth?: AxiosBasicCredentials; - responseType?: ResponseType; - responseEncoding?: responseEncoding | string; - xsrfCookieName?: string; - xsrfHeaderName?: string; - onUploadProgress?: (progressEvent: ProgressEvent) => void; - onDownloadProgress?: (progressEvent: ProgressEvent) => void; - maxContentLength?: number; - validateStatus?: ((status: number) => boolean) | null; - maxBodyLength?: number; - maxRedirects?: number; - beforeRedirect?: (options: Record, responseDetails: {headers: Record}) => void; - socketPath?: string | null; - httpAgent?: any; - httpsAgent?: any; - proxy?: AxiosProxyConfig | false; - cancelToken?: CancelToken; - decompress?: boolean; - transitional?: TransitionalOptions; - signal?: GenericAbortSignal; - insecureHTTPParser?: boolean; - env?: { - FormData?: new (...args: any[]) => object; - }; - formSerializer?: FormSerializerOptions; -} - -export interface HeadersDefaults { - common: AxiosRequestHeaders; - delete: AxiosRequestHeaders; - get: AxiosRequestHeaders; - head: AxiosRequestHeaders; - post: AxiosRequestHeaders; - put: AxiosRequestHeaders; - patch: AxiosRequestHeaders; - options?: AxiosRequestHeaders; - purge?: AxiosRequestHeaders; - link?: AxiosRequestHeaders; - unlink?: AxiosRequestHeaders; -} - -export interface AxiosDefaults extends Omit, 'headers'> { - headers: HeadersDefaults; -} - -export interface CreateAxiosDefaults extends Omit, 'headers'> { - headers?: AxiosRequestHeaders | Partial; -} - -export interface AxiosResponse { - data: T; - status: number; - statusText: string; - headers: AxiosResponseHeaders; - config: AxiosRequestConfig; - request?: any; -} - -export class AxiosError extends Error { +declare class AxiosError_ extends Error { constructor( message?: string, code?: string, - config?: AxiosRequestConfig, + config?: axios.AxiosRequestConfig, request?: any, - response?: AxiosResponse + response?: axios.AxiosResponse ); - config?: AxiosRequestConfig; + config?: axios.AxiosRequestConfig; code?: string; request?: any; - response?: AxiosResponse; + response?: axios.AxiosResponse; isAxiosError: boolean; status?: number; toJSON: () => object; @@ -227,106 +40,300 @@ export class AxiosError extends Error { static readonly ETIMEDOUT = "ETIMEDOUT"; } -export class CanceledError extends AxiosError { +declare class CanceledError_ extends AxiosError_ { } -export type AxiosPromise = Promise>; - -export interface CancelStatic { - new (message?: string): Cancel; -} - -export interface Cancel { - message: string | undefined; -} - -export interface Canceler { - (message?: string, config?: AxiosRequestConfig, request?: any): void; -} - -export interface CancelTokenStatic { - new (executor: (cancel: Canceler) => void): CancelToken; - source(): CancelTokenSource; -} - -export interface CancelToken { - promise: Promise; - reason?: Cancel; - throwIfRequested(): void; -} - -export interface CancelTokenSource { - token: CancelToken; - cancel: Canceler; -} - -export interface AxiosInterceptorOptions { - synchronous?: boolean; - runWhen?: (config: AxiosRequestConfig) => boolean; -} - -export interface AxiosInterceptorManager { - use(onFulfilled?: (value: V) => T | Promise, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number; - eject(id: number): void; -} - -export class Axios { - constructor(config?: AxiosRequestConfig); - defaults: AxiosDefaults; +declare class Axios_ { + constructor(config?: axios.AxiosRequestConfig); + defaults: axios.AxiosDefaults; interceptors: { - request: AxiosInterceptorManager; - response: AxiosInterceptorManager; + request: axios.AxiosInterceptorManager; + response: axios.AxiosInterceptorManager; }; - getUri(config?: AxiosRequestConfig): string; - request, D = any>(config: AxiosRequestConfig): Promise; - get, D = any>(url: string, config?: AxiosRequestConfig): Promise; - delete, D = any>(url: string, config?: AxiosRequestConfig): Promise; - head, D = any>(url: string, config?: AxiosRequestConfig): Promise; - options, D = any>(url: string, config?: AxiosRequestConfig): Promise; - post, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; - put, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; - patch, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; - postForm, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; - putForm, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; - patchForm, D = any>(url: string, data?: D, config?: AxiosRequestConfig): Promise; + getUri(config?: axios.AxiosRequestConfig): string; + request, D = any>(config: axios.AxiosRequestConfig): Promise; + get, D = any>(url: string, config?: axios.AxiosRequestConfig): Promise; + delete, D = any>(url: string, config?: axios.AxiosRequestConfig): Promise; + head, D = any>(url: string, config?: axios.AxiosRequestConfig): Promise; + options, D = any>(url: string, config?: axios.AxiosRequestConfig): Promise; + post, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig): Promise; + put, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig): Promise; + patch, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig): Promise; + postForm, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig): Promise; + putForm, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig): Promise; + patchForm, D = any>(url: string, data?: D, config?: axios.AxiosRequestConfig): Promise; } -export interface AxiosInstance extends Axios { - , D = any>(config: AxiosRequestConfig): AxiosPromise; - , D = any>(url: string, config?: AxiosRequestConfig): AxiosPromise; +declare namespace axios { + type AxiosRequestHeaders = Partial; - defaults: Omit & { - headers: HeadersDefaults & { - [key: string]: string | number | boolean | undefined - } + type AxiosResponseHeaders = Record & { + "set-cookie"?: string[] }; + + interface AxiosRequestTransformer { + (data: any, headers: AxiosRequestHeaders): any; + } + + interface AxiosResponseTransformer { + (data: any, headers?: AxiosResponseHeaders, status?: number): any; + } + + interface AxiosAdapter { + (config: AxiosRequestConfig): AxiosPromise; + } + + interface AxiosBasicCredentials { + username: string; + password: string; + } + + interface AxiosProxyConfig { + host: string; + port: number; + auth?: { + username: string; + password: string; + }; + protocol?: string; + } + + type Method = + | 'get' | 'GET' + | 'delete' | 'DELETE' + | 'head' | 'HEAD' + | 'options' | 'OPTIONS' + | 'post' | 'POST' + | 'put' | 'PUT' + | 'patch' | 'PATCH' + | 'purge' | 'PURGE' + | 'link' | 'LINK' + | 'unlink' | 'UNLINK'; + + type ResponseType = + | 'arraybuffer' + | 'blob' + | 'document' + | 'json' + | 'text' + | 'stream'; + + type responseEncoding = + | 'ascii' | 'ASCII' + | 'ansi' | 'ANSI' + | 'binary' | 'BINARY' + | 'base64' | 'BASE64' + | 'base64url' | 'BASE64URL' + | 'hex' | 'HEX' + | 'latin1' | 'LATIN1' + | 'ucs-2' | 'UCS-2' + | 'ucs2' | 'UCS2' + | 'utf-8' | 'UTF-8' + | 'utf8' | 'UTF8' + | 'utf16le' | 'UTF16LE'; + + interface TransitionalOptions { + silentJSONParsing?: boolean; + forcedJSONParsing?: boolean; + clarifyTimeoutError?: boolean; + } + + interface GenericAbortSignal { + aborted: boolean; + onabort: ((...args: any) => any) | null; + addEventListener: (...args: any) => any; + removeEventListener: (...args: any) => any; + } + + interface FormDataVisitorHelpers { + defaultVisitor: SerializerVisitor; + convertValue: (value: any) => any; + isVisitable: (value: any) => boolean; + } + + interface SerializerVisitor { + ( + this: GenericFormData, + value: any, + key: string | number, + path: null | Array, + helpers: FormDataVisitorHelpers + ): boolean; + } + + interface SerializerOptions { + visitor?: SerializerVisitor; + dots?: boolean; + metaTokens?: boolean; + indexes?: boolean; + } + + // tslint:disable-next-line + interface FormSerializerOptions extends SerializerOptions { + } + + interface ParamEncoder { + (value: any, defaultEncoder: (value: any) => any): any; + } + + interface ParamsSerializerOptions extends SerializerOptions { + encode?: ParamEncoder; + } + + interface AxiosRequestConfig { + url?: string; + method?: Method | string; + baseURL?: string; + transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[]; + transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[]; + headers?: AxiosRequestHeaders; + params?: any; + paramsSerializer?: ParamsSerializerOptions; + data?: D; + timeout?: number; + timeoutErrorMessage?: string; + withCredentials?: boolean; + adapter?: AxiosAdapter; + auth?: AxiosBasicCredentials; + responseType?: ResponseType; + responseEncoding?: responseEncoding | string; + xsrfCookieName?: string; + xsrfHeaderName?: string; + onUploadProgress?: (progressEvent: ProgressEvent) => void; + onDownloadProgress?: (progressEvent: ProgressEvent) => void; + maxContentLength?: number; + validateStatus?: ((status: number) => boolean) | null; + maxBodyLength?: number; + maxRedirects?: number; + beforeRedirect?: (options: Record, responseDetails: {headers: Record}) => void; + socketPath?: string | null; + httpAgent?: any; + httpsAgent?: any; + proxy?: AxiosProxyConfig | false; + cancelToken?: CancelToken; + decompress?: boolean; + transitional?: TransitionalOptions; + signal?: GenericAbortSignal; + insecureHTTPParser?: boolean; + env?: { + FormData?: new (...args: any[]) => object; + }; + formSerializer?: FormSerializerOptions; + } + + interface HeadersDefaults { + common: AxiosRequestHeaders; + delete: AxiosRequestHeaders; + get: AxiosRequestHeaders; + head: AxiosRequestHeaders; + post: AxiosRequestHeaders; + put: AxiosRequestHeaders; + patch: AxiosRequestHeaders; + options?: AxiosRequestHeaders; + purge?: AxiosRequestHeaders; + link?: AxiosRequestHeaders; + unlink?: AxiosRequestHeaders; + } + + interface AxiosDefaults extends Omit, 'headers'> { + headers: HeadersDefaults; + } + + interface CreateAxiosDefaults extends Omit, 'headers'> { + headers?: AxiosRequestHeaders | Partial; + } + + interface AxiosResponse { + data: T; + status: number; + statusText: string; + headers: AxiosResponseHeaders; + config: AxiosRequestConfig; + request?: any; + } + + type AxiosPromise = Promise>; + + interface CancelStatic { + new (message?: string): Cancel; + } + + interface Cancel { + message: string | undefined; + } + + interface Canceler { + (message?: string, config?: AxiosRequestConfig, request?: any): void; + } + + interface CancelTokenStatic { + new (executor: (cancel: Canceler) => void): CancelToken; + source(): CancelTokenSource; + } + + interface CancelToken { + promise: Promise; + reason?: Cancel; + throwIfRequested(): void; + } + + interface CancelTokenSource { + token: CancelToken; + cancel: Canceler; + } + + interface AxiosInterceptorOptions { + synchronous?: boolean; + runWhen?: (config: AxiosRequestConfig) => boolean; + } + + interface AxiosInterceptorManager { + use(onFulfilled?: (value: V) => T | Promise, onRejected?: (error: any) => any, options?: AxiosInterceptorOptions): number; + eject(id: number): void; + } + + interface AxiosInstance extends Axios { + , D = any>(config: AxiosRequestConfig): AxiosPromise; + , D = any>(url: string, config?: AxiosRequestConfig): AxiosPromise; + + defaults: Omit & { + headers: HeadersDefaults & { + [key: string]: string | number | boolean | undefined + } + }; + } + + interface GenericFormData { + append(name: string, value: any, options?: any): any; + } + + interface GenericHTMLFormElement { + name: string; + method: string; + submit(): void; + } + + type Axios = Axios_; + type AxiosError = AxiosError_; + type CanceledError = CanceledError_; + + interface AxiosStatic extends AxiosInstance { + create(config?: CreateAxiosDefaults): AxiosInstance; + Cancel: CancelStatic; + CancelToken: CancelTokenStatic; + Axios: typeof Axios_; + AxiosError: typeof AxiosError_; + CanceledError: typeof CanceledError_; + readonly VERSION: string; + isCancel(value: any): value is Cancel; + all(values: Array>): Promise; + spread(callback: (...args: T[]) => R): (array: T[]) => R; + isAxiosError(payload: any): payload is AxiosError; + toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData; + formToJSON(form: GenericFormData|GenericHTMLFormElement): object; + } } -export interface GenericFormData { - append(name: string, value: any, options?: any): any; -} +declare const axios: axios.AxiosStatic; -export interface GenericHTMLFormElement { - name: string; - method: string; - submit(): void; -} - -export interface AxiosStatic extends AxiosInstance { - create(config?: CreateAxiosDefaults): AxiosInstance; - Cancel: CancelStatic; - CancelToken: CancelTokenStatic; - Axios: typeof Axios; - AxiosError: typeof AxiosError; - readonly VERSION: string; - isCancel(value: any): value is Cancel; - all(values: Array>): Promise; - spread(callback: (...args: T[]) => R): (array: T[]) => R; - isAxiosError(payload: any): payload is AxiosError; - toFormData(sourceObj: object, targetFormData?: GenericFormData, options?: FormSerializerOptions): GenericFormData; - formToJSON(form: GenericFormData|GenericHTMLFormElement): object; -} - -declare const axios: AxiosStatic; - -export default axios; +export = axios; diff --git a/test/typescript/axios.ts b/test/typescript/axios.ts index c0c61599..1b30f4a5 100644 --- a/test/typescript/axios.ts +++ b/test/typescript/axios.ts @@ -1,16 +1,6 @@ -import axios, { - AxiosRequestConfig, - AxiosResponse, - AxiosError, - AxiosInstance, - AxiosAdapter, - Cancel, - CancelToken, - CancelTokenSource, - Canceler -} from 'axios'; +import axios = require('axios'); -const config: AxiosRequestConfig = { +const config: axios.AxiosRequestConfig = { url: '/user', method: 'get', baseURL: 'https://api.example.com/', @@ -44,18 +34,18 @@ const config: AxiosRequestConfig = { host: '127.0.0.1', port: 9000 }, - cancelToken: new axios.CancelToken((cancel: Canceler) => {}) + cancelToken: new axios.CancelToken((cancel: axios.Canceler) => {}) }; -const nullValidateStatusConfig: AxiosRequestConfig = { +const nullValidateStatusConfig: axios.AxiosRequestConfig = { validateStatus: null }; -const undefinedValidateStatusConfig: AxiosRequestConfig = { +const undefinedValidateStatusConfig: axios.AxiosRequestConfig = { validateStatus: undefined }; -const handleResponse = (response: AxiosResponse) => { +const handleResponse = (response: axios.AxiosResponse) => { console.log(response.data); console.log(response.status); console.log(response.statusText); @@ -63,7 +53,7 @@ const handleResponse = (response: AxiosResponse) => { console.log(response.config); }; -const handleError = (error: AxiosError) => { +const handleError = (error: axios.AxiosError) => { if (error.response) { console.log(error.response.data); console.log(error.response.status); @@ -125,7 +115,7 @@ interface User { // with default AxiosResponse result -const handleUserResponse = (response: AxiosResponse) => { +const handleUserResponse = (response: axios.AxiosResponse) => { console.log(response.data.id); console.log(response.data.name); console.log(response.status); @@ -221,8 +211,8 @@ axios.request({ // Instances -const instance1: AxiosInstance = axios.create(); -const instance2: AxiosInstance = axios.create(config); +const instance1: axios.AxiosInstance = axios.create(); +const instance2: axios.AxiosInstance = axios.create(config); instance1(config) .then(handleResponse) @@ -274,39 +264,39 @@ axios.create({ headers: { common: { foo: 'bar' } } }); // Interceptors const requestInterceptorId: number = axios.interceptors.request.use( - (config: AxiosRequestConfig) => config, + (config: axios.AxiosRequestConfig) => config, (error: any) => Promise.reject(error) ); axios.interceptors.request.eject(requestInterceptorId); axios.interceptors.request.use( - (config: AxiosRequestConfig) => Promise.resolve(config), + (config: axios.AxiosRequestConfig) => Promise.resolve(config), (error: any) => Promise.reject(error) ); -axios.interceptors.request.use((config: AxiosRequestConfig) => config); -axios.interceptors.request.use((config: AxiosRequestConfig) => Promise.resolve(config)); +axios.interceptors.request.use((config: axios.AxiosRequestConfig) => config); +axios.interceptors.request.use((config: axios.AxiosRequestConfig) => Promise.resolve(config)); const responseInterceptorId: number = axios.interceptors.response.use( - (response: AxiosResponse) => response, + (response: axios.AxiosResponse) => response, (error: any) => Promise.reject(error) ); axios.interceptors.response.eject(responseInterceptorId); axios.interceptors.response.use( - (response: AxiosResponse) => Promise.resolve(response), + (response: axios.AxiosResponse) => Promise.resolve(response), (error: any) => Promise.reject(error) ); -axios.interceptors.response.use((response: AxiosResponse) => response); -axios.interceptors.response.use((response: AxiosResponse) => Promise.resolve(response)); +axios.interceptors.response.use((response: axios.AxiosResponse) => response); +axios.interceptors.response.use((response: axios.AxiosResponse) => Promise.resolve(response)); // Adapters -const adapter: AxiosAdapter = (config: AxiosRequestConfig) => { - const response: AxiosResponse = { +const adapter: axios.AxiosAdapter = (config: axios.AxiosRequestConfig) => { + const response: axios.AxiosResponse = { data: { foo: 'bar' }, status: 200, statusText: 'OK', @@ -335,19 +325,19 @@ const fn2: (arr: number[]) => string = axios.spread(fn1); // Promises axios.get('/user') - .then((response: AxiosResponse) => 'foo') + .then((response: axios.AxiosResponse) => 'foo') .then((value: string) => {}); axios.get('/user') - .then((response: AxiosResponse) => Promise.resolve('foo')) + .then((response: axios.AxiosResponse) => Promise.resolve('foo')) .then((value: string) => {}); axios.get('/user') - .then((response: AxiosResponse) => 'foo', (error: any) => 'bar') + .then((response: axios.AxiosResponse) => 'foo', (error: any) => 'bar') .then((value: string) => {}); axios.get('/user') - .then((response: AxiosResponse) => 'foo', (error: any) => 123) + .then((response: axios.AxiosResponse) => 'foo', (error: any) => 123) .then((value: string | number) => {}); axios.get('/user') @@ -360,13 +350,13 @@ axios.get('/user') // Cancellation -const source: CancelTokenSource = axios.CancelToken.source(); +const source: axios.CancelTokenSource = axios.CancelToken.source(); axios.get('/user', { cancelToken: source.token -}).catch((thrown: AxiosError | Cancel) => { +}).catch((thrown: axios.AxiosError | axios.Cancel) => { if (axios.isCancel(thrown)) { - const cancel: Cancel = thrown; + const cancel: axios.Cancel = thrown; console.log(cancel.message); } }); @@ -378,7 +368,7 @@ source.cancel('Operation has been canceled.'); axios.get('/user') .catch((error) => { if (axios.isAxiosError(error)) { - const axiosError: AxiosError = error; + const axiosError: axios.AxiosError = error; } }); diff --git a/tsconfig.json b/tsconfig.json index 66651882..815d633e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,6 @@ { "compilerOptions": { - "module": "es2015", + "module": "commonjs", "lib": ["dom", "es2015"], "types": [], "moduleResolution": "node", From d481a8a207e1459a6c5a5608ab6cd1049bb64500 Mon Sep 17 00:00:00 2001 From: letohx <99612194+letohx@users.noreply.github.com> Date: Thu, 30 Jan 2025 22:37:48 +0300 Subject: [PATCH 8/8] chore(docs): update CODE_OF_CONDUCT.md (#6012) chore(docs): update CODE_OF_CONDUCT.md (#6012) --- CODE_OF_CONDUCT.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index ac813664..5c462e38 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -60,7 +60,7 @@ representative at an online or offline event. Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -[INSERT CONTACT METHOD]. +[jasonsaayman](https://github.com/jasonsaayman). All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the