@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 @@ export 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
@@ -12037,6 +12038,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12037
12038
  env: Env,
12038
12039
  ctx: ExecutionContext<Props>,
12039
12040
  ) => void | Promise<void>;
12041
+ /**
12042
+ * Evaluation context for targeting rules.
12043
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12044
+ */
12045
+ export type EvaluationContext = Record<string, string | number | boolean>;
12046
+ export interface EvaluationDetails<T> {
12047
+ flagKey: string;
12048
+ value: T;
12049
+ variant?: string | undefined;
12050
+ reason?: string | undefined;
12051
+ errorCode?: string | undefined;
12052
+ errorMessage?: string | undefined;
12053
+ }
12054
+ export interface FlagEvaluationError extends Error {}
12055
+ /**
12056
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12057
+ *
12058
+ * @example
12059
+ * ```typescript
12060
+ * // Get a boolean flag value with a default
12061
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12062
+ *
12063
+ * // Get a flag value with evaluation context for targeting
12064
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12065
+ * userId: 'user-123',
12066
+ * country: 'US',
12067
+ * });
12068
+ *
12069
+ * // Get full evaluation details including variant and reason
12070
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12071
+ * console.log(details.variant, details.reason);
12072
+ * ```
12073
+ */
12074
+ export declare abstract class Flags {
12075
+ /**
12076
+ * Get a flag value without type checking.
12077
+ * @param flagKey The key of the flag to evaluate.
12078
+ * @param defaultValue Optional default value returned when evaluation fails.
12079
+ * @param context Optional evaluation context for targeting rules.
12080
+ */
12081
+ get(
12082
+ flagKey: string,
12083
+ defaultValue?: unknown,
12084
+ context?: EvaluationContext,
12085
+ ): Promise<unknown>;
12086
+ /**
12087
+ * Get a boolean flag value.
12088
+ * @param flagKey The key of the flag to evaluate.
12089
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12090
+ * @param context Optional evaluation context for targeting rules.
12091
+ */
12092
+ getBooleanValue(
12093
+ flagKey: string,
12094
+ defaultValue: boolean,
12095
+ context?: EvaluationContext,
12096
+ ): Promise<boolean>;
12097
+ /**
12098
+ * Get a string 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
+ getStringValue(
12104
+ flagKey: string,
12105
+ defaultValue: string,
12106
+ context?: EvaluationContext,
12107
+ ): Promise<string>;
12108
+ /**
12109
+ * Get a number 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
+ getNumberValue(
12115
+ flagKey: string,
12116
+ defaultValue: number,
12117
+ context?: EvaluationContext,
12118
+ ): Promise<number>;
12119
+ /**
12120
+ * Get an object 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
+ getObjectValue<T extends object>(
12126
+ flagKey: string,
12127
+ defaultValue: T,
12128
+ context?: EvaluationContext,
12129
+ ): Promise<T>;
12130
+ /**
12131
+ * Get a boolean flag value with full evaluation details.
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
+ getBooleanDetails(
12137
+ flagKey: string,
12138
+ defaultValue: boolean,
12139
+ context?: EvaluationContext,
12140
+ ): Promise<EvaluationDetails<boolean>>;
12141
+ /**
12142
+ * Get a string 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
+ getStringDetails(
12148
+ flagKey: string,
12149
+ defaultValue: string,
12150
+ context?: EvaluationContext,
12151
+ ): Promise<EvaluationDetails<string>>;
12152
+ /**
12153
+ * Get a number 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
+ getNumberDetails(
12159
+ flagKey: string,
12160
+ defaultValue: number,
12161
+ context?: EvaluationContext,
12162
+ ): Promise<EvaluationDetails<number>>;
12163
+ /**
12164
+ * Get an object 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
+ getObjectDetails<T extends object>(
12170
+ flagKey: string,
12171
+ defaultValue: T,
12172
+ context?: EvaluationContext,
12173
+ ): Promise<EvaluationDetails<T>>;
12174
+ }
12040
12175
  /**
12041
12176
  * Hello World binding to serve as an explanatory example. DO NOT USE
12042
12177
  */
@@ -12789,7 +12924,7 @@ export declare namespace CloudflareWorkersModule {
12789
12924
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12790
12925
  fetch?(request: Request): Response | Promise<Response>;
12791
12926
  connect?(socket: Socket): void | Promise<void>;
12792
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12927
+ queue?(batch: MessageBatch): void | Promise<void>;
12793
12928
  scheduled?(controller: ScheduledController): void | Promise<void>;
12794
12929
  tail?(events: TraceItem[]): void | Promise<void>;
12795
12930
  tailStream?(
@@ -13816,6 +13951,11 @@ export declare namespace TailStream {
13816
13951
  readonly tag?: string;
13817
13952
  readonly message?: string;
13818
13953
  }
13954
+ interface TracePreviewInfo {
13955
+ readonly id: string;
13956
+ readonly slug: string;
13957
+ readonly name: string;
13958
+ }
13819
13959
  interface Onset {
13820
13960
  readonly type: "onset";
13821
13961
  readonly attributes: Attribute[];
@@ -13827,6 +13967,7 @@ export declare namespace TailStream {
13827
13967
  readonly scriptName?: string;
13828
13968
  readonly scriptTags?: string[];
13829
13969
  readonly scriptVersion?: ScriptVersion;
13970
+ readonly preview?: TracePreviewInfo;
13830
13971
  readonly info:
13831
13972
  | FetchEventInfo
13832
13973
  | ConnectEventInfo
@@ -10614,6 +10614,7 @@ declare abstract class AiGateway {
10614
10614
  options?: {
10615
10615
  gateway?: UniversalGatewayOptions;
10616
10616
  extraHeaders?: object;
10617
+ signal?: AbortSignal;
10617
10618
  },
10618
10619
  ): Promise<Response>;
10619
10620
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -12026,6 +12027,140 @@ declare module "cloudflare:email" {
12026
12027
  };
12027
12028
  export { _EmailMessage as EmailMessage };
12028
12029
  }
12030
+ /**
12031
+ * Evaluation context for targeting rules.
12032
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12033
+ */
12034
+ type EvaluationContext = Record<string, string | number | boolean>;
12035
+ interface EvaluationDetails<T> {
12036
+ flagKey: string;
12037
+ value: T;
12038
+ variant?: string | undefined;
12039
+ reason?: string | undefined;
12040
+ errorCode?: string | undefined;
12041
+ errorMessage?: string | undefined;
12042
+ }
12043
+ interface FlagEvaluationError extends Error {}
12044
+ /**
12045
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12046
+ *
12047
+ * @example
12048
+ * ```typescript
12049
+ * // Get a boolean flag value with a default
12050
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12051
+ *
12052
+ * // Get a flag value with evaluation context for targeting
12053
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12054
+ * userId: 'user-123',
12055
+ * country: 'US',
12056
+ * });
12057
+ *
12058
+ * // Get full evaluation details including variant and reason
12059
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12060
+ * console.log(details.variant, details.reason);
12061
+ * ```
12062
+ */
12063
+ declare abstract class Flags {
12064
+ /**
12065
+ * Get a flag value without type checking.
12066
+ * @param flagKey The key of the flag to evaluate.
12067
+ * @param defaultValue Optional default value returned when evaluation fails.
12068
+ * @param context Optional evaluation context for targeting rules.
12069
+ */
12070
+ get(
12071
+ flagKey: string,
12072
+ defaultValue?: unknown,
12073
+ context?: EvaluationContext,
12074
+ ): Promise<unknown>;
12075
+ /**
12076
+ * Get a boolean flag value.
12077
+ * @param flagKey The key of the flag to evaluate.
12078
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12079
+ * @param context Optional evaluation context for targeting rules.
12080
+ */
12081
+ getBooleanValue(
12082
+ flagKey: string,
12083
+ defaultValue: boolean,
12084
+ context?: EvaluationContext,
12085
+ ): Promise<boolean>;
12086
+ /**
12087
+ * Get a string flag value.
12088
+ * @param flagKey The key of the flag to evaluate.
12089
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12090
+ * @param context Optional evaluation context for targeting rules.
12091
+ */
12092
+ getStringValue(
12093
+ flagKey: string,
12094
+ defaultValue: string,
12095
+ context?: EvaluationContext,
12096
+ ): Promise<string>;
12097
+ /**
12098
+ * Get a number 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
+ getNumberValue(
12104
+ flagKey: string,
12105
+ defaultValue: number,
12106
+ context?: EvaluationContext,
12107
+ ): Promise<number>;
12108
+ /**
12109
+ * Get an object 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
+ getObjectValue<T extends object>(
12115
+ flagKey: string,
12116
+ defaultValue: T,
12117
+ context?: EvaluationContext,
12118
+ ): Promise<T>;
12119
+ /**
12120
+ * Get a boolean flag value with full evaluation details.
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
+ getBooleanDetails(
12126
+ flagKey: string,
12127
+ defaultValue: boolean,
12128
+ context?: EvaluationContext,
12129
+ ): Promise<EvaluationDetails<boolean>>;
12130
+ /**
12131
+ * Get a string flag value with full evaluation details.
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
+ getStringDetails(
12137
+ flagKey: string,
12138
+ defaultValue: string,
12139
+ context?: EvaluationContext,
12140
+ ): Promise<EvaluationDetails<string>>;
12141
+ /**
12142
+ * Get a number 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
+ getNumberDetails(
12148
+ flagKey: string,
12149
+ defaultValue: number,
12150
+ context?: EvaluationContext,
12151
+ ): Promise<EvaluationDetails<number>>;
12152
+ /**
12153
+ * Get an object 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
+ getObjectDetails<T extends object>(
12159
+ flagKey: string,
12160
+ defaultValue: T,
12161
+ context?: EvaluationContext,
12162
+ ): Promise<EvaluationDetails<T>>;
12163
+ }
12029
12164
  /**
12030
12165
  * Hello World binding to serve as an explanatory example. DO NOT USE
12031
12166
  */
@@ -12827,7 +12962,7 @@ declare namespace CloudflareWorkersModule {
12827
12962
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12828
12963
  fetch?(request: Request): Response | Promise<Response>;
12829
12964
  connect?(socket: Socket): void | Promise<void>;
12830
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12965
+ queue?(batch: MessageBatch): void | Promise<void>;
12831
12966
  scheduled?(controller: ScheduledController): void | Promise<void>;
12832
12967
  tail?(events: TraceItem[]): void | Promise<void>;
12833
12968
  tailStream?(
@@ -13864,6 +13999,11 @@ declare namespace TailStream {
13864
13999
  readonly tag?: string;
13865
14000
  readonly message?: string;
13866
14001
  }
14002
+ interface TracePreviewInfo {
14003
+ readonly id: string;
14004
+ readonly slug: string;
14005
+ readonly name: string;
14006
+ }
13867
14007
  interface Onset {
13868
14008
  readonly type: "onset";
13869
14009
  readonly attributes: Attribute[];
@@ -13875,6 +14015,7 @@ declare namespace TailStream {
13875
14015
  readonly scriptName?: string;
13876
14016
  readonly scriptTags?: string[];
13877
14017
  readonly scriptVersion?: ScriptVersion;
14018
+ readonly preview?: TracePreviewInfo;
13878
14019
  readonly info:
13879
14020
  | FetchEventInfo
13880
14021
  | ConnectEventInfo
@@ -10625,6 +10625,7 @@ export declare abstract class AiGateway {
10625
10625
  options?: {
10626
10626
  gateway?: UniversalGatewayOptions;
10627
10627
  extraHeaders?: object;
10628
+ signal?: AbortSignal;
10628
10629
  },
10629
10630
  ): Promise<Response>;
10630
10631
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -12042,6 +12043,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12042
12043
  env: Env,
12043
12044
  ctx: ExecutionContext<Props>,
12044
12045
  ) => void | Promise<void>;
12046
+ /**
12047
+ * Evaluation context for targeting rules.
12048
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12049
+ */
12050
+ export type EvaluationContext = Record<string, string | number | boolean>;
12051
+ export interface EvaluationDetails<T> {
12052
+ flagKey: string;
12053
+ value: T;
12054
+ variant?: string | undefined;
12055
+ reason?: string | undefined;
12056
+ errorCode?: string | undefined;
12057
+ errorMessage?: string | undefined;
12058
+ }
12059
+ export interface FlagEvaluationError extends Error {}
12060
+ /**
12061
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12062
+ *
12063
+ * @example
12064
+ * ```typescript
12065
+ * // Get a boolean flag value with a default
12066
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12067
+ *
12068
+ * // Get a flag value with evaluation context for targeting
12069
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12070
+ * userId: 'user-123',
12071
+ * country: 'US',
12072
+ * });
12073
+ *
12074
+ * // Get full evaluation details including variant and reason
12075
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12076
+ * console.log(details.variant, details.reason);
12077
+ * ```
12078
+ */
12079
+ export declare abstract class Flags {
12080
+ /**
12081
+ * Get a flag value without type checking.
12082
+ * @param flagKey The key of the flag to evaluate.
12083
+ * @param defaultValue Optional default value returned when evaluation fails.
12084
+ * @param context Optional evaluation context for targeting rules.
12085
+ */
12086
+ get(
12087
+ flagKey: string,
12088
+ defaultValue?: unknown,
12089
+ context?: EvaluationContext,
12090
+ ): Promise<unknown>;
12091
+ /**
12092
+ * Get a boolean flag value.
12093
+ * @param flagKey The key of the flag to evaluate.
12094
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12095
+ * @param context Optional evaluation context for targeting rules.
12096
+ */
12097
+ getBooleanValue(
12098
+ flagKey: string,
12099
+ defaultValue: boolean,
12100
+ context?: EvaluationContext,
12101
+ ): Promise<boolean>;
12102
+ /**
12103
+ * Get a string flag value.
12104
+ * @param flagKey The key of the flag to evaluate.
12105
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12106
+ * @param context Optional evaluation context for targeting rules.
12107
+ */
12108
+ getStringValue(
12109
+ flagKey: string,
12110
+ defaultValue: string,
12111
+ context?: EvaluationContext,
12112
+ ): Promise<string>;
12113
+ /**
12114
+ * Get a number flag value.
12115
+ * @param flagKey The key of the flag to evaluate.
12116
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12117
+ * @param context Optional evaluation context for targeting rules.
12118
+ */
12119
+ getNumberValue(
12120
+ flagKey: string,
12121
+ defaultValue: number,
12122
+ context?: EvaluationContext,
12123
+ ): Promise<number>;
12124
+ /**
12125
+ * Get an object flag value.
12126
+ * @param flagKey The key of the flag to evaluate.
12127
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12128
+ * @param context Optional evaluation context for targeting rules.
12129
+ */
12130
+ getObjectValue<T extends object>(
12131
+ flagKey: string,
12132
+ defaultValue: T,
12133
+ context?: EvaluationContext,
12134
+ ): Promise<T>;
12135
+ /**
12136
+ * Get a boolean flag value with full evaluation details.
12137
+ * @param flagKey The key of the flag to evaluate.
12138
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12139
+ * @param context Optional evaluation context for targeting rules.
12140
+ */
12141
+ getBooleanDetails(
12142
+ flagKey: string,
12143
+ defaultValue: boolean,
12144
+ context?: EvaluationContext,
12145
+ ): Promise<EvaluationDetails<boolean>>;
12146
+ /**
12147
+ * Get a string flag value with full evaluation details.
12148
+ * @param flagKey The key of the flag to evaluate.
12149
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12150
+ * @param context Optional evaluation context for targeting rules.
12151
+ */
12152
+ getStringDetails(
12153
+ flagKey: string,
12154
+ defaultValue: string,
12155
+ context?: EvaluationContext,
12156
+ ): Promise<EvaluationDetails<string>>;
12157
+ /**
12158
+ * Get a number flag value with full evaluation details.
12159
+ * @param flagKey The key of the flag to evaluate.
12160
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12161
+ * @param context Optional evaluation context for targeting rules.
12162
+ */
12163
+ getNumberDetails(
12164
+ flagKey: string,
12165
+ defaultValue: number,
12166
+ context?: EvaluationContext,
12167
+ ): Promise<EvaluationDetails<number>>;
12168
+ /**
12169
+ * Get an object flag value with full evaluation details.
12170
+ * @param flagKey The key of the flag to evaluate.
12171
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12172
+ * @param context Optional evaluation context for targeting rules.
12173
+ */
12174
+ getObjectDetails<T extends object>(
12175
+ flagKey: string,
12176
+ defaultValue: T,
12177
+ context?: EvaluationContext,
12178
+ ): Promise<EvaluationDetails<T>>;
12179
+ }
12045
12180
  /**
12046
12181
  * Hello World binding to serve as an explanatory example. DO NOT USE
12047
12182
  */
@@ -12794,7 +12929,7 @@ export declare namespace CloudflareWorkersModule {
12794
12929
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12795
12930
  fetch?(request: Request): Response | Promise<Response>;
12796
12931
  connect?(socket: Socket): void | Promise<void>;
12797
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12932
+ queue?(batch: MessageBatch): void | Promise<void>;
12798
12933
  scheduled?(controller: ScheduledController): void | Promise<void>;
12799
12934
  tail?(events: TraceItem[]): void | Promise<void>;
12800
12935
  tailStream?(
@@ -13821,6 +13956,11 @@ export declare namespace TailStream {
13821
13956
  readonly tag?: string;
13822
13957
  readonly message?: string;
13823
13958
  }
13959
+ interface TracePreviewInfo {
13960
+ readonly id: string;
13961
+ readonly slug: string;
13962
+ readonly name: string;
13963
+ }
13824
13964
  interface Onset {
13825
13965
  readonly type: "onset";
13826
13966
  readonly attributes: Attribute[];
@@ -13832,6 +13972,7 @@ export declare namespace TailStream {
13832
13972
  readonly scriptName?: string;
13833
13973
  readonly scriptTags?: string[];
13834
13974
  readonly scriptVersion?: ScriptVersion;
13975
+ readonly preview?: TracePreviewInfo;
13835
13976
  readonly info:
13836
13977
  | FetchEventInfo
13837
13978
  | ConnectEventInfo