@openfeature/flagd-provider 0.7.5 → 0.7.6
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/index.cjs +22 -6
- package/index.js +23 -7
- package/package.json +6 -6
- package/src/lib/service/grpc/service.d.ts +3 -0
- package/src/proto/ts/sync/v1/sync_service.d.ts +33 -3
package/index.cjs
CHANGED
|
@@ -1394,12 +1394,28 @@ class GRPCService {
|
|
|
1394
1394
|
// default to false here - reassigned in the constructor if we actaully need to connect
|
|
1395
1395
|
this.streamConnection = Promise.resolve(false);
|
|
1396
1396
|
this.objectParser = (struct) => {
|
|
1397
|
-
if (struct
|
|
1397
|
+
if (struct) {
|
|
1398
1398
|
return Struct.toJson(struct);
|
|
1399
1399
|
}
|
|
1400
|
-
|
|
1401
|
-
|
|
1400
|
+
return {};
|
|
1401
|
+
};
|
|
1402
|
+
this.booleanParser = (value) => {
|
|
1403
|
+
if (value) {
|
|
1404
|
+
return value;
|
|
1405
|
+
}
|
|
1406
|
+
return false;
|
|
1407
|
+
};
|
|
1408
|
+
this.stringParser = (value) => {
|
|
1409
|
+
if (value) {
|
|
1410
|
+
return value;
|
|
1411
|
+
}
|
|
1412
|
+
return '';
|
|
1413
|
+
};
|
|
1414
|
+
this.numberParser = (value) => {
|
|
1415
|
+
if (value) {
|
|
1416
|
+
return value;
|
|
1402
1417
|
}
|
|
1418
|
+
return 0;
|
|
1403
1419
|
};
|
|
1404
1420
|
this.onRejected = (err) => {
|
|
1405
1421
|
// map the errors
|
|
@@ -1433,17 +1449,17 @@ class GRPCService {
|
|
|
1433
1449
|
}
|
|
1434
1450
|
resolveBoolean(flagKey, context, logger) {
|
|
1435
1451
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1436
|
-
return this.resolve(this._client.resolveBoolean, flagKey, context, logger);
|
|
1452
|
+
return this.resolve(this._client.resolveBoolean, flagKey, context, logger, this.booleanParser);
|
|
1437
1453
|
});
|
|
1438
1454
|
}
|
|
1439
1455
|
resolveString(flagKey, context, logger) {
|
|
1440
1456
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1441
|
-
return this.resolve(this._client.resolveString, flagKey, context, logger);
|
|
1457
|
+
return this.resolve(this._client.resolveString, flagKey, context, logger, this.stringParser);
|
|
1442
1458
|
});
|
|
1443
1459
|
}
|
|
1444
1460
|
resolveNumber(flagKey, context, logger) {
|
|
1445
1461
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1446
|
-
return this.resolve(this._client.resolveFloat, flagKey, context, logger);
|
|
1462
|
+
return this.resolve(this._client.resolveFloat, flagKey, context, logger, this.numberParser);
|
|
1447
1463
|
});
|
|
1448
1464
|
}
|
|
1449
1465
|
resolveObject(flagKey, context, logger) {
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as grpc from '@grpc/grpc-js';
|
|
2
|
-
import {
|
|
2
|
+
import { GeneralError, FlagNotFoundError, TypeMismatchError, ParseError, StandardResolutionReasons } from '@openfeature/js-sdk';
|
|
3
3
|
import { GrpcTransport } from '@protobuf-ts/grpc-transport';
|
|
4
4
|
import LRU from 'lru-cache';
|
|
5
5
|
import { MessageType, isJsonObject, typeofJsonValue, reflectionMergePartial, UnknownFieldHandler, WireType, MESSAGE_TYPE } from '@protobuf-ts/runtime';
|
|
@@ -1367,12 +1367,28 @@ class GRPCService {
|
|
|
1367
1367
|
// default to false here - reassigned in the constructor if we actaully need to connect
|
|
1368
1368
|
this.streamConnection = Promise.resolve(false);
|
|
1369
1369
|
this.objectParser = (struct) => {
|
|
1370
|
-
if (struct
|
|
1370
|
+
if (struct) {
|
|
1371
1371
|
return Struct.toJson(struct);
|
|
1372
1372
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1373
|
+
return {};
|
|
1374
|
+
};
|
|
1375
|
+
this.booleanParser = (value) => {
|
|
1376
|
+
if (value) {
|
|
1377
|
+
return value;
|
|
1378
|
+
}
|
|
1379
|
+
return false;
|
|
1380
|
+
};
|
|
1381
|
+
this.stringParser = (value) => {
|
|
1382
|
+
if (value) {
|
|
1383
|
+
return value;
|
|
1384
|
+
}
|
|
1385
|
+
return '';
|
|
1386
|
+
};
|
|
1387
|
+
this.numberParser = (value) => {
|
|
1388
|
+
if (value) {
|
|
1389
|
+
return value;
|
|
1375
1390
|
}
|
|
1391
|
+
return 0;
|
|
1376
1392
|
};
|
|
1377
1393
|
this.onRejected = (err) => {
|
|
1378
1394
|
// map the errors
|
|
@@ -1406,17 +1422,17 @@ class GRPCService {
|
|
|
1406
1422
|
}
|
|
1407
1423
|
resolveBoolean(flagKey, context, logger) {
|
|
1408
1424
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1409
|
-
return this.resolve(this._client.resolveBoolean, flagKey, context, logger);
|
|
1425
|
+
return this.resolve(this._client.resolveBoolean, flagKey, context, logger, this.booleanParser);
|
|
1410
1426
|
});
|
|
1411
1427
|
}
|
|
1412
1428
|
resolveString(flagKey, context, logger) {
|
|
1413
1429
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1414
|
-
return this.resolve(this._client.resolveString, flagKey, context, logger);
|
|
1430
|
+
return this.resolve(this._client.resolveString, flagKey, context, logger, this.stringParser);
|
|
1415
1431
|
});
|
|
1416
1432
|
}
|
|
1417
1433
|
resolveNumber(flagKey, context, logger) {
|
|
1418
1434
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1419
|
-
return this.resolve(this._client.resolveFloat, flagKey, context, logger);
|
|
1435
|
+
return this.resolve(this._client.resolveFloat, flagKey, context, logger, this.numberParser);
|
|
1420
1436
|
});
|
|
1421
1437
|
}
|
|
1422
1438
|
resolveObject(flagKey, context, logger) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openfeature/flagd-provider",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.6",
|
|
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"
|
|
@@ -20,10 +20,10 @@
|
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@grpc/grpc-js": "
|
|
24
|
-
"@protobuf-ts/grpc-transport": "2.8.
|
|
25
|
-
"@protobuf-ts/runtime": "2.8.
|
|
26
|
-
"@protobuf-ts/runtime-rpc": "2.8.
|
|
27
|
-
"lru-cache": "
|
|
23
|
+
"@grpc/grpc-js": "1.8.13",
|
|
24
|
+
"@protobuf-ts/grpc-transport": "2.8.3",
|
|
25
|
+
"@protobuf-ts/runtime": "2.8.3",
|
|
26
|
+
"@protobuf-ts/runtime-rpc": "2.8.3",
|
|
27
|
+
"lru-cache": "8.0.5"
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -40,6 +40,9 @@ export declare class GRPCService implements Service {
|
|
|
40
40
|
private handleError;
|
|
41
41
|
private handleComplete;
|
|
42
42
|
private objectParser;
|
|
43
|
+
private booleanParser;
|
|
44
|
+
private stringParser;
|
|
45
|
+
private numberParser;
|
|
43
46
|
private resolve;
|
|
44
47
|
private convertContext;
|
|
45
48
|
private onRejected;
|
|
@@ -12,13 +12,24 @@ import { MessageType } from "@protobuf-ts/runtime";
|
|
|
12
12
|
*/
|
|
13
13
|
export interface SyncFlagsRequest {
|
|
14
14
|
/**
|
|
15
|
-
* Optional: A unique identifier for flagd
|
|
16
|
-
*
|
|
17
|
-
* is intended to be optional. However server
|
|
15
|
+
* Optional: A unique identifier for flagd(grpc client) initiating the request. The server implementations may
|
|
16
|
+
* utilize this identifier to uniquely identify, validate(ex:- enforce authentication/authorization) and filter
|
|
17
|
+
* flag configurations that it can expose to this request. This field is intended to be optional. However server
|
|
18
|
+
* implementations may enforce it.
|
|
19
|
+
* ex:- provider_id: flagd-weatherapp-sidecar
|
|
18
20
|
*
|
|
19
21
|
* @generated from protobuf field: string provider_id = 1;
|
|
20
22
|
*/
|
|
21
23
|
providerId: string;
|
|
24
|
+
/**
|
|
25
|
+
* Optional: A selector for the flag configuration request. The server implementation may utilize this to select
|
|
26
|
+
* flag configurations from a collection, select the source of the flag or combine this to any desired underlying
|
|
27
|
+
* filtering mechanism.
|
|
28
|
+
* ex:- selector: 'source=database,app=weatherapp'
|
|
29
|
+
*
|
|
30
|
+
* @generated from protobuf field: string selector = 2;
|
|
31
|
+
*/
|
|
32
|
+
selector: string;
|
|
22
33
|
}
|
|
23
34
|
/**
|
|
24
35
|
* SyncFlagsResponse is the server response containing feature flag configurations and the state
|
|
@@ -46,6 +57,25 @@ export interface SyncFlagsResponse {
|
|
|
46
57
|
* @generated from protobuf message sync.v1.FetchAllFlagsRequest
|
|
47
58
|
*/
|
|
48
59
|
export interface FetchAllFlagsRequest {
|
|
60
|
+
/**
|
|
61
|
+
* Optional: A unique identifier for flagd(grpc client) initiating the request. The server implementations may
|
|
62
|
+
* utilize this identifier to uniquely identify, validate(ex:- enforce authentication/authorization) and filter
|
|
63
|
+
* flag configurations that it can expose to this request. This field is intended to be optional. However server
|
|
64
|
+
* implementations may enforce it.
|
|
65
|
+
* ex:- provider_id: flagd-weatherapp-sidecar
|
|
66
|
+
*
|
|
67
|
+
* @generated from protobuf field: string provider_id = 1;
|
|
68
|
+
*/
|
|
69
|
+
providerId: string;
|
|
70
|
+
/**
|
|
71
|
+
* Optional: A selector for the flag configuration request. The server implementation may utilize this to select
|
|
72
|
+
* flag configurations from a collection, select the source of the flag or combine this to any desired underlying
|
|
73
|
+
* filtering mechanism.
|
|
74
|
+
* ex:- selector: 'source=database,app=weatherapp'
|
|
75
|
+
*
|
|
76
|
+
* @generated from protobuf field: string selector = 2;
|
|
77
|
+
*/
|
|
78
|
+
selector: string;
|
|
49
79
|
}
|
|
50
80
|
/**
|
|
51
81
|
* FetchAllFlagsResponse is the server response containing feature flag configurations
|