@openfeature/flagd-provider 0.3.0 → 0.5.0
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/README.md +32 -16
- package/index.cjs +877 -882
- package/index.js +835 -837
- package/lib/configuration.d.ts +33 -0
- package/lib/flagd-provider.d.ts +9 -13
- package/lib/service/grpc/service.d.ts +9 -12
- package/lib/service/service.d.ts +7 -0
- package/package.json +2 -3
- package/lib/service/Service.d.ts +0 -7
- package/lib/service/http/service.d.ts +0 -16
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export interface Config {
|
|
2
|
+
/**
|
|
3
|
+
* The domain name or IP address of flagd.
|
|
4
|
+
*
|
|
5
|
+
* @default localhost
|
|
6
|
+
*/
|
|
7
|
+
host: string;
|
|
8
|
+
/**
|
|
9
|
+
* The port flagd is listen on.
|
|
10
|
+
*
|
|
11
|
+
* @default 8013
|
|
12
|
+
*/
|
|
13
|
+
port: number;
|
|
14
|
+
/**
|
|
15
|
+
* Determines if TLS should be used.
|
|
16
|
+
*
|
|
17
|
+
* @default false
|
|
18
|
+
*/
|
|
19
|
+
tls: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* When set, a unix socket connection is used.
|
|
22
|
+
*
|
|
23
|
+
* @example "/tmp/flagd.socks"
|
|
24
|
+
*/
|
|
25
|
+
socketPath?: string;
|
|
26
|
+
}
|
|
27
|
+
export declare type FlagdProviderOptions = Partial<Config>;
|
|
28
|
+
export declare function getConfig(options?: FlagdProviderOptions): {
|
|
29
|
+
host: string;
|
|
30
|
+
port: number;
|
|
31
|
+
tls: boolean;
|
|
32
|
+
socketPath?: string | undefined;
|
|
33
|
+
};
|
package/lib/flagd-provider.d.ts
CHANGED
|
@@ -1,18 +1,14 @@
|
|
|
1
|
-
import { EvaluationContext, Provider, ResolutionDetails } from '@openfeature/
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
host?: string;
|
|
5
|
-
port?: number;
|
|
6
|
-
protocol?: 'http' | 'https';
|
|
7
|
-
}
|
|
1
|
+
import { EvaluationContext, JsonValue, Provider, ResolutionDetails } from '@openfeature/js-sdk';
|
|
2
|
+
import { Service } from './service/service';
|
|
3
|
+
import { FlagdProviderOptions } from './configuration';
|
|
8
4
|
export declare class FlagdProvider implements Provider {
|
|
9
5
|
metadata: {
|
|
10
6
|
name: string;
|
|
11
7
|
};
|
|
12
|
-
private readonly
|
|
13
|
-
constructor(options?: FlagdProviderOptions);
|
|
14
|
-
resolveBooleanEvaluation(flagKey: string,
|
|
15
|
-
resolveStringEvaluation(flagKey: string,
|
|
16
|
-
resolveNumberEvaluation(flagKey: string,
|
|
17
|
-
resolveObjectEvaluation<
|
|
8
|
+
private readonly _service;
|
|
9
|
+
constructor(options?: FlagdProviderOptions, service?: Service);
|
|
10
|
+
resolveBooleanEvaluation(flagKey: string, _: boolean, transformedContext: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
11
|
+
resolveStringEvaluation(flagKey: string, _: string, transformedContext: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
12
|
+
resolveNumberEvaluation(flagKey: string, _: number, transformedContext: EvaluationContext): Promise<ResolutionDetails<number>>;
|
|
13
|
+
resolveObjectEvaluation<T extends JsonValue>(flagKey: string, _: T, transformedContext: EvaluationContext): Promise<ResolutionDetails<T>>;
|
|
18
14
|
}
|
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import { EvaluationContext, ResolutionDetails } from '@openfeature/
|
|
1
|
+
import { EvaluationContext, JsonValue, ResolutionDetails } from '@openfeature/js-sdk';
|
|
2
2
|
import { ServiceClient } from '../../../proto/ts/schema/v1/schema.client';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
host: string;
|
|
6
|
-
port: number;
|
|
7
|
-
}
|
|
3
|
+
import { Config } from '../../configuration';
|
|
4
|
+
import { Service } from '../service';
|
|
8
5
|
export declare class GRPCService implements Service {
|
|
9
6
|
client: ServiceClient;
|
|
10
|
-
constructor(
|
|
11
|
-
resolveBoolean(flagKey: string,
|
|
12
|
-
resolveString(flagKey: string,
|
|
13
|
-
resolveNumber(flagKey: string,
|
|
14
|
-
resolveObject<T extends
|
|
7
|
+
constructor(config: Config, client?: ServiceClient);
|
|
8
|
+
resolveBoolean(flagKey: string, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
9
|
+
resolveString(flagKey: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
10
|
+
resolveNumber(flagKey: string, context: EvaluationContext): Promise<ResolutionDetails<number>>;
|
|
11
|
+
resolveObject<T extends JsonValue>(flagKey: string, context: EvaluationContext): Promise<ResolutionDetails<T>>;
|
|
12
|
+
private convertContext;
|
|
15
13
|
}
|
|
16
|
-
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EvaluationContext, JsonValue, ResolutionDetails } from '@openfeature/js-sdk';
|
|
2
|
+
export interface Service {
|
|
3
|
+
resolveBoolean(flagKey: string, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
4
|
+
resolveString(flagKey: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
5
|
+
resolveNumber(flagKey: string, context: EvaluationContext): Promise<ResolutionDetails<number>>;
|
|
6
|
+
resolveObject<T extends JsonValue>(flagKey: string, context: EvaluationContext): Promise<ResolutionDetails<T>>;
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfeature/flagd-provider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"publish-if-not-exists": "cp $NPM_CONFIG_USERCONFIG .npmrc && if [ \"$(npm show $npm_package_name@$npm_package_version version)\" = \"$(npm run current-version -s)\" ]; then echo 'already published, skipping'; else npm publish --access public; fi",
|
|
7
7
|
"current-version": "echo $npm_package_version"
|
|
8
8
|
},
|
|
9
9
|
"peerDependencies": {
|
|
10
|
-
"@openfeature/
|
|
10
|
+
"@openfeature/js-sdk": "^0.4.0"
|
|
11
11
|
},
|
|
12
12
|
"module": "./index.js",
|
|
13
13
|
"main": "./index.cjs",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"axios": "^0.27.2",
|
|
24
23
|
"@protobuf-ts/grpc-transport": "^2.7.0",
|
|
25
24
|
"@grpc/grpc-js": "^1.6.7"
|
|
26
25
|
}
|
package/lib/service/Service.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { EvaluationContext, ResolutionDetails } from '@openfeature/nodejs-sdk';
|
|
2
|
-
export interface Service {
|
|
3
|
-
resolveBoolean(flagKey: string, defaultValue: boolean, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
4
|
-
resolveString(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
5
|
-
resolveNumber(flagKey: string, defaultValue: number, context: EvaluationContext): Promise<ResolutionDetails<number>>;
|
|
6
|
-
resolveObject<T extends object>(flagKey: string, defaultValue: T, context: EvaluationContext): Promise<ResolutionDetails<T>>;
|
|
7
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { EvaluationContext, ResolutionDetails } from '@openfeature/nodejs-sdk';
|
|
2
|
-
import { Service } from '../Service';
|
|
3
|
-
interface HTTPServiceOptions {
|
|
4
|
-
host: string;
|
|
5
|
-
port: number;
|
|
6
|
-
protocol: string;
|
|
7
|
-
}
|
|
8
|
-
export declare class HTTPService implements Service {
|
|
9
|
-
private url;
|
|
10
|
-
constructor(options: HTTPServiceOptions);
|
|
11
|
-
resolveBoolean(flagKey: string, defaultValue: boolean, context: EvaluationContext): Promise<ResolutionDetails<boolean>>;
|
|
12
|
-
resolveNumber(flagKey: string, defaultValue: number, context: EvaluationContext): Promise<ResolutionDetails<number>>;
|
|
13
|
-
resolveString(flagKey: string, defaultValue: string, context: EvaluationContext): Promise<ResolutionDetails<string>>;
|
|
14
|
-
resolveObject<T extends object>(flagKey: string, defaultValue: T, context: EvaluationContext): Promise<ResolutionDetails<T>>;
|
|
15
|
-
}
|
|
16
|
-
export {};
|