Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade OpenFeature deps #60

Merged
merged 4 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/actions/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ runs:
scope: '@spotify-confidence'
- name: Install dependencies
shell: bash
run: yarn install --frozen-lockfile
run: corepack enable && yarn install --frozen-lockfile
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**/node_modules/
.idea

# yarn (https://yarnpkg.com/getting-started/qa#which-files-should-be-gitignored)
.yarn/*

# packages
packages/**/build
coverage/*
Expand Down
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
7 changes: 4 additions & 3 deletions examples/next12/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"lint": "next lint"
},
"dependencies": {
"@openfeature/web-sdk": "^0.4.0",
"@openfeature/js-sdk": "^1.4.2",
"@spotify-confidence/openfeature-web-provider": "0.1.5",
"@openfeature/core": "^0.0.24",
"@openfeature/server-sdk": "^1.10.0",
"@openfeature/web-sdk": "^0.4.11",
"@spotify-confidence/openfeature-server-provider": "0.1.5",
"@spotify-confidence/openfeature-web-provider": "0.1.5",
"next": "13.5.3",
"react": "18.2.0",
"react-dom": "18.2.0"
Expand Down
2 changes: 1 addition & 1 deletion examples/next12/pages/api/next12.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';
import { setupOpenFeatureConfidenceProvider } from '../../utils/setupOpenFeatureConfidenceProvider';

setupOpenFeatureConfidenceProvider();
Expand Down
2 changes: 1 addition & 1 deletion examples/next12/pages/next12/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';
import { setupOpenFeatureConfidenceProvider } from '../../utils/setupOpenFeatureConfidenceProvider';

setupOpenFeatureConfidenceProvider();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';

let setup: boolean = false;

Expand Down
4 changes: 1 addition & 3 deletions examples/next13/app/next13Advanced/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';

import { ClientComponent } from '@/app/next13Advanced/ClientComponent';
import { setupOpenFeatureConfidenceProvider } from '@/utils/setupOpenFeatureConfidenceProvider';
Expand All @@ -16,14 +16,12 @@ export default async function App() {

return (
<>
{/* @ts-expect-error Server Component */}
<ClientBoundary>
<SetOpenFeatureContext context={{ targetingKey: 'user-a' }} />
</ClientBoundary>

<p>Flag value being used in the Server Component: {str}</p>

{/* @ts-expect-error Server Component */}
<ClientBoundary>
<React.Suspense fallback={<p>loading...</p>}>
<ClientComponent />
Expand Down
2 changes: 1 addition & 1 deletion examples/next13/app/next13Simple/api/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { setupOpenFeatureConfidenceProvider } from '@/utils/setupOpenFeatureConfidenceProvider';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';
import { NextResponse } from 'next/server';

setupOpenFeatureConfidenceProvider();
Expand Down
2 changes: 1 addition & 1 deletion examples/next13/app/next13Simple/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { SimpleClientComponent } from './SimpleClientComponent';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';
import { setupOpenFeatureConfidenceProvider } from '@/utils/setupOpenFeatureConfidenceProvider';

setupOpenFeatureConfidenceProvider();
Expand Down
7 changes: 4 additions & 3 deletions examples/next13/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
"lint": "next lint"
},
"dependencies": {
"@openfeature/web-sdk": "^0.4.0",
"@openfeature/js-sdk": "^1.4.2",
"@spotify-confidence/openfeature-web-provider": "0.1.5",
"@openfeature/core": "^0.0.24",
"@openfeature/server-sdk": "^1.10.0",
"@openfeature/web-sdk": "^0.4.11",
"@spotify-confidence/openfeature-server-provider": "0.1.5",
"@spotify-confidence/openfeature-web-provider": "0.1.5",
"@types/node": "20.6.5",
"@types/react": "18.2.22",
"@types/react-dom": "18.2.7",
Expand Down
2 changes: 1 addition & 1 deletion examples/next13/pages/api/next12Simulation.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { NextApiRequest, NextApiResponse } from 'next';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';
import { setupOpenFeatureConfidenceProvider } from '@/utils/setupOpenFeatureConfidenceProvider';

setupOpenFeatureConfidenceProvider();
Expand Down
2 changes: 1 addition & 1 deletion examples/next13/pages/next12Simulation/index.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';
import { setupOpenFeatureConfidenceProvider } from '@/utils/setupOpenFeatureConfidenceProvider';

setupOpenFeatureConfidenceProvider();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';

let setup: boolean = false;

Expand Down
3 changes: 2 additions & 1 deletion examples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": "module",
"license": "MIT",
"dependencies": {
"@openfeature/js-sdk": "^1.6.1",
"@openfeature/core": "^0.0.24",
"@openfeature/server-sdk": "^1.10.0",
"@spotify-confidence/openfeature-server-provider": "0.1.5"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/node/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';

const provider = createConfidenceServerProvider({
clientSecret: 'RxDVTrXvc6op1XxiQ4OaR31dKbJ39aYV',
Expand Down
3 changes: 2 additions & 1 deletion examples/nodeCJS/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": "commonjs",
"license": "MIT",
"dependencies": {
"@openfeature/js-sdk": "^1.6.1",
"@openfeature/core": "^0.0.24",
"@openfeature/server-sdk": "^1.10.0",
"@spotify-confidence/openfeature-server-provider": "0.1.5"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion examples/nodeCJS/src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { createConfidenceServerProvider } = require('@spotify-confidence/openfeature-server-provider');
const { OpenFeature } = require('@openfeature/js-sdk');
const { OpenFeature } = require('@openfeature/server-sdk');

const provider = createConfidenceServerProvider({
clientSecret: 'RxDVTrXvc6op1XxiQ4OaR31dKbJ39aYV',
Expand Down
3 changes: 2 additions & 1 deletion examples/react18/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"@babel/core": "^7.23.2",
"@babel/plugin-syntax-flow": "^7.22.5",
"@babel/plugin-transform-react-jsx": "^7.22.15",
"@openfeature/web-sdk": "^0.4.0",
"@openfeature/core": "^0.0.24",
"@openfeature/web-sdk": "^0.4.11",
"@spotify-confidence/integration-react": "0.1.3",
"@spotify-confidence/openfeature-web-provider": "0.1.5",
"@testing-library/dom": "^7.29.6",
Expand Down
6 changes: 3 additions & 3 deletions examples/react18/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import { OpenFeature } from '@openfeature/web-sdk';
import { ClientProviderEvents, OpenFeature } from '@openfeature/web-sdk';
import TestComponent from './TestComponent';
import { createConfidenceWebProvider } from '@spotify-confidence/openfeature-web-provider';

Expand All @@ -11,13 +11,13 @@ export const webProvider = createConfidenceWebProvider({
timeout: 1000,
});

OpenFeature.getClient().addHandler(ClientProviderEvents.Ready, () => console.log('ready!'));
function App() {
useEffect(() => {
OpenFeature.setContext({
targetingKey: 'user-a',
}).then(() => {
OpenFeature.setProvider(webProvider);
});
OpenFeature.setProvider(webProvider);
}, []);

return (
Expand Down
9 changes: 3 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"clean": "lerna run clean",
"format": "prettier --config prettier.config.js -w .",
"format:check": "prettier --config prettier.config.js -c .",
"lint": "eslint ./packages/**/src/**/*.{tsx,ts}",
"lint": "eslint 'packages/*/src/**/*.{tsx,ts}'",
"test": "jest",
"prepare": "husky install",
"cm": "git-cz",
Expand All @@ -26,8 +26,6 @@
"@commitlint/config-conventional": "^17.6.7",
"@commitlint/cz-commitlint": "^17.6.7",
"@commitlint/prompt-cli": "^17.6.7",
"@openfeature/js-sdk": "^1.4.2",
"@openfeature/web-sdk": "^0.4.0",
"@spotify/eslint-config-base": "^15.0.0",
"@spotify/eslint-config-react": "^15.0.0",
"@spotify/eslint-config-typescript": "^15.0.0",
Expand All @@ -53,14 +51,13 @@
"jest-extended": "^4.0.0",
"lerna": "^7.1.4",
"prettier": "^2.8.8",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"ts-jest": "^29.1.0",
"typescript": "^5.1.3"
},
"config": {
"commitizen": {
"path": "@commitlint/cz-commitlint"
}
}
},
"packageManager": "[email protected]+sha256.81a00df816059803e6b5148acf03ce313cad36b7f6e5af6efa040a15981a6ffb"
}
7 changes: 5 additions & 2 deletions packages/integration-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"main": "build/cjs/index.js",
"types": "build/types/index.d.ts",
"peerDependencies": {
"@openfeature/web-sdk": "^0.4.0",
"@openfeature/web-sdk": "^0.4.11",
"react-dom": ">=16 <19"
},
"scripts": {
Expand All @@ -16,11 +16,14 @@
"clean": "rm -rf build"
},
"devDependencies": {
"@openfeature/core": "^0.0.24",
"@openfeature/web-sdk": "^0.4.11",
"@spotify-confidence/openfeature-web-provider": "^0.1.5",
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^14.0.0",
"@types/node-fetch": "^2.6.4",
"@types/use-sync-external-store": "^0.0.4"
"@types/use-sync-external-store": "^0.0.4",
"react": "^18.2.0"
},
"publishConfig": {
"access": "public"
Expand Down
4 changes: 2 additions & 2 deletions packages/openfeature-server-provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@ This implements the dynamic paradigm of OpenFeature.
To add the packages to your dependencies run:

```sh
yarn add @openfeature/js-sdk @spotify-confidence/openfeature-server-provider
yarn add @openfeature/server-sdk @spotify-confidence/openfeature-server-provider @openfeature/core
```

## Enabling the provider, setting the evaluation context and resolving flags

```ts
import { createConfidenceServerProvider } from '@spotify-confidence/openfeature-server-provider';
import { OpenFeature } from '@openfeature/js-sdk';
import { OpenFeature } from '@openfeature/server-sdk';

const provider = createConfidenceServerProvider({
clientSecret: 'your-client-secret',
Expand Down
6 changes: 5 additions & 1 deletion packages/openfeature-server-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@
"dependencies": {
"@spotify-confidence/client-http": "^0.1.4"
},
"devDependencies": {
"@openfeature/core": "^0.0.24",
"@openfeature/server-sdk": "^1.10.0"
},
"peerDependencies": {
"@openfeature/js-sdk": "^1.4.2"
"@openfeature/server-sdk": "^1.10.0"
},
"scripts": {
"build:esm": "tsc -p tsconfig.esm.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { OpenFeature, ProviderEvents } from '@openfeature/js-sdk';
import { OpenFeature, ProviderEvents } from '@openfeature/server-sdk';
import axios from 'axios';
import { createConfidenceServerProvider } from './factory';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
ProviderStatus,
ResolutionDetails,
ResolutionReason,
} from '@openfeature/js-sdk';
} from '@openfeature/server-sdk';

import { ConfidenceClient, ResolveContext, Configuration } from '@spotify-confidence/client-http';

Expand Down
2 changes: 1 addition & 1 deletion packages/openfeature-server-provider/src/factory.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Provider } from '@openfeature/js-sdk';
import { Provider } from '@openfeature/server-sdk';

import { ConfidenceClient, ConfidenceClientOptions } from '@spotify-confidence/client-http';

Expand Down
10 changes: 5 additions & 5 deletions packages/openfeature-web-provider/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ evaluation, if the network request is successful we update the flags and then em

```ts
import { createConfidenceWebProvider } from '@spotify-confidence/openfeature-web-provider';
import { OpenFeature, OpenFeatureAPI } from '@openfeature/web-sdk';
import { OpenFeature } from '@openfeature/web-sdk';

const provider = createConfidenceWebProvider({
clientSecret: 'mysecret',
fetchImplementation: window.fetch.bind(window),
timeout: 1000,
});

await OpenFeature.setContext({
OpenFeature.setContext({
targetingKey: 'myTargetingKey',
});
OpenFeature.setProvider(provider);

await OpenFeature.setProviderAndWait(provider);

const client = OpenFeature.getClient();
const result = client.getBooleanValue('flag.my-boolean', false);
```

Notes:

- It's advised not to perform `setContext` while `setProvider` is running, you can await setting the context first, or listen to the `ProviderEvent.Ready` via a handler on `OpenFeaure`.
- It's advised not to perform resolves while `setProvider` and `setContext` are running: resolves might return the default value with reason `STALE` during such operations.
- In the above example we first set the context and then set the provider and await for the provider to become ready before getting flags values. Other ways of arranging these calls might make more sense depending on what app framework you are using. See the example apps for more inspiration.
andreas-karlsson marked this conversation as resolved.
Show resolved Hide resolved

## Region

Expand Down
6 changes: 5 additions & 1 deletion packages/openfeature-web-provider/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
"@spotify-confidence/client-http": "^0.1.4",
"fast-deep-equal": "^3.1.3"
},
"devDependencies": {
"@openfeature/core": "^0.0.24",
"@openfeature/web-sdk": "^0.4.11"
},
"peerDependencies": {
"@openfeature/web-sdk": "^0.4.0"
"@openfeature/web-sdk": "^0.4.11"
},
"scripts": {
"build:esm": "tsc -p tsconfig.esm.json",
Expand Down
Loading
Loading