@azure/app-configuration 1.9.1-alpha.20250619.1 → 1.9.1-alpha.20250722.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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"]}
|
|
@@ -10,11 +10,10 @@ export function appConfigKeyCredentialPolicy(credential, secret) {
|
|
|
10
10
|
return {
|
|
11
11
|
name: "AppConfigKeyCredentialPolicy",
|
|
12
12
|
async sendRequest(request, next) {
|
|
13
|
-
var _a;
|
|
14
13
|
const verb = request.method;
|
|
15
14
|
const utcNow = new Date().toUTCString();
|
|
16
15
|
logger.info("[appConfigKeyCredentialPolicy] Computing SHA-256 from the request body");
|
|
17
|
-
const contentHash = await computeSha256Hash(
|
|
16
|
+
const contentHash = await computeSha256Hash(request.body?.toString() || "", "base64");
|
|
18
17
|
const signedHeaders = "x-ms-date;host;x-ms-content-sha256";
|
|
19
18
|
const url = new URL(request.url);
|
|
20
19
|
const query = url.search;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"appConfigCredential.js","sourceRoot":"","sources":["../../src/appConfigCredential.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,UAAkB,EAAE,MAAc;IAC7E,OAAO;QACL,IAAI,EAAE,8BAA8B;QACpC,K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AE,QAAQ,CAAC,CAAC;YAE1E,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC,CAAC;YACzC,OAAO,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"]}
|
|
@@ -28,8 +28,9 @@ const deserializationContentTypes = {
|
|
|
28
28
|
* Client for the Azure App Configuration service.
|
|
29
29
|
*/
|
|
30
30
|
export class AppConfigurationClient {
|
|
31
|
+
client;
|
|
32
|
+
_syncTokens;
|
|
31
33
|
constructor(connectionStringOrEndpoint, tokenCredentialOrOptions, options) {
|
|
32
|
-
var _a;
|
|
33
34
|
let appConfigOptions = {};
|
|
34
35
|
let appConfigCredential;
|
|
35
36
|
let appConfigEndpoint;
|
|
@@ -49,7 +50,7 @@ export class AppConfigurationClient {
|
|
|
49
50
|
}
|
|
50
51
|
else {
|
|
51
52
|
appConfigOptions = tokenCredentialOrOptions || {};
|
|
52
|
-
const regexMatch = connectionStringOrEndpoint
|
|
53
|
+
const regexMatch = connectionStringOrEndpoint?.match(ConnectionStringRegex);
|
|
53
54
|
if (regexMatch) {
|
|
54
55
|
appConfigEndpoint = regexMatch[1];
|
|
55
56
|
authPolicy = appConfigKeyCredentialPolicy(regexMatch[2], regexMatch[3]);
|
|
@@ -59,13 +60,17 @@ export class AppConfigurationClient {
|
|
|
59
60
|
` To mitigate the issue, please refer to the troubleshooting guide here at https://aka.ms/azsdk/js/app-configuration/troubleshoot.`);
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
const internalClientPipelineOptions =
|
|
63
|
+
const internalClientPipelineOptions = {
|
|
64
|
+
...appConfigOptions,
|
|
65
|
+
loggingOptions: {
|
|
63
66
|
logger: logger.info,
|
|
64
|
-
},
|
|
67
|
+
},
|
|
68
|
+
deserializationOptions: {
|
|
65
69
|
expectedContentTypes: deserializationContentTypes,
|
|
66
|
-
}
|
|
70
|
+
},
|
|
71
|
+
};
|
|
67
72
|
this._syncTokens = appConfigOptions.syncTokens || new SyncTokens();
|
|
68
|
-
this.client = new AppConfiguration(appConfigEndpoint,
|
|
73
|
+
this.client = new AppConfiguration(appConfigEndpoint, options?.apiVersion ?? appConfigurationApiVersion, internalClientPipelineOptions);
|
|
69
74
|
this.client.pipeline.addPolicy(authPolicy, { phase: "Sign" });
|
|
70
75
|
this.client.pipeline.addPolicy(syncTokenPolicy(this._syncTokens), { afterPhase: "Retry" });
|
|
71
76
|
}
|
|
@@ -97,7 +102,12 @@ export class AppConfigurationClient {
|
|
|
97
102
|
const keyValue = serializeAsConfigurationSettingParam(configurationSetting);
|
|
98
103
|
logger.info("[addConfigurationSetting] Creating a key value pair");
|
|
99
104
|
try {
|
|
100
|
-
const originalResponse = await this.client.putKeyValue(configurationSetting.key,
|
|
105
|
+
const originalResponse = await this.client.putKeyValue(configurationSetting.key, {
|
|
106
|
+
ifNoneMatch: "*",
|
|
107
|
+
label: configurationSetting.label,
|
|
108
|
+
entity: keyValue,
|
|
109
|
+
...updatedOptions,
|
|
110
|
+
});
|
|
101
111
|
const response = transformKeyValueResponse(originalResponse);
|
|
102
112
|
assertResponse(response);
|
|
103
113
|
return response;
|
|
@@ -138,9 +148,14 @@ export class AppConfigurationClient {
|
|
|
138
148
|
return tracingClient.withSpan("AppConfigurationClient.deleteConfigurationSetting", options, async (updatedOptions) => {
|
|
139
149
|
let status;
|
|
140
150
|
logger.info("[deleteConfigurationSetting] Deleting key value pair");
|
|
141
|
-
const originalResponse = await this.client.deleteKeyValue(id.key,
|
|
151
|
+
const originalResponse = await this.client.deleteKeyValue(id.key, {
|
|
152
|
+
label: id.label,
|
|
153
|
+
...updatedOptions,
|
|
154
|
+
...checkAndFormatIfAndIfNoneMatch(id, options),
|
|
155
|
+
onResponse: (response) => {
|
|
142
156
|
status = response.status;
|
|
143
|
-
}
|
|
157
|
+
},
|
|
158
|
+
});
|
|
144
159
|
const response = transformKeyValueResponseWithStatusCode(originalResponse, status);
|
|
145
160
|
assertResponse(response);
|
|
146
161
|
return response;
|
|
@@ -168,9 +183,16 @@ export class AppConfigurationClient {
|
|
|
168
183
|
return tracingClient.withSpan("AppConfigurationClient.getConfigurationSetting", options, async (updatedOptions) => {
|
|
169
184
|
let status;
|
|
170
185
|
logger.info("[getConfigurationSetting] Getting key value pair");
|
|
171
|
-
const originalResponse = await this.client.getKeyValue(id.key,
|
|
186
|
+
const originalResponse = await this.client.getKeyValue(id.key, {
|
|
187
|
+
...updatedOptions,
|
|
188
|
+
label: id.label,
|
|
189
|
+
select: formatFieldsForSelect(options.fields),
|
|
190
|
+
...formatAcceptDateTime(options),
|
|
191
|
+
...checkAndFormatIfAndIfNoneMatch(id, options),
|
|
192
|
+
onResponse: (response) => {
|
|
172
193
|
status = response.status;
|
|
173
|
-
}
|
|
194
|
+
},
|
|
195
|
+
});
|
|
174
196
|
const response = transformKeyValueResponseWithStatusCode(originalResponse, status);
|
|
175
197
|
// 304 only comes back if the user has passed a conditional option in their
|
|
176
198
|
// request _and_ the remote object has the same etag as what the user passed.
|
|
@@ -209,13 +231,17 @@ export class AppConfigurationClient {
|
|
|
209
231
|
const pagedResult = {
|
|
210
232
|
firstPageLink: undefined,
|
|
211
233
|
getPage: async (pageLink) => {
|
|
212
|
-
|
|
213
|
-
const etag = pageEtags === null || pageEtags === void 0 ? void 0 : pageEtags.shift();
|
|
234
|
+
const etag = pageEtags?.shift();
|
|
214
235
|
try {
|
|
215
|
-
const response = await this.sendConfigurationSettingsRequest(
|
|
216
|
-
const currentResponse =
|
|
236
|
+
const response = await this.sendConfigurationSettingsRequest({ ...options, etag }, pageLink);
|
|
237
|
+
const currentResponse = {
|
|
238
|
+
...response,
|
|
239
|
+
items: response.items != null ? response.items?.map(transformKeyValue) : [],
|
|
240
|
+
continuationToken: response.nextLink
|
|
217
241
|
? extractAfterTokenFromNextLink(response.nextLink)
|
|
218
|
-
: undefined,
|
|
242
|
+
: undefined,
|
|
243
|
+
_response: response._response,
|
|
244
|
+
};
|
|
219
245
|
return {
|
|
220
246
|
page: currentResponse,
|
|
221
247
|
nextPageLink: currentResponse.continuationToken,
|
|
@@ -223,7 +249,7 @@ export class AppConfigurationClient {
|
|
|
223
249
|
}
|
|
224
250
|
catch (error) {
|
|
225
251
|
const err = error;
|
|
226
|
-
const link =
|
|
252
|
+
const link = err.response?.headers?.get("link");
|
|
227
253
|
const continuationToken = link ? extractAfterTokenFromLinkHeader(link) : undefined;
|
|
228
254
|
if (err.statusCode === 304) {
|
|
229
255
|
err.message = `Status 304: No updates for this page`;
|
|
@@ -232,7 +258,7 @@ export class AppConfigurationClient {
|
|
|
232
258
|
page: {
|
|
233
259
|
items: [],
|
|
234
260
|
etag,
|
|
235
|
-
_response:
|
|
261
|
+
_response: { ...err.response, status: 304 },
|
|
236
262
|
},
|
|
237
263
|
nextPageLink: continuationToken,
|
|
238
264
|
};
|
|
@@ -268,11 +294,14 @@ export class AppConfigurationClient {
|
|
|
268
294
|
const pagedResult = {
|
|
269
295
|
firstPageLink: undefined,
|
|
270
296
|
getPage: async (pageLink) => {
|
|
271
|
-
|
|
272
|
-
const
|
|
273
|
-
|
|
297
|
+
const response = await this.sendConfigurationSettingsRequest({ snapshotName, ...options }, pageLink);
|
|
298
|
+
const currentResponse = {
|
|
299
|
+
...response,
|
|
300
|
+
items: response.items != null ? response.items?.map(transformKeyValue) : [],
|
|
301
|
+
continuationToken: response.nextLink
|
|
274
302
|
? extractAfterTokenFromNextLink(response.nextLink)
|
|
275
|
-
: undefined
|
|
303
|
+
: undefined,
|
|
304
|
+
};
|
|
276
305
|
return {
|
|
277
306
|
page: currentResponse,
|
|
278
307
|
nextPageLink: currentResponse.continuationToken,
|
|
@@ -303,11 +332,15 @@ export class AppConfigurationClient {
|
|
|
303
332
|
const pagedResult = {
|
|
304
333
|
firstPageLink: undefined,
|
|
305
334
|
getPage: async (pageLink) => {
|
|
306
|
-
var _a;
|
|
307
335
|
const response = await this.sendLabelsRequest(options, pageLink);
|
|
308
|
-
const currentResponse =
|
|
336
|
+
const currentResponse = {
|
|
337
|
+
...response,
|
|
338
|
+
items: response.items ?? [],
|
|
339
|
+
continuationToken: response.nextLink
|
|
309
340
|
? extractAfterTokenFromNextLink(response.nextLink)
|
|
310
|
-
: undefined,
|
|
341
|
+
: undefined,
|
|
342
|
+
_response: response._response,
|
|
343
|
+
};
|
|
311
344
|
return {
|
|
312
345
|
page: currentResponse,
|
|
313
346
|
nextPageLink: currentResponse.continuationToken,
|
|
@@ -319,13 +352,24 @@ export class AppConfigurationClient {
|
|
|
319
352
|
}
|
|
320
353
|
async sendLabelsRequest(options = {}, pageLink) {
|
|
321
354
|
return tracingClient.withSpan("AppConfigurationClient.listConfigurationSettings", options, async (updatedOptions) => {
|
|
322
|
-
const response = await this.client.getLabels(
|
|
355
|
+
const response = await this.client.getLabels({
|
|
356
|
+
...updatedOptions,
|
|
357
|
+
...formatAcceptDateTime(options),
|
|
358
|
+
...formatLabelsFiltersAndSelect(options),
|
|
359
|
+
after: pageLink,
|
|
360
|
+
});
|
|
323
361
|
return response;
|
|
324
362
|
});
|
|
325
363
|
}
|
|
326
364
|
async sendConfigurationSettingsRequest(options = {}, pageLink) {
|
|
327
365
|
return tracingClient.withSpan("AppConfigurationClient.listConfigurationSettings", options, async (updatedOptions) => {
|
|
328
|
-
const response = await this.client.getKeyValues(
|
|
366
|
+
const response = await this.client.getKeyValues({
|
|
367
|
+
...updatedOptions,
|
|
368
|
+
...formatAcceptDateTime(options),
|
|
369
|
+
...formatConfigurationSettingsFiltersAndSelect(options),
|
|
370
|
+
...checkAndFormatIfAndIfNoneMatch({ etag: options.etag }, { onlyIfChanged: true }),
|
|
371
|
+
after: pageLink,
|
|
372
|
+
});
|
|
329
373
|
return response;
|
|
330
374
|
});
|
|
331
375
|
}
|
|
@@ -352,9 +396,13 @@ export class AppConfigurationClient {
|
|
|
352
396
|
firstPageLink: undefined,
|
|
353
397
|
getPage: async (pageLink) => {
|
|
354
398
|
const response = await this.sendRevisionsRequest(options, pageLink);
|
|
355
|
-
const currentResponse =
|
|
399
|
+
const currentResponse = {
|
|
400
|
+
...response,
|
|
401
|
+
items: response.items != null ? response.items.map(transformKeyValue) : [],
|
|
402
|
+
continuationToken: response.nextLink
|
|
356
403
|
? extractAfterTokenFromNextLink(response.nextLink)
|
|
357
|
-
: undefined
|
|
404
|
+
: undefined,
|
|
405
|
+
};
|
|
358
406
|
// let itemList = currentResponse.items;
|
|
359
407
|
return {
|
|
360
408
|
page: currentResponse,
|
|
@@ -367,7 +415,12 @@ export class AppConfigurationClient {
|
|
|
367
415
|
}
|
|
368
416
|
async sendRevisionsRequest(options = {}, pageLink) {
|
|
369
417
|
return tracingClient.withSpan("AppConfigurationClient.listRevisions", options, async (updatedOptions) => {
|
|
370
|
-
const response = await this.client.getRevisions(
|
|
418
|
+
const response = await this.client.getRevisions({
|
|
419
|
+
...updatedOptions,
|
|
420
|
+
...formatAcceptDateTime(options),
|
|
421
|
+
...formatFiltersAndSelect(updatedOptions),
|
|
422
|
+
after: pageLink,
|
|
423
|
+
});
|
|
371
424
|
return response;
|
|
372
425
|
});
|
|
373
426
|
}
|
|
@@ -394,7 +447,12 @@ export class AppConfigurationClient {
|
|
|
394
447
|
return tracingClient.withSpan("AppConfigurationClient.setConfigurationSetting", options, async (updatedOptions) => {
|
|
395
448
|
const keyValue = serializeAsConfigurationSettingParam(configurationSetting);
|
|
396
449
|
logger.info("[setConfigurationSetting] Setting new key value");
|
|
397
|
-
const response = transformKeyValueResponse(await this.client.putKeyValue(configurationSetting.key,
|
|
450
|
+
const response = transformKeyValueResponse(await this.client.putKeyValue(configurationSetting.key, {
|
|
451
|
+
...updatedOptions,
|
|
452
|
+
label: configurationSetting.label,
|
|
453
|
+
entity: keyValue,
|
|
454
|
+
...checkAndFormatIfAndIfNoneMatch(configurationSetting, options),
|
|
455
|
+
}));
|
|
398
456
|
assertResponse(response);
|
|
399
457
|
return response;
|
|
400
458
|
});
|
|
@@ -408,11 +466,19 @@ export class AppConfigurationClient {
|
|
|
408
466
|
let response;
|
|
409
467
|
if (readOnly) {
|
|
410
468
|
logger.info("[setReadOnly] Setting read-only status to ${readOnly}");
|
|
411
|
-
response = await this.client.putLock(id.key,
|
|
469
|
+
response = await this.client.putLock(id.key, {
|
|
470
|
+
...newOptions,
|
|
471
|
+
label: id.label,
|
|
472
|
+
...checkAndFormatIfAndIfNoneMatch(id, options),
|
|
473
|
+
});
|
|
412
474
|
}
|
|
413
475
|
else {
|
|
414
476
|
logger.info("[setReadOnly] Deleting read-only lock");
|
|
415
|
-
response = await this.client.deleteLock(id.key,
|
|
477
|
+
response = await this.client.deleteLock(id.key, {
|
|
478
|
+
...newOptions,
|
|
479
|
+
label: id.label,
|
|
480
|
+
...checkAndFormatIfAndIfNoneMatch(id, options),
|
|
481
|
+
});
|
|
416
482
|
}
|
|
417
483
|
response = transformKeyValueResponse(response);
|
|
418
484
|
assertResponse(response);
|
|
@@ -434,7 +500,7 @@ export class AppConfigurationClient {
|
|
|
434
500
|
beginCreateSnapshot(snapshot,
|
|
435
501
|
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
436
502
|
options = {}) {
|
|
437
|
-
return tracingClient.withSpan(`${AppConfigurationClient.name}.beginCreateSnapshot`, options, (updatedOptions) => this.client.beginCreateSnapshot(snapshot.name, snapshot,
|
|
503
|
+
return tracingClient.withSpan(`${AppConfigurationClient.name}.beginCreateSnapshot`, options, (updatedOptions) => this.client.beginCreateSnapshot(snapshot.name, snapshot, { ...updatedOptions }));
|
|
438
504
|
}
|
|
439
505
|
/**
|
|
440
506
|
* Begins creating a snapshot for Azure App Configuration service, waits until it is done,
|
|
@@ -443,7 +509,7 @@ export class AppConfigurationClient {
|
|
|
443
509
|
beginCreateSnapshotAndWait(snapshot,
|
|
444
510
|
// eslint-disable-next-line @azure/azure-sdk/ts-naming-options
|
|
445
511
|
options = {}) {
|
|
446
|
-
return tracingClient.withSpan(`${AppConfigurationClient.name}.beginCreateSnapshotAndWait`, options, (updatedOptions) => this.client.beginCreateSnapshotAndWait(snapshot.name, snapshot,
|
|
512
|
+
return tracingClient.withSpan(`${AppConfigurationClient.name}.beginCreateSnapshotAndWait`, options, (updatedOptions) => this.client.beginCreateSnapshotAndWait(snapshot.name, snapshot, { ...updatedOptions }));
|
|
447
513
|
}
|
|
448
514
|
/**
|
|
449
515
|
* Get a snapshot from Azure App Configuration service
|
|
@@ -467,7 +533,9 @@ export class AppConfigurationClient {
|
|
|
467
533
|
getSnapshot(name, options = {}) {
|
|
468
534
|
return tracingClient.withSpan("AppConfigurationClient.getSnapshot", options, async (updatedOptions) => {
|
|
469
535
|
logger.info("[getSnapshot] Get a snapshot");
|
|
470
|
-
const originalResponse = await this.client.getSnapshot(name,
|
|
536
|
+
const originalResponse = await this.client.getSnapshot(name, {
|
|
537
|
+
...updatedOptions,
|
|
538
|
+
});
|
|
471
539
|
const response = transformSnapshotResponse(originalResponse);
|
|
472
540
|
assertResponse(response);
|
|
473
541
|
return response;
|
|
@@ -496,7 +564,10 @@ export class AppConfigurationClient {
|
|
|
496
564
|
options = {}) {
|
|
497
565
|
return tracingClient.withSpan("AppConfigurationClient.recoverSnapshot", options, async (updatedOptions) => {
|
|
498
566
|
logger.info("[recoverSnapshot] Recover a snapshot");
|
|
499
|
-
const originalResponse = await this.client.updateSnapshot(name, { status: "ready" },
|
|
567
|
+
const originalResponse = await this.client.updateSnapshot(name, { status: "ready" }, {
|
|
568
|
+
...updatedOptions,
|
|
569
|
+
...checkAndFormatIfAndIfNoneMatch({ etag: options.etag }, { onlyIfUnchanged: true, ...options }),
|
|
570
|
+
});
|
|
500
571
|
const response = transformSnapshotResponse(originalResponse);
|
|
501
572
|
assertResponse(response);
|
|
502
573
|
return response;
|
|
@@ -525,7 +596,10 @@ export class AppConfigurationClient {
|
|
|
525
596
|
options = {}) {
|
|
526
597
|
return tracingClient.withSpan("AppConfigurationClient.archiveSnapshot", options, async (updatedOptions) => {
|
|
527
598
|
logger.info("[archiveSnapshot] Archive a snapshot");
|
|
528
|
-
const originalResponse = await this.client.updateSnapshot(name, { status: "archived" },
|
|
599
|
+
const originalResponse = await this.client.updateSnapshot(name, { status: "archived" }, {
|
|
600
|
+
...updatedOptions,
|
|
601
|
+
...checkAndFormatIfAndIfNoneMatch({ etag: options.etag }, { onlyIfUnchanged: true, ...options }),
|
|
602
|
+
});
|
|
529
603
|
const response = transformSnapshotResponse(originalResponse);
|
|
530
604
|
assertResponse(response);
|
|
531
605
|
return response;
|
|
@@ -557,9 +631,13 @@ export class AppConfigurationClient {
|
|
|
557
631
|
firstPageLink: undefined,
|
|
558
632
|
getPage: async (pageLink) => {
|
|
559
633
|
const response = await this.sendSnapShotsRequest(options, pageLink);
|
|
560
|
-
const currentResponse =
|
|
634
|
+
const currentResponse = {
|
|
635
|
+
...response,
|
|
636
|
+
items: response.items != null ? response.items : [],
|
|
637
|
+
continuationToken: response.nextLink
|
|
561
638
|
? extractAfterTokenFromNextLink(response.nextLink)
|
|
562
|
-
: undefined
|
|
639
|
+
: undefined,
|
|
640
|
+
};
|
|
563
641
|
return {
|
|
564
642
|
page: currentResponse,
|
|
565
643
|
nextPageLink: currentResponse.continuationToken,
|
|
@@ -571,7 +649,11 @@ export class AppConfigurationClient {
|
|
|
571
649
|
}
|
|
572
650
|
async sendSnapShotsRequest(options = {}, pageLink) {
|
|
573
651
|
return tracingClient.withSpan("AppConfigurationClient.listSnapshots", options, async (updatedOptions) => {
|
|
574
|
-
const response = await this.client.getSnapshots(
|
|
652
|
+
const response = await this.client.getSnapshots({
|
|
653
|
+
...updatedOptions,
|
|
654
|
+
...formatSnapshotFiltersAndSelect(options),
|
|
655
|
+
after: pageLink,
|
|
656
|
+
});
|
|
575
657
|
return response;
|
|
576
658
|
});
|
|
577
659
|
}
|