@cloudflare/workers-types 4.20260408.1 → 4.20260410.1

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.
@@ -10591,6 +10591,7 @@ export declare abstract class AiGateway {
10591
10591
  options?: {
10592
10592
  gateway?: UniversalGatewayOptions;
10593
10593
  extraHeaders?: object;
10594
+ signal?: AbortSignal;
10594
10595
  },
10595
10596
  ): Promise<Response>;
10596
10597
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -12008,6 +12009,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12008
12009
  env: Env,
12009
12010
  ctx: ExecutionContext<Props>,
12010
12011
  ) => void | Promise<void>;
12012
+ /**
12013
+ * Evaluation context for targeting rules.
12014
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12015
+ */
12016
+ export type EvaluationContext = Record<string, string | number | boolean>;
12017
+ export interface EvaluationDetails<T> {
12018
+ flagKey: string;
12019
+ value: T;
12020
+ variant?: string | undefined;
12021
+ reason?: string | undefined;
12022
+ errorCode?: string | undefined;
12023
+ errorMessage?: string | undefined;
12024
+ }
12025
+ export interface FlagEvaluationError extends Error {}
12026
+ /**
12027
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12028
+ *
12029
+ * @example
12030
+ * ```typescript
12031
+ * // Get a boolean flag value with a default
12032
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12033
+ *
12034
+ * // Get a flag value with evaluation context for targeting
12035
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12036
+ * userId: 'user-123',
12037
+ * country: 'US',
12038
+ * });
12039
+ *
12040
+ * // Get full evaluation details including variant and reason
12041
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12042
+ * console.log(details.variant, details.reason);
12043
+ * ```
12044
+ */
12045
+ export declare abstract class Flags {
12046
+ /**
12047
+ * Get a flag value without type checking.
12048
+ * @param flagKey The key of the flag to evaluate.
12049
+ * @param defaultValue Optional default value returned when evaluation fails.
12050
+ * @param context Optional evaluation context for targeting rules.
12051
+ */
12052
+ get(
12053
+ flagKey: string,
12054
+ defaultValue?: unknown,
12055
+ context?: EvaluationContext,
12056
+ ): Promise<unknown>;
12057
+ /**
12058
+ * Get a boolean flag value.
12059
+ * @param flagKey The key of the flag to evaluate.
12060
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12061
+ * @param context Optional evaluation context for targeting rules.
12062
+ */
12063
+ getBooleanValue(
12064
+ flagKey: string,
12065
+ defaultValue: boolean,
12066
+ context?: EvaluationContext,
12067
+ ): Promise<boolean>;
12068
+ /**
12069
+ * Get a string flag value.
12070
+ * @param flagKey The key of the flag to evaluate.
12071
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12072
+ * @param context Optional evaluation context for targeting rules.
12073
+ */
12074
+ getStringValue(
12075
+ flagKey: string,
12076
+ defaultValue: string,
12077
+ context?: EvaluationContext,
12078
+ ): Promise<string>;
12079
+ /**
12080
+ * Get a number flag value.
12081
+ * @param flagKey The key of the flag to evaluate.
12082
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12083
+ * @param context Optional evaluation context for targeting rules.
12084
+ */
12085
+ getNumberValue(
12086
+ flagKey: string,
12087
+ defaultValue: number,
12088
+ context?: EvaluationContext,
12089
+ ): Promise<number>;
12090
+ /**
12091
+ * Get an object flag value.
12092
+ * @param flagKey The key of the flag to evaluate.
12093
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12094
+ * @param context Optional evaluation context for targeting rules.
12095
+ */
12096
+ getObjectValue<T extends object>(
12097
+ flagKey: string,
12098
+ defaultValue: T,
12099
+ context?: EvaluationContext,
12100
+ ): Promise<T>;
12101
+ /**
12102
+ * Get a boolean flag value with full evaluation details.
12103
+ * @param flagKey The key of the flag to evaluate.
12104
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12105
+ * @param context Optional evaluation context for targeting rules.
12106
+ */
12107
+ getBooleanDetails(
12108
+ flagKey: string,
12109
+ defaultValue: boolean,
12110
+ context?: EvaluationContext,
12111
+ ): Promise<EvaluationDetails<boolean>>;
12112
+ /**
12113
+ * Get a string flag value with full evaluation details.
12114
+ * @param flagKey The key of the flag to evaluate.
12115
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12116
+ * @param context Optional evaluation context for targeting rules.
12117
+ */
12118
+ getStringDetails(
12119
+ flagKey: string,
12120
+ defaultValue: string,
12121
+ context?: EvaluationContext,
12122
+ ): Promise<EvaluationDetails<string>>;
12123
+ /**
12124
+ * Get a number flag value with full evaluation details.
12125
+ * @param flagKey The key of the flag to evaluate.
12126
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12127
+ * @param context Optional evaluation context for targeting rules.
12128
+ */
12129
+ getNumberDetails(
12130
+ flagKey: string,
12131
+ defaultValue: number,
12132
+ context?: EvaluationContext,
12133
+ ): Promise<EvaluationDetails<number>>;
12134
+ /**
12135
+ * Get an object flag value with full evaluation details.
12136
+ * @param flagKey The key of the flag to evaluate.
12137
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12138
+ * @param context Optional evaluation context for targeting rules.
12139
+ */
12140
+ getObjectDetails<T extends object>(
12141
+ flagKey: string,
12142
+ defaultValue: T,
12143
+ context?: EvaluationContext,
12144
+ ): Promise<EvaluationDetails<T>>;
12145
+ }
12011
12146
  /**
12012
12147
  * Hello World binding to serve as an explanatory example. DO NOT USE
12013
12148
  */
@@ -12760,7 +12895,7 @@ export declare namespace CloudflareWorkersModule {
12760
12895
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12761
12896
  fetch?(request: Request): Response | Promise<Response>;
12762
12897
  connect?(socket: Socket): void | Promise<void>;
12763
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12898
+ queue?(batch: MessageBatch): void | Promise<void>;
12764
12899
  scheduled?(controller: ScheduledController): void | Promise<void>;
12765
12900
  tail?(events: TraceItem[]): void | Promise<void>;
12766
12901
  tailStream?(
@@ -13787,6 +13922,11 @@ export declare namespace TailStream {
13787
13922
  readonly tag?: string;
13788
13923
  readonly message?: string;
13789
13924
  }
13925
+ interface TracePreviewInfo {
13926
+ readonly id: string;
13927
+ readonly slug: string;
13928
+ readonly name: string;
13929
+ }
13790
13930
  interface Onset {
13791
13931
  readonly type: "onset";
13792
13932
  readonly attributes: Attribute[];
@@ -13798,6 +13938,7 @@ export declare namespace TailStream {
13798
13938
  readonly scriptName?: string;
13799
13939
  readonly scriptTags?: string[];
13800
13940
  readonly scriptVersion?: ScriptVersion;
13941
+ readonly preview?: TracePreviewInfo;
13801
13942
  readonly info:
13802
13943
  | FetchEventInfo
13803
13944
  | ConnectEventInfo
@@ -10588,6 +10588,7 @@ declare abstract class AiGateway {
10588
10588
  options?: {
10589
10589
  gateway?: UniversalGatewayOptions;
10590
10590
  extraHeaders?: object;
10591
+ signal?: AbortSignal;
10591
10592
  },
10592
10593
  ): Promise<Response>;
10593
10594
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -12000,6 +12001,140 @@ declare module "cloudflare:email" {
12000
12001
  };
12001
12002
  export { _EmailMessage as EmailMessage };
12002
12003
  }
12004
+ /**
12005
+ * Evaluation context for targeting rules.
12006
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12007
+ */
12008
+ type EvaluationContext = Record<string, string | number | boolean>;
12009
+ interface EvaluationDetails<T> {
12010
+ flagKey: string;
12011
+ value: T;
12012
+ variant?: string | undefined;
12013
+ reason?: string | undefined;
12014
+ errorCode?: string | undefined;
12015
+ errorMessage?: string | undefined;
12016
+ }
12017
+ interface FlagEvaluationError extends Error {}
12018
+ /**
12019
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12020
+ *
12021
+ * @example
12022
+ * ```typescript
12023
+ * // Get a boolean flag value with a default
12024
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12025
+ *
12026
+ * // Get a flag value with evaluation context for targeting
12027
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12028
+ * userId: 'user-123',
12029
+ * country: 'US',
12030
+ * });
12031
+ *
12032
+ * // Get full evaluation details including variant and reason
12033
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12034
+ * console.log(details.variant, details.reason);
12035
+ * ```
12036
+ */
12037
+ declare abstract class Flags {
12038
+ /**
12039
+ * Get a flag value without type checking.
12040
+ * @param flagKey The key of the flag to evaluate.
12041
+ * @param defaultValue Optional default value returned when evaluation fails.
12042
+ * @param context Optional evaluation context for targeting rules.
12043
+ */
12044
+ get(
12045
+ flagKey: string,
12046
+ defaultValue?: unknown,
12047
+ context?: EvaluationContext,
12048
+ ): Promise<unknown>;
12049
+ /**
12050
+ * Get a boolean flag value.
12051
+ * @param flagKey The key of the flag to evaluate.
12052
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12053
+ * @param context Optional evaluation context for targeting rules.
12054
+ */
12055
+ getBooleanValue(
12056
+ flagKey: string,
12057
+ defaultValue: boolean,
12058
+ context?: EvaluationContext,
12059
+ ): Promise<boolean>;
12060
+ /**
12061
+ * Get a string flag value.
12062
+ * @param flagKey The key of the flag to evaluate.
12063
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12064
+ * @param context Optional evaluation context for targeting rules.
12065
+ */
12066
+ getStringValue(
12067
+ flagKey: string,
12068
+ defaultValue: string,
12069
+ context?: EvaluationContext,
12070
+ ): Promise<string>;
12071
+ /**
12072
+ * Get a number flag value.
12073
+ * @param flagKey The key of the flag to evaluate.
12074
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12075
+ * @param context Optional evaluation context for targeting rules.
12076
+ */
12077
+ getNumberValue(
12078
+ flagKey: string,
12079
+ defaultValue: number,
12080
+ context?: EvaluationContext,
12081
+ ): Promise<number>;
12082
+ /**
12083
+ * Get an object flag value.
12084
+ * @param flagKey The key of the flag to evaluate.
12085
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12086
+ * @param context Optional evaluation context for targeting rules.
12087
+ */
12088
+ getObjectValue<T extends object>(
12089
+ flagKey: string,
12090
+ defaultValue: T,
12091
+ context?: EvaluationContext,
12092
+ ): Promise<T>;
12093
+ /**
12094
+ * Get a boolean flag value with full evaluation details.
12095
+ * @param flagKey The key of the flag to evaluate.
12096
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12097
+ * @param context Optional evaluation context for targeting rules.
12098
+ */
12099
+ getBooleanDetails(
12100
+ flagKey: string,
12101
+ defaultValue: boolean,
12102
+ context?: EvaluationContext,
12103
+ ): Promise<EvaluationDetails<boolean>>;
12104
+ /**
12105
+ * Get a string flag value with full evaluation details.
12106
+ * @param flagKey The key of the flag to evaluate.
12107
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12108
+ * @param context Optional evaluation context for targeting rules.
12109
+ */
12110
+ getStringDetails(
12111
+ flagKey: string,
12112
+ defaultValue: string,
12113
+ context?: EvaluationContext,
12114
+ ): Promise<EvaluationDetails<string>>;
12115
+ /**
12116
+ * Get a number flag value with full evaluation details.
12117
+ * @param flagKey The key of the flag to evaluate.
12118
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12119
+ * @param context Optional evaluation context for targeting rules.
12120
+ */
12121
+ getNumberDetails(
12122
+ flagKey: string,
12123
+ defaultValue: number,
12124
+ context?: EvaluationContext,
12125
+ ): Promise<EvaluationDetails<number>>;
12126
+ /**
12127
+ * Get an object flag value with full evaluation details.
12128
+ * @param flagKey The key of the flag to evaluate.
12129
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12130
+ * @param context Optional evaluation context for targeting rules.
12131
+ */
12132
+ getObjectDetails<T extends object>(
12133
+ flagKey: string,
12134
+ defaultValue: T,
12135
+ context?: EvaluationContext,
12136
+ ): Promise<EvaluationDetails<T>>;
12137
+ }
12003
12138
  /**
12004
12139
  * Hello World binding to serve as an explanatory example. DO NOT USE
12005
12140
  */
@@ -12801,7 +12936,7 @@ declare namespace CloudflareWorkersModule {
12801
12936
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12802
12937
  fetch?(request: Request): Response | Promise<Response>;
12803
12938
  connect?(socket: Socket): void | Promise<void>;
12804
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12939
+ queue?(batch: MessageBatch): void | Promise<void>;
12805
12940
  scheduled?(controller: ScheduledController): void | Promise<void>;
12806
12941
  tail?(events: TraceItem[]): void | Promise<void>;
12807
12942
  tailStream?(
@@ -13838,6 +13973,11 @@ declare namespace TailStream {
13838
13973
  readonly tag?: string;
13839
13974
  readonly message?: string;
13840
13975
  }
13976
+ interface TracePreviewInfo {
13977
+ readonly id: string;
13978
+ readonly slug: string;
13979
+ readonly name: string;
13980
+ }
13841
13981
  interface Onset {
13842
13982
  readonly type: "onset";
13843
13983
  readonly attributes: Attribute[];
@@ -13849,6 +13989,7 @@ declare namespace TailStream {
13849
13989
  readonly scriptName?: string;
13850
13990
  readonly scriptTags?: string[];
13851
13991
  readonly scriptVersion?: ScriptVersion;
13992
+ readonly preview?: TracePreviewInfo;
13852
13993
  readonly info:
13853
13994
  | FetchEventInfo
13854
13995
  | ConnectEventInfo
@@ -10599,6 +10599,7 @@ export declare abstract class AiGateway {
10599
10599
  options?: {
10600
10600
  gateway?: UniversalGatewayOptions;
10601
10601
  extraHeaders?: object;
10602
+ signal?: AbortSignal;
10602
10603
  },
10603
10604
  ): Promise<Response>;
10604
10605
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -12016,6 +12017,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12016
12017
  env: Env,
12017
12018
  ctx: ExecutionContext<Props>,
12018
12019
  ) => void | Promise<void>;
12020
+ /**
12021
+ * Evaluation context for targeting rules.
12022
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12023
+ */
12024
+ export type EvaluationContext = Record<string, string | number | boolean>;
12025
+ export interface EvaluationDetails<T> {
12026
+ flagKey: string;
12027
+ value: T;
12028
+ variant?: string | undefined;
12029
+ reason?: string | undefined;
12030
+ errorCode?: string | undefined;
12031
+ errorMessage?: string | undefined;
12032
+ }
12033
+ export interface FlagEvaluationError extends Error {}
12034
+ /**
12035
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12036
+ *
12037
+ * @example
12038
+ * ```typescript
12039
+ * // Get a boolean flag value with a default
12040
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12041
+ *
12042
+ * // Get a flag value with evaluation context for targeting
12043
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12044
+ * userId: 'user-123',
12045
+ * country: 'US',
12046
+ * });
12047
+ *
12048
+ * // Get full evaluation details including variant and reason
12049
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12050
+ * console.log(details.variant, details.reason);
12051
+ * ```
12052
+ */
12053
+ export declare abstract class Flags {
12054
+ /**
12055
+ * Get a flag value without type checking.
12056
+ * @param flagKey The key of the flag to evaluate.
12057
+ * @param defaultValue Optional default value returned when evaluation fails.
12058
+ * @param context Optional evaluation context for targeting rules.
12059
+ */
12060
+ get(
12061
+ flagKey: string,
12062
+ defaultValue?: unknown,
12063
+ context?: EvaluationContext,
12064
+ ): Promise<unknown>;
12065
+ /**
12066
+ * Get a boolean flag value.
12067
+ * @param flagKey The key of the flag to evaluate.
12068
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12069
+ * @param context Optional evaluation context for targeting rules.
12070
+ */
12071
+ getBooleanValue(
12072
+ flagKey: string,
12073
+ defaultValue: boolean,
12074
+ context?: EvaluationContext,
12075
+ ): Promise<boolean>;
12076
+ /**
12077
+ * Get a string flag value.
12078
+ * @param flagKey The key of the flag to evaluate.
12079
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12080
+ * @param context Optional evaluation context for targeting rules.
12081
+ */
12082
+ getStringValue(
12083
+ flagKey: string,
12084
+ defaultValue: string,
12085
+ context?: EvaluationContext,
12086
+ ): Promise<string>;
12087
+ /**
12088
+ * Get a number flag value.
12089
+ * @param flagKey The key of the flag to evaluate.
12090
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12091
+ * @param context Optional evaluation context for targeting rules.
12092
+ */
12093
+ getNumberValue(
12094
+ flagKey: string,
12095
+ defaultValue: number,
12096
+ context?: EvaluationContext,
12097
+ ): Promise<number>;
12098
+ /**
12099
+ * Get an object flag value.
12100
+ * @param flagKey The key of the flag to evaluate.
12101
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12102
+ * @param context Optional evaluation context for targeting rules.
12103
+ */
12104
+ getObjectValue<T extends object>(
12105
+ flagKey: string,
12106
+ defaultValue: T,
12107
+ context?: EvaluationContext,
12108
+ ): Promise<T>;
12109
+ /**
12110
+ * Get a boolean flag value with full evaluation details.
12111
+ * @param flagKey The key of the flag to evaluate.
12112
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12113
+ * @param context Optional evaluation context for targeting rules.
12114
+ */
12115
+ getBooleanDetails(
12116
+ flagKey: string,
12117
+ defaultValue: boolean,
12118
+ context?: EvaluationContext,
12119
+ ): Promise<EvaluationDetails<boolean>>;
12120
+ /**
12121
+ * Get a string flag value with full evaluation details.
12122
+ * @param flagKey The key of the flag to evaluate.
12123
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12124
+ * @param context Optional evaluation context for targeting rules.
12125
+ */
12126
+ getStringDetails(
12127
+ flagKey: string,
12128
+ defaultValue: string,
12129
+ context?: EvaluationContext,
12130
+ ): Promise<EvaluationDetails<string>>;
12131
+ /**
12132
+ * Get a number flag value with full evaluation details.
12133
+ * @param flagKey The key of the flag to evaluate.
12134
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12135
+ * @param context Optional evaluation context for targeting rules.
12136
+ */
12137
+ getNumberDetails(
12138
+ flagKey: string,
12139
+ defaultValue: number,
12140
+ context?: EvaluationContext,
12141
+ ): Promise<EvaluationDetails<number>>;
12142
+ /**
12143
+ * Get an object flag value with full evaluation details.
12144
+ * @param flagKey The key of the flag to evaluate.
12145
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12146
+ * @param context Optional evaluation context for targeting rules.
12147
+ */
12148
+ getObjectDetails<T extends object>(
12149
+ flagKey: string,
12150
+ defaultValue: T,
12151
+ context?: EvaluationContext,
12152
+ ): Promise<EvaluationDetails<T>>;
12153
+ }
12019
12154
  /**
12020
12155
  * Hello World binding to serve as an explanatory example. DO NOT USE
12021
12156
  */
@@ -12768,7 +12903,7 @@ export declare namespace CloudflareWorkersModule {
12768
12903
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12769
12904
  fetch?(request: Request): Response | Promise<Response>;
12770
12905
  connect?(socket: Socket): void | Promise<void>;
12771
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12906
+ queue?(batch: MessageBatch): void | Promise<void>;
12772
12907
  scheduled?(controller: ScheduledController): void | Promise<void>;
12773
12908
  tail?(events: TraceItem[]): void | Promise<void>;
12774
12909
  tailStream?(
@@ -13795,6 +13930,11 @@ export declare namespace TailStream {
13795
13930
  readonly tag?: string;
13796
13931
  readonly message?: string;
13797
13932
  }
13933
+ interface TracePreviewInfo {
13934
+ readonly id: string;
13935
+ readonly slug: string;
13936
+ readonly name: string;
13937
+ }
13798
13938
  interface Onset {
13799
13939
  readonly type: "onset";
13800
13940
  readonly attributes: Attribute[];
@@ -13806,6 +13946,7 @@ export declare namespace TailStream {
13806
13946
  readonly scriptName?: string;
13807
13947
  readonly scriptTags?: string[];
13808
13948
  readonly scriptVersion?: ScriptVersion;
13949
+ readonly preview?: TracePreviewInfo;
13809
13950
  readonly info:
13810
13951
  | FetchEventInfo
13811
13952
  | ConnectEventInfo