@openfeature/flagd-provider 0.7.7 → 0.8.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/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@openfeature/flagd-provider",
3
- "version": "0.7.7",
3
+ "version": "0.8.0",
4
4
  "scripts": {
5
5
  "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",
6
6
  "current-version": "echo $npm_package_version"
7
7
  },
8
8
  "peerDependencies": {
9
9
  "@grpc/grpc-js": "^1.6.0",
10
- "@openfeature/js-sdk": "^1.1.0"
10
+ "@openfeature/js-sdk": ">=1.3.0"
11
11
  },
12
12
  "module": "./index.js",
13
13
  "main": "./index.cjs",
@@ -21,7 +21,6 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "@protobuf-ts/grpc-transport": "2.9.0",
25
24
  "@protobuf-ts/runtime-rpc": "2.9.0",
26
25
  "lru-cache": "10.0.0"
27
26
  }
@@ -1,4 +1,4 @@
1
- import { EvaluationContext, JsonValue, Logger, Provider, ResolutionDetails } from '@openfeature/js-sdk';
1
+ import { EvaluationContext, JsonValue, Logger, OpenFeatureEventEmitter, Provider, ProviderStatus, ResolutionDetails } from '@openfeature/js-sdk';
2
2
  import { FlagdProviderOptions } from './configuration';
3
3
  import { Service } from './service/service';
4
4
  export declare class FlagdProvider implements Provider {
@@ -6,20 +6,27 @@ export declare class FlagdProvider implements Provider {
6
6
  metadata: {
7
7
  name: string;
8
8
  };
9
+ get status(): ProviderStatus;
10
+ get events(): OpenFeatureEventEmitter;
9
11
  private readonly _service;
12
+ private _status;
13
+ private _events;
10
14
  /**
11
- * Promise indicating the gRPC stream is connected.
15
+ * Construct a new flagd provider.
12
16
  *
13
- * Can be used in instances where the provider being connected to the event stream is a prerequisite
14
- * to execution (e.g. testing). Not necessary for standard usage.
15
- *
16
- * @returns true if stream connected successfully, false if connection not enabled.
17
+ * @param options options, see {@link FlagdProviderOptions}
18
+ * @param logger optional logger, see {@link Logger}
19
+ * @param service optional internal service implementation, should not be needed for production
17
20
  */
18
- get streamConnection(): Promise<boolean>;
19
- constructor(options?: FlagdProviderOptions, service?: Service, logger?: Logger | undefined);
21
+ constructor(options?: FlagdProviderOptions, logger?: Logger | undefined, service?: Service);
22
+ initialize(): Promise<void>;
23
+ onClose(): Promise<void>;
20
24
  resolveBooleanEvaluation(flagKey: string, _: boolean, transformedContext: EvaluationContext, logger: Logger): Promise<ResolutionDetails<boolean>>;
21
25
  resolveStringEvaluation(flagKey: string, _: string, transformedContext: EvaluationContext, logger: Logger): Promise<ResolutionDetails<string>>;
22
26
  resolveNumberEvaluation(flagKey: string, _: number, transformedContext: EvaluationContext, logger: Logger): Promise<ResolutionDetails<number>>;
23
27
  resolveObjectEvaluation<T extends JsonValue>(flagKey: string, _: T, transformedContext: EvaluationContext, logger: Logger): Promise<ResolutionDetails<T>>;
24
28
  logRejected: (err: Error, flagKey: string, logger: Logger) => never;
29
+ private setReady;
30
+ private setError;
31
+ private emitChanged;
25
32
  }
@@ -1,5 +1,5 @@
1
1
  import { EvaluationContext, JsonValue, Logger, ResolutionDetails } from '@openfeature/js-sdk';
2
- import { ServiceClient } from '../../../proto/ts/schema/v1/schema.client';
2
+ import { ServiceClient } from '../../../proto/ts/schema/v1/schema';
3
3
  import { Config } from '../../configuration';
4
4
  import { Service } from '../service';
5
5
  interface FlagChange {
@@ -25,11 +25,13 @@ export declare class GRPCService implements Service {
25
25
  private _cacheEnabled;
26
26
  private _streamAlive;
27
27
  private _streamConnectAttempt;
28
+ private _stream;
28
29
  private _streamConnectBackoff;
29
30
  private _maxEventStreamRetries;
30
31
  private get _cacheActive();
31
- readonly streamConnection: Promise<boolean>;
32
32
  constructor(config: Config, client?: ServiceClient, logger?: Logger | undefined);
33
+ connect(connectCallback: () => void, changedCallback: (flagsChanged: string[]) => void, disconnectCallback: () => void): Promise<void>;
34
+ disconnect(): Promise<void>;
33
35
  resolveBoolean(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<boolean>>;
34
36
  resolveString(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<string>>;
35
37
  resolveNumber(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<number>>;
@@ -38,13 +40,12 @@ export declare class GRPCService implements Service {
38
40
  private handleProviderReady;
39
41
  private handleFlagsChanged;
40
42
  private handleError;
41
- private handleComplete;
43
+ private handleClose;
42
44
  private objectParser;
43
45
  private booleanParser;
44
46
  private stringParser;
45
47
  private numberParser;
46
48
  private resolve;
47
- private convertContext;
48
49
  private onRejected;
49
50
  }
50
51
  export {};
@@ -1,6 +1,7 @@
1
1
  import { EvaluationContext, JsonValue, Logger, ResolutionDetails } from '@openfeature/js-sdk';
2
2
  export interface Service {
3
- readonly streamConnection: Promise<boolean>;
3
+ connect(reconnectCallback: () => void, changedCallback: (flagsChanged: string[]) => void, disconnectCallback: () => void): Promise<void>;
4
+ disconnect(): Promise<void>;
4
5
  resolveBoolean(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<boolean>>;
5
6
  resolveString(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<string>>;
6
7
  resolveNumber(flagKey: string, context: EvaluationContext, logger: Logger): Promise<ResolutionDetails<number>>;
@@ -1,12 +1,18 @@
1
- import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
2
- import type { IBinaryWriter } from "@protobuf-ts/runtime";
3
- import type { BinaryReadOptions } from "@protobuf-ts/runtime";
4
- import type { IBinaryReader } from "@protobuf-ts/runtime";
5
- import type { PartialMessage } from "@protobuf-ts/runtime";
6
- import type { JsonValue } from "@protobuf-ts/runtime";
7
- import type { JsonReadOptions } from "@protobuf-ts/runtime";
8
- import type { JsonWriteOptions } from "@protobuf-ts/runtime";
9
- import { MessageType } from "@protobuf-ts/runtime";
1
+ import _m0 from "protobufjs/minimal";
2
+ export declare const protobufPackage = "google.protobuf";
3
+ /**
4
+ * `NullValue` is a singleton enumeration to represent the null value for the
5
+ * `Value` type union.
6
+ *
7
+ * The JSON representation for `NullValue` is JSON `null`.
8
+ */
9
+ export declare enum NullValue {
10
+ /** NULL_VALUE - Null value. */
11
+ NULL_VALUE = 0,
12
+ UNRECOGNIZED = -1
13
+ }
14
+ export declare function nullValueFromJSON(object: any): NullValue;
15
+ export declare function nullValueToJSON(object: NullValue): string;
10
16
  /**
11
17
  * `Struct` represents a structured data value, consisting of fields
12
18
  * which map to dynamically typed values. In some languages, `Struct`
@@ -16,19 +22,17 @@ import { MessageType } from "@protobuf-ts/runtime";
16
22
  * with the proto support for the language.
17
23
  *
18
24
  * The JSON representation for `Struct` is JSON object.
19
- *
20
- * @generated from protobuf message google.protobuf.Struct
21
25
  */
22
26
  export interface Struct {
23
- /**
24
- * Unordered map of dynamically typed values.
25
- *
26
- * @generated from protobuf field: map<string, google.protobuf.Value> fields = 1;
27
- */
27
+ /** Unordered map of dynamically typed values. */
28
28
  fields: {
29
- [key: string]: Value;
29
+ [key: string]: any | undefined;
30
30
  };
31
31
  }
32
+ export interface Struct_FieldsEntry {
33
+ key: string;
34
+ value: any | undefined;
35
+ }
32
36
  /**
33
37
  * `Value` represents a dynamically typed value which can be either
34
38
  * null, a number, a string, a boolean, a recursive struct value, or a
@@ -36,149 +40,162 @@ export interface Struct {
36
40
  * variants. Absence of any variant indicates an error.
37
41
  *
38
42
  * The JSON representation for `Value` is JSON value.
39
- *
40
- * @generated from protobuf message google.protobuf.Value
41
43
  */
42
44
  export interface Value {
43
- /**
44
- * @generated from protobuf oneof: kind
45
- */
46
- kind: {
47
- oneofKind: "nullValue";
48
- /**
49
- * Represents a null value.
50
- *
51
- * @generated from protobuf field: google.protobuf.NullValue null_value = 1;
52
- */
53
- nullValue: NullValue;
54
- } | {
55
- oneofKind: "numberValue";
56
- /**
57
- * Represents a double value.
58
- *
59
- * @generated from protobuf field: double number_value = 2;
60
- */
61
- numberValue: number;
62
- } | {
63
- oneofKind: "stringValue";
64
- /**
65
- * Represents a string value.
66
- *
67
- * @generated from protobuf field: string string_value = 3;
68
- */
69
- stringValue: string;
70
- } | {
71
- oneofKind: "boolValue";
72
- /**
73
- * Represents a boolean value.
74
- *
75
- * @generated from protobuf field: bool bool_value = 4;
76
- */
77
- boolValue: boolean;
78
- } | {
79
- oneofKind: "structValue";
80
- /**
81
- * Represents a structured value.
82
- *
83
- * @generated from protobuf field: google.protobuf.Struct struct_value = 5;
84
- */
85
- structValue: Struct;
86
- } | {
87
- oneofKind: "listValue";
88
- /**
89
- * Represents a repeated `Value`.
90
- *
91
- * @generated from protobuf field: google.protobuf.ListValue list_value = 6;
92
- */
93
- listValue: ListValue;
94
- } | {
95
- oneofKind: undefined;
96
- };
45
+ /** Represents a null value. */
46
+ nullValue?: NullValue | undefined;
47
+ /** Represents a double value. */
48
+ numberValue?: number | undefined;
49
+ /** Represents a string value. */
50
+ stringValue?: string | undefined;
51
+ /** Represents a boolean value. */
52
+ boolValue?: boolean | undefined;
53
+ /** Represents a structured value. */
54
+ structValue?: {
55
+ [key: string]: any;
56
+ } | undefined;
57
+ /** Represents a repeated `Value`. */
58
+ listValue?: Array<any> | undefined;
97
59
  }
98
60
  /**
99
61
  * `ListValue` is a wrapper around a repeated field of values.
100
62
  *
101
63
  * The JSON representation for `ListValue` is JSON array.
102
- *
103
- * @generated from protobuf message google.protobuf.ListValue
104
64
  */
105
65
  export interface ListValue {
106
- /**
107
- * Repeated field of dynamically typed values.
108
- *
109
- * @generated from protobuf field: repeated google.protobuf.Value values = 1;
110
- */
111
- values: Value[];
112
- }
113
- /**
114
- * `NullValue` is a singleton enumeration to represent the null value for the
115
- * `Value` type union.
116
- *
117
- * The JSON representation for `NullValue` is JSON `null`.
118
- *
119
- * @generated from protobuf enum google.protobuf.NullValue
120
- */
121
- export declare enum NullValue {
122
- /**
123
- * Null value.
124
- *
125
- * @generated from protobuf enum value: NULL_VALUE = 0;
126
- */
127
- NULL_VALUE = 0
128
- }
129
- declare class Struct$Type extends MessageType<Struct> {
130
- constructor();
131
- /**
132
- * Encode `Struct` to JSON object.
133
- */
134
- internalJsonWrite(message: Struct, options: JsonWriteOptions): JsonValue;
135
- /**
136
- * Decode `Struct` from JSON object.
137
- */
138
- internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Struct): Struct;
139
- create(value?: PartialMessage<Struct>): Struct;
140
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Struct): Struct;
141
- private binaryReadMap1;
142
- internalBinaryWrite(message: Struct, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
143
- }
144
- /**
145
- * @generated MessageType for protobuf message google.protobuf.Struct
146
- */
147
- export declare const Struct: Struct$Type;
148
- declare class Value$Type extends MessageType<Value> {
149
- constructor();
150
- /**
151
- * Encode `Value` to JSON value.
152
- */
153
- internalJsonWrite(message: Value, options: JsonWriteOptions): JsonValue;
154
- /**
155
- * Decode `Value` from JSON value.
156
- */
157
- internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: Value): Value;
158
- create(value?: PartialMessage<Value>): Value;
159
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: Value): Value;
160
- internalBinaryWrite(message: Value, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
161
- }
162
- /**
163
- * @generated MessageType for protobuf message google.protobuf.Value
164
- */
165
- export declare const Value: Value$Type;
166
- declare class ListValue$Type extends MessageType<ListValue> {
167
- constructor();
168
- /**
169
- * Encode `ListValue` to JSON array.
170
- */
171
- internalJsonWrite(message: ListValue, options: JsonWriteOptions): JsonValue;
172
- /**
173
- * Decode `ListValue` from JSON array.
174
- */
175
- internalJsonRead(json: JsonValue, options: JsonReadOptions, target?: ListValue): ListValue;
176
- create(value?: PartialMessage<ListValue>): ListValue;
177
- internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ListValue): ListValue;
178
- internalBinaryWrite(message: ListValue, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter;
66
+ /** Repeated field of dynamically typed values. */
67
+ values: any[];
179
68
  }
180
- /**
181
- * @generated MessageType for protobuf message google.protobuf.ListValue
182
- */
183
- export declare const ListValue: ListValue$Type;
69
+ export declare const Struct: {
70
+ encode(message: Struct, writer?: _m0.Writer): _m0.Writer;
71
+ decode(input: _m0.Reader | Uint8Array, length?: number): Struct;
72
+ fromJSON(object: any): Struct;
73
+ toJSON(message: Struct): unknown;
74
+ create<I extends {
75
+ fields?: {
76
+ [x: string]: any;
77
+ } | undefined;
78
+ } & {
79
+ fields?: ({
80
+ [x: string]: any;
81
+ } & {
82
+ [x: string]: any;
83
+ } & { [K in Exclude<keyof I["fields"], string | number>]: never; }) | undefined;
84
+ } & { [K_1 in Exclude<keyof I, "fields">]: never; }>(base?: I | undefined): Struct;
85
+ fromPartial<I_1 extends {
86
+ fields?: {
87
+ [x: string]: any;
88
+ } | undefined;
89
+ } & {
90
+ fields?: ({
91
+ [x: string]: any;
92
+ } & {
93
+ [x: string]: any;
94
+ } & { [K_2 in Exclude<keyof I_1["fields"], string | number>]: never; }) | undefined;
95
+ } & { [K_3 in Exclude<keyof I_1, "fields">]: never; }>(object: I_1): Struct;
96
+ wrap(object: {
97
+ [key: string]: any;
98
+ } | undefined): Struct;
99
+ unwrap(message: Struct): {
100
+ [key: string]: any;
101
+ };
102
+ };
103
+ export declare const Struct_FieldsEntry: {
104
+ encode(message: Struct_FieldsEntry, writer?: _m0.Writer): _m0.Writer;
105
+ decode(input: _m0.Reader | Uint8Array, length?: number): Struct_FieldsEntry;
106
+ fromJSON(object: any): Struct_FieldsEntry;
107
+ toJSON(message: Struct_FieldsEntry): unknown;
108
+ create<I extends {
109
+ key?: string | undefined;
110
+ value?: any | undefined;
111
+ } & {
112
+ key?: string | undefined;
113
+ value?: any | undefined;
114
+ } & { [K in Exclude<keyof I, keyof Struct_FieldsEntry>]: never; }>(base?: I | undefined): Struct_FieldsEntry;
115
+ fromPartial<I_1 extends {
116
+ key?: string | undefined;
117
+ value?: any | undefined;
118
+ } & {
119
+ key?: string | undefined;
120
+ value?: any | undefined;
121
+ } & { [K_1 in Exclude<keyof I_1, keyof Struct_FieldsEntry>]: never; }>(object: I_1): Struct_FieldsEntry;
122
+ };
123
+ export declare const Value: {
124
+ encode(message: Value, writer?: _m0.Writer): _m0.Writer;
125
+ decode(input: _m0.Reader | Uint8Array, length?: number): Value;
126
+ fromJSON(object: any): Value;
127
+ toJSON(message: Value): unknown;
128
+ create<I extends {
129
+ nullValue?: NullValue | undefined;
130
+ numberValue?: number | undefined;
131
+ stringValue?: string | undefined;
132
+ boolValue?: boolean | undefined;
133
+ structValue?: {
134
+ [x: string]: any;
135
+ } | undefined;
136
+ listValue?: any[] | undefined;
137
+ } & {
138
+ nullValue?: NullValue | undefined;
139
+ numberValue?: number | undefined;
140
+ stringValue?: string | undefined;
141
+ boolValue?: boolean | undefined;
142
+ structValue?: ({
143
+ [x: string]: any;
144
+ } & {
145
+ [x: string]: any;
146
+ } & { [K in Exclude<keyof I["structValue"], string | number>]: never; }) | undefined;
147
+ listValue?: (any[] & any[] & { [K_1 in Exclude<keyof I["listValue"], keyof any[]>]: never; }) | undefined;
148
+ } & { [K_2 in Exclude<keyof I, keyof Value>]: never; }>(base?: I | undefined): Value;
149
+ fromPartial<I_1 extends {
150
+ nullValue?: NullValue | undefined;
151
+ numberValue?: number | undefined;
152
+ stringValue?: string | undefined;
153
+ boolValue?: boolean | undefined;
154
+ structValue?: {
155
+ [x: string]: any;
156
+ } | undefined;
157
+ listValue?: any[] | undefined;
158
+ } & {
159
+ nullValue?: NullValue | undefined;
160
+ numberValue?: number | undefined;
161
+ stringValue?: string | undefined;
162
+ boolValue?: boolean | undefined;
163
+ structValue?: ({
164
+ [x: string]: any;
165
+ } & {
166
+ [x: string]: any;
167
+ } & { [K_3 in Exclude<keyof I_1["structValue"], string | number>]: never; }) | undefined;
168
+ listValue?: (any[] & any[] & { [K_4 in Exclude<keyof I_1["listValue"], keyof any[]>]: never; }) | undefined;
169
+ } & { [K_5 in Exclude<keyof I_1, keyof Value>]: never; }>(object: I_1): Value;
170
+ wrap(value: any): Value;
171
+ unwrap(message: any): string | number | boolean | Object | null | Array<any> | undefined;
172
+ };
173
+ export declare const ListValue: {
174
+ encode(message: ListValue, writer?: _m0.Writer): _m0.Writer;
175
+ decode(input: _m0.Reader | Uint8Array, length?: number): ListValue;
176
+ fromJSON(object: any): ListValue;
177
+ toJSON(message: ListValue): unknown;
178
+ create<I extends {
179
+ values?: any[] | undefined;
180
+ } & {
181
+ values?: (any[] & any[] & { [K in Exclude<keyof I["values"], keyof any[]>]: never; }) | undefined;
182
+ } & { [K_1 in Exclude<keyof I, "values">]: never; }>(base?: I | undefined): ListValue;
183
+ fromPartial<I_1 extends {
184
+ values?: any[] | undefined;
185
+ } & {
186
+ values?: (any[] & any[] & { [K_2 in Exclude<keyof I_1["values"], keyof any[]>]: never; }) | undefined;
187
+ } & { [K_3 in Exclude<keyof I_1, "values">]: never; }>(object: I_1): ListValue;
188
+ wrap(array: Array<any> | undefined): ListValue;
189
+ unwrap(message: ListValue): Array<any>;
190
+ };
191
+ type Builtin = Date | Function | Uint8Array | string | number | boolean | undefined;
192
+ export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
193
+ [K in keyof T]?: DeepPartial<T[K]>;
194
+ } : Partial<T>;
195
+ type KeysOfUnion<T> = T extends T ? keyof T : never;
196
+ export type Exact<P, I extends P> = P extends Builtin ? P : P & {
197
+ [K in keyof P]: Exact<P[K], I[K]>;
198
+ } & {
199
+ [K in Exclude<keyof I, KeysOfUnion<P>>]: never;
200
+ };
184
201
  export {};