@featurevisor/types 2.0.0 → 2.0.2

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/src/index.ts DELETED
@@ -1,621 +0,0 @@
1
- export type AttributeKey = string;
2
-
3
- export interface AttributeObjectValue {
4
- [key: AttributeKey]: AttributeValue;
5
- }
6
-
7
- export type AttributeValue =
8
- | string
9
- | number
10
- | boolean
11
- | Date
12
- | null
13
- | undefined
14
- | string[]
15
- | AttributeObjectValue;
16
-
17
- export interface Context {
18
- [key: AttributeKey]: AttributeValue;
19
- }
20
-
21
- export type AttributeType =
22
- | "boolean"
23
- | "string"
24
- | "integer"
25
- | "double"
26
- | "date"
27
- | "semver"
28
- | "object"
29
- | "array";
30
-
31
- export interface Attribute {
32
- archived?: boolean; // only available in YAML files
33
- key?: AttributeKey; // needed for supporting v1 datafile generation
34
- type: AttributeType;
35
- description?: string; // only available in YAML files
36
- properties?: {
37
- [key: AttributeKey]: {
38
- type:
39
- | "boolean"
40
- | "string"
41
- | "integer"
42
- | "double"
43
- | "date"
44
- | "semver"
45
- // | "object" // NOTE: avoid nesting for now
46
- | "array";
47
- description?: string;
48
- };
49
- };
50
- }
51
-
52
- export type Operator =
53
- | "equals"
54
- | "notEquals"
55
- | "exists"
56
- | "notExists"
57
-
58
- // numeric
59
- | "greaterThan"
60
- | "greaterThanOrEquals"
61
- | "lessThan"
62
- | "lessThanOrEquals"
63
-
64
- // string
65
- | "contains"
66
- | "notContains"
67
- | "startsWith"
68
- | "endsWith"
69
-
70
- // semver (string)
71
- | "semverEquals"
72
- | "semverNotEquals"
73
- | "semverGreaterThan"
74
- | "semverGreaterThanOrEquals"
75
- | "semverLessThan"
76
- | "semverLessThanOrEquals"
77
-
78
- // date comparisons
79
- | "before"
80
- | "after"
81
-
82
- // array of strings
83
- | "includes"
84
- | "notIncludes"
85
-
86
- // regex
87
- | "matches"
88
- | "notMatches"
89
-
90
- // array of strings
91
- | "in"
92
- | "notIn";
93
-
94
- export type ConditionValue = string | number | boolean | Date | null | undefined | string[];
95
-
96
- export interface PlainCondition {
97
- attribute: AttributeKey;
98
- operator: Operator;
99
- value?: ConditionValue; // for all operators, except for "exists" and "notExists"
100
- regexFlags?: string; // for regex operators only (matches, notMatches)
101
- }
102
-
103
- export interface AndCondition {
104
- and: Condition[];
105
- }
106
-
107
- export interface OrCondition {
108
- or: Condition[];
109
- }
110
-
111
- export interface NotCondition {
112
- not: Condition[];
113
- }
114
-
115
- export type AndOrNotCondition = AndCondition | OrCondition | NotCondition;
116
-
117
- export type Condition = PlainCondition | AndOrNotCondition | string;
118
-
119
- export type SegmentKey = string;
120
-
121
- export interface Segment {
122
- archived?: boolean; // only available in YAML files
123
- key?: SegmentKey; // needed for supporting v1 datafile generation
124
- conditions: Condition | Condition[]; // string only when stringified for datafile
125
- description?: string; // only available in YAML files
126
- }
127
-
128
- export type PlainGroupSegment = SegmentKey;
129
-
130
- export interface AndGroupSegment {
131
- and: GroupSegment[];
132
- }
133
-
134
- export interface OrGroupSegment {
135
- or: GroupSegment[];
136
- }
137
-
138
- export interface NotGroupSegment {
139
- not: GroupSegment[];
140
- }
141
-
142
- export type AndOrNotGroupSegment = AndGroupSegment | OrGroupSegment | NotGroupSegment;
143
-
144
- // group of segment keys with and/or conditions, or just string
145
- export type GroupSegment = PlainGroupSegment | AndOrNotGroupSegment;
146
-
147
- export type VariationValue = string;
148
-
149
- export type VariableKey = string;
150
- export type VariableType =
151
- | "boolean"
152
- | "string"
153
- | "integer"
154
- | "double"
155
- | "array"
156
- | "object"
157
- | "json";
158
- export interface VariableObjectValue {
159
- [key: string]: VariableValue;
160
- }
161
- export type VariableValue =
162
- | boolean
163
- | string
164
- | number
165
- | string[]
166
- | VariableObjectValue
167
- | null
168
- | undefined;
169
-
170
- export interface VariableOverrideSegments {
171
- segments: GroupSegment | GroupSegment[];
172
- }
173
-
174
- export interface VariableOverrideConditions {
175
- conditions: Condition | Condition[];
176
- }
177
-
178
- export type VariableOverrideSegmentsOrConditions =
179
- | VariableOverrideSegments
180
- | VariableOverrideConditions;
181
-
182
- export interface VariableOverride {
183
- value: VariableValue;
184
-
185
- // one of the below must be present in YAML files
186
- conditions?: Condition | Condition[];
187
- segments?: GroupSegment | GroupSegment[];
188
- }
189
-
190
- export interface VariableV1 {
191
- key: VariableKey;
192
- value: VariableValue;
193
- description?: string; // only available in YAML files
194
- overrides?: VariableOverride[];
195
- }
196
-
197
- export interface VariationV1 {
198
- description?: string; // only available in YAML files
199
- value: VariationValue;
200
- weight?: Weight; // 0 to 100 (available from parsed YAML, but not in datafile)
201
- variables?: VariableV1[];
202
- }
203
-
204
- export interface Variation {
205
- description?: string; // only available in YAML files
206
- value: VariationValue;
207
- weight?: Weight; // 0 to 100 (available from parsed YAML, but not in datafile)
208
- variables?: {
209
- [key: VariableKey]: VariableValue;
210
- };
211
- variableOverrides?: {
212
- [key: VariableKey]: VariableOverride[];
213
- };
214
- }
215
-
216
- export interface VariableSchema {
217
- deprecated?: boolean;
218
- key?: VariableKey; // @NOTE: remove
219
- type: VariableType;
220
- defaultValue: VariableValue;
221
- description?: string; // only available in YAML files
222
- useDefaultWhenDisabled?: boolean;
223
- disabledValue?: VariableValue;
224
- }
225
-
226
- export type FeatureKey = string;
227
-
228
- export interface Slot {
229
- feature: FeatureKey | false;
230
- percentage: Weight; // 0 to 100
231
- }
232
-
233
- export interface Group {
234
- key: string;
235
- description: string;
236
- slots: Slot[];
237
- }
238
-
239
- export type BucketKey = string;
240
- export type BucketValue = number; // 0 to 100,000 (100% * 1000 to include three decimal places in same integer)
241
-
242
- /**
243
- * Datafile-only types
244
- */
245
- export type Percentage = number; // 0 to 100,000 (100% * 1000 to include three decimal places in same integer)
246
-
247
- export type Range = [Percentage, Percentage]; // 0 to 100k
248
-
249
- export interface Allocation {
250
- variation: VariationValue;
251
- range: Range;
252
- }
253
-
254
- export interface Traffic {
255
- key: RuleKey;
256
- segments: GroupSegment | GroupSegment[] | "*";
257
- percentage: Percentage;
258
-
259
- enabled?: boolean;
260
- variation?: VariationValue;
261
- variables?: {
262
- [key: string]: VariableValue;
263
- };
264
- variationWeights?: {
265
- [key: string]: Weight;
266
- };
267
-
268
- allocation?: Allocation[];
269
- }
270
-
271
- export type PlainBucketBy = AttributeKey;
272
- export type AndBucketBy = AttributeKey[];
273
- export interface OrBucketBy {
274
- or: AttributeKey[];
275
- }
276
- export type BucketBy = PlainBucketBy | AndBucketBy | OrBucketBy;
277
-
278
- export interface RequiredWithVariation {
279
- key: FeatureKey;
280
- variation: VariationValue;
281
- }
282
-
283
- export type Required = FeatureKey | RequiredWithVariation;
284
-
285
- export interface Feature {
286
- key?: FeatureKey; // needed for supporting v1 datafile generation
287
- hash?: string;
288
- deprecated?: boolean;
289
- required?: Required[];
290
- variablesSchema?: Record<VariableKey, VariableSchema>;
291
- disabledVariationValue?: VariationValue;
292
- variations?: Variation[];
293
- bucketBy: BucketBy;
294
- traffic: Traffic[];
295
- force?: Force[];
296
- ranges?: Range[]; // if in a Group (mutex), these are the available slot ranges
297
- }
298
-
299
- export interface FeatureV1 {
300
- key?: FeatureKey;
301
- hash?: string;
302
- deprecated?: boolean;
303
- required?: Required[];
304
- bucketBy: BucketBy;
305
- traffic: Traffic[];
306
- force?: Force[];
307
- ranges?: Range[]; // if in a Group (mutex), these are the available slot ranges
308
-
309
- variablesSchema?: VariableSchema[];
310
- variations?: VariationV1[];
311
- }
312
-
313
- export interface DatafileContentV1 {
314
- schemaVersion: string;
315
- revision: string;
316
- attributes: Attribute[];
317
- segments: Segment[];
318
- features: FeatureV1[];
319
- }
320
-
321
- export interface DatafileContent {
322
- schemaVersion: string;
323
- revision: string;
324
- segments: {
325
- [key: SegmentKey]: Segment;
326
- };
327
- features: {
328
- [key: FeatureKey]: Feature;
329
- };
330
- }
331
-
332
- export interface EvaluatedFeature {
333
- enabled: boolean;
334
- variation?: VariationValue;
335
- variables?: {
336
- [key: VariableKey]: VariableValue;
337
- };
338
- }
339
-
340
- export interface EvaluatedFeatures {
341
- [key: FeatureKey]: EvaluatedFeature;
342
- }
343
-
344
- export type StickyFeatures = EvaluatedFeatures;
345
-
346
- /**
347
- * YAML-only type
348
- */
349
- export type Weight = number; // 0 to 100
350
-
351
- export type EnvironmentKey = string; // ideally "production", "staging", "testing", or "development" only
352
-
353
- export type Tag = string;
354
-
355
- export type RuleKey = string;
356
-
357
- export interface Rule {
358
- key: RuleKey;
359
- description?: string; // only available in YAML
360
- segments: GroupSegment | GroupSegment[];
361
- percentage: Weight;
362
-
363
- enabled?: boolean;
364
- variation?: VariationValue;
365
- variables?: {
366
- [key: string]: VariableValue;
367
- };
368
- variationWeights?: {
369
- [key: string]: Weight;
370
- };
371
- }
372
-
373
- export interface RulesByEnvironment {
374
- [key: EnvironmentKey]: Rule[];
375
- }
376
-
377
- export interface Force {
378
- // one of the below must be present in YAML
379
- conditions?: Condition | Condition[];
380
- segments?: GroupSegment | GroupSegment[];
381
-
382
- enabled?: boolean;
383
- variation?: VariationValue;
384
- variables?: {
385
- [key: string]: VariableValue;
386
- };
387
- }
388
-
389
- export interface ForceByEnvironment {
390
- [key: EnvironmentKey]: Force[];
391
- }
392
-
393
- export type Expose = boolean | Tag[];
394
-
395
- export interface ExposeByEnvironment {
396
- [key: EnvironmentKey]: Expose;
397
- }
398
-
399
- export interface ParsedFeature {
400
- key: FeatureKey;
401
-
402
- archived?: boolean;
403
- deprecated?: boolean;
404
-
405
- description: string;
406
- tags: Tag[];
407
-
408
- required?: Required[];
409
-
410
- bucketBy: BucketBy;
411
-
412
- disabledVariationValue?: VariationValue;
413
-
414
- variablesSchema?: Record<VariableKey, VariableSchema>;
415
- variations?: Variation[];
416
-
417
- expose?: ExposeByEnvironment | Expose;
418
- force?: ForceByEnvironment | Force[];
419
- rules?: RulesByEnvironment | Rule[];
420
- }
421
-
422
- /**
423
- * For maintaining old allocations info,
424
- * allowing for gradual rollout of new allocations
425
- * with consistent bucketing
426
- */
427
- export interface ExistingFeature {
428
- hash?: string;
429
- variations?: {
430
- value: VariationValue;
431
- weight: Weight;
432
- }[];
433
- traffic: {
434
- key: RuleKey;
435
- percentage: Percentage;
436
- allocation?: Allocation[];
437
- }[];
438
- ranges?: Range[]; // if in a Group (mutex), these are the available slot ranges
439
- }
440
-
441
- export interface ExistingFeatures {
442
- [key: FeatureKey]: ExistingFeature;
443
- }
444
-
445
- export interface ExistingState {
446
- features: ExistingFeatures;
447
- }
448
-
449
- /**
450
- * Tests
451
- */
452
- export interface AssertionMatrix {
453
- [key: string]: AttributeValue[];
454
- }
455
-
456
- export interface ExpectedEvaluations {
457
- flag?: Record<string, any>;
458
- variation?: Record<string, any>;
459
- variables?: {
460
- [key: VariableKey]: Record<string, any>;
461
- };
462
- }
463
-
464
- export interface FeatureChildAssertion {
465
- sticky?: StickyFeatures;
466
- context?: Context;
467
-
468
- defaultVariationValue?: VariationValue;
469
- defaultVariableValues?: {
470
- [key: string]: VariableValue;
471
- };
472
-
473
- expectedToBeEnabled?: boolean;
474
- expectedVariation?: VariationValue;
475
- expectedVariables?: {
476
- [key: VariableKey]: VariableValue;
477
- };
478
- expectedEvaluations?: ExpectedEvaluations;
479
- }
480
-
481
- export interface FeatureAssertion {
482
- matrix?: AssertionMatrix;
483
- description?: string;
484
- environment: EnvironmentKey;
485
- at?: Weight; // bucket weight: 0 to 100
486
-
487
- sticky?: StickyFeatures;
488
- context?: Context;
489
-
490
- defaultVariationValue?: VariationValue;
491
- defaultVariableValues?: {
492
- [key: string]: VariableValue;
493
- };
494
-
495
- expectedToBeEnabled?: boolean;
496
- expectedVariation?: VariationValue;
497
- expectedVariables?: {
498
- [key: VariableKey]: VariableValue;
499
- };
500
- expectedEvaluations?: ExpectedEvaluations;
501
-
502
- children?: FeatureChildAssertion[];
503
- }
504
-
505
- export interface TestFeature {
506
- key?: string; // file path
507
- feature: FeatureKey;
508
- assertions: FeatureAssertion[];
509
- }
510
-
511
- export interface SegmentAssertion {
512
- matrix?: AssertionMatrix;
513
- description?: string;
514
- context: Context;
515
- expectedToMatch: boolean;
516
- }
517
-
518
- export interface TestSegment {
519
- key?: string; // file path
520
- segment: SegmentKey;
521
- assertions: SegmentAssertion[];
522
- }
523
-
524
- export type Test = TestSegment | TestFeature;
525
-
526
- export interface TestResultAssertionError {
527
- type: "flag" | "variation" | "variable" | "segment" | "evaluation";
528
- expected: string | number | boolean | Date | null | undefined;
529
- actual: string | number | boolean | Date | null | undefined;
530
- message?: string;
531
- details?: {
532
- evaluationType?: string; // e.g., "flag", "variation", "variable"
533
- evaluationKey?: string; // e.g., "myFeatureKey", "myVariableKey"
534
- childIndex?: number; // for children assertions
535
- [key: string]: any;
536
- };
537
- }
538
-
539
- export interface TestResultAssertion {
540
- description: string;
541
- duration: number;
542
- passed: boolean;
543
- errors?: TestResultAssertionError[];
544
- }
545
-
546
- export interface TestResult {
547
- type: "feature" | "segment";
548
- key: string;
549
- notFound?: boolean;
550
- passed: boolean;
551
- duration: number;
552
- assertions: TestResultAssertion[];
553
- }
554
-
555
- /**
556
- * Site index and history
557
- */
558
- export type EntityType = "attribute" | "segment" | "feature" | "group" | "test";
559
-
560
- export type CommitHash = string;
561
-
562
- export interface HistoryEntity {
563
- type: EntityType;
564
- key: string;
565
- }
566
-
567
- export interface HistoryEntry {
568
- commit: CommitHash;
569
- author: string;
570
- timestamp: string;
571
- entities: HistoryEntity[];
572
- }
573
-
574
- export interface LastModified {
575
- commit: CommitHash;
576
- timestamp: string;
577
- author: string;
578
- }
579
-
580
- export interface SearchIndex {
581
- links?: {
582
- feature: string;
583
- segment: string;
584
- attribute: string;
585
- commit: CommitHash;
586
- };
587
- projectConfig: {
588
- tags: Tag[];
589
- environments: EnvironmentKey[] | false;
590
- };
591
- entities: {
592
- attributes: (Attribute & {
593
- lastModified?: LastModified;
594
- usedInSegments: SegmentKey[];
595
- usedInFeatures: FeatureKey[];
596
- })[];
597
- segments: (Segment & {
598
- lastModified?: LastModified;
599
- usedInFeatures: FeatureKey[];
600
- })[];
601
- features: (ParsedFeature & {
602
- lastModified?: LastModified;
603
- })[];
604
- };
605
- }
606
-
607
- export interface EntityDiff {
608
- type: EntityType;
609
- key: string;
610
- created?: boolean;
611
- deleted?: boolean;
612
- updated?: boolean;
613
- content?: string;
614
- }
615
-
616
- export interface Commit {
617
- hash: CommitHash;
618
- author: string;
619
- timestamp: string;
620
- entities: EntityDiff[];
621
- }
package/tsconfig.cjs.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.cjs.json",
3
- "compilerOptions": {
4
- "outDir": "./lib"
5
- },
6
- "include": ["./src/**/*.ts"]
7
- }
package/webpack.config.js DELETED
@@ -1,13 +0,0 @@
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;