zuplo 6.70.70 → 6.70.71

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.
Files changed (52) hide show
  1. package/docs/ai-gateway/getting-started.mdx +2 -1
  2. package/docs/ai-gateway/integrations/ai-sdk.mdx +17 -0
  3. package/docs/ai-gateway/introduction.mdx +5 -5
  4. package/docs/ai-gateway/providers.mdx +2 -0
  5. package/docs/analytics/access-and-entitlements.md +71 -0
  6. package/docs/analytics/overview.md +63 -0
  7. package/docs/analytics/reference/metrics-glossary.md +105 -0
  8. package/docs/analytics/reference/url-parameters.md +66 -0
  9. package/docs/analytics/shared-controls.md +121 -0
  10. package/docs/analytics/tabs/agents.md +88 -0
  11. package/docs/analytics/tabs/consumers.md +73 -0
  12. package/docs/analytics/tabs/graphql.md +77 -0
  13. package/docs/analytics/tabs/mcp.md +80 -0
  14. package/docs/analytics/tabs/origins.md +82 -0
  15. package/docs/analytics/tabs/requests.md +96 -0
  16. package/docs/articles/ci-cd-github/basic-deployment.mdx +10 -1
  17. package/docs/articles/ci-cd-github/deploy-and-test.mdx +14 -1
  18. package/docs/articles/ci-cd-github/local-testing.mdx +3 -1
  19. package/docs/articles/ci-cd-github/pr-preview-environments.mdx +36 -4
  20. package/docs/articles/custom-ci-cd-github.mdx +11 -2
  21. package/docs/articles/monetization/api-access.mdx +184 -0
  22. package/docs/articles/monetization/meters.mdx +4 -4
  23. package/docs/articles/monetization/monetization-policy.md +4 -1
  24. package/docs/articles/monetization/private-plans.md +3 -4
  25. package/docs/articles/monetization/stripe-integration.md +9 -0
  26. package/docs/articles/monetization/subscription-lifecycle.md +12 -11
  27. package/docs/articles/monorepo-deployment.mdx +20 -2
  28. package/docs/cli/deploy.mdx +32 -0
  29. package/docs/cli/deploy.partial.mdx +32 -0
  30. package/docs/concepts/api-keys.md +2 -2
  31. package/docs/dev-portal/zudoku/components/callout.mdx +11 -18
  32. package/docs/dev-portal/zudoku/configuration/search.md +36 -0
  33. package/docs/dev-portal/zudoku/configuration/site.md +38 -0
  34. package/docs/dev-portal/zudoku/customization/colors-theme.mdx +51 -40
  35. package/docs/errors/rate-limit-exceeded.mdx +30 -3
  36. package/docs/policies/_index.md +2 -0
  37. package/docs/policies/data-loss-prevention-inbound/doc.md +116 -0
  38. package/docs/policies/data-loss-prevention-inbound/intro.md +15 -0
  39. package/docs/policies/data-loss-prevention-inbound/schema.json +220 -0
  40. package/docs/policies/data-loss-prevention-outbound/doc.md +116 -0
  41. package/docs/policies/data-loss-prevention-outbound/intro.md +18 -0
  42. package/docs/policies/data-loss-prevention-outbound/schema.json +220 -0
  43. package/docs/programmable-api/background-dispatcher.mdx +6 -8
  44. package/docs/programmable-api/zone-cache.mdx +1 -1
  45. package/docs/rate-limiting/combining-policies.mdx +293 -0
  46. package/docs/rate-limiting/dynamic-rate-limiting.mdx +240 -0
  47. package/docs/rate-limiting/getting-started.mdx +339 -0
  48. package/docs/rate-limiting/how-it-works.md +225 -0
  49. package/docs/rate-limiting/monitoring-and-troubleshooting.mdx +243 -0
  50. package/docs/{articles → rate-limiting}/per-user-rate-limits-using-db.mdx +39 -27
  51. package/package.json +4 -4
  52. package/docs/concepts/rate-limiting.md +0 -246
@@ -1,246 +0,0 @@
1
- ---
2
- title: Rate Limiting
3
- ---
4
-
5
- Rate limiting controls how many requests a client can make to your API within a
6
- given time window. It protects your backend from traffic spikes, enforces fair
7
- usage across consumers, and enables tiered access for different customer plans.
8
-
9
- Zuplo's rate limiter uses a **sliding window algorithm** enforced globally
10
- across all edge locations. When a client exceeds the limit, they receive a
11
- `429 Too Many Requests` response with a `retry-after` header indicating when
12
- they can retry.
13
-
14
- ## Rate limiting policies
15
-
16
- Zuplo provides two rate limiting policies, each suited to different levels of
17
- complexity.
18
-
19
- ### Rate Limiting policy
20
-
21
- The [Rate Limiting policy](../policies/rate-limit-inbound.mdx) enforces a single
22
- request counter per time window. Configure a maximum number of requests, a time
23
- window, and how to identify callers.
24
-
25
- ```json
26
- {
27
- "name": "my-rate-limit-policy",
28
- "policyType": "rate-limit-inbound",
29
- "handler": {
30
- "export": "RateLimitInboundPolicy",
31
- "module": "$import(@zuplo/runtime)",
32
- "options": {
33
- "rateLimitBy": "user",
34
- "requestsAllowed": 100,
35
- "timeWindowMinutes": 1
36
- }
37
- }
38
- }
39
- ```
40
-
41
- Use this policy when you need a straightforward "X requests per Y minutes"
42
- limit.
43
-
44
- ### Complex Rate Limiting policy
45
-
46
- The [Complex Rate Limiting policy](../policies/complex-rate-limit-inbound.mdx)
47
- supports **multiple named counters** in a single policy. Each counter tracks a
48
- different resource or unit of work.
49
-
50
- ```json
51
- {
52
- "name": "my-complex-rate-limit-policy",
53
- "policyType": "complex-rate-limit-inbound",
54
- "handler": {
55
- "export": "ComplexRateLimitInboundPolicy",
56
- "module": "$import(@zuplo/runtime)",
57
- "options": {
58
- "rateLimitBy": "user",
59
- "timeWindowMinutes": 1,
60
- "limits": {
61
- "requests": 100,
62
- "compute": 500
63
- }
64
- }
65
- }
66
- }
67
- ```
68
-
69
- You can override counter increments programmatically per request using
70
- `ComplexRateLimitInboundPolicy.setIncrements()`. This is useful for usage-based
71
- pricing where different endpoints consume different amounts of a resource (for
72
- example, counting compute units or tokens instead of raw requests).
73
-
74
- ## Choosing a policy
75
-
76
- | Scenario | Policy |
77
- | ------------------------------------------------------ | --------------------------------------------- |
78
- | Fixed requests-per-minute limit for all callers | Rate Limiting |
79
- | Different limits per customer tier (free vs. paid) | Rate Limiting with a custom function |
80
- | Counting multiple resources (requests + compute units) | Complex Rate Limiting |
81
- | Usage-based billing with variable cost per request | Complex Rate Limiting with dynamic increments |
82
-
83
- ## How `rateLimitBy` works
84
-
85
- The `rateLimitBy` option determines how the rate limiter groups requests into
86
- buckets. Both policies support the same four modes.
87
-
88
- ### `ip`
89
-
90
- Groups requests by the client's IP address. No authentication is required. This
91
- is the simplest option and works well for public APIs or as a first layer of
92
- protection.
93
-
94
- ### `user`
95
-
96
- Groups requests by the authenticated user's identity (`request.user.sub`). When
97
- using [API key authentication](../articles/api-key-authentication.mdx), the
98
- `sub` value is the consumer name you assigned when creating the API key. When
99
- using JWT authentication, it comes from the token's `sub` claim.
100
-
101
- This is the recommended mode for authenticated APIs because it ties limits to
102
- the actual consumer rather than a shared IP address.
103
-
104
- ### `function`
105
-
106
- Groups requests using a custom TypeScript function that you provide. The
107
- function returns a `CustomRateLimitDetails` object containing a grouping key
108
- and, optionally, overridden values for `requestsAllowed` and
109
- `timeWindowMinutes`.
110
-
111
- This mode enables dynamic rate limiting where limits vary based on customer
112
- tier, route parameters, or any other request property.
113
-
114
- ### `all`
115
-
116
- Applies a single shared counter across all requests to the route, regardless of
117
- who makes them. Use this for global rate limits on endpoints that call
118
- resource-constrained backends.
119
-
120
- ## Dynamic rate limiting with custom functions
121
-
122
- When `rateLimitBy` is set to `"function"`, you provide a TypeScript module that
123
- determines the rate limit at request time. The function signature is:
124
-
125
- ```ts
126
- import {
127
- CustomRateLimitDetails,
128
- ZuploContext,
129
- ZuploRequest,
130
- } from "@zuplo/runtime";
131
-
132
- export function rateLimit(
133
- request: ZuploRequest,
134
- context: ZuploContext,
135
- policyName: string,
136
- ): CustomRateLimitDetails | undefined {
137
- const user = request.user;
138
-
139
- if (user.data.customerType === "premium") {
140
- return {
141
- key: user.sub,
142
- requestsAllowed: 1000,
143
- timeWindowMinutes: 1,
144
- };
145
- }
146
-
147
- return {
148
- key: user.sub,
149
- requestsAllowed: 50,
150
- timeWindowMinutes: 1,
151
- };
152
- }
153
- ```
154
-
155
- The `CustomRateLimitDetails` object has the following properties:
156
-
157
- - `key` - The string used to group requests into rate limit buckets
158
- - `requestsAllowed` (optional) - Overrides the policy's `requestsAllowed` value
159
- - `timeWindowMinutes` (optional) - Overrides the policy's `timeWindowMinutes`
160
- value
161
-
162
- Returning `undefined` skips rate limiting for that request entirely.
163
-
164
- The function can also be `async` if you need to look up limits from a database
165
- or external service. See
166
- [Per-user rate limiting using a database](../articles/per-user-rate-limits-using-db.mdx)
167
- for a complete example using the ZoneCache for performance.
168
-
169
- Wire the function into the policy configuration using the `identifier` option:
170
-
171
- ```json
172
- {
173
- "export": "RateLimitInboundPolicy",
174
- "module": "$import(@zuplo/runtime)",
175
- "options": {
176
- "rateLimitBy": "function",
177
- "requestsAllowed": 50,
178
- "timeWindowMinutes": 1,
179
- "identifier": {
180
- "export": "rateLimit",
181
- "module": "$import(./modules/rate-limit)"
182
- }
183
- }
184
- }
185
- ```
186
-
187
- :::note
188
-
189
- The `requestsAllowed` and `timeWindowMinutes` values in the policy configuration
190
- serve as defaults. The custom function can override them per request.
191
-
192
- :::
193
-
194
- ## Combining rate limiting with authentication
195
-
196
- Rate limiting works best when combined with authentication so that limits apply
197
- per consumer rather than per IP. A typical policy pipeline is:
198
-
199
- 1. **Authentication** (e.g., API Key Authentication) -- validates credentials
200
- and populates `request.user`
201
- 2. **Rate Limiting** with `rateLimitBy: "user"` -- enforces per-consumer limits
202
- using `request.user.sub`
203
-
204
- With API key authentication, the consumer's metadata (stored when creating the
205
- key) is available at `request.user.data`. A custom rate limit function can read
206
- fields like `customerType` or `plan` from the metadata to apply tiered limits.
207
-
208
- ## Rate limiting and monetization
209
-
210
- If you use Zuplo's
211
- [Monetization](../articles/monetization/monetization-policy.md) feature, the
212
- monetization policy handles quota enforcement based on subscription plans. You
213
- can still add a rate limiting policy after the monetization policy to provide
214
- per-second or per-minute spike protection on top of monthly billing quotas.
215
- These serve different purposes:
216
-
217
- - **Monetization quotas** enforce monthly or billing-period usage limits tied to
218
- a subscription plan
219
- - **Rate limiting** protects against short-duration traffic spikes that could
220
- overwhelm your backend
221
-
222
- ## Combining multiple rate limit policies
223
-
224
- You can apply multiple rate limiting policies to the same route. For example,
225
- you might enforce both a per-minute and a per-hour limit. When using multiple
226
- policies, apply the longest time window first, followed by shorter durations.
227
-
228
- ## Additional options
229
-
230
- Both rate limiting policies support the following additional options:
231
-
232
- - `headerMode` - Set to `"retry-after"` (default) to include the `retry-after`
233
- header in 429 responses, or `"none"` to omit it
234
- - `mode` - Set to `"strict"` (default) for synchronous enforcement, or `"async"`
235
- for non-blocking checks that may allow some requests over the limit
236
- - `throwOnFailure` - Set to `true` to return an error if the rate limit service
237
- is unreachable, or `false` (default) to allow the request through
238
-
239
- ## Related resources
240
-
241
- - [Rate Limiting policy reference](../policies/rate-limit-inbound.mdx)
242
- - [Complex Rate Limiting policy reference](../policies/complex-rate-limit-inbound.mdx)
243
- - [Dynamic Rate Limiting tutorial](../articles/step-5-dynamic-rate-limiting.mdx)
244
- - [Per-user rate limiting with a database](../articles/per-user-rate-limits-using-db.mdx)
245
- - [Quota policy](../policies/quota-inbound.mdx)
246
- - [Monetization policy](../articles/monetization/monetization-policy.md)