2022-04-25 14:17:59 +02:00
|
|
|
import { OpenAPIV3 } from 'openapi-types';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { addonParameterSchema } from './spec/addon-parameter-schema';
|
|
|
|
import { addonSchema } from './spec/addon-schema';
|
|
|
|
import { addonsSchema } from './spec/addons-schema';
|
|
|
|
import { addonTypeSchema } from './spec/addon-type-schema';
|
2022-06-17 21:35:26 +02:00
|
|
|
import { apiTokenSchema } from './spec/api-token-schema';
|
|
|
|
import { apiTokensSchema } from './spec/api-tokens-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { applicationSchema } from './spec/application-schema';
|
|
|
|
import { applicationsSchema } from './spec/applications-schema';
|
|
|
|
import { changePasswordSchema } from './spec/change-password-schema';
|
|
|
|
import { clientApplicationSchema } from './spec/client-application-schema';
|
|
|
|
import { clientFeatureSchema } from './spec/client-feature-schema';
|
|
|
|
import { clientFeaturesQuerySchema } from './spec/client-features-query-schema';
|
|
|
|
import { clientFeaturesSchema } from './spec/client-features-schema';
|
|
|
|
import { clientMetricsSchema } from './spec/client-metrics-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { cloneFeatureSchema } from './spec/clone-feature-schema';
|
Complete open api schemas for project features controller (#1563)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* revert
* revert
* revert
* revert
* revert
* mapper
* revert
* revert
* revert
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* revert
* revert
* add mappers
* add mappers
* fix pr comments
* ignore report.json
* ignore report.json
* Route permission required
Co-authored-by: olav <mail@olav.io>
2022-05-18 15:17:09 +02:00
|
|
|
import { constraintSchema } from './spec/constraint-schema';
|
2022-06-17 11:11:55 +02:00
|
|
|
import { contextFieldSchema } from './spec/context-field-schema';
|
|
|
|
import { contextFieldsSchema } from './spec/context-fields-schema';
|
2022-06-17 21:35:26 +02:00
|
|
|
import { createApiTokenSchema } from './spec/create-api-token-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { createFeatureSchema } from './spec/create-feature-schema';
|
2022-06-23 08:10:20 +02:00
|
|
|
import { createFeatureStrategySchema } from './spec/create-feature-strategy-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { createUserSchema } from './spec/create-user-schema';
|
|
|
|
import { dateSchema } from './spec/date-schema';
|
|
|
|
import { emailSchema } from './spec/email-schema';
|
2022-06-08 15:31:34 +02:00
|
|
|
import { environmentSchema } from './spec/environment-schema';
|
2022-06-13 11:23:36 +02:00
|
|
|
import { environmentsSchema } from './spec/environments-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { eventSchema } from './spec/event-schema';
|
|
|
|
import { eventsSchema } from './spec/events-schema';
|
|
|
|
import { featureEnvironmentMetricsSchema } from './spec/feature-environment-metrics-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { featureEnvironmentSchema } from './spec/feature-environment-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { featureEventsSchema } from './spec/feature-events-schema';
|
|
|
|
import { featureMetricsSchema } from './spec/feature-metrics-schema';
|
Complete open api schemas for project features controller (#1563)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* revert
* revert
* revert
* revert
* revert
* mapper
* revert
* revert
* revert
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* revert
* revert
* add mappers
* add mappers
* fix pr comments
* ignore report.json
* ignore report.json
* Route permission required
Co-authored-by: olav <mail@olav.io>
2022-05-18 15:17:09 +02:00
|
|
|
import { featureSchema } from './spec/feature-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { featuresSchema } from './spec/features-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { featureStrategySchema } from './spec/feature-strategy-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { featureStrategySegmentSchema } from './spec/feature-strategy-segment-schema';
|
|
|
|
import { featureTagSchema } from './spec/feature-tag-schema';
|
2022-06-09 13:17:13 +02:00
|
|
|
import { featureTypeSchema } from './spec/feature-type-schema';
|
|
|
|
import { featureTypesSchema } from './spec/feature-types-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { featureUsageSchema } from './spec/feature-usage-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { featureVariantsSchema } from './spec/feature-variants-schema';
|
2022-06-17 08:15:56 +02:00
|
|
|
import { feedbackSchema } from './spec/feedback-schema';
|
2022-06-20 12:22:41 +02:00
|
|
|
import { healthCheckSchema } from './spec/health-check-schema';
|
2022-06-08 15:31:34 +02:00
|
|
|
import { healthOverviewSchema } from './spec/health-overview-schema';
|
|
|
|
import { healthReportSchema } from './spec/health-report-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { idSchema } from './spec/id-schema';
|
2022-06-17 11:11:55 +02:00
|
|
|
import { legalValueSchema } from './spec/legal-value-schema';
|
2022-06-23 09:40:25 +02:00
|
|
|
import { loginSchema } from './spec/login-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { mapValues } from '../util/map-values';
|
2022-06-22 14:55:43 +02:00
|
|
|
import { meSchema } from './spec/me-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { nameSchema } from './spec/name-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { omitKeys } from '../util/omit-keys';
|
|
|
|
import { overrideSchema } from './spec/override-schema';
|
Complete open api schemas for project features controller (#1563)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* Completed OpenAPI Schemas for ProjectFeatures Controller
Completed OpenAPI Schemas for Feature Controller (tags)
* bug fix
* bug fix
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* fix merge conflicts, some refactoring
* added emptyResponse, patch feature operation schemas and request
* added emptyResponse, patch feature operation schemas and request
* patch strategy
* patch strategy
* update strategy
* update strategy
* fix pr comment
* fix pr comments
* improvements
* added operationId to schema for better generation
* fix pr comment
* fix pr comment
* fix pr comment
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* improvements to generated and dynamic types
* Update response types to use inferred types
* Update addTag response status to 201
* refactor: move schema ref destructuring into createSchemaObject
* made serialize date handle deep objects
* made serialize date handle deep objects
* add `name` to IFeatureStrategy nad fix tests
* fix pr comments
* fix pr comments
* Add types to IAuthRequest
* Sync StrategySchema for FE and BE - into the rabbit hole
* Sync model with OAS spec
* revert
* revert
* revert
* revert
* revert
* mapper
* revert
* revert
* revert
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* remove serialize-dates.ts
* revert
* revert
* add mappers
* add mappers
* fix pr comments
* ignore report.json
* ignore report.json
* Route permission required
Co-authored-by: olav <mail@olav.io>
2022-05-18 15:17:09 +02:00
|
|
|
import { parametersSchema } from './spec/parameters-schema';
|
2022-06-22 14:55:43 +02:00
|
|
|
import { passwordSchema } from './spec/password-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { patchesSchema } from './spec/patches-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { patchSchema } from './spec/patch-schema';
|
2022-06-22 14:55:43 +02:00
|
|
|
import { permissionSchema } from './spec/permission-schema';
|
2022-07-12 13:01:10 +02:00
|
|
|
import { playgroundFeatureSchema } from './spec/playground-feature-schema';
|
feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839)
* Feat: return reasons why a feature evaluated to true or false
Note: this is very rough and just straight ripped from the nodejs
client. It will need a lot of work, but is a good place to start
* Feat: add suggested shape for new payload
* Chore: minor cleanup
* Wip: make server compile again
* Remove unused schema ref
* Export new schemas
* Chore: fix some tests to use sub property
* Fix: fix some tests
* Refactor: rename some variables, uncomment some stuff
* Add segments type to bootstrap options
* Add segments capability to offline feature evaluator
* Fix function calls after turning params into an option abject
* Feat: test strategy order, etc
* Feat: add test to check that all strats are returned correctly
* Feat: allow you to include strategy ids in clients
* Wip: hook up segments in the offline client.
Note: compared to regular clients, they still fail
* Feat: add segments validation
* Fix: fix test case invariant.
* Chore: revert to returning only `boolean` from strategies.
This _should_ make it work with custom strategies too 🤞
* Feat: make more properties of the returned feature required
* Wip: add some comments and unfinished tests for edge cases
* Feat: add `isEnabledInCurrentEnvironment` prop
* Feat: consider more strategy failure cases
* Feat: test that isenabledinenvironment matches expectations
* Feat: add unknown strategies
* Fix: fix property access typo
* Feat: add unknown strategy for fallback purposes
* Feat: test edge case: all unknown strategies
* Feat: add custom strategy to arbitrary
* Feat: test that features can be true, even if not enabled in env
* Chore: add some comments
* Wip: fix sdk tests
* Remove comments, improve test logging
* Feat: add descriptions and examples to playground feature schema
* Switch `examples` for `example`
* Update schemas with descriptions and examples
* Fix: update snapshot
* Fix: openapi example
* Fix: merge issues
* Fix: fix issue where feature evaluation state was wrong
* Chore: update openapi spec
* Fix: fix broken offline client tests
* Refactor: move schemas into separate files
* Refactor: remove "reason" for incomplete evaluation.
The only instances where evaluation is incomplete is when we don't
know what the strategy is.
* Refactor: move unleash node client into test and dev dependencies
* Wip: further removal of stuff
* Chore: remove a bunch of code that we don't use
* Chore: remove comment
* Chore: remove unused code
* Fix: fix some prettier errors
* Type parameters in strategies to avoid `any`
* Fix: remove commented out code
* Feat: make `id` required on playground strategies
* Chore: remove redundant type
* Fix: remove redundant if and fix fallback evaluation
* Refactor: reduce nesting and remove duplication
* Fix: remove unused helper function
* Refactor: type `parameters` as `unknown`
* Chore: remove redundant comment
* Refactor: move constraint code into a separate file
* Refactor: rename `unleash` -> `feature-evaluator`
* Rename class `Unleash` -> `FeatureEvaluator`
* Refactor: remove this.ready and sync logic from feature evaluator
* Refactor: remove unused code, rename config type
* Refactor: remove event emission from the Unleash client
* Remove unlistened-for events in feature evaluator
* Refactor: make offline client synchronous; remove code
* Fix: update openapi snapshot after adding required strategy ids
* Feat: change `strategies` format.
This commit changes the format of a playground feature's `strategies`
properties from a list of strategies to an object with properties
`result` and `data`. It looks a bit like this:
```ts
type Strategies = {
result: boolean | "unknown",
data: Strategy[]
}
```
The reason is that this allows us to avoid the breaking change that
was previously suggested in the PR:
`feature.isEnabled` used to be a straight boolean. Then, when we found
out we couldn't necessarily evaluate all strategies (custom strats are
hard!) we changed it to `boolean | 'unevaluated'`. However, this is
confusing on a few levels as the playground results are no longer the
same as the SDK would be, nor are they strictly boolean anymore.
This change reverts the `isEnabled` functionality to what it was
before (so it's always a mirror of what the SDK would show).
The equivalent of `feature.isEnabled === 'unevaluated'` now becomes
`feature.isEnabled && strategy.result === 'unknown'`.
* Fix: Fold long string descriptions over multiple lines.
* Fix: update snapshot after adding line breaks to descriptions
2022-08-04 15:41:52 +02:00
|
|
|
import { playgroundStrategySchema } from './spec/playground-strategy-schema';
|
|
|
|
import { playgroundConstraintSchema } from './spec/playground-constraint-schema';
|
|
|
|
import { playgroundSegmentSchema } from './spec/playground-segment-schema';
|
2022-07-12 13:01:10 +02:00
|
|
|
import { playgroundRequestSchema } from './spec/playground-request-schema';
|
2022-07-26 14:16:30 +02:00
|
|
|
import { playgroundResponseSchema } from './spec/playground-response-schema';
|
2022-06-08 15:31:34 +02:00
|
|
|
import { projectEnvironmentSchema } from './spec/project-environment-schema';
|
|
|
|
import { projectSchema } from './spec/project-schema';
|
|
|
|
import { projectsSchema } from './spec/projects-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { resetPasswordSchema } from './spec/reset-password-schema';
|
2022-06-22 14:55:43 +02:00
|
|
|
import { roleSchema } from './spec/role-schema';
|
2022-07-12 13:01:10 +02:00
|
|
|
import { sdkContextSchema } from './spec/sdk-context-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { segmentSchema } from './spec/segment-schema';
|
2022-07-26 14:16:30 +02:00
|
|
|
import { setStrategySortOrderSchema } from './spec/set-strategy-sort-order-schema';
|
2022-06-13 11:23:36 +02:00
|
|
|
import { sortOrderSchema } from './spec/sort-order-schema';
|
|
|
|
import { splashSchema } from './spec/splash-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { stateSchema } from './spec/state-schema';
|
|
|
|
import { strategiesSchema } from './spec/strategies-schema';
|
|
|
|
import { strategySchema } from './spec/strategy-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { tagSchema } from './spec/tag-schema';
|
|
|
|
import { tagsSchema } from './spec/tags-schema';
|
2022-06-17 21:35:26 +02:00
|
|
|
import { tagTypeSchema } from './spec/tag-type-schema';
|
|
|
|
import { tagTypesSchema } from './spec/tag-types-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { tagWithVersionSchema } from './spec/tag-with-version-schema';
|
|
|
|
import { tokenUserSchema } from './spec/token-user-schema';
|
2022-06-08 14:57:39 +02:00
|
|
|
import { uiConfigSchema } from './spec/ui-config-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { updateApiTokenSchema } from './spec/update-api-token-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { updateFeatureSchema } from './spec/update-feature-schema';
|
2022-06-23 08:10:20 +02:00
|
|
|
import { updateFeatureStrategySchema } from './spec/update-feature-strategy-schema';
|
2022-06-17 21:35:26 +02:00
|
|
|
import { updateTagTypeSchema } from './spec/update-tag-type-schema';
|
2022-06-22 14:55:43 +02:00
|
|
|
import { updateUserSchema } from './spec/update-user-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { upsertContextFieldSchema } from './spec/upsert-context-field-schema';
|
|
|
|
import { upsertStrategySchema } from './spec/upsert-strategy-schema';
|
2022-06-22 14:55:43 +02:00
|
|
|
import { userSchema } from './spec/user-schema';
|
|
|
|
import { usersSchema } from './spec/users-schema';
|
|
|
|
import { usersSearchSchema } from './spec/users-search-schema';
|
2022-06-30 14:21:40 +02:00
|
|
|
import { validatePasswordSchema } from './spec/validate-password-schema';
|
2022-06-17 21:35:26 +02:00
|
|
|
import { validateTagTypeSchema } from './spec/validate-tag-type-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
import { variantSchema } from './spec/variant-schema';
|
|
|
|
import { variantsSchema } from './spec/variants-schema';
|
2022-06-08 14:57:39 +02:00
|
|
|
import { versionSchema } from './spec/version-schema';
|
2022-06-27 15:39:08 +02:00
|
|
|
import { IServerOption } from '../types';
|
|
|
|
import { URL } from 'url';
|
2022-07-21 16:23:56 +02:00
|
|
|
import { groupSchema } from './spec/group-schema';
|
|
|
|
import { groupsSchema } from './spec/groups-schema';
|
|
|
|
import { groupUserModelSchema } from './spec/group-user-model-schema';
|
2022-07-26 13:39:55 +02:00
|
|
|
import { usersGroupsBaseSchema } from './spec/users-groups-base-schema';
|
2022-08-12 11:37:57 +02:00
|
|
|
import { openApiTags } from './util/openapi-tags';
|
2022-08-09 16:14:50 +02:00
|
|
|
import { searchEventsSchema } from './spec/search-events-schema';
|
2022-08-16 15:33:33 +02:00
|
|
|
import { proxyFeaturesSchema } from './spec/proxy-features-schema';
|
|
|
|
import { proxyFeatureSchema } from './spec/proxy-feature-schema';
|
|
|
|
import { proxyClientSchema } from './spec/proxy-client-schema';
|
|
|
|
import { proxyMetricsSchema } from './spec/proxy-metrics-schema';
|
2022-08-26 09:09:48 +02:00
|
|
|
import { setUiConfigSchema } from './spec/set-ui-config-schema';
|
2022-06-08 08:01:14 +02:00
|
|
|
|
2022-06-13 11:23:36 +02:00
|
|
|
// All schemas in `openapi/spec` should be listed here.
|
2022-06-08 08:01:14 +02:00
|
|
|
export const schemas = {
|
2022-06-30 14:21:40 +02:00
|
|
|
addonParameterSchema,
|
2022-06-22 12:49:18 +02:00
|
|
|
addonSchema,
|
|
|
|
addonsSchema,
|
|
|
|
addonTypeSchema,
|
2022-06-17 21:35:26 +02:00
|
|
|
apiTokenSchema,
|
|
|
|
apiTokensSchema,
|
2022-06-21 09:12:40 +02:00
|
|
|
applicationSchema,
|
|
|
|
applicationsSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
changePasswordSchema,
|
2022-06-24 15:29:27 +02:00
|
|
|
clientApplicationSchema,
|
2022-06-30 11:54:14 +02:00
|
|
|
clientFeatureSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
clientFeaturesQuerySchema,
|
2022-06-30 11:54:14 +02:00
|
|
|
clientFeaturesSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
clientMetricsSchema,
|
|
|
|
cloneFeatureSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
constraintSchema,
|
2022-06-17 11:11:55 +02:00
|
|
|
contextFieldSchema,
|
|
|
|
contextFieldsSchema,
|
2022-06-17 21:35:26 +02:00
|
|
|
createApiTokenSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
createFeatureSchema,
|
2022-06-23 08:10:20 +02:00
|
|
|
createFeatureStrategySchema,
|
2022-06-22 14:55:43 +02:00
|
|
|
createUserSchema,
|
2022-06-30 12:27:12 +02:00
|
|
|
dateSchema,
|
2022-06-22 14:55:43 +02:00
|
|
|
emailSchema,
|
2022-06-08 15:31:34 +02:00
|
|
|
environmentSchema,
|
2022-06-10 10:04:56 +02:00
|
|
|
environmentsSchema,
|
2022-06-30 10:12:34 +02:00
|
|
|
eventSchema,
|
|
|
|
eventsSchema,
|
2022-06-27 10:17:44 +02:00
|
|
|
featureEnvironmentMetricsSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
featureEnvironmentSchema,
|
2022-06-30 10:12:34 +02:00
|
|
|
featureEventsSchema,
|
2022-06-27 10:17:44 +02:00
|
|
|
featureMetricsSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
featureSchema,
|
|
|
|
featuresSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
featureStrategySchema,
|
2022-06-22 09:09:49 +02:00
|
|
|
featureStrategySegmentSchema,
|
|
|
|
featureTagSchema,
|
2022-06-09 13:17:13 +02:00
|
|
|
featureTypeSchema,
|
|
|
|
featureTypesSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
featureUsageSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
featureVariantsSchema,
|
2022-06-17 08:15:56 +02:00
|
|
|
feedbackSchema,
|
2022-07-21 16:23:56 +02:00
|
|
|
groupSchema,
|
|
|
|
groupsSchema,
|
|
|
|
groupUserModelSchema,
|
2022-06-20 12:22:41 +02:00
|
|
|
healthCheckSchema,
|
2022-06-08 15:31:34 +02:00
|
|
|
healthOverviewSchema,
|
|
|
|
healthReportSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
idSchema,
|
2022-06-17 11:11:55 +02:00
|
|
|
legalValueSchema,
|
2022-06-23 09:40:25 +02:00
|
|
|
loginSchema,
|
2022-06-22 14:55:43 +02:00
|
|
|
meSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
nameSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
overrideSchema,
|
|
|
|
parametersSchema,
|
2022-06-22 14:55:43 +02:00
|
|
|
passwordSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
patchesSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
patchSchema,
|
2022-06-22 14:55:43 +02:00
|
|
|
permissionSchema,
|
2022-07-12 13:01:10 +02:00
|
|
|
playgroundFeatureSchema,
|
feat(#1873/playground): Return detailed information on feature toggle evaluation (#1839)
* Feat: return reasons why a feature evaluated to true or false
Note: this is very rough and just straight ripped from the nodejs
client. It will need a lot of work, but is a good place to start
* Feat: add suggested shape for new payload
* Chore: minor cleanup
* Wip: make server compile again
* Remove unused schema ref
* Export new schemas
* Chore: fix some tests to use sub property
* Fix: fix some tests
* Refactor: rename some variables, uncomment some stuff
* Add segments type to bootstrap options
* Add segments capability to offline feature evaluator
* Fix function calls after turning params into an option abject
* Feat: test strategy order, etc
* Feat: add test to check that all strats are returned correctly
* Feat: allow you to include strategy ids in clients
* Wip: hook up segments in the offline client.
Note: compared to regular clients, they still fail
* Feat: add segments validation
* Fix: fix test case invariant.
* Chore: revert to returning only `boolean` from strategies.
This _should_ make it work with custom strategies too 🤞
* Feat: make more properties of the returned feature required
* Wip: add some comments and unfinished tests for edge cases
* Feat: add `isEnabledInCurrentEnvironment` prop
* Feat: consider more strategy failure cases
* Feat: test that isenabledinenvironment matches expectations
* Feat: add unknown strategies
* Fix: fix property access typo
* Feat: add unknown strategy for fallback purposes
* Feat: test edge case: all unknown strategies
* Feat: add custom strategy to arbitrary
* Feat: test that features can be true, even if not enabled in env
* Chore: add some comments
* Wip: fix sdk tests
* Remove comments, improve test logging
* Feat: add descriptions and examples to playground feature schema
* Switch `examples` for `example`
* Update schemas with descriptions and examples
* Fix: update snapshot
* Fix: openapi example
* Fix: merge issues
* Fix: fix issue where feature evaluation state was wrong
* Chore: update openapi spec
* Fix: fix broken offline client tests
* Refactor: move schemas into separate files
* Refactor: remove "reason" for incomplete evaluation.
The only instances where evaluation is incomplete is when we don't
know what the strategy is.
* Refactor: move unleash node client into test and dev dependencies
* Wip: further removal of stuff
* Chore: remove a bunch of code that we don't use
* Chore: remove comment
* Chore: remove unused code
* Fix: fix some prettier errors
* Type parameters in strategies to avoid `any`
* Fix: remove commented out code
* Feat: make `id` required on playground strategies
* Chore: remove redundant type
* Fix: remove redundant if and fix fallback evaluation
* Refactor: reduce nesting and remove duplication
* Fix: remove unused helper function
* Refactor: type `parameters` as `unknown`
* Chore: remove redundant comment
* Refactor: move constraint code into a separate file
* Refactor: rename `unleash` -> `feature-evaluator`
* Rename class `Unleash` -> `FeatureEvaluator`
* Refactor: remove this.ready and sync logic from feature evaluator
* Refactor: remove unused code, rename config type
* Refactor: remove event emission from the Unleash client
* Remove unlistened-for events in feature evaluator
* Refactor: make offline client synchronous; remove code
* Fix: update openapi snapshot after adding required strategy ids
* Feat: change `strategies` format.
This commit changes the format of a playground feature's `strategies`
properties from a list of strategies to an object with properties
`result` and `data`. It looks a bit like this:
```ts
type Strategies = {
result: boolean | "unknown",
data: Strategy[]
}
```
The reason is that this allows us to avoid the breaking change that
was previously suggested in the PR:
`feature.isEnabled` used to be a straight boolean. Then, when we found
out we couldn't necessarily evaluate all strategies (custom strats are
hard!) we changed it to `boolean | 'unevaluated'`. However, this is
confusing on a few levels as the playground results are no longer the
same as the SDK would be, nor are they strictly boolean anymore.
This change reverts the `isEnabled` functionality to what it was
before (so it's always a mirror of what the SDK would show).
The equivalent of `feature.isEnabled === 'unevaluated'` now becomes
`feature.isEnabled && strategy.result === 'unknown'`.
* Fix: Fold long string descriptions over multiple lines.
* Fix: update snapshot after adding line breaks to descriptions
2022-08-04 15:41:52 +02:00
|
|
|
playgroundStrategySchema,
|
|
|
|
playgroundConstraintSchema,
|
|
|
|
playgroundSegmentSchema,
|
2022-07-12 13:01:10 +02:00
|
|
|
playgroundRequestSchema,
|
2022-07-26 14:16:30 +02:00
|
|
|
playgroundResponseSchema,
|
2022-06-08 15:31:34 +02:00
|
|
|
projectEnvironmentSchema,
|
|
|
|
projectSchema,
|
|
|
|
projectsSchema,
|
2022-06-22 13:31:41 +02:00
|
|
|
resetPasswordSchema,
|
2022-06-22 14:55:43 +02:00
|
|
|
roleSchema,
|
2022-07-12 13:01:10 +02:00
|
|
|
sdkContextSchema,
|
2022-08-09 16:14:50 +02:00
|
|
|
searchEventsSchema,
|
2022-06-22 09:09:49 +02:00
|
|
|
segmentSchema,
|
2022-07-26 14:16:30 +02:00
|
|
|
setStrategySortOrderSchema,
|
2022-08-26 09:09:48 +02:00
|
|
|
setUiConfigSchema,
|
2022-06-10 10:04:56 +02:00
|
|
|
sortOrderSchema,
|
2022-06-10 15:11:07 +02:00
|
|
|
splashSchema,
|
2022-06-22 09:09:49 +02:00
|
|
|
stateSchema,
|
2022-06-23 08:10:20 +02:00
|
|
|
strategiesSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
strategySchema,
|
|
|
|
tagSchema,
|
|
|
|
tagsSchema,
|
2022-06-14 09:06:41 +02:00
|
|
|
tagTypeSchema,
|
|
|
|
tagTypesSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
tagWithVersionSchema,
|
2022-06-22 13:31:41 +02:00
|
|
|
tokenUserSchema,
|
2022-06-08 14:57:39 +02:00
|
|
|
uiConfigSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
updateApiTokenSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
updateFeatureSchema,
|
2022-06-23 08:10:20 +02:00
|
|
|
updateFeatureStrategySchema,
|
2022-06-14 09:06:41 +02:00
|
|
|
updateTagTypeSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
updateUserSchema,
|
2022-06-17 11:11:55 +02:00
|
|
|
upsertContextFieldSchema,
|
2022-06-23 08:10:20 +02:00
|
|
|
upsertStrategySchema,
|
2022-07-26 13:39:55 +02:00
|
|
|
usersGroupsBaseSchema,
|
2022-06-22 14:55:43 +02:00
|
|
|
userSchema,
|
|
|
|
usersSchema,
|
|
|
|
usersSearchSchema,
|
2022-06-30 14:21:40 +02:00
|
|
|
validatePasswordSchema,
|
|
|
|
validateTagTypeSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
variantSchema,
|
|
|
|
variantsSchema,
|
2022-06-08 14:57:39 +02:00
|
|
|
versionSchema,
|
2022-08-16 15:33:33 +02:00
|
|
|
proxyClientSchema,
|
|
|
|
proxyFeaturesSchema,
|
|
|
|
proxyFeatureSchema,
|
|
|
|
proxyMetricsSchema,
|
2022-06-08 08:01:14 +02:00
|
|
|
};
|
|
|
|
|
2022-06-13 11:23:36 +02:00
|
|
|
// Schemas must have an $id property on the form "#/components/schemas/mySchema".
|
|
|
|
export type SchemaId = typeof schemas[keyof typeof schemas]['$id'];
|
|
|
|
|
|
|
|
// Schemas must list all their $refs in `components`, including nested schemas.
|
|
|
|
export type SchemaRef = typeof schemas[keyof typeof schemas]['components'];
|
|
|
|
|
|
|
|
// JSON schema properties that should not be included in the OpenAPI spec.
|
|
|
|
export interface JsonSchemaProps {
|
|
|
|
$id: string;
|
|
|
|
components: object;
|
|
|
|
}
|
|
|
|
|
2022-06-10 10:04:56 +02:00
|
|
|
// Remove JSONSchema keys that would result in an invalid OpenAPI spec.
|
|
|
|
export const removeJsonSchemaProps = <T extends JsonSchemaProps>(
|
|
|
|
schema: T,
|
|
|
|
): OpenAPIV3.SchemaObject => {
|
|
|
|
return omitKeys(schema, '$id', 'components');
|
|
|
|
};
|
|
|
|
|
2022-06-27 15:39:08 +02:00
|
|
|
const findRootUrl: (unleashUrl: string, baseUriPath: string) => string = (
|
|
|
|
unleashUrl: string,
|
|
|
|
baseUriPath?: string,
|
|
|
|
) => {
|
|
|
|
if (!baseUriPath) {
|
|
|
|
return unleashUrl;
|
|
|
|
}
|
|
|
|
const baseUrl = new URL(unleashUrl);
|
|
|
|
if (baseUrl.pathname.indexOf(baseUriPath) >= 0) {
|
|
|
|
return `${baseUrl.protocol}//${baseUrl.host}`;
|
|
|
|
}
|
|
|
|
return baseUrl.toString();
|
|
|
|
};
|
|
|
|
|
|
|
|
export const createOpenApiSchema = ({
|
|
|
|
unleashUrl,
|
|
|
|
baseUriPath,
|
|
|
|
}: Pick<IServerOption, 'unleashUrl' | 'baseUriPath'>): Omit<
|
|
|
|
OpenAPIV3.Document,
|
|
|
|
'paths'
|
|
|
|
> => {
|
|
|
|
const url = findRootUrl(unleashUrl, baseUriPath);
|
2022-04-25 14:17:59 +02:00
|
|
|
return {
|
|
|
|
openapi: '3.0.3',
|
2022-06-27 15:39:08 +02:00
|
|
|
servers: url ? [{ url }] : [],
|
2022-04-25 14:17:59 +02:00
|
|
|
info: {
|
|
|
|
title: 'Unleash API',
|
2022-06-08 08:01:14 +02:00
|
|
|
version: process.env.npm_package_version!,
|
2022-04-25 14:17:59 +02:00
|
|
|
},
|
2022-06-08 08:01:14 +02:00
|
|
|
security: [{ apiKey: [] }],
|
2022-04-25 14:17:59 +02:00
|
|
|
components: {
|
|
|
|
securitySchemes: {
|
|
|
|
apiKey: {
|
|
|
|
type: 'apiKey',
|
|
|
|
in: 'header',
|
|
|
|
name: 'Authorization',
|
|
|
|
},
|
|
|
|
},
|
2022-06-10 10:04:56 +02:00
|
|
|
schemas: mapValues(schemas, removeJsonSchemaProps),
|
2022-04-25 14:17:59 +02:00
|
|
|
},
|
2022-08-12 11:37:57 +02:00
|
|
|
tags: openApiTags,
|
2022-04-25 14:17:59 +02:00
|
|
|
};
|
|
|
|
};
|