stellate 3.0.4 → 3.2.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/dist/apollo-server.d.mts +14 -0
- package/dist/apollo-server.mjs +4 -8
- package/dist/bin.js +745 -733
- package/dist/envelop.d.mts +16 -0
- package/dist/envelop.mjs +2 -4
- package/dist/graphql-yoga.d.mts +14 -0
- package/dist/graphql-yoga.mjs +2 -4
- package/dist/index.d.mts +2094 -0
- package/dist/index.d.ts +7 -7
- package/dist/index.js +1 -1
- package/dist/rate-limiting.d.mts +69 -0
- package/package.json +7 -6
package/dist/index.d.ts
CHANGED
|
@@ -231,7 +231,7 @@ declare const inputSchema: z.ZodObject<{
|
|
|
231
231
|
definition?: string | ((args_0: {
|
|
232
232
|
headers: Record<string, string | string[]>;
|
|
233
233
|
cookies: Record<string, string>;
|
|
234
|
-
}, ...
|
|
234
|
+
}, ...args: unknown[]) => string | null) | null | undefined;
|
|
235
235
|
jwt?: {
|
|
236
236
|
claim?: string | null | undefined;
|
|
237
237
|
algorithm?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES256k" | "EdDSA" | "PS256" | "PS384" | "PS512" | null | undefined;
|
|
@@ -241,7 +241,7 @@ declare const inputSchema: z.ZodObject<{
|
|
|
241
241
|
definition?: string | ((args_0: {
|
|
242
242
|
headers: Record<string, string | string[]>;
|
|
243
243
|
cookies: Record<string, string>;
|
|
244
|
-
}, ...
|
|
244
|
+
}, ...args: unknown[]) => string | null) | null | undefined;
|
|
245
245
|
jwt?: {
|
|
246
246
|
claim?: string | null | undefined;
|
|
247
247
|
algorithm?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES256k" | "EdDSA" | "PS256" | "PS384" | "PS512" | null | undefined;
|
|
@@ -1014,11 +1014,11 @@ declare const inputSchema: z.ZodObject<{
|
|
|
1014
1014
|
scopes?: Record<string, string | ((args_0: {
|
|
1015
1015
|
headers: Record<string, string | string[]>;
|
|
1016
1016
|
cookies: Record<string, string>;
|
|
1017
|
-
}, ...
|
|
1017
|
+
}, ...args: unknown[]) => string | null) | {
|
|
1018
1018
|
definition?: string | ((args_0: {
|
|
1019
1019
|
headers: Record<string, string | string[]>;
|
|
1020
1020
|
cookies: Record<string, string>;
|
|
1021
|
-
}, ...
|
|
1021
|
+
}, ...args: unknown[]) => string | null) | null | undefined;
|
|
1022
1022
|
jwt?: {
|
|
1023
1023
|
claim?: string | null | undefined;
|
|
1024
1024
|
algorithm?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES256k" | "EdDSA" | "PS256" | "PS384" | "PS512" | null | undefined;
|
|
@@ -1251,11 +1251,11 @@ declare const inputSchema: z.ZodObject<{
|
|
|
1251
1251
|
scopes?: Record<string, string | ((args_0: {
|
|
1252
1252
|
headers: Record<string, string | string[]>;
|
|
1253
1253
|
cookies: Record<string, string>;
|
|
1254
|
-
}, ...
|
|
1254
|
+
}, ...args: unknown[]) => string | null) | {
|
|
1255
1255
|
definition?: string | ((args_0: {
|
|
1256
1256
|
headers: Record<string, string | string[]>;
|
|
1257
1257
|
cookies: Record<string, string>;
|
|
1258
|
-
}, ...
|
|
1258
|
+
}, ...args: unknown[]) => string | null) | null | undefined;
|
|
1259
1259
|
jwt?: {
|
|
1260
1260
|
claim?: string | null | undefined;
|
|
1261
1261
|
algorithm?: "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512" | "ES256" | "ES384" | "ES256k" | "EdDSA" | "PS256" | "PS384" | "PS512" | null | undefined;
|
|
@@ -2091,4 +2091,4 @@ type Config = {
|
|
|
2091
2091
|
};
|
|
2092
2092
|
declare const createConfig: (input: Partial<Input>) => Input;
|
|
2093
2093
|
|
|
2094
|
-
export { ComplexityConfig, ComplexityLimit, Config, ConfigFunction, EdgeRequest, Input, RateLimitConfig, RateLimitRule, RateLimitRules, RequestLimit, ScopeContext, ScopeFunctionDefinition, TimeWindow, createConfig as default };
|
|
2094
|
+
export { type ComplexityConfig, type ComplexityLimit, type Config, type ConfigFunction, type EdgeRequest, type Input, type RateLimitConfig, type RateLimitRule, type RateLimitRules, type RequestLimit, type ScopeContext, type ScopeFunctionDefinition, type TimeWindow, createConfig as default };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var a=(i,t)=>{for(var e in t)o(i,e,{get:t[e],enumerable:!0})},f=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!g.call(i,n)&&n!==e&&o(i,n,{get:()=>t[n],enumerable:!(r=m(t,n))||r.enumerable});return i};var u=i=>f(o({},"__esModule",{value:!0}),i);var l={};a(l,{default:()=>s});module.exports=u(l);var c=i=>i,s=c;
|
|
1
|
+
"use strict";var o=Object.defineProperty;var m=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var g=Object.prototype.hasOwnProperty;var a=(i,t)=>{for(var e in t)o(i,e,{get:t[e],enumerable:!0})},f=(i,t,e,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of p(t))!g.call(i,n)&&n!==e&&o(i,n,{get:()=>t[n],enumerable:!(r=m(t,n))||r.enumerable});return i};var u=i=>f(o({},"__esModule",{value:!0}),i);var l={};a(l,{default:()=>s});module.exports=u(l);var c=i=>i,s=c;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
type TimeWindow = `${number}${'s' | 'm' | 'h'}` | {
|
|
2
|
+
value: number;
|
|
3
|
+
unit: 'seconds' | 'minutes' | 'hours';
|
|
4
|
+
};
|
|
5
|
+
interface EdgeRequest {
|
|
6
|
+
method: string;
|
|
7
|
+
path: string;
|
|
8
|
+
queryString: string;
|
|
9
|
+
queryParams: Record<string, string | string[]>;
|
|
10
|
+
headers: Record<string, string | string[]>;
|
|
11
|
+
ip: string;
|
|
12
|
+
jwt: Record<string, unknown> | null;
|
|
13
|
+
operation: 'query' | 'mutation' | 'subscription';
|
|
14
|
+
rootFields: {
|
|
15
|
+
name: string;
|
|
16
|
+
alias: string | null;
|
|
17
|
+
args: Record<string, unknown>;
|
|
18
|
+
}[];
|
|
19
|
+
}
|
|
20
|
+
interface ComplexityLimit {
|
|
21
|
+
type: 'QueryComplexity';
|
|
22
|
+
budget: number;
|
|
23
|
+
warning?: number;
|
|
24
|
+
window: TimeWindow;
|
|
25
|
+
}
|
|
26
|
+
interface RequestLimit {
|
|
27
|
+
type: 'RequestCount';
|
|
28
|
+
budget: number;
|
|
29
|
+
warning?: number;
|
|
30
|
+
window: TimeWindow;
|
|
31
|
+
}
|
|
32
|
+
type RateLimitGroupBy = 'ip' | {
|
|
33
|
+
header: string;
|
|
34
|
+
} | {
|
|
35
|
+
cookie: string;
|
|
36
|
+
} | {
|
|
37
|
+
jwt: string;
|
|
38
|
+
} | {
|
|
39
|
+
consumerIdentifier: string;
|
|
40
|
+
};
|
|
41
|
+
interface BaseRateLimitRule {
|
|
42
|
+
name: string;
|
|
43
|
+
description?: string;
|
|
44
|
+
state?: 'enabled' | 'disabled' | 'dryRun';
|
|
45
|
+
allowList?: readonly string[];
|
|
46
|
+
limit: ComplexityLimit | RequestLimit;
|
|
47
|
+
}
|
|
48
|
+
type DynamicRateLimitRule = BaseRateLimitRule & ({
|
|
49
|
+
groupBy: RateLimitGroupBy;
|
|
50
|
+
} | {
|
|
51
|
+
group: string | number;
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
declare function isQuery(req: EdgeRequest): boolean;
|
|
55
|
+
declare function isMutation(req: EdgeRequest): boolean;
|
|
56
|
+
declare function hasRootField(req: EdgeRequest, rootField: string): boolean;
|
|
57
|
+
type FieldConfigMap = {
|
|
58
|
+
[rootFieldName: string]: Omit<RequestLimit, 'type'>;
|
|
59
|
+
};
|
|
60
|
+
type OmitLimitKey<Type> = {
|
|
61
|
+
[Key in keyof Type as Exclude<Key, 'limit'>]: Type[Key];
|
|
62
|
+
};
|
|
63
|
+
type ByFieldConfig = OmitLimitKey<DynamicRateLimitRule> & {
|
|
64
|
+
queryFields?: FieldConfigMap;
|
|
65
|
+
mutationFields?: FieldConfigMap;
|
|
66
|
+
};
|
|
67
|
+
declare function byField(req: EdgeRequest, { queryFields, mutationFields, ...baseConfig }: ByFieldConfig): DynamicRateLimitRule[];
|
|
68
|
+
|
|
69
|
+
export { byField, hasRootField, isMutation, isQuery };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "stellate",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"engines": {
|
|
5
5
|
"node": ">=18"
|
|
6
6
|
},
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"table": "^6.0.7",
|
|
39
39
|
"terminal-link": "^2.1.1",
|
|
40
40
|
"timeago.js": "^4.0.2",
|
|
41
|
-
"tsup": "
|
|
42
|
-
"tsx": "
|
|
43
|
-
"typescript": "
|
|
44
|
-
"vitest": "
|
|
41
|
+
"tsup": "8.5.0",
|
|
42
|
+
"tsx": "4.20.0",
|
|
43
|
+
"typescript": "5.8.3",
|
|
44
|
+
"vitest": "3.2.3",
|
|
45
45
|
"ws": "8.17.1",
|
|
46
46
|
"yaml": "^1.10.2",
|
|
47
47
|
"@gcdn/configuration": "1.39.7"
|
|
@@ -123,6 +123,7 @@
|
|
|
123
123
|
"build": "tsup && rm dist/bin.mjs",
|
|
124
124
|
"stellate": "tsx src/bin.ts",
|
|
125
125
|
"test": "FORCE_COLOR=0 vitest run",
|
|
126
|
-
"test:watch": "vitest"
|
|
126
|
+
"test:watch": "vitest",
|
|
127
|
+
"typecheck": "tsc --noEmit"
|
|
127
128
|
}
|
|
128
129
|
}
|