@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.
- package/2021-11-03/index.d.ts +166 -0
- package/2021-11-03/index.ts +166 -0
- package/2022-01-31/index.d.ts +166 -0
- package/2022-01-31/index.ts +166 -0
- package/2022-03-21/index.d.ts +166 -0
- package/2022-03-21/index.ts +166 -0
- package/2022-08-04/index.d.ts +166 -0
- package/2022-08-04/index.ts +166 -0
- package/2022-10-31/index.d.ts +166 -0
- package/2022-10-31/index.ts +166 -0
- package/2022-11-30/index.d.ts +166 -0
- package/2022-11-30/index.ts +166 -0
- package/2023-03-01/index.d.ts +166 -0
- package/2023-03-01/index.ts +166 -0
- package/2023-07-01/index.d.ts +166 -0
- package/2023-07-01/index.ts +166 -0
- package/experimental/index.d.ts +140 -0
- package/experimental/index.ts +140 -0
- package/index.d.ts +166 -0
- package/index.ts +166 -0
- package/latest/index.d.ts +166 -0
- package/latest/index.ts +166 -0
- package/oldest/index.d.ts +166 -0
- package/oldest/index.ts +166 -0
- package/package.json +1 -1
package/2023-07-01/index.ts
CHANGED
|
@@ -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
|
}
|
|
@@ -3870,6 +3890,8 @@ export type LoopbackDurableObjectClass<
|
|
|
3870
3890
|
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
|
|
3871
3891
|
? (opts: { props?: Props }) => DurableObjectClass<T>
|
|
3872
3892
|
: (opts: { props?: any }) => DurableObjectClass<T>);
|
|
3893
|
+
export interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
|
|
3894
|
+
export interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
|
|
3873
3895
|
export interface SyncKvStorage {
|
|
3874
3896
|
get<T = unknown>(key: string): T | undefined;
|
|
3875
3897
|
list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
|
|
@@ -3889,6 +3911,10 @@ export interface WorkerStub {
|
|
|
3889
3911
|
name?: string,
|
|
3890
3912
|
options?: WorkerStubEntrypointOptions,
|
|
3891
3913
|
): Fetcher<T>;
|
|
3914
|
+
getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
|
|
3915
|
+
name?: string,
|
|
3916
|
+
options?: WorkerStubEntrypointOptions,
|
|
3917
|
+
): DurableObjectClass<T>;
|
|
3892
3918
|
}
|
|
3893
3919
|
export interface WorkerStubEntrypointOptions {
|
|
3894
3920
|
props?: any;
|
|
@@ -12022,6 +12048,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
|
|
|
12022
12048
|
env: Env,
|
|
12023
12049
|
ctx: ExecutionContext<Props>,
|
|
12024
12050
|
) => void | Promise<void>;
|
|
12051
|
+
/**
|
|
12052
|
+
* Evaluation context for targeting rules.
|
|
12053
|
+
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
12054
|
+
*/
|
|
12055
|
+
export type EvaluationContext = Record<string, string | number | boolean>;
|
|
12056
|
+
export interface EvaluationDetails<T> {
|
|
12057
|
+
flagKey: string;
|
|
12058
|
+
value: T;
|
|
12059
|
+
variant?: string | undefined;
|
|
12060
|
+
reason?: string | undefined;
|
|
12061
|
+
errorCode?: string | undefined;
|
|
12062
|
+
errorMessage?: string | undefined;
|
|
12063
|
+
}
|
|
12064
|
+
export interface FlagEvaluationError extends Error {}
|
|
12065
|
+
/**
|
|
12066
|
+
* Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
|
|
12067
|
+
*
|
|
12068
|
+
* @example
|
|
12069
|
+
* ```typescript
|
|
12070
|
+
* // Get a boolean flag value with a default
|
|
12071
|
+
* const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
|
|
12072
|
+
*
|
|
12073
|
+
* // Get a flag value with evaluation context for targeting
|
|
12074
|
+
* const variant = await env.FLAGS.getStringValue('experiment', 'control', {
|
|
12075
|
+
* userId: 'user-123',
|
|
12076
|
+
* country: 'US',
|
|
12077
|
+
* });
|
|
12078
|
+
*
|
|
12079
|
+
* // Get full evaluation details including variant and reason
|
|
12080
|
+
* const details = await env.FLAGS.getBooleanDetails('my-feature', false);
|
|
12081
|
+
* console.log(details.variant, details.reason);
|
|
12082
|
+
* ```
|
|
12083
|
+
*/
|
|
12084
|
+
export declare abstract class Flags {
|
|
12085
|
+
/**
|
|
12086
|
+
* Get a flag value without type checking.
|
|
12087
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12088
|
+
* @param defaultValue Optional default value returned when evaluation fails.
|
|
12089
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12090
|
+
*/
|
|
12091
|
+
get(
|
|
12092
|
+
flagKey: string,
|
|
12093
|
+
defaultValue?: unknown,
|
|
12094
|
+
context?: EvaluationContext,
|
|
12095
|
+
): Promise<unknown>;
|
|
12096
|
+
/**
|
|
12097
|
+
* Get a boolean 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
|
+
getBooleanValue(
|
|
12103
|
+
flagKey: string,
|
|
12104
|
+
defaultValue: boolean,
|
|
12105
|
+
context?: EvaluationContext,
|
|
12106
|
+
): Promise<boolean>;
|
|
12107
|
+
/**
|
|
12108
|
+
* Get a string 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
|
+
getStringValue(
|
|
12114
|
+
flagKey: string,
|
|
12115
|
+
defaultValue: string,
|
|
12116
|
+
context?: EvaluationContext,
|
|
12117
|
+
): Promise<string>;
|
|
12118
|
+
/**
|
|
12119
|
+
* Get a number 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
|
+
getNumberValue(
|
|
12125
|
+
flagKey: string,
|
|
12126
|
+
defaultValue: number,
|
|
12127
|
+
context?: EvaluationContext,
|
|
12128
|
+
): Promise<number>;
|
|
12129
|
+
/**
|
|
12130
|
+
* Get an object flag value.
|
|
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
|
+
getObjectValue<T extends object>(
|
|
12136
|
+
flagKey: string,
|
|
12137
|
+
defaultValue: T,
|
|
12138
|
+
context?: EvaluationContext,
|
|
12139
|
+
): Promise<T>;
|
|
12140
|
+
/**
|
|
12141
|
+
* Get a boolean 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
|
+
getBooleanDetails(
|
|
12147
|
+
flagKey: string,
|
|
12148
|
+
defaultValue: boolean,
|
|
12149
|
+
context?: EvaluationContext,
|
|
12150
|
+
): Promise<EvaluationDetails<boolean>>;
|
|
12151
|
+
/**
|
|
12152
|
+
* Get a string 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
|
+
getStringDetails(
|
|
12158
|
+
flagKey: string,
|
|
12159
|
+
defaultValue: string,
|
|
12160
|
+
context?: EvaluationContext,
|
|
12161
|
+
): Promise<EvaluationDetails<string>>;
|
|
12162
|
+
/**
|
|
12163
|
+
* Get a number 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
|
+
getNumberDetails(
|
|
12169
|
+
flagKey: string,
|
|
12170
|
+
defaultValue: number,
|
|
12171
|
+
context?: EvaluationContext,
|
|
12172
|
+
): Promise<EvaluationDetails<number>>;
|
|
12173
|
+
/**
|
|
12174
|
+
* Get an object flag value with full evaluation details.
|
|
12175
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12176
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12177
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12178
|
+
*/
|
|
12179
|
+
getObjectDetails<T extends object>(
|
|
12180
|
+
flagKey: string,
|
|
12181
|
+
defaultValue: T,
|
|
12182
|
+
context?: EvaluationContext,
|
|
12183
|
+
): Promise<EvaluationDetails<T>>;
|
|
12184
|
+
}
|
|
12025
12185
|
/**
|
|
12026
12186
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|
|
12027
12187
|
*/
|
|
@@ -13801,6 +13961,11 @@ export declare namespace TailStream {
|
|
|
13801
13961
|
readonly tag?: string;
|
|
13802
13962
|
readonly message?: string;
|
|
13803
13963
|
}
|
|
13964
|
+
interface TracePreviewInfo {
|
|
13965
|
+
readonly id: string;
|
|
13966
|
+
readonly slug: string;
|
|
13967
|
+
readonly name: string;
|
|
13968
|
+
}
|
|
13804
13969
|
interface Onset {
|
|
13805
13970
|
readonly type: "onset";
|
|
13806
13971
|
readonly attributes: Attribute[];
|
|
@@ -13812,6 +13977,7 @@ export declare namespace TailStream {
|
|
|
13812
13977
|
readonly scriptName?: string;
|
|
13813
13978
|
readonly scriptTags?: string[];
|
|
13814
13979
|
readonly scriptVersion?: ScriptVersion;
|
|
13980
|
+
readonly preview?: TracePreviewInfo;
|
|
13815
13981
|
readonly info:
|
|
13816
13982
|
| FetchEventInfo
|
|
13817
13983
|
| ConnectEventInfo
|
package/experimental/index.d.ts
CHANGED
|
@@ -12757,6 +12757,140 @@ declare module "cloudflare:email" {
|
|
|
12757
12757
|
};
|
|
12758
12758
|
export { _EmailMessage as EmailMessage };
|
|
12759
12759
|
}
|
|
12760
|
+
/**
|
|
12761
|
+
* Evaluation context for targeting rules.
|
|
12762
|
+
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
12763
|
+
*/
|
|
12764
|
+
type EvaluationContext = Record<string, string | number | boolean>;
|
|
12765
|
+
interface EvaluationDetails<T> {
|
|
12766
|
+
flagKey: string;
|
|
12767
|
+
value: T;
|
|
12768
|
+
variant?: string | undefined;
|
|
12769
|
+
reason?: string | undefined;
|
|
12770
|
+
errorCode?: string | undefined;
|
|
12771
|
+
errorMessage?: string | undefined;
|
|
12772
|
+
}
|
|
12773
|
+
interface FlagEvaluationError extends Error {}
|
|
12774
|
+
/**
|
|
12775
|
+
* Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
|
|
12776
|
+
*
|
|
12777
|
+
* @example
|
|
12778
|
+
* ```typescript
|
|
12779
|
+
* // Get a boolean flag value with a default
|
|
12780
|
+
* const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
|
|
12781
|
+
*
|
|
12782
|
+
* // Get a flag value with evaluation context for targeting
|
|
12783
|
+
* const variant = await env.FLAGS.getStringValue('experiment', 'control', {
|
|
12784
|
+
* userId: 'user-123',
|
|
12785
|
+
* country: 'US',
|
|
12786
|
+
* });
|
|
12787
|
+
*
|
|
12788
|
+
* // Get full evaluation details including variant and reason
|
|
12789
|
+
* const details = await env.FLAGS.getBooleanDetails('my-feature', false);
|
|
12790
|
+
* console.log(details.variant, details.reason);
|
|
12791
|
+
* ```
|
|
12792
|
+
*/
|
|
12793
|
+
declare abstract class Flags {
|
|
12794
|
+
/**
|
|
12795
|
+
* Get a flag value without type checking.
|
|
12796
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12797
|
+
* @param defaultValue Optional default value returned when evaluation fails.
|
|
12798
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12799
|
+
*/
|
|
12800
|
+
get(
|
|
12801
|
+
flagKey: string,
|
|
12802
|
+
defaultValue?: unknown,
|
|
12803
|
+
context?: EvaluationContext,
|
|
12804
|
+
): Promise<unknown>;
|
|
12805
|
+
/**
|
|
12806
|
+
* Get a boolean flag value.
|
|
12807
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12808
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12809
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12810
|
+
*/
|
|
12811
|
+
getBooleanValue(
|
|
12812
|
+
flagKey: string,
|
|
12813
|
+
defaultValue: boolean,
|
|
12814
|
+
context?: EvaluationContext,
|
|
12815
|
+
): Promise<boolean>;
|
|
12816
|
+
/**
|
|
12817
|
+
* Get a string flag value.
|
|
12818
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12819
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12820
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12821
|
+
*/
|
|
12822
|
+
getStringValue(
|
|
12823
|
+
flagKey: string,
|
|
12824
|
+
defaultValue: string,
|
|
12825
|
+
context?: EvaluationContext,
|
|
12826
|
+
): Promise<string>;
|
|
12827
|
+
/**
|
|
12828
|
+
* Get a number flag value.
|
|
12829
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12830
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12831
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12832
|
+
*/
|
|
12833
|
+
getNumberValue(
|
|
12834
|
+
flagKey: string,
|
|
12835
|
+
defaultValue: number,
|
|
12836
|
+
context?: EvaluationContext,
|
|
12837
|
+
): Promise<number>;
|
|
12838
|
+
/**
|
|
12839
|
+
* Get an object flag value.
|
|
12840
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12841
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12842
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12843
|
+
*/
|
|
12844
|
+
getObjectValue<T extends object>(
|
|
12845
|
+
flagKey: string,
|
|
12846
|
+
defaultValue: T,
|
|
12847
|
+
context?: EvaluationContext,
|
|
12848
|
+
): Promise<T>;
|
|
12849
|
+
/**
|
|
12850
|
+
* Get a boolean flag value with full evaluation details.
|
|
12851
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12852
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12853
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12854
|
+
*/
|
|
12855
|
+
getBooleanDetails(
|
|
12856
|
+
flagKey: string,
|
|
12857
|
+
defaultValue: boolean,
|
|
12858
|
+
context?: EvaluationContext,
|
|
12859
|
+
): Promise<EvaluationDetails<boolean>>;
|
|
12860
|
+
/**
|
|
12861
|
+
* Get a string flag value with full evaluation details.
|
|
12862
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12863
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12864
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12865
|
+
*/
|
|
12866
|
+
getStringDetails(
|
|
12867
|
+
flagKey: string,
|
|
12868
|
+
defaultValue: string,
|
|
12869
|
+
context?: EvaluationContext,
|
|
12870
|
+
): Promise<EvaluationDetails<string>>;
|
|
12871
|
+
/**
|
|
12872
|
+
* Get a number flag value with full evaluation details.
|
|
12873
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12874
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12875
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12876
|
+
*/
|
|
12877
|
+
getNumberDetails(
|
|
12878
|
+
flagKey: string,
|
|
12879
|
+
defaultValue: number,
|
|
12880
|
+
context?: EvaluationContext,
|
|
12881
|
+
): Promise<EvaluationDetails<number>>;
|
|
12882
|
+
/**
|
|
12883
|
+
* Get an object flag value with full evaluation details.
|
|
12884
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12885
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12886
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12887
|
+
*/
|
|
12888
|
+
getObjectDetails<T extends object>(
|
|
12889
|
+
flagKey: string,
|
|
12890
|
+
defaultValue: T,
|
|
12891
|
+
context?: EvaluationContext,
|
|
12892
|
+
): Promise<EvaluationDetails<T>>;
|
|
12893
|
+
}
|
|
12760
12894
|
/**
|
|
12761
12895
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|
|
12762
12896
|
*/
|
|
@@ -14595,6 +14729,11 @@ declare namespace TailStream {
|
|
|
14595
14729
|
readonly tag?: string;
|
|
14596
14730
|
readonly message?: string;
|
|
14597
14731
|
}
|
|
14732
|
+
interface TracePreviewInfo {
|
|
14733
|
+
readonly id: string;
|
|
14734
|
+
readonly slug: string;
|
|
14735
|
+
readonly name: string;
|
|
14736
|
+
}
|
|
14598
14737
|
interface Onset {
|
|
14599
14738
|
readonly type: "onset";
|
|
14600
14739
|
readonly attributes: Attribute[];
|
|
@@ -14606,6 +14745,7 @@ declare namespace TailStream {
|
|
|
14606
14745
|
readonly scriptName?: string;
|
|
14607
14746
|
readonly scriptTags?: string[];
|
|
14608
14747
|
readonly scriptVersion?: ScriptVersion;
|
|
14748
|
+
readonly preview?: TracePreviewInfo;
|
|
14609
14749
|
readonly info:
|
|
14610
14750
|
| FetchEventInfo
|
|
14611
14751
|
| ConnectEventInfo
|
package/experimental/index.ts
CHANGED
|
@@ -12773,6 +12773,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
|
|
|
12773
12773
|
env: Env,
|
|
12774
12774
|
ctx: ExecutionContext<Props>,
|
|
12775
12775
|
) => void | Promise<void>;
|
|
12776
|
+
/**
|
|
12777
|
+
* Evaluation context for targeting rules.
|
|
12778
|
+
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
12779
|
+
*/
|
|
12780
|
+
export type EvaluationContext = Record<string, string | number | boolean>;
|
|
12781
|
+
export interface EvaluationDetails<T> {
|
|
12782
|
+
flagKey: string;
|
|
12783
|
+
value: T;
|
|
12784
|
+
variant?: string | undefined;
|
|
12785
|
+
reason?: string | undefined;
|
|
12786
|
+
errorCode?: string | undefined;
|
|
12787
|
+
errorMessage?: string | undefined;
|
|
12788
|
+
}
|
|
12789
|
+
export interface FlagEvaluationError extends Error {}
|
|
12790
|
+
/**
|
|
12791
|
+
* Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
|
|
12792
|
+
*
|
|
12793
|
+
* @example
|
|
12794
|
+
* ```typescript
|
|
12795
|
+
* // Get a boolean flag value with a default
|
|
12796
|
+
* const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
|
|
12797
|
+
*
|
|
12798
|
+
* // Get a flag value with evaluation context for targeting
|
|
12799
|
+
* const variant = await env.FLAGS.getStringValue('experiment', 'control', {
|
|
12800
|
+
* userId: 'user-123',
|
|
12801
|
+
* country: 'US',
|
|
12802
|
+
* });
|
|
12803
|
+
*
|
|
12804
|
+
* // Get full evaluation details including variant and reason
|
|
12805
|
+
* const details = await env.FLAGS.getBooleanDetails('my-feature', false);
|
|
12806
|
+
* console.log(details.variant, details.reason);
|
|
12807
|
+
* ```
|
|
12808
|
+
*/
|
|
12809
|
+
export declare abstract class Flags {
|
|
12810
|
+
/**
|
|
12811
|
+
* Get a flag value without type checking.
|
|
12812
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12813
|
+
* @param defaultValue Optional default value returned when evaluation fails.
|
|
12814
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12815
|
+
*/
|
|
12816
|
+
get(
|
|
12817
|
+
flagKey: string,
|
|
12818
|
+
defaultValue?: unknown,
|
|
12819
|
+
context?: EvaluationContext,
|
|
12820
|
+
): Promise<unknown>;
|
|
12821
|
+
/**
|
|
12822
|
+
* Get a boolean flag value.
|
|
12823
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12824
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12825
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12826
|
+
*/
|
|
12827
|
+
getBooleanValue(
|
|
12828
|
+
flagKey: string,
|
|
12829
|
+
defaultValue: boolean,
|
|
12830
|
+
context?: EvaluationContext,
|
|
12831
|
+
): Promise<boolean>;
|
|
12832
|
+
/**
|
|
12833
|
+
* Get a string flag value.
|
|
12834
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12835
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12836
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12837
|
+
*/
|
|
12838
|
+
getStringValue(
|
|
12839
|
+
flagKey: string,
|
|
12840
|
+
defaultValue: string,
|
|
12841
|
+
context?: EvaluationContext,
|
|
12842
|
+
): Promise<string>;
|
|
12843
|
+
/**
|
|
12844
|
+
* Get a number flag value.
|
|
12845
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12846
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12847
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12848
|
+
*/
|
|
12849
|
+
getNumberValue(
|
|
12850
|
+
flagKey: string,
|
|
12851
|
+
defaultValue: number,
|
|
12852
|
+
context?: EvaluationContext,
|
|
12853
|
+
): Promise<number>;
|
|
12854
|
+
/**
|
|
12855
|
+
* Get an object flag value.
|
|
12856
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12857
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12858
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12859
|
+
*/
|
|
12860
|
+
getObjectValue<T extends object>(
|
|
12861
|
+
flagKey: string,
|
|
12862
|
+
defaultValue: T,
|
|
12863
|
+
context?: EvaluationContext,
|
|
12864
|
+
): Promise<T>;
|
|
12865
|
+
/**
|
|
12866
|
+
* Get a boolean flag value with full evaluation details.
|
|
12867
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12868
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12869
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12870
|
+
*/
|
|
12871
|
+
getBooleanDetails(
|
|
12872
|
+
flagKey: string,
|
|
12873
|
+
defaultValue: boolean,
|
|
12874
|
+
context?: EvaluationContext,
|
|
12875
|
+
): Promise<EvaluationDetails<boolean>>;
|
|
12876
|
+
/**
|
|
12877
|
+
* Get a string flag value with full evaluation details.
|
|
12878
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12879
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12880
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12881
|
+
*/
|
|
12882
|
+
getStringDetails(
|
|
12883
|
+
flagKey: string,
|
|
12884
|
+
defaultValue: string,
|
|
12885
|
+
context?: EvaluationContext,
|
|
12886
|
+
): Promise<EvaluationDetails<string>>;
|
|
12887
|
+
/**
|
|
12888
|
+
* Get a number flag value with full evaluation details.
|
|
12889
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12890
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12891
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12892
|
+
*/
|
|
12893
|
+
getNumberDetails(
|
|
12894
|
+
flagKey: string,
|
|
12895
|
+
defaultValue: number,
|
|
12896
|
+
context?: EvaluationContext,
|
|
12897
|
+
): Promise<EvaluationDetails<number>>;
|
|
12898
|
+
/**
|
|
12899
|
+
* Get an object flag value with full evaluation details.
|
|
12900
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12901
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12902
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12903
|
+
*/
|
|
12904
|
+
getObjectDetails<T extends object>(
|
|
12905
|
+
flagKey: string,
|
|
12906
|
+
defaultValue: T,
|
|
12907
|
+
context?: EvaluationContext,
|
|
12908
|
+
): Promise<EvaluationDetails<T>>;
|
|
12909
|
+
}
|
|
12776
12910
|
/**
|
|
12777
12911
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|
|
12778
12912
|
*/
|
|
@@ -14552,6 +14686,11 @@ export declare namespace TailStream {
|
|
|
14552
14686
|
readonly tag?: string;
|
|
14553
14687
|
readonly message?: string;
|
|
14554
14688
|
}
|
|
14689
|
+
interface TracePreviewInfo {
|
|
14690
|
+
readonly id: string;
|
|
14691
|
+
readonly slug: string;
|
|
14692
|
+
readonly name: string;
|
|
14693
|
+
}
|
|
14555
14694
|
interface Onset {
|
|
14556
14695
|
readonly type: "onset";
|
|
14557
14696
|
readonly attributes: Attribute[];
|
|
@@ -14563,6 +14702,7 @@ export declare namespace TailStream {
|
|
|
14563
14702
|
readonly scriptName?: string;
|
|
14564
14703
|
readonly scriptTags?: string[];
|
|
14565
14704
|
readonly scriptVersion?: ScriptVersion;
|
|
14705
|
+
readonly preview?: TracePreviewInfo;
|
|
14566
14706
|
readonly info:
|
|
14567
14707
|
| FetchEventInfo
|
|
14568
14708
|
| ConnectEventInfo
|