Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 23 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`.
Expand Down
4 changes: 2 additions & 2 deletions examples/tanstack-start-spa-effetch/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion examples/tanstack-start-spa-effetch/src/api.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
2 changes: 1 addition & 1 deletion examples/tanstack-start-spa-effetch/src/endpoints.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
8 changes: 4 additions & 4 deletions examples/tanstack-start-spa-effetch/src/error-message.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -7,9 +7,9 @@ import * as Option from "effect/Option";
import type { ApiError } from "./backend";

type ApiCallError =
| HttpError.With<ApiError>
| NetworkError
| DecodeError
| Fetch.HttpError.With<ApiError>
| Fetch.NetworkError
| Fetch.DecodeError
| AuthFailure;

/**
Expand Down
2 changes: 1 addition & 1 deletion examples/tanstack-start-spa-effetch/src/refresh.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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",
Expand Down
33 changes: 17 additions & 16 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions site/content/docs/(latest)/effect.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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";
Expand Down
2 changes: 1 addition & 1 deletion site/content/docs/(latest)/reference/compatibility.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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` |
Expand Down
12 changes: 6 additions & 6 deletions src/effetch/index.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down Expand Up @@ -78,7 +78,7 @@ export interface SessionBearerOptions {
*
* @since 0.1.0
*/
export type SessionBearerPlugin = Plugin<
export type SessionBearerPlugin = Fetch.Plugin<
"sessionBearer",
AuthFailure,
Auth,
Expand Down Expand Up @@ -121,8 +121,8 @@ const refuseRedirects = <A, E, R>(
*
* 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.
Expand All @@ -138,7 +138,7 @@ const refuseRedirects = <A, E, R>(
* ```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";
*
Expand All @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion tests/consumer.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -635,8 +635,8 @@
const requestAuth: RequestAuth<AppUser, AppUser> = serverAuth.forRequest(jar);
// Its members are read-only; a server's and Next's session's aren't.
// @ts-expect-error RequestAuth's members are read-only.
requestAuth.signIn = requestAuth.signIn;

Check warning on line 638 in tests/consumer.ts

View workflow job for this annotation

GitHub Actions / check

eslint(no-self-assign)

tests/consumer.ts:638:22: this expression is assigned to itself
serverAuth.signIn = serverAuth.signIn;

Check warning on line 639 in tests/consumer.ts

View workflow job for this annotation

GitHub Actions / check

eslint(no-self-assign)

tests/consumer.ts:639:21: this expression is assigned to itself
const anyRequestAuth: RequestAuth<AppUser, any> = requestAuth;
// A request's session is a client for createAuthFetch, in generic code too.
const fetchClient = <U, I>(session: RequestAuth<U, I>): AuthFetchClient =>
Expand Down
2 changes: 1 addition & 1 deletion tests/effetch.test.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand Down
Loading