Skip to content

Commit d87fefb

Browse files
author
Josh Sirota
committed
Update to 1.0.2
Rename from nodejs to just js Up-to-date with latest spec
1 parent a653517 commit d87fefb

File tree

7 files changed

+20
-90
lines changed

7 files changed

+20
-90
lines changed

.eslintrc.json

Lines changed: 0 additions & 18 deletions
This file was deleted.

CHANGES.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
- First release. Up to date with spec 0.4.0, and @openfeature/nodejs-sdk v0.2.0
33
1.0.1
44
- Fixes issues with flag details and error codes in negative cases, adds unit tests
5-
- Up to date with spec 0.4.0 and @openfeature/nodejs-sdk v0.3.2
5+
- Up to date with spec 0.4.0 and @openfeature/nodejs-sdk v0.3.2
6+
1.0.2
7+
- Changes name from Node-specific implementation to generic JSON
8+
- Up to date with spec 0.4.0 and @openfeature/js-sdk 0.4.0

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,13 @@ This Provider is designed to allow the use of OpenFeature with Split, the platfo
1111
Below is a simple example that describes the instantiation of the Split Provider. Please see the [OpenFeature Documentation](https://docs.openfeature.dev/docs/reference/concepts/evaluation-api) for details on how to use the OpenFeature SDK.
1212

1313
```js
14-
const OpenFeature = require('@openfeature/nodejs-sdk').OpenFeature;
14+
const OpenFeature = require('@openfeature/js-sdk').OpenFeature;
1515
const SplitFactory = require('@splitsoftware/splitio').SplitFactory;
1616
const OpenFeatureSplitProvider = require('@splitsoftware/openfeature-nodejs-split-provider').OpenFeatureSplitProvider;
1717

1818
splitClient = SplitFactory({core: {authorizationKey: 'localhost'}}).client();
19-
openFeature.setProvider(splitClient);
19+
provider = new OpenFeatureSplitProvider({splitClient});
20+
openFeature.setProvider(provider);
2021
```
2122

2223
## Use of OpenFeature with Split

package.json

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"name": "@splitsoftware/openfeature-nodejs-split-provider",
3-
"version": "1.0.1",
2+
"name": "@splitsoftware/openfeature-js-split-provider",
3+
"version": "1.0.2",
44
"description": "Split OpenFeature Provider",
55
"files": [
66
"README.md",
@@ -27,75 +27,32 @@
2727
"node": ">=6"
2828
},
2929
"dependencies": {
30-
"@openfeature/nodejs-sdk": "^0.3.2",
30+
"@openfeature/js-sdk": "^0.4.0",
3131
"@splitsoftware/splitio": "^10.21.1"
3232
},
3333
"devDependencies": {
34-
"@types/node-fetch": "^2.5.12",
3534
"copyfiles": "^2.4.1",
3635
"cross-env": "^7.0.3",
37-
"csv-streamify": "4.0.0",
38-
"eslint": "^8.0.1",
39-
"eslint-plugin-compat": "^3.13.0",
40-
"eslint-plugin-import": "^2.25.4",
41-
"fetch-mock": "^9.11.0",
42-
"karma": "^6.3.16",
43-
"karma-chrome-launcher": "^3.1.0",
44-
"karma-tap": "4.1.4",
45-
"karma-webpack": "^5.0.0",
46-
"lodash": "^4.17.21",
47-
"node-polyfill-webpack-plugin": "^1.1.4",
48-
"proxyquire": "^2.1.3",
49-
"puppeteer": "^3.3.0",
50-
"redis-dumpz": "0.1.12",
51-
"redis-server": "1.2.2",
5236
"replace": "^1.2.1",
5337
"rimraf": "^3.0.2",
54-
"sinon": "^9.2.4",
5538
"tap-min": "^2.0.0",
5639
"tape": "4.13.2",
5740
"tape-catch": "1.0.6",
58-
"ts-loader": "^9.2.6",
5941
"ts-node": "^10.5.0",
60-
"typescript": "4.4.4",
61-
"webpack": "^5.53.0",
62-
"webpack-cli": "^4.8.0",
63-
"webpack-merge": "^5.8.0"
42+
"typescript": "4.4.4"
6443
},
6544
"scripts": {
6645
"build-esm": "rimraf es && tsc -outDir es",
6746
"postbuild-esm": "cross-env NODE_ENV=es node scripts/copy.packages.json.js && ./scripts/build_esm_replace_imports.sh",
68-
"build-umd:stats": "webpack --progress --env production --json > ./stats/stat_results.json",
6947
"build-cjs": "rimraf lib && tsc -outDir lib -m CommonJS",
7048
"postbuild-cjs": "cross-env NODE_ENV=cjs node scripts/copy.packages.json.js && ./scripts/build_cjs_replace_imports.sh",
71-
"build-umd": "webpack --config webpack.dev.js --env branch=$BUILD_BRANCH --env commit_hash=$BUILD_COMMIT && webpack --config webpack.prod.js --env branch=$BUILD_BRANCH --env commit_hash=$BUILD_COMMIT && ./scripts/clean_umd_build.sh",
72-
"build:npm": "rimraf lib es && npm run build-cjs && npm run build-esm",
73-
"build": "rimraf lib umd es && npm run build-cjs && npm run build-esm && npm run build-umd",
74-
"check": "npm run check:lint && npm run check:version",
75-
"check:lint": "eslint src",
49+
"build": "rimraf lib es && npm run build-cjs && npm run build-esm",
50+
"check": "npm run check:version",
7651
"check:version": "cross-env NODE_ENV=test tape -r ./ts-node.register src/settings/__tests__/defaults.spec.js",
77-
"test-browser-local": "cross-env NODE_ENV=test karma start karma/local.karma.conf.js",
78-
"test-browser-e2e-local": "cross-env NODE_ENV=test karma start karma/e2e.local.karma.conf.js",
79-
"test-browser": "npm run test-browser-unit && npm run test-browser-online && npm run test-browser-offline && npm run test-browser-destroy && npm run test-browser-errors && npm run test-browser-push && npm run test-browser-gaintegration",
80-
"test-browser-unit": "cross-env NODE_ENV=test karma start karma/ci.karma.conf.js",
81-
"test-browser-online": "cross-env NODE_ENV=test karma start karma/e2e.ci.karma.conf.js",
82-
"test-browser-offline": "cross-env NODE_ENV=test karma start karma/offline.karma.conf.js",
83-
"test-browser-destroy": "cross-env NODE_ENV=test karma start karma/destroy.ci.karma.conf.js",
84-
"test-browser-errors": "cross-env NODE_ENV=test karma start karma/errors.ci.karma.conf.js",
85-
"test-browser-gaintegration": "cross-env NODE_ENV=test karma start karma/gaintegration.ci.karma.conf.js",
86-
"test-browser-push": "cross-env NODE_ENV=test karma start karma/push.ci.karma.conf.js",
87-
"test-node": "npm run test-node-unit && npm run test-node-online && npm run test-node-redis && npm run test-node-offline && npm run test-node-destroy && npm run test-node-errors && npm run test-node-push",
88-
"test-node-unit": "cross-env NODE_ENV=test tape -r ./ts-node.register \"src/*/**/__tests__/**/!(browser).spec.js\" | tap-min",
89-
"test-node-online": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/node.spec.js | tap-min",
90-
"test-node-destroy": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/destroy/node.spec.js | tap-min",
91-
"test-node-errors": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/errorCatching/node.spec.js | tap-min",
92-
"test-node-offline": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/offline/node.spec.js | tap-min",
93-
"test-node-redis": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/node_redis.spec.js | tap-min",
94-
"test-node-push": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/push/node.spec.js | tap-min",
9552
"pretest-ts-decls": "npm run build-esm && npm run build-cjs && npm link",
9653
"test-ts-decls": "./scripts/ts-tests.sh",
9754
"posttest-ts-decls": "npm unlink && npm install",
98-
"test": "npm run test-node && npm run test-browser",
55+
"test": "cross-env NODE_ENV=test tape -r ./ts-node.register src/__tests__/node.spec.js | tap-min",
9956
"publish:rc": "npm run check && npm run build && npm publish --tag canary",
10057
"publish:stable": "npm run check && npm run build && npm publish"
10158
},
File renamed without changes.

src/__tests__/nodeSuites/client.spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const OpenFeature = require('@openfeature/nodejs-sdk').OpenFeature;
1+
const OpenFeature = require('@openfeature/js-sdk').OpenFeature;
22
const SplitFactory = require('@splitsoftware/splitio').SplitFactory;
33
import { OpenFeatureSplitProvider } from '../..';
44

@@ -148,7 +148,7 @@ export default async function(assert) {
148148
authorizationKey: 'localhost'
149149
},
150150
features: './split.yaml',
151-
debug: 'WARN'
151+
debug: 'DEBUG'
152152
}).client();
153153

154154
let provider = new OpenFeatureSplitProvider({splitClient});
@@ -158,7 +158,7 @@ export default async function(assert) {
158158
let evaluationContext = {
159159
targetingKey: 'key'
160160
};
161-
client.context = evaluationContext;
161+
client.setContext(evaluationContext);
162162

163163
await useDefaultTest(client);
164164
await missingTargetingKeyTest(client);

src/lib/js-split-provider.ts

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import { EvaluationContext, Provider, ResolutionDetails, ParseError, FlagNotFoundError, OpenFeatureError, StandardResolutionReasons } from '@openfeature/nodejs-sdk';
1+
import { EvaluationContext, Provider, ResolutionDetails, ParseError, FlagNotFoundError, JsonValue, OpenFeatureError, StandardResolutionReasons } from '@openfeature/js-sdk';
22
import SplitIO from '@splitsoftware/splitio/types/splitio';
33

4-
/**
5-
* This simple provider implementation relies on storing all data as strings in the treatment value.
6-
*
7-
* It may be more idiomatic to only rely on that for the "isEnabled" calls,
8-
* and for all values store the data in teh associated "split config" JSON.
9-
*/
104
export interface SplitProviderOptions {
115
splitClient: SplitIO.IClient;
126
}
@@ -16,11 +10,6 @@ type Consumer = {
1610
attributes: SplitIO.Attributes;
1711
};
1812

19-
/**
20-
* NOTE: This is an unofficial provider that was created for demonstration
21-
* purposes only. The playground environment will be updated to use official
22-
* providers once they're available.
23-
*/
2413
export class OpenFeatureSplitProvider implements Provider {
2514
metadata = {
2615
name: 'split',
@@ -30,8 +19,6 @@ export class OpenFeatureSplitProvider implements Provider {
3019

3120
constructor(options: SplitProviderOptions) {
3221
this.client = options.splitClient;
33-
// we don't expose any init events at the moment (we might later) so for now, lets create a private
34-
// promise to await into before we evaluate any flags.
3522
this.initialized = new Promise((resolve) => {
3623
this.client.on(this.client.Event.SDK_READY, () => {
3724
console.log(`${this.metadata.name} provider initialized`);
@@ -98,7 +85,7 @@ export class OpenFeatureSplitProvider implements Provider {
9885
return { ...details, value: this.parseValidNumber(details.value) };
9986
}
10087

101-
async resolveObjectEvaluation<U extends object>(
88+
async resolveObjectEvaluation<U extends JsonValue>(
10289
flagKey: string,
10390
_: U,
10491
context: EvaluationContext
@@ -149,7 +136,7 @@ export class OpenFeatureSplitProvider implements Provider {
149136
return result;
150137
}
151138

152-
private parseValidJsonObject<T extends Object>(stringValue: string | undefined): T {
139+
private parseValidJsonObject<T extends JsonValue>(stringValue: string | undefined): T {
153140
if (stringValue === undefined) {
154141
throw new ParseError(`Invalid 'undefined' JSON value.`);
155142
}

0 commit comments

Comments
 (0)