@alxia/graphql 0.16.5 → 0.18.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 +60 -62
- package/dist/endpoint.d.ts +14 -2
- package/dist/endpoint.d.ts.map +1 -1
- package/dist/executor.d.ts +20 -37
- package/dist/executor.d.ts.map +1 -1
- package/dist/explorer.d.ts +24 -0
- package/dist/explorer.d.ts.map +1 -0
- package/dist/graphql.d.ts +32 -95
- package/dist/graphql.d.ts.map +1 -1
- package/dist/handler.d.ts +7 -34
- package/dist/handler.d.ts.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +301 -1011
- package/dist/index.js.map +14 -23
- package/dist/once-per-request.d.ts +5 -0
- package/dist/once-per-request.d.ts.map +1 -1
- package/dist/operation.d.ts +2 -7
- package/dist/operation.d.ts.map +1 -1
- package/dist/options.d.ts +38 -0
- package/dist/options.d.ts.map +1 -0
- package/dist/removed.d.ts +14 -0
- package/dist/removed.d.ts.map +1 -0
- package/dist/sandbox.d.ts +3 -17
- package/dist/sandbox.d.ts.map +1 -1
- package/dist/testing/client.d.ts +9 -7
- package/dist/testing/client.d.ts.map +1 -1
- package/dist/testing/index.js +5 -1
- package/dist/testing/index.js.map +3 -3
- package/dist/ws.d.ts +18 -30
- package/dist/ws.d.ts.map +1 -1
- package/docs/README.md +3 -2
- package/docs/guide/context.md +40 -32
- package/docs/guide/endpoint.md +42 -27
- package/docs/guide/executor.md +23 -8
- package/docs/guide/ide.md +27 -64
- package/docs/guide/{yoga.md → plugins.md} +87 -72
- package/docs/guide/production.md +115 -196
- package/docs/guide/testing.md +24 -24
- package/docs/guide/websockets.md +21 -14
- package/docs/migrating-to-graxia.md +283 -0
- package/docs/roadmap.md +7 -11
- package/docs/troubleshooting.md +231 -248
- package/package.json +15 -22
- package/dist/body-refusal.d.ts +0 -25
- package/dist/body-refusal.d.ts.map +0 -1
- package/dist/document-cache.d.ts +0 -39
- package/dist/document-cache.d.ts.map +0 -1
- package/dist/field-rate-limit/count.d.ts +0 -28
- package/dist/field-rate-limit/count.d.ts.map +0 -1
- package/dist/field-rate-limit/from-store.d.ts +0 -21
- package/dist/field-rate-limit/from-store.d.ts.map +0 -1
- package/dist/field-rate-limit/index.d.ts +0 -5
- package/dist/field-rate-limit/index.d.ts.map +0 -1
- package/dist/field-rate-limit/ipv6-network.d.ts +0 -8
- package/dist/field-rate-limit/ipv6-network.d.ts.map +0 -1
- package/dist/field-rate-limit/plugin.d.ts +0 -28
- package/dist/field-rate-limit/plugin.d.ts.map +0 -1
- package/dist/field-rate-limit/types.d.ts +0 -60
- package/dist/field-rate-limit/types.d.ts.map +0 -1
- package/dist/nesting.d.ts +0 -18
- package/dist/nesting.d.ts.map +0 -1
- package/dist/parse-limits.d.ts +0 -50
- package/dist/parse-limits.d.ts.map +0 -1
- package/dist/same-origin/index.d.ts +0 -2
- package/dist/same-origin/index.d.ts.map +0 -1
- package/dist/same-origin/same-origin.d.ts +0 -30
- package/dist/same-origin/same-origin.d.ts.map +0 -1
- package/dist/ws-operations.d.ts +0 -31
- package/dist/ws-operations.d.ts.map +0 -1
- package/dist/ws-server.d.ts +0 -32
- package/dist/ws-server.d.ts.map +0 -1
- package/dist/yoga.d.ts +0 -12
- package/dist/yoga.d.ts.map +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alxia/graphql",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "GraphQL for alxia
|
|
3
|
+
"version": "0.18.0",
|
|
4
|
+
"description": "GraphQL for alxia served by @graxia/core: its plugins, subscriptions over SSE or WebSocket and GraphiQL, behind the app's hooks, its resolvers reading the app's typed context",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -47,31 +47,24 @@
|
|
|
47
47
|
]
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@alxia/core": "^0.
|
|
51
|
-
"@alxia/logger": "^0.6.
|
|
52
|
-
"@alxia/
|
|
53
|
-
"@
|
|
50
|
+
"@alxia/core": "^0.27.0",
|
|
51
|
+
"@alxia/logger": "^0.6.19",
|
|
52
|
+
"@alxia/telemetry": "^0.9.4",
|
|
53
|
+
"@envelop/core": "^6.0.1",
|
|
54
54
|
"@envelop/depth-limit": "^7.2.1",
|
|
55
|
-
"@
|
|
56
|
-
"@
|
|
57
|
-
"@
|
|
55
|
+
"@graxia/core": "^0.10.0",
|
|
56
|
+
"@graxia/envelop": "^0.1.4",
|
|
57
|
+
"@graxia/graphiql": "^0.2.4",
|
|
58
58
|
"@softistx/telemetry": "^0.5.0",
|
|
59
59
|
"@types/bun": "^1.4.4",
|
|
60
60
|
"dataloader": "^2.2.3",
|
|
61
|
-
"graphql": "^
|
|
62
|
-
"graphql-ws": "^6.3.0",
|
|
63
|
-
"graphql-yoga": "^6.0.1"
|
|
61
|
+
"graphql": "^17.1.0"
|
|
64
62
|
},
|
|
65
63
|
"peerDependencies": {
|
|
66
|
-
"@alxia/core": "^0.
|
|
67
|
-
"graphql": "^
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
},
|
|
72
|
-
"peerDependenciesMeta": {
|
|
73
|
-
"graphql-ws": {
|
|
74
|
-
"optional": true
|
|
75
|
-
}
|
|
64
|
+
"@alxia/core": "^0.27.0",
|
|
65
|
+
"graphql": "^17.1.0",
|
|
66
|
+
"typescript": "^6.0.3 || ^7.0.0",
|
|
67
|
+
"@graxia/core": "^0.10.0",
|
|
68
|
+
"@graxia/graphiql": "^0.2.4"
|
|
76
69
|
}
|
|
77
70
|
}
|
package/dist/body-refusal.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Yoga reads the request body itself, and turns any failure of the read
|
|
3
|
-
* into its own 400. A body past core's `bodyLimit` fails the read with a
|
|
4
|
-
* `ContentTooLargeError`; `watchBody` keeps that error and hands Yoga its
|
|
5
|
-
* own 413 error in its place, so Yoga logs nothing, and the handler can
|
|
6
|
-
* throw core's again once Yoga has answered: the app's own boundary
|
|
7
|
-
* answers the 413 in its error format, leaking nothing of Yoga's.
|
|
8
|
-
*/
|
|
9
|
-
import type { ContentTooLargeError } from '@alxia/core';
|
|
10
|
-
export interface WatchedRequest {
|
|
11
|
-
/** The request to hand to Yoga: the same, its body watched. */
|
|
12
|
-
readonly request: Request;
|
|
13
|
-
/** The `ContentTooLargeError` the body's read failed with, if it did. */
|
|
14
|
-
refusal(): ContentTooLargeError | undefined;
|
|
15
|
-
}
|
|
16
|
-
/** `request` with its body's failure recorded; a request with no body is as it is. */
|
|
17
|
-
export declare function watchBody(request: Request): WatchedRequest;
|
|
18
|
-
/**
|
|
19
|
-
* Yoga's 400 for a request it cannot read — a body that is not JSON, a
|
|
20
|
-
* query string that is not valid — carries the parser's own error as
|
|
21
|
-
* `extensions.originalError`. A client reads the message and the code, not
|
|
22
|
-
* what a parser said: the response without it, any other as it is.
|
|
23
|
-
*/
|
|
24
|
-
export declare function withoutOriginalError(response: Response): Promise<Response>;
|
|
25
|
-
//# sourceMappingURL=body-refusal.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"body-refusal.d.ts","sourceRoot":"","sources":["../src/body-refusal.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAexD,MAAM,WAAW,cAAc;IAC9B,+DAA+D;IAC/D,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,yEAAyE;IACzE,OAAO,IAAI,oBAAoB,GAAG,SAAS,CAAC;CAC5C;AAED,sFAAsF;AACtF,wBAAgB,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,cAAc,CAgC1D;AAMD;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACzC,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,QAAQ,CAAC,CAqBnB"}
|
package/dist/document-cache.d.ts
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The parse cache `graphql()` gives Yoga: a least-recently-used map bounded
|
|
3
|
-
* by entries, by age and by estimated bytes, since a parsed document costs
|
|
4
|
-
* by its tokens and no count of entries bounds that.
|
|
5
|
-
*/
|
|
6
|
-
import { type DocumentNode } from 'graphql';
|
|
7
|
-
/** Yoga's `Cache` contract. */
|
|
8
|
-
export interface Cache<T> {
|
|
9
|
-
get(key: string): T | undefined;
|
|
10
|
-
set(key: string, value: T): void;
|
|
11
|
-
}
|
|
12
|
-
export interface BoundedCacheOptions<T> {
|
|
13
|
-
/** The most entries kept. */
|
|
14
|
-
readonly max: number;
|
|
15
|
-
/** How long an entry lives, in milliseconds. */
|
|
16
|
-
readonly ttl: number;
|
|
17
|
-
/** The most estimated bytes kept, the sum of the weights. */
|
|
18
|
-
readonly maxBytes: number;
|
|
19
|
-
/** The estimated bytes an entry holds. */
|
|
20
|
-
readonly weigh: (key: string, value: T) => number;
|
|
21
|
-
/** The clock, in milliseconds; injectable for the specs. */
|
|
22
|
-
readonly now?: () => number;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* A least-recently-used cache that evicts by `max`, `ttl` and `maxBytes`.
|
|
26
|
-
* An entry heavier than `maxBytes / 8` is not stored and evicts nothing.
|
|
27
|
-
*/
|
|
28
|
-
export declare function boundedCache<T>(options: BoundedCacheOptions<T>): Cache<T>;
|
|
29
|
-
/**
|
|
30
|
-
* A parsed document's estimated bytes: every token the lexer linked,
|
|
31
|
-
* comments included, plus the source as the key and as token values, plus
|
|
32
|
-
* 32 B per char of escaped string literals. Without `loc` (`noLocation`),
|
|
33
|
-
* nothing tells where the strings are: `tokenCount` and 36 B per char stand
|
|
34
|
-
* in; without `tokenCount` (older graphql), the source's length does.
|
|
35
|
-
*/
|
|
36
|
-
export declare function documentWeight(source: string, document: DocumentNode): number;
|
|
37
|
-
/** A parse error's estimated bytes: its source as the key, and the error (1 024 B). */
|
|
38
|
-
export declare function errorWeight(source: string): number;
|
|
39
|
-
//# sourceMappingURL=document-cache.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"document-cache.d.ts","sourceRoot":"","sources":["../src/document-cache.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,KAAK,YAAY,EAAyB,MAAM,SAAS,CAAC;AAEnE,+BAA+B;AAC/B,MAAM,WAAW,KAAK,CAAC,CAAC;IACvB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAAC;IAChC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB,CAAC,CAAC;IACrC,6BAA6B;IAC7B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,0CAA0C;IAC1C,QAAQ,CAAC,KAAK,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC;IAClD,4DAA4D;IAC5D,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CAC5B;AAQD;;;GAGG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAAE,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAoCzE;AA2DD;;;;;;GAMG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,GAAG,MAAM,CAc7E;AAED,uFAAuF;AACvF,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElD"}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,21 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,5 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,28 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,60 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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/nesting.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* How deep a document may nest. graphql-js parses by recursion, one set of
|
|
3
|
-
* frames per `{`, `(` or `[`, so a document a few thousand levels deep
|
|
4
|
-
* overflows the stack (a `RangeError`) long before `maxTokens` stops it,
|
|
5
|
-
* and Yoga answers that with a 500. A linear scan of the source counts the
|
|
6
|
-
* nesting first, without recursing.
|
|
7
|
-
*/
|
|
8
|
-
/** The most levels of `{`, `(` and `[` a document may nest, unless `maxNesting` says otherwise. */
|
|
9
|
-
export declare const DEFAULT_MAX_NESTING = 1000;
|
|
10
|
-
/** `maxNesting` checked where `graphql()` is declared. */
|
|
11
|
-
export declare function nestingLimit(maxNesting: number | false | undefined): number | false;
|
|
12
|
-
/**
|
|
13
|
-
* The offset of the first bracket that nests `body` deeper than `max`
|
|
14
|
-
* levels, or -1. Brackets inside strings, block strings and comments are
|
|
15
|
-
* text, not nesting; an unbalanced closing bracket is left to the parser.
|
|
16
|
-
*/
|
|
17
|
-
export declare function tooDeepAt(body: string, max: number): number;
|
|
18
|
-
//# sourceMappingURL=nesting.d.ts.map
|
package/dist/nesting.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"nesting.d.ts","sourceRoot":"","sources":["../src/nesting.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,mGAAmG;AACnG,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC,0DAA0D;AAC1D,wBAAgB,YAAY,CAC3B,UAAU,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GACpC,MAAM,GAAG,KAAK,CAShB;AAQD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAuC3D"}
|
package/dist/parse-limits.d.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* What `graphql()` bounds about parsing: the tokens a document may hold,
|
|
3
|
-
* and the cache of what was parsed.
|
|
4
|
-
*/
|
|
5
|
-
import { type DocumentNode } from 'graphql';
|
|
6
|
-
import type { Plugin, YogaServerOptions } from 'graphql-yoga';
|
|
7
|
-
import { type Cache } from './document-cache';
|
|
8
|
-
import type { YogaContext } from './handler';
|
|
9
|
-
/** The most tokens a document may hold, unless `maxTokens` says otherwise. */
|
|
10
|
-
export declare const DEFAULT_MAX_TOKENS = 15000;
|
|
11
|
-
/** The sizes of the parse cache, of each endpoint. */
|
|
12
|
-
export interface ParseCacheOptions {
|
|
13
|
-
/** The most estimated bytes of parsed documents kept. 64 MiB by default. */
|
|
14
|
-
readonly maxBytes?: number;
|
|
15
|
-
/** The most documents kept. 1 024 by default. */
|
|
16
|
-
readonly max?: number;
|
|
17
|
-
/** How long a document is kept, in milliseconds. One hour by default. */
|
|
18
|
-
readonly ttl?: number;
|
|
19
|
-
}
|
|
20
|
-
/** `maxTokens` checked where `graphql()` is declared. */
|
|
21
|
-
export declare function tokenLimit(maxTokens: number | false | undefined): number | false;
|
|
22
|
-
/**
|
|
23
|
-
* A Yoga plugin bounding what the parser is given: the tokens of every
|
|
24
|
-
* document (`maxTokens`) and the levels it nests (`maxNesting`, a scan of the
|
|
25
|
-
* source before any recursion). A document the parser still overflows the
|
|
26
|
-
* stack on is refused the same way, never a 500. It wraps the parse function
|
|
27
|
-
* Envelop already holds, never graphql's own `parse`: a second copy of
|
|
28
|
-
* graphql would throw errors Yoga does not recognise, masked as a 500.
|
|
29
|
-
*/
|
|
30
|
-
export declare function limitsParsing(maxTokens: number | false, maxNesting: number | false): Plugin;
|
|
31
|
-
/** What Yoga's `parserAndValidationCache` takes from alxia. */
|
|
32
|
-
export type ParseCaches = false | {
|
|
33
|
-
documentCache: Cache<DocumentNode>;
|
|
34
|
-
errorCache: Cache<unknown>;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* The limits `graphql()` was given, checked once at declaration: the token
|
|
38
|
-
* cap and the nesting limit, resolved, and the parse cache, which cannot be given beside Yoga's
|
|
39
|
-
* own. Each endpoint's Yoga builds its caches from the same options.
|
|
40
|
-
*/
|
|
41
|
-
export declare function resolveLimits(maxTokens: number | false | undefined, maxNesting: number | false | undefined, parseCache: false | ParseCacheOptions | undefined, yogaOptions: Pick<YogaServerOptions<YogaContext, YogaContext>, 'parserAndValidationCache'>): {
|
|
42
|
-
readonly tokens: number | false;
|
|
43
|
-
readonly depth: number | false;
|
|
44
|
-
};
|
|
45
|
-
/**
|
|
46
|
-
* The `parserAndValidationCache` of one Yoga: a pair of bounded caches,
|
|
47
|
-
* created per call so each endpoint has its own. `false` gives none.
|
|
48
|
-
*/
|
|
49
|
-
export declare function parseCaches(parseCache: false | ParseCacheOptions | undefined): ParseCaches;
|
|
50
|
-
//# sourceMappingURL=parse-limits.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-limits.d.ts","sourceRoot":"","sources":["../src/parse-limits.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,YAAY,EAAuB,MAAM,SAAS,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAEN,KAAK,KAAK,EAGV,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAG7C,8EAA8E;AAC9E,eAAO,MAAM,kBAAkB,QAAS,CAAC;AAEzC,sDAAsD;AACtD,MAAM,WAAW,iBAAiB;IACjC,4EAA4E;IAC5E,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,iDAAiD;IACjD,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;IACtB,yEAAyE;IACzE,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACtB;AAkBD,yDAAyD;AACzD,wBAAgB,UAAU,CACzB,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,GACnC,MAAM,GAAG,KAAK,CAShB;AAMD;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAC5B,SAAS,EAAE,MAAM,GAAG,KAAK,EACzB,UAAU,EAAE,MAAM,GAAG,KAAK,GACxB,MAAM,CAgCR;AAED,+DAA+D;AAC/D,MAAM,MAAM,WAAW,GACpB,KAAK,GACL;IACA,aAAa,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC;IACnC,UAAU,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC1B,CAAC;AA0CL;;;;GAIG;AACH,wBAAgB,aAAa,CAC5B,SAAS,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,EACrC,UAAU,EAAE,MAAM,GAAG,KAAK,GAAG,SAAS,EACtC,UAAU,EAAE,KAAK,GAAG,iBAAiB,GAAG,SAAS,EACjD,WAAW,EAAE,IAAI,CAChB,iBAAiB,CAAC,WAAW,EAAE,WAAW,CAAC,EAC3C,0BAA0B,CAC1B,GACC;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,KAAK,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,KAAK,CAAA;CAAE,CAarE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAC1B,UAAU,EAAE,KAAK,GAAG,iBAAiB,GAAG,SAAS,GAC/C,WAAW,CAiBb"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/same-origin/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { Plugin } from 'graphql-yoga';
|
|
2
|
-
/** Options of {@link sameOrigin}. */
|
|
3
|
-
export interface SameOriginOptions {
|
|
4
|
-
/**
|
|
5
|
-
* Origins (`https://app.example.com`) or hosts (`app.example.com`,
|
|
6
|
-
* `app.example.com:8443`) accepted besides the request URL's own host.
|
|
7
|
-
* Needed behind a proxy that rewrites the host, or for a trusted sibling.
|
|
8
|
-
*/
|
|
9
|
-
readonly allow?: readonly string[];
|
|
10
|
-
/**
|
|
11
|
-
* Refuse a `POST` whose `Content-Type` is not `application/json`, which an
|
|
12
|
-
* HTML form cannot send. Default `true`.
|
|
13
|
-
*/
|
|
14
|
-
readonly json?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* The answer to a refused request, instead of the default 403 `FORBIDDEN`
|
|
17
|
-
* JSON error. Receives the request; send no CORS header, so a foreign page
|
|
18
|
-
* cannot read it.
|
|
19
|
-
*/
|
|
20
|
-
readonly refuse?: (request: Request) => Response | Promise<Response>;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* A Yoga plugin for a GraphQL endpoint authenticated by a cookie: a request
|
|
24
|
-
* whose `Origin` is not the endpoint's own host (or one of `allow`), `Origin:
|
|
25
|
-
* null` included, and, unless `json` is `false`, a `POST` that is not
|
|
26
|
-
* `application/json`, is answered 403 before anything is parsed or run. A
|
|
27
|
-
* request with no `Origin` (not a browser) passes. List it first.
|
|
28
|
-
*/
|
|
29
|
-
export declare function sameOrigin(options?: SameOriginOptions): Plugin;
|
|
30
|
-
//# sourceMappingURL=same-origin.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"same-origin.d.ts","sourceRoot":"","sources":["../../src/same-origin/same-origin.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAE3C,qCAAqC;AACrC,MAAM,WAAW,iBAAiB;IACjC;;;;OAIG;IACH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IACxB;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;CACrE;AA4CD;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,GAAE,iBAAsB,GAAG,MAAM,CA4BlE"}
|
package/dist/ws-operations.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { type DocumentNode } from 'graphql';
|
|
2
|
-
import type { ServerOptions } from 'graphql-ws';
|
|
3
|
-
/** The operations of one socket, by their `graphql-ws` id. */
|
|
4
|
-
export declare class SocketOperations {
|
|
5
|
-
#private;
|
|
6
|
-
/** `ctx`: the socket's context, which carries its upgrade's observers. */
|
|
7
|
-
constructor(ctx: object);
|
|
8
|
-
/** The operation `id` starts: the one of `document` that `operationName` names. */
|
|
9
|
-
begin(id: string, document: DocumentNode, operationName: string | null | undefined): void;
|
|
10
|
-
/** The operation `id` answered with errors: a result's `errors`, or an error message. */
|
|
11
|
-
failed(id: string): void;
|
|
12
|
-
/** The operation `id` ended: completed, stopped by its client, or failed. */
|
|
13
|
-
end(id: string): void;
|
|
14
|
-
/**
|
|
15
|
-
* The socket closed: an operation still open then is one whose run threw,
|
|
16
|
-
* which `graphql-ws` answers by closing the socket, and ends with errors.
|
|
17
|
-
*/
|
|
18
|
-
closed(): void;
|
|
19
|
-
}
|
|
20
|
-
/** What `graphql-ws` keeps of each socket for its hooks: its operations. */
|
|
21
|
-
interface Followed {
|
|
22
|
-
readonly operations: SocketOperations;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* `graphql-ws`'s hooks that follow each operation: a result with errors
|
|
26
|
-
* marks it, an error message ends it, and so does its completion — sent,
|
|
27
|
-
* stopped by the client, or cut by the socket's close.
|
|
28
|
-
*/
|
|
29
|
-
export declare function following<E extends Followed>(): Pick<ServerOptions<Record<string, unknown> | undefined, E>, 'onNext' | 'onError' | 'onComplete'>;
|
|
30
|
-
export {};
|
|
31
|
-
//# sourceMappingURL=ws-operations.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws-operations.d.ts","sourceRoot":"","sources":["../src/ws-operations.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,KAAK,YAAY,EAAmB,MAAM,SAAS,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAQhD,8DAA8D;AAC9D,qBAAa,gBAAgB;;IAI5B,0EAA0E;gBAC9D,GAAG,EAAE,MAAM;IAIvB,mFAAmF;IACnF,KAAK,CACJ,EAAE,EAAE,MAAM,EACV,QAAQ,EAAE,YAAY,EACtB,aAAa,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GACtC,IAAI;IAYP,yFAAyF;IACzF,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAKxB,6EAA6E;IAC7E,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI;IAOrB;;;OAGG;IACH,MAAM,IAAI,IAAI;CAMd;AAED,4EAA4E;AAC5E,UAAU,QAAQ;IACjB,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;CACtC;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,QAAQ,KAAK,IAAI,CACpD,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,CAAC,CAAC,EACrD,QAAQ,GAAG,SAAS,GAAG,YAAY,CACnC,CAeA"}
|
package/dist/ws-server.d.ts
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* `graphql-ws`'s server options for a socket route: each operation parsed,
|
|
3
|
-
* validated, executed and subscribed through the endpoint's Yoga, and
|
|
4
|
-
* followed to its end for the observers around the upgrade.
|
|
5
|
-
*/
|
|
6
|
-
import type { BaseContext } from '@alxia/core';
|
|
7
|
-
import type { ServerOptions } from 'graphql-ws';
|
|
8
|
-
import type { YogaServerInstance } from 'graphql-yoga';
|
|
9
|
-
import { type YogaContext } from './handler';
|
|
10
|
-
import { type SocketOperations } from './ws-operations';
|
|
11
|
-
/**
|
|
12
|
-
* What `graphql-ws` keeps of each socket: the context its upgrade built,
|
|
13
|
-
* the request each of its operations reads as Yoga's `request`, and its
|
|
14
|
-
* operations, told to the upgrade's observers.
|
|
15
|
-
*/
|
|
16
|
-
export interface Extra {
|
|
17
|
-
readonly ctx: Record<string, unknown> & BaseContext;
|
|
18
|
-
readonly request: Request;
|
|
19
|
-
readonly operations: SocketOperations;
|
|
20
|
-
}
|
|
21
|
-
/** Where the socket route is, and the endpoint whose Yoga it runs. */
|
|
22
|
-
export interface Paths {
|
|
23
|
-
readonly endpoint: string;
|
|
24
|
-
readonly socket: string;
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* `graphql-ws`'s options: each operation parsed, validated, executed and
|
|
28
|
-
* subscribed through Yoga's envelop, with the context the upgrade built,
|
|
29
|
-
* the operation's `params` and the client's `connectionParams`.
|
|
30
|
-
*/
|
|
31
|
-
export declare function serverOptions<UserCtx extends YogaContext>(yogaAt: (endpoint: string) => YogaServerInstance<YogaContext, UserCtx>, paths: Paths): ServerOptions<Record<string, unknown> | undefined, Extra>;
|
|
32
|
-
//# sourceMappingURL=ws-server.d.ts.map
|
package/dist/ws-server.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ws-server.d.ts","sourceRoot":"","sources":["../src/ws-server.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAAE,aAAa,EAAoB,MAAM,YAAY,CAAC;AAClE,OAAO,KAAK,EAAsB,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAiB,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AAC5D,OAAO,EAAa,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnE;;;;GAIG;AACH,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,WAAW,CAAC;IACpD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAC;CACtC;AAQD,sEAAsE;AACtE,MAAM,WAAW,KAAK;IACrB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CACxB;AAcD;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,WAAW,EACxD,MAAM,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,kBAAkB,CAAC,WAAW,EAAE,OAAO,CAAC,EACtE,KAAK,EAAE,KAAK,GACV,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,EAAE,KAAK,CAAC,CAwC3D"}
|
package/dist/yoga.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type YogaContext } from './handler';
|
|
2
|
-
/**
|
|
3
|
-
* The Yoga behind an endpoint, from the options `graphql()` and
|
|
4
|
-
* `graphqlExecutor()` share: the limits, the parse cache, the logging and
|
|
5
|
-
* request id defaults, and `reportsOperations`. One Yoga per path.
|
|
6
|
-
*/
|
|
7
|
-
export declare function yogaFor<UserCtx extends YogaContext>(yogaOptions: object, page: {
|
|
8
|
-
readonly cors: unknown;
|
|
9
|
-
readonly ide?: 'graphiql' | 'apollo-sandbox' | false | undefined;
|
|
10
|
-
readonly graphiql?: unknown | undefined;
|
|
11
|
-
}): (endpoint: string) => import("graphql-yoga").YogaServerInstance<YogaContext, UserCtx>;
|
|
12
|
-
//# sourceMappingURL=yoga.d.ts.map
|
package/dist/yoga.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"yoga.d.ts","sourceRoot":"","sources":["../src/yoga.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,WAAW,EAAe,MAAM,WAAW,CAAC;AAS1D;;;;GAIG;AACH,wBAAgB,OAAO,CAAC,OAAO,SAAS,WAAW,EAClD,WAAW,EAAE,MAAM,EACnB,IAAI,EAAE;IACL,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,GAAG,CAAC,EAAE,UAAU,GAAG,gBAAgB,GAAG,KAAK,GAAG,SAAS,CAAC;IACjE,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CACxC,yFAkCD"}
|