Skip to content
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
21 changes: 21 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Flipper Expressions

JSON Schema (`schemas/*.json`) and JS library for Flipper Expressions. The schemas are the canonical spec; the Ruby gem reimplements the expressions and vendors these schemas + examples for its tests.

## Keep flipper in sync when schemas or examples change

Any time `schemas/*.json` or `examples/*.json` change here, the vendored copies in the [flippercloud/flipper](https://github.com/flippercloud/flipper) gem must be re-synced and its specs re-run — otherwise Ruby and JS drift apart.

In a flipper checkout:

```sh
# Copies schemas/*.json and examples/*.json from this repo into flipper
# (lib/flipper/expression/schemas + spec/fixtures/expressions/examples).
# Defaults to a sibling ../expressions checkout; override with SOURCE.
rake expressions:vendor SOURCE=/path/to/expressions

# Then run flipper's specs to confirm Ruby agrees with the schema/examples.
bundle exec rspec spec/flipper/expression/schema_spec.rb
```

See the README's "Adding a new expression" section for the full cross-repo workflow.
15 changes: 15 additions & 0 deletions examples/FeatureEnabled.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"valid": [
{
"expression": { "FeatureEnabled": ["other_feature"] }
},
{
"expression": { "FeatureEnabled": [{ "Property": ["feature_name"] }] }
}
],
"invalid": [
{ "FeatureEnabled": [] },
{ "FeatureEnabled": ["a", "b"] },
{ "FeatureEnabled": ["a"], "Any": [] }
]
}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@flippercloud.io/expressions",
"version": "1.0.0",
"name": "@flippercloud/expressions",
"version": "1.1.0",
"description": "Library and Schema for evaluating Flipper Expressions",
"type": "module",
"files": [
Expand All @@ -16,7 +16,7 @@
"require": "./dist/expressions.umd.cjs"
}
},
"repository": "https:://github.com/jnunemaker/flipper",
"repository": "https://github.com/flippercloud/expressions",
"license": "MIT",
"dependencies": {
"ajv": "^8.12.0",
Expand Down
11 changes: 11 additions & 0 deletions schemas/FeatureEnabled.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://www.flippercloud.io/expressions/FeatureEnabled.schema.json",
"title": "FeatureEnabled",
"description": "Returns true if the named feature is enabled for the current actor.",
"category": "Value",
"type": "array",
"items": { "$ref": "schema.json#/definitions/string" },
"minItems": 1,
"maxItems": 1
}
3 changes: 2 additions & 1 deletion schemas/PercentageOfActors.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"$schema": "http://json-schema.org/draft-07/schema#",
"$id": "https://www.flippercloud.io/expressions/PercentageOfActors.schema.json",
"title": "PercentageOfActors",
"description": "",
"description": "Returns true when the actor falls within the given percentage for the feature.",
"category": "Condition",
"type": "array",
"items": [
{ "$ref": "schema.json#/definitions/string" },
Expand Down
1 change: 1 addition & 0 deletions schemas/Property.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "https://www.flippercloud.io/expressions/Property.schema.json",
"title": "Property",
"description": "Extract a property from context[properties].",
"category": "Value",
"type": "array",
"items": { "$ref": "schema.json#/definitions/string" },
"minItems": 1,
Expand Down
1 change: 1 addition & 0 deletions schemas/Random.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "https://www.flippercloud.io/expressions/Random.schema.json",
"title": "Random",
"description": "Return a random number",
"category": "Value",
"type": "array",
"items": {
"title": "Maximum",
Expand Down
1 change: 1 addition & 0 deletions schemas/Time.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"$id": "https://www.flippercloud.io/expressions/Time.schema.json",
"title": "Time",
"description": "A time in ISO8601 format",
"category": "Value",
"type": "array",
"items": {
"title": "Time",
Expand Down
1 change: 1 addition & 0 deletions schemas/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
"Divide": { "$ref": "Divide.schema.json" },
"Duration": { "$ref": "Duration.schema.json" },
"Equal": { "$ref": "Equal.schema.json" },
"FeatureEnabled": { "$ref": "FeatureEnabled.schema.json" },
"GreaterThan": { "$ref": "GreaterThan.schema.json" },
"GreaterThanOrEqualTo": { "$ref": "GreaterThanOrEqualTo.schema.json" },
"LessThan": { "$ref": "LessThan.schema.json" },
Expand Down
2 changes: 1 addition & 1 deletion vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export default defineConfig({
sourcemap: true,
lib: {
entry: resolve(__dirname, 'lib/index.js'),
name: '@flippercloud.io/expressions'
name: '@flippercloud/expressions'
},
rollupOptions: {
external: [
Expand Down
Loading