@cloudflare/workers-types 4.20260408.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 +140 -0
- package/2021-11-03/index.ts +140 -0
- package/2022-01-31/index.d.ts +140 -0
- package/2022-01-31/index.ts +140 -0
- package/2022-03-21/index.d.ts +140 -0
- package/2022-03-21/index.ts +140 -0
- package/2022-08-04/index.d.ts +140 -0
- package/2022-08-04/index.ts +140 -0
- package/2022-10-31/index.d.ts +140 -0
- package/2022-10-31/index.ts +140 -0
- package/2022-11-30/index.d.ts +140 -0
- package/2022-11-30/index.ts +140 -0
- package/2023-03-01/index.d.ts +140 -0
- package/2023-03-01/index.ts +140 -0
- package/2023-07-01/index.d.ts +140 -0
- package/2023-07-01/index.ts +140 -0
- package/experimental/index.d.ts +140 -0
- package/experimental/index.ts +140 -0
- package/index.d.ts +140 -0
- package/index.ts +140 -0
- package/latest/index.d.ts +140 -0
- package/latest/index.ts +140 -0
- package/oldest/index.d.ts +140 -0
- package/oldest/index.ts +140 -0
- package/package.json +1 -1
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
|
package/index.d.ts
CHANGED
|
@@ -11925,6 +11925,140 @@ declare module "cloudflare:email" {
|
|
|
11925
11925
|
};
|
|
11926
11926
|
export { _EmailMessage as EmailMessage };
|
|
11927
11927
|
}
|
|
11928
|
+
/**
|
|
11929
|
+
* Evaluation context for targeting rules.
|
|
11930
|
+
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
11931
|
+
*/
|
|
11932
|
+
type EvaluationContext = Record<string, string | number | boolean>;
|
|
11933
|
+
interface EvaluationDetails<T> {
|
|
11934
|
+
flagKey: string;
|
|
11935
|
+
value: T;
|
|
11936
|
+
variant?: string | undefined;
|
|
11937
|
+
reason?: string | undefined;
|
|
11938
|
+
errorCode?: string | undefined;
|
|
11939
|
+
errorMessage?: string | undefined;
|
|
11940
|
+
}
|
|
11941
|
+
interface FlagEvaluationError extends Error {}
|
|
11942
|
+
/**
|
|
11943
|
+
* Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
|
|
11944
|
+
*
|
|
11945
|
+
* @example
|
|
11946
|
+
* ```typescript
|
|
11947
|
+
* // Get a boolean flag value with a default
|
|
11948
|
+
* const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
|
|
11949
|
+
*
|
|
11950
|
+
* // Get a flag value with evaluation context for targeting
|
|
11951
|
+
* const variant = await env.FLAGS.getStringValue('experiment', 'control', {
|
|
11952
|
+
* userId: 'user-123',
|
|
11953
|
+
* country: 'US',
|
|
11954
|
+
* });
|
|
11955
|
+
*
|
|
11956
|
+
* // Get full evaluation details including variant and reason
|
|
11957
|
+
* const details = await env.FLAGS.getBooleanDetails('my-feature', false);
|
|
11958
|
+
* console.log(details.variant, details.reason);
|
|
11959
|
+
* ```
|
|
11960
|
+
*/
|
|
11961
|
+
declare abstract class Flags {
|
|
11962
|
+
/**
|
|
11963
|
+
* Get a flag value without type checking.
|
|
11964
|
+
* @param flagKey The key of the flag to evaluate.
|
|
11965
|
+
* @param defaultValue Optional default value returned when evaluation fails.
|
|
11966
|
+
* @param context Optional evaluation context for targeting rules.
|
|
11967
|
+
*/
|
|
11968
|
+
get(
|
|
11969
|
+
flagKey: string,
|
|
11970
|
+
defaultValue?: unknown,
|
|
11971
|
+
context?: EvaluationContext,
|
|
11972
|
+
): Promise<unknown>;
|
|
11973
|
+
/**
|
|
11974
|
+
* Get a boolean flag value.
|
|
11975
|
+
* @param flagKey The key of the flag to evaluate.
|
|
11976
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
11977
|
+
* @param context Optional evaluation context for targeting rules.
|
|
11978
|
+
*/
|
|
11979
|
+
getBooleanValue(
|
|
11980
|
+
flagKey: string,
|
|
11981
|
+
defaultValue: boolean,
|
|
11982
|
+
context?: EvaluationContext,
|
|
11983
|
+
): Promise<boolean>;
|
|
11984
|
+
/**
|
|
11985
|
+
* Get a string flag value.
|
|
11986
|
+
* @param flagKey The key of the flag to evaluate.
|
|
11987
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
11988
|
+
* @param context Optional evaluation context for targeting rules.
|
|
11989
|
+
*/
|
|
11990
|
+
getStringValue(
|
|
11991
|
+
flagKey: string,
|
|
11992
|
+
defaultValue: string,
|
|
11993
|
+
context?: EvaluationContext,
|
|
11994
|
+
): Promise<string>;
|
|
11995
|
+
/**
|
|
11996
|
+
* Get a number flag value.
|
|
11997
|
+
* @param flagKey The key of the flag to evaluate.
|
|
11998
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
11999
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12000
|
+
*/
|
|
12001
|
+
getNumberValue(
|
|
12002
|
+
flagKey: string,
|
|
12003
|
+
defaultValue: number,
|
|
12004
|
+
context?: EvaluationContext,
|
|
12005
|
+
): Promise<number>;
|
|
12006
|
+
/**
|
|
12007
|
+
* Get an object flag value.
|
|
12008
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12009
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12010
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12011
|
+
*/
|
|
12012
|
+
getObjectValue<T extends object>(
|
|
12013
|
+
flagKey: string,
|
|
12014
|
+
defaultValue: T,
|
|
12015
|
+
context?: EvaluationContext,
|
|
12016
|
+
): Promise<T>;
|
|
12017
|
+
/**
|
|
12018
|
+
* Get a boolean flag value with full evaluation details.
|
|
12019
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12020
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12021
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12022
|
+
*/
|
|
12023
|
+
getBooleanDetails(
|
|
12024
|
+
flagKey: string,
|
|
12025
|
+
defaultValue: boolean,
|
|
12026
|
+
context?: EvaluationContext,
|
|
12027
|
+
): Promise<EvaluationDetails<boolean>>;
|
|
12028
|
+
/**
|
|
12029
|
+
* Get a string flag value with full evaluation details.
|
|
12030
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12031
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12032
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12033
|
+
*/
|
|
12034
|
+
getStringDetails(
|
|
12035
|
+
flagKey: string,
|
|
12036
|
+
defaultValue: string,
|
|
12037
|
+
context?: EvaluationContext,
|
|
12038
|
+
): Promise<EvaluationDetails<string>>;
|
|
12039
|
+
/**
|
|
12040
|
+
* Get a number flag value with full evaluation details.
|
|
12041
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12042
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12043
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12044
|
+
*/
|
|
12045
|
+
getNumberDetails(
|
|
12046
|
+
flagKey: string,
|
|
12047
|
+
defaultValue: number,
|
|
12048
|
+
context?: EvaluationContext,
|
|
12049
|
+
): Promise<EvaluationDetails<number>>;
|
|
12050
|
+
/**
|
|
12051
|
+
* Get an object flag value with full evaluation details.
|
|
12052
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12053
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12054
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12055
|
+
*/
|
|
12056
|
+
getObjectDetails<T extends object>(
|
|
12057
|
+
flagKey: string,
|
|
12058
|
+
defaultValue: T,
|
|
12059
|
+
context?: EvaluationContext,
|
|
12060
|
+
): Promise<EvaluationDetails<T>>;
|
|
12061
|
+
}
|
|
11928
12062
|
/**
|
|
11929
12063
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|
|
11930
12064
|
*/
|
|
@@ -13763,6 +13897,11 @@ declare namespace TailStream {
|
|
|
13763
13897
|
readonly tag?: string;
|
|
13764
13898
|
readonly message?: string;
|
|
13765
13899
|
}
|
|
13900
|
+
interface TracePreviewInfo {
|
|
13901
|
+
readonly id: string;
|
|
13902
|
+
readonly slug: string;
|
|
13903
|
+
readonly name: string;
|
|
13904
|
+
}
|
|
13766
13905
|
interface Onset {
|
|
13767
13906
|
readonly type: "onset";
|
|
13768
13907
|
readonly attributes: Attribute[];
|
|
@@ -13774,6 +13913,7 @@ declare namespace TailStream {
|
|
|
13774
13913
|
readonly scriptName?: string;
|
|
13775
13914
|
readonly scriptTags?: string[];
|
|
13776
13915
|
readonly scriptVersion?: ScriptVersion;
|
|
13916
|
+
readonly preview?: TracePreviewInfo;
|
|
13777
13917
|
readonly info:
|
|
13778
13918
|
| FetchEventInfo
|
|
13779
13919
|
| ConnectEventInfo
|
package/index.ts
CHANGED
|
@@ -11941,6 +11941,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
|
|
|
11941
11941
|
env: Env,
|
|
11942
11942
|
ctx: ExecutionContext<Props>,
|
|
11943
11943
|
) => void | Promise<void>;
|
|
11944
|
+
/**
|
|
11945
|
+
* Evaluation context for targeting rules.
|
|
11946
|
+
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
11947
|
+
*/
|
|
11948
|
+
export type EvaluationContext = Record<string, string | number | boolean>;
|
|
11949
|
+
export interface EvaluationDetails<T> {
|
|
11950
|
+
flagKey: string;
|
|
11951
|
+
value: T;
|
|
11952
|
+
variant?: string | undefined;
|
|
11953
|
+
reason?: string | undefined;
|
|
11954
|
+
errorCode?: string | undefined;
|
|
11955
|
+
errorMessage?: string | undefined;
|
|
11956
|
+
}
|
|
11957
|
+
export interface FlagEvaluationError extends Error {}
|
|
11958
|
+
/**
|
|
11959
|
+
* Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
|
|
11960
|
+
*
|
|
11961
|
+
* @example
|
|
11962
|
+
* ```typescript
|
|
11963
|
+
* // Get a boolean flag value with a default
|
|
11964
|
+
* const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
|
|
11965
|
+
*
|
|
11966
|
+
* // Get a flag value with evaluation context for targeting
|
|
11967
|
+
* const variant = await env.FLAGS.getStringValue('experiment', 'control', {
|
|
11968
|
+
* userId: 'user-123',
|
|
11969
|
+
* country: 'US',
|
|
11970
|
+
* });
|
|
11971
|
+
*
|
|
11972
|
+
* // Get full evaluation details including variant and reason
|
|
11973
|
+
* const details = await env.FLAGS.getBooleanDetails('my-feature', false);
|
|
11974
|
+
* console.log(details.variant, details.reason);
|
|
11975
|
+
* ```
|
|
11976
|
+
*/
|
|
11977
|
+
export declare abstract class Flags {
|
|
11978
|
+
/**
|
|
11979
|
+
* Get a flag value without type checking.
|
|
11980
|
+
* @param flagKey The key of the flag to evaluate.
|
|
11981
|
+
* @param defaultValue Optional default value returned when evaluation fails.
|
|
11982
|
+
* @param context Optional evaluation context for targeting rules.
|
|
11983
|
+
*/
|
|
11984
|
+
get(
|
|
11985
|
+
flagKey: string,
|
|
11986
|
+
defaultValue?: unknown,
|
|
11987
|
+
context?: EvaluationContext,
|
|
11988
|
+
): Promise<unknown>;
|
|
11989
|
+
/**
|
|
11990
|
+
* Get a boolean flag value.
|
|
11991
|
+
* @param flagKey The key of the flag to evaluate.
|
|
11992
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
11993
|
+
* @param context Optional evaluation context for targeting rules.
|
|
11994
|
+
*/
|
|
11995
|
+
getBooleanValue(
|
|
11996
|
+
flagKey: string,
|
|
11997
|
+
defaultValue: boolean,
|
|
11998
|
+
context?: EvaluationContext,
|
|
11999
|
+
): Promise<boolean>;
|
|
12000
|
+
/**
|
|
12001
|
+
* Get a string flag value.
|
|
12002
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12003
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12004
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12005
|
+
*/
|
|
12006
|
+
getStringValue(
|
|
12007
|
+
flagKey: string,
|
|
12008
|
+
defaultValue: string,
|
|
12009
|
+
context?: EvaluationContext,
|
|
12010
|
+
): Promise<string>;
|
|
12011
|
+
/**
|
|
12012
|
+
* Get a number flag value.
|
|
12013
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12014
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12015
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12016
|
+
*/
|
|
12017
|
+
getNumberValue(
|
|
12018
|
+
flagKey: string,
|
|
12019
|
+
defaultValue: number,
|
|
12020
|
+
context?: EvaluationContext,
|
|
12021
|
+
): Promise<number>;
|
|
12022
|
+
/**
|
|
12023
|
+
* Get an object flag value.
|
|
12024
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12025
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12026
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12027
|
+
*/
|
|
12028
|
+
getObjectValue<T extends object>(
|
|
12029
|
+
flagKey: string,
|
|
12030
|
+
defaultValue: T,
|
|
12031
|
+
context?: EvaluationContext,
|
|
12032
|
+
): Promise<T>;
|
|
12033
|
+
/**
|
|
12034
|
+
* Get a boolean flag value with full evaluation details.
|
|
12035
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12036
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12037
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12038
|
+
*/
|
|
12039
|
+
getBooleanDetails(
|
|
12040
|
+
flagKey: string,
|
|
12041
|
+
defaultValue: boolean,
|
|
12042
|
+
context?: EvaluationContext,
|
|
12043
|
+
): Promise<EvaluationDetails<boolean>>;
|
|
12044
|
+
/**
|
|
12045
|
+
* Get a string flag value with full evaluation details.
|
|
12046
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12047
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12048
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12049
|
+
*/
|
|
12050
|
+
getStringDetails(
|
|
12051
|
+
flagKey: string,
|
|
12052
|
+
defaultValue: string,
|
|
12053
|
+
context?: EvaluationContext,
|
|
12054
|
+
): Promise<EvaluationDetails<string>>;
|
|
12055
|
+
/**
|
|
12056
|
+
* Get a number flag value with full evaluation details.
|
|
12057
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12058
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12059
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12060
|
+
*/
|
|
12061
|
+
getNumberDetails(
|
|
12062
|
+
flagKey: string,
|
|
12063
|
+
defaultValue: number,
|
|
12064
|
+
context?: EvaluationContext,
|
|
12065
|
+
): Promise<EvaluationDetails<number>>;
|
|
12066
|
+
/**
|
|
12067
|
+
* Get an object flag value with full evaluation details.
|
|
12068
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12069
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12070
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12071
|
+
*/
|
|
12072
|
+
getObjectDetails<T extends object>(
|
|
12073
|
+
flagKey: string,
|
|
12074
|
+
defaultValue: T,
|
|
12075
|
+
context?: EvaluationContext,
|
|
12076
|
+
): Promise<EvaluationDetails<T>>;
|
|
12077
|
+
}
|
|
11944
12078
|
/**
|
|
11945
12079
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|
|
11946
12080
|
*/
|
|
@@ -13720,6 +13854,11 @@ export declare namespace TailStream {
|
|
|
13720
13854
|
readonly tag?: string;
|
|
13721
13855
|
readonly message?: string;
|
|
13722
13856
|
}
|
|
13857
|
+
interface TracePreviewInfo {
|
|
13858
|
+
readonly id: string;
|
|
13859
|
+
readonly slug: string;
|
|
13860
|
+
readonly name: string;
|
|
13861
|
+
}
|
|
13723
13862
|
interface Onset {
|
|
13724
13863
|
readonly type: "onset";
|
|
13725
13864
|
readonly attributes: Attribute[];
|
|
@@ -13731,6 +13870,7 @@ export declare namespace TailStream {
|
|
|
13731
13870
|
readonly scriptName?: string;
|
|
13732
13871
|
readonly scriptTags?: string[];
|
|
13733
13872
|
readonly scriptVersion?: ScriptVersion;
|
|
13873
|
+
readonly preview?: TracePreviewInfo;
|
|
13734
13874
|
readonly info:
|
|
13735
13875
|
| FetchEventInfo
|
|
13736
13876
|
| ConnectEventInfo
|