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

feat: add dedupe feature, params option, and more #99

Open
wants to merge 78 commits into
base: main
Choose a base branch
from

Conversation

Ryan-Zayne
Copy link
Member

@Ryan-Zayne Ryan-Zayne commented Sep 17, 2024

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 support for composing interceptors, and relevant options
feat: a few code and perf improvements

  • 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

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

  • I have reviewed the Contribution Guidelines linked above.
  • I have tested my changes thoroughly and ensured that all existing tests pass.
  • I have provided clear and concise commit messages.
  • I have updated the project's documentation as necessary.

Screenshots (if applicable)

Additional context (if needed)

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
@Ryan-Zayne Ryan-Zayne linked an issue Sep 17, 2024 that may be closed by this pull request
Copy link

changeset-bot bot commented Sep 17, 2024

🦋 Changeset detected

Latest commit: 7a5a22b

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

netlify bot commented Sep 17, 2024

Deploy Preview for zayne-callapi canceled.

Name Link
🔨 Latest commit e950750
🔍 Latest deploy log https://app.netlify.com/sites/zayne-callapi/deploys/6748b88d4870700008584f93

Copy link

pkg-pr-new bot commented Sep 17, 2024

Open in Stackblitz

npm i https://pkg.pr.new/zayne-labs/call-api/@zayne-labs/callapi-legacy@99

commit: e950750

@Ryan-Zayne Ryan-Zayne changed the title feat: Add Vite configuration files and dependencies feat: Add Vite configuration files and Params feature Sep 17, 2024
@Ryan-Zayne Ryan-Zayne linked an issue Sep 17, 2024 that may be closed by this pull request
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
@Ryan-Zayne Ryan-Zayne marked this pull request as ready for review September 19, 2024 16:51
Ryan-Zayne and others added 16 commits September 19, 2024 17:52
…recate cancelRedundantRequests option, and stabilize current API
…recate cancelRedundantRequests option, and stabilize current API
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
@Ryan-Zayne Ryan-Zayne changed the title feat: Add Vite configuration files and Params feature feat: Add Dedupe and Params feature Sep 22, 2024
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.
…n and utility functions

feat(callapi-legacy): Release package to cater for the needs of older node versions
fix(eslint): adjust tsconfigPath to include an empty string for ESLint configuration
fix(eslint): specify tsconfig path for dev environment
fix(package): update lint:eslint script to build before linting
fix(callapi): update Node.js engine version in package.json
fix(callapi-legacy): update Node.js engine version in package.json
fix(docs): update _app.tsx to import tailwind.css
fix(dependencies): add new ESLint plugins to devDependencies
fix(eslint): enhance ESLint configuration for React and Next.js
…equestKey option

- Enhance resolveHeaders function to handle various types of auth and body options
- Add requestKey option to callApi function in dev/src/client.ts
…lveHeaders function

- Update the RequestOptions interface to use Pick<RequestInit, FetchSpecificKeysUnion> instead of extending CallApiConfig
- Update the resolveHeaders function to use the request.body and request.headers instead of options.body and options.headers
…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
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant