-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
feat: add dedupe feature, params option, and more as v1 #99
Conversation
feat: Add params feature - Added vite-env.d.ts file for Vite client types - Added tsconfig.json file for TypeScript configuration - Added pnpm-workspace.yaml file for pnpm workspace configuration - Deleted tsconfig.eslint.json file - Added client.ts file with a fetchStuff function - Added README.md file with installation and run instructions - Added .gitignore file to ignore logs, editor files, and build artifacts - Added server.ts file with a foo variable and console.log statements - Updated eslint.config.js file to use tsconfig.json as the default project - Added index.html file with basic HTML structure and script import - Updated autofix.yml, size-limit.yml, lint-and-type.yml, test--release-and-publish.yml, and changeset--release-and-publish.yml workflows to use pnpm version 9.10.0 - Updated package.json file with dependencies and devDependencies - Added pnpm-lock.yaml file with lockfile information - Updated types.ts file to include params property in ExtraOptions interface - Updated typeof.ts file to use isArray and isString helper functions - Updated theme.config.tsx file to remove eslint-disable comments - Added vite.svg file for Vite logo
|
✅ Deploy Preview for zayne-callapi canceled.
|
commit: |
The dedupeStrategy option in the createFetchClient function has been updated to use the "cancel" strategy instead of the deprecated cancelRedundantRequests option. This change ensures that the previous pending request to the same URL will be cancelled and allows the new request to go through. The cancelRedundantRequests option is now deprecated and should be replaced with dedupeStrategy === "cancel". Refactor the code in createFetchClient.ts to reflect this change.
The createFetchClient function now supports a new dedupeStrategy option that allows controlling the behavior when a duplicate request is detected. The "cancel" strategy will cancel the previous pending request, while the "defer" strategy will return the response from the previous request. This change ensures that the previous pending request to the same URL will be cancelled and allows the new request to go through. The cancelRedundantRequests option is now deprecated and should be replaced with dedupeStrategy === "cancel". Additionally, the types.ts and utils.ts files have been updated to support the new dedupeStrategy option and related functionality.
refactor: ensure caching mechanism only works if a key is available
…recate cancelRedundantRequests option, and stabilize current API
…recate cancelRedundantRequests option, and stabilize current API
… createFetchClient
This commit updates the map types in the `types.ts` file and adds a new type helper called `Awaitable` in the `type-helpers.ts` file. The map types have been modified to include the `Awaitable` type, which represents a promise or a non-promise value. This change improves the type safety and readability of the codebase. Refactor the map types and add Awaitable type helper
This commit deduplicates interceptors in the `handleMergeInterceptors` function. It ensures that only unique interceptors are executed by creating a new array of unique interceptors before mapping and executing them. This change improves the efficiency and reliability of the interceptor handling logic. Additionally, this commit updates the package.json version to 1.0.0-rc-7.
…st deduplication - Update the resolveHeaders function to handle various types of auth and body options - Add requestKey option to callApi function in dev/src/client.ts - Enhance error handling in createFetchClient to better distinguish between HTTP and JavaScript errors - Improve request deduplication logic to provide more informative abort messages - Add Register interface to allow custom meta types
…llation messaging
- Fix isHTTPError type guard with explicit return type, as the inferred one stopped working - Replace PossibleJavascriptErrorNames with explicit error name union - Update error type checking to use isPlainObject for better accuracy - Fix bug in resolveErrorResult where error data was not being set correctly
Rename withConfig directory to options for better semantic meaning and update related imports
🎯 What: - Moved URL and plugin logic into dedicated files - Extracted constants into separate utility file - Enhanced type definitions in both packages - Removed unused dev server files 💡 Why: - Better code organization and maintainability - Improved type safety and developer experience - Reduced code duplication between packages 🔧 Changes: - Created new files: plugins.ts, url.ts, constants.ts - Updated package dependencies - Refined type helpers and common utilities - Streamlined fetch client implementation 📦 Packages affected: - callapi - callapi-legacy
…ling - Introduce `mergedInterceptorsExecutionOrder` option to control the order of execution for merged interceptors - Refactor `initializePlugins` function to handle the new `mergedInterceptorsExecutionOrder` option - Update `createFetchClient` and `createFetchClientWithOptions` to use the new `interceptors` object from `initializePlugins` - Bump package versions to reflect the changes
…bility. - Updated version number to "1.0.0-rc.28" in the package.json file. - Refactored the way headers are handled and added a new function to retrieve headers in the createFetchClient function. - Update the plugin initialization configuration to use a base configuration in the callapi-legacy package. - Updated the response to the user's request: Changed the responseParser function to return an Awaitable object and updated the responseType to use the getResponseType function instead of handleResponseType. Added the plugins property to the BaseCallApiExtraOptions interface to allow extending the library's behavior. - Refactored URL generation function to correctly replace parameters in the URL string. - The main goal of the changes is to add functions for picking and omitting keys from objects, as well as functions for splitting and generating configurations in a TypeScript file related to API calls. - Refactor isPlainObject function to improve code readability by ignoring prettier formatting for a specific condition. - Updated the version in the package.json file to "1.0.0-rc.46". - Update the headers handling and request key generation in the createFetchClient function. - The main goal of the changes is to refactor the way headers are handled and to introduce a new mergedInterceptorsExecutionOrder option in the createFetchClientWithOptions function. - Update the plugin initialization configuration to use a base configuration in the callapi module. - Updated the response to the user's request: The main goal of the changes is to update the reference from `handleResponseType` to `getResponseType` in the `responseType` property and add a new `Awaitable` type to the `responseParser` property. - The main goal of the changes is to update the way URL parameters are replaced in the `mergeUrlWithParams` function. - The main goal of the changes is to add functions for picking and omitting keys from objects, splitting base and regular configurations, generating request keys, and handling response types in a TypeScript file. - Refactored the isPlainObject function to improve code readability by using prettier-ignore for a specific condition.
- Updated the version in package.json to "1.0.0-rc.30". - Refactor response handling and cloning logic in createFetchClient function. - Added a custom function to validate response error data from the API. - The main goal of the changes is to add a new parameter for validation in the getResponseData function and update the resolveSuccessResult function to use the new data parameter instead of successData. - Updated the version in the package.json file to "1.0.0-rc.48". - Refactor response handling to clone only when necessary and simplify data validation and handling. - The main goal of the changes is to ensure the response is cloned when specific strategies are set to avoid errors from reading the response more than once. - Added a custom function to validate response error data from the API. - The main goal of the changes is to add a new parameter for validation in the getResponseData function and update the resolveSuccessResult function to use the new data parameter instead of successData.
feat: Add params feature
feat: Add dedupe feature
feat!: move cjs support to legacy entrypoint
refactor: cleaned up some parts of the logic
feat!: deprecate cancelRedundantRequest option
feat: add plugin support
feat: add callApiOptions support, just like query options
feat: add support for responseErrorValidation
feat: improved types
feat: a few code and perf improvements
Description
Please include a summary of the change and which issue is fixed (if applicable).
Related Issue
Contribution Guidelines
Before submitting this pull request, please review our Contribution Guidelines to understand how to contribute to this project.
Checklist
Screenshots (if applicable)
Additional context (if needed)