Skip to content

Commit f32d3b0

Browse files
thomaspoignantbeeme1mrtoddbaert
authored
feat: Go feature flag provider (open-feature#64)
* New empty provider Signed-off-by: Thomas Poignant <[email protected]> * Go Feature Flag provider initialisation. Signed-off-by: Thomas Poignant <[email protected]> * Adding test to the go-feature-flag provider Signed-off-by: Thomas Poignant <[email protected]> * linting issues Signed-off-by: Thomas Poignant <[email protected]> * Edit readme Signed-off-by: Thomas Poignant <[email protected]> * Moved dependencies to the root Signed-off-by: Michael Beemer <[email protected]> * Set inferred deps to dependencies in package.json Signed-off-by: Michael Beemer <[email protected]> * export go feature flag provider Signed-off-by: Michael Beemer <[email protected]> * Formatted and linted Signed-off-by: Michael Beemer <[email protected]> * Remove semicolon eslint exclusion rule Signed-off-by: Michael Beemer <[email protected]> * Add release please config Signed-off-by: Michael Beemer <[email protected]> * chore: update to new publishing Signed-off-by: Todd Baert <[email protected]> Co-authored-by: Michael Beemer <[email protected]> Co-authored-by: Todd Baert <[email protected]>
1 parent 2082f6f commit f32d3b0

23 files changed

+1325
-39
lines changed

.release-please-manifest.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2-
"libs/hooks/open-telemetry": "1.2.0-alpha"
2+
"libs/hooks/open-telemetry": "1.2.0-alpha",
3+
"libs/providers/go-feature-flag": "0.0.1"
34
}
+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
[
4+
"@nrwl/web/babel",
5+
{
6+
"useBuiltIns": "usage"
7+
}
8+
]
9+
]
10+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"extends": ["../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"rules": {
5+
"@typescript-eslint/no-explicit-any": "off",
6+
"quotes": ["error", "single"]
7+
},
8+
"overrides": [
9+
{
10+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.ts", "*.tsx"],
15+
"rules": {}
16+
},
17+
{
18+
"files": ["*.js", "*.jsx"],
19+
"rules": {}
20+
}
21+
]
22+
}
+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# js-go-feature-flag-provider
2+
3+
This provider is an implementation for [`go-feature-flag`](https://github.com/thomaspoignant/go-feature-flag) a simple and complete
4+
feature flag solution, without any complex backend system to install, all you need is a file as your backend.
5+
6+
It uses [`go-feature-flag-relay-proxy`](https://github.com/thomaspoignant/go-feature-flag-relay-proxy) which expose the capabilities of the SDK through an API layer.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["minify"]
3+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'provider-go-feature-flag',
4+
preset: '../../../jest.preset.js',
5+
globals: {
6+
'ts-jest': {
7+
tsconfig: '<rootDir>/tsconfig.spec.json',
8+
},
9+
},
10+
transform: {
11+
'^.+\\.[tj]s$': 'ts-jest',
12+
},
13+
moduleFileExtensions: ['ts', 'js', 'html'],
14+
coverageDirectory: '../../../coverage/libs/providers/go-feature-flag',
15+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "@openfeature/go-feature-flag-provider",
3+
"version": "0.0.1",
4+
"type": "commonjs",
5+
"peerDependencies": {
6+
"@openfeature/nodejs-sdk": "^0.0.1"
7+
},
8+
"scripts": {
9+
"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",
10+
"current-version": "echo $npm_package_version"
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
{
2+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
3+
"sourceRoot": "libs/providers/go-feature-flag/src",
4+
"projectType": "library",
5+
"targets": {
6+
"publish": {
7+
"executor": "@nrwl/workspace:run-commands",
8+
"options": {
9+
"command": "npm run publish-if-not-exists",
10+
"cwd": "dist/libs/providers/go-feature-flag"
11+
},
12+
"dependsOn": [
13+
{
14+
"projects": "self",
15+
"target": "package"
16+
}
17+
]
18+
},
19+
"lint": {
20+
"executor": "@nrwl/linter:eslint",
21+
"outputs": [
22+
"{options.outputFile}"
23+
],
24+
"options": {
25+
"lintFilePatterns": [
26+
"libs/providers/go-feature-flag/**/*.ts"
27+
]
28+
}
29+
},
30+
"test": {
31+
"executor": "@nrwl/jest:jest",
32+
"outputs": [
33+
"coverage/libs/providers/go-feature-flag"
34+
],
35+
"options": {
36+
"jestConfig": "libs/providers/go-feature-flag/jest.config.ts",
37+
"passWithNoTests": true
38+
}
39+
},
40+
"package": {
41+
"executor": "@nrwl/web:rollup",
42+
"outputs": [
43+
"{options.outputPath}"
44+
],
45+
"options": {
46+
"project": "libs/providers/go-feature-flag/package.json",
47+
"outputPath": "dist/libs/providers/go-feature-flag",
48+
"entryFile": "libs/providers/go-feature-flag/src/index.ts",
49+
"tsConfig": "libs/providers/go-feature-flag/tsconfig.lib.json",
50+
"compiler": "babel",
51+
"buildableProjectDepsInPackageJsonType": "dependencies",
52+
"umdName": "go-feature-flag",
53+
"external": [
54+
"typescript"
55+
],
56+
"format": [
57+
"cjs",
58+
"esm"
59+
],
60+
"assets": [
61+
{
62+
"glob": "LICENSE",
63+
"input": "./",
64+
"output": "./"
65+
},
66+
{
67+
"glob": "README.md",
68+
"input": "./libs/providers/go-feature-flag",
69+
"output": "./"
70+
}
71+
]
72+
}
73+
}
74+
},
75+
"tags": []
76+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib/go-feature-flag-provider';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ErrorCode, OpenFeatureError } from '@openfeature/nodejs-sdk'
2+
3+
// ProxyNotReady is an error send when we try to call the relay proxy and he is not ready
4+
// to return a valid response.
5+
export class ProxyNotReady extends OpenFeatureError {
6+
code: ErrorCode
7+
8+
constructor(message: string, originalError: Error) {
9+
super(`${message}: ${originalError}`)
10+
Object.setPrototypeOf(this, ProxyNotReady.prototype)
11+
this.code = ErrorCode.PROVIDER_NOT_READY
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { ErrorCode, OpenFeatureError } from '@openfeature/nodejs-sdk'
2+
3+
// ProxyTimeout is an error send when we try to call the relay proxy and he his not responding
4+
// in the appropriate time.
5+
export class ProxyTimeout extends OpenFeatureError {
6+
code: ErrorCode
7+
8+
constructor(message: string, originalError: Error) {
9+
super(`${message}: ${originalError}`)
10+
Object.setPrototypeOf(this, ProxyTimeout.prototype)
11+
this.code = ErrorCode.GENERAL
12+
}
13+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { ErrorCode, OpenFeatureError } from '@openfeature/nodejs-sdk'
2+
3+
// UnknownError is an error send when something unexpected happened.
4+
export class UnknownError extends OpenFeatureError {
5+
code: ErrorCode
6+
7+
constructor(message: string, originalError: Error | unknown) {
8+
super(`${message}: ${originalError}`)
9+
Object.setPrototypeOf(this, UnknownError.prototype)
10+
this.code = ErrorCode.GENERAL
11+
}
12+
}

0 commit comments

Comments
 (0)