@alxia/react-router 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -6
- package/dist/lists/index.d.ts +2 -1
- package/dist/lists/index.d.ts.map +1 -1
- package/dist/lists/index.js +30 -2
- package/dist/lists/index.js.map +5 -4
- package/dist/lists/or-failed.d.ts +19 -0
- package/dist/lists/or-failed.d.ts.map +1 -0
- package/dist/lists/use-search-change.d.ts +10 -5
- package/dist/lists/use-search-change.d.ts.map +1 -1
- package/dist/subscription/index.d.ts +1 -1
- package/dist/subscription/index.d.ts.map +1 -1
- package/dist/subscription/index.js +10 -9
- package/dist/subscription/index.js.map +3 -3
- package/dist/subscription/proxy.d.ts +26 -11
- package/dist/subscription/proxy.d.ts.map +1 -1
- package/docs/guide/lists.md +31 -2
- package/docs/guide/subscriptions.md +14 -6
- package/docs/troubleshooting.md +18 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -997,8 +997,13 @@ connections mode, so `graphql-sse` works against it. It imports nothing and adds
|
|
|
997
997
|
|
|
998
998
|
```ts
|
|
999
999
|
// app/routes/events.ts
|
|
1000
|
-
import {
|
|
1000
|
+
import { alxiaOf } from '@alxia/react-router';
|
|
1001
|
+
import {
|
|
1002
|
+
createSubscriptionProxy,
|
|
1003
|
+
type SubscriptionArgs,
|
|
1004
|
+
} from '@alxia/react-router/subscription';
|
|
1001
1005
|
import { print } from 'graphql';
|
|
1006
|
+
import type { RouterContextProvider } from 'react-router';
|
|
1002
1007
|
import { RoomEventsDocument } from '../generated/graphql';
|
|
1003
1008
|
import { cookies } from '../session.server';
|
|
1004
1009
|
|
|
@@ -1006,8 +1011,12 @@ const events = createSubscriptionProxy({
|
|
|
1006
1011
|
endpoint: 'https://api.example.com/graphql',
|
|
1007
1012
|
allow: { RoomEvents: print(RoomEventsDocument) },
|
|
1008
1013
|
getToken: (request) => cookies.token(request),
|
|
1009
|
-
|
|
1010
|
-
|
|
1014
|
+
// the route's context is the second argument: send the trusted client address
|
|
1015
|
+
headers: (
|
|
1016
|
+
request,
|
|
1017
|
+
{ context }: SubscriptionArgs<Readonly<RouterContextProvider>>,
|
|
1018
|
+
) => ({
|
|
1019
|
+
'x-forwarded-for': context ? alxiaOf(context).ip : null,
|
|
1011
1020
|
'accept-language': request.headers.get('accept-language'),
|
|
1012
1021
|
}),
|
|
1013
1022
|
});
|
|
@@ -1068,7 +1077,19 @@ export default function Users({ loaderData }: Route.ComponentProps) {
|
|
|
1068
1077
|
}
|
|
1069
1078
|
```
|
|
1070
1079
|
|
|
1071
|
-
The loader answers `?after=<cursor>` with the next page. A loader that throws on a cursor request lands on the route's `ErrorBoundary
|
|
1080
|
+
The loader answers `?after=<cursor>` with the next page. A loader that throws on a cursor request lands on the route's `ErrorBoundary`; wrap the read in `orFailed(after, run)` to keep the rows and offer a retry instead:
|
|
1081
|
+
|
|
1082
|
+
```ts
|
|
1083
|
+
import { orFailed } from '@alxia/react-router/lists';
|
|
1084
|
+
|
|
1085
|
+
export function loader({ request }: Route.LoaderArgs) {
|
|
1086
|
+
const url = new URL(request.url);
|
|
1087
|
+
// no ?after: a failure throws (ErrorBoundary); with ?after: it answers { failed: true }
|
|
1088
|
+
return orFailed(url.searchParams.get('after'), () => listUsers(url.searchParams));
|
|
1089
|
+
}
|
|
1090
|
+
```
|
|
1091
|
+
|
|
1092
|
+
`usePagedRows` reads `{ failed: true }` as a page without rows, so it sets `error` and keeps the rows. See [troubleshooting](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/troubleshooting.md). See the
|
|
1072
1093
|
[lists guide](https://github.com/softistx/alxia/blob/develop/packages/react-router/docs/guide/lists.md).
|
|
1073
1094
|
|
|
1074
1095
|
## Traps
|
|
@@ -1280,15 +1301,16 @@ From `@alxia/react-router/lists` (`react` and `react-router` are its only import
|
|
|
1280
1301
|
|
|
1281
1302
|
| export | |
|
|
1282
1303
|
| --- | --- |
|
|
1283
|
-
| `useSearchChange({ resetKeys? })`, `SearchChangeOptions` | `(changes) => void`: sets a parameter given a string, deletes one given `null` or `undefined`, and deletes `resetKeys` (default `['after']`); the history entry is replaced and the scroll position kept |
|
|
1304
|
+
| `useSearchChange({ resetKeys? })`, `SearchChange`, `SearchChangeOptions` | `(changes: SearchChange) => void`: a record sets a parameter given a string, deletes one given `null` or `undefined`, and deletes `resetKeys` (default `['after']`); a `URLSearchParams` replaces the whole search, and an updater `(prev) => URLSearchParams` computes it (`resetKeys` does not apply to these two); the history entry is replaced and the scroll position kept |
|
|
1284
1305
|
| `useSameRouteLoading()` | `true` while a navigation is loading and its pathname is the current one (another search of the list), `false` for any other page |
|
|
1285
1306
|
| `usePagedRows(firstPage, rowsOf, { cursorParam?, nextOf? }?)`, `PagedRows`, `PagedRowsOptions` | `{ rows, next, loading, error, loadMore }`: appends the pages the same route answers to `?<cursorParam>=<next>` (default `after`, `nextOf` default `page.next`) through `useFetcher`; starts over when `firstPage` is another object; a failure keeps the rows and sets `error` (an answer that is not a page), and data that is not a page is ignored |
|
|
1307
|
+
| `orFailed(after, run)`, `FAILED`, `isFailedPage(value)`, `FailedPage` | the loader half of `usePagedRows`: `run()`'s answer; an error is rethrown when `after` is empty, and with an `after` it answers `FAILED` (`{ failed: true }`, typed `Promise<T \| FailedPage>`), except a 3xx `Response`, which is rethrown. `isFailedPage` narrows an answer |
|
|
1286
1308
|
|
|
1287
1309
|
From `@alxia/react-router/subscription` (no import, no peer):
|
|
1288
1310
|
|
|
1289
1311
|
| export | |
|
|
1290
1312
|
| --- | --- |
|
|
1291
|
-
| `createSubscriptionProxy({ endpoint, allow, getToken, headers?, origin?, heartbeatMs?, fetch? })`, `SubscriptionProxy`, `SubscriptionProxyOptions` | a resource route's `loader` (GET) and `action` (POST) relaying GraphQL subscriptions over SSE (graphql-sse's distinct connections mode). `allow` is `{ [operationName]: document }`: the proxy sends its own document, the client's `query` and `extensions` are ignored and an unknown name is a 403. Both methods refuse a cross-site request (403) and a POST that is not JSON (415); 401 without a token; 400 for a malformed or oversize request (body 64 KiB, query string and variables 16 KiB); the bearer and `headers` upstream, a heartbeat comment every `heartbeatMs` (15000), the upstream aborted with the client, a pulled relay with a 1 MiB cap per event, an upstream 429 passed on with `Retry-After` and `retryAfter`, 502 for an upstream failure |
|
|
1313
|
+
| `createSubscriptionProxy({ endpoint, allow, getToken, headers?, origin?, heartbeatMs?, fetch? })`, `SubscriptionProxy`, `SubscriptionProxyOptions`, `SubscriptionArgs` | a resource route's `loader` (GET) and `action` (POST) relaying GraphQL subscriptions over SSE (graphql-sse's distinct connections mode). `allow` is `{ [operationName]: document }`: the proxy sends its own document, the client's `query` and `extensions` are ignored and an unknown name is a 403. Both methods refuse a cross-site request (403) and a POST that is not JSON (415); 401 without a token; 400 for a malformed or oversize request (body 64 KiB, query string and variables 16 KiB); the bearer and `headers` upstream (`headers(request, { request, context, params })`: a function gets the route's context, which never leaves it), a heartbeat comment every `heartbeatMs` (15000), the upstream aborted with the client, a pulled relay with a 1 MiB cap per event, an upstream 429 passed on with `Retry-After` and `retryAfter`, 502 for an upstream failure |
|
|
1292
1314
|
|
|
1293
1315
|
The `alxia-react-router` bin, run with `bunx`:
|
|
1294
1316
|
|
package/dist/lists/index.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* URL (a search, filters, a cursor). `react` and `react-router` are its only
|
|
4
4
|
* imports, and every hook renders on the server.
|
|
5
5
|
*/
|
|
6
|
+
export { FAILED, type FailedPage, isFailedPage, orFailed, } from './or-failed';
|
|
6
7
|
export { DEFAULT_CURSOR_PARAM, type PagedRows, type PagedRowsOptions, usePagedRows, } from './use-paged-rows';
|
|
7
8
|
export { useSameRouteLoading } from './use-same-route-loading';
|
|
8
|
-
export { type SearchChangeOptions, useSearchChange } from './use-search-change';
|
|
9
|
+
export { type SearchChange, type SearchChangeOptions, useSearchChange, } from './use-search-change';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lists/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,oBAAoB,EACpB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/lists/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EACN,MAAM,EACN,KAAK,UAAU,EACf,YAAY,EACZ,QAAQ,GACR,MAAM,aAAa,CAAC;AACrB,OAAO,EACN,oBAAoB,EACpB,KAAK,SAAS,EACd,KAAK,gBAAgB,EACrB,YAAY,GACZ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,eAAe,GACf,MAAM,qBAAqB,CAAC"}
|
package/dist/lists/index.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
// src/lists/or-failed.ts
|
|
2
|
+
var FAILED = Object.freeze({ failed: true });
|
|
3
|
+
function isFailedPage(value) {
|
|
4
|
+
return typeof value === "object" && value !== null && value.failed === true;
|
|
5
|
+
}
|
|
6
|
+
async function orFailed(after, run) {
|
|
7
|
+
if (!after)
|
|
8
|
+
return await run();
|
|
9
|
+
try {
|
|
10
|
+
return await run();
|
|
11
|
+
} catch (error) {
|
|
12
|
+
if (error instanceof Response && error.status >= 300 && error.status < 400)
|
|
13
|
+
throw error;
|
|
14
|
+
return FAILED;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
1
17
|
// src/lists/use-paged-rows.ts
|
|
2
18
|
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
19
|
import { useFetcher, useLocation } from "react-router";
|
|
@@ -101,6 +117,15 @@ function useSearchChange(options = {}) {
|
|
|
101
117
|
const resetKeys = options.resetKeys ?? RESET_KEYS;
|
|
102
118
|
const joined = resetKeys.join("\x00");
|
|
103
119
|
return useCallback2((changes) => {
|
|
120
|
+
const navigation = { replace: true, preventScrollReset: true };
|
|
121
|
+
if (typeof changes === "function") {
|
|
122
|
+
setSearchParams((current) => changes(new URLSearchParams(current)), navigation);
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
if (changes instanceof URLSearchParams) {
|
|
126
|
+
setSearchParams(new URLSearchParams(changes), navigation);
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
104
129
|
setSearchParams((current) => {
|
|
105
130
|
const next = new URLSearchParams(current);
|
|
106
131
|
for (const [key, value] of Object.entries(changes)) {
|
|
@@ -112,15 +137,18 @@ function useSearchChange(options = {}) {
|
|
|
112
137
|
for (const key of joined === "" ? [] : joined.split("\x00"))
|
|
113
138
|
next.delete(key);
|
|
114
139
|
return next;
|
|
115
|
-
},
|
|
140
|
+
}, navigation);
|
|
116
141
|
}, [setSearchParams, joined]);
|
|
117
142
|
}
|
|
118
143
|
export {
|
|
119
144
|
DEFAULT_CURSOR_PARAM,
|
|
145
|
+
FAILED,
|
|
146
|
+
isFailedPage,
|
|
147
|
+
orFailed,
|
|
120
148
|
usePagedRows,
|
|
121
149
|
useSameRouteLoading,
|
|
122
150
|
useSearchChange
|
|
123
151
|
};
|
|
124
152
|
|
|
125
|
-
//# debugId=
|
|
153
|
+
//# debugId=CCC4EB19C4BC264164756E2164756E21
|
|
126
154
|
//# sourceMappingURL=index.js.map
|
package/dist/lists/index.js.map
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
|
-
"sources": ["../src/lists/use-paged-rows.ts", "../src/lists/use-same-route-loading.ts", "../src/lists/use-search-change.ts"],
|
|
3
|
+
"sources": ["../src/lists/or-failed.ts", "../src/lists/use-paged-rows.ts", "../src/lists/use-same-route-loading.ts", "../src/lists/use-search-change.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
+
"/** What a loader answers for a failed cursor page: no rows, so `usePagedRows` sets `error`. */\nexport const FAILED = Object.freeze({ failed: true as const });\n\n/** The type of {@link FAILED}. */\nexport type FailedPage = typeof FAILED;\n\n/** Whether a loader answer is {@link FAILED}. */\nexport function isFailedPage(value: unknown): value is FailedPage {\n\treturn (\n\t\ttypeof value === 'object' &&\n\t\tvalue !== null &&\n\t\t(value as { failed?: unknown }).failed === true\n\t);\n}\n\n/**\n * The loader half of `usePagedRows`. Runs `run` and returns its answer.\n *\n * - With no `after` (the first page), an error is rethrown, so the route's\n * `ErrorBoundary` shows.\n * - With an `after` (a \"load more\"), any error becomes {@link FAILED}, so the\n * rows stay on screen with a retry, except a 3xx `Response` (a redirect),\n * which is rethrown.\n */\nexport async function orFailed<T>(\n\tafter: string | null | undefined,\n\trun: () => Promise<T> | T,\n): Promise<T | FailedPage> {\n\tif (!after) return await run();\n\ttry {\n\t\treturn await run();\n\t} catch (error) {\n\t\tif (error instanceof Response && error.status >= 300 && error.status < 400)\n\t\t\tthrow error;\n\t\treturn FAILED;\n\t}\n}\n",
|
|
5
6
|
"import { useCallback, useEffect, useRef, useState } from 'react';\nimport { useFetcher, useLocation } from 'react-router';\n\nexport interface PagedRowsOptions<Page> {\n\t/** The search parameter that carries the cursor (default `after`). */\n\treadonly cursorParam?: string;\n\t/** The cursor of the page after this one, `null` at the end (default `page.next`). */\n\treadonly nextOf?: (page: Page) => string | null;\n}\n\nexport interface PagedRows<Row> {\n\t/** The first page's rows, then the rows of each page loaded after it. */\n\treadonly rows: readonly Row[];\n\t/** The cursor of the next page, `null` when there is none. */\n\treadonly next: string | null;\n\t/** A page is being fetched. */\n\treadonly loading: boolean;\n\t/**\n\t * The last `loadMore` ended with nothing usable (the route answered something\n\t * that is not a page). The rows stay; call `loadMore` again to retry. The\n\t * next `loadMore` clears it.\n\t */\n\treadonly error: boolean;\n\t/** Fetches the page after the last one; nothing when there is none or one is on its way. */\n\treadonly loadMore: () => void;\n}\n\n/** The default cursor parameter, shared with `useSearchChange`'s default `resetKeys`. */\nexport const DEFAULT_CURSOR_PARAM = 'after';\n\ninterface Loaded<Page, Row> {\n\treadonly first: Page;\n\treadonly extra: readonly Row[];\n\treadonly next: string | null;\n\treadonly error: boolean;\n}\n\ntype NextOf<Page> = (page: Page) => string | null;\n\n/** The state for a first page: nothing loaded after it yet. */\nfunction restart<Page, Row>(\n\tfirst: Page,\n\tnextOf: NextOf<Page>,\n): Loaded<Page, Row> {\n\treturn { first, extra: [], next: nextOf(first) ?? null, error: false };\n}\n\n/**\n * The rows and cursor of `value` when it is a page (an object whose rows are\n * an array and whose cursor is a string or `null`), else `undefined`.\n */\nfunction readPage<Page, Row>(\n\tvalue: unknown,\n\trowsOf: (page: Page) => readonly Row[],\n\tnextOf: NextOf<Page>,\n): { rows: readonly Row[]; next: string | null } | undefined {\n\tif (typeof value !== 'object' || value === null) return undefined;\n\ttry {\n\t\tconst rows = rowsOf(value as Page);\n\t\tconst next = nextOf(value as Page);\n\t\tif (!Array.isArray(rows)) return undefined;\n\t\tif (next !== null && typeof next !== 'string') return undefined;\n\t\treturn { rows, next };\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** The state after an answer: its rows appended, or `error` when it was not a page. */\nfunction settle<Page, Row>(\n\tprevious: Loaded<Page, Row>,\n\tfirst: Page,\n\tmore: { rows: readonly Row[]; next: string | null } | undefined,\n\tnextOf: NextOf<Page>,\n): Loaded<Page, Row> {\n\tconst base =\n\t\tprevious.first === first ? previous : restart<Page, Row>(first, nextOf);\n\tif (more === undefined) return { ...base, error: true };\n\treturn {\n\t\t...base,\n\t\textra: [...base.extra, ...more.rows],\n\t\tnext: more.next,\n\t\terror: false,\n\t};\n}\n\n/**\n * Appends the pages a \"load more\" asks of the route the page is on. The\n * route's loader answers `?<cursorParam>=<next>` with the next page, through\n * `useFetcher`, so the address bar and the page's own data stay as they are.\n *\n * - It starts over whenever `firstPage` is another object (a new search, a\n * revalidation): the rows are the new first page's alone, in that very\n * render. A page still on its way for the old one is dropped.\n * - A failed load keeps the rows and sets `error`. A thrown loader error goes\n * to the route's `ErrorBoundary` as React Router always does; `error` covers\n * an answer that is not a page, such as `data({ message }, { status: 503 })`\n * or `null`.\n * - Data of the fetcher that is not a page (no rows, or no cursor) is ignored.\n */\nexport function usePagedRows<Page, Row>(\n\tfirstPage: Page,\n\trowsOf: (page: Page) => readonly Row[],\n\toptions: PagedRowsOptions<Page> = {},\n): PagedRows<Row> {\n\tconst cursorParam = options.cursorParam ?? DEFAULT_CURSOR_PARAM;\n\tconst nextOf: NextOf<Page> =\n\t\toptions.nextOf ??\n\t\t((page) => (page as { next?: string | null }).next as string | null);\n\tconst fetcher = useFetcher();\n\tconst { pathname, search } = useLocation();\n\tconst [loaded, setLoaded] = useState(() =>\n\t\trestart<Page, Row>(firstPage, nextOf),\n\t);\n\t// What was asked, and for which first page, so an answer that comes after a restart is dropped.\n\tconst asked = useRef<{ first: Page; seen: unknown; started: boolean } | null>(\n\t\tnull,\n\t);\n\tconst current =\n\t\tloaded.first === firstPage ? loaded : restart<Page, Row>(firstPage, nextOf);\n\n\t// Deliberate deps: rowsOf and nextOf are usually inline functions, new on\n\t// every render, and are read at the time of the answer; the effect must run\n\t// on the fetcher's settling, not on each render.\n\tuseEffect(() => {\n\t\tconst request = asked.current;\n\t\tif (request === null) return;\n\t\tif (fetcher.state !== 'idle') {\n\t\t\trequest.started = true;\n\t\t\treturn;\n\t\t}\n\t\t// Idle: the answer is in when the fetcher was seen busy, or when its data\n\t\t// is no longer the one it had at the call (an answer within one batch).\n\t\tif (!request.started && fetcher.data === request.seen) return;\n\t\tasked.current = null;\n\t\tif (request.first !== firstPage) return;\n\t\tconst more =\n\t\t\tfetcher.data === request.seen\n\t\t\t\t? undefined\n\t\t\t\t: readPage(fetcher.data, rowsOf, nextOf);\n\t\tsetLoaded((previous) => settle(previous, firstPage, more, nextOf));\n\t}, [fetcher.state, fetcher.data, firstPage]);\n\n\tconst next = current.next;\n\tconst busy = fetcher.state !== 'idle';\n\tconst { load } = fetcher;\n\tconst loadMore = useCallback(() => {\n\t\tif (next === null || busy) return;\n\t\tconst params = new URLSearchParams(search);\n\t\tparams.set(cursorParam, next);\n\t\tasked.current = { first: firstPage, seen: fetcher.data, started: false };\n\t\tsetLoaded({ ...current, error: false });\n\t\tvoid load(`${pathname}?${params}`);\n\t}, [\n\t\tnext,\n\t\tbusy,\n\t\tsearch,\n\t\tcursorParam,\n\t\tfirstPage,\n\t\tfetcher.data,\n\t\tcurrent,\n\t\tpathname,\n\t\tload,\n\t]);\n\n\treturn {\n\t\trows: [...rowsOf(firstPage), ...current.extra],\n\t\tnext,\n\t\tloading: busy,\n\t\terror: current.error,\n\t\tloadMore,\n\t};\n}\n",
|
|
6
7
|
"import { useLocation, useNavigation } from 'react-router';\n\n/**\n * `true` while a navigation is loading and goes to the pathname the page is\n * on: another search of this list, not another page. It stays `false` for a\n * navigation elsewhere (and when idle), so a list can show its skeleton\n * without flashing on a click that leaves it.\n */\nexport function useSameRouteLoading(): boolean {\n\tconst navigation = useNavigation();\n\tconst { pathname } = useLocation();\n\treturn (\n\t\tnavigation.state === 'loading' && navigation.location.pathname === pathname\n\t);\n}\n",
|
|
7
|
-
"import { useCallback } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { DEFAULT_CURSOR_PARAM } from './use-paged-rows';\n\nexport interface SearchChangeOptions {\n\t/**\n\t * The parameters dropped by every change, because they only mean something\n\t * for the search they were read from (default `['after']`, a cursor).\n\t */\n\treadonly resetKeys?: readonly string[];\n}\n\nconst RESET_KEYS: readonly string[] = [DEFAULT_CURSOR_PARAM];\n\n/**\n * Returns `(changes) => void
|
|
8
|
+
"import { useCallback } from 'react';\nimport { useSearchParams } from 'react-router';\nimport { DEFAULT_CURSOR_PARAM } from './use-paged-rows';\n\nexport interface SearchChangeOptions {\n\t/**\n\t * The parameters dropped by every change, because they only mean something\n\t * for the search they were read from (default `['after']`, a cursor).\n\t */\n\treadonly resetKeys?: readonly string[];\n}\n\nconst RESET_KEYS: readonly string[] = [DEFAULT_CURSOR_PARAM];\n\n/** What `change` takes: a record of changes, a whole search, or an updater. */\nexport type SearchChange =\n\t| Record<string, string | null | undefined>\n\t| URLSearchParams\n\t| ((prev: URLSearchParams) => URLSearchParams);\n\n/**\n * Returns `(changes) => void`. With a record it sets the parameters it is\n * given a value for, deletes the ones given `null` or `undefined` (an empty\n * string is a value, so it is set), and deletes `resetKeys` in the same step.\n * With a `URLSearchParams` it replaces the whole search by it, and with an\n * updater `(prev) => URLSearchParams` by what the updater returns; both are\n * the caller's whole search, so `resetKeys` does not apply. Every form\n * replaces the history entry and keeps the scroll position.\n */\nexport function useSearchChange(\n\toptions: SearchChangeOptions = {},\n): (changes: SearchChange) => void {\n\tconst [, setSearchParams] = useSearchParams();\n\tconst resetKeys = options.resetKeys ?? RESET_KEYS;\n\tconst joined = resetKeys.join('\\u0000');\n\treturn useCallback(\n\t\t(changes) => {\n\t\t\tconst navigation = { replace: true, preventScrollReset: true };\n\t\t\tif (typeof changes === 'function') {\n\t\t\t\tsetSearchParams(\n\t\t\t\t\t(current) => changes(new URLSearchParams(current)),\n\t\t\t\t\tnavigation,\n\t\t\t\t);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (changes instanceof URLSearchParams) {\n\t\t\t\tsetSearchParams(new URLSearchParams(changes), navigation);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetSearchParams((current) => {\n\t\t\t\tconst next = new URLSearchParams(current);\n\t\t\t\tfor (const [key, value] of Object.entries(changes)) {\n\t\t\t\t\tif (value === null || value === undefined) next.delete(key);\n\t\t\t\t\telse next.set(key, value);\n\t\t\t\t}\n\t\t\t\tfor (const key of joined === '' ? [] : joined.split('\\u0000'))\n\t\t\t\t\tnext.delete(key);\n\t\t\t\treturn next;\n\t\t\t}, navigation);\n\t\t},\n\t\t[setSearchParams, joined],\n\t);\n}\n"
|
|
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SAAS,MAAM,oBAAoB,KAAK;AAAA,IAC7D,IAAI,OAAO,YAAY,YAAY;AAAA,MAClC,gBACC,CAAC,YAAY,QAAQ,IAAI,gBAAgB,OAAO,CAAC,GACjD,UACD;AAAA,MACA;AAAA,IACD;AAAA,IACA,IAAI,mBAAmB,iBAAiB;AAAA,MACvC,gBAAgB,IAAI,gBAAgB,OAAO,GAAG,UAAU;AAAA,MACxD;AAAA,IACD;AAAA,IACA,gBAAgB,CAAC,YAAY;AAAA,MAC5B,MAAM,OAAO,IAAI,gBAAgB,OAAO;AAAA,MACxC,YAAY,KAAK,UAAU,OAAO,QAAQ,OAAO,GAAG;AAAA,QACnD,IAAI,UAAU,QAAQ,UAAU;AAAA,UAAW,KAAK,OAAO,GAAG;AAAA,QAC1D;AAAA,UAAK,KAAK,IAAI,KAAK,KAAK;AAAA,MACzB;AAAA,MACA,WAAW,OAAO,WAAW,KAAK,CAAC,IAAI,OAAO,MAAM,MAAQ;AAAA,QAC3D,KAAK,OAAO,GAAG;AAAA,MAChB,OAAO;AAAA,OACL,UAAU;AAAA,KAEd,CAAC,iBAAiB,MAAM,CACzB;AAAA;",
|
|
11
|
+
"debugId": "CCC4EB19C4BC264164756E2164756E21",
|
|
11
12
|
"names": []
|
|
12
13
|
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** What a loader answers for a failed cursor page: no rows, so `usePagedRows` sets `error`. */
|
|
2
|
+
export declare const FAILED: Readonly<{
|
|
3
|
+
failed: true;
|
|
4
|
+
}>;
|
|
5
|
+
/** The type of {@link FAILED}. */
|
|
6
|
+
export type FailedPage = typeof FAILED;
|
|
7
|
+
/** Whether a loader answer is {@link FAILED}. */
|
|
8
|
+
export declare function isFailedPage(value: unknown): value is FailedPage;
|
|
9
|
+
/**
|
|
10
|
+
* The loader half of `usePagedRows`. Runs `run` and returns its answer.
|
|
11
|
+
*
|
|
12
|
+
* - With no `after` (the first page), an error is rethrown, so the route's
|
|
13
|
+
* `ErrorBoundary` shows.
|
|
14
|
+
* - With an `after` (a "load more"), any error becomes {@link FAILED}, so the
|
|
15
|
+
* rows stay on screen with a retry, except a 3xx `Response` (a redirect),
|
|
16
|
+
* which is rethrown.
|
|
17
|
+
*/
|
|
18
|
+
export declare function orFailed<T>(after: string | null | undefined, run: () => Promise<T> | T): Promise<T | FailedPage>;
|
|
19
|
+
//# sourceMappingURL=or-failed.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"or-failed.d.ts","sourceRoot":"","sources":["../../src/lists/or-failed.ts"],"names":[],"mappings":"AAAA,+FAA+F;AAC/F,eAAO,MAAM,MAAM;;EAA2C,CAAC;AAE/D,kCAAkC;AAClC,MAAM,MAAM,UAAU,GAAG,OAAO,MAAM,CAAC;AAEvC,iDAAiD;AACjD,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,UAAU,CAMhE;AAED;;;;;;;;GAQG;AACH,wBAAsB,QAAQ,CAAC,CAAC,EAC/B,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAChC,GAAG,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,GACvB,OAAO,CAAC,CAAC,GAAG,UAAU,CAAC,CASzB"}
|
|
@@ -5,11 +5,16 @@ export interface SearchChangeOptions {
|
|
|
5
5
|
*/
|
|
6
6
|
readonly resetKeys?: readonly string[];
|
|
7
7
|
}
|
|
8
|
+
/** What `change` takes: a record of changes, a whole search, or an updater. */
|
|
9
|
+
export type SearchChange = Record<string, string | null | undefined> | URLSearchParams | ((prev: URLSearchParams) => URLSearchParams);
|
|
8
10
|
/**
|
|
9
|
-
* Returns `(changes) => void
|
|
10
|
-
* deletes the ones given `null` or `undefined` (an empty
|
|
11
|
-
* so it is set), and deletes `resetKeys` in
|
|
12
|
-
*
|
|
11
|
+
* Returns `(changes) => void`. With a record it sets the parameters it is
|
|
12
|
+
* given a value for, deletes the ones given `null` or `undefined` (an empty
|
|
13
|
+
* string is a value, so it is set), and deletes `resetKeys` in the same step.
|
|
14
|
+
* With a `URLSearchParams` it replaces the whole search by it, and with an
|
|
15
|
+
* updater `(prev) => URLSearchParams` by what the updater returns; both are
|
|
16
|
+
* the caller's whole search, so `resetKeys` does not apply. Every form
|
|
17
|
+
* replaces the history entry and keeps the scroll position.
|
|
13
18
|
*/
|
|
14
|
-
export declare function useSearchChange(options?: SearchChangeOptions): (changes:
|
|
19
|
+
export declare function useSearchChange(options?: SearchChangeOptions): (changes: SearchChange) => void;
|
|
15
20
|
//# sourceMappingURL=use-search-change.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-search-change.d.ts","sourceRoot":"","sources":["../../src/lists/use-search-change.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAID
|
|
1
|
+
{"version":3,"file":"use-search-change.d.ts","sourceRoot":"","sources":["../../src/lists/use-search-change.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,mBAAmB;IACnC;;;OAGG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACvC;AAID,+EAA+E;AAC/E,MAAM,MAAM,YAAY,GACrB,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GACzC,eAAe,GACf,CAAC,CAAC,IAAI,EAAE,eAAe,KAAK,eAAe,CAAC,CAAC;AAEhD;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC9B,OAAO,GAAE,mBAAwB,GAC/B,CAAC,OAAO,EAAE,YAAY,KAAK,IAAI,CA+BjC"}
|
|
@@ -3,5 +3,5 @@
|
|
|
3
3
|
* BFF, as a resource route. It imports nothing (web APIs only), so it adds
|
|
4
4
|
* no peer.
|
|
5
5
|
*/
|
|
6
|
-
export { createSubscriptionProxy, type SubscriptionProxy, type SubscriptionProxyOptions, } from './proxy';
|
|
6
|
+
export { createSubscriptionProxy, type SubscriptionArgs, type SubscriptionProxy, type SubscriptionProxyOptions, } from './proxy';
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/subscription/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,uBAAuB,EACvB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC7B,MAAM,SAAS,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/subscription/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EACN,uBAAuB,EACvB,KAAK,gBAAgB,EACrB,KAAK,iBAAiB,EACtB,KAAK,wBAAwB,GAC7B,MAAM,SAAS,CAAC"}
|
|
@@ -266,9 +266,9 @@ function relay(upstream, abort, heartbeatMs) {
|
|
|
266
266
|
|
|
267
267
|
// src/subscription/proxy.ts
|
|
268
268
|
var UNSAFE = /[\r\n\0]/;
|
|
269
|
-
async function upstreamHeaders(config,
|
|
269
|
+
async function upstreamHeaders(config, args, token) {
|
|
270
270
|
const { headers } = config.options;
|
|
271
|
-
const extra = typeof headers === "function" ? await headers(request) : headers;
|
|
271
|
+
const extra = typeof headers === "function" ? await headers(args.request, args) : headers;
|
|
272
272
|
const out = new Headers;
|
|
273
273
|
for (const [name, value] of extra instanceof Headers ? extra.entries() : Object.entries(extra ?? {}))
|
|
274
274
|
if (value !== null && value !== undefined)
|
|
@@ -278,7 +278,8 @@ async function upstreamHeaders(config, request, token) {
|
|
|
278
278
|
out.set("authorization", `Bearer ${token}`);
|
|
279
279
|
return out;
|
|
280
280
|
}
|
|
281
|
-
async function handle(config,
|
|
281
|
+
async function handle(config, args) {
|
|
282
|
+
const { request } = args;
|
|
282
283
|
if (isCrossSite(request, config.origin()))
|
|
283
284
|
return problem(403, "Cross-site request refused.", "FORBIDDEN");
|
|
284
285
|
const token = await config.options.getToken(request);
|
|
@@ -297,9 +298,9 @@ async function handle(config, request) {
|
|
|
297
298
|
return problem(403, "This operation is not allowed.", "FORBIDDEN");
|
|
298
299
|
let headers;
|
|
299
300
|
try {
|
|
300
|
-
headers = await upstreamHeaders(config,
|
|
301
|
+
headers = await upstreamHeaders(config, args, token);
|
|
301
302
|
} catch {
|
|
302
|
-
return problem(500, "The proxy's upstream headers are not valid (a name or a value no header can hold).", "PROXY_MISCONFIGURED");
|
|
303
|
+
return problem(500, "The proxy's upstream headers are not valid (a name or a value no header can hold, or the headers function threw).", "PROXY_MISCONFIGURED");
|
|
303
304
|
}
|
|
304
305
|
const abort = new AbortController;
|
|
305
306
|
if (request.signal.aborted)
|
|
@@ -335,7 +336,7 @@ async function handle(config, request) {
|
|
|
335
336
|
return refused;
|
|
336
337
|
}
|
|
337
338
|
function only(method, run) {
|
|
338
|
-
return async (
|
|
339
|
+
return async (args) => args.request.method === method ? run(args) : problem(405, `Use ${method}.`, "METHOD_NOT_ALLOWED", {}, { allow: method });
|
|
339
340
|
}
|
|
340
341
|
function createSubscriptionProxy(options) {
|
|
341
342
|
checkDocuments(options.allow);
|
|
@@ -348,13 +349,13 @@ function createSubscriptionProxy(options) {
|
|
|
348
349
|
upstreamFetch: options.fetch ?? ((request) => fetch(request))
|
|
349
350
|
};
|
|
350
351
|
return {
|
|
351
|
-
loader: only("GET", (
|
|
352
|
-
action: only("POST", (
|
|
352
|
+
loader: only("GET", (args) => handle(config, args)),
|
|
353
|
+
action: only("POST", (args) => handle(config, args))
|
|
353
354
|
};
|
|
354
355
|
}
|
|
355
356
|
export {
|
|
356
357
|
createSubscriptionProxy
|
|
357
358
|
};
|
|
358
359
|
|
|
359
|
-
//# debugId=
|
|
360
|
+
//# debugId=4D71F489F243030064756E2164756E21
|
|
360
361
|
//# sourceMappingURL=index.js.map
|
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
"/** An answer the proxy gives itself, as GraphQL-shaped JSON a client can read. */\nexport class Refusal extends Error {\n\tconstructor(\n\t\treadonly status: number,\n\t\tmessage: string,\n\t\treadonly code: string,\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'Refusal';\n\t}\n}\n\nexport function problem(\n\tstatus: number,\n\tmessage: string,\n\tcode: string,\n\textra: Record<string, unknown> = {},\n\theaders: HeadersInit = {},\n): Response {\n\treturn new Response(\n\t\tJSON.stringify({\n\t\t\terrors: [{ message, extensions: { code, ...extra } }],\n\t\t\t...extra,\n\t\t}),\n\t\t{\n\t\t\tstatus,\n\t\t\theaders: {\n\t\t\t\t'content-type': 'application/json',\n\t\t\t\t'cache-control': 'no-store',\n\t\t\t\t...headers,\n\t\t\t},\n\t\t},\n\t);\n}\n\nexport const refusalResponse = (refusal: Refusal): Response =>\n\tproblem(refusal.status, refusal.message, refusal.code);\n\nfunction retryAfterOf(upstream: Response, body: unknown): number | undefined {\n\tconst header = Number(upstream.headers.get('retry-after'));\n\tif (Number.isFinite(header) && header > 0) return Math.ceil(header);\n\tconst seconds = (value: unknown): number | undefined =>\n\t\ttypeof value === 'number' && Number.isFinite(value) && value > 0\n\t\t\t? Math.ceil(value)\n\t\t\t: undefined;\n\tif (typeof body !== 'object' || body === null) return undefined;\n\tconst top = body as { retryAfter?: unknown; errors?: unknown };\n\tconst first = Array.isArray(top.errors)\n\t\t? (top.errors[0] as { extensions?: { retryAfter?: unknown } } | undefined)\n\t\t: undefined;\n\treturn seconds(top.retryAfter) ?? seconds(first?.extensions?.retryAfter);\n}\n\n/** What a non-2xx upstream answer becomes: a 429 with `retryAfter`, a 502 for a 5xx, any other 4xx as it came. */\nexport async function refusedUpstream(upstream: Response): Promise<Response> {\n\tconst text = await upstream.text().catch(() => '');\n\tif (upstream.status === 429) {\n\t\tlet body: unknown;\n\t\ttry {\n\t\t\tbody = JSON.parse(text);\n\t\t} catch {}\n\t\tconst retryAfter = retryAfterOf(upstream, body);\n\t\treturn problem(\n\t\t\t429,\n\t\t\t'Too many requests.',\n\t\t\t'RATE_LIMITED',\n\t\t\tretryAfter === undefined ? {} : { retryAfter },\n\t\t\tretryAfter === undefined ? {} : { 'retry-after': String(retryAfter) },\n\t\t);\n\t}\n\tif (upstream.status >= 500)\n\t\treturn problem(502, 'The API is unavailable.', 'UPSTREAM_ERROR');\n\treturn new Response(text, {\n\t\tstatus: upstream.status,\n\t\theaders: {\n\t\t\t'content-type':\n\t\t\t\tupstream.headers.get('content-type') ?? 'application/json',\n\t\t\t'cache-control': 'no-store',\n\t\t},\n\t});\n}\n",
|
|
7
7
|
"import { Refusal } from './refusal';\n\n/** The most a body, a query string or the variables may weigh, in bytes. */\nexport const LIMITS = {\n\tbody: 64 * 1024,\n\tqueryString: 16 * 1024,\n\tvariables: 16 * 1024,\n} as const;\n\nexport interface Asked {\n\treadonly operationName: string;\n\treadonly variables?: Record<string, unknown>;\n}\n\nconst TOO_LARGE = () =>\n\tnew Refusal(400, 'The request is too large.', 'BAD_REQUEST');\nconst NOT_JSON = () =>\n\tnew Refusal(400, 'The request is not valid JSON.', 'BAD_REQUEST');\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n\treturn typeof value === 'object' && value !== null && !Array.isArray(value)\n\t\t? (value as Record<string, unknown>)\n\t\t: undefined;\n}\n\n/** The body as text, refused past `limit` bytes: `content-length` first, then a cap on what is read. */\nasync function textOf(request: Request, limit: number): Promise<string> {\n\tconst declared = Number(request.headers.get('content-length'));\n\tif (Number.isFinite(declared) && declared > limit) throw TOO_LARGE();\n\tif (request.body === null) return '';\n\tconst reader = request.body.getReader();\n\tconst chunks: Uint8Array[] = [];\n\tlet size = 0;\n\tfor (;;) {\n\t\tconst { done, value } = await reader.read();\n\t\tif (done) break;\n\t\tsize += value.byteLength;\n\t\tif (size > limit) {\n\t\t\tvoid reader.cancel().catch(() => {});\n\t\t\tthrow TOO_LARGE();\n\t\t}\n\t\tchunks.push(value);\n\t}\n\treturn new TextDecoder().decode(Buffer.concat(chunks));\n}\n\nfunction parse(text: string): unknown {\n\ttry {\n\t\treturn JSON.parse(text);\n\t} catch {\n\t\tthrow NOT_JSON();\n\t}\n}\n\n/**\n * What a client asks for: an `operationName` and its `variables`, from a\n * GET's search params or a POST's JSON body. Any `query` or `extensions` it\n * sends (graphql-sse always sends a `query`) is ignored.\n */\nexport async function readAsked(request: Request): Promise<Asked> {\n\tlet raw: Record<string, unknown> | undefined;\n\tif (request.method === 'GET') {\n\t\tconst url = new URL(request.url);\n\t\tif (url.search.length > LIMITS.queryString) throw TOO_LARGE();\n\t\tconst variables = url.searchParams.get('variables');\n\t\traw = {\n\t\t\toperationName: url.searchParams.get('operationName') ?? undefined,\n\t\t\tvariables: variables ? parse(variables) : undefined,\n\t\t};\n\t} else {\n\t\tconst type = (request.headers.get('content-type') ?? '')\n\t\t\t.split(';')[0]\n\t\t\t?.trim()\n\t\t\t.toLowerCase();\n\t\tif (type !== 'application/json')\n\t\t\tthrow new Refusal(\n\t\t\t\t415,\n\t\t\t\t'Send the request as application/json.',\n\t\t\t\t'UNSUPPORTED_MEDIA_TYPE',\n\t\t\t);\n\t\traw = record(parse(await textOf(request, LIMITS.body)));\n\t\tif (raw === undefined)\n\t\t\tthrow new Refusal(\n\t\t\t\t400,\n\t\t\t\t'The request must be a JSON object.',\n\t\t\t\t'BAD_REQUEST',\n\t\t\t);\n\t}\n\tconst { operationName, variables } = raw;\n\tif (operationName === undefined)\n\t\tthrow new Refusal(400, 'Send an \"operationName\".', 'BAD_REQUEST');\n\tif (typeof operationName !== 'string')\n\t\tthrow new Refusal(400, '\"operationName\" must be a string.', 'BAD_REQUEST');\n\tif (variables !== undefined) {\n\t\tif (record(variables) === undefined)\n\t\t\tthrow new Refusal(400, '\"variables\" must be an object.', 'BAD_REQUEST');\n\t\tif (JSON.stringify(variables).length > LIMITS.variables) throw TOO_LARGE();\n\t}\n\treturn {\n\t\toperationName,\n\t\t...(variables === undefined\n\t\t\t? {}\n\t\t\t: { variables: variables as Record<string, unknown> }),\n\t};\n}\n",
|
|
8
8
|
"/** The most one event may weigh before the stream is cut, in characters. */\nexport const MAX_EVENT = 1024 * 1024;\n\nconst encoder = new TextEncoder();\nconst decoder = new TextDecoder();\n\nexport const SSE_HEADERS = {\n\t'content-type': 'text/event-stream; charset=utf-8',\n\t'cache-control': 'no-store, no-transform',\n\t'x-accel-buffering': 'no',\n};\n\nconst FAILED =\n\t'event: next\\ndata: {\"errors\":[{\"message\":\"The API stream failed.\",\"extensions\":{\"code\":\"UPSTREAM_ERROR\"}}]}\\n\\nevent: complete\\ndata:\\n\\n';\n\n/**\n * Relays whole events (a heartbeat never lands inside one) until the upstream\n * ends or the client leaves. The stream is pulled: upstream is read only when\n * the client has taken what was queued, so a slow client holds the upstream\n * back instead of growing a buffer, and a heartbeat is skipped while one is\n * waiting.\n */\nexport function relay(\n\tupstream: Response,\n\tabort: AbortController,\n\theartbeatMs: number,\n): Response {\n\tconst reader = (upstream.body as ReadableStream<Uint8Array>).getReader();\n\tlet timer: ReturnType<typeof setInterval> | undefined;\n\tlet buffer = '';\n\tconst stop = (): void => {\n\t\tif (timer !== undefined) clearInterval(timer);\n\t\ttimer = undefined;\n\t};\n\tconst stream = new ReadableStream<Uint8Array>(\n\t\t{\n\t\t\tstart(controller) {\n\t\t\t\tif (heartbeatMs > 0)\n\t\t\t\t\ttimer = setInterval(() => {\n\t\t\t\t\t\tif ((controller.desiredSize ?? 0) > 0)\n\t\t\t\t\t\t\tcontroller.enqueue(encoder.encode(':\\n\\n'));\n\t\t\t\t\t}, heartbeatMs);\n\t\t\t},\n\t\t\tasync pull(controller) {\n\t\t\t\ttry {\n\t\t\t\t\tfor (;;) {\n\t\t\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\t\t\tif (done) {\n\t\t\t\t\t\t\tstop();\n\t\t\t\t\t\t\tif (buffer.trim() !== '')\n\t\t\t\t\t\t\t\tcontroller.enqueue(encoder.encode(`${buffer}\\n\\n`));\n\t\t\t\t\t\t\tcontroller.close();\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tbuffer += decoder\n\t\t\t\t\t\t\t.decode(value, { stream: true })\n\t\t\t\t\t\t\t.replace(/\\r\\n?/g, '\\n');\n\t\t\t\t\t\tconst cut = buffer.lastIndexOf('\\n\\n');\n\t\t\t\t\t\tif (cut !== -1) {\n\t\t\t\t\t\t\tcontroller.enqueue(encoder.encode(buffer.slice(0, cut + 2)));\n\t\t\t\t\t\t\tbuffer = buffer.slice(cut + 2);\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (buffer.length > MAX_EVENT) throw new Error('event too large');\n\t\t\t\t\t}\n\t\t\t\t} catch {\n\t\t\t\t\tstop();\n\t\t\t\t\tif (abort.signal.aborted) return;\n\t\t\t\t\tabort.abort();\n\t\t\t\t\tcontroller.enqueue(encoder.encode(FAILED));\n\t\t\t\t\tcontroller.close();\n\t\t\t\t}\n\t\t\t},\n\t\t\tcancel() {\n\t\t\t\tstop();\n\t\t\t\tabort.abort();\n\t\t\t\tvoid reader.cancel().catch(() => {});\n\t\t\t},\n\t\t},\n\t\t{ highWaterMark: 1 },\n\t);\n\treturn new Response(stream, { status: 200, headers: SSE_HEADERS });\n}\n",
|
|
9
|
-
"import { isCrossSite } from '../errors/cross-site';\nimport { checkDocuments } from './documents';\nimport { readAsked } from './read';\nimport { problem, Refusal, refusalResponse, refusedUpstream } from './refusal';\nimport { relay } from './relay';\n\ntype HeaderValues = Record<string, string | null | undefined> | Headers;\n\nexport interface SubscriptionProxyOptions {\n\t/** The API's GraphQL endpoint, which serves subscriptions over SSE. */\n\treadonly endpoint: string | URL;\n\t/**\n\t * The operations the browser may start: each name with the document the\n\t * proxy sends upstream for it. The client names an operation and sends\n\t * variables; its own `query` and `extensions` are ignored, so nothing it\n\t * writes reaches the API. A name that is not a key is a 403.\n\t */\n\treadonly allow: Readonly<Record<string, string>>;\n\t/** The session's token, from the request: `(request) => cookies.token(request)`. Empty is a 401. */\n\treadonly getToken: (\n\t\trequest: Request,\n\t) => string | null | undefined | Promise<string | null | undefined>;\n\t
|
|
9
|
+
"import { isCrossSite } from '../errors/cross-site';\nimport { checkDocuments } from './documents';\nimport { readAsked } from './read';\nimport { problem, Refusal, refusalResponse, refusedUpstream } from './refusal';\nimport { relay } from './relay';\n\ntype HeaderValues = Record<string, string | null | undefined> | Headers;\n\n/**\n * What React Router gives the resource route's `loader` and `action`, and what\n * `headers` receives beside the request: the route's `context` (the app's\n * `getLoadContext` value, `RouterContextProvider`) and `params`. Both are\n * optional so a call with the request alone, as in a spec, still type-checks.\n */\nexport interface SubscriptionArgs<Context = unknown> {\n\treadonly request: Request;\n\treadonly context?: Context;\n\treadonly params?: Readonly<Record<string, string | undefined>>;\n}\n\nexport interface SubscriptionProxyOptions<Context = unknown> {\n\t/** The API's GraphQL endpoint, which serves subscriptions over SSE. */\n\treadonly endpoint: string | URL;\n\t/**\n\t * The operations the browser may start: each name with the document the\n\t * proxy sends upstream for it. The client names an operation and sends\n\t * variables; its own `query` and `extensions` are ignored, so nothing it\n\t * writes reaches the API. A name that is not a key is a 403.\n\t */\n\treadonly allow: Readonly<Record<string, string>>;\n\t/** The session's token, from the request: `(request) => cookies.token(request)`. Empty is a 401. */\n\treadonly getToken: (\n\t\trequest: Request,\n\t) => string | null | undefined | Promise<string | null | undefined>;\n\t/**\n\t * Extra upstream headers (client name, proxy secret, `X-Forwarded-For`,\n\t * `Accept-Language`), fixed or built per request. A `null` or `undefined`\n\t * value is left out. A function gets the request and, as its second\n\t * argument, the route's loader or action arguments (`context`, `params`), so\n\t * it can send the trusted client address from the app's context instead of\n\t * copying a header the browser could forge. They reach this function only,\n\t * never the browser.\n\t */\n\treadonly headers?:\n\t\t| HeaderValues\n\t\t| ((\n\t\t\t\trequest: Request,\n\t\t\t\targs: SubscriptionArgs<Context>,\n\t\t ) => HeaderValues | Promise<HeaderValues>);\n\t/** The app's own origin for the cross-site check, as `jsonActions` takes it; the request's own by default. */\n\treadonly origin?: string | (() => string | undefined);\n\t/** A comment line sent this often so a proxy or Bun's `idleTimeout` keeps the stream open. 15000 by default; `0` turns it off. */\n\treadonly heartbeatMs?: number;\n\t/** The `fetch` used upstream. The global one by default. */\n\treadonly fetch?: (request: Request) => Promise<Response>;\n}\n\nexport interface SubscriptionProxy<Context = unknown> {\n\t/** A GET: graphql-sse's distinct connections mode, the operation in the search params. */\n\tloader(args: SubscriptionArgs<Context>): Promise<Response>;\n\t/** A POST: the operation in a JSON body. */\n\taction(args: SubscriptionArgs<Context>): Promise<Response>;\n}\n\ninterface Config {\n\treadonly endpoint: URL;\n\treadonly documents: ReadonlyMap<string, string>;\n\t// `Context` is the caller's own claim about what its route passes and is never checked; `never` lets any typed `headers` function be stored.\n\treadonly options: SubscriptionProxyOptions<never>;\n\treadonly origin: () => string | undefined;\n\treadonly heartbeatMs: number;\n\treadonly upstreamFetch: (request: Request) => Promise<Response>;\n}\n\nconst UNSAFE = /[\\r\\n\\0]/;\n\nasync function upstreamHeaders(\n\tconfig: Config,\n\targs: SubscriptionArgs,\n\ttoken: string,\n): Promise<Headers> {\n\tconst { headers } = config.options;\n\tconst extra =\n\t\ttypeof headers === 'function'\n\t\t\t? await headers(args.request, args as SubscriptionArgs<never>)\n\t\t\t: headers;\n\tconst out = new Headers();\n\tfor (const [name, value] of extra instanceof Headers\n\t\t? extra.entries()\n\t\t: Object.entries(extra ?? {}))\n\t\tif (value !== null && value !== undefined) out.set(name, value);\n\tout.set('content-type', 'application/json');\n\tout.set('accept', 'text/event-stream');\n\tout.set('authorization', `Bearer ${token}`);\n\treturn out;\n}\n\nasync function handle(\n\tconfig: Config,\n\targs: SubscriptionArgs,\n): Promise<Response> {\n\tconst { request } = args;\n\tif (isCrossSite(request, config.origin()))\n\t\treturn problem(403, 'Cross-site request refused.', 'FORBIDDEN');\n\tconst token = await config.options.getToken(request);\n\tif (!token || UNSAFE.test(token))\n\t\treturn problem(401, 'Sign in to continue.', 'UNAUTHENTICATED');\n\n\tlet asked: Awaited<ReturnType<typeof readAsked>>;\n\ttry {\n\t\tasked = await readAsked(request);\n\t} catch (error) {\n\t\tif (error instanceof Refusal) return refusalResponse(error);\n\t\treturn problem(400, 'The request body could not be read.', 'BAD_REQUEST');\n\t}\n\tconst query = config.documents.get(asked.operationName);\n\tif (query === undefined)\n\t\treturn problem(403, 'This operation is not allowed.', 'FORBIDDEN');\n\n\tlet headers: Headers;\n\ttry {\n\t\theaders = await upstreamHeaders(config, args, token);\n\t} catch {\n\t\treturn problem(\n\t\t\t500,\n\t\t\t\"The proxy's upstream headers are not valid (a name or a value no header can hold, or the headers function threw).\",\n\t\t\t'PROXY_MISCONFIGURED',\n\t\t);\n\t}\n\n\tconst abort = new AbortController();\n\tif (request.signal.aborted) abort.abort();\n\telse\n\t\trequest.signal.addEventListener('abort', () => abort.abort(), {\n\t\t\tonce: true,\n\t\t});\n\tlet upstream: Response;\n\ttry {\n\t\tupstream = await config.upstreamFetch(\n\t\t\tnew Request(config.endpoint, {\n\t\t\t\tmethod: 'POST',\n\t\t\t\theaders,\n\t\t\t\tbody: JSON.stringify({\n\t\t\t\t\tquery,\n\t\t\t\t\toperationName: asked.operationName,\n\t\t\t\t\t...(asked.variables === undefined\n\t\t\t\t\t\t? {}\n\t\t\t\t\t\t: { variables: asked.variables }),\n\t\t\t\t}),\n\t\t\t\tsignal: abort.signal,\n\t\t\t}),\n\t\t);\n\t} catch {\n\t\treturn problem(502, 'The API is unreachable.', 'UPSTREAM_ERROR');\n\t}\n\tconst streaming =\n\t\tupstream.ok &&\n\t\tupstream.body !== null &&\n\t\t(upstream.headers.get('content-type') ?? '').startsWith(\n\t\t\t'text/event-stream',\n\t\t);\n\tif (streaming) return relay(upstream, abort, config.heartbeatMs);\n\tif (upstream.ok) {\n\t\tabort.abort();\n\t\treturn problem(\n\t\t\t502,\n\t\t\t'The API did not answer with an event stream.',\n\t\t\t'UPSTREAM_ERROR',\n\t\t);\n\t}\n\tconst refused = await refusedUpstream(upstream);\n\tabort.abort();\n\treturn refused;\n}\n\nfunction only(\n\tmethod: string,\n\trun: (args: SubscriptionArgs) => Promise<Response>,\n): (args: SubscriptionArgs) => Promise<Response> {\n\treturn async (args) =>\n\t\targs.request.method === method\n\t\t\t? run(args)\n\t\t\t: problem(\n\t\t\t\t\t405,\n\t\t\t\t\t`Use ${method}.`,\n\t\t\t\t\t'METHOD_NOT_ALLOWED',\n\t\t\t\t\t{},\n\t\t\t\t\t{ allow: method },\n\t\t\t\t);\n}\n\n/**\n * A resource route that exposes GraphQL subscriptions to the browser without\n * giving it the API's token or a way to write its own document. See the\n * subscription guide.\n */\nexport function createSubscriptionProxy<Context = unknown>(\n\toptions: SubscriptionProxyOptions<Context>,\n): SubscriptionProxy<Context> {\n\tcheckDocuments(options.allow);\n\tconst config: Config = {\n\t\tendpoint: new URL(options.endpoint),\n\t\tdocuments: new Map(Object.entries(options.allow)),\n\t\toptions: options as SubscriptionProxyOptions<never>,\n\t\torigin: () =>\n\t\t\ttypeof options.origin === 'function' ? options.origin() : options.origin,\n\t\theartbeatMs: options.heartbeatMs ?? 15000,\n\t\tupstreamFetch: options.fetch ?? ((request) => fetch(request)),\n\t};\n\treturn {\n\t\tloader: only('GET', (args) => handle(config, args)),\n\t\taction: only('POST', (args) => handle(config, args)),\n\t};\n}\n"
|
|
10
10
|
],
|
|
11
|
-
"mappings": ";;;;;AAOA,SAAS,QAAQ,CAAC,UAA0B;AAAA,EAC3C,OAAO,SACL,QAAQ,mBAAmB,GAAG,EAC9B,QAAQ,wBAAwB,GAAG,EACnC,QAAQ,cAAc,GAAG;AAAA;AAI5B,SAAS,WAAW,CAAC,UAAuD;AAAA,EAC3E,MAAM,QAA6C,CAAC;AAAA,EACpD,IAAI,QAAQ;AAAA,EACZ,IAAI;AAAA,EACJ,IAAI,WAAW;AAAA,EACf,WAAW,KAAK,SAAS,QAAQ,EAAE,SAAS,sBAAsB,GAAG;AAAA,IACpE,MAAM,IAAI,EAAE;AAAA,IACZ,IAAI,MAAM;AAAA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AO,CACjB;AAAA;AAQG,SAAS,uBAA0C,CACzD,SAC6B;AAAA,EAC7B,eAAe,QAAQ,KAAK;AAAA,EAC5B,MAAM,SAAiB;AAAA,IACtB,UAAU,IAAI,IAAI,QAAQ,QAAQ;AAAA,IAClC,WAAW,IAAI,IAAI,OAAO,QAAQ,QAAQ,KAAK,CAAC;AAAA,IAChD;AAAA,IACA,QAAQ,MACP,OAAO,QAAQ,WAAW,aAAa,QAAQ,OAAO,IAAI,QAAQ;AAAA,IACnE,aAAa,QAAQ,eAAe;AAAA,IACpC,eAAe,QAAQ,UAAU,CAAC,YAAY,MAAM,OAAO;AAAA,EAC5D;AAAA,EACA,OAAO;AAAA,IACN,QAAQ,KAAK,OAAO,CAAC,SAAS,OAAO,QAAQ,IAAI,CAAC;AAAA,IAClD,QAAQ,KAAK,QAAQ,CAAC,SAAS,OAAO,QAAQ,IAAI,CAAC;AAAA,EACpD;AAAA;",
|
|
12
|
+
"debugId": "4D71F489F243030064756E2164756E21",
|
|
13
13
|
"names": []
|
|
14
14
|
}
|
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
type HeaderValues = Record<string, string | null | undefined> | Headers;
|
|
2
|
-
|
|
2
|
+
/**
|
|
3
|
+
* What React Router gives the resource route's `loader` and `action`, and what
|
|
4
|
+
* `headers` receives beside the request: the route's `context` (the app's
|
|
5
|
+
* `getLoadContext` value, `RouterContextProvider`) and `params`. Both are
|
|
6
|
+
* optional so a call with the request alone, as in a spec, still type-checks.
|
|
7
|
+
*/
|
|
8
|
+
export interface SubscriptionArgs<Context = unknown> {
|
|
9
|
+
readonly request: Request;
|
|
10
|
+
readonly context?: Context;
|
|
11
|
+
readonly params?: Readonly<Record<string, string | undefined>>;
|
|
12
|
+
}
|
|
13
|
+
export interface SubscriptionProxyOptions<Context = unknown> {
|
|
3
14
|
/** The API's GraphQL endpoint, which serves subscriptions over SSE. */
|
|
4
15
|
readonly endpoint: string | URL;
|
|
5
16
|
/**
|
|
@@ -11,8 +22,16 @@ export interface SubscriptionProxyOptions {
|
|
|
11
22
|
readonly allow: Readonly<Record<string, string>>;
|
|
12
23
|
/** The session's token, from the request: `(request) => cookies.token(request)`. Empty is a 401. */
|
|
13
24
|
readonly getToken: (request: Request) => string | null | undefined | Promise<string | null | undefined>;
|
|
14
|
-
/**
|
|
15
|
-
|
|
25
|
+
/**
|
|
26
|
+
* Extra upstream headers (client name, proxy secret, `X-Forwarded-For`,
|
|
27
|
+
* `Accept-Language`), fixed or built per request. A `null` or `undefined`
|
|
28
|
+
* value is left out. A function gets the request and, as its second
|
|
29
|
+
* argument, the route's loader or action arguments (`context`, `params`), so
|
|
30
|
+
* it can send the trusted client address from the app's context instead of
|
|
31
|
+
* copying a header the browser could forge. They reach this function only,
|
|
32
|
+
* never the browser.
|
|
33
|
+
*/
|
|
34
|
+
readonly headers?: HeaderValues | ((request: Request, args: SubscriptionArgs<Context>) => HeaderValues | Promise<HeaderValues>);
|
|
16
35
|
/** The app's own origin for the cross-site check, as `jsonActions` takes it; the request's own by default. */
|
|
17
36
|
readonly origin?: string | (() => string | undefined);
|
|
18
37
|
/** A comment line sent this often so a proxy or Bun's `idleTimeout` keeps the stream open. 15000 by default; `0` turns it off. */
|
|
@@ -20,21 +39,17 @@ export interface SubscriptionProxyOptions {
|
|
|
20
39
|
/** The `fetch` used upstream. The global one by default. */
|
|
21
40
|
readonly fetch?: (request: Request) => Promise<Response>;
|
|
22
41
|
}
|
|
23
|
-
export interface SubscriptionProxy {
|
|
42
|
+
export interface SubscriptionProxy<Context = unknown> {
|
|
24
43
|
/** A GET: graphql-sse's distinct connections mode, the operation in the search params. */
|
|
25
|
-
loader(args:
|
|
26
|
-
request: Request;
|
|
27
|
-
}): Promise<Response>;
|
|
44
|
+
loader(args: SubscriptionArgs<Context>): Promise<Response>;
|
|
28
45
|
/** A POST: the operation in a JSON body. */
|
|
29
|
-
action(args:
|
|
30
|
-
request: Request;
|
|
31
|
-
}): Promise<Response>;
|
|
46
|
+
action(args: SubscriptionArgs<Context>): Promise<Response>;
|
|
32
47
|
}
|
|
33
48
|
/**
|
|
34
49
|
* A resource route that exposes GraphQL subscriptions to the browser without
|
|
35
50
|
* giving it the API's token or a way to write its own document. See the
|
|
36
51
|
* subscription guide.
|
|
37
52
|
*/
|
|
38
|
-
export declare function createSubscriptionProxy(options: SubscriptionProxyOptions): SubscriptionProxy
|
|
53
|
+
export declare function createSubscriptionProxy<Context = unknown>(options: SubscriptionProxyOptions<Context>): SubscriptionProxy<Context>;
|
|
39
54
|
export {};
|
|
40
55
|
//# sourceMappingURL=proxy.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/subscription/proxy.ts"],"names":[],"mappings":"AAMA,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC;AAExE,MAAM,WAAW,wBAAwB;
|
|
1
|
+
{"version":3,"file":"proxy.d.ts","sourceRoot":"","sources":["../../src/subscription/proxy.ts"],"names":[],"mappings":"AAMA,KAAK,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC;AAExE;;;;;GAKG;AACH,MAAM,WAAW,gBAAgB,CAAC,OAAO,GAAG,OAAO;IAClD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,MAAM,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;CAC/D;AAED,MAAM,WAAW,wBAAwB,CAAC,OAAO,GAAG,OAAO;IAC1D,uEAAuE;IACvE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC;IAChC;;;;;OAKG;IACH,QAAQ,CAAC,KAAK,EAAE,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
47
47
|
so typing does not fill the history nor jump the page. Pass
|
|
48
48
|
`{ resetKeys: ['after', 'page'] }` to drop more.
|
|
49
49
|
|
|
50
|
+
`change` also takes a whole `URLSearchParams`, which replaces the search, or an
|
|
51
|
+
updater `(prev) => URLSearchParams`, for a filter bar or a server table that
|
|
52
|
+
hands back its next parameters. Both navigate exactly as the record form does
|
|
53
|
+
(`replace: true`, `preventScrollReset: true`), and since they are the whole
|
|
54
|
+
search, `resetKeys` does not apply to them: drop the cursor yourself if the
|
|
55
|
+
new search needs it gone.
|
|
56
|
+
|
|
57
|
+
```tsx
|
|
58
|
+
<Table onParamsChange={(next: URLSearchParams) => change(next)} />;
|
|
59
|
+
change((prev) => new URLSearchParams([...prev].filter(([key]) => key !== 'status')));
|
|
60
|
+
```
|
|
61
|
+
|
|
50
62
|
## `useSameRouteLoading`
|
|
51
63
|
|
|
52
64
|
```tsx
|
|
@@ -107,5 +119,22 @@ with another one a search that keeps the old cursor shows the wrong page.
|
|
|
107
119
|
|
|
108
120
|
A loader that **throws** on a cursor request is not an `error` here: React
|
|
109
121
|
Router sends a fetcher's thrown error to the route's `ErrorBoundary`. To offer
|
|
110
|
-
a retry instead,
|
|
111
|
-
|
|
122
|
+
a retry instead, wrap the read in `orFailed(after, run)`: it answers
|
|
123
|
+
`FAILED` (`{ failed: true }`, a value that is not a page) for a request that
|
|
124
|
+
has the cursor, rethrows when there is none and rethrows a 3xx `Response`.
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
import { orFailed } from '@alxia/react-router/lists';
|
|
128
|
+
|
|
129
|
+
export function loader({ request }: Route.LoaderArgs) {
|
|
130
|
+
const url = new URL(request.url);
|
|
131
|
+
return orFailed(url.searchParams.get('after'), async () => ({
|
|
132
|
+
page: await listUsers({
|
|
133
|
+
q: url.searchParams.get('q') ?? '',
|
|
134
|
+
after: url.searchParams.get('after'),
|
|
135
|
+
}),
|
|
136
|
+
}));
|
|
137
|
+
}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`isFailedPage(loaderData)` narrows the answer when a component reads it.
|
|
@@ -17,8 +17,13 @@ client was generated from:
|
|
|
17
17
|
|
|
18
18
|
```ts
|
|
19
19
|
// app/routes/events.ts: a resource route, served at /events
|
|
20
|
-
import {
|
|
20
|
+
import { alxiaOf } from '@alxia/react-router';
|
|
21
|
+
import {
|
|
22
|
+
createSubscriptionProxy,
|
|
23
|
+
type SubscriptionArgs,
|
|
24
|
+
} from '@alxia/react-router/subscription';
|
|
21
25
|
import { print } from 'graphql';
|
|
26
|
+
import type { RouterContextProvider } from 'react-router';
|
|
22
27
|
import { ChatMessagesDocument, RoomEventsDocument } from '../generated/graphql';
|
|
23
28
|
import { cookies } from '../session.server';
|
|
24
29
|
|
|
@@ -30,13 +35,16 @@ const events = createSubscriptionProxy({
|
|
|
30
35
|
// or the document string codegen exports, or a literal
|
|
31
36
|
},
|
|
32
37
|
getToken: (request) => cookies.token(request),
|
|
33
|
-
headers: (
|
|
38
|
+
headers: (
|
|
39
|
+
request,
|
|
40
|
+
{ context }: SubscriptionArgs<Readonly<RouterContextProvider>>,
|
|
41
|
+
) => ({
|
|
34
42
|
'x-client-name': 'my-bff',
|
|
35
43
|
'x-proxy-secret': process.env.PROXY_SECRET,
|
|
36
|
-
|
|
44
|
+
// the trusted client address (behind `proxy: trustProxy(...)`), not the browser's own header; null leaves it out
|
|
45
|
+
'x-forwarded-for': context ? alxiaOf(context).ip : null,
|
|
37
46
|
'accept-language': request.headers.get('accept-language'),
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
47
|
+
}),});
|
|
40
48
|
|
|
41
49
|
export const loader = events.loader; // GET: operationName and variables in the query string
|
|
42
50
|
export const action = events.action; // POST: the same in a JSON body
|
|
@@ -98,7 +106,7 @@ adapter or reverse proxy needs to buffer it.
|
|
|
98
106
|
| `endpoint` | the API's GraphQL URL (required) |
|
|
99
107
|
| `allow` | operation name to the document sent upstream (required); each document must define `subscription <name>`, that operation alone, checked when the proxy is created |
|
|
100
108
|
| `getToken(request)` | the session's token, sync or async (required) |
|
|
101
|
-
| `headers` | a record, `Headers`, or `(request) => record
|
|
109
|
+
| `headers` | a record, `Headers`, or `(request, args) => record`, sync or async; `args` is what React Router gave the route (`request`, `context`, `params`), so a header can come from the app's context; a `null` or `undefined` value is left out. A `(request) => record` function keeps working |
|
|
102
110
|
| `origin` | the app's origin for the same-site check, a string or a getter; the request's own by default |
|
|
103
111
|
| `heartbeatMs` | 15000 |
|
|
104
112
|
| `fetch` | the `fetch` used upstream (the global one); useful in specs |
|
package/docs/troubleshooting.md
CHANGED
|
@@ -539,7 +539,16 @@ name.
|
|
|
539
539
|
|
|
540
540
|
**Why:** React Router sends the error of a fetcher's load to the route's boundary. `usePagedRows` only sees what the fetcher answers, so its `error` is `true` for an answer that is not a page, not for a throw.
|
|
541
541
|
|
|
542
|
-
**Fix:**
|
|
542
|
+
**Fix:** wrap the read in `orFailed(after, run)` from `@alxia/react-router/lists`, which answers `{ failed: true }` for a request that has the cursor and rethrows otherwise (and rethrows a redirect):
|
|
543
|
+
|
|
544
|
+
```ts
|
|
545
|
+
export function loader({ request }: Route.LoaderArgs) {
|
|
546
|
+
const url = new URL(request.url);
|
|
547
|
+
return orFailed(url.searchParams.get('after'), () => listUsers(url.searchParams));
|
|
548
|
+
}
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
By hand, that is:
|
|
543
552
|
|
|
544
553
|
```ts
|
|
545
554
|
export async function loader({ request }: Route.LoaderArgs) {
|
|
@@ -2808,9 +2817,14 @@ string, or `variables` is not an object.
|
|
|
2808
2817
|
### A subscription answers 500 `The proxy's upstream headers are not valid …`
|
|
2809
2818
|
|
|
2810
2819
|
**Why:** a value of `headers` (a forwarded `Accept-Language`, a secret from the
|
|
2811
|
-
environment) holds a line break, or a name is not a header name
|
|
2812
|
-
|
|
2813
|
-
|
|
2820
|
+
environment) holds a line break, or a name is not a header name, or the
|
|
2821
|
+
`headers` function threw (for example `alxiaOf(context)` on a request served
|
|
2822
|
+
without alxia's context). The answer's text is fixed: nothing from the error
|
|
2823
|
+
reaches the browser.
|
|
2824
|
+
|
|
2825
|
+
**Fix:** trim or validate the value before it goes in `headers`, and guard the
|
|
2826
|
+
context (`context ? alxiaOf(context).ip : null`); read the error in your own
|
|
2827
|
+
log by catching inside the function.
|
|
2814
2828
|
|
|
2815
2829
|
### A subscription answers 429 with `retryAfter`
|
|
2816
2830
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alxia/react-router",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "alxia as the server of a React Router framework app: server rendering behind the app's hooks, loaders reading its typed context, the client's assets served; the code with no UI an installable app shares (`/pwa`), its hooks (`/pwa/react`), `noCache` for the worker's script (`/pwa/server`), the service worker on Workbox (`/pwa/worker`) and its build (`/pwa/build`), an API's refusals worded for the page (`/errors`), the BFF session: cookies, sign-in, step-up and mail links (`/session`), its page hooks (`/session/react`) and what it shares with the page (`/session/model`), a GraphQL subscription relayed to the browser over SSE (`/subscription`), the page's CSP nonce and inline boot scripts (`/document`) and a streaming `entry.server` (`/entry`)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|