@zuplo/runtime 5.2181.0 → 5.2182.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.
@@ -22,5 +22,5 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{b as e,c as t,e as a,f as o,g as r,h as i,i as n}from"../chunk-QSL25HFO.js";import"../chunk-HPMPWPKQ.js";import"../chunk-4DUPDUSC.js";export{o as getIdForParameterSchema,i as getIdForRefSchema,r as getIdForRequestBodySchema,a as getRawOperationDataIdentifierName,e as isRestrictedEnvVariableName,t as isZuploReadableEnvVariableName,n as sanitizedIdentifierName};
25
+ import{b as e,c as t,e as a,f as o,g as r,h as i,i as n}from"../chunk-CRZT3N5H.js";import"../chunk-4NFZOV2A.js";import"../chunk-4DUPDUSC.js";export{o as getIdForParameterSchema,i as getIdForRefSchema,r as getIdForRequestBodySchema,a as getRawOperationDataIdentifierName,e as isRestrictedEnvVariableName,t as isZuploReadableEnvVariableName,n as sanitizedIdentifierName};
26
26
  /*! For license information please see index.js.LEGAL.txt */
@@ -22,5 +22,5 @@
22
22
  * DEALINGS IN THE SOFTWARE.
23
23
  *--------------------------------------------------------------------------------------------*/
24
24
 
25
- import{g as o}from"../../chunk-CI735RIK.js";import"../../chunk-HPMPWPKQ.js";import"../../chunk-4DUPDUSC.js";export{o as PdpService};
25
+ import{g as o}from"../../chunk-M2WV76HS.js";import"../../chunk-4NFZOV2A.js";import"../../chunk-4DUPDUSC.js";export{o as PdpService};
26
26
  /*! For license information please see exports.js.LEGAL.txt */
@@ -904,6 +904,88 @@ declare interface CompatibilityFlags {
904
904
  removeAllVendorHeadersExceptListed: boolean;
905
905
  }
906
906
 
907
+ export declare type ComplexRateLimitFunction = (request: ZuploRequest, context: ZuploContext, policyName: string) => CustomComplexRateLimitDetails | Promise<CustomComplexRateLimitDetails>;
908
+
909
+ /**
910
+ * The Complex Rate Limiting policy is an advanced rate limiting policy that
911
+ * let's you set rate limits based on custom counters (not just requests)
912
+ *
913
+ * @remarks
914
+ * You can use the Complex Rate Limiting policy to limit the number of requests
915
+ * based on complex counters, based on details of the request or the response
916
+ *
917
+ * @title Monetization
918
+ * @beta
919
+ * @param request - The ZuploRequest
920
+ * @param context - The ZuploContext
921
+ * @param options - The policy options set in policies.json
922
+ * @param policyName - The name of the policy as set in policies.json
923
+ * @returns A Request or a Response
924
+ */
925
+ export declare class ComplexRateLimitInboundPolicy extends InboundPolicy<ComplexRateLimitInboundPolicyOptions> {
926
+ #private;
927
+ /**
928
+ * Override the costs for limits in the current request.
929
+ *
930
+ * @remarks
931
+ * If your policy is has a limit set as follows:
932
+ *
933
+ * ```
934
+ * "limits": {
935
+ * "compute": 10
936
+ * }
937
+ * ```
938
+ *
939
+ * You can use this function to override the cost of the `compute` limit
940
+ * by calling `setLimits(context, { compute: 5 })` on a custom policy.
941
+ * This can be useful if you want to dynamically change the cost of a limit
942
+ * based on data in the response (say a header).
943
+ *
944
+ * @param context - The ZuploContext
945
+ * @param limits - The limits to set.
946
+ */
947
+ static setLimits(context: ZuploContext, limits: Record<string, number>): void;
948
+ private ttlSeconds;
949
+ constructor(options: ComplexRateLimitInboundPolicyOptions, policyName: string);
950
+ handler(request: ZuploRequest, context: ZuploContext): Promise<ZuploRequest<RequestGeneric> | Response>;
951
+ }
952
+
953
+ /**
954
+ * The options for this policy.
955
+ */
956
+ export declare interface ComplexRateLimitInboundPolicyOptions {
957
+ rateLimitBy: RateLimitByType;
958
+ /**
959
+ * A dictionary (string: number) of limits to be enforced across custom counters for this policy.
960
+ */
961
+ limits: {
962
+ [k: string]: number;
963
+ };
964
+ /**
965
+ * The time window in which the requests are rate-limited. The count restarts after each window expires.
966
+ */
967
+ timeWindowMinutes: number;
968
+ /**
969
+ * The function that returns dynamic configuration data. Used only with `rateLimitBy=function`.
970
+ */
971
+ identifier?: {
972
+ /**
973
+ * used only with rateLimitBy=function. Specifies the export to load your custom bucket function, e.g. `default`, `rateLimitIdentifier`.
974
+ */
975
+ export: string;
976
+ /**
977
+ * Specifies the module to load your custom bucket function, in the format `$import(./modules/my-module)`.
978
+ */
979
+ module: string;
980
+ };
981
+ headerMode?: RateLimitHeaderMode;
982
+ /**
983
+ * If true, the policy will throw an error in the event there is a problem connecting to the rate limit service.
984
+ */
985
+ throwOnFailure?: boolean;
986
+ mode?: RateLimitMode;
987
+ }
988
+
907
989
  /**
908
990
  * Creates a composite, or group policy - composed of other policies. For reuse across routes.
909
991
  *
@@ -985,11 +1067,11 @@ export declare class ConfigurationError extends RuntimeError {
985
1067
  */
986
1068
  export declare class ContextData<T = any> {
987
1069
  #private;
988
- constructor(name: string);
1070
+ constructor(name: string | symbol);
989
1071
  set(context: ZuploContext, data: T): void;
990
1072
  get(context: ZuploContext): T | undefined;
991
- static set<T = any>(context: ZuploContext, name: string, data: T): void;
992
- static get<T = any>(context: ZuploContext, name: string): T | undefined;
1073
+ static set<T = any>(context: ZuploContext, name: string | symbol, data: T): void;
1074
+ static get<T = any>(context: ZuploContext, name: string | symbol): T | undefined;
993
1075
  }
994
1076
 
995
1077
  /** The 2-letter continent codes Cloudflare uses */
@@ -1130,6 +1212,12 @@ export declare interface CurityPhantomTokenInboundPolicyOptions {
1130
1212
  cacheDurationSeconds?: number;
1131
1213
  }
1132
1214
 
1215
+ export declare interface CustomComplexRateLimitDetails {
1216
+ key: string;
1217
+ limits?: Record<string, number>;
1218
+ timeWindowMinutes?: number;
1219
+ }
1220
+
1133
1221
  /**
1134
1222
  * @beta
1135
1223
  */
@@ -3790,11 +3878,21 @@ export declare interface PropelAuthJwtInboundPolicyOptions {
3790
3878
  */
3791
3879
  declare type RateLimitByType = "user" | "ip" | "function" | "all";
3792
3880
 
3881
+ /**
3882
+ * The identifying element of the request that enforces distinct rate limits. For example, you can limit by `user`, `ip`, `function` or `all` - function allows you to specify a simple function to create a string identifier to create a rate-limit group.
3883
+ */
3884
+ declare type RateLimitByType_2 = "user" | "ip" | "function" | "all";
3885
+
3793
3886
  /**
3794
3887
  * Adds the retry-after header.
3795
3888
  */
3796
3889
  declare type RateLimitHeaderMode = "none" | "retry-after";
3797
3890
 
3891
+ /**
3892
+ * Adds the retry-after header.
3893
+ */
3894
+ declare type RateLimitHeaderMode_2 = "none" | "retry-after";
3895
+
3798
3896
  /**
3799
3897
  * The rate-limiting policy is used to limit the number of requests that can be made against your API based on a key.
3800
3898
  *
@@ -3828,7 +3926,7 @@ export { RateLimitInboundPolicy }
3828
3926
  * The options for this policy.
3829
3927
  */
3830
3928
  declare interface RateLimitInboundPolicyOptions {
3831
- rateLimitBy: RateLimitByType;
3929
+ rateLimitBy: RateLimitByType_2;
3832
3930
  /**
3833
3931
  * The max number of requests allowed in the given time window.
3834
3932
  */
@@ -3850,12 +3948,12 @@ declare interface RateLimitInboundPolicyOptions {
3850
3948
  */
3851
3949
  module: string;
3852
3950
  };
3853
- headerMode?: RateLimitHeaderMode;
3951
+ headerMode?: RateLimitHeaderMode_2;
3854
3952
  /**
3855
3953
  * If true, the policy will throw an error in the event there is a problem connecting to the rate limit service.
3856
3954
  */
3857
3955
  throwOnFailure?: boolean;
3858
- mode?: RateLimitMode;
3956
+ mode?: RateLimitMode_2;
3859
3957
  }
3860
3958
  export { RateLimitInboundPolicyOptions as BasicRateLimitInboundPolicyOptions }
3861
3959
  export { RateLimitInboundPolicyOptions }
@@ -3865,6 +3963,11 @@ export { RateLimitInboundPolicyOptions }
3865
3963
  */
3866
3964
  declare type RateLimitMode = "strict" | "async";
3867
3965
 
3966
+ /**
3967
+ * The mode of the policy. If set to `async`, the policy will check if the request is over the rate limit without blocking. This can result in some requests allowed over the rate limit.
3968
+ */
3969
+ declare type RateLimitMode_2 = "strict" | "async";
3970
+
3868
3971
  /**
3869
3972
  * The options for this policy. Many of them can be overridden at the code level in a request using the `AmberfloMeteringPolicy.setRequestProperties` method.
3870
3973
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
- "version": "5.2181.0",
3
+ "version": "5.2182.0",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "exports": {