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

feat(ofrep): ofrep core #795

Merged
merged 10 commits into from
Mar 15, 2024
1 change: 1 addition & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@
"libs/providers/launchdarkly-client": "0.2.1",
"libs/providers/go-feature-flag-web": "0.1.6",
"libs/shared/flagd-core": "0.1.11",
"libs/shared/ofrep-core": "0.0.1-experimental",
"libs/providers/flipt": "0.0.2"
}
3 changes: 3 additions & 0 deletions babel.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"babelrcRoots": ["*"]
}
25 changes: 25 additions & 0 deletions libs/shared/ofrep-core/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"extends": ["../../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.json"],
"parser": "jsonc-eslint-parser",
"rules": {
"@nx/dependency-checks": "error"
}
}
]
}
Empty file.
Empty file.
11 changes: 11 additions & 0 deletions libs/shared/ofrep-core/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/* eslint-disable */
export default {
displayName: 'ofrep-core',
preset: '../../../jest.preset.js',
testEnvironment: 'node',
transform: {
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
},
moduleFileExtensions: ['ts', 'js', 'html'],
coverageDirectory: '../../../coverage/libs/shared/ofrep-core',
};
9 changes: 9 additions & 0 deletions libs/shared/ofrep-core/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"name": "@openfeature/ofrep-core",
"version": "0.0.1-experimental",
"scripts": {
"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",
"current-version": "echo $npm_package_version"
},
"peerDependencies": {}
}
85 changes: 85 additions & 0 deletions libs/shared/ofrep-core/project.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
{
"name": "ofrep-core",
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
"sourceRoot": "libs/shared/ofrep-core/src",
"projectType": "library",
"targets": {
"publish": {
"executor": "nx:run-commands",
"options": {
"command": "npm run publish-if-not-exists",
"cwd": "dist/libs/shared/ofrep-core"
},
"dependsOn": [
"build"
]
},
"lint": {
"executor": "@nx/linter:eslint",
"outputs": [
"{options.outputFile}"
],
"options": {
"lintFilePatterns": [
"libs/shared/ofrep-core/**/*.ts"
]
}
},
"test": {
"executor": "@nx/jest:jest",
"outputs": [
"{workspaceRoot}/coverage/{projectRoot}"
],
"options": {
"jestConfig": "libs/shared/ofrep-core/jest.config.ts",
"passWithNoTests": true
},
"configurations": {
"ci": {
"ci": true,
"codeCoverage": true
}
}
},
"package": {
"executor": "@nx/rollup:rollup",
"outputs": [
"{options.outputPath}"
],
"options": {
"project": "libs/shared/ofrep-core/package.json",
"outputPath": "dist/libs/shared/ofrep-core",
"entryFile": "libs/shared/ofrep-core/src/index.ts",
"tsConfig": "libs/shared/ofrep-core/tsconfig.lib.json",
"compiler": "tsc",
"generateExportsField": true,
"buildableProjectDepsInPackageJsonType": "dependencies",
"umdName": "ofrep-core",
"external": "all",
"format": [
"cjs",
"esm"
],
"assets": [
{
"glob": "package.json",
"input": "./assets",
"output": "./src/"
},
{
"glob": "LICENSE",
"input": "./",
"output": "./"
},
{
"glob": "README.md",
"input": "./libs/shared/ofrep-core",
"output": "./"
}
],
"updateBuildableProjectDepsInPackageJson": true
}
}
},
"tags": []
}
1 change: 1 addition & 0 deletions libs/shared/ofrep-core/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './lib';
52 changes: 52 additions & 0 deletions libs/shared/ofrep-core/src/lib/api/errors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
abstract class OFREPApiError extends Error {
constructor(
public error: unknown | undefined,
public response: Response | undefined,
message?: string,
options?: ErrorOptions,
) {
super(message, options);
Object.setPrototypeOf(this, OFREPApiError.prototype);
this.name = OFREPApiError.name;
}
}

export class OFREPApiFetchError extends OFREPApiError {
constructor(error: unknown, message?: string, options?: ErrorOptions) {
super(error, undefined, message, options);
Object.setPrototypeOf(this, OFREPApiFetchError.prototype);
this.name = OFREPApiFetchError.name;
}
}

export class OFREPApiUnexpectedResponseError extends OFREPApiError {
constructor(response?: Response, message?: string, options?: ErrorOptions) {
super(undefined, response, message, options);
Object.setPrototypeOf(this, OFREPApiUnexpectedResponseError.prototype);
this.name = OFREPApiUnexpectedResponseError.name;
}
}

export class OFREPApiUnauthorizedError extends OFREPApiError {
constructor(response: Response, message?: string, options?: ErrorOptions) {
super(undefined, response, message, options);
Object.setPrototypeOf(this, OFREPApiUnauthorizedError.prototype);
this.name = OFREPApiUnauthorizedError.name;
}
}

export class OFREPForbiddenError extends OFREPApiError {
constructor(response: Response, message?: string, options?: ErrorOptions) {
super(undefined, response, message, options);
Object.setPrototypeOf(this, OFREPForbiddenError.prototype);
this.name = OFREPForbiddenError.name;
}
}

export class OFREPApiTooManyRequestsError extends OFREPApiError {
constructor(response: Response, message?: string, options?: ErrorOptions) {
super(undefined, response, message, options);
Object.setPrototypeOf(this, OFREPApiTooManyRequestsError.prototype);
this.name = OFREPApiTooManyRequestsError.name;
}
}
2 changes: 2 additions & 0 deletions libs/shared/ofrep-core/src/lib/api/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './errors';
export * from './ofrep-api';
Loading
Loading