@alxia/graphql 0.13.3 → 0.15.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 CHANGED
@@ -290,6 +290,56 @@ where `graphql()` is declared.
290
290
  A client query is a few thousand tokens; the introspection query is 163. See
291
291
  [Cap what a request costs](https://github.com/softistx/alxia/blob/develop/packages/graphql/docs/guide/production.md#cap-what-a-request-costs).
292
292
 
293
+ ## Count a field, not a request
294
+
295
+ A limit on HTTP requests counts one request however many times it selects
296
+ `signIn` under aliases (`a: signIn(...) b: signIn(...) …`). `fieldRateLimit`
297
+ is a Yoga plugin that walks the operation about to run, aliases, inline
298
+ fragments and fragment spreads expanded, and consumes the number of
299
+ selections of each chosen field on a limit keyed by the client. Past the
300
+ limit nothing executes: a 429 `RATE_LIMITED` (the `code` option names it
301
+ otherwise, `TOO_MANY_ATTEMPTS` say) with `extensions.retryAfter` (seconds) and
302
+ a `Retry-After` header. List it first in `plugins`.
303
+
304
+ ```ts
305
+ import { alxia } from '@alxia/core';
306
+ import { MemoryStore } from '@alxia/rate-limit';
307
+ import { fieldRateLimit, graphql, limitFromStore } from '@alxia/graphql';
308
+ import { schema } from './schema';
309
+
310
+ const store = new MemoryStore();
311
+
312
+ graphql(alxia(), {
313
+ schema,
314
+ plugins: [
315
+ fieldRateLimit({
316
+ // Optional: who is counted. The client's address by default, and
317
+ // ipv6Prefix: 64 counts an IPv6 client by its network.
318
+ // key: ({ ip }) => ip,
319
+ fields: {
320
+ signIn: { limit: limitFromStore(store, { limit: 5, windowMs: 60_000 }), single: true },
321
+ },
322
+ }),
323
+ ],
324
+ });
325
+ ```
326
+
327
+ A limit is anything with `consume(key, cost)` answering `{ allowed,
328
+ retryAfter }` (milliseconds): `limitFromStore` makes one of an
329
+ `@alxia/rate-limit` store, one store call per unit of cost (up to `limit + 1`
330
+ round trips), and a `@softistx/redis` bound limit, which takes the cost in
331
+ one call and suits a large limit, fits as
332
+ `{ consume: async (key, cost) => limit.consume({ ip: key }, cost) }` (`limit`
333
+ is the entry of your wired Redis handle). Units spent before a refusal stay
334
+ spent, and so do the fields charged before a refused one. `single: true`
335
+ refuses the field written more than once in the document (400
336
+ `FIELD_SELECTED_ONCE`), counting a selection written the same way twice as
337
+ one. Counting is per selection in the document: a list parent costs 1,
338
+ `@skip` and `@include` are not evaluated, and a field matches by name on any
339
+ type. Under `batching` a refused element is an error in a 200 array, with no
340
+ `Retry-After`. See
341
+ [Count a field, not a request](https://github.com/softistx/alxia/blob/develop/packages/graphql/docs/guide/production.md#count-a-field-not-a-request).
342
+
293
343
  ## Errors, health and shutdown
294
344
 
295
345
  A GraphQL error stays GraphQL's — an entry of `errors[]`, inside a 200 —
@@ -310,6 +360,21 @@ app.listen({ port: 4000 });
310
360
 
311
361
  See [the endpoint guide](https://github.com/softistx/alxia/blob/develop/packages/graphql/docs/guide/endpoint.md#errors-health-and-shutdown).
312
362
 
363
+ ## In process
364
+
365
+ `graphqlExecutor(options)` runs a query or a mutation in the process, with the
366
+ same plugins, limits, parse cache and error masking as `graphql()`, and a
367
+ server context you pass: for an MCP tool or a job, not a browser.
368
+
369
+ ```ts
370
+ import { graphqlExecutor } from '@alxia/graphql';
371
+
372
+ const execute = graphqlExecutor({ schema, plugins: [useAuth()] });
373
+ const { data, errors } = await execute({ query: '{ me { id } }' }, { viewer });
374
+ ```
375
+
376
+ See [the guide](https://github.com/softistx/alxia/blob/develop/packages/graphql/docs/guide/executor.md).
377
+
313
378
  ## Testing
314
379
 
315
380
  `graphqlClient` from `@alxia/graphql/testing` sends operations to the app
@@ -343,6 +408,8 @@ See
343
408
  | export | |
344
409
  | --- | --- |
345
410
  | `graphql(app, options)` | the endpoint: `schema`, `path`, `ide`, `sandbox`, `ws`, `maxTokens`, `maxNesting`, `parseCache`, `bodyLimit`, and every Yoga option |
411
+ | `graphqlExecutor(options)` | `(request: { query, operationName?, variables? }, context, { signal? }?) => Promise<{ data?, errors? }>`: a query or mutation in process, through the options of `graphql()` without the route's (`path`, `ide`, `ws`, `bodyLimit`, `cors`) |
412
+ | `ExecutorRequest`, `ExecutorResult`, `ExecutorError`, `ExecutorCall`, `GraphQLExecutor`, `GraphQLExecutorOptions` | its types |
346
413
  | `GraphQLWsOptions` | `ws`'s options: `path`, `keepAlive` |
347
414
  | `GraphQLWsContext` | what an operation over WebSocket adds to the context: `connectionParams` |
348
415
  | `renderSandbox(endpoint, options?)`, `SANDBOX_POLICY` | the Sandbox page, and the policy it loads under |
@@ -351,6 +418,9 @@ See
351
418
  | `oncePerRequest(request, key, load)` | `load()`'s value, computed at most once per request object and `key` (a `string`); returns `T`, a promise kept as the same promise, a throw or rejection not kept |
352
419
  | `clearRequestCache(request)` | empties what `oncePerRequest` kept for that request object; the next call loads again; returns `void` |
353
420
  | `freshPerMutation(resolvers)` | the same resolvers (same type) with each function of `Mutation` wrapped to call `clearRequestCache(context)` first: each root mutation field starts empty, its sub-fields share, a query is untouched |
421
+ | `fieldRateLimit({ fields, key?, ipv6Prefix?, code? })` | a Yoga plugin, listed first: consumes the number of selections (aliases and fragments expanded) of each chosen field on its limit, keyed by `key(context)` (the client address by default, its IPv6 network under `ipv6Prefix`); 429 `RATE_LIMITED` (`code`) with `retryAfter`, or 400 `FIELD_SELECTED_ONCE` for a `single` field; units spent before a refusal stay spent |
422
+ | `limitFromStore(store, policy?)` | an `@alxia/rate-limit` store as a `FieldLimit`: one consume per unit of cost, stopped at the first refusal (up to `limit + 1` round trips); `policy` may come from `store.policy` and must not differ from it |
423
+ | `FieldLimit`, `FieldDecision`, `FieldRule`, `FieldRateLimitOptions`, `CostlessStore` | their types |
354
424
  | `boundedStream(source, options)` | `source` (an `AsyncIterable` or `AsyncIterator`) as an `AsyncIterableIterator<T>` for a subscription's `subscribe`: ends cleanly after `idleMs` without an event and `totalMs` in all, runs `check` every `checkEveryMs` and before an event when the last check is `checkDebounceMs` old, throws `mapError(error)` when `check` fails or the source itself throws, and calls the source's `return()` on disconnect or any end |
355
425
  | `BoundedStreamOptions` | its options: `idleMs`, `totalMs`, `checkEveryMs`, `checkDebounceMs?`, `check`, `mapError?`, `signal?` |
356
426
  | `ServerContext<Ctx>`, `GraphQLOptions` | its types |
@@ -359,7 +429,7 @@ See
359
429
 
360
430
  ## Documentation
361
431
 
362
- - [Guide](https://github.com/softistx/alxia/tree/develop/packages/graphql/docs): a page per area — mounting the endpoint, the typed context, Yoga's plugins and options, GraphQL over WebSocket, GraphiQL and Apollo Sandbox, and [hardening an API for production](https://github.com/softistx/alxia/blob/develop/packages/graphql/docs/guide/production.md) (rate limits, depth limits, introspection, errors, body size, CSRF, persisted operations).
432
+ - [Guide](https://github.com/softistx/alxia/tree/develop/packages/graphql/docs): a page per area — mounting the endpoint, the typed context, Yoga's plugins and options, GraphQL over WebSocket, running operations in process, GraphiQL and Apollo Sandbox, and [hardening an API for production](https://github.com/softistx/alxia/blob/develop/packages/graphql/docs/guide/production.md) (rate limits, depth limits, introspection, errors, body size, CSRF, persisted operations).
363
433
  - [Troubleshooting](https://github.com/softistx/alxia/blob/develop/packages/graphql/docs/troubleshooting.md): an error message, and what to do about it.
364
434
  - [Roadmap](https://github.com/softistx/alxia/blob/develop/packages/graphql/docs/roadmap.md): what is coming, and what is not planned.
365
435
  - [Recipes](https://github.com/softistx/alxia/blob/develop/docs/recipes/README.md): [A GraphQL API](https://github.com/softistx/alxia/blob/develop/docs/recipes/graphql-api.md), [Authenticate requests](https://github.com/softistx/alxia/blob/develop/docs/recipes/authentication.md), [Test an alxia app](https://github.com/softistx/alxia/blob/develop/docs/recipes/testing.md), [Health checks and graceful shutdown](https://github.com/softistx/alxia/blob/develop/docs/recipes/health-and-shutdown.md), and more.
@@ -0,0 +1,66 @@
1
+ import type { Empty } from '@alxia/core';
2
+ import type { GraphQLSchemaWithContext, YogaInitialContext, YogaServerOptions } from 'graphql-yoga';
3
+ import type { YogaContext } from './handler';
4
+ import type { ParseCacheOptions } from './parse-limits';
5
+ /** What an in-process call asks for: a GraphQL-over-HTTP request's parameters. */
6
+ export interface ExecutorRequest {
7
+ readonly query: string;
8
+ readonly operationName?: string | undefined;
9
+ readonly variables?: Readonly<Record<string, unknown>> | undefined;
10
+ }
11
+ /** A plain, JSON-shaped error, as the route answers it. */
12
+ export interface ExecutorError {
13
+ readonly message: string;
14
+ readonly path?: readonly (string | number)[];
15
+ readonly locations?: readonly {
16
+ line: number;
17
+ column: number;
18
+ }[];
19
+ readonly extensions?: Readonly<Record<string, unknown>>;
20
+ }
21
+ /** The answer: `data` and `errors`, as the endpoint's JSON body. */
22
+ export interface ExecutorResult {
23
+ readonly data?: unknown;
24
+ readonly errors?: readonly ExecutorError[];
25
+ }
26
+ /** Per call: the signal that stops the operation, as a client leaving does. */
27
+ export interface ExecutorCall {
28
+ readonly signal?: AbortSignal;
29
+ }
30
+ /**
31
+ * The options of `graphqlExecutor()`: those of `graphql()` that mean
32
+ * something without a route. Put an HTTP-only plugin (a client-header
33
+ * check, `cache-control`) in the route's list and not here.
34
+ */
35
+ export interface GraphQLExecutorOptions<ServerCtx extends YogaContext, UserCtx extends YogaContext, SchemaCtx = unknown> extends Omit<YogaServerOptions<ServerCtx, UserCtx>, 'graphqlEndpoint' | 'cors' | 'schema' | 'graphiql' | 'landingPage' | 'parserAndValidationCache'> {
36
+ /** The schema, as for `graphql()`. */
37
+ readonly schema: GraphQLSchemaWithContext<SchemaCtx>;
38
+ /** At most this many tokens in a document, 15 000 by default, or `false`. */
39
+ readonly maxTokens?: number | false;
40
+ /** At most this many levels of `{`, `(` and `[`, 1 000 by default, or `false`. */
41
+ readonly maxNesting?: number | false;
42
+ /** The cache of parsed documents, this executor's own. `false` parses every call. */
43
+ readonly parseCache?: false | ParseCacheOptions;
44
+ }
45
+ /** Runs one operation in process. */
46
+ export type GraphQLExecutor<ServerCtx> = (request: ExecutorRequest, context: ServerCtx, call?: ExecutorCall) => Promise<ExecutorResult>;
47
+ /**
48
+ * Runs a GraphQL operation in the process, through the same Yoga setup as
49
+ * `graphql()` — its plugins, `maxTokens`, `maxNesting`, the parse cache, the
50
+ * masking of errors — with a server context the caller gives, and no HTTP
51
+ * route in between. For a caller that is not a browser: an MCP tool, a job.
52
+ * Queries and mutations only.
53
+ *
54
+ * ```ts
55
+ * const execute = graphqlExecutor({ schema, plugins: [useJanus(...)] });
56
+ * const { data, errors } = await execute(
57
+ * { query: '{ me { id } }' },
58
+ * { viewer, services },
59
+ * );
60
+ * ```
61
+ *
62
+ * It does not run `graphql()`'s middlewares: the context is whatever is
63
+ * passed. It keeps its own parse cache, apart from the route's.
64
+ */
65
+ export declare function graphqlExecutor<SchemaCtx, UserCtx extends YogaContext = Empty, ServerCtx = Omit<SchemaCtx, keyof YogaInitialContext>>(options: GraphQLExecutorOptions<YogaContext, UserCtx, SchemaCtx>): GraphQLExecutor<ServerCtx>;
66
+ //# sourceMappingURL=executor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executor.d.ts","sourceRoot":"","sources":["../src/executor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,KAAK,EACX,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAGxD,kFAAkF;AAClF,MAAM,WAAW,eAAe;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,SAAS,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC;CACnE;AAED,2DAA2D;AAC3D,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CA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IAAI,CAAC,EAAE,YAAY,KACf,OAAO,CAAC,cAAc,CAAC,CAAC;AAY7B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC9B,SAAS,EACT,OAAO,SAAS,WAAW,GAAG,KAAK,EACnC,SAAS,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,kBAAkB,CAAC,EAErD,OAAO,EAAE,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,SAAS,CAAC,GAC9D,eAAe,CAAC,SAAS,CAAC,CAuC5B"}
@@ -0,0 +1,28 @@
1
+ import { type DocumentNode, type SelectionSetNode } from 'graphql';
2
+ /** How a field was selected: how many times, and under how many distinct response keys and arguments. */
3
+ export interface Selected {
4
+ count: number;
5
+ readonly distinct: Set<string>;
6
+ }
7
+ type Counts = Map<string, Selected>;
8
+ /**
9
+ * `distinct` only has to tell one path from two or more (`single`), so it is
10
+ * built for the `singles` alone and holds at most 2 paths. That is sound: a
11
+ * set of 2 or more distinct relative paths stays that after any prefix; a
12
+ * union of sets cut to 2 has 2 or more elements whenever the true union does
13
+ * (one input already has 2, or all have at most 1 and are exact). A document
14
+ * whose fragments fan out (`{ x: y { ...F1 } z: y { ...F1 } }` down forty
15
+ * levels) has 2^40 paths, and costs a few set entries here.
16
+ *
17
+ * How many times each of `names` is selected by `selections`, fragments
18
+ * expanded. Counted per selection in the document, as written: a list
19
+ * parent costs 1 however long the list, `@skip` and `@include` are not
20
+ * evaluated, selections that merge at execution (the same alias twice) still
21
+ * count each, and a field matches by name alone, on any type. A fragment is
22
+ * walked once, so a document whose fragments spread each other many times
23
+ * is counted in linear time. `distinct` holds each selection's response key
24
+ * and arguments, so a field written twice the same way is one, under the same parents (the response keys and arguments above it).
25
+ */
26
+ export declare function countSelections(document: DocumentNode, selections: SelectionSetNode, names: ReadonlySet<string>, singles?: ReadonlySet<string>): Counts;
27
+ export {};
28
+ //# sourceMappingURL=count.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"count.d.ts","sourceRoot":"","sources":["../../src/field-rate-limit/count.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,YAAY,EAGjB,KAAK,gBAAgB,EACrB,MAAM,SAAS,CAAC;AAEjB,yGAAyG;AACzG,MAAM,WAAW,QAAQ;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CAC/B;AAED,KAAK,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEpC;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,eAAe,CAC9B,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,gBAAgB,EAC5B,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,EAC1B,OAAO,GAAE,WAAW,CAAC,MAAM,CAAa,GACtC,MAAM,CA8DR"}
@@ -0,0 +1,21 @@
1
+ import type { CostlessStore, FieldLimit } from './types';
2
+ interface Given {
3
+ readonly limit?: number;
4
+ readonly windowMs?: number;
5
+ }
6
+ /**
7
+ * A `@alxia/rate-limit` store as a `FieldLimit`. The store counts one hit
8
+ * per call, so a cost of N is N consumes, stopped at the first refusal: up
9
+ * to `limit + 1` round trips for one selection count, which a Redis-backed
10
+ * store feels. The units spent before a refusal stay spent. For a large
11
+ * limit, give `fieldRateLimit` a limit that takes the cost in one call (a
12
+ * `@softistx/redis` bound limit).
13
+ *
14
+ * `policy` may be left out for a store that declares its own (`store.policy`,
15
+ * as `redisStore` of a wired limit does); numbers that differ from the
16
+ * store's are an error here, as in `rateLimit`. `limit` and `windowMs` are
17
+ * whole numbers of 1 or more.
18
+ */
19
+ export declare function limitFromStore(store: CostlessStore, policy?: Given): FieldLimit;
20
+ export {};
21
+ //# sourceMappingURL=from-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"from-store.d.ts","sourceRoot":"","sources":["../../src/field-rate-limit/from-store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAEzD,UAAU,KAAK;IACd,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC7B,KAAK,EAAE,aAAa,EACpB,MAAM,CAAC,EAAE,KAAK,GACZ,UAAU,CA8BZ"}
@@ -0,0 +1,5 @@
1
+ export { countSelections } from './count';
2
+ export { limitFromStore } from './from-store';
3
+ export { DEFAULT_LIMIT_CODE, fieldRateLimit } from './plugin';
4
+ export type { CostlessStore, FieldDecision, FieldLimit, FieldRateLimitOptions, FieldRule, } from './types';
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/field-rate-limit/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC9D,YAAY,EACX,aAAa,EACb,aAAa,EACb,UAAU,EACV,qBAAqB,EACrB,SAAS,GACT,MAAM,SAAS,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The network of an IPv6 `address` under `prefix` bits, as `2001:db8:1:2::/64`
3
+ * writes it. An IPv4-mapped address (`::ffff:203.0.113.9`) is its IPv4 address,
4
+ * a zone id (`%eth0`) is dropped, and a text that is not an IPv6 address
5
+ * (an IPv4 one included) is returned as it is.
6
+ */
7
+ export declare function ipv6Network(address: string, prefix: number): string;
8
+ //# sourceMappingURL=ipv6-network.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ipv6-network.d.ts","sourceRoot":"","sources":["../../src/field-rate-limit/ipv6-network.ts"],"names":[],"mappings":"AAsEA;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAenE"}
@@ -0,0 +1,28 @@
1
+ import type { Plugin } from 'graphql-yoga';
2
+ import type { FieldRateLimitOptions } from './types';
3
+ /** The `extensions.code` of an over-limit refusal, unless `code` says otherwise. */
4
+ export declare const DEFAULT_LIMIT_CODE = "RATE_LIMITED";
5
+ /**
6
+ * A Yoga plugin that counts every selection of the chosen fields in the
7
+ * operation about to execute (aliases and fragments included) and consumes
8
+ * that cost on each field's limit, keyed by the client. Past a limit the
9
+ * operation does not run: a 429 with `extensions.code` `RATE_LIMITED`
10
+ * (the `code` option; `TOO_MANY_ATTEMPTS` for a sign-in, say) and `retryAfter` (seconds, also the `Retry-After`
11
+ * header). `{ limit, single: true }` refuses the field selected more than
12
+ * once in the document with a 400 `FIELD_SELECTED_ONCE`, a field written the
13
+ * same way twice (same parents, response key and arguments) counting once.
14
+ *
15
+ * The check runs in `onExecute` itself, so a plugin after it that replaces
16
+ * the execute function does not drop it; still, list it first in
17
+ * `graphql({ plugins })`. Fields are charged in the order the document first selects them: units spent
18
+ * on one field before a refusal stay spent, and so do earlier fields when a
19
+ * later one is refused. Subscriptions are not counted. Under `batching` each
20
+ * operation is checked on its own, and a refused one is an error in a 200
21
+ * array, with no `Retry-After` header.
22
+ *
23
+ * ```ts
24
+ * fieldRateLimit({ fields: { signIn: limitFromStore(store, { limit: 5, windowMs: 60_000 }) } })
25
+ * ```
26
+ */
27
+ export declare function fieldRateLimit<Ctx extends object = any>(options: FieldRateLimitOptions<Ctx>): Plugin;
28
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/field-rate-limit/plugin.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAG3C,OAAO,KAAK,EAAc,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAEjE,oFAAoF;AACpF,eAAO,MAAM,kBAAkB,iBAAiB,CAAC;AA+EjD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,cAAc,CAAC,GAAG,SAAS,MAAM,GAAG,GAAG,EACtD,OAAO,EAAE,qBAAqB,CAAC,GAAG,CAAC,GACjC,MAAM,CA8DR"}
@@ -0,0 +1,60 @@
1
+ /** What a limit answers: allowed or not, and, when not, the delay until it would be, in milliseconds. */
2
+ export interface FieldDecision {
3
+ readonly allowed: boolean;
4
+ readonly retryAfter: number;
5
+ }
6
+ /**
7
+ * Where selections are counted: anything that consumes `cost` for `key`.
8
+ * A `@softistx/redis` bound limit (`limit`, from the app's wired Redis
9
+ * handle) fits through `{ consume: (key, cost) => limit.consume({ ip: key },
10
+ * cost) }`; a `@alxia/rate-limit` store, through `limitFromStore`.
11
+ *
12
+ * A limit that takes the cost in one call (as the Redis one does) is the
13
+ * right one for a large limit: `limitFromStore` makes one store call per unit.
14
+ */
15
+ export interface FieldLimit {
16
+ consume(key: string, cost: number): FieldDecision | Promise<FieldDecision>;
17
+ }
18
+ /** A field's rule: a limit, or a limit with `single`, which refuses the field selected more than once in the document. */
19
+ export type FieldRule = FieldLimit | {
20
+ readonly limit: FieldLimit;
21
+ readonly single?: boolean;
22
+ };
23
+ export interface FieldRateLimitOptions<Ctx extends object = any> {
24
+ /** The fields to count, by name (at any depth), each with its limit. */
25
+ readonly fields: Readonly<Record<string, FieldRule>>;
26
+ /**
27
+ * Who is counted, from the context (`ip`, `request`, the app's own);
28
+ * `undefined` counts nothing. The client's address (`ctx.ip`) by default,
29
+ * grouped by `ipv6Prefix`. Not required: leave it out to count by address.
30
+ */
31
+ readonly key?: (ctx: Ctx) => string | undefined | Promise<string | undefined>;
32
+ /**
33
+ * Count an IPv6 client by its network: the first `ipv6Prefix` bits of the
34
+ * default key, as `rateLimit`'s option of the same name does (a whole number
35
+ * from 0 to 128; none by default, so each address counts apart). Goes with
36
+ * the default key: with a `key` of your own, group the address in it.
37
+ */
38
+ readonly ipv6Prefix?: number;
39
+ /** The `extensions.code` of the over-limit refusal; `RATE_LIMITED` by default (`TOO_MANY_ATTEMPTS`, say, for a sign-in). */
40
+ readonly code?: string;
41
+ }
42
+ /** The part of a `@alxia/rate-limit` `RateLimitStore` that `limitFromStore` uses. */
43
+ export interface CostlessStore {
44
+ consume(key: string, policy: {
45
+ readonly limit: number;
46
+ readonly windowMs: number;
47
+ }): {
48
+ readonly allowed: boolean;
49
+ readonly retryAfter: number;
50
+ } | Promise<{
51
+ readonly allowed: boolean;
52
+ readonly retryAfter: number;
53
+ }>;
54
+ /** The policy the store counts by itself, when it has one. */
55
+ readonly policy?: {
56
+ readonly limit: number;
57
+ readonly windowMs: number;
58
+ };
59
+ }
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/field-rate-limit/types.ts"],"names":[],"mappings":"AAAA,yGAAyG;AACzG,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC5B;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,UAAU;IAC1B,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAC3E;AAED,0HAA0H;AAC1H,MAAM,MAAM,SAAS,GAClB,UAAU,GACV;IAAE,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAC;IAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAE7D,MAAM,WAAW,qBAAqB,CAAC,GAAG,SAAS,MAAM,GAAG,GAAG;IAC9D,wEAAwE;IACxE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAAC;IACrD;;;;OAIG;IACH,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,MAAM,GAAG,SAAS,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAC9E;;;;;OAKG;IACH,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAC7B,4HAA4H;IAC5H,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,qFAAqF;AACrF,MAAM,WAAW,aAAa;IAC7B,OAAO,CACN,GAAG,EAAE,MAAM,EACX,MAAM,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,GAE3D;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAAE,GAC1D,OAAO,CAAC;QAAE,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;QAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACvE,8DAA8D;IAC9D,QAAQ,CAAC,MAAM,CAAC,EAAE;QAAE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;CACxE"}
package/dist/graphql.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import { type Alxia, type BaseContext, type Empty, type RoutePath } from '@alxia/core';
1
+ import type { Alxia, BaseContext, Empty, RoutePath } from '@alxia/core';
2
2
  import type { GraphQLSchemaWithContext, YogaInitialContext, YogaServerOptions } from 'graphql-yoga';
3
3
  import { type YogaContext } from './handler';
4
- import { type ParseCacheOptions } from './parse-limits';
4
+ import type { ParseCacheOptions } from './parse-limits';
5
5
  import type { SandboxOptions } from './sandbox';
6
6
  import { type GraphQLWsOptions } from './ws';
7
7
  /** The parts of a route's context Yoga owns, or that mean nothing to a resolver. */
@@ -1 +1 @@
1
- {"version":3,"file":"graphql.d.ts","sourceRoot":"","sources":["../src/graphql.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,KAAK,KAAK,EACV,KAAK,WAAW,EAChB,KAAK,KAAK,EAEV,KAAK,SAAS,EACd,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EACX,wBAAwB,EACxB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAkB,KAAK,WAAW,EAAe,MAAM,WAAW,CAAC;AAE1E,OAAO,EAEN,KAAK,iBAAiB,EAGtB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChD,OAAO,EAAE,KAAK,gBAAgB,EAAiB,MAAM,MAAM,CAAC;AAE5D,oFAAoF;AACpF,KAAK,SAAS,GACX,QAAQ,GACR,OAAO,GACP,SAAS,GACT,SAAS,GACT,MAAM,GACN,OAAO,GACP,UAAU,CAAC;AAEd;;;;GAIG;AACH,MAAM,MAAM,aAAa,CAAC,GAAG,IAAI,IAAI,CAAC,WAAW,GAAG,GAAG,EAAE,SAAS,CAAC,CAAC;AAEpE;;;;GAIG;AACH,MAAM,WAAW,gBAAgB;IAChC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CAC9D;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,cAAc,CAAC,GAAG,EAAE,WAAW,GAAG,KAAK,IAAI,GAAG,SAAS;IAClE,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,CAAC;CAC/B,GACE,kBAAkB,GAAG,aAAa,CAAC,GAAG,CAAC,GAAG,gBAAgB,GAAG,WAAW,GAGzE;IACC,QAAQ,CAAC,QAAQ,EAAE,qEAAqE,CAAC;CACzF,CAAC;AAEJ,MAAM,WAAW,cAAc,CAC9B,SAAS,SA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type BoundedStreamOptions, boundedStream } from './bounded-stream';
2
+ export { type ExecutorCall, type ExecutorError, type ExecutorRequest, type ExecutorResult, type GraphQLExecutor, type GraphQLExecutorOptions, graphqlExecutor, } from './executor';
3
+ export { type CostlessStore, type FieldDecision, type FieldLimit, type FieldRateLimitOptions, type FieldRule, fieldRateLimit, limitFromStore, } from './field-rate-limit';
2
4
  export { type GraphQLContext, type GraphQLOptions, type GraphQLWsContext, graphql, type ServerContext, } from './graphql';
3
5
  export { clearRequestCache, freshPerMutation, oncePerRequest, } from './once-per-request';
4
6
  export { renderSandbox, SANDBOX_POLICY, type SandboxOptions } from './sandbox';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,OAAO,EACP,KAAK,aAAa,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5E,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,aAAa,EAClB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,sBAAsB,EAC3B,eAAe,GACf,MAAM,YAAY,CAAC;AACpB,OAAO,EACN,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,SAAS,EACd,cAAc,EACd,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACN,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,gBAAgB,EACrB,OAAO,EACP,KAAK,aAAa,GAClB,MAAM,WAAW,CAAC;AACnB,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,GACd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AAC/E,YAAY,EAAE,gBAAgB,EAAE,MAAM,MAAM,CAAC"}