@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.
@@ -10620,6 +10620,7 @@ declare abstract class AiGateway {
10620
10620
  options?: {
10621
10621
  gateway?: UniversalGatewayOptions;
10622
10622
  extraHeaders?: object;
10623
+ signal?: AbortSignal;
10623
10624
  },
10624
10625
  ): Promise<Response>;
10625
10626
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -12032,6 +12033,140 @@ declare module "cloudflare:email" {
12032
12033
  };
12033
12034
  export { _EmailMessage as EmailMessage };
12034
12035
  }
12036
+ /**
12037
+ * Evaluation context for targeting rules.
12038
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12039
+ */
12040
+ type EvaluationContext = Record<string, string | number | boolean>;
12041
+ interface EvaluationDetails<T> {
12042
+ flagKey: string;
12043
+ value: T;
12044
+ variant?: string | undefined;
12045
+ reason?: string | undefined;
12046
+ errorCode?: string | undefined;
12047
+ errorMessage?: string | undefined;
12048
+ }
12049
+ interface FlagEvaluationError extends Error {}
12050
+ /**
12051
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12052
+ *
12053
+ * @example
12054
+ * ```typescript
12055
+ * // Get a boolean flag value with a default
12056
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12057
+ *
12058
+ * // Get a flag value with evaluation context for targeting
12059
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12060
+ * userId: 'user-123',
12061
+ * country: 'US',
12062
+ * });
12063
+ *
12064
+ * // Get full evaluation details including variant and reason
12065
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12066
+ * console.log(details.variant, details.reason);
12067
+ * ```
12068
+ */
12069
+ declare abstract class Flags {
12070
+ /**
12071
+ * Get a flag value without type checking.
12072
+ * @param flagKey The key of the flag to evaluate.
12073
+ * @param defaultValue Optional default value returned when evaluation fails.
12074
+ * @param context Optional evaluation context for targeting rules.
12075
+ */
12076
+ get(
12077
+ flagKey: string,
12078
+ defaultValue?: unknown,
12079
+ context?: EvaluationContext,
12080
+ ): Promise<unknown>;
12081
+ /**
12082
+ * Get a boolean flag value.
12083
+ * @param flagKey The key of the flag to evaluate.
12084
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12085
+ * @param context Optional evaluation context for targeting rules.
12086
+ */
12087
+ getBooleanValue(
12088
+ flagKey: string,
12089
+ defaultValue: boolean,
12090
+ context?: EvaluationContext,
12091
+ ): Promise<boolean>;
12092
+ /**
12093
+ * Get a string flag value.
12094
+ * @param flagKey The key of the flag to evaluate.
12095
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12096
+ * @param context Optional evaluation context for targeting rules.
12097
+ */
12098
+ getStringValue(
12099
+ flagKey: string,
12100
+ defaultValue: string,
12101
+ context?: EvaluationContext,
12102
+ ): Promise<string>;
12103
+ /**
12104
+ * Get a number flag value.
12105
+ * @param flagKey The key of the flag to evaluate.
12106
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12107
+ * @param context Optional evaluation context for targeting rules.
12108
+ */
12109
+ getNumberValue(
12110
+ flagKey: string,
12111
+ defaultValue: number,
12112
+ context?: EvaluationContext,
12113
+ ): Promise<number>;
12114
+ /**
12115
+ * Get an object flag value.
12116
+ * @param flagKey The key of the flag to evaluate.
12117
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12118
+ * @param context Optional evaluation context for targeting rules.
12119
+ */
12120
+ getObjectValue<T extends object>(
12121
+ flagKey: string,
12122
+ defaultValue: T,
12123
+ context?: EvaluationContext,
12124
+ ): Promise<T>;
12125
+ /**
12126
+ * Get a boolean flag value with full evaluation details.
12127
+ * @param flagKey The key of the flag to evaluate.
12128
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12129
+ * @param context Optional evaluation context for targeting rules.
12130
+ */
12131
+ getBooleanDetails(
12132
+ flagKey: string,
12133
+ defaultValue: boolean,
12134
+ context?: EvaluationContext,
12135
+ ): Promise<EvaluationDetails<boolean>>;
12136
+ /**
12137
+ * Get a string flag value with full evaluation details.
12138
+ * @param flagKey The key of the flag to evaluate.
12139
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12140
+ * @param context Optional evaluation context for targeting rules.
12141
+ */
12142
+ getStringDetails(
12143
+ flagKey: string,
12144
+ defaultValue: string,
12145
+ context?: EvaluationContext,
12146
+ ): Promise<EvaluationDetails<string>>;
12147
+ /**
12148
+ * Get a number flag value with full evaluation details.
12149
+ * @param flagKey The key of the flag to evaluate.
12150
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12151
+ * @param context Optional evaluation context for targeting rules.
12152
+ */
12153
+ getNumberDetails(
12154
+ flagKey: string,
12155
+ defaultValue: number,
12156
+ context?: EvaluationContext,
12157
+ ): Promise<EvaluationDetails<number>>;
12158
+ /**
12159
+ * Get an object flag value with full evaluation details.
12160
+ * @param flagKey The key of the flag to evaluate.
12161
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12162
+ * @param context Optional evaluation context for targeting rules.
12163
+ */
12164
+ getObjectDetails<T extends object>(
12165
+ flagKey: string,
12166
+ defaultValue: T,
12167
+ context?: EvaluationContext,
12168
+ ): Promise<EvaluationDetails<T>>;
12169
+ }
12035
12170
  /**
12036
12171
  * Hello World binding to serve as an explanatory example. DO NOT USE
12037
12172
  */
@@ -12833,7 +12968,7 @@ declare namespace CloudflareWorkersModule {
12833
12968
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12834
12969
  fetch?(request: Request): Response | Promise<Response>;
12835
12970
  connect?(socket: Socket): void | Promise<void>;
12836
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12971
+ queue?(batch: MessageBatch): void | Promise<void>;
12837
12972
  scheduled?(controller: ScheduledController): void | Promise<void>;
12838
12973
  tail?(events: TraceItem[]): void | Promise<void>;
12839
12974
  tailStream?(
@@ -13870,6 +14005,11 @@ declare namespace TailStream {
13870
14005
  readonly tag?: string;
13871
14006
  readonly message?: string;
13872
14007
  }
14008
+ interface TracePreviewInfo {
14009
+ readonly id: string;
14010
+ readonly slug: string;
14011
+ readonly name: string;
14012
+ }
13873
14013
  interface Onset {
13874
14014
  readonly type: "onset";
13875
14015
  readonly attributes: Attribute[];
@@ -13881,6 +14021,7 @@ declare namespace TailStream {
13881
14021
  readonly scriptName?: string;
13882
14022
  readonly scriptTags?: string[];
13883
14023
  readonly scriptVersion?: ScriptVersion;
14024
+ readonly preview?: TracePreviewInfo;
13884
14025
  readonly info:
13885
14026
  | FetchEventInfo
13886
14027
  | ConnectEventInfo
@@ -10631,6 +10631,7 @@ export declare abstract class AiGateway {
10631
10631
  options?: {
10632
10632
  gateway?: UniversalGatewayOptions;
10633
10633
  extraHeaders?: object;
10634
+ signal?: AbortSignal;
10634
10635
  },
10635
10636
  ): Promise<Response>;
10636
10637
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -12048,6 +12049,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12048
12049
  env: Env,
12049
12050
  ctx: ExecutionContext<Props>,
12050
12051
  ) => void | Promise<void>;
12052
+ /**
12053
+ * Evaluation context for targeting rules.
12054
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12055
+ */
12056
+ export type EvaluationContext = Record<string, string | number | boolean>;
12057
+ export interface EvaluationDetails<T> {
12058
+ flagKey: string;
12059
+ value: T;
12060
+ variant?: string | undefined;
12061
+ reason?: string | undefined;
12062
+ errorCode?: string | undefined;
12063
+ errorMessage?: string | undefined;
12064
+ }
12065
+ export interface FlagEvaluationError extends Error {}
12066
+ /**
12067
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12068
+ *
12069
+ * @example
12070
+ * ```typescript
12071
+ * // Get a boolean flag value with a default
12072
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12073
+ *
12074
+ * // Get a flag value with evaluation context for targeting
12075
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12076
+ * userId: 'user-123',
12077
+ * country: 'US',
12078
+ * });
12079
+ *
12080
+ * // Get full evaluation details including variant and reason
12081
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12082
+ * console.log(details.variant, details.reason);
12083
+ * ```
12084
+ */
12085
+ export declare abstract class Flags {
12086
+ /**
12087
+ * Get a flag value without type checking.
12088
+ * @param flagKey The key of the flag to evaluate.
12089
+ * @param defaultValue Optional default value returned when evaluation fails.
12090
+ * @param context Optional evaluation context for targeting rules.
12091
+ */
12092
+ get(
12093
+ flagKey: string,
12094
+ defaultValue?: unknown,
12095
+ context?: EvaluationContext,
12096
+ ): Promise<unknown>;
12097
+ /**
12098
+ * Get a boolean flag value.
12099
+ * @param flagKey The key of the flag to evaluate.
12100
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12101
+ * @param context Optional evaluation context for targeting rules.
12102
+ */
12103
+ getBooleanValue(
12104
+ flagKey: string,
12105
+ defaultValue: boolean,
12106
+ context?: EvaluationContext,
12107
+ ): Promise<boolean>;
12108
+ /**
12109
+ * Get a string flag value.
12110
+ * @param flagKey The key of the flag to evaluate.
12111
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12112
+ * @param context Optional evaluation context for targeting rules.
12113
+ */
12114
+ getStringValue(
12115
+ flagKey: string,
12116
+ defaultValue: string,
12117
+ context?: EvaluationContext,
12118
+ ): Promise<string>;
12119
+ /**
12120
+ * Get a number flag value.
12121
+ * @param flagKey The key of the flag to evaluate.
12122
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12123
+ * @param context Optional evaluation context for targeting rules.
12124
+ */
12125
+ getNumberValue(
12126
+ flagKey: string,
12127
+ defaultValue: number,
12128
+ context?: EvaluationContext,
12129
+ ): Promise<number>;
12130
+ /**
12131
+ * Get an object flag value.
12132
+ * @param flagKey The key of the flag to evaluate.
12133
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12134
+ * @param context Optional evaluation context for targeting rules.
12135
+ */
12136
+ getObjectValue<T extends object>(
12137
+ flagKey: string,
12138
+ defaultValue: T,
12139
+ context?: EvaluationContext,
12140
+ ): Promise<T>;
12141
+ /**
12142
+ * Get a boolean flag value with full evaluation details.
12143
+ * @param flagKey The key of the flag to evaluate.
12144
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12145
+ * @param context Optional evaluation context for targeting rules.
12146
+ */
12147
+ getBooleanDetails(
12148
+ flagKey: string,
12149
+ defaultValue: boolean,
12150
+ context?: EvaluationContext,
12151
+ ): Promise<EvaluationDetails<boolean>>;
12152
+ /**
12153
+ * Get a string flag value with full evaluation details.
12154
+ * @param flagKey The key of the flag to evaluate.
12155
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12156
+ * @param context Optional evaluation context for targeting rules.
12157
+ */
12158
+ getStringDetails(
12159
+ flagKey: string,
12160
+ defaultValue: string,
12161
+ context?: EvaluationContext,
12162
+ ): Promise<EvaluationDetails<string>>;
12163
+ /**
12164
+ * Get a number flag value with full evaluation details.
12165
+ * @param flagKey The key of the flag to evaluate.
12166
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12167
+ * @param context Optional evaluation context for targeting rules.
12168
+ */
12169
+ getNumberDetails(
12170
+ flagKey: string,
12171
+ defaultValue: number,
12172
+ context?: EvaluationContext,
12173
+ ): Promise<EvaluationDetails<number>>;
12174
+ /**
12175
+ * Get an object flag value with full evaluation details.
12176
+ * @param flagKey The key of the flag to evaluate.
12177
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12178
+ * @param context Optional evaluation context for targeting rules.
12179
+ */
12180
+ getObjectDetails<T extends object>(
12181
+ flagKey: string,
12182
+ defaultValue: T,
12183
+ context?: EvaluationContext,
12184
+ ): Promise<EvaluationDetails<T>>;
12185
+ }
12051
12186
  /**
12052
12187
  * Hello World binding to serve as an explanatory example. DO NOT USE
12053
12188
  */
@@ -12800,7 +12935,7 @@ export declare namespace CloudflareWorkersModule {
12800
12935
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12801
12936
  fetch?(request: Request): Response | Promise<Response>;
12802
12937
  connect?(socket: Socket): void | Promise<void>;
12803
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12938
+ queue?(batch: MessageBatch): void | Promise<void>;
12804
12939
  scheduled?(controller: ScheduledController): void | Promise<void>;
12805
12940
  tail?(events: TraceItem[]): void | Promise<void>;
12806
12941
  tailStream?(
@@ -13827,6 +13962,11 @@ export declare namespace TailStream {
13827
13962
  readonly tag?: string;
13828
13963
  readonly message?: string;
13829
13964
  }
13965
+ interface TracePreviewInfo {
13966
+ readonly id: string;
13967
+ readonly slug: string;
13968
+ readonly name: string;
13969
+ }
13830
13970
  interface Onset {
13831
13971
  readonly type: "onset";
13832
13972
  readonly attributes: Attribute[];
@@ -13838,6 +13978,7 @@ export declare namespace TailStream {
13838
13978
  readonly scriptName?: string;
13839
13979
  readonly scriptTags?: string[];
13840
13980
  readonly scriptVersion?: ScriptVersion;
13981
+ readonly preview?: TracePreviewInfo;
13841
13982
  readonly info:
13842
13983
  | FetchEventInfo
13843
13984
  | ConnectEventInfo
@@ -10620,6 +10620,7 @@ declare abstract class AiGateway {
10620
10620
  options?: {
10621
10621
  gateway?: UniversalGatewayOptions;
10622
10622
  extraHeaders?: object;
10623
+ signal?: AbortSignal;
10623
10624
  },
10624
10625
  ): Promise<Response>;
10625
10626
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -12032,6 +12033,140 @@ declare module "cloudflare:email" {
12032
12033
  };
12033
12034
  export { _EmailMessage as EmailMessage };
12034
12035
  }
12036
+ /**
12037
+ * Evaluation context for targeting rules.
12038
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12039
+ */
12040
+ type EvaluationContext = Record<string, string | number | boolean>;
12041
+ interface EvaluationDetails<T> {
12042
+ flagKey: string;
12043
+ value: T;
12044
+ variant?: string | undefined;
12045
+ reason?: string | undefined;
12046
+ errorCode?: string | undefined;
12047
+ errorMessage?: string | undefined;
12048
+ }
12049
+ interface FlagEvaluationError extends Error {}
12050
+ /**
12051
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12052
+ *
12053
+ * @example
12054
+ * ```typescript
12055
+ * // Get a boolean flag value with a default
12056
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12057
+ *
12058
+ * // Get a flag value with evaluation context for targeting
12059
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12060
+ * userId: 'user-123',
12061
+ * country: 'US',
12062
+ * });
12063
+ *
12064
+ * // Get full evaluation details including variant and reason
12065
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12066
+ * console.log(details.variant, details.reason);
12067
+ * ```
12068
+ */
12069
+ declare abstract class Flags {
12070
+ /**
12071
+ * Get a flag value without type checking.
12072
+ * @param flagKey The key of the flag to evaluate.
12073
+ * @param defaultValue Optional default value returned when evaluation fails.
12074
+ * @param context Optional evaluation context for targeting rules.
12075
+ */
12076
+ get(
12077
+ flagKey: string,
12078
+ defaultValue?: unknown,
12079
+ context?: EvaluationContext,
12080
+ ): Promise<unknown>;
12081
+ /**
12082
+ * Get a boolean flag value.
12083
+ * @param flagKey The key of the flag to evaluate.
12084
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12085
+ * @param context Optional evaluation context for targeting rules.
12086
+ */
12087
+ getBooleanValue(
12088
+ flagKey: string,
12089
+ defaultValue: boolean,
12090
+ context?: EvaluationContext,
12091
+ ): Promise<boolean>;
12092
+ /**
12093
+ * Get a string flag value.
12094
+ * @param flagKey The key of the flag to evaluate.
12095
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12096
+ * @param context Optional evaluation context for targeting rules.
12097
+ */
12098
+ getStringValue(
12099
+ flagKey: string,
12100
+ defaultValue: string,
12101
+ context?: EvaluationContext,
12102
+ ): Promise<string>;
12103
+ /**
12104
+ * Get a number flag value.
12105
+ * @param flagKey The key of the flag to evaluate.
12106
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12107
+ * @param context Optional evaluation context for targeting rules.
12108
+ */
12109
+ getNumberValue(
12110
+ flagKey: string,
12111
+ defaultValue: number,
12112
+ context?: EvaluationContext,
12113
+ ): Promise<number>;
12114
+ /**
12115
+ * Get an object flag value.
12116
+ * @param flagKey The key of the flag to evaluate.
12117
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12118
+ * @param context Optional evaluation context for targeting rules.
12119
+ */
12120
+ getObjectValue<T extends object>(
12121
+ flagKey: string,
12122
+ defaultValue: T,
12123
+ context?: EvaluationContext,
12124
+ ): Promise<T>;
12125
+ /**
12126
+ * Get a boolean flag value with full evaluation details.
12127
+ * @param flagKey The key of the flag to evaluate.
12128
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12129
+ * @param context Optional evaluation context for targeting rules.
12130
+ */
12131
+ getBooleanDetails(
12132
+ flagKey: string,
12133
+ defaultValue: boolean,
12134
+ context?: EvaluationContext,
12135
+ ): Promise<EvaluationDetails<boolean>>;
12136
+ /**
12137
+ * Get a string flag value with full evaluation details.
12138
+ * @param flagKey The key of the flag to evaluate.
12139
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12140
+ * @param context Optional evaluation context for targeting rules.
12141
+ */
12142
+ getStringDetails(
12143
+ flagKey: string,
12144
+ defaultValue: string,
12145
+ context?: EvaluationContext,
12146
+ ): Promise<EvaluationDetails<string>>;
12147
+ /**
12148
+ * Get a number flag value with full evaluation details.
12149
+ * @param flagKey The key of the flag to evaluate.
12150
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12151
+ * @param context Optional evaluation context for targeting rules.
12152
+ */
12153
+ getNumberDetails(
12154
+ flagKey: string,
12155
+ defaultValue: number,
12156
+ context?: EvaluationContext,
12157
+ ): Promise<EvaluationDetails<number>>;
12158
+ /**
12159
+ * Get an object flag value with full evaluation details.
12160
+ * @param flagKey The key of the flag to evaluate.
12161
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12162
+ * @param context Optional evaluation context for targeting rules.
12163
+ */
12164
+ getObjectDetails<T extends object>(
12165
+ flagKey: string,
12166
+ defaultValue: T,
12167
+ context?: EvaluationContext,
12168
+ ): Promise<EvaluationDetails<T>>;
12169
+ }
12035
12170
  /**
12036
12171
  * Hello World binding to serve as an explanatory example. DO NOT USE
12037
12172
  */
@@ -12833,7 +12968,7 @@ declare namespace CloudflareWorkersModule {
12833
12968
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12834
12969
  fetch?(request: Request): Response | Promise<Response>;
12835
12970
  connect?(socket: Socket): void | Promise<void>;
12836
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12971
+ queue?(batch: MessageBatch): void | Promise<void>;
12837
12972
  scheduled?(controller: ScheduledController): void | Promise<void>;
12838
12973
  tail?(events: TraceItem[]): void | Promise<void>;
12839
12974
  tailStream?(
@@ -13870,6 +14005,11 @@ declare namespace TailStream {
13870
14005
  readonly tag?: string;
13871
14006
  readonly message?: string;
13872
14007
  }
14008
+ interface TracePreviewInfo {
14009
+ readonly id: string;
14010
+ readonly slug: string;
14011
+ readonly name: string;
14012
+ }
13873
14013
  interface Onset {
13874
14014
  readonly type: "onset";
13875
14015
  readonly attributes: Attribute[];
@@ -13881,6 +14021,7 @@ declare namespace TailStream {
13881
14021
  readonly scriptName?: string;
13882
14022
  readonly scriptTags?: string[];
13883
14023
  readonly scriptVersion?: ScriptVersion;
14024
+ readonly preview?: TracePreviewInfo;
13884
14025
  readonly info:
13885
14026
  | FetchEventInfo
13886
14027
  | ConnectEventInfo