@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/index.d.ts
CHANGED
|
@@ -544,6 +544,9 @@ interface AlarmInvocationInfo {
|
|
|
544
544
|
interface Cloudflare {
|
|
545
545
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
546
546
|
}
|
|
547
|
+
declare abstract class ColoLocalActorNamespace {
|
|
548
|
+
get(actorId: string): Fetcher;
|
|
549
|
+
}
|
|
547
550
|
interface DurableObject {
|
|
548
551
|
fetch(request: Request): Response | Promise<Response>;
|
|
549
552
|
connect?(socket: Socket): void | Promise<void>;
|
|
@@ -623,6 +626,7 @@ interface DurableObjectState<Props = unknown> {
|
|
|
623
626
|
readonly id: DurableObjectId;
|
|
624
627
|
readonly storage: DurableObjectStorage;
|
|
625
628
|
container?: Container;
|
|
629
|
+
facets: DurableObjectFacets;
|
|
626
630
|
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
|
|
627
631
|
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
|
|
628
632
|
getWebSockets(tag?: string): WebSocket[];
|
|
@@ -737,6 +741,22 @@ declare class WebSocketRequestResponsePair {
|
|
|
737
741
|
get request(): string;
|
|
738
742
|
get response(): string;
|
|
739
743
|
}
|
|
744
|
+
interface DurableObjectFacets {
|
|
745
|
+
get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
|
|
746
|
+
name: string,
|
|
747
|
+
getStartupOptions: () =>
|
|
748
|
+
| FacetStartupOptions<T>
|
|
749
|
+
| Promise<FacetStartupOptions<T>>,
|
|
750
|
+
): Fetcher<T>;
|
|
751
|
+
abort(name: string, reason: any): void;
|
|
752
|
+
delete(name: string): void;
|
|
753
|
+
}
|
|
754
|
+
interface FacetStartupOptions<
|
|
755
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
756
|
+
> {
|
|
757
|
+
id?: DurableObjectId | string;
|
|
758
|
+
class: DurableObjectClass<T>;
|
|
759
|
+
}
|
|
740
760
|
interface AnalyticsEngineDataset {
|
|
741
761
|
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
|
|
742
762
|
}
|
|
@@ -3757,6 +3777,8 @@ type LoopbackDurableObjectClass<
|
|
|
3757
3777
|
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
|
|
3758
3778
|
? (opts: { props?: Props }) => DurableObjectClass<T>
|
|
3759
3779
|
: (opts: { props?: any }) => DurableObjectClass<T>);
|
|
3780
|
+
interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
|
|
3781
|
+
interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
|
|
3760
3782
|
interface SyncKvStorage {
|
|
3761
3783
|
get<T = unknown>(key: string): T | undefined;
|
|
3762
3784
|
list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
|
|
@@ -3776,6 +3798,10 @@ interface WorkerStub {
|
|
|
3776
3798
|
name?: string,
|
|
3777
3799
|
options?: WorkerStubEntrypointOptions,
|
|
3778
3800
|
): Fetcher<T>;
|
|
3801
|
+
getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
|
|
3802
|
+
name?: string,
|
|
3803
|
+
options?: WorkerStubEntrypointOptions,
|
|
3804
|
+
): DurableObjectClass<T>;
|
|
3779
3805
|
}
|
|
3780
3806
|
interface WorkerStubEntrypointOptions {
|
|
3781
3807
|
props?: any;
|
|
@@ -11899,6 +11925,140 @@ declare module "cloudflare:email" {
|
|
|
11899
11925
|
};
|
|
11900
11926
|
export { _EmailMessage as EmailMessage };
|
|
11901
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
|
+
}
|
|
11902
12062
|
/**
|
|
11903
12063
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|
|
11904
12064
|
*/
|
|
@@ -13737,6 +13897,11 @@ declare namespace TailStream {
|
|
|
13737
13897
|
readonly tag?: string;
|
|
13738
13898
|
readonly message?: string;
|
|
13739
13899
|
}
|
|
13900
|
+
interface TracePreviewInfo {
|
|
13901
|
+
readonly id: string;
|
|
13902
|
+
readonly slug: string;
|
|
13903
|
+
readonly name: string;
|
|
13904
|
+
}
|
|
13740
13905
|
interface Onset {
|
|
13741
13906
|
readonly type: "onset";
|
|
13742
13907
|
readonly attributes: Attribute[];
|
|
@@ -13748,6 +13913,7 @@ declare namespace TailStream {
|
|
|
13748
13913
|
readonly scriptName?: string;
|
|
13749
13914
|
readonly scriptTags?: string[];
|
|
13750
13915
|
readonly scriptVersion?: ScriptVersion;
|
|
13916
|
+
readonly preview?: TracePreviewInfo;
|
|
13751
13917
|
readonly info:
|
|
13752
13918
|
| FetchEventInfo
|
|
13753
13919
|
| ConnectEventInfo
|
package/index.ts
CHANGED
|
@@ -546,6 +546,9 @@ export interface AlarmInvocationInfo {
|
|
|
546
546
|
export interface Cloudflare {
|
|
547
547
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
548
548
|
}
|
|
549
|
+
export declare abstract class ColoLocalActorNamespace {
|
|
550
|
+
get(actorId: string): Fetcher;
|
|
551
|
+
}
|
|
549
552
|
export interface DurableObject {
|
|
550
553
|
fetch(request: Request): Response | Promise<Response>;
|
|
551
554
|
connect?(socket: Socket): void | Promise<void>;
|
|
@@ -625,6 +628,7 @@ export interface DurableObjectState<Props = unknown> {
|
|
|
625
628
|
readonly id: DurableObjectId;
|
|
626
629
|
readonly storage: DurableObjectStorage;
|
|
627
630
|
container?: Container;
|
|
631
|
+
facets: DurableObjectFacets;
|
|
628
632
|
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
|
|
629
633
|
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
|
|
630
634
|
getWebSockets(tag?: string): WebSocket[];
|
|
@@ -739,6 +743,22 @@ export declare class WebSocketRequestResponsePair {
|
|
|
739
743
|
get request(): string;
|
|
740
744
|
get response(): string;
|
|
741
745
|
}
|
|
746
|
+
export interface DurableObjectFacets {
|
|
747
|
+
get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
|
|
748
|
+
name: string,
|
|
749
|
+
getStartupOptions: () =>
|
|
750
|
+
| FacetStartupOptions<T>
|
|
751
|
+
| Promise<FacetStartupOptions<T>>,
|
|
752
|
+
): Fetcher<T>;
|
|
753
|
+
abort(name: string, reason: any): void;
|
|
754
|
+
delete(name: string): void;
|
|
755
|
+
}
|
|
756
|
+
export interface FacetStartupOptions<
|
|
757
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
758
|
+
> {
|
|
759
|
+
id?: DurableObjectId | string;
|
|
760
|
+
class: DurableObjectClass<T>;
|
|
761
|
+
}
|
|
742
762
|
export interface AnalyticsEngineDataset {
|
|
743
763
|
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
|
|
744
764
|
}
|
|
@@ -3763,6 +3783,8 @@ export type LoopbackDurableObjectClass<
|
|
|
3763
3783
|
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
|
|
3764
3784
|
? (opts: { props?: Props }) => DurableObjectClass<T>
|
|
3765
3785
|
: (opts: { props?: any }) => DurableObjectClass<T>);
|
|
3786
|
+
export interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
|
|
3787
|
+
export interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
|
|
3766
3788
|
export interface SyncKvStorage {
|
|
3767
3789
|
get<T = unknown>(key: string): T | undefined;
|
|
3768
3790
|
list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
|
|
@@ -3782,6 +3804,10 @@ export interface WorkerStub {
|
|
|
3782
3804
|
name?: string,
|
|
3783
3805
|
options?: WorkerStubEntrypointOptions,
|
|
3784
3806
|
): Fetcher<T>;
|
|
3807
|
+
getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
|
|
3808
|
+
name?: string,
|
|
3809
|
+
options?: WorkerStubEntrypointOptions,
|
|
3810
|
+
): DurableObjectClass<T>;
|
|
3785
3811
|
}
|
|
3786
3812
|
export interface WorkerStubEntrypointOptions {
|
|
3787
3813
|
props?: any;
|
|
@@ -11915,6 +11941,140 @@ export declare type EmailExportedHandler<Env = unknown, Props = unknown> = (
|
|
|
11915
11941
|
env: Env,
|
|
11916
11942
|
ctx: ExecutionContext<Props>,
|
|
11917
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
|
+
}
|
|
11918
12078
|
/**
|
|
11919
12079
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|
|
11920
12080
|
*/
|
|
@@ -13694,6 +13854,11 @@ export declare namespace TailStream {
|
|
|
13694
13854
|
readonly tag?: string;
|
|
13695
13855
|
readonly message?: string;
|
|
13696
13856
|
}
|
|
13857
|
+
interface TracePreviewInfo {
|
|
13858
|
+
readonly id: string;
|
|
13859
|
+
readonly slug: string;
|
|
13860
|
+
readonly name: string;
|
|
13861
|
+
}
|
|
13697
13862
|
interface Onset {
|
|
13698
13863
|
readonly type: "onset";
|
|
13699
13864
|
readonly attributes: Attribute[];
|
|
@@ -13705,6 +13870,7 @@ export declare namespace TailStream {
|
|
|
13705
13870
|
readonly scriptName?: string;
|
|
13706
13871
|
readonly scriptTags?: string[];
|
|
13707
13872
|
readonly scriptVersion?: ScriptVersion;
|
|
13873
|
+
readonly preview?: TracePreviewInfo;
|
|
13708
13874
|
readonly info:
|
|
13709
13875
|
| FetchEventInfo
|
|
13710
13876
|
| ConnectEventInfo
|
package/latest/index.d.ts
CHANGED
|
@@ -562,6 +562,9 @@ interface AlarmInvocationInfo {
|
|
|
562
562
|
interface Cloudflare {
|
|
563
563
|
readonly compatibilityFlags: Record<string, boolean>;
|
|
564
564
|
}
|
|
565
|
+
declare abstract class ColoLocalActorNamespace {
|
|
566
|
+
get(actorId: string): Fetcher;
|
|
567
|
+
}
|
|
565
568
|
interface DurableObject {
|
|
566
569
|
fetch(request: Request): Response | Promise<Response>;
|
|
567
570
|
connect?(socket: Socket): void | Promise<void>;
|
|
@@ -642,6 +645,7 @@ interface DurableObjectState<Props = unknown> {
|
|
|
642
645
|
readonly id: DurableObjectId;
|
|
643
646
|
readonly storage: DurableObjectStorage;
|
|
644
647
|
container?: Container;
|
|
648
|
+
facets: DurableObjectFacets;
|
|
645
649
|
blockConcurrencyWhile<T>(callback: () => Promise<T>): Promise<T>;
|
|
646
650
|
acceptWebSocket(ws: WebSocket, tags?: string[]): void;
|
|
647
651
|
getWebSockets(tag?: string): WebSocket[];
|
|
@@ -756,6 +760,22 @@ declare class WebSocketRequestResponsePair {
|
|
|
756
760
|
get request(): string;
|
|
757
761
|
get response(): string;
|
|
758
762
|
}
|
|
763
|
+
interface DurableObjectFacets {
|
|
764
|
+
get<T extends Rpc.DurableObjectBranded | undefined = undefined>(
|
|
765
|
+
name: string,
|
|
766
|
+
getStartupOptions: () =>
|
|
767
|
+
| FacetStartupOptions<T>
|
|
768
|
+
| Promise<FacetStartupOptions<T>>,
|
|
769
|
+
): Fetcher<T>;
|
|
770
|
+
abort(name: string, reason: any): void;
|
|
771
|
+
delete(name: string): void;
|
|
772
|
+
}
|
|
773
|
+
interface FacetStartupOptions<
|
|
774
|
+
T extends Rpc.DurableObjectBranded | undefined = undefined,
|
|
775
|
+
> {
|
|
776
|
+
id?: DurableObjectId | string;
|
|
777
|
+
class: DurableObjectClass<T>;
|
|
778
|
+
}
|
|
759
779
|
interface AnalyticsEngineDataset {
|
|
760
780
|
writeDataPoint(event?: AnalyticsEngineDataPoint): void;
|
|
761
781
|
}
|
|
@@ -3897,6 +3917,8 @@ type LoopbackDurableObjectClass<
|
|
|
3897
3917
|
(T extends CloudflareWorkersModule.DurableObject<any, infer Props>
|
|
3898
3918
|
? (opts: { props?: Props }) => DurableObjectClass<T>
|
|
3899
3919
|
: (opts: { props?: any }) => DurableObjectClass<T>);
|
|
3920
|
+
interface LoopbackDurableObjectNamespace extends DurableObjectNamespace {}
|
|
3921
|
+
interface LoopbackColoLocalActorNamespace extends ColoLocalActorNamespace {}
|
|
3900
3922
|
interface SyncKvStorage {
|
|
3901
3923
|
get<T = unknown>(key: string): T | undefined;
|
|
3902
3924
|
list<T = unknown>(options?: SyncKvListOptions): Iterable<[string, T]>;
|
|
@@ -3916,6 +3938,10 @@ interface WorkerStub {
|
|
|
3916
3938
|
name?: string,
|
|
3917
3939
|
options?: WorkerStubEntrypointOptions,
|
|
3918
3940
|
): Fetcher<T>;
|
|
3941
|
+
getDurableObjectClass<T extends Rpc.DurableObjectBranded | undefined>(
|
|
3942
|
+
name?: string,
|
|
3943
|
+
options?: WorkerStubEntrypointOptions,
|
|
3944
|
+
): DurableObjectClass<T>;
|
|
3919
3945
|
}
|
|
3920
3946
|
interface WorkerStubEntrypointOptions {
|
|
3921
3947
|
props?: any;
|
|
@@ -12039,6 +12065,140 @@ declare module "cloudflare:email" {
|
|
|
12039
12065
|
};
|
|
12040
12066
|
export { _EmailMessage as EmailMessage };
|
|
12041
12067
|
}
|
|
12068
|
+
/**
|
|
12069
|
+
* Evaluation context for targeting rules.
|
|
12070
|
+
* Keys are attribute names (e.g. "userId", "country"), values are the attribute values.
|
|
12071
|
+
*/
|
|
12072
|
+
type EvaluationContext = Record<string, string | number | boolean>;
|
|
12073
|
+
interface EvaluationDetails<T> {
|
|
12074
|
+
flagKey: string;
|
|
12075
|
+
value: T;
|
|
12076
|
+
variant?: string | undefined;
|
|
12077
|
+
reason?: string | undefined;
|
|
12078
|
+
errorCode?: string | undefined;
|
|
12079
|
+
errorMessage?: string | undefined;
|
|
12080
|
+
}
|
|
12081
|
+
interface FlagEvaluationError extends Error {}
|
|
12082
|
+
/**
|
|
12083
|
+
* Feature flags binding for evaluating feature flags from a Cloudflare Workers script.
|
|
12084
|
+
*
|
|
12085
|
+
* @example
|
|
12086
|
+
* ```typescript
|
|
12087
|
+
* // Get a boolean flag value with a default
|
|
12088
|
+
* const enabled = await env.FLAGS.getBooleanValue('my-feature', false);
|
|
12089
|
+
*
|
|
12090
|
+
* // Get a flag value with evaluation context for targeting
|
|
12091
|
+
* const variant = await env.FLAGS.getStringValue('experiment', 'control', {
|
|
12092
|
+
* userId: 'user-123',
|
|
12093
|
+
* country: 'US',
|
|
12094
|
+
* });
|
|
12095
|
+
*
|
|
12096
|
+
* // Get full evaluation details including variant and reason
|
|
12097
|
+
* const details = await env.FLAGS.getBooleanDetails('my-feature', false);
|
|
12098
|
+
* console.log(details.variant, details.reason);
|
|
12099
|
+
* ```
|
|
12100
|
+
*/
|
|
12101
|
+
declare abstract class Flags {
|
|
12102
|
+
/**
|
|
12103
|
+
* Get a flag value without type checking.
|
|
12104
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12105
|
+
* @param defaultValue Optional default value returned when evaluation fails.
|
|
12106
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12107
|
+
*/
|
|
12108
|
+
get(
|
|
12109
|
+
flagKey: string,
|
|
12110
|
+
defaultValue?: unknown,
|
|
12111
|
+
context?: EvaluationContext,
|
|
12112
|
+
): Promise<unknown>;
|
|
12113
|
+
/**
|
|
12114
|
+
* Get a boolean flag value.
|
|
12115
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12116
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12117
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12118
|
+
*/
|
|
12119
|
+
getBooleanValue(
|
|
12120
|
+
flagKey: string,
|
|
12121
|
+
defaultValue: boolean,
|
|
12122
|
+
context?: EvaluationContext,
|
|
12123
|
+
): Promise<boolean>;
|
|
12124
|
+
/**
|
|
12125
|
+
* Get a string flag value.
|
|
12126
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12127
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12128
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12129
|
+
*/
|
|
12130
|
+
getStringValue(
|
|
12131
|
+
flagKey: string,
|
|
12132
|
+
defaultValue: string,
|
|
12133
|
+
context?: EvaluationContext,
|
|
12134
|
+
): Promise<string>;
|
|
12135
|
+
/**
|
|
12136
|
+
* Get a number flag value.
|
|
12137
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12138
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12139
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12140
|
+
*/
|
|
12141
|
+
getNumberValue(
|
|
12142
|
+
flagKey: string,
|
|
12143
|
+
defaultValue: number,
|
|
12144
|
+
context?: EvaluationContext,
|
|
12145
|
+
): Promise<number>;
|
|
12146
|
+
/**
|
|
12147
|
+
* Get an object flag value.
|
|
12148
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12149
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12150
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12151
|
+
*/
|
|
12152
|
+
getObjectValue<T extends object>(
|
|
12153
|
+
flagKey: string,
|
|
12154
|
+
defaultValue: T,
|
|
12155
|
+
context?: EvaluationContext,
|
|
12156
|
+
): Promise<T>;
|
|
12157
|
+
/**
|
|
12158
|
+
* Get a boolean flag value with full evaluation details.
|
|
12159
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12160
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12161
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12162
|
+
*/
|
|
12163
|
+
getBooleanDetails(
|
|
12164
|
+
flagKey: string,
|
|
12165
|
+
defaultValue: boolean,
|
|
12166
|
+
context?: EvaluationContext,
|
|
12167
|
+
): Promise<EvaluationDetails<boolean>>;
|
|
12168
|
+
/**
|
|
12169
|
+
* Get a string flag value with full evaluation details.
|
|
12170
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12171
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12172
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12173
|
+
*/
|
|
12174
|
+
getStringDetails(
|
|
12175
|
+
flagKey: string,
|
|
12176
|
+
defaultValue: string,
|
|
12177
|
+
context?: EvaluationContext,
|
|
12178
|
+
): Promise<EvaluationDetails<string>>;
|
|
12179
|
+
/**
|
|
12180
|
+
* Get a number flag value with full evaluation details.
|
|
12181
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12182
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12183
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12184
|
+
*/
|
|
12185
|
+
getNumberDetails(
|
|
12186
|
+
flagKey: string,
|
|
12187
|
+
defaultValue: number,
|
|
12188
|
+
context?: EvaluationContext,
|
|
12189
|
+
): Promise<EvaluationDetails<number>>;
|
|
12190
|
+
/**
|
|
12191
|
+
* Get an object flag value with full evaluation details.
|
|
12192
|
+
* @param flagKey The key of the flag to evaluate.
|
|
12193
|
+
* @param defaultValue Default value returned when evaluation fails or the flag type does not match.
|
|
12194
|
+
* @param context Optional evaluation context for targeting rules.
|
|
12195
|
+
*/
|
|
12196
|
+
getObjectDetails<T extends object>(
|
|
12197
|
+
flagKey: string,
|
|
12198
|
+
defaultValue: T,
|
|
12199
|
+
context?: EvaluationContext,
|
|
12200
|
+
): Promise<EvaluationDetails<T>>;
|
|
12201
|
+
}
|
|
12042
12202
|
/**
|
|
12043
12203
|
* Hello World binding to serve as an explanatory example. DO NOT USE
|
|
12044
12204
|
*/
|
|
@@ -13877,6 +14037,11 @@ declare namespace TailStream {
|
|
|
13877
14037
|
readonly tag?: string;
|
|
13878
14038
|
readonly message?: string;
|
|
13879
14039
|
}
|
|
14040
|
+
interface TracePreviewInfo {
|
|
14041
|
+
readonly id: string;
|
|
14042
|
+
readonly slug: string;
|
|
14043
|
+
readonly name: string;
|
|
14044
|
+
}
|
|
13880
14045
|
interface Onset {
|
|
13881
14046
|
readonly type: "onset";
|
|
13882
14047
|
readonly attributes: Attribute[];
|
|
@@ -13888,6 +14053,7 @@ declare namespace TailStream {
|
|
|
13888
14053
|
readonly scriptName?: string;
|
|
13889
14054
|
readonly scriptTags?: string[];
|
|
13890
14055
|
readonly scriptVersion?: ScriptVersion;
|
|
14056
|
+
readonly preview?: TracePreviewInfo;
|
|
13891
14057
|
readonly info:
|
|
13892
14058
|
| FetchEventInfo
|
|
13893
14059
|
| ConnectEventInfo
|