@featurevisor/catalog 0.0.1 → 3.1.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/LICENSE +21 -0
- package/dist/assets/index-DB7fEbI6.js +25 -0
- package/dist/assets/index-DgA0Oqrg.css +2 -0
- package/dist/favicon.png +0 -0
- package/dist/index.html +14 -0
- package/dist/logo-text.png +0 -0
- package/lib/entityTypes.d.ts +16 -0
- package/lib/entityTypes.js +96 -0
- package/lib/entityTypes.js.map +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +18 -0
- package/lib/index.js.map +1 -0
- package/lib/node/index.d.ts +74 -0
- package/lib/node/index.js +1368 -0
- package/lib/node/index.js.map +1 -0
- package/lib/types.d.ts +95 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/package.json +66 -13
- package/public/favicon.png +0 -0
- package/public/logo-text.png +0 -0
- package/src/App.tsx +62 -0
- package/src/api.spec.ts +14 -0
- package/src/api.ts +74 -0
- package/src/components/tests.spec.ts +134 -0
- package/src/components/tests.tsx +301 -0
- package/src/components/trees.tsx +202 -0
- package/src/components/ui.tsx +660 -0
- package/src/components/variables.tsx +700 -0
- package/src/components/variations.tsx +450 -0
- package/src/context/CatalogContext.tsx +30 -0
- package/src/entityTypes.spec.ts +13 -0
- package/src/entityTypes.ts +102 -0
- package/src/index.ts +1 -0
- package/src/main.tsx +26 -0
- package/src/node/index.spec.ts +380 -0
- package/src/node/index.ts +1906 -0
- package/src/pages/EntityDetailPage.tsx +1144 -0
- package/src/pages/HistoryPage.tsx +144 -0
- package/src/pages/HomePage.tsx +21 -0
- package/src/pages/ListPage.tsx +737 -0
- package/src/styles.css +59 -0
- package/src/testModel.ts +123 -0
- package/src/types.ts +112 -0
- package/src/vite-env.d.ts +1 -0
- package/index.js +0 -1
package/src/styles.css
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
@import "tailwindcss";
|
|
2
|
+
@config "../tailwind.config.mts";
|
|
3
|
+
|
|
4
|
+
:root {
|
|
5
|
+
color-scheme: light;
|
|
6
|
+
|
|
7
|
+
--mv-color-background: #e5e7eb;
|
|
8
|
+
--mv-color-surface: #ffffff;
|
|
9
|
+
--mv-color-elevated: #f8fafc;
|
|
10
|
+
--mv-color-border: #e5e7eb;
|
|
11
|
+
--mv-color-text: #374151;
|
|
12
|
+
--mv-color-muted: #6b7280;
|
|
13
|
+
--mv-color-primary: #475569;
|
|
14
|
+
--mv-color-success: #16a34a;
|
|
15
|
+
--mv-color-warning: #ea580c;
|
|
16
|
+
--mv-color-danger: #dc2626;
|
|
17
|
+
--mv-color-header: #1f2937;
|
|
18
|
+
--mv-color-header-active: #374151;
|
|
19
|
+
--mv-color-header-text: #f9fafb;
|
|
20
|
+
--mv-color-pill: #cbd5e1;
|
|
21
|
+
--mv-color-faint: #9ca3af;
|
|
22
|
+
--mv-color-success-surface: #bbf7d0;
|
|
23
|
+
--mv-color-warning-surface: #fed7aa;
|
|
24
|
+
--mv-color-danger-surface: #fee2e2;
|
|
25
|
+
--mv-shadow-soft: 0 10px 30px rgb(15 23 42 / 0.08);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
body {
|
|
29
|
+
margin: 0;
|
|
30
|
+
background: var(--mv-color-background);
|
|
31
|
+
color: var(--mv-color-text);
|
|
32
|
+
font-family:
|
|
33
|
+
ui-sans-serif,
|
|
34
|
+
system-ui,
|
|
35
|
+
-apple-system,
|
|
36
|
+
BlinkMacSystemFont,
|
|
37
|
+
"Segoe UI",
|
|
38
|
+
sans-serif;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
a {
|
|
42
|
+
color: inherit;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.variable-schema-col-path {
|
|
46
|
+
width: 28%;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.variable-schema-col-type {
|
|
50
|
+
width: 14%;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.variable-schema-col-constraints {
|
|
54
|
+
width: 30%;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
.variable-schema-col-description {
|
|
58
|
+
width: 28%;
|
|
59
|
+
}
|
package/src/testModel.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AssertionMatrix,
|
|
3
|
+
FeatureAssertion,
|
|
4
|
+
SegmentAssertion,
|
|
5
|
+
Test,
|
|
6
|
+
} from "@featurevisor/types";
|
|
7
|
+
|
|
8
|
+
export interface ExpandedTestAssertion {
|
|
9
|
+
assertion: FeatureAssertion | SegmentAssertion;
|
|
10
|
+
assertionIndex: number;
|
|
11
|
+
caseIndex?: number;
|
|
12
|
+
caseCount?: number;
|
|
13
|
+
label: string;
|
|
14
|
+
matrixValues?: Record<string, unknown>;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function getMatrixCombinations(matrix: AssertionMatrix) {
|
|
18
|
+
const keys = Object.keys(matrix);
|
|
19
|
+
|
|
20
|
+
if (keys.length === 0) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return keys.reduce<Array<Record<string, unknown>>>(
|
|
25
|
+
(combinations, key) =>
|
|
26
|
+
combinations.flatMap((combination) =>
|
|
27
|
+
matrix[key].map((value) => ({ ...combination, [key]: value })),
|
|
28
|
+
),
|
|
29
|
+
[{}],
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function applyCombinationToValue(value: unknown, combination: Record<string, unknown>) {
|
|
34
|
+
if (typeof value !== "string") {
|
|
35
|
+
return value;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const placeholders = value.match(/\${{(.+?)}}/g);
|
|
39
|
+
if (!placeholders) {
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
if (placeholders.length === 1 && value.startsWith("${{") && value.endsWith("}}")) {
|
|
44
|
+
const key = value.replace("${{", "").replace("}}", "").trim();
|
|
45
|
+
return combination[key];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return value.replace(/\${{(.+?)}}/g, (_, key) => String(combination[key.trim()]));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function applyCombinationToContext(
|
|
52
|
+
context: Record<string, unknown> | undefined,
|
|
53
|
+
combination: Record<string, unknown>,
|
|
54
|
+
) {
|
|
55
|
+
return Object.fromEntries(
|
|
56
|
+
Object.entries(context || {}).map(([key, value]) => [
|
|
57
|
+
key,
|
|
58
|
+
applyCombinationToValue(value, combination),
|
|
59
|
+
]),
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function applyCombinationToAssertion(
|
|
64
|
+
test: Test,
|
|
65
|
+
assertion: FeatureAssertion | SegmentAssertion,
|
|
66
|
+
combination: Record<string, unknown>,
|
|
67
|
+
) {
|
|
68
|
+
const result = {
|
|
69
|
+
...assertion,
|
|
70
|
+
context: applyCombinationToContext(assertion.context, combination),
|
|
71
|
+
};
|
|
72
|
+
delete result.matrix;
|
|
73
|
+
|
|
74
|
+
if (result.description) {
|
|
75
|
+
result.description = String(applyCombinationToValue(result.description, combination));
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if ("feature" in test) {
|
|
79
|
+
const featureResult = result as FeatureAssertion;
|
|
80
|
+
featureResult.environment = applyCombinationToValue(
|
|
81
|
+
featureResult.environment,
|
|
82
|
+
combination,
|
|
83
|
+
) as FeatureAssertion["environment"];
|
|
84
|
+
featureResult.target = applyCombinationToValue(
|
|
85
|
+
featureResult.target,
|
|
86
|
+
combination,
|
|
87
|
+
) as FeatureAssertion["target"];
|
|
88
|
+
const at = applyCombinationToValue(featureResult.at, combination);
|
|
89
|
+
featureResult.at = (
|
|
90
|
+
typeof at === "string" ? (at.includes(".") ? parseFloat(at) : parseInt(at, 10)) : at
|
|
91
|
+
) as FeatureAssertion["at"];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return result;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function expandTestAssertions(test: Test): ExpandedTestAssertion[] {
|
|
98
|
+
return test.assertions.flatMap((assertion, assertionIndex) => {
|
|
99
|
+
if (!assertion.matrix) {
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
assertion: { ...assertion },
|
|
103
|
+
assertionIndex,
|
|
104
|
+
label: String(assertionIndex + 1),
|
|
105
|
+
},
|
|
106
|
+
];
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const combinations = getMatrixCombinations(assertion.matrix);
|
|
110
|
+
return combinations.map((combination, caseIndex) => ({
|
|
111
|
+
assertion: applyCombinationToAssertion(test, assertion, combination),
|
|
112
|
+
assertionIndex,
|
|
113
|
+
caseIndex,
|
|
114
|
+
caseCount: combinations.length,
|
|
115
|
+
label: `${assertionIndex + 1}.${caseIndex + 1}`,
|
|
116
|
+
matrixValues: combination,
|
|
117
|
+
}));
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function getTestAssertionPermalink(testKey: string, assertionLabel: string) {
|
|
122
|
+
return `${testKey}:${assertionLabel}`;
|
|
123
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { EntityType, Test } from "@featurevisor/types";
|
|
2
|
+
|
|
3
|
+
export type CatalogEntityType = EntityType;
|
|
4
|
+
export type EntityPath =
|
|
5
|
+
| "features"
|
|
6
|
+
| "segments"
|
|
7
|
+
| "attributes"
|
|
8
|
+
| "targets"
|
|
9
|
+
| "groups"
|
|
10
|
+
| "schemas"
|
|
11
|
+
| "tests";
|
|
12
|
+
export type GitProvider = "github" | "gitlab" | "bitbucket";
|
|
13
|
+
export type DevEditorId = "cursor" | "vscode";
|
|
14
|
+
|
|
15
|
+
export interface DevEditor {
|
|
16
|
+
id: DevEditorId;
|
|
17
|
+
label: string;
|
|
18
|
+
icon: DevEditorId;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface LastModified {
|
|
22
|
+
commit: string;
|
|
23
|
+
author: string;
|
|
24
|
+
timestamp: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface EntitySummary {
|
|
28
|
+
key: string;
|
|
29
|
+
description?: string;
|
|
30
|
+
archived?: boolean;
|
|
31
|
+
deprecated?: boolean;
|
|
32
|
+
promotable?: boolean;
|
|
33
|
+
environmentStatus?: "production" | "other" | "disabled";
|
|
34
|
+
environmentStatusEnvironment?: string;
|
|
35
|
+
tags?: string[];
|
|
36
|
+
targets?: string[];
|
|
37
|
+
usedInFeatureCount?: number;
|
|
38
|
+
usedInSegmentCount?: number;
|
|
39
|
+
environments?: string[];
|
|
40
|
+
variationValues?: string[];
|
|
41
|
+
variableKeys?: string[];
|
|
42
|
+
hasVariations?: boolean;
|
|
43
|
+
hasVariables?: boolean;
|
|
44
|
+
lastModified?: LastModified;
|
|
45
|
+
href: string;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface CatalogIndex {
|
|
49
|
+
set: string;
|
|
50
|
+
counts: Record<CatalogEntityType, number>;
|
|
51
|
+
entities: Record<CatalogEntityType, EntitySummary[]>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface CatalogManifest {
|
|
55
|
+
schemaVersion: string;
|
|
56
|
+
generatedAt: string;
|
|
57
|
+
router?: "hash" | "browser";
|
|
58
|
+
sets: boolean;
|
|
59
|
+
setKeys: string[];
|
|
60
|
+
projectConfig: {
|
|
61
|
+
tags: string[];
|
|
62
|
+
environments?: string[];
|
|
63
|
+
};
|
|
64
|
+
dev?: {
|
|
65
|
+
editors: DevEditor[];
|
|
66
|
+
};
|
|
67
|
+
links?: {
|
|
68
|
+
provider?: GitProvider;
|
|
69
|
+
repository?: string;
|
|
70
|
+
source: string;
|
|
71
|
+
commit: string;
|
|
72
|
+
};
|
|
73
|
+
paths: {
|
|
74
|
+
projectHistory: string;
|
|
75
|
+
root?: string;
|
|
76
|
+
sets?: Record<string, string>;
|
|
77
|
+
};
|
|
78
|
+
counts: Record<string, Record<CatalogEntityType, number>>;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface HistoryEntity {
|
|
82
|
+
type: CatalogEntityType;
|
|
83
|
+
key: string;
|
|
84
|
+
set?: string;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface HistoryEntry {
|
|
88
|
+
commit: string;
|
|
89
|
+
author: string;
|
|
90
|
+
timestamp: string;
|
|
91
|
+
entities: HistoryEntity[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface HistoryPage {
|
|
95
|
+
page: number;
|
|
96
|
+
pageSize: number;
|
|
97
|
+
totalPages: number;
|
|
98
|
+
entries: HistoryEntry[];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface EntityDetail<T = Record<string, unknown>> {
|
|
102
|
+
type: CatalogEntityType;
|
|
103
|
+
key: string;
|
|
104
|
+
entity: T;
|
|
105
|
+
sourcePath?: string;
|
|
106
|
+
editLinks?: Partial<Record<DevEditorId, string>>;
|
|
107
|
+
lastModified?: LastModified;
|
|
108
|
+
relationships?: Record<string, string[]>;
|
|
109
|
+
tests?: Test[];
|
|
110
|
+
environments?: string[];
|
|
111
|
+
historyPath?: string;
|
|
112
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|
package/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
module.exports = {};
|