@featurevisor/types 0.0.3
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 +30 -0
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/lib/index.d.ts +170 -0
- package/lib/index.js +2 -0
- package/lib/index.js.map +1 -0
- package/package.json +45 -0
- package/src/index.ts +251 -0
- package/tsconfig.cjs.json +7 -0
- package/tsconfig.esm.json +7 -0
- package/webpack.config.js +13 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
## [0.0.3](https://github.com/fahad19/featurevisor/compare/v0.0.2...v0.0.3) (2023-03-05)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* publish access ([ea5cd7c](https://github.com/fahad19/featurevisor/commit/ea5cd7cd8554e2def5fdcc1d3488598a08e99bfa))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## [0.0.2](https://github.com/fahad19/featurevisor/compare/v0.0.1...v0.0.2) (2023-03-05)
|
|
18
|
+
|
|
19
|
+
**Note:** Version bump only for package @featurevisor/types
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## 0.0.1 (2023-03-05)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* linting ([230bfa0](https://github.com/fahad19/featurevisor/commit/230bfa0824f79181581585ccc37c2e78c5aeac42))
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2023 Fahad Heylaal (https://fahad19.com)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# @featurevisor/types
|
|
2
|
+
|
|
3
|
+
Common TypeScript typings for Featurevisor packages.
|
|
4
|
+
|
|
5
|
+
Visit [https://featurevisor.com](https://featurevisor.com) for more information.
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
$ npm install --save @featurevisor/types
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## License
|
|
14
|
+
|
|
15
|
+
MIT © [Fahad Heylaal](https://fahad19.com)
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.FeaturevisorTypes=t():e.FeaturevisorTypes=t()}(this,(()=>(()=>{"use strict";var e={};return(()=>{var t=e;Object.defineProperty(t,"__esModule",{value:!0})})(),e})()));
|
|
2
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","mappings":"CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,GACe,iBAAZC,QACdA,QAA2B,kBAAID,IAE/BD,EAAwB,kBAAIC,GAC7B,CATD,CASGK,MAAM,I","sources":["webpack://FeaturevisorTypes/webpack/universalModuleDefinition"],"sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"FeaturevisorTypes\"] = factory();\n\telse\n\t\troot[\"FeaturevisorTypes\"] = factory();\n})(this, () => {\nreturn "],"names":["root","factory","exports","module","define","amd","this"],"sourceRoot":""}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
export type AttributeKey = string;
|
|
2
|
+
export type AttributeValue = string | number | boolean | null | undefined;
|
|
3
|
+
export interface Attributes {
|
|
4
|
+
[key: AttributeKey]: AttributeValue;
|
|
5
|
+
}
|
|
6
|
+
export interface Attribute {
|
|
7
|
+
archived?: boolean;
|
|
8
|
+
key: AttributeKey;
|
|
9
|
+
type: AttributeValue;
|
|
10
|
+
capture?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export type Operator = "equals" | "notEquals" | "greaterThan" | "greaterThanOrEquals" | "lessThan" | "lessThanOrEquals" | "contains" | "notContains" | "startsWith" | "endsWith" | "in" | "notIn";
|
|
13
|
+
export type ConditionValue = string | number | boolean | null | undefined | string[];
|
|
14
|
+
export interface PlainCondition {
|
|
15
|
+
attribute: AttributeKey;
|
|
16
|
+
operator: Operator;
|
|
17
|
+
value: ConditionValue;
|
|
18
|
+
}
|
|
19
|
+
export interface AndCondition {
|
|
20
|
+
and: Condition[];
|
|
21
|
+
}
|
|
22
|
+
export interface OrCondition {
|
|
23
|
+
or: Condition[];
|
|
24
|
+
}
|
|
25
|
+
export type AndOrCondition = AndCondition | OrCondition;
|
|
26
|
+
export type Condition = PlainCondition | AndOrCondition;
|
|
27
|
+
export type SegmentKey = string;
|
|
28
|
+
export interface Segment {
|
|
29
|
+
archived?: boolean;
|
|
30
|
+
key: SegmentKey;
|
|
31
|
+
conditions: Condition | Condition[] | string;
|
|
32
|
+
}
|
|
33
|
+
export type PlainGroupSegment = SegmentKey;
|
|
34
|
+
export interface AndGroupSegment {
|
|
35
|
+
and: GroupSegment[];
|
|
36
|
+
}
|
|
37
|
+
export interface OrGroupSegment {
|
|
38
|
+
or: GroupSegment[];
|
|
39
|
+
}
|
|
40
|
+
export type AndOrGroupSegment = AndGroupSegment | OrGroupSegment;
|
|
41
|
+
export type GroupSegment = PlainGroupSegment | AndOrGroupSegment;
|
|
42
|
+
export type VariationType = "boolean" | "string" | "integer" | "double";
|
|
43
|
+
export type VariationValue = boolean | string | number | null | undefined;
|
|
44
|
+
export type VariableKey = string;
|
|
45
|
+
export type VariableType = "boolean" | "string" | "integer" | "double" | "array";
|
|
46
|
+
export type VariableValue = boolean | string | number | string[] | null | undefined;
|
|
47
|
+
export interface VariableOverrideSegments {
|
|
48
|
+
segments: GroupSegment | GroupSegment[];
|
|
49
|
+
}
|
|
50
|
+
export interface VariableOverrideConditions {
|
|
51
|
+
conditions: Condition | Condition[];
|
|
52
|
+
}
|
|
53
|
+
export interface VariableOverrideBase {
|
|
54
|
+
value: VariableValue;
|
|
55
|
+
}
|
|
56
|
+
export type VariableOverrideSegmentsOrConditions = VariableOverrideSegments | VariableOverrideConditions;
|
|
57
|
+
export interface VariableOverride {
|
|
58
|
+
value: VariableValue;
|
|
59
|
+
conditions?: Condition | Condition[];
|
|
60
|
+
segments?: GroupSegment | GroupSegment[];
|
|
61
|
+
}
|
|
62
|
+
export interface Variable {
|
|
63
|
+
key: VariableKey;
|
|
64
|
+
value: VariableValue;
|
|
65
|
+
overrides?: VariableOverride[];
|
|
66
|
+
}
|
|
67
|
+
export interface Variation {
|
|
68
|
+
type: VariationType;
|
|
69
|
+
value: VariationValue;
|
|
70
|
+
weight?: Weight;
|
|
71
|
+
variables?: Variable[];
|
|
72
|
+
}
|
|
73
|
+
export interface VariableSchema {
|
|
74
|
+
key: VariableKey;
|
|
75
|
+
type: VariableType;
|
|
76
|
+
defaultValue: VariableValue;
|
|
77
|
+
}
|
|
78
|
+
export type FeatureKey = string;
|
|
79
|
+
export interface Force {
|
|
80
|
+
conditions?: Condition | Condition[];
|
|
81
|
+
segments?: GroupSegment | GroupSegment[];
|
|
82
|
+
variation: VariationValue;
|
|
83
|
+
variables?: {
|
|
84
|
+
[key: string]: VariableValue;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
export type BucketKey = string;
|
|
88
|
+
export type BucketValue = number;
|
|
89
|
+
/**
|
|
90
|
+
* Datafile-only types
|
|
91
|
+
*/
|
|
92
|
+
export type Percentage = number;
|
|
93
|
+
export interface Allocation {
|
|
94
|
+
variation: VariationValue;
|
|
95
|
+
percentage: Percentage;
|
|
96
|
+
}
|
|
97
|
+
export interface Traffic {
|
|
98
|
+
key: RuleKey;
|
|
99
|
+
segments: GroupSegment | GroupSegment[] | "*";
|
|
100
|
+
percentage: Percentage;
|
|
101
|
+
allocation: Allocation[];
|
|
102
|
+
}
|
|
103
|
+
export type BucketBy = AttributeKey | AttributeKey[];
|
|
104
|
+
export interface Feature {
|
|
105
|
+
key: FeatureKey;
|
|
106
|
+
defaultVariation: VariationValue;
|
|
107
|
+
variablesSchema?: VariableSchema[];
|
|
108
|
+
variations: Variation[];
|
|
109
|
+
bucketBy: BucketBy;
|
|
110
|
+
traffic: Traffic[];
|
|
111
|
+
force?: Force[];
|
|
112
|
+
}
|
|
113
|
+
export interface DatafileContent {
|
|
114
|
+
schemaVersion: string;
|
|
115
|
+
revision: string;
|
|
116
|
+
attributes: Attribute[];
|
|
117
|
+
segments: Segment[];
|
|
118
|
+
features: Feature[];
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* YAML-only type
|
|
122
|
+
*/
|
|
123
|
+
export type Weight = number;
|
|
124
|
+
export type EnvironmentKey = string;
|
|
125
|
+
export type RuleKey = string;
|
|
126
|
+
export interface Rule {
|
|
127
|
+
key: RuleKey;
|
|
128
|
+
segments: GroupSegment | GroupSegment[];
|
|
129
|
+
percentage: Weight;
|
|
130
|
+
}
|
|
131
|
+
export interface Environment {
|
|
132
|
+
expose?: boolean;
|
|
133
|
+
rules: Rule[];
|
|
134
|
+
force?: Force[];
|
|
135
|
+
}
|
|
136
|
+
export interface ParsedFeature {
|
|
137
|
+
key: FeatureKey;
|
|
138
|
+
archived: boolean;
|
|
139
|
+
description: string;
|
|
140
|
+
tags: string[];
|
|
141
|
+
bucketBy?: AttributeKey | AttributeKey[];
|
|
142
|
+
defaultVariation: VariationValue;
|
|
143
|
+
variablesSchema?: VariableSchema[];
|
|
144
|
+
variations: Variation[];
|
|
145
|
+
environments: {
|
|
146
|
+
[key: EnvironmentKey]: Environment;
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* For maintaining old allocations info,
|
|
151
|
+
* allowing for gradual rollout of new allocations
|
|
152
|
+
* with consistent bucketing
|
|
153
|
+
*/
|
|
154
|
+
export interface ExistingFeature {
|
|
155
|
+
variations: {
|
|
156
|
+
value: VariationValue;
|
|
157
|
+
weight: Weight;
|
|
158
|
+
}[];
|
|
159
|
+
traffic: {
|
|
160
|
+
key: RuleKey;
|
|
161
|
+
percentage: Percentage;
|
|
162
|
+
allocation: Allocation[];
|
|
163
|
+
}[];
|
|
164
|
+
}
|
|
165
|
+
export interface ExistingFeatures {
|
|
166
|
+
[key: FeatureKey]: ExistingFeature;
|
|
167
|
+
}
|
|
168
|
+
export interface ExistingState {
|
|
169
|
+
features: ExistingFeatures;
|
|
170
|
+
}
|
package/lib/index.js
ADDED
package/lib/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@featurevisor/types",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Common Typescript types for Featurevisor",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "lib/index.js",
|
|
7
|
+
"types": "lib/index.d.ts",
|
|
8
|
+
"scripts": {
|
|
9
|
+
"lint": "echo 'not linting in this package yet'",
|
|
10
|
+
"transpile": "rimraf lib && tsc --project tsconfig.esm.json",
|
|
11
|
+
"dist": "webpack --config ./webpack.config.js",
|
|
12
|
+
"build": "npm run transpile && npm run dist",
|
|
13
|
+
"test": "echo 'Nothing to test in types package'"
|
|
14
|
+
},
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Fahad Heylaal",
|
|
17
|
+
"url": "https://fahad19.com"
|
|
18
|
+
},
|
|
19
|
+
"homepage": "https://featurevisor.com",
|
|
20
|
+
"keywords": [
|
|
21
|
+
"featurevisor",
|
|
22
|
+
"feature",
|
|
23
|
+
"features",
|
|
24
|
+
"flags",
|
|
25
|
+
"feature flags",
|
|
26
|
+
"feature toggles",
|
|
27
|
+
"feature management",
|
|
28
|
+
"experimentation",
|
|
29
|
+
"experiment",
|
|
30
|
+
"experiments"
|
|
31
|
+
],
|
|
32
|
+
"repository": {
|
|
33
|
+
"type": "git",
|
|
34
|
+
"url": "https://github.com/fahad19/featurevisor.git"
|
|
35
|
+
},
|
|
36
|
+
"publishConfig": {
|
|
37
|
+
"access": "public",
|
|
38
|
+
"registry": "https://registry.npmjs.org/"
|
|
39
|
+
},
|
|
40
|
+
"bugs": {
|
|
41
|
+
"url": "https://github.com/fahad19/featurevisor/issues"
|
|
42
|
+
},
|
|
43
|
+
"license": "MIT",
|
|
44
|
+
"gitHead": "303aca84f7c32163cb1079513d799296bd892e72"
|
|
45
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
export type AttributeKey = string;
|
|
2
|
+
|
|
3
|
+
export type AttributeValue = string | number | boolean | null | undefined;
|
|
4
|
+
|
|
5
|
+
export interface Attributes {
|
|
6
|
+
[key: AttributeKey]: AttributeValue;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface Attribute {
|
|
10
|
+
archived?: boolean; // only available in YAML
|
|
11
|
+
key: AttributeKey;
|
|
12
|
+
type: AttributeValue;
|
|
13
|
+
capture?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type Operator =
|
|
17
|
+
| "equals"
|
|
18
|
+
| "notEquals"
|
|
19
|
+
|
|
20
|
+
// numeric
|
|
21
|
+
| "greaterThan"
|
|
22
|
+
| "greaterThanOrEquals"
|
|
23
|
+
| "lessThan"
|
|
24
|
+
| "lessThanOrEquals"
|
|
25
|
+
|
|
26
|
+
// string
|
|
27
|
+
| "contains"
|
|
28
|
+
| "notContains"
|
|
29
|
+
| "startsWith"
|
|
30
|
+
| "endsWith"
|
|
31
|
+
|
|
32
|
+
// array of strings
|
|
33
|
+
| "in"
|
|
34
|
+
| "notIn";
|
|
35
|
+
|
|
36
|
+
export type ConditionValue = string | number | boolean | null | undefined | string[];
|
|
37
|
+
|
|
38
|
+
export interface PlainCondition {
|
|
39
|
+
attribute: AttributeKey;
|
|
40
|
+
operator: Operator;
|
|
41
|
+
value: ConditionValue;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface AndCondition {
|
|
45
|
+
and: Condition[];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface OrCondition {
|
|
49
|
+
or: Condition[];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export type AndOrCondition = AndCondition | OrCondition;
|
|
53
|
+
|
|
54
|
+
export type Condition = PlainCondition | AndOrCondition;
|
|
55
|
+
|
|
56
|
+
export type SegmentKey = string;
|
|
57
|
+
|
|
58
|
+
export interface Segment {
|
|
59
|
+
archived?: boolean; // only available in YAML
|
|
60
|
+
key: SegmentKey;
|
|
61
|
+
conditions: Condition | Condition[] | string; // string only when stringified for datafile
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export type PlainGroupSegment = SegmentKey;
|
|
65
|
+
|
|
66
|
+
export interface AndGroupSegment {
|
|
67
|
+
and: GroupSegment[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface OrGroupSegment {
|
|
71
|
+
or: GroupSegment[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type AndOrGroupSegment = AndGroupSegment | OrGroupSegment;
|
|
75
|
+
|
|
76
|
+
// group of segment keys with and/or conditions, or just string
|
|
77
|
+
export type GroupSegment = PlainGroupSegment | AndOrGroupSegment;
|
|
78
|
+
|
|
79
|
+
export type VariationType = "boolean" | "string" | "integer" | "double";
|
|
80
|
+
export type VariationValue = boolean | string | number | null | undefined;
|
|
81
|
+
|
|
82
|
+
export type VariableKey = string;
|
|
83
|
+
export type VariableType = "boolean" | "string" | "integer" | "double" | "array";
|
|
84
|
+
export type VariableValue = boolean | string | number | string[] | null | undefined;
|
|
85
|
+
|
|
86
|
+
export interface VariableOverrideSegments {
|
|
87
|
+
segments: GroupSegment | GroupSegment[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface VariableOverrideConditions {
|
|
91
|
+
conditions: Condition | Condition[];
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface VariableOverrideBase {
|
|
95
|
+
value: VariableValue;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type VariableOverrideSegmentsOrConditions =
|
|
99
|
+
| VariableOverrideSegments
|
|
100
|
+
| VariableOverrideConditions;
|
|
101
|
+
|
|
102
|
+
// export type VariableOverride = VariableOverrideBase & VariableOverrideSegmentsOrConditions;
|
|
103
|
+
|
|
104
|
+
export interface VariableOverride {
|
|
105
|
+
value: VariableValue;
|
|
106
|
+
|
|
107
|
+
// one of the below must be present in YAML
|
|
108
|
+
// @TODO: try with above commented out TypeScript later
|
|
109
|
+
conditions?: Condition | Condition[];
|
|
110
|
+
segments?: GroupSegment | GroupSegment[];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export interface Variable {
|
|
114
|
+
key: VariableKey;
|
|
115
|
+
value: VariableValue;
|
|
116
|
+
overrides?: VariableOverride[];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
export interface Variation {
|
|
120
|
+
type: VariationType;
|
|
121
|
+
value: VariationValue;
|
|
122
|
+
weight?: Weight; // 0 to 100 (available from parsed YAML, but not in datafile)
|
|
123
|
+
variables?: Variable[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface VariableSchema {
|
|
127
|
+
key: VariableKey;
|
|
128
|
+
type: VariableType;
|
|
129
|
+
defaultValue: VariableValue;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export type FeatureKey = string;
|
|
133
|
+
|
|
134
|
+
export interface Force {
|
|
135
|
+
// one of the below must be present in YAML
|
|
136
|
+
// @TODO: make it better with TypeScript
|
|
137
|
+
conditions?: Condition | Condition[];
|
|
138
|
+
segments?: GroupSegment | GroupSegment[];
|
|
139
|
+
|
|
140
|
+
variation: VariationValue;
|
|
141
|
+
variables?: {
|
|
142
|
+
[key: string]: VariableValue;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type BucketKey = string;
|
|
147
|
+
export type BucketValue = number; // 0 to 100,000 (100% * 1000 to include three decimal places in same integer)
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Datafile-only types
|
|
151
|
+
*/
|
|
152
|
+
export type Percentage = number; // 0 to 100,000 (100% * 1000 to include three decimal places in same integer)
|
|
153
|
+
|
|
154
|
+
export interface Allocation {
|
|
155
|
+
variation: VariationValue;
|
|
156
|
+
percentage: Percentage;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface Traffic {
|
|
160
|
+
key: RuleKey;
|
|
161
|
+
segments: GroupSegment | GroupSegment[] | "*";
|
|
162
|
+
percentage: Percentage;
|
|
163
|
+
allocation: Allocation[];
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
export type BucketBy = AttributeKey | AttributeKey[]; // @TODO: have first available attribute as well?
|
|
167
|
+
export interface Feature {
|
|
168
|
+
key: FeatureKey;
|
|
169
|
+
// @TODO: introduce new `parent` key?
|
|
170
|
+
// @TODO: introduce `type` for distinguishing between feature flags and experiments?
|
|
171
|
+
defaultVariation: VariationValue;
|
|
172
|
+
variablesSchema?: VariableSchema[];
|
|
173
|
+
variations: Variation[];
|
|
174
|
+
bucketBy: BucketBy;
|
|
175
|
+
traffic: Traffic[];
|
|
176
|
+
force?: Force[];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface DatafileContent {
|
|
180
|
+
schemaVersion: string;
|
|
181
|
+
revision: string;
|
|
182
|
+
attributes: Attribute[];
|
|
183
|
+
segments: Segment[];
|
|
184
|
+
features: Feature[];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* YAML-only type
|
|
189
|
+
*/
|
|
190
|
+
export type Weight = number; // 0 to 100
|
|
191
|
+
|
|
192
|
+
export type EnvironmentKey = string; // ideally "production", "staging", "testing", or "development" only
|
|
193
|
+
|
|
194
|
+
export type RuleKey = string;
|
|
195
|
+
|
|
196
|
+
export interface Rule {
|
|
197
|
+
key: RuleKey;
|
|
198
|
+
segments: GroupSegment | GroupSegment[];
|
|
199
|
+
percentage: Weight;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
export interface Environment {
|
|
203
|
+
expose?: boolean;
|
|
204
|
+
rules: Rule[];
|
|
205
|
+
force?: Force[];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface ParsedFeature {
|
|
209
|
+
key: FeatureKey;
|
|
210
|
+
|
|
211
|
+
archived: boolean;
|
|
212
|
+
description: string;
|
|
213
|
+
tags: string[];
|
|
214
|
+
|
|
215
|
+
bucketBy?: AttributeKey | AttributeKey[]; // @TODO: have first available attribute as well?
|
|
216
|
+
|
|
217
|
+
defaultVariation: VariationValue;
|
|
218
|
+
variablesSchema?: VariableSchema[];
|
|
219
|
+
variations: Variation[];
|
|
220
|
+
|
|
221
|
+
environments: {
|
|
222
|
+
[key: EnvironmentKey]: Environment;
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/**
|
|
227
|
+
* For maintaining old allocations info,
|
|
228
|
+
* allowing for gradual rollout of new allocations
|
|
229
|
+
* with consistent bucketing
|
|
230
|
+
*/
|
|
231
|
+
export interface ExistingFeature {
|
|
232
|
+
variations: {
|
|
233
|
+
// @TODO: use Exclude with Variation?
|
|
234
|
+
value: VariationValue;
|
|
235
|
+
weight: Weight;
|
|
236
|
+
}[];
|
|
237
|
+
traffic: {
|
|
238
|
+
// @TODO: use Exclude with Traffic?
|
|
239
|
+
key: RuleKey;
|
|
240
|
+
percentage: Percentage;
|
|
241
|
+
allocation: Allocation[];
|
|
242
|
+
}[];
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface ExistingFeatures {
|
|
246
|
+
[key: FeatureKey]: ExistingFeature;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface ExistingState {
|
|
250
|
+
features: ExistingFeatures;
|
|
251
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
const getWebpackConfig = require("../../tools/getWebpackConfig");
|
|
4
|
+
|
|
5
|
+
const wepbackConfig = getWebpackConfig({
|
|
6
|
+
entryFilePath: path.join(__dirname, "src", "index.ts"),
|
|
7
|
+
entryKey: "index",
|
|
8
|
+
outputDirectoryPath: path.join(__dirname, "dist"),
|
|
9
|
+
outputLibrary: "FeaturevisorTypes",
|
|
10
|
+
tsConfigFilePath: path.join(__dirname, "tsconfig.cjs.json"),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
module.exports = wepbackConfig;
|