@azure/app-configuration-importer 1.0.0-preview → 1.1.0-preview
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/README.md +67 -0
- package/dist/index.js +7110 -217
- package/dist/index.js.map +1 -1
- package/dist-esm/src/MsFeatureFlagSchema.js +122 -0
- package/dist-esm/src/MsFeatureFlagSchema.js.map +1 -0
- package/dist-esm/src/appConfigurationImporter.js +157 -0
- package/dist-esm/src/appConfigurationImporter.js.map +1 -0
- package/dist-esm/src/enums.js +28 -0
- package/dist-esm/src/enums.js.map +1 -0
- package/dist-esm/src/errors.js +53 -0
- package/dist-esm/src/errors.js.map +1 -0
- package/dist-esm/src/featureFlag.js +12 -0
- package/dist-esm/src/featureFlag.js.map +1 -0
- package/dist-esm/src/importOptions.js +4 -0
- package/dist-esm/src/importOptions.js.map +1 -0
- package/dist-esm/src/index.js +9 -0
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/internal/adaptiveTaskManager.js +69 -0
- package/dist-esm/src/internal/adaptiveTaskManager.js.map +1 -0
- package/dist-esm/src/internal/constants.js +36 -0
- package/dist-esm/src/internal/constants.js.map +1 -0
- package/dist-esm/src/internal/parsers/configurationSettingsConverter.js +4 -0
- package/dist-esm/src/internal/parsers/configurationSettingsConverter.js.map +1 -0
- package/dist-esm/src/internal/parsers/defaultConfigurationSettingsConverter.js +328 -0
- package/dist-esm/src/internal/parsers/defaultConfigurationSettingsConverter.js.map +1 -0
- package/dist-esm/src/internal/parsers/kvSetConfigurationSettingsConverter.js +66 -0
- package/dist-esm/src/internal/parsers/kvSetConfigurationSettingsConverter.js.map +1 -0
- package/dist-esm/src/internal/stream.browser.js +16 -0
- package/dist-esm/src/internal/stream.browser.js.map +1 -0
- package/dist-esm/src/internal/stream.js +15 -0
- package/dist-esm/src/internal/stream.js.map +1 -0
- package/dist-esm/src/internal/utils.js +129 -0
- package/dist-esm/src/internal/utils.js.map +1 -0
- package/dist-esm/src/models.js +4 -0
- package/dist-esm/src/models.js.map +1 -0
- package/dist-esm/src/settingsImport/configurationSettingsSource.js +4 -0
- package/dist-esm/src/settingsImport/configurationSettingsSource.js.map +1 -0
- package/dist-esm/src/settingsImport/iterableConfigurationSettingsSource.js +83 -0
- package/dist-esm/src/settingsImport/iterableConfigurationSettingsSource.js.map +1 -0
- package/dist-esm/src/settingsImport/readableStreamConfigurationSettingsSource.js +49 -0
- package/dist-esm/src/settingsImport/readableStreamConfigurationSettingsSource.js.map +1 -0
- package/dist-esm/src/settingsImport/stringConfigurationSettingsSource.js +92 -0
- package/dist-esm/src/settingsImport/stringConfigurationSettingsSource.js.map +1 -0
- package/package.json +20 -5
- package/types/azure-app-configuration-importer.d.ts +13 -0
- package/types/src/MsFeatureFlagSchema.d.ts +164 -0
- package/types/src/MsFeatureFlagSchema.d.ts.map +1 -0
- package/types/src/appConfigurationImporter.d.ts +37 -0
- package/types/src/appConfigurationImporter.d.ts.map +1 -0
- package/types/src/enums.d.ts +23 -0
- package/types/src/enums.d.ts.map +1 -0
- package/types/src/errors.d.ts +36 -0
- package/types/src/errors.d.ts.map +1 -0
- package/types/src/featureFlag.d.ts +50 -0
- package/types/src/featureFlag.d.ts.map +1 -0
- package/types/src/importOptions.d.ts +39 -0
- package/types/src/importOptions.d.ts.map +1 -0
- package/types/src/index.d.ts +10 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/internal/adaptiveTaskManager.d.ts +20 -0
- package/types/src/internal/adaptiveTaskManager.d.ts.map +1 -0
- package/types/src/internal/constants.d.ts +10 -0
- package/types/src/internal/constants.d.ts.map +1 -0
- package/types/src/internal/parsers/configurationSettingsConverter.d.ts +11 -0
- package/types/src/internal/parsers/configurationSettingsConverter.d.ts.map +1 -0
- package/types/src/internal/parsers/defaultConfigurationSettingsConverter.d.ts +21 -0
- package/types/src/internal/parsers/defaultConfigurationSettingsConverter.d.ts.map +1 -0
- package/types/src/internal/parsers/kvSetConfigurationSettingsConverter.d.ts +15 -0
- package/types/src/internal/parsers/kvSetConfigurationSettingsConverter.d.ts.map +1 -0
- package/types/src/internal/stream.browser.d.ts +4 -0
- package/types/src/internal/stream.browser.d.ts.map +1 -0
- package/types/src/internal/stream.d.ts +4 -0
- package/types/src/internal/stream.d.ts.map +1 -0
- package/types/src/internal/utils.d.ts +17 -0
- package/types/src/internal/utils.d.ts.map +1 -0
- package/types/src/models.d.ts +42 -0
- package/types/src/models.d.ts.map +1 -0
- package/types/src/settingsImport/configurationSettingsSource.d.ts +19 -0
- package/types/src/settingsImport/configurationSettingsSource.d.ts.map +1 -0
- package/types/src/settingsImport/iterableConfigurationSettingsSource.d.ts +14 -0
- package/types/src/settingsImport/iterableConfigurationSettingsSource.d.ts.map +1 -0
- package/types/src/settingsImport/readableStreamConfigurationSettingsSource.d.ts +11 -0
- package/types/src/settingsImport/readableStreamConfigurationSettingsSource.d.ts.map +1 -0
- package/types/src/settingsImport/stringConfigurationSettingsSource.d.ts +24 -0
- package/types/src/settingsImport/stringConfigurationSettingsSource.d.ts.map +1 -0
- package/NOTICE.txt +0 -370
- package/app-configuration-importer.test.log +0 -164
- package/dist/app-configuration-importer.api.md +0 -136
- package/examples/README.md +0 -59
- package/examples/package.json +0 -32
- package/examples/sample.env +0 -6
- package/examples/testFiles/default.json +0 -24
- package/examples/testFiles/kvset.json +0 -35
- package/types/tsdoc-metadata.json +0 -11
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/internal/utils.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAIL,sBAAsB,EACA,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,WAAW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,WAAW,IAAI,iBAAiB,CAAC,WAAW;QAC9D,0BAA0B,CAAC,iBAAiB,CAAC,UAAU,CAAC,aAAa,EAAE,iBAAiB,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AACvH,CAAC;AAED,SAAS,0BAA0B,CAAC,OAAmC,EAAE,OAAmC;IAC1G,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE;QACrC,OAAO,KAAK,CAAC;KACd;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QACvC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE;YACpC,OAAO,KAAK,CAAC;SACd;KACF;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAa;IACvC,MAAM,UAAU,GAAQ,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE1C,OAAO;QACL,EAAE,EAAE,UAAU,CAAC,EAAE;QACjB,OAAO,EAAE,UAAU,CAAC,OAAO;QAC3B,WAAW,EAAC,UAAU,CAAC,WAAW;QAClC,UAAU,EAAE,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,EAAC,aAAa,EAAE,EAAE,EAAC,CAAC,CAAC,CAAC,EAAC,aAAa,EAAE,UAAU,CAAC,UAAU,CAAC,cAAc,EAAC;KACzH,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { \n ConfigurationSetting, \n SetConfigurationSettingParam, \n FeatureFlagValue,\n featureFlagContentType,\n SecretReferenceValue } from \"@azure/app-configuration\";\nimport { isEmpty, isEqual } from \"lodash\";\nimport { Tags, FeatureFlagClientFilters } from \"../models\";\nimport { SourceOptions } from \"../importOptions\";\nimport { ConfigurationFormat, ConfigurationProfile } from \"../enums\";\nimport { ArgumentError, ArgumentNullError } from \"../errors\";\nimport { Constants } from \"../internal/constants\";\n\n/** @internal*/\nexport function isJsonContentType(contentType?: string): boolean {\n if (!contentType) {\n return false;\n }\n\n contentType = contentType.trim().toLowerCase();\n const mineType = contentType.split(\";\")[0].trim();\n const typeParts = mineType.split(\"/\");\n if (typeParts.length != 2) {\n return false;\n }\n\n if (typeParts[0] != \"application\") {\n return false;\n }\n\n const subTypes = typeParts[1].split(\"+\");\n if (subTypes[subTypes.length-1] == \"json\") {\n return true;\n }\n\n return false;\n}\n\n/** @internal*/\nexport function isConfigSettingEqual(settingA: SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>, settingB: ConfigurationSetting) {\n let valueIsEqual: boolean = settingA.value == settingB.value;\n \n if (settingA.contentType == featureFlagContentType &&\n settingB.contentType == featureFlagContentType && \n settingA.value !== undefined && \n settingB.value !== undefined) {\n valueIsEqual = isFeatureFlagValueEqual(settingA.value as string | FeatureFlagValue, settingB.value);\n }\n\n return valueIsEqual &&\n settingA.contentType == settingB.contentType &&\n areTagsEqual(settingA.tags, settingB.tags);\n}\n\n/** @internal*/\nexport function areTagsEqual(tagA?: Tags, tagB?: Tags): boolean {\n if (isEmpty(tagA) || isEmpty(tagB)) {\n return isEmpty(tagA) && isEmpty(tagB);\n }\n\n if (Object.keys(tagA).length !== Object.keys(tagB).length) {\n return false;\n }\n\n for(const key in tagA) {\n if (tagA[key] !== tagB[key]) {\n return false;\n }\n }\n return true;\n}\n\n/** @internal*/\n/**\n * Validate the ConfigurationSyncOptions argument, throw fatal error if options are not valid.\n *\n * @param options - ConfigurationSyncOptions to be validated.\n */\nexport function validateOptions(options: SourceOptions): void {\n if (!options) {\n throw new ArgumentNullError();\n }\n\n if (options.profile == ConfigurationProfile.KvSet) {\n if (\n options.prefix ||\n options.separator ||\n options.label ||\n options.depth ||\n options.tags ||\n options.contentType\n ) {\n throw new ArgumentError(\n \"The option label, prefix, depth, contentType, tags and separator are not supported when importing using 'appconfig/kvset' profile\"\n );\n }\n\n if (options.format !== ConfigurationFormat.Json) {\n throw new ArgumentError(\n \"Yaml and Properties formats are not supported for appconfig/kvset profile. Supported value is: Json\"\n );\n }\n }\n\n if (options.depth && options.depth > 1 && !options.separator) {\n throw new ArgumentError(\n \"Separator must be specified if Depth is default value or set a value lager than 1\"\n );\n }\n\n if (options.separator && !Constants.Separators.includes(options.separator)) {\n throw new ArgumentError(`${options.separator} is not a supported separator.`);\n }\n\n if (!options.separator && !options.depth) {\n options.depth = 1;\n }\n\n if (options.format !== ConfigurationFormat.Json && isJsonContentType(options.contentType)) {\n throw new ArgumentError(`Failed to import '${ConfigurationFormat[options.format]}' data format with '${options.contentType}' content type. Please provide data in JSON format to match your content type.`);\n }\n}\n\nfunction isFeatureFlagValueEqual(valueA: string | FeatureFlagValue, valueB: string): boolean {\n let featureFlagAValue: FeatureFlagValue;\n\n if (typeof valueA == \"string\") {\n featureFlagAValue = toFeatureFlagValue(valueA);\n }\n else {\n featureFlagAValue = valueA;\n }\n\n const featureFlagBValue: FeatureFlagValue = toFeatureFlagValue(valueB);\n\n if (Object.keys(featureFlagAValue).length !== Object.keys(featureFlagBValue).length) {\n return false;\n }\n\n return featureFlagAValue.id == featureFlagBValue.id &&\n featureFlagAValue.enabled == featureFlagBValue.enabled &&\n featureFlagAValue.description == featureFlagBValue.description &&\n areFeatureFlagFiltersEqual(featureFlagAValue.conditions.clientFilters, featureFlagBValue.conditions.clientFilters);\n}\n\nfunction areFeatureFlagFiltersEqual(filterA: FeatureFlagClientFilters[], filterB: FeatureFlagClientFilters[]): boolean {\n if (filterA.length !== filterB.length) {\n return false;\n }\n\n for (let i = 0; i < filterA.length; i++) {\n if (!isEqual(filterA[i], filterB[i])) {\n return false;\n }\n }\n return true;\n}\n\nfunction toFeatureFlagValue(value: string): FeatureFlagValue {\n const parsedJson: any = JSON.parse(value);\n\n return {\n id: parsedJson.id,\n enabled: parsedJson.enabled,\n description:parsedJson.description,\n conditions: isEmpty(parsedJson.conditions) ? {clientFilters: []} : {clientFilters: parsedJson.conditions.client_filters}\n };\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"models.js","sourceRoot":"","sources":["../../src/models.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * @internal\n */\nexport type ClientFilter = { name: string; parameters?: Record<string, unknown> };\n\n/**\n * @internal\n */\nexport interface JsonSecretReferenceValue {\n uri: string;\n}\n\n/**\n * @internal\n */\nexport type KvSetConfigurationItem = {\n key: string;\n value?: string;\n label?: string;\n content_type?: string;\n tags?: { [propertyName: string]: string };\n}\n\nexport interface ImportProgress {\n successCount: number;\n importCount: number;\n}\n\nexport interface Tags {\n [propertyName: string]: string;\n}\n\nexport interface FeatureFlagClientFilters {\n name: string;\n parameters?: Record<string, unknown> | undefined;\n}\n\nexport interface KeyLabelLookup {\n [key: string]: {\n [label: string] : boolean\n }\n}"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configurationSettingsSource.js","sourceRoot":"","sources":["../../../src/settingsImport/configurationSettingsSource.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n FeatureFlagValue,\n ListConfigurationSettingsOptions,\n SecretReferenceValue,\n SetConfigurationSettingParam\n} from \"@azure/app-configuration\";\n\n/**\n * Interface of all ConfigurationSettingsSource\n */\nexport interface ConfigurationSettingsSource {\n /**\n * Get ConfigurationSettings collection from source.\n *\n * @returns Collection of ConfigurationSettings\n */\n GetConfigurationSettings(): Promise<Array<SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>>>;\n\n /**\n * Get label and prefix filter\n *\n * @returns label and prefix\n */\n FilterOptions: ListConfigurationSettingsOptions;\n}\n"]}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
4
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
5
|
+
var m = o[Symbol.asyncIterator], i;
|
|
6
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
7
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
8
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
9
|
+
};
|
|
10
|
+
import { featureFlagContentType, featureFlagPrefix, secretReferenceContentType } from "@azure/app-configuration";
|
|
11
|
+
import { ArgumentError } from "../errors";
|
|
12
|
+
export class IterableConfigurationSettingsSource {
|
|
13
|
+
constructor(options) {
|
|
14
|
+
this.FilterOptions = {};
|
|
15
|
+
this.data = options.data;
|
|
16
|
+
this.options = options;
|
|
17
|
+
this.FilterOptions = {
|
|
18
|
+
keyFilter: options.prefix ? options.prefix + "*" : undefined,
|
|
19
|
+
labelFilter: options.label ? options.label : "\0"
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* @inheritdoc
|
|
24
|
+
*/
|
|
25
|
+
async GetConfigurationSettings() {
|
|
26
|
+
var _a, e_1, _b, _c;
|
|
27
|
+
const result = [];
|
|
28
|
+
try {
|
|
29
|
+
for (var _d = true, _e = __asyncValues(this.data), _f; _f = await _e.next(), _a = _f.done, !_a;) {
|
|
30
|
+
_c = _f.value;
|
|
31
|
+
_d = false;
|
|
32
|
+
try {
|
|
33
|
+
const configuration = _c;
|
|
34
|
+
const isFeatureFlag = configuration.key.startsWith(featureFlagPrefix) && configuration.contentType == featureFlagContentType;
|
|
35
|
+
const isKeyVaultReference = configuration.contentType == secretReferenceContentType;
|
|
36
|
+
const contentType = isFeatureFlag || isKeyVaultReference ?
|
|
37
|
+
configuration.contentType :
|
|
38
|
+
this.options.contentType || configuration.contentType;
|
|
39
|
+
let generatedKey = configuration.key;
|
|
40
|
+
if (this.options.prefix || this.options.trimPrefix) {
|
|
41
|
+
if (isFeatureFlag) {
|
|
42
|
+
generatedKey = generatedKey.substring(featureFlagPrefix.length);
|
|
43
|
+
}
|
|
44
|
+
if (this.options.trimPrefix && generatedKey.startsWith(this.options.trimPrefix)) {
|
|
45
|
+
generatedKey = generatedKey.substring(this.options.trimPrefix.length);
|
|
46
|
+
}
|
|
47
|
+
if (this.options.prefix) {
|
|
48
|
+
generatedKey = this.options.prefix + generatedKey;
|
|
49
|
+
}
|
|
50
|
+
if (isFeatureFlag) {
|
|
51
|
+
generatedKey = featureFlagPrefix + generatedKey;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
if (generatedKey === "." || generatedKey === ".." || generatedKey.indexOf("%") > -1) {
|
|
55
|
+
throw new ArgumentError("Key cannot be a '.' or '..', or contain the '%' character.");
|
|
56
|
+
}
|
|
57
|
+
if (this.options.skipFeatureFlags && isFeatureFlag) {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
result.push({
|
|
61
|
+
key: generatedKey,
|
|
62
|
+
label: this.options.label || configuration.label,
|
|
63
|
+
value: configuration.value,
|
|
64
|
+
contentType: contentType,
|
|
65
|
+
tags: configuration.tags
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
finally {
|
|
69
|
+
_d = true;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
74
|
+
finally {
|
|
75
|
+
try {
|
|
76
|
+
if (!_d && !_a && (_b = _e.return)) await _b.call(_e);
|
|
77
|
+
}
|
|
78
|
+
finally { if (e_1) throw e_1.error; }
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=iterableConfigurationSettingsSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"iterableConfigurationSettingsSource.js","sourceRoot":"","sources":["../../../src/settingsImport/iterableConfigurationSettingsSource.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;;;;;;;AAIlC,OAAO,EAOL,sBAAsB,EACtB,iBAAiB,EACjB,0BAA0B,EAAC,MAAM,0BAA0B,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,MAAM,OAAO,mCAAmC;IAM9C,YAAY,OAA8B;QALnC,kBAAa,GAAqC,EAAE,CAAC;QAM1D,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,IAAI,CAAC,aAAa,GAAG;YACnB,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS;YAC5D,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;SAClD,CAAC;IACJ,CAAC;IAED;;SAEK;IACE,KAAK,CAAC,wBAAwB;;QACnC,MAAM,MAAM,GAAmC,EAAE,CAAC;;YAElD,KAAkC,eAAA,KAAA,cAAA,IAAI,CAAC,IAAI,CAAA,IAAA;gBAAT,cAAS;gBAAT,WAAS;;oBAAhC,MAAM,aAAa,KAAA,CAAA;oBAC5B,MAAM,aAAa,GAAY,aAAa,CAAC,GAAG,CAAC,UAAU,CAAC,iBAAiB,CAAC,IAAI,aAAa,CAAC,WAAW,IAAI,sBAAsB,CAAC;oBACtI,MAAM,mBAAmB,GAAY,aAAa,CAAC,WAAW,I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,CAAC,KAAK;wBAChD,KAAK,EAAE,aAAa,CAAC,KAAK;wBAC1B,WAAW,EAAE,WAAW;wBACxB,IAAI,EAAE,aAAa,CAAC,IAAI;qBACzB,CAAC,CAAC;;;;;aACJ;;;;;;;;;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { PagedAsyncIterableIterator, PageSettings } from \"@azure/core-paging\";\nimport { ConfigurationSettingsSource } from \"./configurationSettingsSource\";\nimport { \n ConfigurationSetting, \n SetConfigurationSettingParam, \n FeatureFlagValue,\n SecretReferenceValue,\n ListConfigurationSettingsOptions, \n ListConfigurationSettingPage, \n featureFlagContentType,\n featureFlagPrefix,\n secretReferenceContentType} from \"@azure/app-configuration\";\nimport { IterableSourceOptions } from \"../importOptions\";\nimport { ArgumentError } from \"../errors\";\n\nexport class IterableConfigurationSettingsSource implements ConfigurationSettingsSource {\n public FilterOptions: ListConfigurationSettingsOptions = {};\n\n private data: PagedAsyncIterableIterator<ConfigurationSetting<string>, ListConfigurationSettingPage, PageSettings>;\n private options: IterableSourceOptions;\n\n constructor(options: IterableSourceOptions) {\n this.data = options.data;\n this.options = options;\n \n this.FilterOptions = {\n keyFilter: options.prefix ? options.prefix + \"*\" : undefined,\n labelFilter: options.label ? options.label : \"\\0\"\n };\n }\n \n /**\n * @inheritdoc\n */\n public async GetConfigurationSettings(): Promise<SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>[]> {\n const result: SetConfigurationSettingParam[] = [];\n\n for await (const configuration of this.data) {\n const isFeatureFlag: boolean = configuration.key.startsWith(featureFlagPrefix) && configuration.contentType == featureFlagContentType;\n const isKeyVaultReference: boolean = configuration.contentType == secretReferenceContentType;\n const contentType: string | undefined = isFeatureFlag || isKeyVaultReference ?\n configuration.contentType :\n this.options.contentType || configuration.contentType;\n\n let generatedKey: string = configuration.key;\n \n if (this.options.prefix || this.options.trimPrefix) {\n if (isFeatureFlag) {\n generatedKey = generatedKey.substring(featureFlagPrefix.length);\n }\n\n if (this.options.trimPrefix && generatedKey.startsWith(this.options.trimPrefix)) {\n generatedKey = generatedKey.substring(this.options.trimPrefix.length);\n }\n\n if (this.options.prefix) {\n generatedKey = this.options.prefix + generatedKey;\n }\n\n if(isFeatureFlag) {\n generatedKey = featureFlagPrefix + generatedKey;\n }\n }\n \n if (generatedKey === \".\" || generatedKey === \"..\" || generatedKey.indexOf(\"%\") > -1) {\n throw new ArgumentError(\"Key cannot be a '.' or '..', or contain the '%' character.\");\n }\n \n if (this.options.skipFeatureFlags && isFeatureFlag) {\n continue;\n }\n\n result.push({\n key: generatedKey,\n label: this.options.label || configuration.label,\n value: configuration.value,\n contentType: contentType,\n tags: configuration.tags\n });\n }\n\n return result;\n }\n}"]}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
import { toWebStream } from "../internal/stream";
|
|
4
|
+
import { ConfigurationProfile } from "../enums";
|
|
5
|
+
import { StringConfigurationSettingsSource } from "./stringConfigurationSettingsSource";
|
|
6
|
+
import { validateOptions } from "../internal/utils";
|
|
7
|
+
export class ReadableStreamConfigurationSettingsSource {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.FilterOptions = {};
|
|
10
|
+
validateOptions(options);
|
|
11
|
+
this.options = options;
|
|
12
|
+
this.data = options.data;
|
|
13
|
+
if (options.profile == ConfigurationProfile.Default) {
|
|
14
|
+
this.FilterOptions = {
|
|
15
|
+
keyFilter: options.prefix ? options.prefix + "*" : undefined,
|
|
16
|
+
labelFilter: options.label ? options.label : "\0"
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
else if (options.profile == ConfigurationProfile.KvSet) {
|
|
20
|
+
this.FilterOptions = {
|
|
21
|
+
keyFilter: "*",
|
|
22
|
+
labelFilter: "*"
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
async GetConfigurationSettings() {
|
|
27
|
+
const reader = toWebStream(this.data).getReader();
|
|
28
|
+
const textDecoder = new TextDecoder("utf-8");
|
|
29
|
+
try {
|
|
30
|
+
let allData = "";
|
|
31
|
+
// eslint-disable-next-line no-constant-condition
|
|
32
|
+
while (true) {
|
|
33
|
+
const { done, value } = await reader.read();
|
|
34
|
+
if (done) {
|
|
35
|
+
const stringSource = new StringConfigurationSettingsSource(Object.assign(Object.assign({}, this.options), { data: allData }));
|
|
36
|
+
const settings = await stringSource.GetConfigurationSettings();
|
|
37
|
+
return settings;
|
|
38
|
+
}
|
|
39
|
+
if (value) {
|
|
40
|
+
allData += textDecoder.decode(value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
finally {
|
|
45
|
+
reader.releaseLock();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=readableStreamConfigurationSettingsSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"readableStreamConfigurationSettingsSource.js","sourceRoot":"","sources":["../../../src/settingsImport/readableStreamConfigurationSettingsSource.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAGjD,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAChD,OAAO,EAAE,iCAAiC,EAAE,MAAM,qCAAqC,CAAC;AACxF,OAAO,EAAE,eAAe,EAAC,MAAM,mBAAmB,CAAC;AAEnD,MAAM,OAAO,yCAAyC;IAKpD,YAAY,OAAoC;QAJzC,kBAAa,GAAqC,EAAE,CAAC;QAK1D,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAEzB,IAAI,OAAO,CAAC,OAAO,IAAI,o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.\n\nimport { SetConfigurationSettingParam, FeatureFlagValue, SecretReferenceValue, ListConfigurationSettingsOptions } from \"@azure/app-configuration\";\nimport { toWebStream } from \"../internal/stream\";\nimport { ReadableStreamSourceOptions, SourceOptions } from \"../importOptions\";\nimport { ConfigurationSettingsSource } from \"./configurationSettingsSource\";\nimport { ConfigurationProfile } from \"../enums\";\nimport { StringConfigurationSettingsSource } from \"./stringConfigurationSettingsSource\";\nimport { validateOptions} from \"../internal/utils\";\n\nexport class ReadableStreamConfigurationSettingsSource implements ConfigurationSettingsSource { \n public FilterOptions: ListConfigurationSettingsOptions = {};\n private options: SourceOptions;\n private data: ReadableStream<Uint8Array> | NodeJS.ReadableStream;\n\n constructor(options: ReadableStreamSourceOptions) {\n validateOptions(options);\n this.options = options;\n this.data = options.data;\n\n if (options.profile == ConfigurationProfile.Default) {\n this.FilterOptions = {\n keyFilter: options.prefix ? options.prefix + \"*\" : undefined,\n labelFilter: options.label ? options.label : \"\\0\"\n };\n }\n else if (options.profile == ConfigurationProfile.KvSet) {\n this.FilterOptions = {\n keyFilter: \"*\",\n labelFilter: \"*\"\n };\n }\n }\n\n public async GetConfigurationSettings(): Promise<SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>[]> {\n const reader: ReadableStreamDefaultReader = toWebStream(this.data).getReader();\n const textDecoder = new TextDecoder(\"utf-8\");\n\n try {\n let allData = \"\";\n\n // eslint-disable-next-line no-constant-condition\n while (true) {\n const { done, value } = await reader.read();\n if (done) {\n const stringSource = new StringConfigurationSettingsSource({...this.options, data: allData});\n const settings = await stringSource.GetConfigurationSettings();\n\n return settings;\n }\n\n if (value) {\n allData += textDecoder.decode(value);\n }\n }\n }\n finally{\n reader.releaseLock();\n }\n }\n}"]}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import * as jsyaml from "js-yaml";
|
|
4
|
+
import stripJSONComments from "strip-json-comments";
|
|
5
|
+
import { getProperties } from "properties-file";
|
|
6
|
+
import { ConfigurationFormat, ConfigurationProfile } from "../enums";
|
|
7
|
+
import { ArgumentError, ParseError } from "../errors";
|
|
8
|
+
import { validateOptions } from "../internal/utils";
|
|
9
|
+
import { DefaultConfigurationSettingsConverter } from "../internal/parsers/defaultConfigurationSettingsConverter";
|
|
10
|
+
import { KvSetConfigurationSettingsConverter } from "../internal/parsers/kvSetConfigurationSettingsConverter";
|
|
11
|
+
/**
|
|
12
|
+
* ConfigurationSettingsSource implementation of string data configuration source
|
|
13
|
+
*/
|
|
14
|
+
export class StringConfigurationSettingsSource {
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.FilterOptions = {};
|
|
17
|
+
validateOptions(options);
|
|
18
|
+
this.options = options;
|
|
19
|
+
this.data = options.data;
|
|
20
|
+
if (options.profile == ConfigurationProfile.Default) {
|
|
21
|
+
this.FilterOptions = {
|
|
22
|
+
keyFilter: options.prefix ? options.prefix + "*" : undefined,
|
|
23
|
+
labelFilter: options.label ? options.label : "\0"
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
else if (options.profile == ConfigurationProfile.KvSet) {
|
|
27
|
+
this.FilterOptions = {
|
|
28
|
+
keyFilter: "*",
|
|
29
|
+
labelFilter: "*"
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @inheritdoc
|
|
35
|
+
*/
|
|
36
|
+
async GetConfigurationSettings() {
|
|
37
|
+
return this.getConfigurationSettingsInternal(this.data);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Get the ConfigurationSettings from supplied data string source.
|
|
41
|
+
*
|
|
42
|
+
* @param data The string data being parsed.
|
|
43
|
+
* @returns Collection of ConfigurationSettings
|
|
44
|
+
*/
|
|
45
|
+
getConfigurationSettingsInternal(data) {
|
|
46
|
+
let loadedData = {};
|
|
47
|
+
// Checking string encoding format
|
|
48
|
+
if (/^\uFEFF/.test(data)) {
|
|
49
|
+
throw new ParseError("Failed to parse data: An invalid encoding, UTF-8 with BOM, was detected. Please update encoding to UTF-8 without BOM.");
|
|
50
|
+
}
|
|
51
|
+
try {
|
|
52
|
+
switch (this.options.format) {
|
|
53
|
+
case ConfigurationFormat.Json: {
|
|
54
|
+
loadedData = JSON.parse(stripJSONComments(data));
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
case ConfigurationFormat.Yaml: {
|
|
58
|
+
const temp = jsyaml.load(data, { schema: jsyaml.JSON_SCHEMA });
|
|
59
|
+
if (temp === undefined) {
|
|
60
|
+
throw new ParseError("Failed to parse data: Not a valid yaml format.");
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
loadedData = temp;
|
|
64
|
+
}
|
|
65
|
+
break;
|
|
66
|
+
}
|
|
67
|
+
case ConfigurationFormat.Properties: {
|
|
68
|
+
loadedData = getProperties(data);
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
default: {
|
|
72
|
+
throw new ArgumentError("Data Format provided is not supported. Supported values are: Json, Yaml and Properties.");
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (e) {
|
|
77
|
+
throw new ParseError(`Failed to parse data: ${e.message}`);
|
|
78
|
+
}
|
|
79
|
+
if (typeof loadedData !== "object") {
|
|
80
|
+
throw new ParseError(`Type of data be parsed is ${typeof loadedData}, not a valid object type`);
|
|
81
|
+
}
|
|
82
|
+
let converter;
|
|
83
|
+
if (this.options.profile === ConfigurationProfile.KvSet) {
|
|
84
|
+
converter = new KvSetConfigurationSettingsConverter();
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
converter = new DefaultConfigurationSettingsConverter();
|
|
88
|
+
}
|
|
89
|
+
return converter.Convert(loadedData, this.options);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=stringConfigurationSettingsSource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stringConfigurationSettingsSource.js","sourceRoot":"","sources":["../../../src/settingsImport/stringConfigurationSettingsSource.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAClC,OAAO,iBAAiB,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAG,MAAM,iBAAiB,CAAC;AAGjD,OAAO,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AACrE,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAE,qCAAqC,EAAE,MAAM,2DAA2D,CAAC;AAClH,OAAO,EAAE,mCAAmC,EAAE,MAAM,yDAAyD,CAAC;AAE9G;;GAEG;AACH,MAAM,OAAO,iCAAiC;IAK5C,YAAY,OAA4B;QAJjC,kBAAa,GAAqC,EAAE,CAAC;QAK1D,eAAe,CAAC,OAAO,CAAC,CAAC;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;QAEzB,IAAI,OAAO,CAAC,OAAO,IAAI,oBAAoB,CAAC,OAAO,EAAE;YACnD,IAAI,CAAC,aAAa,GAAG;gBACnB,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS;gBAC5D,WAAW,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI;aAClD,CAAC;SACH;aACI,IAAI,OAAO,CAAC,OAAO,IAAI,oBAAoB,CAAC,KAAK,EAAE;YACtD,IAAI,CAAC,aAAa,GAAG;gBACnB,SAAS,EAAE,GAAG;gBACd,WAAW,EAAE,GAAG;aACjB,CAAC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I,UAAU,CAClB,6BAA6B,OAAO,UAAU,2BAA2B,CAC1E,CAAC;SACH;QAED,IAAI,SAAyC,CAAC;QAC9C,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,KAAK,oBAAoB,CAAC,KAAK,EAAE;YACvD,SAAS,GAAG,IAAI,mCAAmC,EAAE,CAAC;SACvD;aACI;YACH,SAAS,GAAG,IAAI,qCAAqC,EAAE,CAAC;SACzD;QAED,OAAO,SAAS,CAAC,OAAO,CAAC,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACrD,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n FeatureFlagValue,\n ListConfigurationSettingsOptions,\n SecretReferenceValue,\n SetConfigurationSettingParam\n} from \"@azure/app-configuration\";\nimport * as jsyaml from \"js-yaml\";\nimport stripJSONComments from \"strip-json-comments\";\nimport { getProperties } from \"properties-file\";\nimport { SourceOptions, StringSourceOptions } from \"../importOptions\";\nimport { ConfigurationSettingsSource } from \"./configurationSettingsSource\";\nimport { ConfigurationFormat, ConfigurationProfile } from \"../enums\";\nimport { ArgumentError, ParseError } from \"../errors\";\nimport { validateOptions } from \"../internal/utils\";\nimport { ConfigurationSettingsConverter } from \"../internal/parsers/configurationSettingsConverter\";\nimport { DefaultConfigurationSettingsConverter } from \"../internal/parsers/defaultConfigurationSettingsConverter\";\nimport { KvSetConfigurationSettingsConverter } from \"../internal/parsers/kvSetConfigurationSettingsConverter\";\n\n/**\n * ConfigurationSettingsSource implementation of string data configuration source\n */\nexport class StringConfigurationSettingsSource implements ConfigurationSettingsSource {\n public FilterOptions: ListConfigurationSettingsOptions = {};\n private options: SourceOptions;\n private data: string;\n\n constructor(options: StringSourceOptions) {\n validateOptions(options);\n this.options = options;\n this.data = options.data;\n\n if (options.profile == ConfigurationProfile.Default) {\n this.FilterOptions = {\n keyFilter: options.prefix ? options.prefix + \"*\" : undefined,\n labelFilter: options.label ? options.label : \"\\0\"\n };\n }\n else if (options.profile == ConfigurationProfile.KvSet) {\n this.FilterOptions = {\n keyFilter: \"*\",\n labelFilter: \"*\"\n };\n }\n }\n\n /**\n * @inheritdoc\n */\n public async GetConfigurationSettings(): Promise<SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>[]> {\n return this.getConfigurationSettingsInternal(this.data);\n }\n\n /**\n * Get the ConfigurationSettings from supplied data string source.\n * \n * @param data The string data being parsed.\n * @returns Collection of ConfigurationSettings\n */\n protected getConfigurationSettingsInternal(data: string): Array<\n SetConfigurationSettingParam<string | FeatureFlagValue | SecretReferenceValue>\n > {\n let loadedData: any = {};\n // Checking string encoding format\n if (/^\\uFEFF/.test(data)) {\n throw new ParseError(\n \"Failed to parse data: An invalid encoding, UTF-8 with BOM, was detected. Please update encoding to UTF-8 without BOM.\"\n );\n }\n\n try {\n switch (this.options.format) {\n case ConfigurationFormat.Json: {\n loadedData = JSON.parse(stripJSONComments(data));\n break;\n }\n case ConfigurationFormat.Yaml: {\n const temp = jsyaml.load(data, { schema: jsyaml.JSON_SCHEMA });\n if (temp === undefined) {\n throw new ParseError(\n \"Failed to parse data: Not a valid yaml format.\"\n );\n }\n else {\n loadedData = temp;\n }\n break;\n }\n case ConfigurationFormat.Properties: {\n loadedData = getProperties(data);\n break;\n }\n default: {\n throw new ArgumentError(\"Data Format provided is not supported. Supported values are: Json, Yaml and Properties.\");\n }\n }\n }\n catch (e: any) {\n throw new ParseError(`Failed to parse data: ${e.message}`);\n }\n\n if (typeof loadedData !== \"object\") {\n throw new ParseError(\n `Type of data be parsed is ${typeof loadedData}, not a valid object type`\n );\n }\n\n let converter: ConfigurationSettingsConverter;\n if (this.options.profile === ConfigurationProfile.KvSet) {\n converter = new KvSetConfigurationSettingsConverter();\n }\n else {\n converter = new DefaultConfigurationSettingsConverter();\n }\n\n return converter.Convert(loadedData, this.options);\n }\n}"]}
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@azure/app-configuration-importer",
|
|
3
3
|
"author": "Microsoft Corporation",
|
|
4
4
|
"description": "A client library for importing/exporting key-values between configuration sources and Azure App Configuration service",
|
|
5
|
-
"version": "1.
|
|
5
|
+
"version": "1.1.0-preview",
|
|
6
6
|
"sdk-type": "client",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"node",
|
|
@@ -16,6 +16,17 @@
|
|
|
16
16
|
"./dist-esm/src/internal/stream.js": "./dist-esm/src/internal/stream.browser.js"
|
|
17
17
|
},
|
|
18
18
|
"types": "./types/azure-app-configuration-importer.d.ts",
|
|
19
|
+
"files": [
|
|
20
|
+
"dist/**/*.js",
|
|
21
|
+
"dist/**/*.js.map",
|
|
22
|
+
"dist-esm/src/**/*.js",
|
|
23
|
+
"dist-esm/src/**/*.js.map",
|
|
24
|
+
"types/src/**/*d.ts",
|
|
25
|
+
"types/src/**/*d.ts.map",
|
|
26
|
+
"types/azure-app-configuration-importer.d.ts",
|
|
27
|
+
"README.md",
|
|
28
|
+
"LICENSE"
|
|
29
|
+
],
|
|
19
30
|
"scripts": {
|
|
20
31
|
"build": "npm run clean && tsc -p . && rollup -c && api-extractor run --local",
|
|
21
32
|
"test": "cross-env TS_NODE_PROJECT=\"tsconfig.test.json\" mocha -r ts-node/register 'tests/**/*.ts'",
|
|
@@ -25,17 +36,21 @@
|
|
|
25
36
|
},
|
|
26
37
|
"dependencies": {
|
|
27
38
|
"@azure/app-configuration": "1.5.0",
|
|
39
|
+
"@azure/core-client": "^1.9.2",
|
|
28
40
|
"@azure/core-paging": "^1.4.0",
|
|
29
41
|
"@azure/core-rest-pipeline": "^1.6.0",
|
|
42
|
+
"ajv": "^8.17.1",
|
|
30
43
|
"flat": "^5.0.2",
|
|
31
44
|
"js-yaml": "^4.1.0",
|
|
45
|
+
"lodash": "^4.17.21",
|
|
32
46
|
"properties-file": "^3.5.4",
|
|
33
47
|
"rxjs": "^7.5.6",
|
|
34
|
-
"tslib": "^2.2.0",
|
|
35
48
|
"strip-json-comments": "^3.1.1",
|
|
36
|
-
"
|
|
49
|
+
"tslib": "^2.2.0",
|
|
50
|
+
"uuid": "^10.0.0"
|
|
37
51
|
},
|
|
38
52
|
"devDependencies": {
|
|
53
|
+
"@azure/core-http": "^3.0.1",
|
|
39
54
|
"@microsoft/api-extractor": "^7.22.2",
|
|
40
55
|
"@rollup/plugin-commonjs": "^21.0.1",
|
|
41
56
|
"@rollup/plugin-inject": "^4.0.0",
|
|
@@ -51,6 +66,7 @@
|
|
|
51
66
|
"@types/node": "^18.0.0",
|
|
52
67
|
"@types/nodegit": "^0.22.5",
|
|
53
68
|
"@types/sinon": "^10.0.11",
|
|
69
|
+
"@types/uuid": "^10.0.0",
|
|
54
70
|
"@typescript-eslint/eslint-plugin": "^5.30.0",
|
|
55
71
|
"@typescript-eslint/parser": "^5.30.0",
|
|
56
72
|
"chai": "^4.2.0",
|
|
@@ -72,7 +88,6 @@
|
|
|
72
88
|
"rollup-plugin-typescript2": "^0.31.2",
|
|
73
89
|
"sinon": "^13.0.2",
|
|
74
90
|
"ts-node": "^10.0.0",
|
|
75
|
-
"typescript": "^4.6.3"
|
|
76
|
-
"@azure/core-http": "^3.0.1"
|
|
91
|
+
"typescript": "^4.6.3"
|
|
77
92
|
}
|
|
78
93
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import { AppConfigurationClient } from '@azure/app-configuration';
|
|
4
4
|
import { ConfigurationSetting } from '@azure/app-configuration';
|
|
5
|
+
import { ErrorObject } from 'ajv';
|
|
5
6
|
import { FeatureFlagValue } from '@azure/app-configuration';
|
|
6
7
|
import { ListConfigurationSettingPage } from '@azure/app-configuration';
|
|
7
8
|
import { ListConfigurationSettingsOptions } from '@azure/app-configuration';
|
|
@@ -10,6 +11,18 @@ import { PageSettings } from '@azure/core-paging';
|
|
|
10
11
|
import { SecretReferenceValue } from '@azure/app-configuration';
|
|
11
12
|
import { SetConfigurationSettingParam } from '@azure/app-configuration';
|
|
12
13
|
|
|
14
|
+
export declare interface AjvErrorInfo {
|
|
15
|
+
schemaPath: string;
|
|
16
|
+
message: string;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export declare class AjvValidationError extends Error {
|
|
20
|
+
errors: AjvErrorInfo[];
|
|
21
|
+
constructor(validationErrors: ErrorObject[]);
|
|
22
|
+
private parseAjvErrors;
|
|
23
|
+
getFriendlyMessage(): string;
|
|
24
|
+
}
|
|
25
|
+
|
|
13
26
|
/**
|
|
14
27
|
* Entrypoint class for sync configuration
|
|
15
28
|
*/
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { RequirementType, StatusOverride } from "./featureFlag";
|
|
2
|
+
export declare const MsFeatureFlagValueSchema: {
|
|
3
|
+
type: string;
|
|
4
|
+
properties: {
|
|
5
|
+
id: {
|
|
6
|
+
type: string;
|
|
7
|
+
};
|
|
8
|
+
description: {
|
|
9
|
+
type: string;
|
|
10
|
+
nullable: boolean;
|
|
11
|
+
};
|
|
12
|
+
enabled: {
|
|
13
|
+
type: string;
|
|
14
|
+
nullable: boolean;
|
|
15
|
+
};
|
|
16
|
+
conditions: {
|
|
17
|
+
type: string;
|
|
18
|
+
nullable: boolean;
|
|
19
|
+
properties: {
|
|
20
|
+
client_filters: {
|
|
21
|
+
type: string;
|
|
22
|
+
minItems: number;
|
|
23
|
+
nullable: boolean;
|
|
24
|
+
items: {
|
|
25
|
+
type: string;
|
|
26
|
+
properties: {
|
|
27
|
+
name: {
|
|
28
|
+
type: string;
|
|
29
|
+
};
|
|
30
|
+
parameters: {
|
|
31
|
+
type: string;
|
|
32
|
+
nullable: boolean;
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
required: string[];
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
requirement_type: {
|
|
39
|
+
type: string;
|
|
40
|
+
nullable: boolean;
|
|
41
|
+
enum: RequirementType[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
display_name: {
|
|
46
|
+
type: string;
|
|
47
|
+
nullable: boolean;
|
|
48
|
+
};
|
|
49
|
+
allocation: {
|
|
50
|
+
type: string;
|
|
51
|
+
nullable: boolean;
|
|
52
|
+
properties: {
|
|
53
|
+
user: {
|
|
54
|
+
type: string;
|
|
55
|
+
nullable: boolean;
|
|
56
|
+
items: {
|
|
57
|
+
type: string;
|
|
58
|
+
properties: {
|
|
59
|
+
variant: {
|
|
60
|
+
type: string;
|
|
61
|
+
};
|
|
62
|
+
users: {
|
|
63
|
+
type: string;
|
|
64
|
+
items: {
|
|
65
|
+
type: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
required: string[];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
group: {
|
|
73
|
+
type: string;
|
|
74
|
+
nullable: boolean;
|
|
75
|
+
items: {
|
|
76
|
+
type: string;
|
|
77
|
+
properties: {
|
|
78
|
+
variant: {
|
|
79
|
+
type: string;
|
|
80
|
+
};
|
|
81
|
+
groups: {
|
|
82
|
+
type: string;
|
|
83
|
+
items: {
|
|
84
|
+
type: string;
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
required: string[];
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
default_when_enabled: {
|
|
92
|
+
type: string;
|
|
93
|
+
nullable: boolean;
|
|
94
|
+
};
|
|
95
|
+
default_when_disabled: {
|
|
96
|
+
type: string;
|
|
97
|
+
nullable: boolean;
|
|
98
|
+
};
|
|
99
|
+
percentile: {
|
|
100
|
+
type: string;
|
|
101
|
+
nullable: boolean;
|
|
102
|
+
items: {
|
|
103
|
+
type: string;
|
|
104
|
+
properties: {
|
|
105
|
+
variant: {
|
|
106
|
+
type: string;
|
|
107
|
+
};
|
|
108
|
+
from: {
|
|
109
|
+
type: string;
|
|
110
|
+
minimum: number;
|
|
111
|
+
maximum: number;
|
|
112
|
+
};
|
|
113
|
+
to: {
|
|
114
|
+
type: string;
|
|
115
|
+
minimum: number;
|
|
116
|
+
maximum: number;
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
required: string[];
|
|
120
|
+
};
|
|
121
|
+
};
|
|
122
|
+
seed: {
|
|
123
|
+
type: string;
|
|
124
|
+
nullable: boolean;
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
};
|
|
128
|
+
variants: {
|
|
129
|
+
type: string;
|
|
130
|
+
nullable: boolean;
|
|
131
|
+
items: {
|
|
132
|
+
type: string;
|
|
133
|
+
properties: {
|
|
134
|
+
name: {
|
|
135
|
+
type: string;
|
|
136
|
+
};
|
|
137
|
+
configuration_value: any;
|
|
138
|
+
status_override: {
|
|
139
|
+
type: string;
|
|
140
|
+
nullable: boolean;
|
|
141
|
+
enum: StatusOverride[];
|
|
142
|
+
};
|
|
143
|
+
};
|
|
144
|
+
required: string[];
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
telemetry: {
|
|
148
|
+
type: string;
|
|
149
|
+
nullable: boolean;
|
|
150
|
+
properties: {
|
|
151
|
+
enabled: {
|
|
152
|
+
type: string;
|
|
153
|
+
nullable: boolean;
|
|
154
|
+
};
|
|
155
|
+
metadata: {
|
|
156
|
+
type: string;
|
|
157
|
+
nullable: boolean;
|
|
158
|
+
};
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
required: string[];
|
|
163
|
+
};
|
|
164
|
+
//# sourceMappingURL=MsFeatureFlagSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MsFeatureFlagSchema.d.ts","sourceRoot":"","sources":["../../src/MsFeatureFlagSchema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEhE,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAqHpC,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AppConfigurationClient } from "@azure/app-configuration";
|
|
2
|
+
import { ConfigurationSettingsSource } from "./settingsImport/configurationSettingsSource";
|
|
3
|
+
import { ImportMode } from "./enums";
|
|
4
|
+
import { ImportProgress } from "./models";
|
|
5
|
+
/**
|
|
6
|
+
* Entrypoint class for sync configuration
|
|
7
|
+
*/
|
|
8
|
+
export declare class AppConfigurationImporter {
|
|
9
|
+
private configurationClient;
|
|
10
|
+
/**
|
|
11
|
+
* Initializes a new instance of the AppConfigurationSync class.
|
|
12
|
+
* @param configurationClient - App configuration client for manipulate the target App Configuration.
|
|
13
|
+
*/
|
|
14
|
+
constructor(configurationClient: AppConfigurationClient);
|
|
15
|
+
/**
|
|
16
|
+
* Import source settings into the Azure App Configuration service
|
|
17
|
+
*
|
|
18
|
+
* Example usage:
|
|
19
|
+
* ```ts
|
|
20
|
+
* const fileData = fs.readFileSync("mylocalPath").toString();
|
|
21
|
+
* const result = await asyncClient.Import(new StringConfigurationSettingsSource({data:fileData, format: ConfigurationFormat.Json}));
|
|
22
|
+
* ```
|
|
23
|
+
* @param configSettingsSource - A ConfigurationSettingsSource instance.
|
|
24
|
+
* @param strict - Use strict mode or not.
|
|
25
|
+
* @param timeout - Seconds of entire import progress timeout
|
|
26
|
+
* @param progressCallback - Callback for report the progress of import
|
|
27
|
+
* @param importMode - Determines the behavior when importing key-values. The default value, 'All' will import all key-values in the input file to App Configuration. 'Ignore-Match' will only import settings that have no matching key-value in App Configuration.
|
|
28
|
+
* @param dryRun - When dry run is enabled, no updates will be performed to App Configuration. Instead, any updates that would have been performed in a normal run will be printed to the console for review
|
|
29
|
+
*/
|
|
30
|
+
Import(configSettingsSource: ConfigurationSettingsSource, timeout: number, strict?: boolean, progressCallback?: (progress: ImportProgress) => unknown, importMode?: ImportMode, dryRun?: boolean): Promise<void>;
|
|
31
|
+
private printUpdatesToConsole;
|
|
32
|
+
private applyUpdatesToServer;
|
|
33
|
+
private newAdaptiveTaskManager;
|
|
34
|
+
private executeTasksWithTimeout;
|
|
35
|
+
private validateImportMode;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=appConfigurationImporter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"appConfigurationImporter.d.ts","sourceRoot":"","sources":["../../src/appConfigurationImporter.ts"],"names":[],"mappings":"AAGA,OAAO,EACL,sBAAsB,EAIA,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAC3F,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAGrC,OAAO,EAAE,cAAc,EAAkB,MAAM,UAAU,CAAC;AAM1D;;GAEG;AACH,qBAAa,wBAAwB;IACnC,OAAO,CAAC,mBAAmB,CAAyB;IACpD;;;OAGG;gBACS,mBAAmB,EAAE,sBAAsB;IAIvD;;;;;;;;;;;;;;OAcG;IACU,MAAM,CACjB,oBAAoB,EAAE,2BAA2B,EACjD,OAAO,EAAE,MAAM,EACf,MAAM,UAAQ,EACd,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,KAAK,OAAO,EACxD,UAAU,CAAC,EAAE,UAAU,EACvB,MAAM,CAAC,EAAE,OAAO;IA4DlB,OAAO,CAAC,qBAAqB;YAiBf,oBAAoB;IAkBlC,OAAO,CAAC,sBAAsB;YAchB,uBAAuB;IAWrC,OAAO,CAAC,kBAAkB;CAM3B"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Enums of configuration Format.
|
|
3
|
+
*/
|
|
4
|
+
export declare enum ConfigurationFormat {
|
|
5
|
+
Json = 0,
|
|
6
|
+
Properties = 1,
|
|
7
|
+
Yaml = 2
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Enums of configuration Profile.
|
|
11
|
+
*/
|
|
12
|
+
export declare enum ConfigurationProfile {
|
|
13
|
+
Default = 0,
|
|
14
|
+
KvSet = 1
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Enums of import mode.
|
|
18
|
+
*/
|
|
19
|
+
export declare enum ImportMode {
|
|
20
|
+
All = 0,
|
|
21
|
+
IgnoreMatch = 1
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=enums.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enums.d.ts","sourceRoot":"","sources":["../../src/enums.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,oBAAY,mBAAmB;IAC7B,IAAI,IAAA;IACJ,UAAU,IAAA;IACV,IAAI,IAAA;CACL;AAED;;GAEG;AACH,oBAAY,oBAAoB;IAC9B,OAAO,IAAA;IACP,KAAK,IAAA;CACN;AAED;;GAEG;AACH,oBAAY,UAAU;IACpB,GAAG,IAAA;IACH,WAAW,IAAA;CACZ"}
|