@zuplo/runtime 5.2097.0 → 5.2099.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/index.min.cjs +25 -25
- package/index.min.js +24 -24
- package/internal.min.cjs +1 -1
- package/package.json +1 -1
- package/types-beta.d.ts +144 -5
- package/types-public.d.ts +144 -5
package/internal.min.cjs
CHANGED
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
* DEALINGS IN THE SOFTWARE.
|
|
23
23
|
*--------------------------------------------------------------------------------------------*/
|
|
24
24
|
|
|
25
|
-
"use strict";var u=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var r=(e,t)=>u(e,"name",{value:t,configurable:!0});var h=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},R=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of E(t))!P.call(e,s)&&s!==n&&u(e,s,{get:()=>t[s],enumerable:!(i=L(t,s))||i.enumerable});return e};var I=e=>R(u({},"__esModule",{value:!0}),e);var T={};h(T,{getIdForParameterSchema:()=>p,getIdForRefSchema:()=>
|
|
25
|
+
"use strict";var u=Object.defineProperty;var L=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var r=(e,t)=>u(e,"name",{value:t,configurable:!0});var h=(e,t)=>{for(var n in t)u(e,n,{get:t[n],enumerable:!0})},R=(e,t,n,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of E(t))!P.call(e,s)&&s!==n&&u(e,s,{get:()=>t[s],enumerable:!(i=L(t,s))||i.enumerable});return e};var I=e=>R(u({},"__esModule",{value:!0}),e);var T={};h(T,{getIdForParameterSchema:()=>p,getIdForRefSchema:()=>f,getIdForRequestBodySchema:()=>O,getRawOperationDataIdentifierName:()=>m,isRestrictedEnvVariableName:()=>l,isZuploReadableEnvVariableName:()=>g,sanitizedIdentifierName:()=>a});module.exports=I(T);var _="2024-03-14",d=Object.freeze({none:{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1},"2023-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!1,doNotRunHooksOnSystemRoutes:!1,removeAllVendorHeadersExceptListed:!1},"2024-01-15":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0},"2024-03-14":{runOutboundPoliciesOnHandlerOnAllStatuses:!0,doNotRunHooksOnSystemRoutes:!0,removeAllVendorHeadersExceptListed:!0}});function c(){return new o({build:{ACCOUNT_NAME:"mock-account-name",PROJECT_NAME:"mock-project-name",API_VERSION:"0.0.0",BUILD_ID:crypto.randomUUID(),TIMESTAMP:new Date().toISOString(),IS_PRODUCTION:!1,BUILD_ENV:"test",ZUPLO_VERSION:"0.0.0",COMPATIBILITY_DATE:_,ENVIRONMENT_TYPE:"mock-environment-type",GIT_SHA:void 0,COMPATIBILITY_FLAGS:d[_]},runtime:{RUNTIME_ENV:"test",RUNTIME_STAGE:"test",__ZUPLO_DEPLOYMENT_NAME:"mock-deployment-name",__ZUPLO_LOG_LEVEL:"debug",__ZUPLO_LOG_FORMAT:"pretty",__ZUPLO_MANAGEMENT_API_URL:"",__ZUPLO_RUNTIME_TYPE:"cloudflare",__ZUPLO_AUTH_API_JWT:""}})}r(c,"getMockEnvironment");var o=class e{static{r(this,"Environment")}config;static#e;static#t=!1;static initialize(t){this.#e||(this.#e=new e(t),this.#t=!0)}static get instance(){return this.#t||(console.debug("Environment has not been initialized. This is okay when running tests, a mock environment will be used."),this.#e=c()),this.#e}constructor({build:t,runtime:n}){let i;try{if(n.__ZUPLO_CONFIG){let s=atob(n.__ZUPLO_CONFIG);i=JSON.parse(s)}}catch{console.warn("Failed to parse runtime configuration")}this.config=i??{},this.build=t,this.runtime=n,this.instanceId=crypto.randomUUID()}build;runtime;instanceId;get deploymentName(){return this.runtime.__ZUPLO_DEPLOYMENT_NAME??this.config.deployment_name??void 0}get useSha256ServiceRouting(){return this.config.use_sha256_service_routing??void 0}get useProxyForFetchFromZups(){return this.config.use_proxy_for_fetch_from_zups??void 0}get devPortalBaseUrl(){return this.runtime.__ZUPLO_DEV_PORTAL_URL??this.config.dev_portal_url??"https://dev-portal-v4-1.zuplo.com"}get buildAssetsUrl(){return this.runtime.__ZUPLO_BUILD_ASSETS_URL??this.config.build_assets_url??"https://build-assets.zuplo.com"}get remoteLogToken(){return this.runtime.__ZUPLO_REMOTE_LOG_TOKEN??this.config.remote_log_token??void 0}get managementApiURL(){return this.runtime.__ZUPLO_MANAGEMENT_API_URL??this.config.management_api_url??"https://api.zuplo.com"}get cdnURL(){return this.runtime.__ZUPLO_CDN_URL??this.config.cdn_url??"https://cdn.zuplo.com"}get remoteLogURL(){return this.runtime.__ZUPLO_REMOTE_LOG_URL??this.config.log_event_api??"https://ellie.zuplo.com"}get loggingId(){return this.runtime.__ZUPLO_LOGGING_ID??this.config.logging_id??void 0}get redisURL(){return this.runtime.__ZUPLO_REDIS_URL??this.config.redis_proxy_url??"https://redis-proxy.zuplo.com"}get apiKeyServiceUrl(){return this.runtime.__ZUPLO_API_KEY_SERVICE_URL??this.config.api_key_service_url??"https://apikey.zuplo.com"}get meteringServiceUrl(){return this.config.metering_service_url??"https://meters.zuplo.com"}get authApiJWT(){return this.runtime.__ZUPLO_AUTH_API_JWT??void 0}get userLogLevel(){return this.runtime.ZUPLO_LOG_LEVEL??this.runtime.__ZUPLO_LOG_LEVEL??this.config.user_log_level??"debug"}get systemLogLevel(){return this.runtime.__ZUPLO_LOG_LEVEL??this.config.system_log_level??"debug"}get logFormat(){return this.runtime.__ZUPLO_LOG_FORMAT??this.config.log_format??"cloudflare"}get isCloudflare(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="cloudflare":this.config.runtime_type?this.config.runtime_type==="cloudflare":typeof WebSocketPair=="function"}get isDeno(){return this.runtime.__ZUPLO_RUNTIME_TYPE?this.runtime.__ZUPLO_RUNTIME_TYPE==="deno":this.config.runtime_type?this.config.runtime_type==="deno":typeof WebSocketPair!="function"}get isLocalDevelopment(){return this.build.ENVIRONMENT_TYPE?this.build.ENVIRONMENT_TYPE==="LOCAL_DEVELOPMENT":!1}get systemUserAgent(){return`Zuplo/${this.build.ZUPLO_VERSION}`}get loggingEnvironmentType(){return this.isCloudflare?"edge":this.isLocalDevelopment?"local":this.isDeno?"working-copy":"unknown"}get loggingEnvironmentStage(){return this.build.ENVIRONMENT_TYPE==="PRODUCTION"?"production":this.build.ENVIRONMENT_TYPE==="PREVIEW"?"preview":this.isLocalDevelopment?"local":this.isWorkingCopy?"working-copy":"unknown"}get isWorkingCopy(){return this.build.ENVIRONMENT_TYPE==="WORKING_COPY"}};var U=["ZUPLO_USER_LOGGER_DATA_DOG_API_KEY","ZUPLO_USER_LOGGER_DATA_DOG_URL","ZUPLO_LOG_LEVEL","ZUPLO_HANDLER_WRITE_LOG_LEVEL"];function l(e){return e.startsWith("__ZUPLO")||e.startsWith("ZUPLO_")?!U.includes(e)&&!e.startsWith("ZUPLO_PUBLIC_"):!1}r(l,"isRestrictedEnvVariableName");function g(e){return!!e.startsWith("ZUPLO_")}r(g,"isZuploReadableEnvVariableName");var x=new Proxy({},{get(e,t){let n=String(t);switch(n){case"ZUPLO_ENVIRONMENT_TYPE":return o.instance.loggingEnvironmentType;case"ZUPLO_ENVIRONMENT_STAGE":return o.instance.loggingEnvironmentStage;case"ZUPLO_ENVIRONMENT_NAME":return o.instance.runtime.__ZUPLO_DEPLOYMENT_NAME;case"ZUPLO_ACCOUNT_NAME":return o.instance.build.ACCOUNT_NAME;case"ZUPLO_PROJECT_NAME":return o.instance.build.PROJECT_NAME;case"ZUPLO_BUILD_ID":return o.instance.build.BUILD_ID}if(!(l(n)&&!g(n)))return o.instance.runtime[n]}});function m(e,t,n){return`_${a(e+"_"+t+"_"+n)}`}r(m,"getRawOperationDataIdentifierName");function p(e,t,n,i){return`_${a(e.toLowerCase())}_`+t.toLowerCase()+"_"+n.toLowerCase()+`_${i.toLowerCase()}`}r(p,"getIdForParameterSchema");function O(e,t,n){return`_${a(e.toLowerCase())}_`+t.toLowerCase()+`_rb_${a(n.toLowerCase())}`}r(O,"getIdForRequestBodySchema");function f(e,t){return`_${a(e)}__${a(t)}`}r(f,"getIdForRefSchema");function a(e){let t=[];for(let n=0;n<e.length;n++){let i=e.charCodeAt(n);i>="0".charCodeAt(0)&&i<="9".charCodeAt(0)||i>="A".charCodeAt(0)&&i<="Z".charCodeAt(0)||i>="a".charCodeAt(0)&&i<="z".charCodeAt(0)?t.push(e.charAt(n)):t.push("_")}return t.join("")}r(a,"sanitizedIdentifierName");
|
|
26
26
|
/*! For license information please see internal.min.cjs.LEGAL.txt */
|
package/package.json
CHANGED
package/types-beta.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ export declare interface ApiAuthKeyInboundPolicyOptions {
|
|
|
138
138
|
* @param policyName - The name of the policy as set in policies.json
|
|
139
139
|
* @returns A Request or a Response
|
|
140
140
|
*/
|
|
141
|
-
export declare function ApiKeyInboundPolicy(request: ZuploRequest, context: ZuploContext, unparsedOptions: ApiKeyInboundPolicyOptions, policyName: string): Promise<
|
|
141
|
+
export declare function ApiKeyInboundPolicy(request: ZuploRequest, context: ZuploContext, unparsedOptions: ApiKeyInboundPolicyOptions, policyName: string): Promise<ZuploRequest<RequestGeneric> | Response>;
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* The options for this policy.
|
|
@@ -452,6 +452,10 @@ export declare interface AxiomaticsAuthZInboundPolicyOptions {
|
|
|
452
452
|
* The password to use when authenticating with the PDP.
|
|
453
453
|
*/
|
|
454
454
|
pdpPassword: string;
|
|
455
|
+
/**
|
|
456
|
+
* Indicates whether the plugin should include default action attributes in the authorization request.
|
|
457
|
+
*/
|
|
458
|
+
includeDefaultActionAttributes?: boolean;
|
|
455
459
|
/**
|
|
456
460
|
* Indicates whether the plugin should include default resource attributes in the authorization request.
|
|
457
461
|
*/
|
|
@@ -568,8 +572,67 @@ declare interface BatchDispatcherOptions {
|
|
|
568
572
|
name?: string;
|
|
569
573
|
}
|
|
570
574
|
|
|
571
|
-
|
|
572
|
-
|
|
575
|
+
/**
|
|
576
|
+
* Authenticate requests based on the mTLS protocol.
|
|
577
|
+
*
|
|
578
|
+
* @remarks
|
|
579
|
+
* The brownout policy allows performing scheduled downtime on your API. This can
|
|
580
|
+
* be useful for helping notify clients of an impending deprecation or for
|
|
581
|
+
* scheduling maintenance.
|
|
582
|
+
*
|
|
583
|
+
* This policy uses {@link https://crontab.guru|cron schedules} to check if a request
|
|
584
|
+
* should experience a brownout or not. When a request falls into a scheduled
|
|
585
|
+
* brownout an error response will be return. The error response can be customized
|
|
586
|
+
* by setting the `problem` properties.
|
|
587
|
+
*
|
|
588
|
+
* For more information using brownouts to alert clients on impending API
|
|
589
|
+
* changes/deprecations see our blog post
|
|
590
|
+
* {@link https://zuplo.com/blog/2022/05/17/how-to-version-an-api|How to version an API}
|
|
591
|
+
*
|
|
592
|
+
* @title Brown Out
|
|
593
|
+
* @public
|
|
594
|
+
* @param request - The ZuploRequest
|
|
595
|
+
* @param context - The ZuploContext
|
|
596
|
+
* @param options - The policy options set in policies.json
|
|
597
|
+
* @param policyName - The name of the policy as set in policies.json
|
|
598
|
+
* @returns A Request or a Response
|
|
599
|
+
*/
|
|
600
|
+
export declare class BrownoutInboundPolicy extends InboundPolicy<BrownoutInboundPolicyOptions> {
|
|
601
|
+
crons: Cron[];
|
|
602
|
+
constructor(options: BrownoutInboundPolicyOptions, policyName: string);
|
|
603
|
+
handler(request: ZuploRequest, context: ZuploContext): Promise<ZuploRequest | Response>;
|
|
604
|
+
}
|
|
605
|
+
|
|
606
|
+
/**
|
|
607
|
+
* The options for this policy.
|
|
608
|
+
*/
|
|
609
|
+
export declare interface BrownoutInboundPolicyOptions {
|
|
610
|
+
/**
|
|
611
|
+
* The cron schedule for when this policy is enabled. This can be a single cron string or an array of multiple cron strings.
|
|
612
|
+
*/
|
|
613
|
+
cronSchedule: string | string[];
|
|
614
|
+
/**
|
|
615
|
+
* The problem that is returned in the response body when this policy is enabled.
|
|
616
|
+
*/
|
|
617
|
+
problem?: {
|
|
618
|
+
/**
|
|
619
|
+
* The type of problem.
|
|
620
|
+
*/
|
|
621
|
+
type?: string;
|
|
622
|
+
/**
|
|
623
|
+
* The title of problem.
|
|
624
|
+
*/
|
|
625
|
+
title?: string;
|
|
626
|
+
/**
|
|
627
|
+
* The detail of problem.
|
|
628
|
+
*/
|
|
629
|
+
detail?: string;
|
|
630
|
+
/**
|
|
631
|
+
* Http status code of the problem.
|
|
632
|
+
*/
|
|
633
|
+
status?: number;
|
|
634
|
+
[k: string]: unknown;
|
|
635
|
+
};
|
|
573
636
|
}
|
|
574
637
|
|
|
575
638
|
/* Excluded from this release type: BuildEnvironment */
|
|
@@ -625,7 +688,7 @@ declare interface CacheOptions {
|
|
|
625
688
|
* @param policyName - The name of the policy as set in policies.json
|
|
626
689
|
* @returns A Request or a Response
|
|
627
690
|
*/
|
|
628
|
-
export declare function CachingInboundPolicy(request: ZuploRequest, context: ZuploContext, options: CachingInboundPolicyOptions, policyName: string): Promise<
|
|
691
|
+
export declare function CachingInboundPolicy(request: ZuploRequest, context: ZuploContext, options: CachingInboundPolicyOptions, policyName: string): Promise<ZuploRequest<RequestGeneric> | Response>;
|
|
629
692
|
|
|
630
693
|
/**
|
|
631
694
|
* The options for this policy.
|
|
@@ -935,6 +998,82 @@ export declare interface CorsPolicyConfiguration {
|
|
|
935
998
|
exposeHeaders?: string[] | string;
|
|
936
999
|
}
|
|
937
1000
|
|
|
1001
|
+
declare class Cron {
|
|
1002
|
+
readonly seconds: ReadonlyArray<number>;
|
|
1003
|
+
readonly minutes: ReadonlyArray<number>;
|
|
1004
|
+
readonly hours: ReadonlyArray<number>;
|
|
1005
|
+
readonly days: ReadonlyArray<number>;
|
|
1006
|
+
readonly months: ReadonlyArray<number>;
|
|
1007
|
+
readonly weekdays: ReadonlyArray<number>;
|
|
1008
|
+
readonly reversed: {
|
|
1009
|
+
seconds: ReadonlyArray<number>;
|
|
1010
|
+
minutes: ReadonlyArray<number>;
|
|
1011
|
+
hours: ReadonlyArray<number>;
|
|
1012
|
+
days: ReadonlyArray<number>;
|
|
1013
|
+
months: ReadonlyArray<number>;
|
|
1014
|
+
weekdays: ReadonlyArray<number>;
|
|
1015
|
+
};
|
|
1016
|
+
constructor({ seconds, minutes, hours, days, months, weekdays, }: CronDefinition);
|
|
1017
|
+
/**
|
|
1018
|
+
* Find the next or previous hour, starting from the given start hour that matches the hour constraint.
|
|
1019
|
+
* startHour itself might also be allowed.
|
|
1020
|
+
*/
|
|
1021
|
+
private findAllowedHour;
|
|
1022
|
+
/**
|
|
1023
|
+
* Find the next or previous minute, starting from the given start minute that matches the minute constraint.
|
|
1024
|
+
* startMinute itself might also be allowed.
|
|
1025
|
+
*/
|
|
1026
|
+
private findAllowedMinute;
|
|
1027
|
+
/**
|
|
1028
|
+
* Find the next or previous second, starting from the given start second that matches the second constraint.
|
|
1029
|
+
* startSecond itself IS NOT allowed.
|
|
1030
|
+
*/
|
|
1031
|
+
private findAllowedSecond;
|
|
1032
|
+
/**
|
|
1033
|
+
* Find the next or previous time, starting from the given start time that matches the hour, minute
|
|
1034
|
+
* and second constraints. startTime itself might also be allowed.
|
|
1035
|
+
*/
|
|
1036
|
+
private findAllowedTime;
|
|
1037
|
+
/**
|
|
1038
|
+
* Find the next or previous day in the given month, starting from the given startDay
|
|
1039
|
+
* that matches either the day or the weekday constraint. startDay itself might also be allowed.
|
|
1040
|
+
*/
|
|
1041
|
+
private findAllowedDayInMonth;
|
|
1042
|
+
/** Gets the next date starting from the given start date or now. */
|
|
1043
|
+
getNextDate(startDate?: Date): Date;
|
|
1044
|
+
/** Gets the specified amount of future dates starting from the given start date or now. */
|
|
1045
|
+
getNextDates(amount: number, startDate?: Date): Date[];
|
|
1046
|
+
/**
|
|
1047
|
+
* Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.
|
|
1048
|
+
* The iterator runs until the optional endDate is reached or forever.
|
|
1049
|
+
*/
|
|
1050
|
+
getNextDatesIterator(startDate?: Date, endDate?: Date): Generator<Date, undefined, undefined>;
|
|
1051
|
+
/** Gets the previous date starting from the given start date or now. */
|
|
1052
|
+
getPrevDate(startDate?: Date): Date;
|
|
1053
|
+
/** Gets the specified amount of previous dates starting from the given start date or now. */
|
|
1054
|
+
getPrevDates(amount: number, startDate?: Date): Date[];
|
|
1055
|
+
/**
|
|
1056
|
+
* Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.
|
|
1057
|
+
* The iterator runs until the optional endDate is reached or forever.
|
|
1058
|
+
*/
|
|
1059
|
+
getPrevDatesIterator(startDate?: Date, endDate?: Date): Generator<Date, undefined, undefined>;
|
|
1060
|
+
/** Returns true when there is a cron date at the given date. */
|
|
1061
|
+
matchDate(date: Date): boolean;
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
/**
|
|
1065
|
+
* An object with contains for each element of a date, which values are allowed.
|
|
1066
|
+
* Everything starting at 0, except for days.
|
|
1067
|
+
*/
|
|
1068
|
+
declare interface CronDefinition {
|
|
1069
|
+
readonly seconds: Set<number>;
|
|
1070
|
+
readonly minutes: Set<number>;
|
|
1071
|
+
readonly hours: Set<number>;
|
|
1072
|
+
readonly days: Set<number>;
|
|
1073
|
+
readonly months: Set<number>;
|
|
1074
|
+
readonly weekdays: Set<number>;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
938
1077
|
/**
|
|
939
1078
|
* @beta
|
|
940
1079
|
*/
|
|
@@ -4431,7 +4570,7 @@ export declare interface StripeMonetizationPluginOptions {
|
|
|
4431
4570
|
* @returns A Request or a Response
|
|
4432
4571
|
*/
|
|
4433
4572
|
export declare class StripeWebhookVerificationInboundPolicy extends InboundPolicy<StripeWebhookVerificationInboundPolicyOptions> {
|
|
4434
|
-
handler(request: ZuploRequest, context: ZuploContext): Promise<
|
|
4573
|
+
handler(request: ZuploRequest, context: ZuploContext): Promise<ZuploRequest<RequestGeneric> | Response>;
|
|
4435
4574
|
}
|
|
4436
4575
|
|
|
4437
4576
|
/**
|
package/types-public.d.ts
CHANGED
|
@@ -138,7 +138,7 @@ export declare interface ApiAuthKeyInboundPolicyOptions {
|
|
|
138
138
|
* @param policyName - The name of the policy as set in policies.json
|
|
139
139
|
* @returns A Request or a Response
|
|
140
140
|
*/
|
|
141
|
-
export declare function ApiKeyInboundPolicy(request: ZuploRequest, context: ZuploContext, unparsedOptions: ApiKeyInboundPolicyOptions, policyName: string): Promise<
|
|
141
|
+
export declare function ApiKeyInboundPolicy(request: ZuploRequest, context: ZuploContext, unparsedOptions: ApiKeyInboundPolicyOptions, policyName: string): Promise<ZuploRequest<RequestGeneric> | Response>;
|
|
142
142
|
|
|
143
143
|
/**
|
|
144
144
|
* The options for this policy.
|
|
@@ -445,6 +445,10 @@ export declare interface AxiomaticsAuthZInboundPolicyOptions {
|
|
|
445
445
|
* The password to use when authenticating with the PDP.
|
|
446
446
|
*/
|
|
447
447
|
pdpPassword: string;
|
|
448
|
+
/**
|
|
449
|
+
* Indicates whether the plugin should include default action attributes in the authorization request.
|
|
450
|
+
*/
|
|
451
|
+
includeDefaultActionAttributes?: boolean;
|
|
448
452
|
/**
|
|
449
453
|
* Indicates whether the plugin should include default resource attributes in the authorization request.
|
|
450
454
|
*/
|
|
@@ -547,8 +551,67 @@ declare interface BatchDispatcherOptions {
|
|
|
547
551
|
name?: string;
|
|
548
552
|
}
|
|
549
553
|
|
|
550
|
-
|
|
551
|
-
|
|
554
|
+
/**
|
|
555
|
+
* Authenticate requests based on the mTLS protocol.
|
|
556
|
+
*
|
|
557
|
+
* @remarks
|
|
558
|
+
* The brownout policy allows performing scheduled downtime on your API. This can
|
|
559
|
+
* be useful for helping notify clients of an impending deprecation or for
|
|
560
|
+
* scheduling maintenance.
|
|
561
|
+
*
|
|
562
|
+
* This policy uses {@link https://crontab.guru|cron schedules} to check if a request
|
|
563
|
+
* should experience a brownout or not. When a request falls into a scheduled
|
|
564
|
+
* brownout an error response will be return. The error response can be customized
|
|
565
|
+
* by setting the `problem` properties.
|
|
566
|
+
*
|
|
567
|
+
* For more information using brownouts to alert clients on impending API
|
|
568
|
+
* changes/deprecations see our blog post
|
|
569
|
+
* {@link https://zuplo.com/blog/2022/05/17/how-to-version-an-api|How to version an API}
|
|
570
|
+
*
|
|
571
|
+
* @title Brown Out
|
|
572
|
+
* @public
|
|
573
|
+
* @param request - The ZuploRequest
|
|
574
|
+
* @param context - The ZuploContext
|
|
575
|
+
* @param options - The policy options set in policies.json
|
|
576
|
+
* @param policyName - The name of the policy as set in policies.json
|
|
577
|
+
* @returns A Request or a Response
|
|
578
|
+
*/
|
|
579
|
+
export declare class BrownoutInboundPolicy extends InboundPolicy<BrownoutInboundPolicyOptions> {
|
|
580
|
+
crons: Cron[];
|
|
581
|
+
constructor(options: BrownoutInboundPolicyOptions, policyName: string);
|
|
582
|
+
handler(request: ZuploRequest, context: ZuploContext): Promise<ZuploRequest | Response>;
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* The options for this policy.
|
|
587
|
+
*/
|
|
588
|
+
export declare interface BrownoutInboundPolicyOptions {
|
|
589
|
+
/**
|
|
590
|
+
* The cron schedule for when this policy is enabled. This can be a single cron string or an array of multiple cron strings.
|
|
591
|
+
*/
|
|
592
|
+
cronSchedule: string | string[];
|
|
593
|
+
/**
|
|
594
|
+
* The problem that is returned in the response body when this policy is enabled.
|
|
595
|
+
*/
|
|
596
|
+
problem?: {
|
|
597
|
+
/**
|
|
598
|
+
* The type of problem.
|
|
599
|
+
*/
|
|
600
|
+
type?: string;
|
|
601
|
+
/**
|
|
602
|
+
* The title of problem.
|
|
603
|
+
*/
|
|
604
|
+
title?: string;
|
|
605
|
+
/**
|
|
606
|
+
* The detail of problem.
|
|
607
|
+
*/
|
|
608
|
+
detail?: string;
|
|
609
|
+
/**
|
|
610
|
+
* Http status code of the problem.
|
|
611
|
+
*/
|
|
612
|
+
status?: number;
|
|
613
|
+
[k: string]: unknown;
|
|
614
|
+
};
|
|
552
615
|
}
|
|
553
616
|
|
|
554
617
|
/* Excluded from this release type: BuildEnvironment */
|
|
@@ -604,7 +667,7 @@ declare interface CacheOptions {
|
|
|
604
667
|
* @param policyName - The name of the policy as set in policies.json
|
|
605
668
|
* @returns A Request or a Response
|
|
606
669
|
*/
|
|
607
|
-
export declare function CachingInboundPolicy(request: ZuploRequest, context: ZuploContext, options: CachingInboundPolicyOptions, policyName: string): Promise<
|
|
670
|
+
export declare function CachingInboundPolicy(request: ZuploRequest, context: ZuploContext, options: CachingInboundPolicyOptions, policyName: string): Promise<ZuploRequest<RequestGeneric> | Response>;
|
|
608
671
|
|
|
609
672
|
/**
|
|
610
673
|
* The options for this policy.
|
|
@@ -914,6 +977,82 @@ export declare interface CorsPolicyConfiguration {
|
|
|
914
977
|
exposeHeaders?: string[] | string;
|
|
915
978
|
}
|
|
916
979
|
|
|
980
|
+
declare class Cron {
|
|
981
|
+
readonly seconds: ReadonlyArray<number>;
|
|
982
|
+
readonly minutes: ReadonlyArray<number>;
|
|
983
|
+
readonly hours: ReadonlyArray<number>;
|
|
984
|
+
readonly days: ReadonlyArray<number>;
|
|
985
|
+
readonly months: ReadonlyArray<number>;
|
|
986
|
+
readonly weekdays: ReadonlyArray<number>;
|
|
987
|
+
readonly reversed: {
|
|
988
|
+
seconds: ReadonlyArray<number>;
|
|
989
|
+
minutes: ReadonlyArray<number>;
|
|
990
|
+
hours: ReadonlyArray<number>;
|
|
991
|
+
days: ReadonlyArray<number>;
|
|
992
|
+
months: ReadonlyArray<number>;
|
|
993
|
+
weekdays: ReadonlyArray<number>;
|
|
994
|
+
};
|
|
995
|
+
constructor({ seconds, minutes, hours, days, months, weekdays, }: CronDefinition);
|
|
996
|
+
/**
|
|
997
|
+
* Find the next or previous hour, starting from the given start hour that matches the hour constraint.
|
|
998
|
+
* startHour itself might also be allowed.
|
|
999
|
+
*/
|
|
1000
|
+
private findAllowedHour;
|
|
1001
|
+
/**
|
|
1002
|
+
* Find the next or previous minute, starting from the given start minute that matches the minute constraint.
|
|
1003
|
+
* startMinute itself might also be allowed.
|
|
1004
|
+
*/
|
|
1005
|
+
private findAllowedMinute;
|
|
1006
|
+
/**
|
|
1007
|
+
* Find the next or previous second, starting from the given start second that matches the second constraint.
|
|
1008
|
+
* startSecond itself IS NOT allowed.
|
|
1009
|
+
*/
|
|
1010
|
+
private findAllowedSecond;
|
|
1011
|
+
/**
|
|
1012
|
+
* Find the next or previous time, starting from the given start time that matches the hour, minute
|
|
1013
|
+
* and second constraints. startTime itself might also be allowed.
|
|
1014
|
+
*/
|
|
1015
|
+
private findAllowedTime;
|
|
1016
|
+
/**
|
|
1017
|
+
* Find the next or previous day in the given month, starting from the given startDay
|
|
1018
|
+
* that matches either the day or the weekday constraint. startDay itself might also be allowed.
|
|
1019
|
+
*/
|
|
1020
|
+
private findAllowedDayInMonth;
|
|
1021
|
+
/** Gets the next date starting from the given start date or now. */
|
|
1022
|
+
getNextDate(startDate?: Date): Date;
|
|
1023
|
+
/** Gets the specified amount of future dates starting from the given start date or now. */
|
|
1024
|
+
getNextDates(amount: number, startDate?: Date): Date[];
|
|
1025
|
+
/**
|
|
1026
|
+
* Get an ES6 compatible iterator which iterates over the next dates starting from startDate or now.
|
|
1027
|
+
* The iterator runs until the optional endDate is reached or forever.
|
|
1028
|
+
*/
|
|
1029
|
+
getNextDatesIterator(startDate?: Date, endDate?: Date): Generator<Date, undefined, undefined>;
|
|
1030
|
+
/** Gets the previous date starting from the given start date or now. */
|
|
1031
|
+
getPrevDate(startDate?: Date): Date;
|
|
1032
|
+
/** Gets the specified amount of previous dates starting from the given start date or now. */
|
|
1033
|
+
getPrevDates(amount: number, startDate?: Date): Date[];
|
|
1034
|
+
/**
|
|
1035
|
+
* Get an ES6 compatible iterator which iterates over the previous dates starting from startDate or now.
|
|
1036
|
+
* The iterator runs until the optional endDate is reached or forever.
|
|
1037
|
+
*/
|
|
1038
|
+
getPrevDatesIterator(startDate?: Date, endDate?: Date): Generator<Date, undefined, undefined>;
|
|
1039
|
+
/** Returns true when there is a cron date at the given date. */
|
|
1040
|
+
matchDate(date: Date): boolean;
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
/**
|
|
1044
|
+
* An object with contains for each element of a date, which values are allowed.
|
|
1045
|
+
* Everything starting at 0, except for days.
|
|
1046
|
+
*/
|
|
1047
|
+
declare interface CronDefinition {
|
|
1048
|
+
readonly seconds: Set<number>;
|
|
1049
|
+
readonly minutes: Set<number>;
|
|
1050
|
+
readonly hours: Set<number>;
|
|
1051
|
+
readonly days: Set<number>;
|
|
1052
|
+
readonly months: Set<number>;
|
|
1053
|
+
readonly weekdays: Set<number>;
|
|
1054
|
+
}
|
|
1055
|
+
|
|
917
1056
|
/* Excluded from this release type: CryptoBeta */
|
|
918
1057
|
|
|
919
1058
|
/**
|
|
@@ -2991,7 +3130,7 @@ export declare interface SleepInboundPolicyOptions {
|
|
|
2991
3130
|
* @returns A Request or a Response
|
|
2992
3131
|
*/
|
|
2993
3132
|
export declare class StripeWebhookVerificationInboundPolicy extends InboundPolicy<StripeWebhookVerificationInboundPolicyOptions> {
|
|
2994
|
-
handler(request: ZuploRequest, context: ZuploContext): Promise<
|
|
3133
|
+
handler(request: ZuploRequest, context: ZuploContext): Promise<ZuploRequest<RequestGeneric> | Response>;
|
|
2995
3134
|
}
|
|
2996
3135
|
|
|
2997
3136
|
/**
|