@zuplo/runtime 5.2098.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zuplo/runtime",
3
- "version": "5.2098.0",
3
+ "version": "5.2099.0",
4
4
  "repository": "https://github.com/zuplo/zuplo",
5
5
  "author": "Zuplo, Inc.",
6
6
  "exports": {
package/types-beta.d.ts CHANGED
@@ -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
- declare interface BuildAuthorizationRequestHook {
572
- (request: ZuploRequest, context: ZuploContext, currentXacmlRequest: XacmlRequest): Promise<XacmlRequest>;
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 */
@@ -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
  */
package/types-public.d.ts CHANGED
@@ -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
- declare interface BuildAuthorizationRequestHook {
551
- (request: ZuploRequest, context: ZuploContext, currentXacmlRequest: XacmlRequest): Promise<XacmlRequest>;
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 */
@@ -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
  /**