Skip to content

Commit 17e6d57

Browse files
lukas-reiningthomaspoignantbeeme1mr
authored
feat(ofrep): ofrep core (#795)
Signed-off-by: Lukas Reining <[email protected]> Co-authored-by: Thomas Poignant <[email protected]> Co-authored-by: Michael Beemer <[email protected]>
1 parent 1b1cfa7 commit 17e6d57

27 files changed

+1284
-1
lines changed

.release-please-manifest.json

+1
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,6 @@
88
"libs/providers/launchdarkly-client": "0.2.1",
99
"libs/providers/go-feature-flag-web": "0.1.6",
1010
"libs/shared/flagd-core": "0.1.11",
11+
"libs/shared/ofrep-core": "0.0.1-experimental",
1112
"libs/providers/flipt": "0.0.2"
1213
}

babel.config.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"babelrcRoots": ["*"]
3+
}

libs/shared/ofrep-core/.eslintrc.json

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"extends": ["../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
},
17+
{
18+
"files": ["*.json"],
19+
"parser": "jsonc-eslint-parser",
20+
"rules": {
21+
"@nx/dependency-checks": "error"
22+
}
23+
}
24+
]
25+
}

libs/shared/ofrep-core/CHANGELOG.md

Whitespace-only changes.

libs/shared/ofrep-core/README.md

Whitespace-only changes.

libs/shared/ofrep-core/jest.config.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'ofrep-core',
4+
preset: '../../../jest.preset.js',
5+
testEnvironment: 'node',
6+
transform: {
7+
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
8+
},
9+
moduleFileExtensions: ['ts', 'js', 'html'],
10+
coverageDirectory: '../../../coverage/libs/shared/ofrep-core',
11+
};

libs/shared/ofrep-core/package.json

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"name": "@openfeature/ofrep-core",
3+
"version": "0.0.1-experimental",
4+
"scripts": {
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+
"current-version": "echo $npm_package_version"
7+
},
8+
"peerDependencies": {}
9+
}

libs/shared/ofrep-core/project.json

+85
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
{
2+
"name": "ofrep-core",
3+
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
4+
"sourceRoot": "libs/shared/ofrep-core/src",
5+
"projectType": "library",
6+
"targets": {
7+
"publish": {
8+
"executor": "nx:run-commands",
9+
"options": {
10+
"command": "npm run publish-if-not-exists",
11+
"cwd": "dist/libs/shared/ofrep-core"
12+
},
13+
"dependsOn": [
14+
"build"
15+
]
16+
},
17+
"lint": {
18+
"executor": "@nx/linter:eslint",
19+
"outputs": [
20+
"{options.outputFile}"
21+
],
22+
"options": {
23+
"lintFilePatterns": [
24+
"libs/shared/ofrep-core/**/*.ts"
25+
]
26+
}
27+
},
28+
"test": {
29+
"executor": "@nx/jest:jest",
30+
"outputs": [
31+
"{workspaceRoot}/coverage/{projectRoot}"
32+
],
33+
"options": {
34+
"jestConfig": "libs/shared/ofrep-core/jest.config.ts",
35+
"passWithNoTests": true
36+
},
37+
"configurations": {
38+
"ci": {
39+
"ci": true,
40+
"codeCoverage": true
41+
}
42+
}
43+
},
44+
"package": {
45+
"executor": "@nx/rollup:rollup",
46+
"outputs": [
47+
"{options.outputPath}"
48+
],
49+
"options": {
50+
"project": "libs/shared/ofrep-core/package.json",
51+
"outputPath": "dist/libs/shared/ofrep-core",
52+
"entryFile": "libs/shared/ofrep-core/src/index.ts",
53+
"tsConfig": "libs/shared/ofrep-core/tsconfig.lib.json",
54+
"compiler": "tsc",
55+
"generateExportsField": true,
56+
"buildableProjectDepsInPackageJsonType": "dependencies",
57+
"umdName": "ofrep-core",
58+
"external": "all",
59+
"format": [
60+
"cjs",
61+
"esm"
62+
],
63+
"assets": [
64+
{
65+
"glob": "package.json",
66+
"input": "./assets",
67+
"output": "./src/"
68+
},
69+
{
70+
"glob": "LICENSE",
71+
"input": "./",
72+
"output": "./"
73+
},
74+
{
75+
"glob": "README.md",
76+
"input": "./libs/shared/ofrep-core",
77+
"output": "./"
78+
}
79+
],
80+
"updateBuildableProjectDepsInPackageJson": true
81+
}
82+
}
83+
},
84+
"tags": []
85+
}

libs/shared/ofrep-core/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './lib';
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
abstract class OFREPApiError extends Error {
2+
constructor(
3+
public error: unknown | undefined,
4+
public response: Response | undefined,
5+
message?: string,
6+
options?: ErrorOptions,
7+
) {
8+
super(message, options);
9+
Object.setPrototypeOf(this, OFREPApiError.prototype);
10+
this.name = OFREPApiError.name;
11+
}
12+
}
13+
14+
export class OFREPApiFetchError extends OFREPApiError {
15+
constructor(error: unknown, message?: string, options?: ErrorOptions) {
16+
super(error, undefined, message, options);
17+
Object.setPrototypeOf(this, OFREPApiFetchError.prototype);
18+
this.name = OFREPApiFetchError.name;
19+
}
20+
}
21+
22+
export class OFREPApiUnexpectedResponseError extends OFREPApiError {
23+
constructor(response?: Response, message?: string, options?: ErrorOptions) {
24+
super(undefined, response, message, options);
25+
Object.setPrototypeOf(this, OFREPApiUnexpectedResponseError.prototype);
26+
this.name = OFREPApiUnexpectedResponseError.name;
27+
}
28+
}
29+
30+
export class OFREPApiUnauthorizedError extends OFREPApiError {
31+
constructor(response: Response, message?: string, options?: ErrorOptions) {
32+
super(undefined, response, message, options);
33+
Object.setPrototypeOf(this, OFREPApiUnauthorizedError.prototype);
34+
this.name = OFREPApiUnauthorizedError.name;
35+
}
36+
}
37+
38+
export class OFREPForbiddenError extends OFREPApiError {
39+
constructor(response: Response, message?: string, options?: ErrorOptions) {
40+
super(undefined, response, message, options);
41+
Object.setPrototypeOf(this, OFREPForbiddenError.prototype);
42+
this.name = OFREPForbiddenError.name;
43+
}
44+
}
45+
46+
export class OFREPApiTooManyRequestsError extends OFREPApiError {
47+
constructor(response: Response, message?: string, options?: ErrorOptions) {
48+
super(undefined, response, message, options);
49+
Object.setPrototypeOf(this, OFREPApiTooManyRequestsError.prototype);
50+
this.name = OFREPApiTooManyRequestsError.name;
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './errors';
2+
export * from './ofrep-api';

0 commit comments

Comments
 (0)