Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve compatibility #68

Merged
merged 54 commits into from
Sep 30, 2024
Merged

Improve compatibility #68

merged 54 commits into from
Sep 30, 2024

Conversation

MattCCC
Copy link
Owner

@MattCCC MattCCC commented Sep 22, 2024

Features:

  • Typings: Added Query Params, Path Params and Request Body generics to endpoints API, request() and fetchf() functions

Improvements:

  • Added sideEffects false for more aggressive minification in bundlers
  • Pointed default entry point to unpkg as ESM
  • Size monitoring for Node.js build output when building
  • Typings: Custom fetcher options typings - should infer Response Data
  • Typings: Polling error object typings - should infer Response Data
  • Typings: Infer response data in request config when using createApiFetcher()
  • Typings: Updated ApiHandlerMethods -> ApiHandlerDefaultMethods and ApiHandlerReturnType -> ApiHandlerMethods
  • Performance: Don't remove withCredentials and data properties from final fetch object

Fixes:

  • Typings: Set default response type to any instead of never
  • Typings: Response Data when error is returned
  • Typings: Query Params, Url Path Params and Body Payload can infer whole generic interfaces instead of only values
  • Typings: Properly infer TS generics in Endpoint type
  • api.request() was not accepting custom URLs

Docs:

  • Added more information about Compatibility and Polyfills
  • Added section about Headers together with default headers being injected
  • Added section about Response Data Transformation
  • Added section about Automatic Request Cancellation
  • "Multiple API Specific Settings" info regarding general settings moved to the Basic Settings section
  • Updated JSDoc of API Handler interfaces
  • Update generic Typings sections
  • Add Plugin API Architecture section

Breaking changes:

  • Simplified endpoints API in createApiFetcher() - removed queryParamsOrBody and urlPathParams arguments from request() function. Use requestConfig params or body instead.
  • If flattenResponse is set to true, only the data is affected by flattening. It means that the whole response is always returned which increases predictability. If you set flattenResponse anywhere, in order to migrate replace all const data = with const { data } =
  • Locked down build to minimum version of Node.js 18+ as per docs (smaller bundle)
  • Builds should be in ES2018+ mode (smaller bundle; use transpiler if you need older versions)

@MattCCC MattCCC self-assigned this Sep 22, 2024
Copy link

github-actions bot commented Sep 22, 2024

size-limit report 📦

Path Size
dist/browser/index.mjs 3.24 KB (-3.92% 🔽)
dist/browser/index.global.js 3.4 KB (-3.2% 🔽)
dist/node/index.js 3.34 KB (+100% 🔺)

@MattCCC
Copy link
Owner Author

MattCCC commented Sep 22, 2024

Due to possibly breaking changes this will be the next major version.

@MattCCC
Copy link
Owner Author

MattCCC commented Sep 22, 2024

Fixes #66

@MattCCC MattCCC changed the base branch from master to dev September 24, 2024 01:28
@MattCCC MattCCC merged commit 34c3cc2 into dev Sep 30, 2024
7 checks passed
@MattCCC MattCCC deleted the improve-compatibility branch September 30, 2024 22:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants