@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.
@@ -10513,6 +10513,7 @@ declare abstract class AiGateway {
10513
10513
  options?: {
10514
10514
  gateway?: UniversalGatewayOptions;
10515
10515
  extraHeaders?: object;
10516
+ signal?: AbortSignal;
10516
10517
  },
10517
10518
  ): Promise<Response>;
10518
10519
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -11925,6 +11926,140 @@ declare module "cloudflare:email" {
11925
11926
  };
11926
11927
  export { _EmailMessage as EmailMessage };
11927
11928
  }
11929
+ /**
11930
+ * Evaluation context for targeting rules.
11931
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
11932
+ */
11933
+ type EvaluationContext = Record<string, string | number | boolean>;
11934
+ interface EvaluationDetails<T> {
11935
+ flagKey: string;
11936
+ value: T;
11937
+ variant?: string | undefined;
11938
+ reason?: string | undefined;
11939
+ errorCode?: string | undefined;
11940
+ errorMessage?: string | undefined;
11941
+ }
11942
+ interface FlagEvaluationError extends Error {}
11943
+ /**
11944
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
11945
+ *
11946
+ * @example
11947
+ * ```typescript
11948
+ * // Get a boolean flag value with a default
11949
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
11950
+ *
11951
+ * // Get a flag value with evaluation context for targeting
11952
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
11953
+ * userId: 'user-123',
11954
+ * country: 'US',
11955
+ * });
11956
+ *
11957
+ * // Get full evaluation details including variant and reason
11958
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
11959
+ * console.log(details.variant, details.reason);
11960
+ * ```
11961
+ */
11962
+ declare abstract class Flags {
11963
+ /**
11964
+ * Get a flag value without type checking.
11965
+ * @param flagKey The key of the flag to evaluate.
11966
+ * @param defaultValue Optional default value returned when evaluation fails.
11967
+ * @param context Optional evaluation context for targeting rules.
11968
+ */
11969
+ get(
11970
+ flagKey: string,
11971
+ defaultValue?: unknown,
11972
+ context?: EvaluationContext,
11973
+ ): Promise<unknown>;
11974
+ /**
11975
+ * Get a boolean flag value.
11976
+ * @param flagKey The key of the flag to evaluate.
11977
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
11978
+ * @param context Optional evaluation context for targeting rules.
11979
+ */
11980
+ getBooleanValue(
11981
+ flagKey: string,
11982
+ defaultValue: boolean,
11983
+ context?: EvaluationContext,
11984
+ ): Promise<boolean>;
11985
+ /**
11986
+ * Get a string flag value.
11987
+ * @param flagKey The key of the flag to evaluate.
11988
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
11989
+ * @param context Optional evaluation context for targeting rules.
11990
+ */
11991
+ getStringValue(
11992
+ flagKey: string,
11993
+ defaultValue: string,
11994
+ context?: EvaluationContext,
11995
+ ): Promise<string>;
11996
+ /**
11997
+ * Get a number flag value.
11998
+ * @param flagKey The key of the flag to evaluate.
11999
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12000
+ * @param context Optional evaluation context for targeting rules.
12001
+ */
12002
+ getNumberValue(
12003
+ flagKey: string,
12004
+ defaultValue: number,
12005
+ context?: EvaluationContext,
12006
+ ): Promise<number>;
12007
+ /**
12008
+ * Get an object flag value.
12009
+ * @param flagKey The key of the flag to evaluate.
12010
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12011
+ * @param context Optional evaluation context for targeting rules.
12012
+ */
12013
+ getObjectValue<T extends object>(
12014
+ flagKey: string,
12015
+ defaultValue: T,
12016
+ context?: EvaluationContext,
12017
+ ): Promise<T>;
12018
+ /**
12019
+ * Get a boolean flag value with full evaluation details.
12020
+ * @param flagKey The key of the flag to evaluate.
12021
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12022
+ * @param context Optional evaluation context for targeting rules.
12023
+ */
12024
+ getBooleanDetails(
12025
+ flagKey: string,
12026
+ defaultValue: boolean,
12027
+ context?: EvaluationContext,
12028
+ ): Promise<EvaluationDetails<boolean>>;
12029
+ /**
12030
+ * Get a string flag value with full evaluation details.
12031
+ * @param flagKey The key of the flag to evaluate.
12032
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12033
+ * @param context Optional evaluation context for targeting rules.
12034
+ */
12035
+ getStringDetails(
12036
+ flagKey: string,
12037
+ defaultValue: string,
12038
+ context?: EvaluationContext,
12039
+ ): Promise<EvaluationDetails<string>>;
12040
+ /**
12041
+ * Get a number flag value with full evaluation details.
12042
+ * @param flagKey The key of the flag to evaluate.
12043
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12044
+ * @param context Optional evaluation context for targeting rules.
12045
+ */
12046
+ getNumberDetails(
12047
+ flagKey: string,
12048
+ defaultValue: number,
12049
+ context?: EvaluationContext,
12050
+ ): Promise<EvaluationDetails<number>>;
12051
+ /**
12052
+ * Get an object flag value with full evaluation details.
12053
+ * @param flagKey The key of the flag to evaluate.
12054
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12055
+ * @param context Optional evaluation context for targeting rules.
12056
+ */
12057
+ getObjectDetails<T extends object>(
12058
+ flagKey: string,
12059
+ defaultValue: T,
12060
+ context?: EvaluationContext,
12061
+ ): Promise<EvaluationDetails<T>>;
12062
+ }
11928
12063
  /**
11929
12064
  * Hello World binding to serve as an explanatory example. DO NOT USE
11930
12065
  */
@@ -12726,7 +12861,7 @@ declare namespace CloudflareWorkersModule {
12726
12861
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12727
12862
  fetch?(request: Request): Response | Promise<Response>;
12728
12863
  connect?(socket: Socket): void | Promise<void>;
12729
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12864
+ queue?(batch: MessageBatch): void | Promise<void>;
12730
12865
  scheduled?(controller: ScheduledController): void | Promise<void>;
12731
12866
  tail?(events: TraceItem[]): void | Promise<void>;
12732
12867
  tailStream?(
@@ -13763,6 +13898,11 @@ declare namespace TailStream {
13763
13898
  readonly tag?: string;
13764
13899
  readonly message?: string;
13765
13900
  }
13901
+ interface TracePreviewInfo {
13902
+ readonly id: string;
13903
+ readonly slug: string;
13904
+ readonly name: string;
13905
+ }
13766
13906
  interface Onset {
13767
13907
  readonly type: "onset";
13768
13908
  readonly attributes: Attribute[];
@@ -13774,6 +13914,7 @@ declare namespace TailStream {
13774
13914
  readonly scriptName?: string;
13775
13915
  readonly scriptTags?: string[];
13776
13916
  readonly scriptVersion?: ScriptVersion;
13917
+ readonly preview?: TracePreviewInfo;
13777
13918
  readonly info:
13778
13919
  | FetchEventInfo
13779
13920
  | ConnectEventInfo
@@ -10524,6 +10524,7 @@ export declare abstract class AiGateway {
10524
10524
  options?: {
10525
10525
  gateway?: UniversalGatewayOptions;
10526
10526
  extraHeaders?: object;
10527
+ signal?: AbortSignal;
10527
10528
  },
10528
10529
  ): Promise<Response>;
10529
10530
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -11941,6 +11942,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
11941
11942
  env: Env,
11942
11943
  ctx: ExecutionContext<Props>,
11943
11944
  ) => void | Promise<void>;
11945
+ /**
11946
+ * Evaluation context for targeting rules.
11947
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
11948
+ */
11949
+ export type EvaluationContext = Record<string, string | number | boolean>;
11950
+ export interface EvaluationDetails<T> {
11951
+ flagKey: string;
11952
+ value: T;
11953
+ variant?: string | undefined;
11954
+ reason?: string | undefined;
11955
+ errorCode?: string | undefined;
11956
+ errorMessage?: string | undefined;
11957
+ }
11958
+ export interface FlagEvaluationError extends Error {}
11959
+ /**
11960
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
11961
+ *
11962
+ * @example
11963
+ * ```typescript
11964
+ * // Get a boolean flag value with a default
11965
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
11966
+ *
11967
+ * // Get a flag value with evaluation context for targeting
11968
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
11969
+ * userId: 'user-123',
11970
+ * country: 'US',
11971
+ * });
11972
+ *
11973
+ * // Get full evaluation details including variant and reason
11974
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
11975
+ * console.log(details.variant, details.reason);
11976
+ * ```
11977
+ */
11978
+ export declare abstract class Flags {
11979
+ /**
11980
+ * Get a flag value without type checking.
11981
+ * @param flagKey The key of the flag to evaluate.
11982
+ * @param defaultValue Optional default value returned when evaluation fails.
11983
+ * @param context Optional evaluation context for targeting rules.
11984
+ */
11985
+ get(
11986
+ flagKey: string,
11987
+ defaultValue?: unknown,
11988
+ context?: EvaluationContext,
11989
+ ): Promise<unknown>;
11990
+ /**
11991
+ * Get a boolean flag value.
11992
+ * @param flagKey The key of the flag to evaluate.
11993
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
11994
+ * @param context Optional evaluation context for targeting rules.
11995
+ */
11996
+ getBooleanValue(
11997
+ flagKey: string,
11998
+ defaultValue: boolean,
11999
+ context?: EvaluationContext,
12000
+ ): Promise<boolean>;
12001
+ /**
12002
+ * Get a string flag value.
12003
+ * @param flagKey The key of the flag to evaluate.
12004
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12005
+ * @param context Optional evaluation context for targeting rules.
12006
+ */
12007
+ getStringValue(
12008
+ flagKey: string,
12009
+ defaultValue: string,
12010
+ context?: EvaluationContext,
12011
+ ): Promise<string>;
12012
+ /**
12013
+ * Get a number flag value.
12014
+ * @param flagKey The key of the flag to evaluate.
12015
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12016
+ * @param context Optional evaluation context for targeting rules.
12017
+ */
12018
+ getNumberValue(
12019
+ flagKey: string,
12020
+ defaultValue: number,
12021
+ context?: EvaluationContext,
12022
+ ): Promise<number>;
12023
+ /**
12024
+ * Get an object flag value.
12025
+ * @param flagKey The key of the flag to evaluate.
12026
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12027
+ * @param context Optional evaluation context for targeting rules.
12028
+ */
12029
+ getObjectValue<T extends object>(
12030
+ flagKey: string,
12031
+ defaultValue: T,
12032
+ context?: EvaluationContext,
12033
+ ): Promise<T>;
12034
+ /**
12035
+ * Get a boolean flag value with full evaluation details.
12036
+ * @param flagKey The key of the flag to evaluate.
12037
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12038
+ * @param context Optional evaluation context for targeting rules.
12039
+ */
12040
+ getBooleanDetails(
12041
+ flagKey: string,
12042
+ defaultValue: boolean,
12043
+ context?: EvaluationContext,
12044
+ ): Promise<EvaluationDetails<boolean>>;
12045
+ /**
12046
+ * Get a string flag value with full evaluation details.
12047
+ * @param flagKey The key of the flag to evaluate.
12048
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12049
+ * @param context Optional evaluation context for targeting rules.
12050
+ */
12051
+ getStringDetails(
12052
+ flagKey: string,
12053
+ defaultValue: string,
12054
+ context?: EvaluationContext,
12055
+ ): Promise<EvaluationDetails<string>>;
12056
+ /**
12057
+ * Get a number flag value with full evaluation details.
12058
+ * @param flagKey The key of the flag to evaluate.
12059
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12060
+ * @param context Optional evaluation context for targeting rules.
12061
+ */
12062
+ getNumberDetails(
12063
+ flagKey: string,
12064
+ defaultValue: number,
12065
+ context?: EvaluationContext,
12066
+ ): Promise<EvaluationDetails<number>>;
12067
+ /**
12068
+ * Get an object flag value with full evaluation details.
12069
+ * @param flagKey The key of the flag to evaluate.
12070
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12071
+ * @param context Optional evaluation context for targeting rules.
12072
+ */
12073
+ getObjectDetails<T extends object>(
12074
+ flagKey: string,
12075
+ defaultValue: T,
12076
+ context?: EvaluationContext,
12077
+ ): Promise<EvaluationDetails<T>>;
12078
+ }
11944
12079
  /**
11945
12080
  * Hello World binding to serve as an explanatory example. DO NOT USE
11946
12081
  */
@@ -12693,7 +12828,7 @@ export declare namespace CloudflareWorkersModule {
12693
12828
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12694
12829
  fetch?(request: Request): Response | Promise<Response>;
12695
12830
  connect?(socket: Socket): void | Promise<void>;
12696
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12831
+ queue?(batch: MessageBatch): void | Promise<void>;
12697
12832
  scheduled?(controller: ScheduledController): void | Promise<void>;
12698
12833
  tail?(events: TraceItem[]): void | Promise<void>;
12699
12834
  tailStream?(
@@ -13720,6 +13855,11 @@ export declare namespace TailStream {
13720
13855
  readonly tag?: string;
13721
13856
  readonly message?: string;
13722
13857
  }
13858
+ interface TracePreviewInfo {
13859
+ readonly id: string;
13860
+ readonly slug: string;
13861
+ readonly name: string;
13862
+ }
13723
13863
  interface Onset {
13724
13864
  readonly type: "onset";
13725
13865
  readonly attributes: Attribute[];
@@ -13731,6 +13871,7 @@ export declare namespace TailStream {
13731
13871
  readonly scriptName?: string;
13732
13872
  readonly scriptTags?: string[];
13733
13873
  readonly scriptVersion?: ScriptVersion;
13874
+ readonly preview?: TracePreviewInfo;
13734
13875
  readonly info:
13735
13876
  | FetchEventInfo
13736
13877
  | ConnectEventInfo
@@ -10580,6 +10580,7 @@ declare abstract class AiGateway {
10580
10580
  options?: {
10581
10581
  gateway?: UniversalGatewayOptions;
10582
10582
  extraHeaders?: object;
10583
+ signal?: AbortSignal;
10583
10584
  },
10584
10585
  ): Promise<Response>;
10585
10586
  getUrl(provider?: AIGatewayProviders | string): Promise<string>; // eslint-disable-line
@@ -11992,6 +11993,140 @@ declare module "cloudflare:email" {
11992
11993
  };
11993
11994
  export { _EmailMessage as EmailMessage };
11994
11995
  }
11996
+ /**
11997
+ * Evaluation context for targeting rules.
11998
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
11999
+ */
12000
+ type EvaluationContext = Record<string, string | number | boolean>;
12001
+ interface EvaluationDetails<T> {
12002
+ flagKey: string;
12003
+ value: T;
12004
+ variant?: string | undefined;
12005
+ reason?: string | undefined;
12006
+ errorCode?: string | undefined;
12007
+ errorMessage?: string | undefined;
12008
+ }
12009
+ interface FlagEvaluationError extends Error {}
12010
+ /**
12011
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12012
+ *
12013
+ * @example
12014
+ * ```typescript
12015
+ * // Get a boolean flag value with a default
12016
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12017
+ *
12018
+ * // Get a flag value with evaluation context for targeting
12019
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12020
+ * userId: 'user-123',
12021
+ * country: 'US',
12022
+ * });
12023
+ *
12024
+ * // Get full evaluation details including variant and reason
12025
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12026
+ * console.log(details.variant, details.reason);
12027
+ * ```
12028
+ */
12029
+ declare abstract class Flags {
12030
+ /**
12031
+ * Get a flag value without type checking.
12032
+ * @param flagKey The key of the flag to evaluate.
12033
+ * @param defaultValue Optional default value returned when evaluation fails.
12034
+ * @param context Optional evaluation context for targeting rules.
12035
+ */
12036
+ get(
12037
+ flagKey: string,
12038
+ defaultValue?: unknown,
12039
+ context?: EvaluationContext,
12040
+ ): Promise<unknown>;
12041
+ /**
12042
+ * Get a boolean flag value.
12043
+ * @param flagKey The key of the flag to evaluate.
12044
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12045
+ * @param context Optional evaluation context for targeting rules.
12046
+ */
12047
+ getBooleanValue(
12048
+ flagKey: string,
12049
+ defaultValue: boolean,
12050
+ context?: EvaluationContext,
12051
+ ): Promise<boolean>;
12052
+ /**
12053
+ * Get a string flag value.
12054
+ * @param flagKey The key of the flag to evaluate.
12055
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12056
+ * @param context Optional evaluation context for targeting rules.
12057
+ */
12058
+ getStringValue(
12059
+ flagKey: string,
12060
+ defaultValue: string,
12061
+ context?: EvaluationContext,
12062
+ ): Promise<string>;
12063
+ /**
12064
+ * Get a number flag value.
12065
+ * @param flagKey The key of the flag to evaluate.
12066
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12067
+ * @param context Optional evaluation context for targeting rules.
12068
+ */
12069
+ getNumberValue(
12070
+ flagKey: string,
12071
+ defaultValue: number,
12072
+ context?: EvaluationContext,
12073
+ ): Promise<number>;
12074
+ /**
12075
+ * Get an object flag value.
12076
+ * @param flagKey The key of the flag to evaluate.
12077
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12078
+ * @param context Optional evaluation context for targeting rules.
12079
+ */
12080
+ getObjectValue<T extends object>(
12081
+ flagKey: string,
12082
+ defaultValue: T,
12083
+ context?: EvaluationContext,
12084
+ ): Promise<T>;
12085
+ /**
12086
+ * Get a boolean flag value with full evaluation details.
12087
+ * @param flagKey The key of the flag to evaluate.
12088
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12089
+ * @param context Optional evaluation context for targeting rules.
12090
+ */
12091
+ getBooleanDetails(
12092
+ flagKey: string,
12093
+ defaultValue: boolean,
12094
+ context?: EvaluationContext,
12095
+ ): Promise<EvaluationDetails<boolean>>;
12096
+ /**
12097
+ * Get a string flag value with full evaluation details.
12098
+ * @param flagKey The key of the flag to evaluate.
12099
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12100
+ * @param context Optional evaluation context for targeting rules.
12101
+ */
12102
+ getStringDetails(
12103
+ flagKey: string,
12104
+ defaultValue: string,
12105
+ context?: EvaluationContext,
12106
+ ): Promise<EvaluationDetails<string>>;
12107
+ /**
12108
+ * Get a number flag value with full evaluation details.
12109
+ * @param flagKey The key of the flag to evaluate.
12110
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12111
+ * @param context Optional evaluation context for targeting rules.
12112
+ */
12113
+ getNumberDetails(
12114
+ flagKey: string,
12115
+ defaultValue: number,
12116
+ context?: EvaluationContext,
12117
+ ): Promise<EvaluationDetails<number>>;
12118
+ /**
12119
+ * Get an object flag value with full evaluation details.
12120
+ * @param flagKey The key of the flag to evaluate.
12121
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12122
+ * @param context Optional evaluation context for targeting rules.
12123
+ */
12124
+ getObjectDetails<T extends object>(
12125
+ flagKey: string,
12126
+ defaultValue: T,
12127
+ context?: EvaluationContext,
12128
+ ): Promise<EvaluationDetails<T>>;
12129
+ }
11995
12130
  /**
11996
12131
  * Hello World binding to serve as an explanatory example. DO NOT USE
11997
12132
  */
@@ -12793,7 +12928,7 @@ declare namespace CloudflareWorkersModule {
12793
12928
  email?(message: ForwardableEmailMessage): void | Promise<void>;
12794
12929
  fetch?(request: Request): Response | Promise<Response>;
12795
12930
  connect?(socket: Socket): void | Promise<void>;
12796
- queue?(batch: MessageBatch<unknown>): void | Promise<void>;
12931
+ queue?(batch: MessageBatch): void | Promise<void>;
12797
12932
  scheduled?(controller: ScheduledController): void | Promise<void>;
12798
12933
  tail?(events: TraceItem[]): void | Promise<void>;
12799
12934
  tailStream?(
@@ -13830,6 +13965,11 @@ declare namespace TailStream {
13830
13965
  readonly tag?: string;
13831
13966
  readonly message?: string;
13832
13967
  }
13968
+ interface TracePreviewInfo {
13969
+ readonly id: string;
13970
+ readonly slug: string;
13971
+ readonly name: string;
13972
+ }
13833
13973
  interface Onset {
13834
13974
  readonly type: "onset";
13835
13975
  readonly attributes: Attribute[];
@@ -13841,6 +13981,7 @@ declare namespace TailStream {
13841
13981
  readonly scriptName?: string;
13842
13982
  readonly scriptTags?: string[];
13843
13983
  readonly scriptVersion?: ScriptVersion;
13984
+ readonly preview?: TracePreviewInfo;
13844
13985
  readonly info:
13845
13986
  | FetchEventInfo
13846
13987
  | ConnectEventInfo