@featurevisor/site 1.3.0 → 1.5.0
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.
- package/.eslintcache +1 -1
- package/CHANGELOG.md +11 -0
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/lib/utils/index.d.ts +4 -0
- package/package.json +2 -2
- package/src/utils/index.ts +76 -0
package/lib/utils/index.d.ts
CHANGED
|
@@ -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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@featurevisor/site",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
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": "
|
|
68
|
+
"gitHead": "522f5c631801a198ecb676ce7ee719b45fbf4cf4"
|
|
69
69
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -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));
|