ng-configcat-publicapi-ui 5.3.12 → 5.3.13
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.
|
@@ -22,6 +22,7 @@ import { MatIcon } from '@angular/material/icon';
|
|
|
22
22
|
import { MatSnackBarRef, MAT_SNACK_BAR_DATA, MatSnackBarAction, MatSnackBarActions, MatSnackBarLabel, MatSnackBar } from '@angular/material/snack-bar';
|
|
23
23
|
import { takeUntilDestroyed, rxResource } from '@angular/core/rxjs-interop';
|
|
24
24
|
import { timer, Subject, forkJoin, of, tap, catchError as catchError$1, throwError, distinctUntilChanged } from 'rxjs';
|
|
25
|
+
import Papa from 'papaparse';
|
|
25
26
|
import { valid } from 'semver';
|
|
26
27
|
import { map, catchError } from 'rxjs/operators';
|
|
27
28
|
import * as i2 from '@rxweb/reactive-form-validators';
|
|
@@ -39,9 +40,7 @@ import { MatDivider } from '@angular/material/divider';
|
|
|
39
40
|
import { MatTableDataSource, MatTable, MatColumnDef, MatHeaderCellDef, MatHeaderCell, MatCellDef, MatCell, MatHeaderRowDef, MatHeaderRow, MatRowDef, MatRow } from '@angular/material/table';
|
|
40
41
|
import { sha1 } from '@configcat/sdk/lib/esm/Hash.js';
|
|
41
42
|
import { CdkCopyToClipboard, Clipboard } from '@angular/cdk/clipboard';
|
|
42
|
-
import { getValidatorsForSettingType as getValidatorsForSettingType$1, generateValueFormGroup as generateValueFormGroup$1, generatePrerequisiteDefaultValue as generatePrerequisiteDefaultValue$1, generateComparisonValueFormGroup as generateComparisonValueFormGroup$1, addComparisonValueListValueItems as addComparisonValueListValueItems$1, getComparisonValueType as getComparisonValueType$1, getComparisonValueSemverValidators as getComparisonValueSemverValidators$1, getComparisonValueStringValidators as getComparisonValueStringValidators$1, getComparisonValueSemverListItemValidators as getComparisonValueSemverListItemValidators$1, getComparisonValueStringListItemValidators as getComparisonValueStringListItemValidators$1, generateComparisonValueListValueArray as generateComparisonValueListValueArray$1, generateConditionFormGroup as generateConditionFormGroup$1, generateEmptySegmentConditionFormGroup as generateEmptySegmentConditionFormGroup$1, generateEmptyPrerequisiteFlagConditionFormGroup as generateEmptyPrerequisiteFlagConditionFormGroup$1, generatePercentageOptionFormGroup as generatePercentageOptionFormGroup$1, generateDefaultValue as generateDefaultValue$1 } from 'projects/ng-configcat-publicapi-ui/src/public-api';
|
|
43
43
|
import { ENTER, COMMA } from '@angular/cdk/keycodes';
|
|
44
|
-
import { formatValuesAsCsv, formatValuesAndHintAsCsv, formatValuesAndHintAsJson, parseValuesFromCsv, parseValuesAndHintsFromCsv, parseValuesAndHintsFromJson } from 'projects/ng-configcat-publicapi-ui/src/lib/_services/comparison-value-list-helper';
|
|
45
44
|
import { MatRadioGroup, MatRadioButton } from '@angular/material/radio';
|
|
46
45
|
import { MatPaginator } from '@angular/material/paginator';
|
|
47
46
|
|
|
@@ -562,6 +561,77 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImpor
|
|
|
562
561
|
type: Injectable
|
|
563
562
|
}] });
|
|
564
563
|
|
|
564
|
+
function formatValuesAndHintAsJson(comparisonValueList) {
|
|
565
|
+
return JSON.stringify(comparisonValueList, null, 2);
|
|
566
|
+
}
|
|
567
|
+
function formatValuesAndHintAsCsv(comparisonValueList) {
|
|
568
|
+
const data = comparisonValueList.map(comparisonValueListItem => {
|
|
569
|
+
return [
|
|
570
|
+
formatCsvStringValue(comparisonValueListItem.value),
|
|
571
|
+
formatCsvStringValue(comparisonValueListItem.hint ?? ""),
|
|
572
|
+
].join(",");
|
|
573
|
+
});
|
|
574
|
+
return data.join("\r\n");
|
|
575
|
+
}
|
|
576
|
+
function formatValuesAsCsv(comparisonValueList) {
|
|
577
|
+
const data = comparisonValueList.map(comparisonValueList => formatCsvStringValue(comparisonValueList.value));
|
|
578
|
+
return data.join(",");
|
|
579
|
+
}
|
|
580
|
+
function formatCsvStringValue(value) {
|
|
581
|
+
if (!value) {
|
|
582
|
+
return "";
|
|
583
|
+
}
|
|
584
|
+
const escaped = value.replaceAll('"', '""');
|
|
585
|
+
return '"' + escaped + '"';
|
|
586
|
+
}
|
|
587
|
+
function parseValuesAndHintsFromJson(value) {
|
|
588
|
+
if (value === "") {
|
|
589
|
+
return { comparisonValueList: [] };
|
|
590
|
+
}
|
|
591
|
+
try {
|
|
592
|
+
const parsed = JSON.parse(value);
|
|
593
|
+
return { comparisonValueList: parsed.filter(v => !!v.value) };
|
|
594
|
+
}
|
|
595
|
+
catch {
|
|
596
|
+
return { comparisonValueList: [], error: "Parse error." };
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function parseValuesAndHintsFromCsv(value) {
|
|
600
|
+
if (value === "") {
|
|
601
|
+
return { comparisonValueList: [] };
|
|
602
|
+
}
|
|
603
|
+
const parseResult = Papa.parse(value, { delimiter: ",", skipEmptyLines: true });
|
|
604
|
+
if (parseResult.errors.length) {
|
|
605
|
+
return { comparisonValueList: [], error: "Parse error." };
|
|
606
|
+
}
|
|
607
|
+
if (parseResult?.data.length === 0) {
|
|
608
|
+
return { comparisonValueList: [] };
|
|
609
|
+
}
|
|
610
|
+
return {
|
|
611
|
+
comparisonValueList: parseResult.data
|
|
612
|
+
.map(p => ({ value: p[0], hint: p[1] }))
|
|
613
|
+
.filter(v => !!v.value),
|
|
614
|
+
};
|
|
615
|
+
}
|
|
616
|
+
function parseValuesFromCsv(value) {
|
|
617
|
+
if (value === "") {
|
|
618
|
+
return { comparisonValueList: [] };
|
|
619
|
+
}
|
|
620
|
+
const parseResult = Papa.parse(value + ",", { delimiter: ",", skipEmptyLines: true });
|
|
621
|
+
if (parseResult.errors?.length) {
|
|
622
|
+
return { comparisonValueList: [], error: "Parse error." };
|
|
623
|
+
}
|
|
624
|
+
if (!parseResult?.data?.length) {
|
|
625
|
+
return { comparisonValueList: [] };
|
|
626
|
+
}
|
|
627
|
+
return {
|
|
628
|
+
comparisonValueList: parseResult.data
|
|
629
|
+
.flat()
|
|
630
|
+
.map(p => ({ value: p }))
|
|
631
|
+
.filter(v => !!v.value),
|
|
632
|
+
};
|
|
633
|
+
}
|
|
634
|
+
|
|
565
635
|
function validateSemVer(c) {
|
|
566
636
|
if (valid(c.value) === null) {
|
|
567
637
|
return {
|
|
@@ -3852,7 +3922,7 @@ class FeatureFlagValueComponent {
|
|
|
3852
3922
|
data: {
|
|
3853
3923
|
value: stringValueControl.value,
|
|
3854
3924
|
readOnly: stringValueControl.disabled,
|
|
3855
|
-
validators: getValidatorsForSettingType
|
|
3925
|
+
validators: getValidatorsForSettingType(SettingType.String, this.featureFlagLimitations()),
|
|
3856
3926
|
maxValueLength: this.featureFlagLimitations().maxStringFlagValueLength ?? 100000,
|
|
3857
3927
|
description: this.isPrerequisite()
|
|
3858
3928
|
? "Modify the text within the editor to change the prerequisite flag comparison value. The editor supports JSON syntax highlighting."
|
|
@@ -3994,7 +4064,7 @@ class PrerequisiteFlagConditionComponent {
|
|
|
3994
4064
|
const prerequisiteSettingType = newSetting?.settingType ?? SettingType.Boolean;
|
|
3995
4065
|
const variations = newSetting?.predefinedVariations ?? [];
|
|
3996
4066
|
if (changeNeeded) {
|
|
3997
|
-
this.formGroup().setControl("prerequisiteComparisonValue", generateValueFormGroup
|
|
4067
|
+
this.formGroup().setControl("prerequisiteComparisonValue", generateValueFormGroup(generatePrerequisiteDefaultValue(prerequisiteSettingType, variations), prerequisiteSettingType, variations, false, this.featureFlagLimitations()));
|
|
3998
4068
|
}
|
|
3999
4069
|
this.prerequisiteConditionChanged.emit();
|
|
4000
4070
|
}
|
|
@@ -4500,7 +4570,7 @@ class PopoutListEditorDialogComponent {
|
|
|
4500
4570
|
this.setFormGroup(comparisonValueList);
|
|
4501
4571
|
}
|
|
4502
4572
|
setFormGroup(comparisonValueList) {
|
|
4503
|
-
this.listValueFormArray = generateComparisonValueFormGroup
|
|
4573
|
+
this.listValueFormArray = generateComparisonValueFormGroup({ listValue: comparisonValueList, doubleValue: null, stringValue: null }, this.data.comparator, this.data.readOnly, this.data.featureFlagLimitations).controls.listValue;
|
|
4504
4574
|
if (this.listValueFormArray.invalid) {
|
|
4505
4575
|
this.listValueFormArray.markAllAsTouched();
|
|
4506
4576
|
}
|
|
@@ -4546,7 +4616,7 @@ class PopoutListEditorDialogComponent {
|
|
|
4546
4616
|
if (this.listValueFormArray.controls.length >= this.data.featureFlagLimitations.maxComparisonValueListLength) {
|
|
4547
4617
|
return;
|
|
4548
4618
|
}
|
|
4549
|
-
addComparisonValueListValueItems
|
|
4619
|
+
addComparisonValueListValueItems(this.data.comparator, this.listValueFormArray, [{ value: "", hint: null }], this.data.featureFlagLimitations);
|
|
4550
4620
|
this.setDataSource();
|
|
4551
4621
|
this.filterValue = "";
|
|
4552
4622
|
this.applyFilter();
|
|
@@ -4971,7 +5041,7 @@ class UserConditionComponent {
|
|
|
4971
5041
|
this.fakeFormControl = new FormControl("");
|
|
4972
5042
|
}
|
|
4973
5043
|
ngOnChanges() {
|
|
4974
|
-
this.rolloutRuleComparatorType = getComparisonValueType
|
|
5044
|
+
this.rolloutRuleComparatorType = getComparisonValueType(this.formGroup().controls.comparator.value);
|
|
4975
5045
|
this.isClearTextComparator = isClearTextComparator(this.formGroup().controls.comparator.value);
|
|
4976
5046
|
this.errorStateMatcher = new ListValueErrorStateMatcher(this.formGroup());
|
|
4977
5047
|
this.selectedComparator = this.formGroup().controls.comparator.value;
|
|
@@ -5010,7 +5080,7 @@ class UserConditionComponent {
|
|
|
5010
5080
|
this.selectedComparator = comparatorValue;
|
|
5011
5081
|
this.isClearTextComparator = isClearTextComparator(this.formGroup().controls.comparator.value);
|
|
5012
5082
|
const oldRolloutRuleComparatorType = this.rolloutRuleComparatorType;
|
|
5013
|
-
this.rolloutRuleComparatorType = getComparisonValueType
|
|
5083
|
+
this.rolloutRuleComparatorType = getComparisonValueType(this.formGroup().controls.comparator.value);
|
|
5014
5084
|
if (oldRolloutRuleComparatorType !== this.rolloutRuleComparatorType) {
|
|
5015
5085
|
const defaultValue = this.rolloutRuleComparatorType === UserComparatorType.DateTime
|
|
5016
5086
|
? {
|
|
@@ -5019,7 +5089,7 @@ class UserConditionComponent {
|
|
|
5019
5089
|
stringValue: null,
|
|
5020
5090
|
}
|
|
5021
5091
|
: { doubleValue: null, listValue: null, stringValue: null };
|
|
5022
|
-
this.formGroup().setControl("comparisonValue", generateComparisonValueFormGroup
|
|
5092
|
+
this.formGroup().setControl("comparisonValue", generateComparisonValueFormGroup(defaultValue, this.formGroup().controls.comparator.value, false, this.featureFlagLimitations()));
|
|
5023
5093
|
}
|
|
5024
5094
|
}
|
|
5025
5095
|
compDialog() {
|
|
@@ -5062,7 +5132,7 @@ class UserConditionComponent {
|
|
|
5062
5132
|
return;
|
|
5063
5133
|
}
|
|
5064
5134
|
if (!value.includes(",")) {
|
|
5065
|
-
addComparisonValueListValueItems
|
|
5135
|
+
addComparisonValueListValueItems(this.formGroup().controls.comparator.value, this.formGroup().controls.comparisonValue.controls.listValue, [{ value, hint: null }], this.featureFlagLimitations());
|
|
5066
5136
|
return;
|
|
5067
5137
|
}
|
|
5068
5138
|
const dialogRef = this.dialog.open(ConfirmationDialogComponent, {
|
|
@@ -5081,11 +5151,11 @@ class UserConditionComponent {
|
|
|
5081
5151
|
this.messagingService.showErrorSnack("Parse error");
|
|
5082
5152
|
}
|
|
5083
5153
|
else if (comparisonValueListParseResult.comparisonValueList.length > 0) {
|
|
5084
|
-
addComparisonValueListValueItems
|
|
5154
|
+
addComparisonValueListValueItems(this.formGroup().controls.comparator.value, this.formGroup().controls.comparisonValue.controls.listValue, comparisonValueListParseResult.comparisonValueList, this.featureFlagLimitations());
|
|
5085
5155
|
}
|
|
5086
5156
|
}
|
|
5087
5157
|
else {
|
|
5088
|
-
addComparisonValueListValueItems
|
|
5158
|
+
addComparisonValueListValueItems(this.formGroup().controls.comparator.value, this.formGroup().controls.comparisonValue.controls.listValue, [{ value, hint: null }], this.featureFlagLimitations());
|
|
5089
5159
|
}
|
|
5090
5160
|
});
|
|
5091
5161
|
}
|
|
@@ -5139,8 +5209,8 @@ class UserConditionComponent {
|
|
|
5139
5209
|
value: formGroup.controls.comparisonValue.controls.stringValue.value,
|
|
5140
5210
|
readOnly: formGroup.controls.comparisonValue.controls.stringValue.disabled,
|
|
5141
5211
|
validators: this.rolloutRuleComparatorType === UserComparatorType.Semver
|
|
5142
|
-
? getComparisonValueSemverValidators
|
|
5143
|
-
: getComparisonValueStringValidators
|
|
5212
|
+
? getComparisonValueSemverValidators(this.featureFlagLimitations())
|
|
5213
|
+
: getComparisonValueStringValidators(this.featureFlagLimitations()),
|
|
5144
5214
|
maxValueLength: this.featureFlagLimitations().maxComparisonValueLength,
|
|
5145
5215
|
description: "Modify the text within the editor to change the comparison value. The editor supports JSON syntax highlighting.",
|
|
5146
5216
|
},
|
|
@@ -5177,11 +5247,11 @@ class UserConditionComponent {
|
|
|
5177
5247
|
if (JSON.stringify(oldValue) === JSON.stringify(newValue)) {
|
|
5178
5248
|
return;
|
|
5179
5249
|
}
|
|
5180
|
-
const validators = getComparisonValueType
|
|
5250
|
+
const validators = getComparisonValueType(this.formGroup().controls.comparator.value) ===
|
|
5181
5251
|
UserComparatorType.SemverList
|
|
5182
|
-
? getComparisonValueSemverListItemValidators
|
|
5183
|
-
: getComparisonValueStringListItemValidators
|
|
5184
|
-
const formArray = generateComparisonValueListValueArray
|
|
5252
|
+
? getComparisonValueSemverListItemValidators(this.featureFlagLimitations())
|
|
5253
|
+
: getComparisonValueStringListItemValidators(this.featureFlagLimitations());
|
|
5254
|
+
const formArray = generateComparisonValueListValueArray(data.comparisonValueList, this.readOnly(), this.featureFlagLimitations(), validators);
|
|
5185
5255
|
this.formGroup().controls.comparisonValue.setControl("listValue", formArray);
|
|
5186
5256
|
this.formGroup().controls.comparisonValue.updateValueAndValidity();
|
|
5187
5257
|
this.formGroup().controls.comparisonValue.markAllAsTouched();
|
|
@@ -5348,7 +5418,7 @@ class ConditionsComponent {
|
|
|
5348
5418
|
addUserCondition() {
|
|
5349
5419
|
if (!this.checkLimitations())
|
|
5350
5420
|
return;
|
|
5351
|
-
const f = generateConditionFormGroup
|
|
5421
|
+
const f = generateConditionFormGroup({
|
|
5352
5422
|
userCondition: {
|
|
5353
5423
|
comparisonAttribute: "Identifier",
|
|
5354
5424
|
comparator: UserComparator.SensitiveTextEquals,
|
|
@@ -5368,7 +5438,7 @@ class ConditionsComponent {
|
|
|
5368
5438
|
return;
|
|
5369
5439
|
}
|
|
5370
5440
|
const f = new FormGroup({
|
|
5371
|
-
segmentCondition: generateEmptySegmentConditionFormGroup
|
|
5441
|
+
segmentCondition: generateEmptySegmentConditionFormGroup(),
|
|
5372
5442
|
});
|
|
5373
5443
|
this.formArray().push(f);
|
|
5374
5444
|
f.markAsDirty();
|
|
@@ -5377,7 +5447,7 @@ class ConditionsComponent {
|
|
|
5377
5447
|
if (!this.checkLimitations())
|
|
5378
5448
|
return;
|
|
5379
5449
|
const f = new FormGroup({
|
|
5380
|
-
prerequisiteFlagCondition: generateEmptyPrerequisiteFlagConditionFormGroup
|
|
5450
|
+
prerequisiteFlagCondition: generateEmptyPrerequisiteFlagConditionFormGroup(this.featureFlagLimitations()),
|
|
5381
5451
|
});
|
|
5382
5452
|
this.formArray().push(f);
|
|
5383
5453
|
f.markAsDirty();
|
|
@@ -5448,9 +5518,9 @@ class PercentageOptionsComponent {
|
|
|
5448
5518
|
if (this.flagState().settingValue.setting.predefinedVariations.length && !remainingPredefinedVariations.length) {
|
|
5449
5519
|
return;
|
|
5450
5520
|
}
|
|
5451
|
-
this.formArray().push(generatePercentageOptionFormGroup
|
|
5521
|
+
this.formArray().push(generatePercentageOptionFormGroup({
|
|
5452
5522
|
percentage: 0,
|
|
5453
|
-
value: generateDefaultValue
|
|
5523
|
+
value: generateDefaultValue(this.flagState().settingValue.setting.settingType, remainingPredefinedVariations),
|
|
5454
5524
|
}, this.flagState().settingValue.setting.settingType, this.flagState().settingValue.setting.predefinedVariations, false, this.featureFlagLimitations()));
|
|
5455
5525
|
this.formArray().markAsDirty();
|
|
5456
5526
|
this.percentageOptionsCount.set(this.formArray().controls.length);
|
|
@@ -7139,5 +7209,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.7", ngImpor
|
|
|
7139
7209
|
* Generated bundle index. Do not edit.
|
|
7140
7210
|
*/
|
|
7141
7211
|
|
|
7142
|
-
export { AuthorizationComponent, CONFIGCAT_PUBLICAPI_UI_CONFIGURATION, ConfigSelectComponent, CreateConfigComponent, CreateFeatureFlagComponent, DeleteSettingDialogComponent, EnvironmentSelectComponent, FeatureFlagItemComponent, FormHelper, InputDisplayNormalizerDirective, LinkFeatureFlagComponent, LoaderComponent, ProductSelectComponent, PublicApiService, SettingItemComponent, SettingSelectComponent, Theme, ThemeService, UserComparatorText, UserComparatorType, addComparisonValueListValueItems, defaultErrorMessageTypes, featureFlagKeyRegex, generateComparisonValueFormGroup, generateComparisonValueListFormGroup, generateComparisonValueListValueArray, generateConditionFormGroup, generateDefaultValue, generateDefaultValueFormGroup, generateEmptyPrerequisiteFlagConditionFormGroup, generateEmptySegmentConditionFormGroup, generatePercentageEvaluationAttributeFormControl, generatePercentageOptionFormGroup, generatePrerequisiteDefaultValue, generatePrerequisiteFlagConditionFormGroup, generateSegmentConditionFormGroup, generateSettingValuesFormGroup, generateTargetingRuleFormGroup, generateTargetingRuleWithEmptyPercentageOptions, generateUserConditionFormGroup, generateValueFormGroup, getComparisonValueSemverListItemValidators, getComparisonValueSemverValidators, getComparisonValueStringListItemValidators, getComparisonValueStringValidators, getComparisonValueType, getEmptyPercentageOptions, getNextIndex, getRawSettiongValue, getRawValue, getValidatorsForSettingType, isClearTextComparator, isPercentageOnlyTargetingRule, percentageRegex, provideConfigCatPublicApiUi, validatePercentageSum, wholeNumberRegex };
|
|
7212
|
+
export { AuthorizationComponent, CONFIGCAT_PUBLICAPI_UI_CONFIGURATION, ConfigSelectComponent, CreateConfigComponent, CreateFeatureFlagComponent, DeleteSettingDialogComponent, EnvironmentSelectComponent, FeatureFlagItemComponent, FormHelper, InputDisplayNormalizerDirective, LinkFeatureFlagComponent, LoaderComponent, ProductSelectComponent, PublicApiService, SettingItemComponent, SettingSelectComponent, Theme, ThemeService, UserComparatorText, UserComparatorType, addComparisonValueListValueItems, defaultErrorMessageTypes, featureFlagKeyRegex, formatCsvStringValue, formatValuesAndHintAsCsv, formatValuesAndHintAsJson, formatValuesAsCsv, generateComparisonValueFormGroup, generateComparisonValueListFormGroup, generateComparisonValueListValueArray, generateConditionFormGroup, generateDefaultValue, generateDefaultValueFormGroup, generateEmptyPrerequisiteFlagConditionFormGroup, generateEmptySegmentConditionFormGroup, generatePercentageEvaluationAttributeFormControl, generatePercentageOptionFormGroup, generatePrerequisiteDefaultValue, generatePrerequisiteFlagConditionFormGroup, generateSegmentConditionFormGroup, generateSettingValuesFormGroup, generateTargetingRuleFormGroup, generateTargetingRuleWithEmptyPercentageOptions, generateUserConditionFormGroup, generateValueFormGroup, getComparisonValueSemverListItemValidators, getComparisonValueSemverValidators, getComparisonValueStringListItemValidators, getComparisonValueStringValidators, getComparisonValueType, getEmptyPercentageOptions, getNextIndex, getRawSettiongValue, getRawValue, getValidatorsForSettingType, isClearTextComparator, isPercentageOnlyTargetingRule, parseValuesAndHintsFromCsv, parseValuesAndHintsFromJson, parseValuesFromCsv, percentageRegex, provideConfigCatPublicApiUi, validatePercentageSum, wholeNumberRegex };
|
|
7143
7213
|
//# sourceMappingURL=ng-configcat-publicapi-ui.mjs.map
|