@featurevisor/types 2.10.0 → 2.12.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/CHANGELOG.md CHANGED
@@ -3,6 +3,17 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [2.12.0](https://github.com/featurevisor/featurevisor/compare/v2.11.0...v2.12.0) (2026-02-21)
7
+
8
+
9
+ ### Features
10
+
11
+ * reusable schemas ([#390](https://github.com/featurevisor/featurevisor/issues/390)) ([fa32095](https://github.com/featurevisor/featurevisor/commit/fa3209554c08bdc2c7cc3dd8af8f8fc51213e7be))
12
+
13
+
14
+
15
+
16
+
6
17
  # [2.10.0](https://github.com/featurevisor/featurevisor/compare/v2.9.0...v2.10.0) (2026-02-15)
7
18
 
8
19
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@featurevisor/types",
3
- "version": "2.10.0",
3
+ "version": "2.12.0",
4
4
  "description": "Common Typescript types for Featurevisor",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
@@ -47,5 +47,5 @@
47
47
  "url": "https://github.com/featurevisor/featurevisor/issues"
48
48
  },
49
49
  "license": "MIT",
50
- "gitHead": "0cbe15fb45fd08ebd70125f1604ae7fe7e20756a"
50
+ "gitHead": "d7542c7da3615c821b031912e4d12ca4c81e5db2"
51
51
  }
package/src/datafile.d.ts CHANGED
@@ -9,6 +9,7 @@ import type {
9
9
  Required,
10
10
  VariableKey,
11
11
  VariableSchema,
12
+ ResolvedVariableSchema,
12
13
  Variation,
13
14
  Force,
14
15
  VariationV1,
@@ -46,7 +47,7 @@ export interface Feature {
46
47
  hash?: string;
47
48
  deprecated?: boolean;
48
49
  required?: Required[];
49
- variablesSchema?: Record<VariableKey, VariableSchema>;
50
+ variablesSchema?: Record<VariableKey, ResolvedVariableSchema>;
50
51
  disabledVariationValue?: VariationValue;
51
52
  variations?: Variation[];
52
53
  bucketBy: BucketBy;
package/src/feature.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { BucketBy } from "./bucket";
2
2
  import type { Condition } from "./condition";
3
3
  import type { GroupSegment } from "./segment";
4
- import type { PropertyType, Value, PropertySchema } from "./property";
4
+ import type { SchemaType, Value, Schema, SchemaKey } from "./schema";
5
5
 
6
6
  export type VariationValue = string;
7
7
 
8
8
  export type VariableKey = string;
9
- export type VariableType = PropertyType | "json";
9
+ export type VariableType = SchemaType | "json";
10
10
  export type VariableValue =
11
11
  | Value
12
12
  // @TODO: consider removing below items
@@ -59,22 +59,69 @@ export interface Variation {
59
59
  };
60
60
  }
61
61
 
62
- export interface VariableSchema {
62
+ /** Variable schema that references a reusable schema by key. No type/properties/required/items. */
63
+ export interface VariableSchemaWithReference {
63
64
  deprecated?: boolean;
64
65
  key?: VariableKey; // @NOTE: remove
65
- type: VariableType;
66
+ schema: SchemaKey;
67
+
68
+ defaultValue: VariableValue;
69
+ description?: string; // only available in YAML files
70
+ useDefaultWhenDisabled?: boolean;
71
+ disabledValue?: VariableValue;
72
+ }
73
+
74
+ /** Variable schema with inline type and optional structure. */
75
+ export interface VariableSchemaWithInline {
76
+ deprecated?: boolean;
77
+ key?: VariableKey; // @NOTE: remove
78
+ type?: VariableType; // required when not using oneOf
79
+
80
+ properties?: Schema; // if type is object
81
+ required?: Schema["required"]; // if type is object
82
+ items?: Schema["items"]; // if type is array
83
+ oneOf?: Schema[]; // value must match exactly one of these (mutually exclusive with type at top level when used)
84
+ enum?: Value[];
85
+ const?: VariableValue;
86
+
87
+ // Numeric validation (when type is "integer" or "double")
88
+ minimum?: number;
89
+ maximum?: number;
66
90
 
67
- properties?: PropertySchema; // if type is object
68
- required?: PropertySchema["required"]; // if type is object
69
- items?: PropertySchema["items"]; // if type is array
91
+ // String validation (when type is "string")
92
+ minLength?: number;
93
+ maxLength?: number;
94
+ pattern?: string;
95
+
96
+ // Array validation (when type is "array")
97
+ minItems?: number;
98
+ maxItems?: number;
99
+ uniqueItems?: boolean;
70
100
 
71
101
  defaultValue: VariableValue;
72
- // nullable?: boolean; // @TODO: consider in future
73
102
  description?: string; // only available in YAML files
74
103
  useDefaultWhenDisabled?: boolean;
75
104
  disabledValue?: VariableValue;
76
105
  }
77
106
 
107
+ /** Either a reference to a reusable schema or an inline variable schema. */
108
+ export type VariableSchema = VariableSchemaWithReference | VariableSchemaWithInline;
109
+
110
+ /**
111
+ * Variable schema as emitted in the datafile (schema refs resolved to type only).
112
+ * Used by SDK and datafile; only `type` is kept from the schema for datafile size.
113
+ */
114
+ export interface ResolvedVariableSchema {
115
+ deprecated?: boolean;
116
+ key?: VariableKey;
117
+ type: VariableType;
118
+
119
+ defaultValue: VariableValue;
120
+ description?: string;
121
+ useDefaultWhenDisabled?: boolean;
122
+ disabledValue?: VariableValue;
123
+ }
124
+
78
125
  export type FeatureKey = string;
79
126
 
80
127
  export interface RequiredWithVariation {
package/src/index.d.ts CHANGED
@@ -9,4 +9,4 @@ export * from "./segment";
9
9
  export * from "./site";
10
10
  export * from "./state";
11
11
  export * from "./test";
12
- export * from "./property";
12
+ export * from "./schema";
@@ -0,0 +1,59 @@
1
+ export type SchemaKey = string;
2
+
3
+ export type ObjectValue = { [key: string]: Value };
4
+ export type Value =
5
+ | boolean
6
+ | string
7
+ | number // covers integer and double
8
+ // | Date // @TODO: support in future
9
+ | ObjectValue
10
+ | Value[];
11
+
12
+ export type SchemaType =
13
+ | "boolean"
14
+ | "string"
15
+ | "integer"
16
+ | "double"
17
+ | "object"
18
+ // | "date" // @TODO: support in future
19
+ | "array";
20
+
21
+ // adapted JSON Schema for Featurevisor
22
+ export interface Schema {
23
+ // Basic metadata
24
+ description?: string;
25
+
26
+ // General validation keywords
27
+ type?: SchemaType;
28
+ enum?: Value[];
29
+ const?: Value;
30
+
31
+ // Numeric validation keywords (when type is "integer" or "double")
32
+ maximum?: number;
33
+ minimum?: number;
34
+
35
+ // String validation keywords (when type is "string")
36
+ maxLength?: number;
37
+ minLength?: number;
38
+ pattern?: string;
39
+
40
+ // Array validation keywords (when type is "array")
41
+ items?: Schema;
42
+ maxItems?: number;
43
+ minItems?: number;
44
+ uniqueItems?: boolean;
45
+
46
+ // Object validation keywords
47
+ required?: string[];
48
+ properties?: { [key: string]: Schema };
49
+
50
+ // Annotations
51
+ // default?: Value;
52
+ // examples?: Value[];
53
+
54
+ // when referencing another Schema by name
55
+ schema?: SchemaKey;
56
+
57
+ // oneOf: value must match exactly one of the given schemas (reusable Schema level only)
58
+ oneOf?: Schema[];
59
+ }
package/src/site.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { Attribute } from "./attribute";
2
2
  import type { Segment, SegmentKey } from "./segment";
3
3
  import type { Tag, EnvironmentKey, FeatureKey, ParsedFeature } from "./feature";
4
4
 
5
- export type EntityType = "attribute" | "segment" | "feature" | "group" | "test";
5
+ export type EntityType = "attribute" | "segment" | "feature" | "group" | "schema" | "test";
6
6
 
7
7
  export type CommitHash = string;
8
8
 
package/src/property.d.ts DELETED
@@ -1,55 +0,0 @@
1
- export type Schema = PropertySchema;
2
-
3
- export type ObjectValue = { [key: string]: Value };
4
- export type Value =
5
- | boolean
6
- | string
7
- | number // covers integer and double
8
- // | Date // @TODO: support in future
9
- | ObjectValue
10
- | Value[];
11
-
12
- export type PropertyType =
13
- | "boolean"
14
- | "string"
15
- | "integer"
16
- | "double"
17
- | "object"
18
- // | "date" // @TODO: support in future
19
- // | "semver" // @TODO: consider in future
20
- // | "url" // @TODO: consider in future
21
- | "array";
22
-
23
- // adapted JSON Schema for Featurevisor
24
- export interface PropertySchema {
25
- // Basic metadata
26
- description?: string;
27
-
28
- // General validation keywords
29
- type?: PropertyType;
30
- // enum?: Value[];
31
- // const?: Value;
32
-
33
- // Numeric validation keywords
34
- // maximum?: number;
35
- // minimum?: number;
36
-
37
- // String validation keywords
38
- // maxLength?: number;
39
- // minLength?: number;
40
- // pattern?: string;
41
-
42
- // Array validation keywords
43
- items?: PropertySchema; // @TODO: allow array of items in future | PropertySchema[];
44
- // maxItems?: number;
45
- // minItems?: number;
46
- // uniqueItems?: boolean;
47
-
48
- // Object validation keywords
49
- required?: string[];
50
- properties?: { [key: string]: PropertySchema };
51
-
52
- // Annotations
53
- // default?: Value;
54
- // examples?: Value[];
55
- }