@spotify-confidence/sdk
Advanced tools
Comparing version 0.0.7 to 0.1.0
# Changelog | ||
## [0.1.0](https://github.com/spotify/confidence-sdk-js/compare/sdk-v0.0.7...sdk-v0.1.0) (2024-05-31) | ||
### ⚠ BREAKING CHANGES | ||
* react support ([#145](https://github.com/spotify/confidence-sdk-js/issues/145)) | ||
### 🐛 Bug Fixes | ||
* pageviews: handle missed load event ([#148](https://github.com/spotify/confidence-sdk-js/issues/148)) ([ae6bd43](https://github.com/spotify/confidence-sdk-js/commit/ae6bd436c8c66993f722d82d3dbbba7734c79543)) | ||
### ✨ New Features | ||
* react support ([#145](https://github.com/spotify/confidence-sdk-js/issues/145)) ([0493005](https://github.com/spotify/confidence-sdk-js/commit/04930050ef970b8e0481b01fe005321723532ff3)) | ||
## [0.0.7](https://github.com/spotify/confidence-sdk-js/compare/sdk-v0.0.6...sdk-v0.0.7) (2024-05-28) | ||
@@ -4,0 +20,0 @@ |
@@ -1,42 +0,24 @@ | ||
declare interface AppliedFlag { | ||
/** The id of the flag that should be applied, has the format `flags/*`. */ | ||
flag: string; | ||
/** The client time when the flag was applied. */ | ||
applyTime: Date | undefined; | ||
declare class AccessiblePromise<T> { | ||
#private; | ||
protected constructor(value: any, rejected?: boolean); | ||
get state(): 'PENDING' | 'RESOLVED' | 'REJECTED'; | ||
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): AccessiblePromise<TResult1 | TResult2>; | ||
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | undefined | null): AccessiblePromise<T | TResult>; | ||
finally(onfinally?: (() => void) | undefined | null): AccessiblePromise<T>; | ||
orSupply(supplier: () => T): T; | ||
orSuspend(): T; | ||
orThrow(): T; | ||
or(value: T): T; | ||
static resolve<T = void>(value?: T | PromiseLike<T>): AccessiblePromise<T>; | ||
static reject<T = never>(reason?: any): AccessiblePromise<T>; | ||
} | ||
declare const AppliedFlag: { | ||
fromJSON(object: any): AppliedFlag; | ||
toJSON(message: AppliedFlag): unknown; | ||
}; | ||
declare type Applier = (flagName: string) => void; | ||
declare interface ApplyFlagsRequest { | ||
/** The flags to apply and information about when they were applied. */ | ||
flags: AppliedFlag[]; | ||
/** Credentials for the client. */ | ||
clientSecret: string; | ||
/** An opaque token that was returned from `ResolveFlags`; it must be set. */ | ||
resolveToken: Uint8Array; | ||
/** | ||
* The client time when the this request was sent, used for correcting | ||
* clock skew from the client. | ||
*/ | ||
sendTime: Date | undefined; | ||
/** Information about the SDK used to initiate the request. */ | ||
sdk: Sdk | undefined; | ||
export declare namespace Closer { | ||
export function combine(...closers: Closer[]): Closer; | ||
} | ||
declare const ApplyFlagsRequest: { | ||
fromJSON(object: any): ApplyFlagsRequest; | ||
toJSON(message: ApplyFlagsRequest): unknown; | ||
}; | ||
export declare type Closer = () => void; | ||
declare namespace Closer { | ||
function combine(...closers: Closer[]): Closer; | ||
} | ||
declare type Closer = () => void; | ||
export declare class Confidence implements EventSender, Trackable, FlagResolver { | ||
@@ -56,3 +38,3 @@ readonly config: Configuration; | ||
getContext(): Context; | ||
setContext(context: Context): void; | ||
setContext(context: Context): boolean; | ||
clearContext(): void; | ||
@@ -62,4 +44,4 @@ withContext(context: Context): Confidence; | ||
track(manager: Trackable.Manager): Closer; | ||
private resolveFlags; | ||
private get flagState(); | ||
protected resolveFlags(): AccessiblePromise<void>; | ||
get flagState(): State; | ||
subscribe(onStateChange?: StateObserver): () => void; | ||
@@ -82,3 +64,3 @@ private evaluateFlagAsync; | ||
declare interface Configuration { | ||
export declare interface Configuration { | ||
readonly environment: 'client' | 'backend'; | ||
@@ -184,2 +166,6 @@ readonly logger: Logger; | ||
declare namespace FlagResolution { | ||
function create(context: Value.Struct, response: ResolveFlagsResponse, applier?: Applier): FlagResolution; | ||
} | ||
export declare interface FlagResolver extends Contextual<FlagResolver> { | ||
@@ -194,24 +180,6 @@ readonly config: { | ||
declare class FlagResolverClient { | ||
private readonly fetchImplementation; | ||
private readonly clientSecret; | ||
private readonly sdk; | ||
private readonly applyTimeout?; | ||
private readonly baseUrl; | ||
constructor({ fetchImplementation, clientSecret, sdk, applyTimeout, environment, region, }: FlagResolverClientOptions); | ||
declare interface FlagResolverClient { | ||
resolve(context: Context, flags: string[]): PendingResolution; | ||
createApplier(resolveToken: Uint8Array): Applier; | ||
apply(request: ApplyFlagsRequest): Promise<void>; | ||
resolveFlagsJson(request: ResolveFlagsRequest, signal: AbortSignal): Promise<ResolveFlagsResponse>; | ||
} | ||
declare type FlagResolverClientOptions = { | ||
fetchImplementation: SimpleFetch; | ||
clientSecret: string; | ||
sdk: Sdk; | ||
applyTimeout?: number; | ||
environment: 'client' | 'backend'; | ||
region?: 'eu' | 'us'; | ||
}; | ||
/** | ||
@@ -345,5 +313,11 @@ * Schema for the value of a flag. | ||
declare interface PendingResolution extends Promise<FlagResolution> { | ||
readonly context: Value.Struct; | ||
abort(reason?: any): void; | ||
declare class PendingResolution<T = FlagResolution> extends AccessiblePromise<T> { | ||
#private; | ||
protected constructor(promise: PromiseLike<T>, context: Context, controller: AbortController); | ||
get context(): Context; | ||
abort(): void; | ||
then<TResult1 = T, TResult2 = never>(onfulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null | undefined, onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined): PendingResolution<TResult1 | TResult2>; | ||
catch<TResult = never>(onrejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null | undefined): PendingResolution<T | TResult>; | ||
finally(onfinally?: (() => void) | null | undefined): PendingResolution<T>; | ||
static create(context: Context, executor: (signal: AbortSignal) => PromiseLike<FlagResolution>): PendingResolution<FlagResolution>; | ||
} | ||
@@ -390,37 +364,2 @@ | ||
declare interface ResolveFlagsRequest { | ||
/** | ||
* If non-empty, the specific flags are resolved, otherwise all flags | ||
* available to the client will be resolved. | ||
*/ | ||
flags: string[]; | ||
/** | ||
* An object that contains data used in the flag resolve. For example, | ||
* the targeting key e.g. the id of the randomization unit, other attributes | ||
* like country or version that are used for targeting. | ||
*/ | ||
evaluationContext: { | ||
[key: string]: any; | ||
} | undefined; | ||
/** | ||
* Credentials for the client. It is used to identify the client and find | ||
* the flags that are available to it. | ||
*/ | ||
clientSecret: string; | ||
/** | ||
* Determines whether the flags should be applied directly as part of the | ||
* resolve, or delayed until `ApplyFlag` is called. A flag is typically | ||
* applied when it is used, if this occurs much later than the resolve, then | ||
* `apply` should likely be set to false. | ||
*/ | ||
apply: boolean; | ||
/** Information about the SDK used to initiate the request. */ | ||
sdk: Sdk | undefined; | ||
} | ||
declare const ResolveFlagsRequest: { | ||
fromJSON(object: any): ResolveFlagsRequest; | ||
toJSON(message: ResolveFlagsRequest): unknown; | ||
}; | ||
declare interface ResolveFlagsResponse { | ||
@@ -467,52 +406,2 @@ /** | ||
declare interface Sdk { | ||
/** Name of a Confidence SDKs. */ | ||
id?: SdkId | undefined; | ||
/** Custom name for non-Confidence SDKs. */ | ||
customId?: string | undefined; | ||
/** Version of the SDK. */ | ||
version: string; | ||
} | ||
declare const Sdk: { | ||
fromJSON(object: any): Sdk; | ||
toJSON(message: Sdk): unknown; | ||
}; | ||
declare enum SdkId { | ||
/** SDK_ID_UNSPECIFIED - Unspecified enum. */ | ||
SDK_ID_UNSPECIFIED = 0, | ||
/** SDK_ID_JAVA_PROVIDER - Confidence OpenFeature Java Provider. */ | ||
SDK_ID_JAVA_PROVIDER = 1, | ||
/** SDK_ID_KOTLIN_PROVIDER - Confidence OpenFeature Kotlin Provider. */ | ||
SDK_ID_KOTLIN_PROVIDER = 2, | ||
/** SDK_ID_SWIFT_PROVIDER - Confidence OpenFeature Swift Provider. */ | ||
SDK_ID_SWIFT_PROVIDER = 3, | ||
/** SDK_ID_JS_WEB_PROVIDER - Confidence OpenFeature JavaScript Provider for Web (client). */ | ||
SDK_ID_JS_WEB_PROVIDER = 4, | ||
/** SDK_ID_JS_SERVER_PROVIDER - Confidence OpenFeature JavaScript Provider for server. */ | ||
SDK_ID_JS_SERVER_PROVIDER = 5, | ||
/** SDK_ID_PYTHON_PROVIDER - Confidence OpenFeature Python Provider. */ | ||
SDK_ID_PYTHON_PROVIDER = 6, | ||
/** SDK_ID_GO_PROVIDER - Confidence OpenFeature GO Provider. */ | ||
SDK_ID_GO_PROVIDER = 7, | ||
/** SDK_ID_RUBY_PROVIDER - Confidence OpenFeature Ruby Provider. */ | ||
SDK_ID_RUBY_PROVIDER = 8, | ||
/** SDK_ID_RUST_PROVIDER - Confidence OpenFeature Rust Provider. */ | ||
SDK_ID_RUST_PROVIDER = 9, | ||
/** SDK_ID_JAVA_CONFIDENCE - Confidence Java SDK. */ | ||
SDK_ID_JAVA_CONFIDENCE = 10, | ||
/** SDK_ID_KOTLIN_CONFIDENCE - Confidence Kotlin SDK. */ | ||
SDK_ID_KOTLIN_CONFIDENCE = 11, | ||
/** SDK_ID_SWIFT_CONFIDENCE - Confidence Swift SDK. */ | ||
SDK_ID_SWIFT_CONFIDENCE = 12, | ||
/** SDK_ID_JS_CONFIDENCE - Confidence JavaScript SDK. */ | ||
SDK_ID_JS_CONFIDENCE = 13, | ||
/** SDK_ID_PYTHON_CONFIDENCE - Confidence Python SDK. */ | ||
SDK_ID_PYTHON_CONFIDENCE = 14, | ||
/** SDK_ID_GO_CONFIDENCE - Confidence GO SDK. */ | ||
SDK_ID_GO_CONFIDENCE = 15, | ||
UNRECOGNIZED = -1 | ||
} | ||
declare type SimpleFetch = (request: Request) => Promise<Response>; | ||
@@ -526,10 +415,10 @@ | ||
declare namespace Trackable { | ||
type Controller = Pick<Confidence, 'setContext' | 'track' | 'config'>; | ||
type Cleanup = void | Closer; | ||
type Manager = (controller: Controller) => Cleanup; | ||
function setup(controller: Controller, manager: Manager): Closer; | ||
export declare namespace Trackable { | ||
export type Controller = Pick<Confidence, 'setContext' | 'track' | 'config'>; | ||
export type Cleanup = void | Closer; | ||
export type Manager = (controller: Controller) => Cleanup; | ||
export function setup(controller: Controller, manager: Manager): Closer; | ||
} | ||
declare interface Trackable { | ||
export declare interface Trackable { | ||
track(manager: Trackable.Manager): Closer; | ||
@@ -560,2 +449,4 @@ } | ||
export function get(struct: Struct | undefined, ...steps: string[]): Value; | ||
export function serialize(value: Value): string; | ||
export function deserialize(data: string): Value; | ||
} | ||
@@ -562,0 +453,0 @@ |
{ | ||
"name": "@spotify-confidence/sdk", | ||
"license": "Apache-2.0", | ||
"version": "0.0.7", | ||
"version": "0.1.0", | ||
"types": "dist/index.d.ts", | ||
@@ -6,0 +6,0 @@ "engineStrict": true, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
300148
2922
2