@unkey/api 2.1.0 → 2.1.2
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 +10 -6
- package/bin/mcp-server.js +806 -347
- package/bin/mcp-server.js.map +26 -13
- package/dist/commonjs/funcs/keysMigrateKeys.d.ts +23 -0
- package/dist/commonjs/funcs/keysMigrateKeys.d.ts.map +1 -0
- package/dist/commonjs/funcs/keysMigrateKeys.js +133 -0
- package/dist/commonjs/funcs/keysMigrateKeys.js.map +1 -0
- package/dist/commonjs/funcs/ratelimitLimit.d.ts +0 -4
- package/dist/commonjs/funcs/ratelimitLimit.d.ts.map +1 -1
- package/dist/commonjs/funcs/ratelimitLimit.js +0 -4
- package/dist/commonjs/funcs/ratelimitLimit.js.map +1 -1
- package/dist/commonjs/funcs/ratelimitMultiLimit.d.ts +28 -0
- package/dist/commonjs/funcs/ratelimitMultiLimit.d.ts.map +1 -0
- package/dist/commonjs/funcs/ratelimitMultiLimit.js +139 -0
- package/dist/commonjs/funcs/ratelimitMultiLimit.js.map +1 -0
- package/dist/commonjs/hooks/custom/vercel-edge-fetcher.d.ts +5 -0
- package/dist/commonjs/hooks/custom/vercel-edge-fetcher.d.ts.map +1 -0
- package/dist/commonjs/hooks/custom/vercel-edge-fetcher.js +63 -0
- package/dist/commonjs/hooks/custom/vercel-edge-fetcher.js.map +1 -0
- package/dist/commonjs/hooks/registration.d.ts.map +1 -1
- package/dist/commonjs/hooks/registration.js +3 -4
- package/dist/commonjs/hooks/registration.js.map +1 -1
- package/dist/commonjs/lib/config.d.ts +3 -3
- package/dist/commonjs/lib/config.js +3 -3
- package/dist/commonjs/mcp-server/mcp-server.js +1 -1
- package/dist/commonjs/mcp-server/server.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/server.js +5 -1
- package/dist/commonjs/mcp-server/server.js.map +1 -1
- package/dist/commonjs/mcp-server/tools/keysMigrateKeys.d.ts +8 -0
- package/dist/commonjs/mcp-server/tools/keysMigrateKeys.d.ts.map +1 -0
- package/dist/commonjs/mcp-server/tools/keysMigrateKeys.js +70 -0
- package/dist/commonjs/mcp-server/tools/keysMigrateKeys.js.map +1 -0
- package/dist/commonjs/mcp-server/tools/ratelimitLimit.d.ts.map +1 -1
- package/dist/commonjs/mcp-server/tools/ratelimitLimit.js +0 -4
- package/dist/commonjs/mcp-server/tools/ratelimitLimit.js.map +1 -1
- package/dist/commonjs/mcp-server/tools/ratelimitMultiLimit.d.ts +9 -0
- package/dist/commonjs/mcp-server/tools/ratelimitMultiLimit.d.ts.map +1 -0
- package/dist/commonjs/mcp-server/tools/ratelimitMultiLimit.js +76 -0
- package/dist/commonjs/mcp-server/tools/ratelimitMultiLimit.js.map +1 -0
- package/dist/commonjs/models/components/index.d.ts +8 -0
- package/dist/commonjs/models/components/index.d.ts.map +1 -1
- package/dist/commonjs/models/components/index.js +8 -0
- package/dist/commonjs/models/components/index.js.map +1 -1
- package/dist/commonjs/models/components/v2keysmigratekeydata.d.ts +113 -0
- package/dist/commonjs/models/components/v2keysmigratekeydata.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeydata.js +78 -0
- package/dist/commonjs/models/components/v2keysmigratekeydata.js.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeysmigration.d.ts +25 -0
- package/dist/commonjs/models/components/v2keysmigratekeysmigration.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeysmigration.js +60 -0
- package/dist/commonjs/models/components/v2keysmigratekeysmigration.js.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeysrequestbody.d.ts +28 -0
- package/dist/commonjs/models/components/v2keysmigratekeysrequestbody.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeysrequestbody.js +63 -0
- package/dist/commonjs/models/components/v2keysmigratekeysrequestbody.js.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeysresponsebody.d.ts +24 -0
- package/dist/commonjs/models/components/v2keysmigratekeysresponsebody.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeysresponsebody.js +62 -0
- package/dist/commonjs/models/components/v2keysmigratekeysresponsebody.js.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeysresponsedata.d.ts +26 -0
- package/dist/commonjs/models/components/v2keysmigratekeysresponsedata.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2keysmigratekeysresponsedata.js +61 -0
- package/dist/commonjs/models/components/v2keysmigratekeysresponsedata.js.map +1 -0
- package/dist/commonjs/models/components/v2keysverifykeyrequestbody.d.ts +5 -0
- package/dist/commonjs/models/components/v2keysverifykeyrequestbody.d.ts.map +1 -1
- package/dist/commonjs/models/components/v2keysverifykeyrequestbody.js +2 -0
- package/dist/commonjs/models/components/v2keysverifykeyrequestbody.js.map +1 -1
- package/dist/commonjs/models/components/v2keysverifykeyresponsedata.d.ts +3 -3
- package/dist/commonjs/models/components/v2ratelimitmultilimitcheck.d.ts +84 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitcheck.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitcheck.js +70 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitcheck.js.map +1 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitresponsebody.d.ts +27 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitresponsebody.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitresponsebody.js +62 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitresponsebody.js.map +1 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitresponsedata.d.ts +33 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitresponsedata.d.ts.map +1 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitresponsedata.js +61 -0
- package/dist/commonjs/models/components/v2ratelimitmultilimitresponsedata.js.map +1 -0
- package/dist/commonjs/sdk/keys.d.ts +12 -0
- package/dist/commonjs/sdk/keys.d.ts.map +1 -1
- package/dist/commonjs/sdk/keys.js +15 -0
- package/dist/commonjs/sdk/keys.js.map +1 -1
- package/dist/commonjs/sdk/ratelimit.d.ts +17 -4
- package/dist/commonjs/sdk/ratelimit.d.ts.map +1 -1
- package/dist/commonjs/sdk/ratelimit.js +20 -4
- package/dist/commonjs/sdk/ratelimit.js.map +1 -1
- package/dist/commonjs/types/enums.d.ts +10 -6
- package/dist/commonjs/types/enums.d.ts.map +1 -1
- package/dist/commonjs/types/enums.js +76 -2
- package/dist/commonjs/types/enums.js.map +1 -1
- package/dist/commonjs/types/index.d.ts +0 -1
- package/dist/commonjs/types/index.d.ts.map +1 -1
- package/dist/commonjs/types/index.js +1 -3
- package/dist/commonjs/types/index.js.map +1 -1
- package/dist/esm/funcs/keysMigrateKeys.d.ts +23 -0
- package/dist/esm/funcs/keysMigrateKeys.d.ts.map +1 -0
- package/dist/esm/funcs/keysMigrateKeys.js +97 -0
- package/dist/esm/funcs/keysMigrateKeys.js.map +1 -0
- package/dist/esm/funcs/ratelimitLimit.d.ts +0 -4
- package/dist/esm/funcs/ratelimitLimit.d.ts.map +1 -1
- package/dist/esm/funcs/ratelimitLimit.js +0 -4
- package/dist/esm/funcs/ratelimitLimit.js.map +1 -1
- package/dist/esm/funcs/ratelimitMultiLimit.d.ts +28 -0
- package/dist/esm/funcs/ratelimitMultiLimit.d.ts.map +1 -0
- package/dist/esm/funcs/ratelimitMultiLimit.js +103 -0
- package/dist/esm/funcs/ratelimitMultiLimit.js.map +1 -0
- package/dist/esm/hooks/custom/vercel-edge-fetcher.d.ts +5 -0
- package/dist/esm/hooks/custom/vercel-edge-fetcher.d.ts.map +1 -0
- package/dist/esm/hooks/custom/vercel-edge-fetcher.js +59 -0
- package/dist/esm/hooks/custom/vercel-edge-fetcher.js.map +1 -0
- package/dist/esm/hooks/registration.d.ts.map +1 -1
- package/dist/esm/hooks/registration.js +3 -4
- package/dist/esm/hooks/registration.js.map +1 -1
- package/dist/esm/lib/config.d.ts +3 -3
- package/dist/esm/lib/config.js +3 -3
- package/dist/esm/mcp-server/mcp-server.js +1 -1
- package/dist/esm/mcp-server/server.d.ts.map +1 -1
- package/dist/esm/mcp-server/server.js +5 -1
- package/dist/esm/mcp-server/server.js.map +1 -1
- package/dist/esm/mcp-server/tools/keysMigrateKeys.d.ts +8 -0
- package/dist/esm/mcp-server/tools/keysMigrateKeys.d.ts.map +1 -0
- package/dist/esm/mcp-server/tools/keysMigrateKeys.js +34 -0
- package/dist/esm/mcp-server/tools/keysMigrateKeys.js.map +1 -0
- package/dist/esm/mcp-server/tools/ratelimitLimit.d.ts.map +1 -1
- package/dist/esm/mcp-server/tools/ratelimitLimit.js +0 -4
- package/dist/esm/mcp-server/tools/ratelimitLimit.js.map +1 -1
- package/dist/esm/mcp-server/tools/ratelimitMultiLimit.d.ts +9 -0
- package/dist/esm/mcp-server/tools/ratelimitMultiLimit.d.ts.map +1 -0
- package/dist/esm/mcp-server/tools/ratelimitMultiLimit.js +40 -0
- package/dist/esm/mcp-server/tools/ratelimitMultiLimit.js.map +1 -0
- package/dist/esm/models/components/index.d.ts +8 -0
- package/dist/esm/models/components/index.d.ts.map +1 -1
- package/dist/esm/models/components/index.js +8 -0
- package/dist/esm/models/components/index.js.map +1 -1
- package/dist/esm/models/components/v2keysmigratekeydata.d.ts +113 -0
- package/dist/esm/models/components/v2keysmigratekeydata.d.ts.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeydata.js +40 -0
- package/dist/esm/models/components/v2keysmigratekeydata.js.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeysmigration.d.ts +25 -0
- package/dist/esm/models/components/v2keysmigratekeysmigration.d.ts.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeysmigration.js +22 -0
- package/dist/esm/models/components/v2keysmigratekeysmigration.js.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeysrequestbody.d.ts +28 -0
- package/dist/esm/models/components/v2keysmigratekeysrequestbody.d.ts.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeysrequestbody.js +25 -0
- package/dist/esm/models/components/v2keysmigratekeysrequestbody.js.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeysresponsebody.d.ts +24 -0
- package/dist/esm/models/components/v2keysmigratekeysresponsebody.d.ts.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeysresponsebody.js +24 -0
- package/dist/esm/models/components/v2keysmigratekeysresponsebody.js.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeysresponsedata.d.ts +26 -0
- package/dist/esm/models/components/v2keysmigratekeysresponsedata.d.ts.map +1 -0
- package/dist/esm/models/components/v2keysmigratekeysresponsedata.js +23 -0
- package/dist/esm/models/components/v2keysmigratekeysresponsedata.js.map +1 -0
- package/dist/esm/models/components/v2keysverifykeyrequestbody.d.ts +5 -0
- package/dist/esm/models/components/v2keysverifykeyrequestbody.d.ts.map +1 -1
- package/dist/esm/models/components/v2keysverifykeyrequestbody.js +2 -0
- package/dist/esm/models/components/v2keysverifykeyrequestbody.js.map +1 -1
- package/dist/esm/models/components/v2keysverifykeyresponsedata.d.ts +3 -3
- package/dist/esm/models/components/v2ratelimitmultilimitcheck.d.ts +84 -0
- package/dist/esm/models/components/v2ratelimitmultilimitcheck.d.ts.map +1 -0
- package/dist/esm/models/components/v2ratelimitmultilimitcheck.js +32 -0
- package/dist/esm/models/components/v2ratelimitmultilimitcheck.js.map +1 -0
- package/dist/esm/models/components/v2ratelimitmultilimitresponsebody.d.ts +27 -0
- package/dist/esm/models/components/v2ratelimitmultilimitresponsebody.d.ts.map +1 -0
- package/dist/esm/models/components/v2ratelimitmultilimitresponsebody.js +24 -0
- package/dist/esm/models/components/v2ratelimitmultilimitresponsebody.js.map +1 -0
- package/dist/esm/models/components/v2ratelimitmultilimitresponsedata.d.ts +33 -0
- package/dist/esm/models/components/v2ratelimitmultilimitresponsedata.d.ts.map +1 -0
- package/dist/esm/models/components/v2ratelimitmultilimitresponsedata.js +23 -0
- package/dist/esm/models/components/v2ratelimitmultilimitresponsedata.js.map +1 -0
- package/dist/esm/sdk/keys.d.ts +12 -0
- package/dist/esm/sdk/keys.d.ts.map +1 -1
- package/dist/esm/sdk/keys.js +15 -0
- package/dist/esm/sdk/keys.js.map +1 -1
- package/dist/esm/sdk/ratelimit.d.ts +17 -4
- package/dist/esm/sdk/ratelimit.d.ts.map +1 -1
- package/dist/esm/sdk/ratelimit.js +20 -4
- package/dist/esm/sdk/ratelimit.js.map +1 -1
- package/dist/esm/types/enums.d.ts +10 -6
- package/dist/esm/types/enums.d.ts.map +1 -1
- package/dist/esm/types/enums.js +38 -1
- package/dist/esm/types/enums.js.map +1 -1
- package/dist/esm/types/index.d.ts +0 -1
- package/dist/esm/types/index.d.ts.map +1 -1
- package/dist/esm/types/index.js +0 -1
- package/dist/esm/types/index.js.map +1 -1
- package/examples/package-lock.json +1 -1
- package/jsr.json +1 -1
- package/package.json +1 -1
- package/src/funcs/keysMigrateKeys.ts +201 -0
- package/src/funcs/ratelimitLimit.ts +0 -4
- package/src/funcs/ratelimitMultiLimit.ts +213 -0
- package/src/hooks/custom/vercel-edge-fetcher.ts +64 -0
- package/src/hooks/registration.ts +3 -4
- package/src/lib/config.ts +3 -3
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +5 -1
- package/src/mcp-server/tools/keysMigrateKeys.ts +43 -0
- package/src/mcp-server/tools/ratelimitLimit.ts +0 -4
- package/src/mcp-server/tools/ratelimitMultiLimit.ts +49 -0
- package/src/models/components/index.ts +8 -0
- package/src/models/components/v2keysmigratekeydata.ts +171 -0
- package/src/models/components/v2keysmigratekeysmigration.ts +61 -0
- package/src/models/components/v2keysmigratekeysrequestbody.ts +73 -0
- package/src/models/components/v2keysmigratekeysresponsebody.ts +72 -0
- package/src/models/components/v2keysmigratekeysresponsedata.ts +69 -0
- package/src/models/components/v2keysverifykeyrequestbody.ts +7 -0
- package/src/models/components/v2keysverifykeyresponsedata.ts +3 -3
- package/src/models/components/v2ratelimitmultilimitcheck.ts +130 -0
- package/src/models/components/v2ratelimitmultilimitresponsebody.ts +75 -0
- package/src/models/components/v2ratelimitmultilimitresponsedata.ts +76 -0
- package/src/sdk/keys.ts +23 -0
- package/src/sdk/ratelimit.ts +28 -4
- package/src/types/enums.ts +55 -6
- package/src/types/index.ts +0 -1
|
@@ -55,6 +55,11 @@ export * from "./v2keysdeletekeyrequestbody.js";
|
|
|
55
55
|
export * from "./v2keysdeletekeyresponsebody.js";
|
|
56
56
|
export * from "./v2keysgetkeyrequestbody.js";
|
|
57
57
|
export * from "./v2keysgetkeyresponsebody.js";
|
|
58
|
+
export * from "./v2keysmigratekeydata.js";
|
|
59
|
+
export * from "./v2keysmigratekeysmigration.js";
|
|
60
|
+
export * from "./v2keysmigratekeysrequestbody.js";
|
|
61
|
+
export * from "./v2keysmigratekeysresponsebody.js";
|
|
62
|
+
export * from "./v2keysmigratekeysresponsedata.js";
|
|
58
63
|
export * from "./v2keysremovepermissionsrequestbody.js";
|
|
59
64
|
export * from "./v2keysremovepermissionsresponsebody.js";
|
|
60
65
|
export * from "./v2keysremoverolesrequestbody.js";
|
|
@@ -103,6 +108,9 @@ export * from "./v2ratelimitlimitresponsebody.js";
|
|
|
103
108
|
export * from "./v2ratelimitlimitresponsedata.js";
|
|
104
109
|
export * from "./v2ratelimitlistoverridesrequestbody.js";
|
|
105
110
|
export * from "./v2ratelimitlistoverridesresponsebody.js";
|
|
111
|
+
export * from "./v2ratelimitmultilimitcheck.js";
|
|
112
|
+
export * from "./v2ratelimitmultilimitresponsebody.js";
|
|
113
|
+
export * from "./v2ratelimitmultilimitresponsedata.js";
|
|
106
114
|
export * from "./v2ratelimitsetoverriderequestbody.js";
|
|
107
115
|
export * from "./v2ratelimitsetoverrideresponsebody.js";
|
|
108
116
|
export * from "./v2ratelimitsetoverrideresponsedata.js";
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
KeyCreditsData,
|
|
11
|
+
KeyCreditsData$inboundSchema,
|
|
12
|
+
KeyCreditsData$Outbound,
|
|
13
|
+
KeyCreditsData$outboundSchema,
|
|
14
|
+
} from "./keycreditsdata.js";
|
|
15
|
+
import {
|
|
16
|
+
RatelimitRequest,
|
|
17
|
+
RatelimitRequest$inboundSchema,
|
|
18
|
+
RatelimitRequest$Outbound,
|
|
19
|
+
RatelimitRequest$outboundSchema,
|
|
20
|
+
} from "./ratelimitrequest.js";
|
|
21
|
+
|
|
22
|
+
export type V2KeysMigrateKeyData = {
|
|
23
|
+
/**
|
|
24
|
+
* The current hash of the key on your side
|
|
25
|
+
*/
|
|
26
|
+
hash: string;
|
|
27
|
+
/**
|
|
28
|
+
* Sets a human-readable identifier for internal organization and dashboard display.
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
* Never exposed to end users, only visible in management interfaces and API responses.
|
|
32
|
+
* Avoid generic names like "API Key" when managing multiple keys for the same user or service.
|
|
33
|
+
*/
|
|
34
|
+
name?: string | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Links this key to a user or entity in your system using your own identifier.
|
|
37
|
+
*
|
|
38
|
+
* @remarks
|
|
39
|
+
* Returned during verification to identify the key owner without additional database lookups.
|
|
40
|
+
* Essential for user-specific analytics, billing, and multi-tenant key management.
|
|
41
|
+
* Use your primary user ID, organization ID, or tenant ID for best results.
|
|
42
|
+
* Accepts letters, numbers, underscores, dots, and hyphens for flexible identifier formats.
|
|
43
|
+
*/
|
|
44
|
+
externalId?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Stores arbitrary JSON metadata returned during key verification for contextual information.
|
|
47
|
+
*
|
|
48
|
+
* @remarks
|
|
49
|
+
* Eliminates additional database lookups during verification, improving performance for stateless services.
|
|
50
|
+
* Avoid storing sensitive data here as it's returned in verification responses.
|
|
51
|
+
* Large metadata objects increase verification latency and should stay under 10KB total size.
|
|
52
|
+
*/
|
|
53
|
+
meta?: { [k: string]: any } | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Assigns existing roles to this key for permission management through role-based access control.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
* Roles must already exist in your workspace before assignment.
|
|
59
|
+
* During verification, all permissions from assigned roles are checked against requested permissions.
|
|
60
|
+
* Roles provide a convenient way to group permissions and apply consistent access patterns across multiple keys.
|
|
61
|
+
*/
|
|
62
|
+
roles?: Array<string> | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Grants specific permissions directly to this key without requiring role membership.
|
|
65
|
+
*
|
|
66
|
+
* @remarks
|
|
67
|
+
* Wildcard permissions like `documents.*` grant access to all sub-permissions including `documents.read` and `documents.write`.
|
|
68
|
+
* Direct permissions supplement any permissions inherited from assigned roles.
|
|
69
|
+
*/
|
|
70
|
+
permissions?: Array<string> | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Sets when this key automatically expires as a Unix timestamp in milliseconds.
|
|
73
|
+
*
|
|
74
|
+
* @remarks
|
|
75
|
+
* Verification fails with code=EXPIRED immediately after this time passes.
|
|
76
|
+
* Omitting this field creates a permanent key that never expires.
|
|
77
|
+
*
|
|
78
|
+
* Avoid setting timestamps in the past as they immediately invalidate the key.
|
|
79
|
+
* Keys expire based on server time, not client time, which prevents timezone-related issues.
|
|
80
|
+
* Essential for trial periods, temporary access, and security compliance requiring key rotation.
|
|
81
|
+
*/
|
|
82
|
+
expires?: number | undefined;
|
|
83
|
+
/**
|
|
84
|
+
* Controls whether the key is active immediately upon creation.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* When set to `false`, the key exists but all verification attempts fail with `code=DISABLED`.
|
|
88
|
+
* Useful for pre-creating keys that will be activated later or for keys requiring manual approval.
|
|
89
|
+
* Most keys should be created with `enabled=true` for immediate use.
|
|
90
|
+
*/
|
|
91
|
+
enabled?: boolean | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Credit configuration and remaining balance for this key.
|
|
94
|
+
*/
|
|
95
|
+
credits?: KeyCreditsData | undefined;
|
|
96
|
+
/**
|
|
97
|
+
* Defines time-based rate limits that protect against abuse by controlling request frequency.
|
|
98
|
+
*
|
|
99
|
+
* @remarks
|
|
100
|
+
* Unlike credits which track total usage, rate limits reset automatically after each window expires.
|
|
101
|
+
* Multiple rate limits can control different operation types with separate thresholds and windows.
|
|
102
|
+
* Essential for preventing API abuse while maintaining good performance for legitimate usage.
|
|
103
|
+
*/
|
|
104
|
+
ratelimits?: Array<RatelimitRequest> | undefined;
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/** @internal */
|
|
108
|
+
export const V2KeysMigrateKeyData$inboundSchema: z.ZodType<
|
|
109
|
+
V2KeysMigrateKeyData,
|
|
110
|
+
z.ZodTypeDef,
|
|
111
|
+
unknown
|
|
112
|
+
> = z.object({
|
|
113
|
+
hash: z.string(),
|
|
114
|
+
name: z.string().optional(),
|
|
115
|
+
externalId: z.string().optional(),
|
|
116
|
+
meta: z.record(z.any()).optional(),
|
|
117
|
+
roles: z.array(z.string()).optional(),
|
|
118
|
+
permissions: z.array(z.string()).optional(),
|
|
119
|
+
expires: z.number().int().optional(),
|
|
120
|
+
enabled: z.boolean().default(true),
|
|
121
|
+
credits: KeyCreditsData$inboundSchema.optional(),
|
|
122
|
+
ratelimits: z.array(RatelimitRequest$inboundSchema).optional(),
|
|
123
|
+
});
|
|
124
|
+
/** @internal */
|
|
125
|
+
export type V2KeysMigrateKeyData$Outbound = {
|
|
126
|
+
hash: string;
|
|
127
|
+
name?: string | undefined;
|
|
128
|
+
externalId?: string | undefined;
|
|
129
|
+
meta?: { [k: string]: any } | undefined;
|
|
130
|
+
roles?: Array<string> | undefined;
|
|
131
|
+
permissions?: Array<string> | undefined;
|
|
132
|
+
expires?: number | undefined;
|
|
133
|
+
enabled: boolean;
|
|
134
|
+
credits?: KeyCreditsData$Outbound | undefined;
|
|
135
|
+
ratelimits?: Array<RatelimitRequest$Outbound> | undefined;
|
|
136
|
+
};
|
|
137
|
+
|
|
138
|
+
/** @internal */
|
|
139
|
+
export const V2KeysMigrateKeyData$outboundSchema: z.ZodType<
|
|
140
|
+
V2KeysMigrateKeyData$Outbound,
|
|
141
|
+
z.ZodTypeDef,
|
|
142
|
+
V2KeysMigrateKeyData
|
|
143
|
+
> = z.object({
|
|
144
|
+
hash: z.string(),
|
|
145
|
+
name: z.string().optional(),
|
|
146
|
+
externalId: z.string().optional(),
|
|
147
|
+
meta: z.record(z.any()).optional(),
|
|
148
|
+
roles: z.array(z.string()).optional(),
|
|
149
|
+
permissions: z.array(z.string()).optional(),
|
|
150
|
+
expires: z.number().int().optional(),
|
|
151
|
+
enabled: z.boolean().default(true),
|
|
152
|
+
credits: KeyCreditsData$outboundSchema.optional(),
|
|
153
|
+
ratelimits: z.array(RatelimitRequest$outboundSchema).optional(),
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
export function v2KeysMigrateKeyDataToJSON(
|
|
157
|
+
v2KeysMigrateKeyData: V2KeysMigrateKeyData,
|
|
158
|
+
): string {
|
|
159
|
+
return JSON.stringify(
|
|
160
|
+
V2KeysMigrateKeyData$outboundSchema.parse(v2KeysMigrateKeyData),
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
export function v2KeysMigrateKeyDataFromJSON(
|
|
164
|
+
jsonString: string,
|
|
165
|
+
): SafeParseResult<V2KeysMigrateKeyData, SDKValidationError> {
|
|
166
|
+
return safeParse(
|
|
167
|
+
jsonString,
|
|
168
|
+
(x) => V2KeysMigrateKeyData$inboundSchema.parse(JSON.parse(x)),
|
|
169
|
+
`Failed to parse 'V2KeysMigrateKeyData' from JSON`,
|
|
170
|
+
);
|
|
171
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
|
|
10
|
+
export type V2KeysMigrateKeysMigration = {
|
|
11
|
+
/**
|
|
12
|
+
* The hash provided in the migration request
|
|
13
|
+
*/
|
|
14
|
+
hash: string;
|
|
15
|
+
/**
|
|
16
|
+
* The unique identifier for this key in Unkey's system. This is NOT the actual API key, but a reference ID used for management operations like updating or deleting the key. Store this ID in your database to reference the key later. This ID is not sensitive and can be logged or displayed in dashboards.
|
|
17
|
+
*/
|
|
18
|
+
keyId: string;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
/** @internal */
|
|
22
|
+
export const V2KeysMigrateKeysMigration$inboundSchema: z.ZodType<
|
|
23
|
+
V2KeysMigrateKeysMigration,
|
|
24
|
+
z.ZodTypeDef,
|
|
25
|
+
unknown
|
|
26
|
+
> = z.object({
|
|
27
|
+
hash: z.string(),
|
|
28
|
+
keyId: z.string(),
|
|
29
|
+
});
|
|
30
|
+
/** @internal */
|
|
31
|
+
export type V2KeysMigrateKeysMigration$Outbound = {
|
|
32
|
+
hash: string;
|
|
33
|
+
keyId: string;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
/** @internal */
|
|
37
|
+
export const V2KeysMigrateKeysMigration$outboundSchema: z.ZodType<
|
|
38
|
+
V2KeysMigrateKeysMigration$Outbound,
|
|
39
|
+
z.ZodTypeDef,
|
|
40
|
+
V2KeysMigrateKeysMigration
|
|
41
|
+
> = z.object({
|
|
42
|
+
hash: z.string(),
|
|
43
|
+
keyId: z.string(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export function v2KeysMigrateKeysMigrationToJSON(
|
|
47
|
+
v2KeysMigrateKeysMigration: V2KeysMigrateKeysMigration,
|
|
48
|
+
): string {
|
|
49
|
+
return JSON.stringify(
|
|
50
|
+
V2KeysMigrateKeysMigration$outboundSchema.parse(v2KeysMigrateKeysMigration),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export function v2KeysMigrateKeysMigrationFromJSON(
|
|
54
|
+
jsonString: string,
|
|
55
|
+
): SafeParseResult<V2KeysMigrateKeysMigration, SDKValidationError> {
|
|
56
|
+
return safeParse(
|
|
57
|
+
jsonString,
|
|
58
|
+
(x) => V2KeysMigrateKeysMigration$inboundSchema.parse(JSON.parse(x)),
|
|
59
|
+
`Failed to parse 'V2KeysMigrateKeysMigration' from JSON`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
V2KeysMigrateKeyData,
|
|
11
|
+
V2KeysMigrateKeyData$inboundSchema,
|
|
12
|
+
V2KeysMigrateKeyData$Outbound,
|
|
13
|
+
V2KeysMigrateKeyData$outboundSchema,
|
|
14
|
+
} from "./v2keysmigratekeydata.js";
|
|
15
|
+
|
|
16
|
+
export type V2KeysMigrateKeysRequestBody = {
|
|
17
|
+
/**
|
|
18
|
+
* Identifier of the configured migration provider/strategy to use (e.g., "your_company").
|
|
19
|
+
*/
|
|
20
|
+
migrationId: string;
|
|
21
|
+
/**
|
|
22
|
+
* The ID of the API that the keys should be inserted into
|
|
23
|
+
*/
|
|
24
|
+
apiId: string;
|
|
25
|
+
keys: Array<V2KeysMigrateKeyData>;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** @internal */
|
|
29
|
+
export const V2KeysMigrateKeysRequestBody$inboundSchema: z.ZodType<
|
|
30
|
+
V2KeysMigrateKeysRequestBody,
|
|
31
|
+
z.ZodTypeDef,
|
|
32
|
+
unknown
|
|
33
|
+
> = z.object({
|
|
34
|
+
migrationId: z.string(),
|
|
35
|
+
apiId: z.string(),
|
|
36
|
+
keys: z.array(V2KeysMigrateKeyData$inboundSchema),
|
|
37
|
+
});
|
|
38
|
+
/** @internal */
|
|
39
|
+
export type V2KeysMigrateKeysRequestBody$Outbound = {
|
|
40
|
+
migrationId: string;
|
|
41
|
+
apiId: string;
|
|
42
|
+
keys: Array<V2KeysMigrateKeyData$Outbound>;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** @internal */
|
|
46
|
+
export const V2KeysMigrateKeysRequestBody$outboundSchema: z.ZodType<
|
|
47
|
+
V2KeysMigrateKeysRequestBody$Outbound,
|
|
48
|
+
z.ZodTypeDef,
|
|
49
|
+
V2KeysMigrateKeysRequestBody
|
|
50
|
+
> = z.object({
|
|
51
|
+
migrationId: z.string(),
|
|
52
|
+
apiId: z.string(),
|
|
53
|
+
keys: z.array(V2KeysMigrateKeyData$outboundSchema),
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
export function v2KeysMigrateKeysRequestBodyToJSON(
|
|
57
|
+
v2KeysMigrateKeysRequestBody: V2KeysMigrateKeysRequestBody,
|
|
58
|
+
): string {
|
|
59
|
+
return JSON.stringify(
|
|
60
|
+
V2KeysMigrateKeysRequestBody$outboundSchema.parse(
|
|
61
|
+
v2KeysMigrateKeysRequestBody,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
export function v2KeysMigrateKeysRequestBodyFromJSON(
|
|
66
|
+
jsonString: string,
|
|
67
|
+
): SafeParseResult<V2KeysMigrateKeysRequestBody, SDKValidationError> {
|
|
68
|
+
return safeParse(
|
|
69
|
+
jsonString,
|
|
70
|
+
(x) => V2KeysMigrateKeysRequestBody$inboundSchema.parse(JSON.parse(x)),
|
|
71
|
+
`Failed to parse 'V2KeysMigrateKeysRequestBody' from JSON`,
|
|
72
|
+
);
|
|
73
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
Meta,
|
|
11
|
+
Meta$inboundSchema,
|
|
12
|
+
Meta$Outbound,
|
|
13
|
+
Meta$outboundSchema,
|
|
14
|
+
} from "./meta.js";
|
|
15
|
+
import {
|
|
16
|
+
V2KeysMigrateKeysResponseData,
|
|
17
|
+
V2KeysMigrateKeysResponseData$inboundSchema,
|
|
18
|
+
V2KeysMigrateKeysResponseData$Outbound,
|
|
19
|
+
V2KeysMigrateKeysResponseData$outboundSchema,
|
|
20
|
+
} from "./v2keysmigratekeysresponsedata.js";
|
|
21
|
+
|
|
22
|
+
export type V2KeysMigrateKeysResponseBody = {
|
|
23
|
+
/**
|
|
24
|
+
* Metadata object included in every API response. This provides context about the request and is essential for debugging, audit trails, and support inquiries. The `requestId` is particularly important when troubleshooting issues with the Unkey support team.
|
|
25
|
+
*/
|
|
26
|
+
meta: Meta;
|
|
27
|
+
data: V2KeysMigrateKeysResponseData;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
/** @internal */
|
|
31
|
+
export const V2KeysMigrateKeysResponseBody$inboundSchema: z.ZodType<
|
|
32
|
+
V2KeysMigrateKeysResponseBody,
|
|
33
|
+
z.ZodTypeDef,
|
|
34
|
+
unknown
|
|
35
|
+
> = z.object({
|
|
36
|
+
meta: Meta$inboundSchema,
|
|
37
|
+
data: V2KeysMigrateKeysResponseData$inboundSchema,
|
|
38
|
+
});
|
|
39
|
+
/** @internal */
|
|
40
|
+
export type V2KeysMigrateKeysResponseBody$Outbound = {
|
|
41
|
+
meta: Meta$Outbound;
|
|
42
|
+
data: V2KeysMigrateKeysResponseData$Outbound;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/** @internal */
|
|
46
|
+
export const V2KeysMigrateKeysResponseBody$outboundSchema: z.ZodType<
|
|
47
|
+
V2KeysMigrateKeysResponseBody$Outbound,
|
|
48
|
+
z.ZodTypeDef,
|
|
49
|
+
V2KeysMigrateKeysResponseBody
|
|
50
|
+
> = z.object({
|
|
51
|
+
meta: Meta$outboundSchema,
|
|
52
|
+
data: V2KeysMigrateKeysResponseData$outboundSchema,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
export function v2KeysMigrateKeysResponseBodyToJSON(
|
|
56
|
+
v2KeysMigrateKeysResponseBody: V2KeysMigrateKeysResponseBody,
|
|
57
|
+
): string {
|
|
58
|
+
return JSON.stringify(
|
|
59
|
+
V2KeysMigrateKeysResponseBody$outboundSchema.parse(
|
|
60
|
+
v2KeysMigrateKeysResponseBody,
|
|
61
|
+
),
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
export function v2KeysMigrateKeysResponseBodyFromJSON(
|
|
65
|
+
jsonString: string,
|
|
66
|
+
): SafeParseResult<V2KeysMigrateKeysResponseBody, SDKValidationError> {
|
|
67
|
+
return safeParse(
|
|
68
|
+
jsonString,
|
|
69
|
+
(x) => V2KeysMigrateKeysResponseBody$inboundSchema.parse(JSON.parse(x)),
|
|
70
|
+
`Failed to parse 'V2KeysMigrateKeysResponseBody' from JSON`,
|
|
71
|
+
);
|
|
72
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
import {
|
|
10
|
+
V2KeysMigrateKeysMigration,
|
|
11
|
+
V2KeysMigrateKeysMigration$inboundSchema,
|
|
12
|
+
V2KeysMigrateKeysMigration$Outbound,
|
|
13
|
+
V2KeysMigrateKeysMigration$outboundSchema,
|
|
14
|
+
} from "./v2keysmigratekeysmigration.js";
|
|
15
|
+
|
|
16
|
+
export type V2KeysMigrateKeysResponseData = {
|
|
17
|
+
/**
|
|
18
|
+
* Successfully migrated keys with their hash and generated keyId
|
|
19
|
+
*/
|
|
20
|
+
migrated: Array<V2KeysMigrateKeysMigration>;
|
|
21
|
+
/**
|
|
22
|
+
* Hashes that could not be migrated (e.g., already exist in the system)
|
|
23
|
+
*/
|
|
24
|
+
failed: Array<string>;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
/** @internal */
|
|
28
|
+
export const V2KeysMigrateKeysResponseData$inboundSchema: z.ZodType<
|
|
29
|
+
V2KeysMigrateKeysResponseData,
|
|
30
|
+
z.ZodTypeDef,
|
|
31
|
+
unknown
|
|
32
|
+
> = z.object({
|
|
33
|
+
migrated: z.array(V2KeysMigrateKeysMigration$inboundSchema),
|
|
34
|
+
failed: z.array(z.string()),
|
|
35
|
+
});
|
|
36
|
+
/** @internal */
|
|
37
|
+
export type V2KeysMigrateKeysResponseData$Outbound = {
|
|
38
|
+
migrated: Array<V2KeysMigrateKeysMigration$Outbound>;
|
|
39
|
+
failed: Array<string>;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/** @internal */
|
|
43
|
+
export const V2KeysMigrateKeysResponseData$outboundSchema: z.ZodType<
|
|
44
|
+
V2KeysMigrateKeysResponseData$Outbound,
|
|
45
|
+
z.ZodTypeDef,
|
|
46
|
+
V2KeysMigrateKeysResponseData
|
|
47
|
+
> = z.object({
|
|
48
|
+
migrated: z.array(V2KeysMigrateKeysMigration$outboundSchema),
|
|
49
|
+
failed: z.array(z.string()),
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export function v2KeysMigrateKeysResponseDataToJSON(
|
|
53
|
+
v2KeysMigrateKeysResponseData: V2KeysMigrateKeysResponseData,
|
|
54
|
+
): string {
|
|
55
|
+
return JSON.stringify(
|
|
56
|
+
V2KeysMigrateKeysResponseData$outboundSchema.parse(
|
|
57
|
+
v2KeysMigrateKeysResponseData,
|
|
58
|
+
),
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
export function v2KeysMigrateKeysResponseDataFromJSON(
|
|
62
|
+
jsonString: string,
|
|
63
|
+
): SafeParseResult<V2KeysMigrateKeysResponseData, SDKValidationError> {
|
|
64
|
+
return safeParse(
|
|
65
|
+
jsonString,
|
|
66
|
+
(x) => V2KeysMigrateKeysResponseData$inboundSchema.parse(JSON.parse(x)),
|
|
67
|
+
`Failed to parse 'V2KeysMigrateKeysResponseData' from JSON`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
@@ -65,6 +65,10 @@ export type V2KeysVerifyKeyRequestBody = {
|
|
|
65
65
|
* Rate limit checks are optimized for performance but may allow brief bursts during high concurrency.
|
|
66
66
|
*/
|
|
67
67
|
ratelimits?: Array<KeysVerifyKeyRatelimit> | undefined;
|
|
68
|
+
/**
|
|
69
|
+
* Migrate keys on demand from your previous system. Reach out for migration support at support@unkey.dev
|
|
70
|
+
*/
|
|
71
|
+
migrationId?: string | undefined;
|
|
68
72
|
};
|
|
69
73
|
|
|
70
74
|
/** @internal */
|
|
@@ -78,6 +82,7 @@ export const V2KeysVerifyKeyRequestBody$inboundSchema: z.ZodType<
|
|
|
78
82
|
permissions: z.string().optional(),
|
|
79
83
|
credits: KeysVerifyKeyCredits$inboundSchema.optional(),
|
|
80
84
|
ratelimits: z.array(KeysVerifyKeyRatelimit$inboundSchema).optional(),
|
|
85
|
+
migrationId: z.string().optional(),
|
|
81
86
|
});
|
|
82
87
|
/** @internal */
|
|
83
88
|
export type V2KeysVerifyKeyRequestBody$Outbound = {
|
|
@@ -86,6 +91,7 @@ export type V2KeysVerifyKeyRequestBody$Outbound = {
|
|
|
86
91
|
permissions?: string | undefined;
|
|
87
92
|
credits?: KeysVerifyKeyCredits$Outbound | undefined;
|
|
88
93
|
ratelimits?: Array<KeysVerifyKeyRatelimit$Outbound> | undefined;
|
|
94
|
+
migrationId?: string | undefined;
|
|
89
95
|
};
|
|
90
96
|
|
|
91
97
|
/** @internal */
|
|
@@ -99,6 +105,7 @@ export const V2KeysVerifyKeyRequestBody$outboundSchema: z.ZodType<
|
|
|
99
105
|
permissions: z.string().optional(),
|
|
100
106
|
credits: KeysVerifyKeyCredits$outboundSchema.optional(),
|
|
101
107
|
ratelimits: z.array(KeysVerifyKeyRatelimit$outboundSchema).optional(),
|
|
108
|
+
migrationId: z.string().optional(),
|
|
102
109
|
});
|
|
103
110
|
|
|
104
111
|
export function v2KeysVerifyKeyRequestBodyToJSON(
|
|
@@ -103,15 +103,15 @@ export type V2KeysVerifyKeyResponseData = {
|
|
|
103
103
|
* Unix timestamp (in milliseconds) when the key will expire.
|
|
104
104
|
*
|
|
105
105
|
* @remarks
|
|
106
|
-
* If
|
|
106
|
+
* If omitted, the key has no expiration. You can use this to
|
|
107
107
|
* warn users about upcoming expirations or to understand the validity period.
|
|
108
108
|
*/
|
|
109
109
|
expires?: number | undefined;
|
|
110
110
|
/**
|
|
111
|
-
* The number of requests/credits remaining for this key. If
|
|
111
|
+
* The number of requests/credits remaining for this key. If omitted,
|
|
112
112
|
*
|
|
113
113
|
* @remarks
|
|
114
|
-
*
|
|
114
|
+
* the key has unlimited usage. This value decreases with
|
|
115
115
|
* each verification (based on the 'cost' parameter) unless explicit credit
|
|
116
116
|
* refills are configured.
|
|
117
117
|
*/
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
9
|
+
|
|
10
|
+
export type V2RatelimitMultiLimitCheck = {
|
|
11
|
+
/**
|
|
12
|
+
* The namespace this rate limit result corresponds to. Use this field to correlate the response with the request when checking multiple rate limits.
|
|
13
|
+
*/
|
|
14
|
+
namespace: string;
|
|
15
|
+
/**
|
|
16
|
+
* The identifier this rate limit result corresponds to. Use this field to correlate the response with the request when checking multiple rate limits.
|
|
17
|
+
*/
|
|
18
|
+
identifier: string;
|
|
19
|
+
/**
|
|
20
|
+
* The maximum number of operations allowed within the time window. This reflects either the default limit specified in the request or an override limit if one exists for this identifier.
|
|
21
|
+
*
|
|
22
|
+
* @remarks
|
|
23
|
+
*
|
|
24
|
+
* This value helps clients understand their total quota for the current window.
|
|
25
|
+
*/
|
|
26
|
+
limit: number;
|
|
27
|
+
/**
|
|
28
|
+
* The number of operations remaining in the current window before the rate limit is exceeded. Applications should use this value to:
|
|
29
|
+
*
|
|
30
|
+
* @remarks
|
|
31
|
+
*
|
|
32
|
+
* - Implement client-side throttling before hitting limits
|
|
33
|
+
* - Display usage information to end users
|
|
34
|
+
* - Trigger alerts when approaching limits
|
|
35
|
+
* - Adjust request patterns based on available capacity
|
|
36
|
+
*
|
|
37
|
+
* When this reaches zero, requests will be rejected until the window resets.
|
|
38
|
+
*/
|
|
39
|
+
remaining: number;
|
|
40
|
+
/**
|
|
41
|
+
* The Unix timestamp in milliseconds when the rate limit window will reset and 'remaining' will return to 'limit'.
|
|
42
|
+
*
|
|
43
|
+
* @remarks
|
|
44
|
+
*
|
|
45
|
+
* This timestamp enables clients to:
|
|
46
|
+
* - Calculate and display wait times to users
|
|
47
|
+
* - Implement intelligent retry mechanisms
|
|
48
|
+
* - Schedule requests to resume after the reset
|
|
49
|
+
* - Implement exponential backoff when needed
|
|
50
|
+
*
|
|
51
|
+
* The reset time is based on a sliding window from the first request in the current window.
|
|
52
|
+
*/
|
|
53
|
+
reset: number;
|
|
54
|
+
/**
|
|
55
|
+
* Whether the request passed the rate limit check. If true, the request is allowed to proceed. If false, the request has exceeded the rate limit and should be blocked or rejected.
|
|
56
|
+
*
|
|
57
|
+
* @remarks
|
|
58
|
+
*
|
|
59
|
+
* You MUST check this field to determine if the request should proceed, as the endpoint always returns `HTTP 200` even when rate limited.
|
|
60
|
+
*/
|
|
61
|
+
passed: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* If a rate limit override was applied for this identifier, this field contains the ID of the override that was used. Empty when no override is in effect.
|
|
64
|
+
*
|
|
65
|
+
* @remarks
|
|
66
|
+
*
|
|
67
|
+
* This can be useful for:
|
|
68
|
+
* - Debugging which override rule was matched
|
|
69
|
+
* - Tracking the effects of specific overrides
|
|
70
|
+
* - Understanding why limits differ from default values
|
|
71
|
+
*/
|
|
72
|
+
overrideId?: string | undefined;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** @internal */
|
|
76
|
+
export const V2RatelimitMultiLimitCheck$inboundSchema: z.ZodType<
|
|
77
|
+
V2RatelimitMultiLimitCheck,
|
|
78
|
+
z.ZodTypeDef,
|
|
79
|
+
unknown
|
|
80
|
+
> = z.object({
|
|
81
|
+
namespace: z.string(),
|
|
82
|
+
identifier: z.string(),
|
|
83
|
+
limit: z.number().int(),
|
|
84
|
+
remaining: z.number().int(),
|
|
85
|
+
reset: z.number().int(),
|
|
86
|
+
passed: z.boolean(),
|
|
87
|
+
overrideId: z.string().optional(),
|
|
88
|
+
});
|
|
89
|
+
/** @internal */
|
|
90
|
+
export type V2RatelimitMultiLimitCheck$Outbound = {
|
|
91
|
+
namespace: string;
|
|
92
|
+
identifier: string;
|
|
93
|
+
limit: number;
|
|
94
|
+
remaining: number;
|
|
95
|
+
reset: number;
|
|
96
|
+
passed: boolean;
|
|
97
|
+
overrideId?: string | undefined;
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
/** @internal */
|
|
101
|
+
export const V2RatelimitMultiLimitCheck$outboundSchema: z.ZodType<
|
|
102
|
+
V2RatelimitMultiLimitCheck$Outbound,
|
|
103
|
+
z.ZodTypeDef,
|
|
104
|
+
V2RatelimitMultiLimitCheck
|
|
105
|
+
> = z.object({
|
|
106
|
+
namespace: z.string(),
|
|
107
|
+
identifier: z.string(),
|
|
108
|
+
limit: z.number().int(),
|
|
109
|
+
remaining: z.number().int(),
|
|
110
|
+
reset: z.number().int(),
|
|
111
|
+
passed: z.boolean(),
|
|
112
|
+
overrideId: z.string().optional(),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
export function v2RatelimitMultiLimitCheckToJSON(
|
|
116
|
+
v2RatelimitMultiLimitCheck: V2RatelimitMultiLimitCheck,
|
|
117
|
+
): string {
|
|
118
|
+
return JSON.stringify(
|
|
119
|
+
V2RatelimitMultiLimitCheck$outboundSchema.parse(v2RatelimitMultiLimitCheck),
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
export function v2RatelimitMultiLimitCheckFromJSON(
|
|
123
|
+
jsonString: string,
|
|
124
|
+
): SafeParseResult<V2RatelimitMultiLimitCheck, SDKValidationError> {
|
|
125
|
+
return safeParse(
|
|
126
|
+
jsonString,
|
|
127
|
+
(x) => V2RatelimitMultiLimitCheck$inboundSchema.parse(JSON.parse(x)),
|
|
128
|
+
`Failed to parse 'V2RatelimitMultiLimitCheck' from JSON`,
|
|
129
|
+
);
|
|
130
|
+
}
|