Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into next-013
Browse files Browse the repository at this point in the history
  • Loading branch information
igorkamyshev committed Nov 28, 2024
2 parents 7f303b9 + 99acd3f commit f6cb111
Show file tree
Hide file tree
Showing 69 changed files with 571 additions and 998 deletions.
2 changes: 2 additions & 0 deletions .changeset/soft-meals-travel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
---
83 changes: 0 additions & 83 deletions .github/workflows/canary.yml

This file was deleted.

32 changes: 0 additions & 32 deletions .github/workflows/website.yml

This file was deleted.

2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,5 @@ Special thanks to all contributors and especially [Alexandr](https://github.com/
Some of external libraries were inlined to Farfetched due to bundle size and custom features requirements:

- https://github.com/effector/patronum
- https://github.com/emn178/js-sha1/blob/master/tests/test.js
- http://www.movable-type.co.uk/scripts/sha1.html
- https://github.com/smelukov/nano-equal
- https://github.com/DirtyHairy/async-mutex
6 changes: 3 additions & 3 deletions apps/website/changelog/cli.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,19 @@ function mergeChangelogs(packages) {
)) {
const logForVersion = [];
for (const { name: packageName, changes: packageChanges } of packages) {
const pacakgeChangesEntries = Object.entries(packageChanges)
const packageChangesEntries = Object.entries(packageChanges)
.map(([type, items]) => [type, excludeTrashUpdates(items)])
.filter(([, items]) => items.length > 0);

let hasChanges = pacakgeChangesEntries.length > 0;
let hasChanges = packageChangesEntries.length > 0;

if (!hasChanges) {
continue;
}

logForVersion.push(['para', `::: details ${packageName}`]);

for (const [type, items] of pacakgeChangesEntries) {
for (const [type, items] of packageChangesEntries) {
logForVersion.push(['para', ['strong', type]], ...items);
}

Expand Down
7 changes: 3 additions & 4 deletions apps/website/docs/.vitepress/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,6 @@ export default withMermaid(
text: 'Deep dive',
collapsed: false,
items: [
{ text: 'Unique store identifiers', link: '/recipes/sids' },
{
text: 'Data flow in Remote Operation',
link: '/recipes/data_flow',
Expand Down Expand Up @@ -366,19 +365,19 @@ export default withMermaid(
items: [
{
text: 'SolidJS',
link: 'https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase/solid-real-world-rick-morty',
link: 'https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase-solid-real-world-rick-morty',
},
{
text: 'React and React Router',
link: 'https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase/react-real-world-pokemons',
link: 'https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase-react-real-world-pokemons',
},
{
text: 'Next.js',
link: 'https://github.com/effector/next/tree/main/apps/playground-app',
},
{
text: 'Forest',
link: 'https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase/forest-real-world-breaking-bad',
link: 'https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase-forest-real-world-breaking-bad',
},
],
},
Expand Down
6 changes: 3 additions & 3 deletions apps/website/docs/api/contracts/runtypes.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ npm install runtypes @farfetched/runtypes

## Showcases

- [Real-world showcase with SolidJS around JSON API](https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase/solid-real-world-rick-morty/)
- [Real-world showcase with React around JSON API](https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase/react-real-world-pokemons/)
- [Real-world showcase with Forest around JSON API](https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase/forest-real-world-breaking-bad/)
- [Real-world showcase with SolidJS around JSON API](https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase-solid-real-world-rick-morty/)
- [Real-world showcase with React around JSON API](https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase-react-real-world-pokemons/)
- [Real-world showcase with Forest around JSON API](https://github.com/igorkamyshev/farfetched/tree/master/apps/showcase-forest-real-world-breaking-bad/)

## `runtypeContract`

Expand Down
4 changes: 2 additions & 2 deletions apps/website/docs/api/factories/create_barrier.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ Configuration fields:
### `createBarrier({ activateOn, perform })`

```ts
import { createBarrier, isHttpError } from '@farfetched/core';
import { createBarrier, isHttpErrorCode } from '@farfetched/core';
import { combine } from 'effector';

const authBarrier = createBarrier({
activateOn: {
failure: isHttpError(401),
failure: isHttpErrorCode(401),
},
perform: [renewTokenMutationFx],
});
Expand Down
9 changes: 9 additions & 0 deletions apps/website/docs/api/primitives/query.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ outline: [2, 3]

Representation of a piece of remote data.

::: info Rule of thumb:

- some piece of data is stored in a remote location (like a server)
- its local representation can be be easily deleted and re-fetched from the remote location

So, it is a good candidate for a _Query_.

:::

## Commands

This section describes the [_Event_](https://effector.dev/en/api/effector/event/) that can be used to perform actions on the _Query_. Commands should be called in application code.
Expand Down
8 changes: 4 additions & 4 deletions apps/website/docs/recipes/cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ To achieve this, Every [_Query_](/api/primitives/query) exposes `.__.lowLevelAPI

## Cache key generation

[`cache`](/api/operators/cache) does not require any manual key generation to work, it uses the [SID](/recipes/sids) of the [_Query_](/api/primitives/query) and all external [_Stores_](https://effector.dev/en/api/effector/store/) that affect [_Query_](/api/primitives/query) to create a unique identifier for every cache entry. It means, key generation is fully automatic, and you don't need to worry about it.
[`cache`](/api/operators/cache) does not require any manual key generation to work, it uses the [SID](https://effector.dev/en/explanation/sids/) of the [_Query_](/api/primitives/query) and all external [_Stores_](https://effector.dev/en/api/effector/store/) that affect [_Query_](/api/primitives/query) to create a unique identifier for every cache entry. It means, key generation is fully automatic, and you don't need to worry about it.

### Sources extraction

Expand Down Expand Up @@ -86,7 +86,7 @@ Static nature of [Effector](/statements/effector) allows us to perform this tran

### SID

Every [_Query_](/api/primitives/query) has a unique identifier — [SID](/recipes/sids). Effector provides a couple of plugins for automatic SIDs generation.
Every [_Query_](/api/primitives/query) has a unique identifier — [SID](https://effector.dev/en/explanation/sids/). Effector provides a couple of plugins for automatic SIDs generation.

<!--@include: ../shared/sids_plugins.md-->

Expand All @@ -98,10 +98,10 @@ So, the key is a hash of the following data:
- `params` of the particular call of the [_Query_](/api/primitives/query)
- current values of all external [_Stores_](https://effector.dev/en/api/effector/store/) that affect [_Query_](/api/primitives/query)

To get short and unique key, we stringify all data, concatenate it and then hash it with [SHA-1](https://en.wikipedia.org/wiki/SHA-1).
To get short and unique key, we stringify all data, concatenate it and then hash it with [custom hash function](https://github.com/igorkamyshev/farfetched/blob/master/packages/core/src/cache/lib/hash.ts).

:::tip
SHA-1 is a [cryptographically broken](https://blog.mozilla.org/security/2017/02/23/the-end-of-sha-1-on-the-public-web/), but we use it for key generation only, so it is safe to use it in this case.
It is a cryptographically broken, but we use it for key generation only, so it is safe to use it in this case.
:::

## Adapter replacement
Expand Down
2 changes: 1 addition & 1 deletion apps/website/docs/recipes/form_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ const uploadPhotoMutation = createUploadFileMutation();
### SSR, `cache` and DevTools support

::: tip Deep dive
If you want to learn more about the reasons behind this requirement, please read [this article](/recipes/sids).
If you want to learn more about the reasons behind this requirement, please read [this article](https://effector.dev/en/explanation/sids/).
:::

If you use Farfetched in SSR, want to use [DevTools](/tutorial/devtools) or [`cache`](/api/operators/cache), you need to provide a unique name for each [_Mutation_](/api/primitives/mutation). It can be done by passing the `name` option to the [`createMutation`](/api/factories/create_mutation) factory:
Expand Down
2 changes: 1 addition & 1 deletion apps/website/docs/recipes/graphql_query.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function createGraphQLQuery(config) {
```

:::tip
Do not forget to add path of the factory to a factories list in the [code transformations configuration](/recipes/sids).
Do not forget to add path of the factory to a factories list in the [code transformations configuration](https://effector.dev/en/explanation/sids/).
:::

Now, we have to write code with mapping from config of `createGraphQLQuery` to config of `createJsonQuery`.
Expand Down
4 changes: 2 additions & 2 deletions apps/website/docs/recipes/no_fetch.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ import { createMutation } from '@farfetched/core';
import axios from 'axios';

const loginMutation = createMutation({
async handler({ login, password } {
const response = await axios.post('/login', { login, password })
async handler({ login, password }) {
const response = await axios.post('/login', { login, password });

return response.data;
},
Expand Down
2 changes: 1 addition & 1 deletion apps/website/docs/recipes/server_cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Let's talk about [caching](/tutorial/caching) and [SSR](/recipes/ssr) in the sin

## Pre-requisites

Do not forget that [`cache`](/api/operators/cache) operator requires setting up [SIDs](/recipes/sids) in your application. It can be done by using code transformation tools.
Do not forget that [`cache`](/api/operators/cache) operator requires setting up [SIDs](https://effector.dev/en/explanation/sids/) in your application. It can be done by using code transformation tools.

<!--@include: ../shared/sids_plugins.md-->

Expand Down
Loading

0 comments on commit f6cb111

Please sign in to comment.