diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59cac63..9d54f0c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -81,7 +81,7 @@ jobs: @tanstack/react-router@1.132.0 @tanstack/react-start@1.169.0 \ react-router@7.0.0 next@16.0.0 expo-router@5.0.2 \ expo-secure-store@14.2.0 react-native@0.79.0 effect@4.1.0 \ - @monarcode/effetch@0.1.0-rc.3 + @monarcode/effetch@0.1.0-rc.4 - name: Build and test run: pnpm run build && pnpm test && pnpm run test:types diff --git a/CHANGELOG.md b/CHANGELOG.md index b5ec993..4914875 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,28 @@ # Changelog +## 0.1.0-rc.2 + +For effetch `0.1.0-rc.4`, whose main entry now exports only the `Fetch` +namespace, and effetch-query `0.1.0-rc.4`, which needs it. Session kit's own +API is unchanged. + +### Changed + +- **Breaking for effetch users:** the `@monarcode/effetch` peer range is + `^0.1.0-rc.4`, up from `rc.3`. `./effetch` now imports effetch's `Fetch` + namespace, so it needs rc.4. Session kit `0.1.0-rc.1` and earlier fail to + load `./effetch` with effetch rc.4, though their peer ranges accept it. + Upgrade Session kit, effetch and effetch-query together. +- In your own code, `import * as Fetch from "@monarcode/effetch"` becomes + `import { Fetch } from "@monarcode/effetch"`. effetch's `effetch-migrate` + rewrites these imports for you. Imports from Session kit stay the same. + +### Docs + +- The Effect guide, `sessionBearer`'s example and the TanStack Start example + with effetch import `{ Fetch }`, and the guide asks for effetch and + effetch-query `0.1.0-rc.4`. + ## 0.1.0-rc.1 The Effect guide and example move to effetch and effetch-query `0.1.0-rc.3`. diff --git a/examples/tanstack-start-spa-effetch/package.json b/examples/tanstack-start-spa-effetch/package.json index 35b0445..b8f0e83 100644 --- a/examples/tanstack-start-spa-effetch/package.json +++ b/examples/tanstack-start-spa-effetch/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@effect/atom-react": "4.1.3", - "@monarcode/effetch": "0.1.0-rc.3", - "@monarcode/effetch-query": "0.1.0-rc.3", + "@monarcode/effetch": "0.1.0-rc.4", + "@monarcode/effetch-query": "0.1.0-rc.4", "@monarcode/session-kit": "workspace:*", "@tanstack/react-router": "1.170.46", "@tanstack/react-start": "1.169.5", diff --git a/examples/tanstack-start-spa-effetch/src/api.ts b/examples/tanstack-start-spa-effetch/src/api.ts index c6ac8cf..520fc40 100644 --- a/examples/tanstack-start-spa-effetch/src/api.ts +++ b/examples/tanstack-start-spa-effetch/src/api.ts @@ -1,4 +1,4 @@ -import * as Fetch from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import { retry } from "@monarcode/effetch/plugins"; import { sessionBearer } from "@monarcode/session-kit/effetch"; import * as HttpClient from "effect/http/HttpClient"; diff --git a/examples/tanstack-start-spa-effetch/src/endpoints.ts b/examples/tanstack-start-spa-effetch/src/endpoints.ts index 81fbafc..07fbeca 100644 --- a/examples/tanstack-start-spa-effetch/src/endpoints.ts +++ b/examples/tanstack-start-spa-effetch/src/endpoints.ts @@ -1,4 +1,4 @@ -import * as Fetch from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import * as Schema from "effect/Schema"; import { SessionTokens } from "./backend"; diff --git a/examples/tanstack-start-spa-effetch/src/error-message.ts b/examples/tanstack-start-spa-effetch/src/error-message.ts index 770f77c..99e8a34 100644 --- a/examples/tanstack-start-spa-effetch/src/error-message.ts +++ b/examples/tanstack-start-spa-effetch/src/error-message.ts @@ -1,4 +1,4 @@ -import type { DecodeError, HttpError, NetworkError } from "@monarcode/effetch"; +import type { Fetch } from "@monarcode/effetch"; import type { AuthFailure } from "@monarcode/session-kit/effect"; import * as Cause from "effect/Cause"; import * as Match from "effect/Match"; @@ -7,9 +7,9 @@ import * as Option from "effect/Option"; import type { ApiError } from "./backend"; type ApiCallError = - | HttpError.With - | NetworkError - | DecodeError + | Fetch.HttpError.With + | Fetch.NetworkError + | Fetch.DecodeError | AuthFailure; /** diff --git a/examples/tanstack-start-spa-effetch/src/refresh.ts b/examples/tanstack-start-spa-effetch/src/refresh.ts index d4e7d0c..e11e292 100644 --- a/examples/tanstack-start-spa-effetch/src/refresh.ts +++ b/examples/tanstack-start-spa-effetch/src/refresh.ts @@ -1,4 +1,4 @@ -import * as Fetch from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import * as Effect from "effect/Effect"; import * as FetchHttpClient from "effect/http/FetchHttpClient"; import * as HttpClient from "effect/http/HttpClient"; diff --git a/package.json b/package.json index 91a42e4..94c8666 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@monarcode/session-kit", - "version": "0.1.0-rc.1", + "version": "0.1.0-rc.2", "description": "Schema-driven, type-safe sessions for React, with TanStack Router, React Router, Expo Router, Next.js, TanStack Start, and Effect support", "keywords": [ "auth", @@ -123,8 +123,8 @@ "use-sync-external-store": "^1.6.0" }, "devDependencies": { - "@monarcode/effetch": "0.1.0-rc.3", - "@monarcode/effetch-query": "0.1.0-rc.3", + "@monarcode/effetch": "0.1.0-rc.4", + "@monarcode/effetch-query": "0.1.0-rc.4", "@tanstack/react-router": "1.170.46", "@tanstack/react-start": "1.169.5", "@types/jsdom": "21.1.7", @@ -151,7 +151,7 @@ "zod": "4.6.7" }, "peerDependencies": { - "@monarcode/effetch": "^0.1.0-rc.3", + "@monarcode/effetch": "^0.1.0-rc.4", "@tanstack/react-router": "^1.132.0", "@tanstack/react-start": "^1.169.0", "effect": "^4.1.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 402b924..5e18e17 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,11 +19,11 @@ importers: version: 1.7.0(react@19.3.1) devDependencies: '@monarcode/effetch': - specifier: 0.1.0-rc.3 - version: 0.1.0-rc.3(effect@4.1.3) + specifier: 0.1.0-rc.4 + version: 0.1.0-rc.4(effect@4.1.3) '@monarcode/effetch-query': - specifier: 0.1.0-rc.3 - version: 0.1.0-rc.3(@effect/atom-react@4.1.3(effect@4.1.3)(react@19.3.1)(scheduler@0.28.0))(@monarcode/effetch@0.1.0-rc.3(effect@4.1.3))(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(effect@4.1.3)(react@19.3.1) + specifier: 0.1.0-rc.4 + version: 0.1.0-rc.4(@effect/atom-react@4.1.3(effect@4.1.3)(react@19.3.1)(scheduler@0.28.0))(@monarcode/effetch@0.1.0-rc.4(effect@4.1.3))(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(effect@4.1.3)(react@19.3.1) '@tanstack/react-router': specifier: 1.170.46 version: 1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1) @@ -408,11 +408,11 @@ importers: specifier: 4.1.3 version: 4.1.3(effect@4.1.3)(react@19.3.1)(scheduler@0.28.0) '@monarcode/effetch': - specifier: 0.1.0-rc.3 - version: 0.1.0-rc.3(effect@4.1.3) + specifier: 0.1.0-rc.4 + version: 0.1.0-rc.4(effect@4.1.3) '@monarcode/effetch-query': - specifier: 0.1.0-rc.3 - version: 0.1.0-rc.3(@effect/atom-react@4.1.3(effect@4.1.3)(react@19.3.1)(scheduler@0.28.0))(@monarcode/effetch@0.1.0-rc.3(effect@4.1.3))(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(effect@4.1.3)(react@19.3.1) + specifier: 0.1.0-rc.4 + version: 0.1.0-rc.4(@effect/atom-react@4.1.3(effect@4.1.3)(react@19.3.1)(scheduler@0.28.0))(@monarcode/effetch@0.1.0-rc.4(effect@4.1.3))(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(effect@4.1.3)(react@19.3.1) '@monarcode/session-kit': specifier: workspace:* version: link:../.. @@ -1627,11 +1627,11 @@ packages: '@mdx-js/mdx@3.1.1': resolution: {integrity: sha512-f6ZO2ifpwAQIpzGWaBQT2TXxPv6z3RBzQKpVftEWN78Vl/YweF1uwussDx8ECAXVtr3Rs89fKyG9YlzUs9DyGQ==} - '@monarcode/effetch-query@0.1.0-rc.3': - resolution: {integrity: sha512-hfdW4AE7St9izEkHuvdejU/X5smmYwG6T8gRJZa+d8H4DYfpIPKFMHoOBfgXNpx0oXG6J5nWJEPoB0tXNmpTyg==} + '@monarcode/effetch-query@0.1.0-rc.4': + resolution: {integrity: sha512-U6rILi7Qe4NAwUZH2xMKgqvfyci9BfPEuxFE78gr+/Nw/DcT0ycr5skAG4CriB/mqFRLcuCfQAQYZEtauLtlMA==} peerDependencies: '@effect/atom-react': ^4.1.0 - '@monarcode/effetch': '>=0.1.0-rc.3 <0.2.0' + '@monarcode/effetch': '>=0.1.0-rc.4 <0.2.0' '@tanstack/react-router': '>=1.170.33 <2.0.0' effect: ^4.1.0 react: '>=19.0.0 <20.0.0' @@ -1645,8 +1645,9 @@ packages: react: optional: true - '@monarcode/effetch@0.1.0-rc.3': - resolution: {integrity: sha512-LHOELQLZGaouwwvIcMAkovTyvWZ4fbDYgtuN9Xt4QcPgUY8ajQAjIXJTZn5WrHBCl/qA9t1a/jq1TKkMju8uUg==} + '@monarcode/effetch@0.1.0-rc.4': + resolution: {integrity: sha512-457QGbcXWm8BqogaF4twl+2PsxJtszhFa3FPKLiioRMATc1PGqJBzpErCD+hxluiPkB1tgKBn8Abg3+erBv/OA==} + hasBin: true peerDependencies: effect: ^4.0.0 @@ -7278,16 +7279,16 @@ snapshots: transitivePeerDependencies: - supports-color - '@monarcode/effetch-query@0.1.0-rc.3(@effect/atom-react@4.1.3(effect@4.1.3)(react@19.3.1)(scheduler@0.28.0))(@monarcode/effetch@0.1.0-rc.3(effect@4.1.3))(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(effect@4.1.3)(react@19.3.1)': + '@monarcode/effetch-query@0.1.0-rc.4(@effect/atom-react@4.1.3(effect@4.1.3)(react@19.3.1)(scheduler@0.28.0))(@monarcode/effetch@0.1.0-rc.4(effect@4.1.3))(@tanstack/react-router@1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1))(effect@4.1.3)(react@19.3.1)': dependencies: effect: 4.1.3 optionalDependencies: '@effect/atom-react': 4.1.3(effect@4.1.3)(react@19.3.1)(scheduler@0.28.0) - '@monarcode/effetch': 0.1.0-rc.3(effect@4.1.3) + '@monarcode/effetch': 0.1.0-rc.4(effect@4.1.3) '@tanstack/react-router': 1.170.46(react-dom@19.3.1(react@19.3.1))(react@19.3.1) react: 19.3.1 - '@monarcode/effetch@0.1.0-rc.3(effect@4.1.3)': + '@monarcode/effetch@0.1.0-rc.4(effect@4.1.3)': dependencies: effect: 4.1.3 diff --git a/site/content/docs/(latest)/effect.mdx b/site/content/docs/(latest)/effect.mdx index a9e0839..bfcd619 100644 --- a/site/content/docs/(latest)/effect.mdx +++ b/site/content/docs/(latest)/effect.mdx @@ -39,10 +39,10 @@ npm install @monarcode/session-kit effect @monarcode/effetch `effect` and `@monarcode/effetch` are optional peer dependencies of Session kit. `./effect` and `./effetch` need `effect` 4.1 or newer, and `./effetch` -also needs `@monarcode/effetch` 0.1.0-rc.3 or newer. +also needs `@monarcode/effetch` 0.1.0-rc.4 or newer. To [cache with effetch-query](#cache-with-effetch-query), also install -effetch-query 0.1.0-rc.3 or newer, and its `@effect/atom-react` peer for +effetch-query 0.1.0-rc.4 or newer, and its `@effect/atom-react` peer for React: ```npm @@ -103,7 +103,7 @@ and fails for anything else, as [Refresh](/docs/configuration/refresh) explains. The server uses it too: ```ts title="src/refresh.ts" -import * as Fetch from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import * as Effect from "effect/Effect"; import * as FetchHttpClient from "effect/http/FetchHttpClient"; import * as HttpClient from "effect/http/HttpClient"; @@ -214,7 +214,7 @@ client's `baseUrl`, since the token goes only to that origin. The client's layer then needs the `Auth` service, once: ```ts title="src/api.ts" -import * as Fetch from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import { retry } from "@monarcode/effetch/plugins"; import { sessionBearer } from "@monarcode/session-kit/effetch"; import * as HttpClient from "effect/http/HttpClient"; @@ -431,7 +431,7 @@ A feature defines the endpoints it caches, and its components use the queries and mutations made of them: ```tsx title="src/features/account.tsx" -import * as Fetch from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import { useMutation, useQuery } from "@monarcode/effetch-query/react"; import { useAuthClient } from "@monarcode/session-kit/react"; import * as Exit from "effect/Exit"; diff --git a/site/content/docs/(latest)/reference/compatibility.mdx b/site/content/docs/(latest)/reference/compatibility.mdx index 50943ae..ceb2ff8 100644 --- a/site/content/docs/(latest)/reference/compatibility.mdx +++ b/site/content/docs/(latest)/reference/compatibility.mdx @@ -19,7 +19,7 @@ import use: | `react-router` | `^7.0.0 \|\| ^8.0.0` | `/react-router`, `/react-router/server` | | `next` | `^16.0.0` | `/next` | | `effect` | `^4.1.0` | `/effect`, `/effetch` | -| `@monarcode/effetch` | `^0.1.0-rc.3` | `/effetch` | +| `@monarcode/effetch` | `^0.1.0-rc.4` | `/effetch` | | `expo-router` | `^5.0.2` through `^58` | `/expo` | | `expo-secure-store` | `^14.2.0` through `^58` | `/expo` | | `expo-file-system` | `^18.1.0` through `^58` | `/expo` | diff --git a/src/effetch/index.ts b/src/effetch/index.ts index 1e65511..247db0d 100644 --- a/src/effetch/index.ts +++ b/src/effetch/index.ts @@ -1,4 +1,4 @@ -import { plugin, type Plugin } from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import * as Effect from "effect/Effect"; import * as FetchHttpClient from "effect/http/FetchHttpClient"; import * as Headers from "effect/http/Headers"; @@ -78,7 +78,7 @@ export interface SessionBearerOptions { * * @since 0.1.0 */ -export type SessionBearerPlugin = Plugin< +export type SessionBearerPlugin = Fetch.Plugin< "sessionBearer", AuthFailure, Auth, @@ -121,8 +121,8 @@ const refuseRedirects = ( * * The token never leaves your API. A request on another origin, or with a * username or password in its URL, dies with `INVALID_OPTIONS`. With - * Effect's `FetchHttpClient`, a redirect fails as a `NetworkError` rather - * than being followed. An invalid `baseUrl` throws `INVALID_OPTIONS`. + * Effect's `FetchHttpClient`, a redirect fails as a `Fetch.NetworkError` + * rather than being followed. An invalid `baseUrl` throws `INVALID_OPTIONS`. * * A request that already has an `Authorization` header is sent as it is, as * effetch's `bearer` does. @@ -138,7 +138,7 @@ const refuseRedirects = ( * ```ts * import * as Effect from "effect/Effect"; * import * as Schema from "effect/Schema"; - * import * as Fetch from "@monarcode/effetch"; + * import { Fetch } from "@monarcode/effetch"; * import { retry } from "@monarcode/effetch/plugins"; * import { sessionBearer } from "@monarcode/session-kit/effetch"; * @@ -164,7 +164,7 @@ export function sessionBearer( options: SessionBearerOptions, ): SessionBearerPlugin { const { origin } = parseUrl(options.baseUrl); - return plugin({ + return Fetch.plugin({ name: "sessionBearer", defaults: { optional: options.optional ?? false, diff --git a/tests/consumer.ts b/tests/consumer.ts index 85b189e..92bb52c 100644 --- a/tests/consumer.ts +++ b/tests/consumer.ts @@ -1,6 +1,6 @@ import type { LoaderFunction, LoaderFunctionArgs } from "react-router"; -import * as Fetch from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import { createRootRouteWithContext, createRoute, diff --git a/tests/effetch.test.ts b/tests/effetch.test.ts index a16280a..dc76b33 100644 --- a/tests/effetch.test.ts +++ b/tests/effetch.test.ts @@ -1,7 +1,7 @@ import assert from "node:assert/strict"; import { test } from "node:test"; -import * as Fetch from "@monarcode/effetch"; +import { Fetch } from "@monarcode/effetch"; import { retry } from "@monarcode/effetch/plugins"; import { AuthError, createMirrorAuth } from "@monarcode/session-kit"; import { Auth, AuthFailure } from "@monarcode/session-kit/effect";