@azure/app-configuration 1.9.1-alpha.20250619.1 → 1.9.1-alpha.20250730.1
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/dist/browser/appConfigCredential.js +1 -2
- package/dist/browser/appConfigCredential.js.map +1 -1
- package/dist/browser/appConfigurationClient.js +123 -41
- package/dist/browser/appConfigurationClient.js.map +1 -1
- package/dist/browser/featureFlag.js +13 -5
- package/dist/browser/featureFlag.js.map +1 -1
- package/dist/browser/generated/src/appConfiguration.js +21 -9
- package/dist/browser/generated/src/appConfiguration.js.map +1 -1
- package/dist/browser/generated/src/lroImpl.js +7 -3
- package/dist/browser/generated/src/lroImpl.js.map +1 -1
- package/dist/browser/internal/helpers.js +14 -5
- package/dist/browser/internal/helpers.js.map +1 -1
- package/dist/browser/internal/synctokenpolicy.js +1 -3
- package/dist/browser/internal/synctokenpolicy.js.map +1 -1
- package/dist/browser/secretReference.js +8 -2
- package/dist/browser/secretReference.js.map +1 -1
- package/dist/commonjs/appConfigCredential.js +1 -2
- package/dist/commonjs/appConfigCredential.js.map +1 -1
- package/dist/commonjs/appConfigurationClient.js +123 -41
- package/dist/commonjs/appConfigurationClient.js.map +1 -1
- package/dist/commonjs/featureFlag.js +13 -5
- package/dist/commonjs/featureFlag.js.map +1 -1
- package/dist/commonjs/generated/src/appConfiguration.js +21 -9
- package/dist/commonjs/generated/src/appConfiguration.js.map +1 -1
- package/dist/commonjs/generated/src/lroImpl.js +7 -3
- package/dist/commonjs/generated/src/lroImpl.js.map +1 -1
- package/dist/commonjs/internal/helpers.js +14 -5
- package/dist/commonjs/internal/helpers.js.map +1 -1
- package/dist/commonjs/internal/synctokenpolicy.js +1 -3
- package/dist/commonjs/internal/synctokenpolicy.js.map +1 -1
- package/dist/commonjs/secretReference.js +8 -2
- package/dist/commonjs/secretReference.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/esm/appConfigCredential.js +1 -2
- package/dist/esm/appConfigCredential.js.map +1 -1
- package/dist/esm/appConfigurationClient.js +123 -41
- package/dist/esm/appConfigurationClient.js.map +1 -1
- package/dist/esm/featureFlag.js +13 -5
- package/dist/esm/featureFlag.js.map +1 -1
- package/dist/esm/generated/src/appConfiguration.js +21 -9
- package/dist/esm/generated/src/appConfiguration.js.map +1 -1
- package/dist/esm/generated/src/lroImpl.js +7 -3
- package/dist/esm/generated/src/lroImpl.js.map +1 -1
- package/dist/esm/internal/helpers.js +14 -5
- package/dist/esm/internal/helpers.js.map +1 -1
- package/dist/esm/internal/synctokenpolicy.js +1 -3
- package/dist/esm/internal/synctokenpolicy.js.map +1 -1
- package/dist/esm/secretReference.js +8 -2
- package/dist/esm/secretReference.js.map +1 -1
- package/dist/react-native/appConfigCredential.js +1 -2
- package/dist/react-native/appConfigCredential.js.map +1 -1
- package/dist/react-native/appConfigurationClient.js +123 -41
- package/dist/react-native/appConfigurationClient.js.map +1 -1
- package/dist/react-native/featureFlag.js +13 -5
- package/dist/react-native/featureFlag.js.map +1 -1
- package/dist/react-native/generated/src/appConfiguration.js +21 -9
- package/dist/react-native/generated/src/appConfiguration.js.map +1 -1
- package/dist/react-native/generated/src/lroImpl.js +7 -3
- package/dist/react-native/generated/src/lroImpl.js.map +1 -1
- package/dist/react-native/internal/helpers.js +14 -5
- package/dist/react-native/internal/helpers.js.map +1 -1
- package/dist/react-native/internal/synctokenpolicy.js +1 -3
- package/dist/react-native/internal/synctokenpolicy.js.map +1 -1
- package/dist/react-native/secretReference.js +8 -2
- package/dist/react-native/secretReference.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"synctokenpolicy.js","sourceRoot":"","sources":["../../../src/internal/synctokenpolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GA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AAkB,CAAC,MAAM,EAAE,EAAE,CAAC;YACzD,gEAAgE;YAChE,mEAAmE;YACnE,gBAAgB,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC,EAAE,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC;QAC9D,CAAC;QAED,OAAO,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACpC,CAAC;CACF;AAED,oDAAoD;AACpD,EAAE;AACF,0BAA0B;AAC1B,EAAE;AACF,wBAAwB;AACxB,eAAe;AACf,kBAAkB;AAClB,sBAAsB;AACtB,MAAM,cAAc,GAAG,4BAA4B,CAAC;AAQpD;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,SAAiB;IAC9C,MAAM,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAEhD,IAAI,OAAO,IAAI,IAAI,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,+BAA+B,SAAS,gBAAgB,cAAc,CAAC,MAAM,EAAE,CAChF,CAAC;IACJ,CAAC;IAED,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEhD,IAAI,KAAK,CAAC,cAAc,CAAC,EAAE,CAAC;QAC1B,qEAAqE;QACrE,iDAAiD;QACjD,MAAM,IAAI,KAAK,CAAC,GAAG,SAAS,gCAAgC,OAAO,CAAC,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC7F,CAAC;IAED,OAAO;QACL,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;QACd,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC;QACjB,cAAc;KACf,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { logger } from \"../logger.js\";\n\n/**\n * The sync token header, as described here:\n * https://learn.microsoft.com/azure/azure-app-configuration/rest-api-consistency\n * @internal\n */\nexport const SyncTokenHeaderName = \"sync-token\";\n\n/**\n * A policy factory for injecting sync tokens properly into outgoing requests.\n * @param syncTokens - the sync tokens store to be used across requests.\n * @internal\n */\nexport function syncTokenPolicy(syncTokens: SyncTokens): PipelinePolicy {\n return {\n name: \"Sync Token Policy\",\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const syncTokenHeaderValue = syncTokens.getSyncTokenHeaderValue();\n\n if (syncTokenHeaderValue) {\n logger.info(\n \"[syncTokenPolicy] Setting headers with ${SyncTokenHeaderName} and ${syncTokenHeaderValue}\",\n );\n request.headers.set(SyncTokenHeaderName, syncTokenHeaderValue);\n }\n const response = await next(request);\n syncTokens.addSyncTokenFromHeaderValue(response.headers.get(SyncTokenHeaderName));\n return response;\n },\n };\n}\n\n/**\n * Sync token tracker (allows for real-time consistency, even in the face of\n * caching and load balancing within App Configuration).\n *\n * (protocol and format described here)\n * https://learn.microsoft.com/azure/azure-app-configuration/rest-api-consistency\n *\n * @internal\n */\nexport class SyncTokens {\n private _currentSyncTokens = new Map<string, SyncToken>();\n\n /**\n * Takes the value from the header named after the constant `SyncTokenHeaderName`\n * and adds it to our list of accumulated sync tokens.\n *\n * If given an empty value (or undefined) it clears the current list of sync tokens.\n * (indicates the service has properly absorbed values into the cluster).\n *\n * @param syncTokenHeaderValue - The full value of the sync token header.\n */\n addSyncTokenFromHeaderValue(syncTokenHeaderValue: string | undefined): void {\n if (syncTokenHeaderValue == null || syncTokenHeaderValue === \"\") {\n // eventually everything gets synced up and we don't have to track\n // these headers anymore\n this._currentSyncTokens.clear();\n return;\n }\n\n const newTokens = syncTokenHeaderValue.split(\",\").map(parseSyncToken);\n\n for (const newToken of newTokens) {\n const existingToken = this._currentSyncTokens.get(newToken.id);\n\n if (!existingToken || existingToken.sequenceNumber < newToken.sequenceNumber) {\n this._currentSyncTokens.set(newToken.id, newToken);\n continue;\n }\n }\n }\n\n /**\n * Gets a properly formatted SyncToken header value.\n */\n getSyncTokenHeaderValue(): string | undefined {\n if (this._currentSyncTokens.size === 0) {\n return undefined;\n }\n\n const syncTokenStrings = [];\n\n for (const syncToken of this._currentSyncTokens.values()) {\n // note that you don't include the 'sn' field here - that's only\n // used for internal tracking of the 'version' for the token itself\n syncTokenStrings.push(`${syncToken.id}=${syncToken.value}`);\n }\n\n return syncTokenStrings.join(\",\");\n }\n}\n\n// An example sync token (from their documentation):\n//\n// jtqGc1I4=MDoyOA==;sn=28\n//\n// Which breaks down to:\n// id: jtqGc1I4\n// value: MDoyOA==\n// sequence number: 28\nconst syncTokenRegex = /^([^=]+)=([^;]+);sn=(\\d+)$/;\n\ninterface SyncToken {\n id: string;\n value: string;\n sequenceNumber: number;\n}\n\n/**\n * Parses a single sync token into it's constituent parts.\n *\n * @param syncToken - A single sync token.\n *\n * @internal\n */\nexport function parseSyncToken(syncToken: string): SyncToken {\n const matches = syncToken.match(syncTokenRegex);\n\n if (matches == null) {\n throw new Error(\n `Failed to parse sync token '${syncToken}' with regex ${syncTokenRegex.source}`,\n );\n }\n\n const sequenceNumber = parseInt(matches[3], 10);\n\n if (isNaN(sequenceNumber)) {\n // this should be impossible since our regex restricts to just digits\n // but there's nothing wrong with being thorough.\n throw new Error(`${syncToken}: The sequence number value '${matches[3]}' wasn't a number`);\n }\n\n return {\n id: matches[1],\n value: matches[2],\n sequenceNumber,\n };\n}\n"]}
|
|
@@ -21,7 +21,10 @@ export const SecretReferenceHelper = {
|
|
|
21
21
|
const jsonSecretReferenceValue = {
|
|
22
22
|
uri: secretReference.value.secretId,
|
|
23
23
|
};
|
|
24
|
-
const configSetting =
|
|
24
|
+
const configSetting = {
|
|
25
|
+
...secretReference,
|
|
26
|
+
value: JSON.stringify(jsonSecretReferenceValue),
|
|
27
|
+
};
|
|
25
28
|
return configSetting;
|
|
26
29
|
},
|
|
27
30
|
};
|
|
@@ -35,7 +38,10 @@ export function parseSecretReference(setting) {
|
|
|
35
38
|
throw TypeError(`Setting with key ${setting.key} is not a valid SecretReference, make sure to have the correct content-type and a valid non-null value.`);
|
|
36
39
|
}
|
|
37
40
|
const jsonSecretReferenceValue = JSON.parse(setting.value);
|
|
38
|
-
const secretReference =
|
|
41
|
+
const secretReference = {
|
|
42
|
+
...setting,
|
|
43
|
+
value: { secretId: jsonSecretReferenceValue.uri },
|
|
44
|
+
};
|
|
39
45
|
return secretReference;
|
|
40
46
|
}
|
|
41
47
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"secretReference.js","sourceRoot":"","sources":["../../src/secretReference.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC,oEAAoE,CAAC;AAYvE;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG;IACnC;;OAEG;IACH,2BAA2B,EAAE,CAC3B,eAAgE,EACrC,EAAE;QAC7B,MAAM,CAAC,IAAI,CAAC,2DAA2D,EAAE,eAAe,CAAC,CAAC;QAC1F,IAAI,CAAC,eAAe,CAAC,KAAK,EAAE,CAAC;YAC3B,MAAM,CAAC,KAAK,CAAC,yCAAyC,EAAE,eAAe,CAAC,CAAC;YACzE,MAAM,IAAI,SAAS,CAAC,6CAA6C,eAAe,CAAC,KAAK,EAAE,CAAC,CAAC;QAC5F,CAAC;QAED,MAAM,wBAAwB,GAA6B;YACzD,GAAG,EAAE,eAAe,CAAC,KAAK,CAAC,QAAQ;SACpC,CAAC;QAEF,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"secretReference.js","sourceRoot":"","sources":["../../src/secretReference.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,0BAA0B,GACrC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AA6B;IAE7B,OAAO,CACL,OAAO;QACP,OAAO,CAAC,WAAW,KAAK,0BAA0B;QAClD,OAAO,OAAO,CAAC,KAAK,KAAK,QAAQ,CAClC,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ConfigurationSetting, ConfigurationSettingParam } from \"./models.js\";\nimport type { JsonSecretReferenceValue } from \"./internal/jsonModels.js\";\nimport { logger } from \"./logger.js\";\n\n/**\n * content-type for the secret reference.\n */\nexport const secretReferenceContentType =\n \"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8\";\n\n/**\n * Necessary fields for updating or creating a new secret reference.\n */\nexport interface SecretReferenceValue {\n /**\n * Id for the secret reference.\n */\n secretId: string;\n}\n\n/**\n * @internal\n */\nexport const SecretReferenceHelper = {\n /**\n * Takes the SecretReference (JSON) and returns a ConfigurationSetting (with the props encodeed in the value).\n */\n toConfigurationSettingParam: (\n secretReference: ConfigurationSettingParam<SecretReferenceValue>,\n ): ConfigurationSettingParam => {\n logger.info(\"Encoding SecretReference value in a ConfigurationSetting:\", secretReference);\n if (!secretReference.value) {\n logger.error(`SecretReference has an unexpected value`, secretReference);\n throw new TypeError(`SecretReference has an unexpected value - ${secretReference.value}`);\n }\n\n const jsonSecretReferenceValue: JsonSecretReferenceValue = {\n uri: secretReference.value.secretId,\n };\n\n const configSetting = {\n ...secretReference,\n value: JSON.stringify(jsonSecretReferenceValue),\n };\n return configSetting;\n },\n};\n\n/**\n * Takes the ConfigurationSetting as input and returns the ConfigurationSetting<SecretReferenceValue> by parsing the value string.\n */\nexport function parseSecretReference(\n setting: ConfigurationSetting,\n): ConfigurationSetting<SecretReferenceValue> {\n logger.info(\n \"[parseSecretReference] Parsing the value to return the SecretReferenceValue\",\n setting,\n );\n if (!isSecretReference(setting)) {\n logger.error(\"Invalid SecretReference input\", setting);\n throw TypeError(\n `Setting with key ${setting.key} is not a valid SecretReference, make sure to have the correct content-type and a valid non-null value.`,\n );\n }\n\n const jsonSecretReferenceValue = JSON.parse(setting.value) as JsonSecretReferenceValue;\n\n const secretReference: ConfigurationSetting<SecretReferenceValue> = {\n ...setting,\n value: { secretId: jsonSecretReferenceValue.uri },\n };\n return secretReference;\n}\n\n/**\n * Lets you know if the ConfigurationSetting is a secret reference.\n *\n * [Checks if the content type is secretReferenceContentType `\"application/vnd.microsoft.appconfig.keyvaultref+json;charset=utf-8\"`]\n */\nexport function isSecretReference(\n setting: ConfigurationSetting,\n): setting is ConfigurationSetting & Required<Pick<ConfigurationSetting, \"value\">> {\n return (\n setting &&\n setting.contentType === secretReferenceContentType &&\n typeof setting.value === \"string\"\n );\n}\n"]}
|
|
@@ -13,11 +13,10 @@ function appConfigKeyCredentialPolicy(credential, secret) {
|
|
|
13
13
|
return {
|
|
14
14
|
name: "AppConfigKeyCredentialPolicy",
|
|
15
15
|
async sendRequest(request, next) {
|
|
16
|
-
var _a;
|
|
17
16
|
const verb = request.method;
|
|
18
17
|
const utcNow = new Date().toUTCString();
|
|
19
18
|
logger_js_1.logger.info("[appConfigKeyCredentialPolicy] Computing SHA-256 from the request body");
|
|
20
|
-
const contentHash = await (0, core_util_1.computeSha256Hash)(
|
|
19
|
+
const contentHash = await (0, core_util_1.computeSha256Hash)(request.body?.toString() || "", "base64");
|
|
21
20
|
const signedHeaders = "x-ms-date;host;x-ms-content-sha256";
|
|
22
21
|
const url = new URL(request.url);
|
|
23
22
|
const query = url.search;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appConfigCredential.js","sourceRoot":"","sources":["../../src/appConfigCredential.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAelC,oEA4BC;AAnCD,gDAAwE;AACxE,2CAAqC;AAErC;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,UAAkB,EAAE,MAAc;IAC7E,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB
|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O,CAAC,OAAO,CAAC,GAAG,CAAC,qBAAqB,EAAE,WAAW,CAAC,CAAC;YACxD,kCAAkC;YAClC,4GAA4G;YAC5G,OAAO,CAAC,OAAO,CAAC,GAAG,CACjB,eAAe,EACf,0BAA0B,UAAU,kBAAkB,aAAa,cAAc,SAAS,EAAE,CAC7F,CAAC;YAEF,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelinePolicy,\n PipelineRequest,\n PipelineResponse,\n SendRequest,\n} from \"@azure/core-rest-pipeline\";\nimport { computeSha256Hash, computeSha256Hmac } from \"@azure/core-util\";\nimport { logger } from \"./logger.js\";\n\n/**\n * Create an HTTP pipeline policy to authenticate a request\n * using an `AzureKeyCredential` for AppConfig.\n */\nexport function appConfigKeyCredentialPolicy(credential: string, secret: string): PipelinePolicy {\n return {\n name: \"AppConfigKeyCredentialPolicy\",\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const verb = request.method;\n const utcNow = new Date().toUTCString();\n logger.info(\"[appConfigKeyCredentialPolicy] Computing SHA-256 from the request body\");\n const contentHash = await computeSha256Hash(request.body?.toString() || \"\", \"base64\");\n const signedHeaders = \"x-ms-date;host;x-ms-content-sha256\";\n const url = new URL(request.url);\n const query = url.search;\n const urlPathAndQuery = query ? `${url.pathname}${query}` : url.pathname;\n const stringToSign = `${verb}\\n${urlPathAndQuery}\\n${utcNow};${url.host};${contentHash}`;\n logger.info(\"[appConfigKeyCredentialPolicy] Computing a SHA-256 Hmac signature\");\n const signature = await computeSha256Hmac(secret, stringToSign, \"base64\");\n\n request.headers.set(\"x-ms-date\", utcNow);\n request.headers.set(\"x-ms-content-sha256\", contentHash);\n // Syntax for Authorization header\n // Reference - https://learn.microsoft.com/azure/azure-app-configuration/rest-api-authentication-hmac#syntax\n request.headers.set(\n \"Authorization\",\n `HMAC-SHA256 Credential=${credential}&SignedHeaders=${signedHeaders}&Signature=${signature}`,\n );\n\n return next(request);\n },\n };\n}\n"]}
|
|
@@ -31,8 +31,9 @@ const deserializationContentTypes = {
|
|
|
31
31
|
* Client for the Azure App Configuration service.
|
|
32
32
|
*/
|
|
33
33
|
class AppConfigurationClient {
|
|
34
|
+
client;
|
|
35
|
+
_syncTokens;
|
|
34
36
|
constructor(connectionStringOrEndpoint, tokenCredentialOrOptions, options) {
|
|
35
|
-
var _a;
|
|
36
37
|
let appConfigOptions = {};
|
|
37
38
|
let appConfigCredential;
|
|
38
39
|
let appConfigEndpoint;
|
|
@@ -52,7 +53,7 @@ class AppConfigurationClient {
|
|
|
52
53
|
}
|
|
53
54
|
else {
|
|
54
55
|
appConfigOptions = tokenCredentialOrOptions || {};
|
|
55
|
-
const regexMatch = connectionStringOrEndpoint
|
|
56
|
+
const regexMatch = connectionStringOrEndpoint?.match(ConnectionStringRegex);
|
|
56
57
|
if (regexMatch) {
|
|
57
58
|
appConfigEndpoint = regexMatch[1];
|
|
58
59
|
authPolicy = (0, appConfigCredential_js_1.appConfigKeyCredentialPolicy)(regexMatch[2], regexMatch[3]);
|
|
@@ -62,13 +63,17 @@ class AppConfigurationClient {
|
|
|
62
63
|
` To mitigate the issue, please refer to the troubleshooting guide here at https://aka.ms/azsdk/js/app-configuration/troubleshoot.`);
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
|
-
const internalClientPipelineOptions =
|
|
66
|
+
const internalClientPipelineOptions = {
|
|
67
|
+
...appConfigOptions,
|
|
68
|
+
loggingOptions: {
|
|
66
69
|
logger: logger_js_1.logger.info,
|
|
67
|
-
},
|
|
70
|
+
},
|
|
71
|
+
deserializationOptions: {
|
|
68
72
|
expectedContentTypes: deserializationContentTypes,
|
|
69
|
-
}
|
|
73
|
+
},
|
|
74
|
+
};
|
|
70
75
|
this._syncTokens = appConfigOptions.syncTokens || new synctokenpolicy_js_1.SyncTokens();
|
|
71
|
-
this.client = new appConfiguration_js_1.AppConfiguration(appConfigEndpoint,
|
|
76
|
+
this.client = new appConfiguration_js_1.AppConfiguration(appConfigEndpoint, options?.apiVersion ?? constants_js_1.appConfigurationApiVersion, internalClientPipelineOptions);
|
|
72
77
|
this.client.pipeline.addPolicy(authPolicy, { phase: "Sign" });
|
|
73
78
|
this.client.pipeline.addPolicy((0, synctokenpolicy_js_1.syncTokenPolicy)(this._syncTokens), { afterPhase: "Retry" });
|
|
74
79
|
}
|
|
@@ -100,7 +105,12 @@ class AppConfigurationClient {
|
|
|
100
105
|
const keyValue = (0, helpers_js_1.serializeAsConfigurationSettingParam)(configurationSetting);
|
|
101
106
|
logger_js_1.logger.info("[addConfigurationSetting] Creating a key value pair");
|
|
102
107
|
try {
|
|
103
|
-
const originalResponse = await this.client.putKeyValue(configurationSetting.key,
|
|
108
|
+
const originalResponse = await this.client.putKeyValue(configurationSetting.key, {
|
|
109
|
+
ifNoneMatch: "*",
|
|
110
|
+
label: configurationSetting.label,
|
|
111
|
+
entity: keyValue,
|
|
112
|
+
...updatedOptions,
|
|
113
|
+
});
|
|
104
114
|
const response = (0, helpers_js_1.transformKeyValueResponse)(originalResponse);
|
|
105
115
|
(0, helpers_js_1.assertResponse)(response);
|
|
106
116
|
return response;
|
|
@@ -141,9 +151,14 @@ class AppConfigurationClient {
|
|
|
141
151
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.deleteConfigurationSetting", options, async (updatedOptions) => {
|
|
142
152
|
let status;
|
|
143
153
|
logger_js_1.logger.info("[deleteConfigurationSetting] Deleting key value pair");
|
|
144
|
-
const originalResponse = await this.client.deleteKeyValue(id.key,
|
|
154
|
+
const originalResponse = await this.client.deleteKeyValue(id.key, {
|
|
155
|
+
label: id.label,
|
|
156
|
+
...updatedOptions,
|
|
157
|
+
...(0, helpers_js_1.checkAndFormatIfAndIfNoneMatch)(id, options),
|
|
158
|
+
onResponse: (response) => {
|
|
145
159
|
status = response.status;
|
|
146
|
-
}
|
|
160
|
+
},
|
|
161
|
+
});
|
|
147
162
|
const response = (0, helpers_js_1.transformKeyValueResponseWithStatusCode)(originalResponse, status);
|
|
148
163
|
(0, helpers_js_1.assertResponse)(response);
|
|
149
164
|
return response;
|
|
@@ -171,9 +186,16 @@ class AppConfigurationClient {
|
|
|
171
186
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.getConfigurationSetting", options, async (updatedOptions) => {
|
|
172
187
|
let status;
|
|
173
188
|
logger_js_1.logger.info("[getConfigurationSetting] Getting key value pair");
|
|
174
|
-
const originalResponse = await this.client.getKeyValue(id.key,
|
|
189
|
+
const originalResponse = await this.client.getKeyValue(id.key, {
|
|
190
|
+
...updatedOptions,
|
|
191
|
+
label: id.label,
|
|
192
|
+
select: (0, helpers_js_1.formatFieldsForSelect)(options.fields),
|
|
193
|
+
...(0, helpers_js_1.formatAcceptDateTime)(options),
|
|
194
|
+
...(0, helpers_js_1.checkAndFormatIfAndIfNoneMatch)(id, options),
|
|
195
|
+
onResponse: (response) => {
|
|
175
196
|
status = response.status;
|
|
176
|
-
}
|
|
197
|
+
},
|
|
198
|
+
});
|
|
177
199
|
const response = (0, helpers_js_1.transformKeyValueResponseWithStatusCode)(originalResponse, status);
|
|
178
200
|
// 304 only comes back if the user has passed a conditional option in their
|
|
179
201
|
// request _and_ the remote object has the same etag as what the user passed.
|
|
@@ -212,13 +234,17 @@ class AppConfigurationClient {
|
|
|
212
234
|
const pagedResult = {
|
|
213
235
|
firstPageLink: undefined,
|
|
214
236
|
getPage: async (pageLink) => {
|
|
215
|
-
|
|
216
|
-
const etag = pageEtags === null || pageEtags === void 0 ? void 0 : pageEtags.shift();
|
|
237
|
+
const etag = pageEtags?.shift();
|
|
217
238
|
try {
|
|
218
|
-
const response = await this.sendConfigurationSettingsRequest(
|
|
219
|
-
const currentResponse =
|
|
239
|
+
const response = await this.sendConfigurationSettingsRequest({ ...options, etag }, pageLink);
|
|
240
|
+
const currentResponse = {
|
|
241
|
+
...response,
|
|
242
|
+
items: response.items != null ? response.items?.map(helpers_js_1.transformKeyValue) : [],
|
|
243
|
+
continuationToken: response.nextLink
|
|
220
244
|
? (0, helpers_js_1.extractAfterTokenFromNextLink)(response.nextLink)
|
|
221
|
-
: undefined,
|
|
245
|
+
: undefined,
|
|
246
|
+
_response: response._response,
|
|
247
|
+
};
|
|
222
248
|
return {
|
|
223
249
|
page: currentResponse,
|
|
224
250
|
nextPageLink: currentResponse.continuationToken,
|
|
@@ -226,7 +252,7 @@ class AppConfigurationClient {
|
|
|
226
252
|
}
|
|
227
253
|
catch (error) {
|
|
228
254
|
const err = error;
|
|
229
|
-
const link =
|
|
255
|
+
const link = err.response?.headers?.get("link");
|
|
230
256
|
const continuationToken = link ? (0, helpers_js_1.extractAfterTokenFromLinkHeader)(link) : undefined;
|
|
231
257
|
if (err.statusCode === 304) {
|
|
232
258
|
err.message = `Status 304: No updates for this page`;
|
|
@@ -235,7 +261,7 @@ class AppConfigurationClient {
|
|
|
235
261
|
page: {
|
|
236
262
|
items: [],
|
|
237
263
|
etag,
|
|
238
|
-
_response:
|
|
264
|
+
_response: { ...err.response, status: 304 },
|
|
239
265
|
},
|
|
240
266
|
nextPageLink: continuationToken,
|
|
241
267
|
};
|
|
@@ -271,11 +297,14 @@ class AppConfigurationClient {
|
|
|
271
297
|
const pagedResult = {
|
|
272
298
|
firstPageLink: undefined,
|
|
273
299
|
getPage: async (pageLink) => {
|
|
274
|
-
|
|
275
|
-
const
|
|
276
|
-
|
|
300
|
+
const response = await this.sendConfigurationSettingsRequest({ snapshotName, ...options }, pageLink);
|
|
301
|
+
const currentResponse = {
|
|
302
|
+
...response,
|
|
303
|
+
items: response.items != null ? response.items?.map(helpers_js_1.transformKeyValue) : [],
|
|
304
|
+
continuationToken: response.nextLink
|
|
277
305
|
? (0, helpers_js_1.extractAfterTokenFromNextLink)(response.nextLink)
|
|
278
|
-
: undefined
|
|
306
|
+
: undefined,
|
|
307
|
+
};
|
|
279
308
|
return {
|
|
280
309
|
page: currentResponse,
|
|
281
310
|
nextPageLink: currentResponse.continuationToken,
|
|
@@ -306,11 +335,15 @@ class AppConfigurationClient {
|
|
|
306
335
|
const pagedResult = {
|
|
307
336
|
firstPageLink: undefined,
|
|
308
337
|
getPage: async (pageLink) => {
|
|
309
|
-
var _a;
|
|
310
338
|
const response = await this.sendLabelsRequest(options, pageLink);
|
|
311
|
-
const currentResponse =
|
|
339
|
+
const currentResponse = {
|
|
340
|
+
...response,
|
|
341
|
+
items: response.items ?? [],
|
|
342
|
+
continuationToken: response.nextLink
|
|
312
343
|
? (0, helpers_js_1.extractAfterTokenFromNextLink)(response.nextLink)
|
|
313
|
-
: undefined,
|
|
344
|
+
: undefined,
|
|
345
|
+
_response: response._response,
|
|
346
|
+
};
|
|
314
347
|
return {
|
|
315
348
|
page: currentResponse,
|
|
316
349
|
nextPageLink: currentResponse.continuationToken,
|
|
@@ -322,13 +355,24 @@ class AppConfigurationClient {
|
|
|
322
355
|
}
|
|
323
356
|
async sendLabelsRequest(options = {}, pageLink) {
|
|
324
357
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.listConfigurationSettings", options, async (updatedOptions) => {
|
|
325
|
-
const response = await this.client.getLabels(
|
|
358
|
+
const response = await this.client.getLabels({
|
|
359
|
+
...updatedOptions,
|
|
360
|
+
...(0, helpers_js_1.formatAcceptDateTime)(options),
|
|
361
|
+
...(0, helpers_js_1.formatLabelsFiltersAndSelect)(options),
|
|
362
|
+
after: pageLink,
|
|
363
|
+
});
|
|
326
364
|
return response;
|
|
327
365
|
});
|
|
328
366
|
}
|
|
329
367
|
async sendConfigurationSettingsRequest(options = {}, pageLink) {
|
|
330
368
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.listConfigurationSettings", options, async (updatedOptions) => {
|
|
331
|
-
const response = await this.client.getKeyValues(
|
|
369
|
+
const response = await this.client.getKeyValues({
|
|
370
|
+
...updatedOptions,
|
|
371
|
+
...(0, helpers_js_1.formatAcceptDateTime)(options),
|
|
372
|
+
...(0, helpers_js_1.formatConfigurationSettingsFiltersAndSelect)(options),
|
|
373
|
+
...(0, helpers_js_1.checkAndFormatIfAndIfNoneMatch)({ etag: options.etag }, { onlyIfChanged: true }),
|
|
374
|
+
after: pageLink,
|
|
375
|
+
});
|
|
332
376
|
return response;
|
|
333
377
|
});
|
|
334
378
|
}
|
|
@@ -355,9 +399,13 @@ class AppConfigurationClient {
|
|
|
355
399
|
firstPageLink: undefined,
|
|
356
400
|
getPage: async (pageLink) => {
|
|
357
401
|
const response = await this.sendRevisionsRequest(options, pageLink);
|
|
358
|
-
const currentResponse =
|
|
402
|
+
const currentResponse = {
|
|
403
|
+
...response,
|
|
404
|
+
items: response.items != null ? response.items.map(helpers_js_1.transformKeyValue) : [],
|
|
405
|
+
continuationToken: response.nextLink
|
|
359
406
|
? (0, helpers_js_1.extractAfterTokenFromNextLink)(response.nextLink)
|
|
360
|
-
: undefined
|
|
407
|
+
: undefined,
|
|
408
|
+
};
|
|
361
409
|
// let itemList = currentResponse.items;
|
|
362
410
|
return {
|
|
363
411
|
page: currentResponse,
|
|
@@ -370,7 +418,12 @@ class AppConfigurationClient {
|
|
|
370
418
|
}
|
|
371
419
|
async sendRevisionsRequest(options = {}, pageLink) {
|
|
372
420
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.listRevisions", options, async (updatedOptions) => {
|
|
373
|
-
const response = await this.client.getRevisions(
|
|
421
|
+
const response = await this.client.getRevisions({
|
|
422
|
+
...updatedOptions,
|
|
423
|
+
...(0, helpers_js_1.formatAcceptDateTime)(options),
|
|
424
|
+
...(0, helpers_js_1.formatFiltersAndSelect)(updatedOptions),
|
|
425
|
+
after: pageLink,
|
|
426
|
+
});
|
|
374
427
|
return response;
|
|
375
428
|
});
|
|
376
429
|
}
|
|
@@ -397,7 +450,12 @@ class AppConfigurationClient {
|
|
|
397
450
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.setConfigurationSetting", options, async (updatedOptions) => {
|
|
398
451
|
const keyValue = (0, helpers_js_1.serializeAsConfigurationSettingParam)(configurationSetting);
|
|
399
452
|
logger_js_1.logger.info("[setConfigurationSetting] Setting new key value");
|
|
400
|
-
const response = (0, helpers_js_1.transformKeyValueResponse)(await this.client.putKeyValue(configurationSetting.key,
|
|
453
|
+
const response = (0, helpers_js_1.transformKeyValueResponse)(await this.client.putKeyValue(configurationSetting.key, {
|
|
454
|
+
...updatedOptions,
|
|
455
|
+
label: configurationSetting.label,
|
|
456
|
+
entity: keyValue,
|
|
457
|
+
...(0, helpers_js_1.checkAndFormatIfAndIfNoneMatch)(configurationSetting, options),
|
|
458
|
+
}));
|
|
401
459
|
(0, helpers_js_1.assertResponse)(response);
|
|
402
460
|
return response;
|
|
403
461
|
});
|
|
@@ -411,11 +469,19 @@ class AppConfigurationClient {
|
|
|
411
469
|
let response;
|
|
412
470
|
if (readOnly) {
|
|
413
471
|
logger_js_1.logger.info("[setReadOnly] Setting read-only status to ${readOnly}");
|
|
414
|
-
response = await this.client.putLock(id.key,
|
|
472
|
+
response = await this.client.putLock(id.key, {
|
|
473
|
+
...newOptions,
|
|
474
|
+
label: id.label,
|
|
475
|
+
...(0, helpers_js_1.checkAndFormatIfAndIfNoneMatch)(id, options),
|
|
476
|
+
});
|
|
415
477
|
}
|
|
416
478
|
else {
|
|
417
479
|
logger_js_1.logger.info("[setReadOnly] Deleting read-only lock");
|
|
418
|
-
response = await this.client.deleteLock(id.key,
|
|
480
|
+
response = await this.client.deleteLock(id.key, {
|
|
481
|
+
...newOptions,
|
|
482
|
+
label: id.label,
|
|
483
|
+
...(0, helpers_js_1.checkAndFormatIfAndIfNoneMatch)(id, options),
|
|
484
|
+
});
|
|
419
485
|
}
|
|
420
486
|
response = (0, helpers_js_1.transformKeyValueResponse)(response);
|
|
421
487
|
(0, helpers_js_1.assertResponse)(response);
|
|
@@ -437,7 +503,7 @@ class AppConfigurationClient {
|
|
|
437
503
|
beginCreateSnapshot(snapshot,
|
|
438
504
|
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
439
505
|
options = {}) {
|
|
440
|
-
return tracing_js_1.tracingClient.withSpan(`${AppConfigurationClient.name}.beginCreateSnapshot`, options, (updatedOptions) => this.client.beginCreateSnapshot(snapshot.name, snapshot,
|
|
506
|
+
return tracing_js_1.tracingClient.withSpan(`${AppConfigurationClient.name}.beginCreateSnapshot`, options, (updatedOptions) => this.client.beginCreateSnapshot(snapshot.name, snapshot, { ...updatedOptions }));
|
|
441
507
|
}
|
|
442
508
|
/**
|
|
443
509
|
* Begins creating a snapshot for Azure App Configuration service, waits until it is done,
|
|
@@ -446,7 +512,7 @@ class AppConfigurationClient {
|
|
|
446
512
|
beginCreateSnapshotAndWait(snapshot,
|
|
447
513
|
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
448
514
|
options = {}) {
|
|
449
|
-
return tracing_js_1.tracingClient.withSpan(`${AppConfigurationClient.name}.beginCreateSnapshotAndWait`, options, (updatedOptions) => this.client.beginCreateSnapshotAndWait(snapshot.name, snapshot,
|
|
515
|
+
return tracing_js_1.tracingClient.withSpan(`${AppConfigurationClient.name}.beginCreateSnapshotAndWait`, options, (updatedOptions) => this.client.beginCreateSnapshotAndWait(snapshot.name, snapshot, { ...updatedOptions }));
|
|
450
516
|
}
|
|
451
517
|
/**
|
|
452
518
|
* Get a snapshot from Azure App Configuration service
|
|
@@ -470,7 +536,9 @@ class AppConfigurationClient {
|
|
|
470
536
|
getSnapshot(name, options = {}) {
|
|
471
537
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.getSnapshot", options, async (updatedOptions) => {
|
|
472
538
|
logger_js_1.logger.info("[getSnapshot] Get a snapshot");
|
|
473
|
-
const originalResponse = await this.client.getSnapshot(name,
|
|
539
|
+
const originalResponse = await this.client.getSnapshot(name, {
|
|
540
|
+
...updatedOptions,
|
|
541
|
+
});
|
|
474
542
|
const response = (0, helpers_js_1.transformSnapshotResponse)(originalResponse);
|
|
475
543
|
(0, helpers_js_1.assertResponse)(response);
|
|
476
544
|
return response;
|
|
@@ -499,7 +567,10 @@ class AppConfigurationClient {
|
|
|
499
567
|
options = {}) {
|
|
500
568
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.recoverSnapshot", options, async (updatedOptions) => {
|
|
501
569
|
logger_js_1.logger.info("[recoverSnapshot] Recover a snapshot");
|
|
502
|
-
const originalResponse = await this.client.updateSnapshot(name, { status: "ready" },
|
|
570
|
+
const originalResponse = await this.client.updateSnapshot(name, { status: "ready" }, {
|
|
571
|
+
...updatedOptions,
|
|
572
|
+
...(0, helpers_js_1.checkAndFormatIfAndIfNoneMatch)({ etag: options.etag }, { onlyIfUnchanged: true, ...options }),
|
|
573
|
+
});
|
|
503
574
|
const response = (0, helpers_js_1.transformSnapshotResponse)(originalResponse);
|
|
504
575
|
(0, helpers_js_1.assertResponse)(response);
|
|
505
576
|
return response;
|
|
@@ -528,7 +599,10 @@ class AppConfigurationClient {
|
|
|
528
599
|
options = {}) {
|
|
529
600
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.archiveSnapshot", options, async (updatedOptions) => {
|
|
530
601
|
logger_js_1.logger.info("[archiveSnapshot] Archive a snapshot");
|
|
531
|
-
const originalResponse = await this.client.updateSnapshot(name, { status: "archived" },
|
|
602
|
+
const originalResponse = await this.client.updateSnapshot(name, { status: "archived" }, {
|
|
603
|
+
...updatedOptions,
|
|
604
|
+
...(0, helpers_js_1.checkAndFormatIfAndIfNoneMatch)({ etag: options.etag }, { onlyIfUnchanged: true, ...options }),
|
|
605
|
+
});
|
|
532
606
|
const response = (0, helpers_js_1.transformSnapshotResponse)(originalResponse);
|
|
533
607
|
(0, helpers_js_1.assertResponse)(response);
|
|
534
608
|
return response;
|
|
@@ -560,9 +634,13 @@ class AppConfigurationClient {
|
|
|
560
634
|
firstPageLink: undefined,
|
|
561
635
|
getPage: async (pageLink) => {
|
|
562
636
|
const response = await this.sendSnapShotsRequest(options, pageLink);
|
|
563
|
-
const currentResponse =
|
|
637
|
+
const currentResponse = {
|
|
638
|
+
...response,
|
|
639
|
+
items: response.items != null ? response.items : [],
|
|
640
|
+
continuationToken: response.nextLink
|
|
564
641
|
? (0, helpers_js_1.extractAfterTokenFromNextLink)(response.nextLink)
|
|
565
|
-
: undefined
|
|
642
|
+
: undefined,
|
|
643
|
+
};
|
|
566
644
|
return {
|
|
567
645
|
page: currentResponse,
|
|
568
646
|
nextPageLink: currentResponse.continuationToken,
|
|
@@ -574,7 +652,11 @@ class AppConfigurationClient {
|
|
|
574
652
|
}
|
|
575
653
|
async sendSnapShotsRequest(options = {}, pageLink) {
|
|
576
654
|
return tracing_js_1.tracingClient.withSpan("AppConfigurationClient.listSnapshots", options, async (updatedOptions) => {
|
|
577
|
-
const response = await this.client.getSnapshots(
|
|
655
|
+
const response = await this.client.getSnapshots({
|
|
656
|
+
...updatedOptions,
|
|
657
|
+
...(0, helpers_js_1.formatSnapshotFiltersAndSelect)(options),
|
|
658
|
+
after: pageLink,
|
|
659
|
+
});
|
|
578
660
|
return response;
|
|
579
661
|
});
|
|
580
662
|
}
|