@cloudflare/workers-types 4.20260405.1 → 4.20260409.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.
@@ -554,6 +554,9 @@ export interface AlarmInvocationInfo {
554
554
  export interface Cloudflare {
555
555
  readonly compatibilityFlags: Record<string, boolean>;
556
556
  }
557
+ export declare abstract class ColoLocalActorNamespace {
558
+ get(actorId: string): Fetcher;
559
+ }
557
560
  export interface DurableObject {
558
561
  fetch(request: Request): Response | Promise<Response>;
559
562
  connect?(socket: Socket): void | Promise<void>;
@@ -633,6 +636,7 @@ export interface DurableObjectState<Props = unknown> {
633
636
  readonly id: DurableObjectId;
634
637
  readonly storage: DurableObjectStorage;
635
638
  container?: Container;
639
+ facets: DurableObjectFacets;
636
640
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
637
641
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
638
642
  getWebSockets(tag?: string): WebSocket[];
@@ -747,6 +751,22 @@ export declare class WebSocketRequestResponsePair {
747
751
  get request(): string;
748
752
  get response(): string;
749
753
  }
754
+ export interface DurableObjectFacets {
755
+ get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
756
+ name: string,
757
+ getStartupOptions: () =>
758
+ | FacetStartupOptions<T>
759
+ | Promise<FacetStartupOptions<T>>,
760
+ ): Fetcher<T>;
761
+ abort(name: string, reason: any): void;
762
+ delete(name: string): void;
763
+ }
764
+ export interface FacetStartupOptions<
765
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
766
+ > {
767
+ id?: DurableObjectId | string;
768
+ class: DurableObjectClass<T>;
769
+ }
750
770
  export interface AnalyticsEngineDataset {
751
771
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
752
772
  }
@@ -3859,6 +3879,8 @@ export type LoopbackDurableObjectClass<
3859
3879
  (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
3860
3880
  ? (opts: { props?: Props }) => DurableObjectClass<T>
3861
3881
  : (opts: { props?: any }) => DurableObjectClass<T>);
3882
+ export interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
3883
+ export interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
3862
3884
  export interface SyncKvStorage {
3863
3885
  get<T = unknown>(key: string): T | undefined;
3864
3886
  list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
@@ -3878,6 +3900,10 @@ export interface WorkerStub {
3878
3900
  name?: string,
3879
3901
  options?: WorkerStubEntrypointOptions,
3880
3902
  ): Fetcher<T>;
3903
+ getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
3904
+ name?: string,
3905
+ options?: WorkerStubEntrypointOptions,
3906
+ ): DurableObjectClass<T>;
3881
3907
  }
3882
3908
  export interface WorkerStubEntrypointOptions {
3883
3909
  props?: any;
@@ -12011,6 +12037,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12011
12037
  env: Env,
12012
12038
  ctx: ExecutionContext<Props>,
12013
12039
  ) => void | Promise<void>;
12040
+ /**
12041
+ * Evaluation context for targeting rules.
12042
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12043
+ */
12044
+ export type EvaluationContext = Record<string, string | number | boolean>;
12045
+ export interface EvaluationDetails<T> {
12046
+ flagKey: string;
12047
+ value: T;
12048
+ variant?: string | undefined;
12049
+ reason?: string | undefined;
12050
+ errorCode?: string | undefined;
12051
+ errorMessage?: string | undefined;
12052
+ }
12053
+ export interface FlagEvaluationError extends Error {}
12054
+ /**
12055
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12056
+ *
12057
+ * @example
12058
+ * ```typescript
12059
+ * // Get a boolean flag value with a default
12060
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12061
+ *
12062
+ * // Get a flag value with evaluation context for targeting
12063
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12064
+ * userId: 'user-123',
12065
+ * country: 'US',
12066
+ * });
12067
+ *
12068
+ * // Get full evaluation details including variant and reason
12069
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12070
+ * console.log(details.variant, details.reason);
12071
+ * ```
12072
+ */
12073
+ export declare abstract class Flags {
12074
+ /**
12075
+ * Get a flag value without type checking.
12076
+ * @param flagKey The key of the flag to evaluate.
12077
+ * @param defaultValue Optional default value returned when evaluation fails.
12078
+ * @param context Optional evaluation context for targeting rules.
12079
+ */
12080
+ get(
12081
+ flagKey: string,
12082
+ defaultValue?: unknown,
12083
+ context?: EvaluationContext,
12084
+ ): Promise<unknown>;
12085
+ /**
12086
+ * Get a boolean flag value.
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
+ getBooleanValue(
12092
+ flagKey: string,
12093
+ defaultValue: boolean,
12094
+ context?: EvaluationContext,
12095
+ ): Promise<boolean>;
12096
+ /**
12097
+ * Get a string flag value.
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
+ getStringValue(
12103
+ flagKey: string,
12104
+ defaultValue: string,
12105
+ context?: EvaluationContext,
12106
+ ): Promise<string>;
12107
+ /**
12108
+ * Get a number flag value.
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
+ getNumberValue(
12114
+ flagKey: string,
12115
+ defaultValue: number,
12116
+ context?: EvaluationContext,
12117
+ ): Promise<number>;
12118
+ /**
12119
+ * Get an object flag value.
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
+ getObjectValue<T extends object>(
12125
+ flagKey: string,
12126
+ defaultValue: T,
12127
+ context?: EvaluationContext,
12128
+ ): Promise<T>;
12129
+ /**
12130
+ * Get a boolean flag value with full evaluation details.
12131
+ * @param flagKey The key of the flag to evaluate.
12132
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12133
+ * @param context Optional evaluation context for targeting rules.
12134
+ */
12135
+ getBooleanDetails(
12136
+ flagKey: string,
12137
+ defaultValue: boolean,
12138
+ context?: EvaluationContext,
12139
+ ): Promise<EvaluationDetails<boolean>>;
12140
+ /**
12141
+ * Get a string flag value with full evaluation details.
12142
+ * @param flagKey The key of the flag to evaluate.
12143
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12144
+ * @param context Optional evaluation context for targeting rules.
12145
+ */
12146
+ getStringDetails(
12147
+ flagKey: string,
12148
+ defaultValue: string,
12149
+ context?: EvaluationContext,
12150
+ ): Promise<EvaluationDetails<string>>;
12151
+ /**
12152
+ * Get a number flag value with full evaluation details.
12153
+ * @param flagKey The key of the flag to evaluate.
12154
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12155
+ * @param context Optional evaluation context for targeting rules.
12156
+ */
12157
+ getNumberDetails(
12158
+ flagKey: string,
12159
+ defaultValue: number,
12160
+ context?: EvaluationContext,
12161
+ ): Promise<EvaluationDetails<number>>;
12162
+ /**
12163
+ * Get an object flag value with full evaluation details.
12164
+ * @param flagKey The key of the flag to evaluate.
12165
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12166
+ * @param context Optional evaluation context for targeting rules.
12167
+ */
12168
+ getObjectDetails<T extends object>(
12169
+ flagKey: string,
12170
+ defaultValue: T,
12171
+ context?: EvaluationContext,
12172
+ ): Promise<EvaluationDetails<T>>;
12173
+ }
12014
12174
  /**
12015
12175
  * Hello World binding to serve as an explanatory example. DO NOT USE
12016
12176
  */
@@ -13790,6 +13950,11 @@ export declare namespace TailStream {
13790
13950
  readonly tag?: string;
13791
13951
  readonly message?: string;
13792
13952
  }
13953
+ interface TracePreviewInfo {
13954
+ readonly id: string;
13955
+ readonly slug: string;
13956
+ readonly name: string;
13957
+ }
13793
13958
  interface Onset {
13794
13959
  readonly type: "onset";
13795
13960
  readonly attributes: Attribute[];
@@ -13801,6 +13966,7 @@ export declare namespace TailStream {
13801
13966
  readonly scriptName?: string;
13802
13967
  readonly scriptTags?: string[];
13803
13968
  readonly scriptVersion?: ScriptVersion;
13969
+ readonly preview?: TracePreviewInfo;
13804
13970
  readonly info:
13805
13971
  | FetchEventInfo
13806
13972
  | ConnectEventInfo
@@ -557,6 +557,9 @@ interface AlarmInvocationInfo {
557
557
  interface Cloudflare {
558
558
  readonly compatibilityFlags: Record<string, boolean>;
559
559
  }
560
+ declare abstract class ColoLocalActorNamespace {
561
+ get(actorId: string): Fetcher;
562
+ }
560
563
  interface DurableObject {
561
564
  fetch(request: Request): Response | Promise<Response>;
562
565
  connect?(socket: Socket): void | Promise<void>;
@@ -636,6 +639,7 @@ interface DurableObjectState<Props = unknown> {
636
639
  readonly id: DurableObjectId;
637
640
  readonly storage: DurableObjectStorage;
638
641
  container?: Container;
642
+ facets: DurableObjectFacets;
639
643
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
640
644
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
641
645
  getWebSockets(tag?: string): WebSocket[];
@@ -750,6 +754,22 @@ declare class WebSocketRequestResponsePair {
750
754
  get request(): string;
751
755
  get response(): string;
752
756
  }
757
+ interface DurableObjectFacets {
758
+ get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
759
+ name: string,
760
+ getStartupOptions: () =>
761
+ | FacetStartupOptions<T>
762
+ | Promise<FacetStartupOptions<T>>,
763
+ ): Fetcher<T>;
764
+ abort(name: string, reason: any): void;
765
+ delete(name: string): void;
766
+ }
767
+ interface FacetStartupOptions<
768
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
769
+ > {
770
+ id?: DurableObjectId | string;
771
+ class: DurableObjectClass<T>;
772
+ }
753
773
  interface AnalyticsEngineDataset {
754
774
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
755
775
  }
@@ -3858,6 +3878,8 @@ type LoopbackDurableObjectClass<
3858
3878
  (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
3859
3879
  ? (opts: { props?: Props }) => DurableObjectClass<T>
3860
3880
  : (opts: { props?: any }) => DurableObjectClass<T>);
3881
+ interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
3882
+ interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
3861
3883
  interface SyncKvStorage {
3862
3884
  get<T = unknown>(key: string): T | undefined;
3863
3885
  list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
@@ -3877,6 +3899,10 @@ interface WorkerStub {
3877
3899
  name?: string,
3878
3900
  options?: WorkerStubEntrypointOptions,
3879
3901
  ): Fetcher<T>;
3902
+ getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
3903
+ name?: string,
3904
+ options?: WorkerStubEntrypointOptions,
3905
+ ): DurableObjectClass<T>;
3880
3906
  }
3881
3907
  interface WorkerStubEntrypointOptions {
3882
3908
  props?: any;
@@ -12000,6 +12026,140 @@ declare module "cloudflare:email" {
12000
12026
  };
12001
12027
  export { _EmailMessage as EmailMessage };
12002
12028
  }
12029
+ /**
12030
+ * Evaluation context for targeting rules.
12031
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12032
+ */
12033
+ type EvaluationContext = Record<string, string | number | boolean>;
12034
+ interface EvaluationDetails<T> {
12035
+ flagKey: string;
12036
+ value: T;
12037
+ variant?: string | undefined;
12038
+ reason?: string | undefined;
12039
+ errorCode?: string | undefined;
12040
+ errorMessage?: string | undefined;
12041
+ }
12042
+ interface FlagEvaluationError extends Error {}
12043
+ /**
12044
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12045
+ *
12046
+ * @example
12047
+ * ```typescript
12048
+ * // Get a boolean flag value with a default
12049
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12050
+ *
12051
+ * // Get a flag value with evaluation context for targeting
12052
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12053
+ * userId: 'user-123',
12054
+ * country: 'US',
12055
+ * });
12056
+ *
12057
+ * // Get full evaluation details including variant and reason
12058
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12059
+ * console.log(details.variant, details.reason);
12060
+ * ```
12061
+ */
12062
+ declare abstract class Flags {
12063
+ /**
12064
+ * Get a flag value without type checking.
12065
+ * @param flagKey The key of the flag to evaluate.
12066
+ * @param defaultValue Optional default value returned when evaluation fails.
12067
+ * @param context Optional evaluation context for targeting rules.
12068
+ */
12069
+ get(
12070
+ flagKey: string,
12071
+ defaultValue?: unknown,
12072
+ context?: EvaluationContext,
12073
+ ): Promise<unknown>;
12074
+ /**
12075
+ * Get a boolean 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
+ getBooleanValue(
12081
+ flagKey: string,
12082
+ defaultValue: boolean,
12083
+ context?: EvaluationContext,
12084
+ ): Promise<boolean>;
12085
+ /**
12086
+ * Get a string flag value.
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
+ getStringValue(
12092
+ flagKey: string,
12093
+ defaultValue: string,
12094
+ context?: EvaluationContext,
12095
+ ): Promise<string>;
12096
+ /**
12097
+ * Get a number flag value.
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
+ getNumberValue(
12103
+ flagKey: string,
12104
+ defaultValue: number,
12105
+ context?: EvaluationContext,
12106
+ ): Promise<number>;
12107
+ /**
12108
+ * Get an object flag value.
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
+ getObjectValue<T extends object>(
12114
+ flagKey: string,
12115
+ defaultValue: T,
12116
+ context?: EvaluationContext,
12117
+ ): Promise<T>;
12118
+ /**
12119
+ * Get a boolean 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
+ getBooleanDetails(
12125
+ flagKey: string,
12126
+ defaultValue: boolean,
12127
+ context?: EvaluationContext,
12128
+ ): Promise<EvaluationDetails<boolean>>;
12129
+ /**
12130
+ * Get a string flag value with full evaluation details.
12131
+ * @param flagKey The key of the flag to evaluate.
12132
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12133
+ * @param context Optional evaluation context for targeting rules.
12134
+ */
12135
+ getStringDetails(
12136
+ flagKey: string,
12137
+ defaultValue: string,
12138
+ context?: EvaluationContext,
12139
+ ): Promise<EvaluationDetails<string>>;
12140
+ /**
12141
+ * Get a number flag value with full evaluation details.
12142
+ * @param flagKey The key of the flag to evaluate.
12143
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12144
+ * @param context Optional evaluation context for targeting rules.
12145
+ */
12146
+ getNumberDetails(
12147
+ flagKey: string,
12148
+ defaultValue: number,
12149
+ context?: EvaluationContext,
12150
+ ): Promise<EvaluationDetails<number>>;
12151
+ /**
12152
+ * Get an object flag value with full evaluation details.
12153
+ * @param flagKey The key of the flag to evaluate.
12154
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12155
+ * @param context Optional evaluation context for targeting rules.
12156
+ */
12157
+ getObjectDetails<T extends object>(
12158
+ flagKey: string,
12159
+ defaultValue: T,
12160
+ context?: EvaluationContext,
12161
+ ): Promise<EvaluationDetails<T>>;
12162
+ }
12003
12163
  /**
12004
12164
  * Hello World binding to serve as an explanatory example. DO NOT USE
12005
12165
  */
@@ -13838,6 +13998,11 @@ declare namespace TailStream {
13838
13998
  readonly tag?: string;
13839
13999
  readonly message?: string;
13840
14000
  }
14001
+ interface TracePreviewInfo {
14002
+ readonly id: string;
14003
+ readonly slug: string;
14004
+ readonly name: string;
14005
+ }
13841
14006
  interface Onset {
13842
14007
  readonly type: "onset";
13843
14008
  readonly attributes: Attribute[];
@@ -13849,6 +14014,7 @@ declare namespace TailStream {
13849
14014
  readonly scriptName?: string;
13850
14015
  readonly scriptTags?: string[];
13851
14016
  readonly scriptVersion?: ScriptVersion;
14017
+ readonly preview?: TracePreviewInfo;
13852
14018
  readonly info:
13853
14019
  | FetchEventInfo
13854
14020
  | ConnectEventInfo
@@ -559,6 +559,9 @@ export interface AlarmInvocationInfo {
559
559
  export interface Cloudflare {
560
560
  readonly compatibilityFlags: Record<string, boolean>;
561
561
  }
562
+ export declare abstract class ColoLocalActorNamespace {
563
+ get(actorId: string): Fetcher;
564
+ }
562
565
  export interface DurableObject {
563
566
  fetch(request: Request): Response | Promise<Response>;
564
567
  connect?(socket: Socket): void | Promise<void>;
@@ -638,6 +641,7 @@ export interface DurableObjectState<Props = unknown> {
638
641
  readonly id: DurableObjectId;
639
642
  readonly storage: DurableObjectStorage;
640
643
  container?: Container;
644
+ facets: DurableObjectFacets;
641
645
  blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
642
646
  acceptWebSocket(ws: WebSocket, tags?: string[]): void;
643
647
  getWebSockets(tag?: string): WebSocket[];
@@ -752,6 +756,22 @@ export declare class WebSocketRequestResponsePair {
752
756
  get request(): string;
753
757
  get response(): string;
754
758
  }
759
+ export interface DurableObjectFacets {
760
+ get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
761
+ name: string,
762
+ getStartupOptions: () =>
763
+ | FacetStartupOptions<T>
764
+ | Promise<FacetStartupOptions<T>>,
765
+ ): Fetcher<T>;
766
+ abort(name: string, reason: any): void;
767
+ delete(name: string): void;
768
+ }
769
+ export interface FacetStartupOptions<
770
+ T extends Rpc.DurableObjectBranded | undefined = undefined,
771
+ > {
772
+ id?: DurableObjectId | string;
773
+ class: DurableObjectClass<T>;
774
+ }
755
775
  export interface AnalyticsEngineDataset {
756
776
  writeDataPoint(event?: AnalyticsEngineDataPoint): void;
757
777
  }
@@ -3864,6 +3884,8 @@ export type LoopbackDurableObjectClass<
3864
3884
  (T extends CloudflareWorkersModule.DurableObject<any, infer Props>
3865
3885
  ? (opts: { props?: Props }) => DurableObjectClass<T>
3866
3886
  : (opts: { props?: any }) => DurableObjectClass<T>);
3887
+ export interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
3888
+ export interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
3867
3889
  export interface SyncKvStorage {
3868
3890
  get<T = unknown>(key: string): T | undefined;
3869
3891
  list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
@@ -3883,6 +3905,10 @@ export interface WorkerStub {
3883
3905
  name?: string,
3884
3906
  options?: WorkerStubEntrypointOptions,
3885
3907
  ): Fetcher<T>;
3908
+ getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
3909
+ name?: string,
3910
+ options?: WorkerStubEntrypointOptions,
3911
+ ): DurableObjectClass<T>;
3886
3912
  }
3887
3913
  export interface WorkerStubEntrypointOptions {
3888
3914
  props?: any;
@@ -12016,6 +12042,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
12016
12042
  env: Env,
12017
12043
  ctx: ExecutionContext<Props>,
12018
12044
  ) => void | Promise<void>;
12045
+ /**
12046
+ * Evaluation context for targeting rules.
12047
+ * Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
12048
+ */
12049
+ export type EvaluationContext = Record<string, string | number | boolean>;
12050
+ export interface EvaluationDetails<T> {
12051
+ flagKey: string;
12052
+ value: T;
12053
+ variant?: string | undefined;
12054
+ reason?: string | undefined;
12055
+ errorCode?: string | undefined;
12056
+ errorMessage?: string | undefined;
12057
+ }
12058
+ export interface FlagEvaluationError extends Error {}
12059
+ /**
12060
+ * Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
12061
+ *
12062
+ * @example
12063
+ * ```typescript
12064
+ * // Get a boolean flag value with a default
12065
+ * const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
12066
+ *
12067
+ * // Get a flag value with evaluation context for targeting
12068
+ * const variant = await env.FLAGS.getStringValue('experiment', 'control', {
12069
+ * userId: 'user-123',
12070
+ * country: 'US',
12071
+ * });
12072
+ *
12073
+ * // Get full evaluation details including variant and reason
12074
+ * const details = await env.FLAGS.getBooleanDetails('my-feature', false);
12075
+ * console.log(details.variant, details.reason);
12076
+ * ```
12077
+ */
12078
+ export declare abstract class Flags {
12079
+ /**
12080
+ * Get a flag value without type checking.
12081
+ * @param flagKey The key of the flag to evaluate.
12082
+ * @param defaultValue Optional default value returned when evaluation fails.
12083
+ * @param context Optional evaluation context for targeting rules.
12084
+ */
12085
+ get(
12086
+ flagKey: string,
12087
+ defaultValue?: unknown,
12088
+ context?: EvaluationContext,
12089
+ ): Promise<unknown>;
12090
+ /**
12091
+ * Get a boolean 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
+ getBooleanValue(
12097
+ flagKey: string,
12098
+ defaultValue: boolean,
12099
+ context?: EvaluationContext,
12100
+ ): Promise<boolean>;
12101
+ /**
12102
+ * Get a string flag value.
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
+ getStringValue(
12108
+ flagKey: string,
12109
+ defaultValue: string,
12110
+ context?: EvaluationContext,
12111
+ ): Promise<string>;
12112
+ /**
12113
+ * Get a number flag value.
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
+ getNumberValue(
12119
+ flagKey: string,
12120
+ defaultValue: number,
12121
+ context?: EvaluationContext,
12122
+ ): Promise<number>;
12123
+ /**
12124
+ * Get an object flag value.
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
+ getObjectValue<T extends object>(
12130
+ flagKey: string,
12131
+ defaultValue: T,
12132
+ context?: EvaluationContext,
12133
+ ): Promise<T>;
12134
+ /**
12135
+ * Get a boolean 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
+ getBooleanDetails(
12141
+ flagKey: string,
12142
+ defaultValue: boolean,
12143
+ context?: EvaluationContext,
12144
+ ): Promise<EvaluationDetails<boolean>>;
12145
+ /**
12146
+ * Get a string flag value with full evaluation details.
12147
+ * @param flagKey The key of the flag to evaluate.
12148
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12149
+ * @param context Optional evaluation context for targeting rules.
12150
+ */
12151
+ getStringDetails(
12152
+ flagKey: string,
12153
+ defaultValue: string,
12154
+ context?: EvaluationContext,
12155
+ ): Promise<EvaluationDetails<string>>;
12156
+ /**
12157
+ * Get a number flag value with full evaluation details.
12158
+ * @param flagKey The key of the flag to evaluate.
12159
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12160
+ * @param context Optional evaluation context for targeting rules.
12161
+ */
12162
+ getNumberDetails(
12163
+ flagKey: string,
12164
+ defaultValue: number,
12165
+ context?: EvaluationContext,
12166
+ ): Promise<EvaluationDetails<number>>;
12167
+ /**
12168
+ * Get an object flag value with full evaluation details.
12169
+ * @param flagKey The key of the flag to evaluate.
12170
+ * @param defaultValue Default value returned when evaluation fails or the flag type does not match.
12171
+ * @param context Optional evaluation context for targeting rules.
12172
+ */
12173
+ getObjectDetails<T extends object>(
12174
+ flagKey: string,
12175
+ defaultValue: T,
12176
+ context?: EvaluationContext,
12177
+ ): Promise<EvaluationDetails<T>>;
12178
+ }
12019
12179
  /**
12020
12180
  * Hello World binding to serve as an explanatory example. DO NOT USE
12021
12181
  */
@@ -13795,6 +13955,11 @@ export declare namespace TailStream {
13795
13955
  readonly tag?: string;
13796
13956
  readonly message?: string;
13797
13957
  }
13958
+ interface TracePreviewInfo {
13959
+ readonly id: string;
13960
+ readonly slug: string;
13961
+ readonly name: string;
13962
+ }
13798
13963
  interface Onset {
13799
13964
  readonly type: "onset";
13800
13965
  readonly attributes: Attribute[];
@@ -13806,6 +13971,7 @@ export declare namespace TailStream {
13806
13971
  readonly scriptName?: string;
13807
13972
  readonly scriptTags?: string[];
13808
13973
  readonly scriptVersion?: ScriptVersion;
13974
+ readonly preview?: TracePreviewInfo;
13809
13975
  readonly info:
13810
13976
  | FetchEventInfo
13811
13977
  | ConnectEventInfo