UNPKG

@procore/core-http

Version:

A HTTP Client

222 lines (127 loc) • 8.94 kB
# Change Log ## 12.0.0 ### Major Changes - 6445f87: Converts project to use hammer, and removes access to any exported "dist" references. Also exports the type `RequestParams`. **Breaking Changes** Since direct access to the "dist" directory as an export is no longer available, you will need to change any import references to reference functions and types from `@procore/core-http` only. Example: ```ts // Before import { RequestParams } from '@procore/core-http/src/request' // After import { type RequestParams } from '@procore/core-http' ``` ## 11.0.2 ### Patch Changes - 534e400: Fixed type exports in package.json. ## 11.0.1 ### Patch Changes - 05ecdc9: Updates the package export to be more narrow. ## 11.0.0 ### Major Changes - 9b814c4: Removes the fetch polyfill from this package. If you still have a need for a fetch polyfill, such as in some test environments or if you are required to support older browsers, such as IE 11, please add the polyfill directly to your project. ## 10.4.1 ### Patch Changes - 61a94b4: linking to workspace prettier for consistency ## 10.4.0 ### Minor Changes - d6ee7d2: dogfooding into core-http the internal packages ### Patch Changes - e72a703: Updates dependencies to latest stable version. All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. # [10.3.0](https://github.com/procore/frontend-tooling/compare/@procore/core-http@10.3.0-rc.0...@procore/core-http@10.3.0) (2022-08-15) **Note:** Version bump only for package @procore/core-http # [10.2.0](https://github.com/procore/frontend-tooling/compare/v10.1.0...v10.2.0) (2022-02-07) ### Bug Fixes - **core-http:** fix invalid test ([65997d4](https://github.com/procore/frontend-tooling/commit/65997d49874856281e17e47cdcc91b961fb7d34c)) - **core-http:** make csrf header conditional ([8bf0ced](https://github.com/procore/frontend-tooling/commit/8bf0ced28a5c9f68d46167a95aaff04947ff677c)) ## [10.0.1](https://github.com/procore/frontend-tooling/compare/v10.0.0...v10.0.1) (2021-08-31) ### Reverts - Revert "chore: publish v10.0.1 [ci skip]" ([19c6447](https://github.com/procore/frontend-tooling/commit/19c644710a9e44266f366a15d46c20595ccf9206)) # [10.0.0](https://github.com/procore/frontend-tooling/compare/v9.6.2...v10.0.0) (2021-05-11) ### Features - pull url from options, make it the first argument ([#250](https://github.com/procore/frontend-tooling/issues/250)) ([c0b61ef](https://github.com/procore/frontend-tooling/commit/c0b61ef4f68de0c38c6d7449cb502478d7fd45a0)) - Webpack 5 ([1353385](https://github.com/procore/frontend-tooling/commit/1353385fbbcda136f002d9e2482d936d58e28714)) # 10.0.0 Refactoring of the entire package to be more streamlined and easier to maintain. ## Breaking Changes - No more `createHttp` to create a client, just use `request` or `requestJSON` directly - `fetch` client is no longer configurable, we now always use `whatwg-fetch` under the hood - Middleware is no longer exported/supported, instead exposed as props to the main requests - baseUrl middleware is replaced with the `baseUrl` option. Supplying it with this option will do the same as setting it up as middleware - defaultHeaders middleware is now just the `headers` option to the request, and does a deep merge of the defaults and the provided headers - if you would like to automatically parse the data field to JSON, please use the `requestJSON` export ## Features - `request` thin wrapper over `fetch` api which injects CSRF token header - `requestJSON` thin wrapper over `request` which automatically parses response as json with text fallback If you would like to create a "client" for minimal code change, similar to how it was previously created: ```typescript import { request as coreHttpRequest } from '@procore/core-http' export default function createHttpClient(baseOptions?: RequestParams) { return function (url: string, options: RequestParams) { return coreHttpRequest(url, { ...baseOptions, ...options }) } } const request = createHttpClient({ baseUrl: 'your base url', headers: { 'CUSTOM-HEADER': 'value', }, }) request('/api/resource.json').then((res) => { if (res.status === 200) { // ... } }) ``` ## [9.6.2](https://github.com/procore/core-scripts/compare/v9.6.0...v9.6.2) (2021-03-24) **Note:** Version bump only for package @procore/core-http ## [9.6.1](https://github.com/procore/core-scripts/compare/v9.6.0...v9.6.1) (2021-03-24) **Note:** Version bump only for package @procore/core-http # 9.6.0 (2021-02-23) ### Features - bumping version to help circle scripts ([#16](https://github.com/procore/core-scripts/issues/16)) ([956948d](https://github.com/procore/core-scripts/commit/956948d7277bd7b0f52cc3c55ab58a23e4f25530)) - moving over aux packages for core-scripts ([3bd40ae](https://github.com/procore/core-scripts/commit/3bd40ae09c239f85e37147f1d6c91760e479bd8d)) # [9.0.0](https://github.com/procore/core/compare/v8.25.0...v9.0.0) (2020-10-09) **Note:** Version bump only for package @procore/core-http # [8.24.0](https://github.com/procore/core/compare/v8.23.1...v8.24.0) (2020-09-28) ### Features - introduce FileSelect component ([#7137](https://github.com/procore/core/issues/7137)) ([7325ab4](https://github.com/procore/core/commit/7325ab403c61633062daecda024d8b76ea0e524a)) ## [8.18.3](https://github.com/procore/core/compare/v8.18.2...v8.18.3) (2020-07-16) ### Bug Fixes - [GLUE-2124] top left portal interrupts pointer events ([#7267](https://github.com/procore/core/issues/7267)) ([d272fe6](https://github.com/procore/core/commit/d272fe650d46251dbe99f4ccb20f4b90ecca473e)) # [8.18.0](https://github.com/procore/core/compare/v8.17.0...v8.18.0) (2020-07-13) **Note:** Version bump only for package @procore/core-http # [8.17.0](https://github.com/procore/core/compare/v8.16.1...v8.17.0) (2020-06-26) **Note:** Version bump only for package @procore/core-http ## [8.16.1](https://github.com/procore/core/compare/v8.16.0...v8.16.1) (2020-06-25) **Note:** Version bump only for package @procore/core-http # [8.16.0](https://github.com/procore/core/compare/v8.15.0...v8.16.0) (2020-06-16) ### Features - **core-react,core-docs,core-css:** introduce FileAttacher component ([66ee19d](https://github.com/procore/core/commit/66ee19db4f45a849760ac5bd6436d1b1bc321985)) # [8.14.0](https://github.com/procore/core/compare/v8.13.0...v8.14.0) (2020-05-21) **Note:** Version bump only for package @procore/core-http # [8.13.0](https://github.com/procore/core/compare/v8.12.0...v8.13.0) (2020-05-20) ### Bug Fixes - **deps:** update dependency @types/jest to v25.2.2 ([#6578](https://github.com/procore/core/issues/6578)) ([183ac23](https://github.com/procore/core/commit/183ac23cd970266032e4aa1f87ff56df9158af22)) - **deps:** update dependency @types/jest to v25.2.3 ([#6641](https://github.com/procore/core/issues/6641)) ([3ae6d7a](https://github.com/procore/core/commit/3ae6d7a40f1dcf56ee4bdc191b78dbeb2b83433f)) # [8.12.0](https://github.com/procore/core/compare/v8.11.0...v8.12.0) (2020-05-08) **Note:** Version bump only for package @procore/core-http # [8.11.0](https://github.com/procore/core/compare/v8.10.0...v8.11.0) (2020-04-27) **Note:** Version bump only for package @procore/core-http # [8.10.0](https://github.com/procore/core/compare/v8.9.1...v8.10.0) (2020-04-10) ### Bug Fixes - **deps:** update dependency @types/jest to v25.2.1 ([#6244](https://github.com/procore/core/issues/6244)) ([e60e8b3](https://github.com/procore/core/commit/e60e8b3eeddd6186c5b233cae82f1313610ba3d6)) - fix return type of client to Promise<Response> ([#6235](https://github.com/procore/core/issues/6235)) ([fc2b24d](https://github.com/procore/core/commit/fc2b24d8be7fe62f13999b175c8bcee53b61762d)) - **deps:** update dependency @types/jest to v25.1.5 ([#6230](https://github.com/procore/core/issues/6230)) ([ec93d82](https://github.com/procore/core/commit/ec93d824b41c746bb1b0f85aa0ecd80d27fada93)) ### Features - [GLUE-2024] Core React Form ([#6055](https://github.com/procore/core/issues/6055)) ([f4e353d](https://github.com/procore/core/commit/f4e353dac7bca99741576ff8677729414e6920fb)) # [8.9.0](https://github.com/procore/core/compare/v8.8.1...v8.9.0) (2020-03-26) ### Bug Fixes - **deps:** update dependency @types/jest to v25.1.4 ([#6028](https://github.com/procore/core/issues/6028)) ([df7dbeb](https://github.com/procore/core/commit/df7dbeb1360314ab030bc51712664fbd220f13be)) # [8.8.0](https://github.com/procore/core/compare/v8.7.0...v8.8.0) (2020-03-05) **Note:** Version bump only for package @procore/core-http # [8.7.0](https://github.com/procore/core/compare/v8.6.0...v8.7.0) (2020-02-28) ### Features - add core-http ([#5770](https://github.com/procore/core/issues/5770)) ([53a8aec](https://github.com/procore/core/commit/53a8aecc47d7b7a9daffb3db0e7fd25d127e3d4e))