@featurevisor/site 1.3.0 → 1.5.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,6 +5,10 @@ export interface Query {
5
5
  environments: string[];
6
6
  archived?: boolean;
7
7
  capture?: boolean;
8
+ hasVariations?: boolean;
9
+ hasVariables?: boolean;
10
+ variableKeys?: string[];
11
+ variationValues?: string[];
8
12
  }
9
13
  export declare function parseSearchQuery(queryString: string): Query;
10
14
  export declare function isEnabledInEnvironment(feature: any, environment: string): boolean;
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "links": {
3
- "attribute": "https://github.com/fahad19/featurevisor/blob/site-variable-show/examples/example-1/attributes/{{key}}.yml",
4
- "segment": "https://github.com/fahad19/featurevisor/blob/site-variable-show/examples/example-1/segments/{{key}}.yml",
5
- "feature": "https://github.com/fahad19/featurevisor/blob/site-variable-show/examples/example-1/features/{{key}}.yml",
6
- "commit": "https://github.com/fahad19/featurevisor/commit/{{hash}}"
3
+ "attribute": "https://github.com/featurevisor/featurevisor/blob/main/examples/example-1/attributes/{{key}}.yml",
4
+ "segment": "https://github.com/featurevisor/featurevisor/blob/main/examples/example-1/segments/{{key}}.yml",
5
+ "feature": "https://github.com/featurevisor/featurevisor/blob/main/examples/example-1/features/{{key}}.yml",
6
+ "commit": "https://github.com/featurevisor/featurevisor/commit/{{hash}}"
7
7
  },
8
8
  "entities": {
9
9
  "attributes": [
@@ -70,7 +70,7 @@
70
70
  "timestamp": "2023-03-05T18:38:34+01:00",
71
71
  "author": "Fahad Heylaal"
72
72
  },
73
- "usedInFeatures": ["foo", "showPopup"],
73
+ "usedInFeatures": ["foo", "showBanner", "showPopup"],
74
74
  "usedInSegments": ["qa"]
75
75
  },
76
76
  {
@@ -151,7 +151,7 @@
151
151
  "timestamp": "2023-11-21T17:50:37+01:00",
152
152
  "author": "Fahad Heylaal"
153
153
  },
154
- "usedInFeatures": ["showPopup"]
154
+ "usedInFeatures": ["showBanner", "showPopup"]
155
155
  },
156
156
  {
157
157
  "archived": false,
@@ -407,8 +407,8 @@
407
407
  },
408
408
  "key": "foo",
409
409
  "lastModified": {
410
- "commit": "986fc2f",
411
- "timestamp": "2024-01-04T19:17:05+01:00",
410
+ "commit": "9daf95b",
411
+ "timestamp": "2024-01-11T20:17:34+01:00",
412
412
  "author": "Fahad Heylaal"
413
413
  }
414
414
  },
@@ -494,6 +494,31 @@
494
494
  "author": "Fahad Heylaal"
495
495
  }
496
496
  },
497
+ {
498
+ "description": "for testing expose property with tags",
499
+ "tags": ["all", "checkout"],
500
+ "bucketBy": "userId",
501
+ "environments": {
502
+ "staging": {
503
+ "expose": ["checkout"],
504
+ "force": [
505
+ { "segments": "qa", "enabled": true },
506
+ {
507
+ "conditions": [{ "attribute": "userId", "operator": "equals", "value": "user-3" }],
508
+ "enabled": true
509
+ }
510
+ ],
511
+ "rules": [{ "key": "1", "segments": "*", "percentage": 0 }]
512
+ },
513
+ "production": { "rules": [{ "key": "1", "segments": "*", "percentage": 0 }] }
514
+ },
515
+ "key": "showBanner",
516
+ "lastModified": {
517
+ "commit": "1ae08e7",
518
+ "timestamp": "2024-01-23T22:36:30+01:00",
519
+ "author": "Fahad Heylaal"
520
+ }
521
+ },
497
522
  {
498
523
  "description": "for testing force API in features",
499
524
  "tags": ["all"],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@featurevisor/site",
3
- "version": "1.3.0",
3
+ "version": "1.5.1",
4
4
  "description": "Static site for Featurevisor",
5
5
  "main": "dist",
6
6
  "scripts": {
@@ -65,5 +65,5 @@
65
65
  "dependencies": {
66
66
  "@featurevisor/types": "^1.3.0"
67
67
  },
68
- "gitHead": "92829e94ab09474433695d29577bd3eb22490f97"
68
+ "gitHead": "1202fddb786e61079771c78f5a4a33dddd11bdfe"
69
69
  }
@@ -216,6 +216,13 @@ export function DisplayFeatureRulesTable() {
216
216
  </p>
217
217
  )}
218
218
 
219
+ {Array.isArray(feature.environments[environmentKey].expose) && (
220
+ <p className="mt-2 block rounded border-2 border-orange-300 bg-orange-200 p-3 text-sm text-gray-600">
221
+ Rules are <a href="https://featurevisor.com/docs/features/#expose">exposed</a> for these
222
+ tags only: {feature.environments[environmentKey].expose.join(", ")}.
223
+ </p>
224
+ )}
225
+
219
226
  <table className="mt-3 min-w-full divide-y divide-gray-300 border border-gray-200">
220
227
  <thead className="bg-gray-50">
221
228
  <tr>
@@ -6,6 +6,10 @@ export interface Query {
6
6
  environments: string[];
7
7
  archived?: boolean;
8
8
  capture?: boolean;
9
+ hasVariations?: boolean;
10
+ hasVariables?: boolean;
11
+ variableKeys?: string[];
12
+ variationValues?: string[];
9
13
  }
10
14
 
11
15
  export function parseSearchQuery(queryString: string) {
@@ -48,6 +52,34 @@ export function parseSearchQuery(queryString: string) {
48
52
  } else if (capture === "false") {
49
53
  query.capture = false;
50
54
  }
55
+ } else if (part.startsWith("variable:")) {
56
+ const variableKey = part.replace("variable:", "");
57
+
58
+ if (typeof query.variableKeys === "undefined") {
59
+ query.variableKeys = [];
60
+ }
61
+
62
+ if (variableKey.length > 0) {
63
+ query.variableKeys.push(variableKey);
64
+ }
65
+ } else if (part.startsWith("variation:")) {
66
+ const variationValue = part.replace("variation:", "");
67
+
68
+ if (typeof query.variationValues === "undefined") {
69
+ query.variationValues = [];
70
+ }
71
+
72
+ if (variationValue.length > 0) {
73
+ query.variationValues.push(variationValue);
74
+ }
75
+ } else if (part === "with:variations") {
76
+ query.hasVariations = true;
77
+ } else if (part === "without:variations") {
78
+ query.hasVariations = false;
79
+ } else if (part === "with:variables") {
80
+ query.hasVariables = true;
81
+ } else if (part === "without:variables") {
82
+ query.hasVariables = false;
51
83
  } else {
52
84
  if (part.length > 0) {
53
85
  query.keyword = part;
@@ -127,6 +159,50 @@ export function getFeaturesByQuery(query: Query, data: SearchIndex) {
127
159
  }
128
160
  }
129
161
 
162
+ if (typeof query.hasVariations !== "undefined") {
163
+ if (query.hasVariations && !feature.variations) {
164
+ matched = false;
165
+ }
166
+
167
+ if (!query.hasVariations && feature.variations) {
168
+ matched = false;
169
+ }
170
+ }
171
+
172
+ if (typeof query.variationValues !== "undefined") {
173
+ if (!feature.variations) {
174
+ matched = false;
175
+ } else {
176
+ const valuesFromFeature = feature.variations.map((v: any) => v.value);
177
+
178
+ if (query.variationValues.some((v) => valuesFromFeature.indexOf(v) === -1)) {
179
+ matched = false;
180
+ }
181
+ }
182
+ }
183
+
184
+ if (typeof query.variableKeys !== "undefined") {
185
+ if (!feature.variablesSchema) {
186
+ matched = false;
187
+ } else {
188
+ const keysFromFeature = feature.variablesSchema.map((v: any) => v.key);
189
+
190
+ if (query.variableKeys.some((k) => keysFromFeature.indexOf(k) === -1)) {
191
+ matched = false;
192
+ }
193
+ }
194
+ }
195
+
196
+ if (typeof query.hasVariables !== "undefined") {
197
+ if (query.hasVariables && !feature.variablesSchema) {
198
+ matched = false;
199
+ }
200
+
201
+ if (!query.hasVariables && feature.variablesSchema) {
202
+ matched = false;
203
+ }
204
+ }
205
+
130
206
  return matched;
131
207
  })
132
208
  .sort((a, b) => a.key.localeCompare(b.key));