@azure-rest/maps-timezone 1.0.0-beta.1 → 1.0.0-beta.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/CHANGELOG.md +17 -0
- package/LICENSE +4 -4
- package/README.md +92 -43
- package/dist/browser/MapsTimeZone.d.ts +6 -5
- package/dist/browser/MapsTimeZone.d.ts.map +1 -1
- package/dist/browser/MapsTimeZone.js.map +1 -1
- package/dist/browser/generated/isUnexpected.js +5 -6
- package/dist/browser/generated/isUnexpected.js.map +1 -1
- package/dist/browser/generated/mapsTimeZoneClient.js +13 -11
- package/dist/browser/generated/mapsTimeZoneClient.js.map +1 -1
- package/dist/commonjs/MapsTimeZone.d.ts +6 -5
- package/dist/commonjs/MapsTimeZone.d.ts.map +1 -1
- package/dist/commonjs/MapsTimeZone.js.map +1 -1
- package/dist/commonjs/generated/isUnexpected.js +5 -6
- package/dist/commonjs/generated/isUnexpected.js.map +1 -1
- package/dist/commonjs/generated/mapsTimeZoneClient.js +13 -11
- package/dist/commonjs/generated/mapsTimeZoneClient.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/esm/MapsTimeZone.d.ts +6 -5
- package/dist/esm/MapsTimeZone.d.ts.map +1 -1
- package/dist/esm/MapsTimeZone.js.map +1 -1
- package/dist/esm/generated/isUnexpected.js +5 -6
- package/dist/esm/generated/isUnexpected.js.map +1 -1
- package/dist/esm/generated/mapsTimeZoneClient.js +13 -11
- package/dist/esm/generated/mapsTimeZoneClient.js.map +1 -1
- package/dist/react-native/MapsTimeZone.d.ts +6 -5
- package/dist/react-native/MapsTimeZone.d.ts.map +1 -1
- package/dist/react-native/MapsTimeZone.js.map +1 -1
- package/dist/react-native/generated/isUnexpected.js +5 -6
- package/dist/react-native/generated/isUnexpected.js.map +1 -1
- package/dist/react-native/generated/mapsTimeZoneClient.js +13 -11
- package/dist/react-native/generated/mapsTimeZoneClient.js.map +1 -1
- package/package.json +41 -45
- package/review/maps-timezone-node.api.md +374 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAwDlC,oCA6BC;AApED,MAAM,WAAW,GAA6B;IAC5C,6BAA6B,EAAE,CAAC,KAAK,CAAC;IACtC,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,sCAAsC,EAAE,CAAC,KAAK,CAAC;CAChD,CAAC;AAgCF,SAAgB,YAAY,CAC1B,QAYuD;IAQvD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAwDlC,oCA6BC;AApED,MAAM,WAAW,GAA6B;IAC5C,6BAA6B,EAAE,CAAC,KAAK,CAAC;IACtC,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,sCAAsC,EAAE,CAAC,KAAK,CAAC;CAChD,CAAC;AAgCF,SAAgB,YAAY,CAC1B,QAYuD;IAQvD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n TimeZoneGetTimeZoneByID200Response,\n TimeZoneGetTimeZoneByIDDefaultResponse,\n TimeZoneGetTimeZoneByCoordinates200Response,\n TimeZoneGetTimeZoneByCoordinatesDefaultResponse,\n TimeZoneGetWindowsTimezoneIds200Response,\n TimeZoneGetWindowsTimezoneIdsDefaultResponse,\n TimeZoneGetIanaTimezoneIds200Response,\n TimeZoneGetIanaTimezoneIdsDefaultResponse,\n TimeZoneGetIanaVersion200Response,\n TimeZoneGetIanaVersionDefaultResponse,\n TimeZoneConvertWindowsTimezoneToIana200Response,\n TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /timezone/byId/{format}\": [\"200\"],\n \"GET /timezone/byCoordinates/{format}\": [\"200\"],\n \"GET /timezone/enumWindows/{format}\": [\"200\"],\n \"GET /timezone/enumIana/{format}\": [\"200\"],\n \"GET /timezone/ianaVersion/{format}\": [\"200\"],\n \"GET /timezone/windowsToIana/{format}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByID200Response\n | TimeZoneGetTimeZoneByIDDefaultResponse,\n): response is TimeZoneGetTimeZoneByIDDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByCoordinates200Response\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse,\n): response is TimeZoneGetTimeZoneByCoordinatesDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetWindowsTimezoneIds200Response\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse,\n): response is TimeZoneGetWindowsTimezoneIdsDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetIanaTimezoneIds200Response\n | TimeZoneGetIanaTimezoneIdsDefaultResponse,\n): response is TimeZoneGetIanaTimezoneIdsDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetIanaVersion200Response\n | TimeZoneGetIanaVersionDefaultResponse,\n): response is TimeZoneGetIanaVersionDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneConvertWindowsTimezoneToIana200Response\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n): response is TimeZoneConvertWindowsTimezoneToIanaDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByID200Response\n | TimeZoneGetTimeZoneByIDDefaultResponse\n | TimeZoneGetTimeZoneByCoordinates200Response\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse\n | TimeZoneGetWindowsTimezoneIds200Response\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse\n | TimeZoneGetIanaTimezoneIds200Response\n | TimeZoneGetIanaTimezoneIdsDefaultResponse\n | TimeZoneGetIanaVersion200Response\n | TimeZoneGetIanaVersionDefaultResponse\n | TimeZoneConvertWindowsTimezoneToIana200Response\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n): response is\n | TimeZoneGetTimeZoneByIDDefaultResponse\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse\n | TimeZoneGetIanaTimezoneIdsDefaultResponse\n | TimeZoneGetIanaVersionDefaultResponse\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (\n let i = candidateParts.length - 1, j = pathParts.length - 1;\n i >= 1 && j >= 1;\n i--, j--\n ) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.indexOf(\"}\") !== -1\n ) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(\n `${candidateParts[i]?.slice(start, end)}`,\n ).test(pathParts[j] || \"\");\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.default = createClient;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
6
|
const core_client_1 = require("@azure-rest/core-client");
|
|
8
7
|
const logger_js_1 = require("./logger.js");
|
|
9
8
|
/**
|
|
@@ -11,21 +10,24 @@ const logger_js_1 = require("./logger.js");
|
|
|
11
10
|
* @param credentials - uniquely identify client credential
|
|
12
11
|
* @param options - the parameter for all optional parameters
|
|
13
12
|
*/
|
|
14
|
-
function createClient(credentials,
|
|
15
|
-
|
|
16
|
-
var { apiVersion = "1.0" } = _a, options = tslib_1.__rest(_a, ["apiVersion"]);
|
|
17
|
-
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://atlas.microsoft.com`;
|
|
13
|
+
function createClient(credentials, { apiVersion = "1.0", ...options } = {}) {
|
|
14
|
+
const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
18
15
|
const userAgentInfo = `azsdk-js-maps-timezone-rest/1.0.0-beta.1`;
|
|
19
16
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
20
17
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
21
18
|
: `${userAgentInfo}`;
|
|
22
|
-
options =
|
|
19
|
+
options = {
|
|
20
|
+
...options,
|
|
21
|
+
userAgentOptions: {
|
|
23
22
|
userAgentPrefix,
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
23
|
+
},
|
|
24
|
+
loggingOptions: {
|
|
25
|
+
logger: options.loggingOptions?.logger ?? logger_js_1.logger.info,
|
|
26
|
+
},
|
|
27
|
+
credentials: {
|
|
28
|
+
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "subscription-key",
|
|
29
|
+
},
|
|
30
|
+
};
|
|
29
31
|
const client = (0, core_client_1.getClient)(endpointUrl, credentials, options);
|
|
30
32
|
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
31
33
|
client.pipeline.addPolicy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapsTimeZoneClient.js","sourceRoot":"","sources":["../../../src/generated/mapsTimeZoneClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;AAkBlC,+BAgDC
|
|
1
|
+
{"version":3,"file":"mapsTimeZoneClient.js","sourceRoot":"","sources":["../../../src/generated/mapsTimeZoneClient.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C,GAAG,CAAC,aAAa,CAAC,IAAI,UAAU,EAAE,CAAC;gBACvD,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsTimeZoneClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface MapsTimeZoneClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `MapsTimeZoneClient`\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n credentials: KeyCredential,\n { apiVersion = \"1.0\", ...options }: MapsTimeZoneClientOptions = {},\n): MapsTimeZoneClient {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;\n const userAgentInfo = `azsdk-js-maps-timezone-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\",\n },\n };\n const client = getClient(\n endpointUrl,\n credentials,\n options,\n ) as MapsTimeZoneClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
-
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
-
{
|
|
4
|
-
"tsdocVersion": "0.12",
|
|
5
|
-
"toolPackages": [
|
|
6
|
-
{
|
|
7
|
-
"packageName": "@microsoft/api-extractor",
|
|
8
|
-
"packageVersion": "7.
|
|
9
|
-
}
|
|
10
|
-
]
|
|
11
|
-
}
|
|
1
|
+
// This file is read by tools that parse documentation comments conforming to the TSDoc standard.
|
|
2
|
+
// It should be published with your NPM package. It should not be tracked by Git.
|
|
3
|
+
{
|
|
4
|
+
"tsdocVersion": "0.12",
|
|
5
|
+
"toolPackages": [
|
|
6
|
+
{
|
|
7
|
+
"packageName": "@microsoft/api-extractor",
|
|
8
|
+
"packageVersion": "7.52.10"
|
|
9
|
+
}
|
|
10
|
+
]
|
|
11
|
+
}
|
|
@@ -5,7 +5,8 @@ import type { MapsTimeZoneClient } from "./generated/index.js";
|
|
|
5
5
|
* Creates an instance of MapsTimeZoneClient from a subscription key.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```ts
|
|
8
|
+
* ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
9
|
+
* import { AzureKeyCredential } from "@azure/core-auth";
|
|
9
10
|
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
10
11
|
*
|
|
11
12
|
* const credential = new AzureKeyCredential("<subscription-key>");
|
|
@@ -20,9 +21,9 @@ export default function MapsTimeZone(credential: AzureKeyCredential, options?: C
|
|
|
20
21
|
* Creates an instance of MapsTimeZone from an Azure Identity `TokenCredential`.
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import MapsTimeZoneClient from "@azure-rest/maps-timezone";
|
|
24
|
+
* ```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
25
25
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
26
|
+
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
26
27
|
*
|
|
27
28
|
* const credential = new DefaultAzureCredential();
|
|
28
29
|
* const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
@@ -37,9 +38,9 @@ export default function MapsTimeZone(credential: TokenCredential, mapsAccountCli
|
|
|
37
38
|
* Creates an instance of MapsTimeZone from an Azure Identity `AzureSASCredential`.
|
|
38
39
|
*
|
|
39
40
|
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
41
|
+
* ```ts snippet:ReadmeSampleCreateClient_SASToken
|
|
42
42
|
* import { AzureSASCredential } from "@azure/core-auth";
|
|
43
|
+
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
43
44
|
*
|
|
44
45
|
* const credential = new AzureSASCredential("<SAS Token>");
|
|
45
46
|
* const client = MapsTimeZone(credential);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsTimeZone.d.ts","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D
|
|
1
|
+
{"version":3,"file":"MapsTimeZone.d.ts","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC;AACtB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,eAAe,EAC3B,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC;AACtB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsTimeZone.js","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"MapsTimeZone.js","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OA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,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;gBACxE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport type { AzureKeyCredential, AzureSASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isSASCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsTimeZoneClient } from \"./generated/index.js\";\nimport createClient from \"./generated/mapsTimeZoneClient.js\";\n\n/**\n * Creates an instance of MapsTimeZoneClient from a subscription key.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsTimeZone(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsTimeZoneClient;\n/**\n * Creates an instance of MapsTimeZone from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsTimeZone(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsTimeZoneClient;\n/**\n * Creates an instance of MapsTimeZone from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { AzureSASCredential } from \"@azure/core-auth\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsTimeZone(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsTimeZoneClient;\nexport default function MapsTimeZone(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsTimeZoneClient {\n const options = typeof clientIdOrOptions === \"string\" ? maybeOptions : clientIdOrOptions;\n\n /**\n * maps service requires a header \"ms-x-client-id\", which is different from the standard Microsoft Entra ID.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: \"https://atlas.microsoft.com/.default\",\n }),\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n\n if (isSASCredential(credential)) {\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy({\n name: \"mapsSASCredentialPolicy\",\n async sendRequest(request, next) {\n request.headers.set(\"Authorization\", `jwt-sas ${credential.signature}`);\n return next(request);\n },\n });\n return client;\n }\n\n return createClient(credential, options);\n}\n"]}
|
|
@@ -10,7 +10,7 @@ const responseMap = {
|
|
|
10
10
|
};
|
|
11
11
|
export function isUnexpected(response) {
|
|
12
12
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
13
|
-
const url = new URL(lroOriginal
|
|
13
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
14
14
|
const method = response.request.method;
|
|
15
15
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
16
16
|
if (!pathDetails) {
|
|
@@ -19,7 +19,6 @@ export function isUnexpected(response) {
|
|
|
19
19
|
return !pathDetails.includes(response.status);
|
|
20
20
|
}
|
|
21
21
|
function getParametrizedPathSuccess(method, path) {
|
|
22
|
-
var _a, _b, _c, _d;
|
|
23
22
|
const pathParts = path.split("/");
|
|
24
23
|
// Traverse list to match the longest candidate
|
|
25
24
|
// matchedLen: the length of candidate path
|
|
@@ -38,14 +37,14 @@ function getParametrizedPathSuccess(method, path) {
|
|
|
38
37
|
// track if we have found a match to return the values found.
|
|
39
38
|
let found = true;
|
|
40
39
|
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
const start = candidateParts[i].indexOf("}") + 1, end =
|
|
40
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
41
|
+
candidateParts[i]?.indexOf("}") !== -1) {
|
|
42
|
+
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
|
|
44
43
|
// If the current part of the candidate is a "template" part
|
|
45
44
|
// Try to use the suffix of pattern to match the path
|
|
46
45
|
// {guid} ==> $
|
|
47
46
|
// {guid}:export ==> :export$
|
|
48
|
-
const isMatched = new RegExp(`${
|
|
47
|
+
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
|
|
49
48
|
if (!isMatched) {
|
|
50
49
|
found = false;
|
|
51
50
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAiBlC,MAAM,WAAW,GAA6B;IAC5C,6BAA6B,EAAE,CAAC,KAAK,CAAC;IACtC,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,sCAAsC,EAAE,CAAC,KAAK,CAAC;CAChD,CAAC;AAgCF,MAAM,UAAU,YAAY,CAC1B,QAYuD;IAQvD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAiBlC,MAAM,WAAW,GAA6B;IAC5C,6BAA6B,EAAE,CAAC,KAAK,CAAC;IACtC,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,sCAAsC,EAAE,CAAC,KAAK,CAAC;CAChD,CAAC;AAgCF,MAAM,UAAU,YAAY,CAC1B,QAYuD;IAQvD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,IAAI,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACzD,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAA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.\n\nimport {\n TimeZoneGetTimeZoneByID200Response,\n TimeZoneGetTimeZoneByIDDefaultResponse,\n TimeZoneGetTimeZoneByCoordinates200Response,\n TimeZoneGetTimeZoneByCoordinatesDefaultResponse,\n TimeZoneGetWindowsTimezoneIds200Response,\n TimeZoneGetWindowsTimezoneIdsDefaultResponse,\n TimeZoneGetIanaTimezoneIds200Response,\n TimeZoneGetIanaTimezoneIdsDefaultResponse,\n TimeZoneGetIanaVersion200Response,\n TimeZoneGetIanaVersionDefaultResponse,\n TimeZoneConvertWindowsTimezoneToIana200Response,\n TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /timezone/byId/{format}\": [\"200\"],\n \"GET /timezone/byCoordinates/{format}\": [\"200\"],\n \"GET /timezone/enumWindows/{format}\": [\"200\"],\n \"GET /timezone/enumIana/{format}\": [\"200\"],\n \"GET /timezone/ianaVersion/{format}\": [\"200\"],\n \"GET /timezone/windowsToIana/{format}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByID200Response\n | TimeZoneGetTimeZoneByIDDefaultResponse,\n): response is TimeZoneGetTimeZoneByIDDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByCoordinates200Response\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse,\n): response is TimeZoneGetTimeZoneByCoordinatesDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetWindowsTimezoneIds200Response\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse,\n): response is TimeZoneGetWindowsTimezoneIdsDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetIanaTimezoneIds200Response\n | TimeZoneGetIanaTimezoneIdsDefaultResponse,\n): response is TimeZoneGetIanaTimezoneIdsDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetIanaVersion200Response\n | TimeZoneGetIanaVersionDefaultResponse,\n): response is TimeZoneGetIanaVersionDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneConvertWindowsTimezoneToIana200Response\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n): response is TimeZoneConvertWindowsTimezoneToIanaDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByID200Response\n | TimeZoneGetTimeZoneByIDDefaultResponse\n | TimeZoneGetTimeZoneByCoordinates200Response\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse\n | TimeZoneGetWindowsTimezoneIds200Response\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse\n | TimeZoneGetIanaTimezoneIds200Response\n | TimeZoneGetIanaTimezoneIdsDefaultResponse\n | TimeZoneGetIanaVersion200Response\n | TimeZoneGetIanaVersionDefaultResponse\n | TimeZoneConvertWindowsTimezoneToIana200Response\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n): response is\n | TimeZoneGetTimeZoneByIDDefaultResponse\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse\n | TimeZoneGetIanaTimezoneIdsDefaultResponse\n | TimeZoneGetIanaVersionDefaultResponse\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (\n let i = candidateParts.length - 1, j = pathParts.length - 1;\n i >= 1 && j >= 1;\n i--, j--\n ) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.indexOf(\"}\") !== -1\n ) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(\n `${candidateParts[i]?.slice(start, end)}`,\n ).test(pathParts[j] || \"\");\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __rest } from "tslib";
|
|
4
3
|
import { getClient } from "@azure-rest/core-client";
|
|
5
4
|
import { logger } from "./logger.js";
|
|
6
5
|
/**
|
|
@@ -8,21 +7,24 @@ import { logger } from "./logger.js";
|
|
|
8
7
|
* @param credentials - uniquely identify client credential
|
|
9
8
|
* @param options - the parameter for all optional parameters
|
|
10
9
|
*/
|
|
11
|
-
export default function createClient(credentials,
|
|
12
|
-
|
|
13
|
-
var { apiVersion = "1.0" } = _a, options = __rest(_a, ["apiVersion"]);
|
|
14
|
-
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://atlas.microsoft.com`;
|
|
10
|
+
export default function createClient(credentials, { apiVersion = "1.0", ...options } = {}) {
|
|
11
|
+
const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
15
12
|
const userAgentInfo = `azsdk-js-maps-timezone-rest/1.0.0-beta.1`;
|
|
16
13
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
17
14
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
18
15
|
: `${userAgentInfo}`;
|
|
19
|
-
options =
|
|
16
|
+
options = {
|
|
17
|
+
...options,
|
|
18
|
+
userAgentOptions: {
|
|
20
19
|
userAgentPrefix,
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
},
|
|
21
|
+
loggingOptions: {
|
|
22
|
+
logger: options.loggingOptions?.logger ?? logger.info,
|
|
23
|
+
},
|
|
24
|
+
credentials: {
|
|
25
|
+
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "subscription-key",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
26
28
|
const client = getClient(endpointUrl, credentials, options);
|
|
27
29
|
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
28
30
|
client.pipeline.addPolicy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapsTimeZoneClient.js","sourceRoot":"","sources":["../../../src/generated/mapsTimeZoneClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC
|
|
1
|
+
{"version":3,"file":"mapsTimeZoneClient.js","sourceRoot":"","sources":["../../../src/generated/mapsTimeZoneClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,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AG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsTimeZoneClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface MapsTimeZoneClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `MapsTimeZoneClient`\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n credentials: KeyCredential,\n { apiVersion = \"1.0\", ...options }: MapsTimeZoneClientOptions = {},\n): MapsTimeZoneClient {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;\n const userAgentInfo = `azsdk-js-maps-timezone-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\",\n },\n };\n const client = getClient(\n endpointUrl,\n credentials,\n options,\n ) as MapsTimeZoneClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
|
|
@@ -5,7 +5,8 @@ import type { MapsTimeZoneClient } from "./generated/index.js";
|
|
|
5
5
|
* Creates an instance of MapsTimeZoneClient from a subscription key.
|
|
6
6
|
*
|
|
7
7
|
* @example
|
|
8
|
-
* ```ts
|
|
8
|
+
* ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey
|
|
9
|
+
* import { AzureKeyCredential } from "@azure/core-auth";
|
|
9
10
|
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
10
11
|
*
|
|
11
12
|
* const credential = new AzureKeyCredential("<subscription-key>");
|
|
@@ -20,9 +21,9 @@ export default function MapsTimeZone(credential: AzureKeyCredential, options?: C
|
|
|
20
21
|
* Creates an instance of MapsTimeZone from an Azure Identity `TokenCredential`.
|
|
21
22
|
*
|
|
22
23
|
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import MapsTimeZoneClient from "@azure-rest/maps-timezone";
|
|
24
|
+
* ```ts snippet:ReadmeSampleCreateClient_TokenCredential
|
|
25
25
|
* import { DefaultAzureCredential } from "@azure/identity";
|
|
26
|
+
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
26
27
|
*
|
|
27
28
|
* const credential = new DefaultAzureCredential();
|
|
28
29
|
* const client = MapsTimeZone(credential, "<maps-account-client-id>");
|
|
@@ -37,9 +38,9 @@ export default function MapsTimeZone(credential: TokenCredential, mapsAccountCli
|
|
|
37
38
|
* Creates an instance of MapsTimeZone from an Azure Identity `AzureSASCredential`.
|
|
38
39
|
*
|
|
39
40
|
* @example
|
|
40
|
-
* ```ts
|
|
41
|
-
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
41
|
+
* ```ts snippet:ReadmeSampleCreateClient_SASToken
|
|
42
42
|
* import { AzureSASCredential } from "@azure/core-auth";
|
|
43
|
+
* import MapsTimeZone from "@azure-rest/maps-timezone";
|
|
43
44
|
*
|
|
44
45
|
* const credential = new AzureSASCredential("<SAS Token>");
|
|
45
46
|
* const client = MapsTimeZone(credential);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsTimeZone.d.ts","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D
|
|
1
|
+
{"version":3,"file":"MapsTimeZone.d.ts","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,KAAK,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAIhG,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAG/D;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC;AACtB;;;;;;;;;;;;;;;GAeG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,eAAe,EAC3B,mBAAmB,EAAE,MAAM,EAC3B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC;AACtB;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAU,EAAE,kBAAkB,EAC9B,OAAO,CAAC,EAAE,aAAa,GACtB,kBAAkB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MapsTimeZone.js","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"MapsTimeZone.js","sourceRoot":"","sources":["../../src/MapsTimeZone.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAC5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,oBAAoB,CAAC;AAE9D,OAAO,YAAY,MAAM,mCAAmC,CAAC;AA6D7D,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,UAAqE,EACrE,oBAA4C,EAAE,EAC9C,eAA8B,EAAE;IAEhC,MAAM,OAAO,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,iBAAiB,CAAC;IAEzF;;;;OAIG;IACH,IAAI,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;QAClC,MAAM,QAAQ,GAAG,OAAO,iBAAiB,KAAK,QAAQ,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;QAChF,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,KAAK,CAAC,yCAAyC,CAAC,CAAC;QACzD,CAAC;QACD,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CACvB,+BAA+B,CAAC;YAC9B,UAAU;YACV,MAAM,EAAE,sCAAsC;SAC/C,CAAC,CACH,CAAC;QACF,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC,wBAAwB,CAAC,QAAQ,CAAC,CAAC,CAAC;QAC9D,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAI,eAAe,CAAC,UAAU,CAAC,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,YAAY,CAAC,SAAgB,EAAE,OAAO,CAAC,CAAC;QACvD,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;YACxB,IAAI,EAAE,yBAAyB;YAC/B,KAAK,CAAC,WAAW,CAAC,OAAO,EAAE,IAAI;gBAC7B,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,WAAW,UAAU,CAAC,SAAS,EAAE,CAAC,CAAC;gBACxE,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;YACvB,CAAC;SACF,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,OAAO,YAAY,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { ClientOptions } from \"@azure-rest/core-client\";\nimport type { AzureKeyCredential, AzureSASCredential, TokenCredential } from \"@azure/core-auth\";\nimport { isSASCredential, isTokenCredential } from \"@azure/core-auth\";\nimport { bearerTokenAuthenticationPolicy } from \"@azure/core-rest-pipeline\";\nimport { createMapsClientIdPolicy } from \"@azure/maps-common\";\nimport type { MapsTimeZoneClient } from \"./generated/index.js\";\nimport createClient from \"./generated/mapsTimeZoneClient.js\";\n\n/**\n * Creates an instance of MapsTimeZoneClient from a subscription key.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SubscriptionKey\n * import { AzureKeyCredential } from \"@azure/core-auth\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new AzureKeyCredential(\"<subscription-key>\");\n * const client = MapsTimeZone(credential);\n *```\n *\n * @param credential - An AzureKeyCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: AzureKeyCredential,\n options?: ClientOptions,\n): MapsTimeZoneClient;\n/**\n * Creates an instance of MapsTimeZone from an Azure Identity `TokenCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_TokenCredential\n * import { DefaultAzureCredential } from \"@azure/identity\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new DefaultAzureCredential();\n * const client = MapsTimeZone(credential, \"<maps-account-client-id>\");\n *```\n *\n * @param credential - An TokenCredential instance used to authenticate requests to the service\n * @param mapsAccountClientId - The Azure Maps client id of a specific map resource\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: TokenCredential,\n mapsAccountClientId: string,\n options?: ClientOptions,\n): MapsTimeZoneClient;\n/**\n * Creates an instance of MapsTimeZone from an Azure Identity `AzureSASCredential`.\n *\n * @example\n * ```ts snippet:ReadmeSampleCreateClient_SASToken\n * import { AzureSASCredential } from \"@azure/core-auth\";\n * import MapsTimeZone from \"@azure-rest/maps-timezone\";\n *\n * const credential = new AzureSASCredential(\"<SAS Token>\");\n * const client = MapsTimeZone(credential);\n * ```\n *\n * @param credential - An AzureSASCredential instance used to authenticate requests to the service\n * @param options - Options used to configure the TimeZone Client\n */\nexport default function MapsTimeZone(\n credential: AzureSASCredential,\n options?: ClientOptions,\n): MapsTimeZoneClient;\nexport default function MapsTimeZone(\n credential: TokenCredential | AzureKeyCredential | AzureSASCredential,\n clientIdOrOptions: string | ClientOptions = {},\n maybeOptions: ClientOptions = {},\n): MapsTimeZoneClient {\n const options = typeof clientIdOrOptions === \"string\" ? maybeOptions : clientIdOrOptions;\n\n /**\n * maps service requires a header \"ms-x-client-id\", which is different from the standard Microsoft Entra ID.\n * So we need to do our own implementation.\n * This customized authentication is following by this guide: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/RLC-customization.md#custom-authentication\n */\n if (isTokenCredential(credential)) {\n const clientId = typeof clientIdOrOptions === \"string\" ? clientIdOrOptions : \"\";\n if (!clientId) {\n throw Error(\"Client id is needed for TokenCredential\");\n }\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy(\n bearerTokenAuthenticationPolicy({\n credential,\n scopes: \"https://atlas.microsoft.com/.default\",\n }),\n );\n client.pipeline.addPolicy(createMapsClientIdPolicy(clientId));\n return client;\n }\n\n if (isSASCredential(credential)) {\n const client = createClient(undefined as any, options);\n client.pipeline.addPolicy({\n name: \"mapsSASCredentialPolicy\",\n async sendRequest(request, next) {\n request.headers.set(\"Authorization\", `jwt-sas ${credential.signature}`);\n return next(request);\n },\n });\n return client;\n }\n\n return createClient(credential, options);\n}\n"]}
|
|
@@ -10,7 +10,7 @@ const responseMap = {
|
|
|
10
10
|
};
|
|
11
11
|
export function isUnexpected(response) {
|
|
12
12
|
const lroOriginal = response.headers["x-ms-original-url"];
|
|
13
|
-
const url = new URL(lroOriginal
|
|
13
|
+
const url = new URL(lroOriginal ?? response.request.url);
|
|
14
14
|
const method = response.request.method;
|
|
15
15
|
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
|
16
16
|
if (!pathDetails) {
|
|
@@ -19,7 +19,6 @@ export function isUnexpected(response) {
|
|
|
19
19
|
return !pathDetails.includes(response.status);
|
|
20
20
|
}
|
|
21
21
|
function getParametrizedPathSuccess(method, path) {
|
|
22
|
-
var _a, _b, _c, _d;
|
|
23
22
|
const pathParts = path.split("/");
|
|
24
23
|
// Traverse list to match the longest candidate
|
|
25
24
|
// matchedLen: the length of candidate path
|
|
@@ -38,14 +37,14 @@ function getParametrizedPathSuccess(method, path) {
|
|
|
38
37
|
// track if we have found a match to return the values found.
|
|
39
38
|
let found = true;
|
|
40
39
|
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
|
41
|
-
if (
|
|
42
|
-
|
|
43
|
-
const start = candidateParts[i].indexOf("}") + 1, end =
|
|
40
|
+
if (candidateParts[i]?.startsWith("{") &&
|
|
41
|
+
candidateParts[i]?.indexOf("}") !== -1) {
|
|
42
|
+
const start = candidateParts[i].indexOf("}") + 1, end = candidateParts[i]?.length;
|
|
44
43
|
// If the current part of the candidate is a "template" part
|
|
45
44
|
// Try to use the suffix of pattern to match the path
|
|
46
45
|
// {guid} ==> $
|
|
47
46
|
// {guid}:export ==> :export$
|
|
48
|
-
const isMatched = new RegExp(`${
|
|
47
|
+
const isMatched = new RegExp(`${candidateParts[i]?.slice(start, end)}`).test(pathParts[j] || "");
|
|
49
48
|
if (!isMatched) {
|
|
50
49
|
found = false;
|
|
51
50
|
break;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAiBlC,MAAM,WAAW,GAA6B;IAC5C,6BAA6B,EAAE,CAAC,KAAK,CAAC;IACtC,sCAAsC,EAAE,CAAC,KAAK,CAAC;IAC/C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,iCAAiC,EAAE,CAAC,KAAK,CAAC;IAC1C,oCAAoC,EAAE,CAAC,KAAK,CAAC;IAC7C,sCAAsC,EAAE,CAAC,KAAK,CAAC;CAChD,CAAC;AAgCF,MAAM,UAAU,YAAY,CAC1B,QAYuD;IAQvD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAC1D,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,WAAW,
|
|
1
|
+
{"version":3,"file":"isUnexpected.js","sourceRoot":"","sources":["../../../src/generated/isUnexpected.ts"],"names":[],"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YAC3C,IAAI,cAAc,CAAC,CAAC,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvC,KAAK,GAAG,KAAK,CAAC;gBACd,MAAM;YACR,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,sEAAsE;QACtE,IAAI,KAAK,IAAI,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;YAC/C,UAAU,GAAG,aAAa,CAAC,MAAM,CAAC;YAClC,YAAY,GAAG,KAAK,CAAC;QACvB,CAAC;IACH,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,iBAAiB,CAAC,MAAc;IACvC,MAAM,SAAS,GAAG,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACtC,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AACjC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n TimeZoneGetTimeZoneByID200Response,\n TimeZoneGetTimeZoneByIDDefaultResponse,\n TimeZoneGetTimeZoneByCoordinates200Response,\n TimeZoneGetTimeZoneByCoordinatesDefaultResponse,\n TimeZoneGetWindowsTimezoneIds200Response,\n TimeZoneGetWindowsTimezoneIdsDefaultResponse,\n TimeZoneGetIanaTimezoneIds200Response,\n TimeZoneGetIanaTimezoneIdsDefaultResponse,\n TimeZoneGetIanaVersion200Response,\n TimeZoneGetIanaVersionDefaultResponse,\n TimeZoneConvertWindowsTimezoneToIana200Response,\n TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n} from \"./responses.js\";\n\nconst responseMap: Record<string, string[]> = {\n \"GET /timezone/byId/{format}\": [\"200\"],\n \"GET /timezone/byCoordinates/{format}\": [\"200\"],\n \"GET /timezone/enumWindows/{format}\": [\"200\"],\n \"GET /timezone/enumIana/{format}\": [\"200\"],\n \"GET /timezone/ianaVersion/{format}\": [\"200\"],\n \"GET /timezone/windowsToIana/{format}\": [\"200\"],\n};\n\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByID200Response\n | TimeZoneGetTimeZoneByIDDefaultResponse,\n): response is TimeZoneGetTimeZoneByIDDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByCoordinates200Response\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse,\n): response is TimeZoneGetTimeZoneByCoordinatesDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetWindowsTimezoneIds200Response\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse,\n): response is TimeZoneGetWindowsTimezoneIdsDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetIanaTimezoneIds200Response\n | TimeZoneGetIanaTimezoneIdsDefaultResponse,\n): response is TimeZoneGetIanaTimezoneIdsDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetIanaVersion200Response\n | TimeZoneGetIanaVersionDefaultResponse,\n): response is TimeZoneGetIanaVersionDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneConvertWindowsTimezoneToIana200Response\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n): response is TimeZoneConvertWindowsTimezoneToIanaDefaultResponse;\nexport function isUnexpected(\n response:\n | TimeZoneGetTimeZoneByID200Response\n | TimeZoneGetTimeZoneByIDDefaultResponse\n | TimeZoneGetTimeZoneByCoordinates200Response\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse\n | TimeZoneGetWindowsTimezoneIds200Response\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse\n | TimeZoneGetIanaTimezoneIds200Response\n | TimeZoneGetIanaTimezoneIdsDefaultResponse\n | TimeZoneGetIanaVersion200Response\n | TimeZoneGetIanaVersionDefaultResponse\n | TimeZoneConvertWindowsTimezoneToIana200Response\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse,\n): response is\n | TimeZoneGetTimeZoneByIDDefaultResponse\n | TimeZoneGetTimeZoneByCoordinatesDefaultResponse\n | TimeZoneGetWindowsTimezoneIdsDefaultResponse\n | TimeZoneGetIanaTimezoneIdsDefaultResponse\n | TimeZoneGetIanaVersionDefaultResponse\n | TimeZoneConvertWindowsTimezoneToIanaDefaultResponse {\n const lroOriginal = response.headers[\"x-ms-original-url\"];\n const url = new URL(lroOriginal ?? response.request.url);\n const method = response.request.method;\n let pathDetails = responseMap[`${method} ${url.pathname}`];\n if (!pathDetails) {\n pathDetails = getParametrizedPathSuccess(method, url.pathname);\n }\n return !pathDetails.includes(response.status);\n}\n\nfunction getParametrizedPathSuccess(method: string, path: string): string[] {\n const pathParts = path.split(\"/\");\n\n // Traverse list to match the longest candidate\n // matchedLen: the length of candidate path\n // matchedValue: the matched status code array\n let matchedLen = -1,\n matchedValue: string[] = [];\n\n // Iterate the responseMap to find a match\n for (const [key, value] of Object.entries(responseMap)) {\n // Extracting the path from the map key which is in format\n // GET /path/foo\n if (!key.startsWith(method)) {\n continue;\n }\n const candidatePath = getPathFromMapKey(key);\n // Get each part of the url path\n const candidateParts = candidatePath.split(\"/\");\n\n // track if we have found a match to return the values found.\n let found = true;\n for (\n let i = candidateParts.length - 1, j = pathParts.length - 1;\n i >= 1 && j >= 1;\n i--, j--\n ) {\n if (\n candidateParts[i]?.startsWith(\"{\") &&\n candidateParts[i]?.indexOf(\"}\") !== -1\n ) {\n const start = candidateParts[i]!.indexOf(\"}\") + 1,\n end = candidateParts[i]?.length;\n // If the current part of the candidate is a \"template\" part\n // Try to use the suffix of pattern to match the path\n // {guid} ==> $\n // {guid}:export ==> :export$\n const isMatched = new RegExp(\n `${candidateParts[i]?.slice(start, end)}`,\n ).test(pathParts[j] || \"\");\n\n if (!isMatched) {\n found = false;\n break;\n }\n continue;\n }\n\n // If the candidate part is not a template and\n // the parts don't match mark the candidate as not found\n // to move on with the next candidate path.\n if (candidateParts[i] !== pathParts[j]) {\n found = false;\n break;\n }\n }\n\n // We finished evaluating the current candidate parts\n // Update the matched value if and only if we found the longer pattern\n if (found && candidatePath.length > matchedLen) {\n matchedLen = candidatePath.length;\n matchedValue = value;\n }\n }\n\n return matchedValue;\n}\n\nfunction getPathFromMapKey(mapKey: string): string {\n const pathStart = mapKey.indexOf(\"/\");\n return mapKey.slice(pathStart);\n}\n"]}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// Copyright (c) Microsoft Corporation.
|
|
2
2
|
// Licensed under the MIT License.
|
|
3
|
-
import { __rest } from "tslib";
|
|
4
3
|
import { getClient } from "@azure-rest/core-client";
|
|
5
4
|
import { logger } from "./logger.js";
|
|
6
5
|
/**
|
|
@@ -8,21 +7,24 @@ import { logger } from "./logger.js";
|
|
|
8
7
|
* @param credentials - uniquely identify client credential
|
|
9
8
|
* @param options - the parameter for all optional parameters
|
|
10
9
|
*/
|
|
11
|
-
export default function createClient(credentials,
|
|
12
|
-
|
|
13
|
-
var { apiVersion = "1.0" } = _a, options = __rest(_a, ["apiVersion"]);
|
|
14
|
-
const endpointUrl = (_c = (_b = options.endpoint) !== null && _b !== void 0 ? _b : options.baseUrl) !== null && _c !== void 0 ? _c : `https://atlas.microsoft.com`;
|
|
10
|
+
export default function createClient(credentials, { apiVersion = "1.0", ...options } = {}) {
|
|
11
|
+
const endpointUrl = options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;
|
|
15
12
|
const userAgentInfo = `azsdk-js-maps-timezone-rest/1.0.0-beta.1`;
|
|
16
13
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
17
14
|
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
|
18
15
|
: `${userAgentInfo}`;
|
|
19
|
-
options =
|
|
16
|
+
options = {
|
|
17
|
+
...options,
|
|
18
|
+
userAgentOptions: {
|
|
20
19
|
userAgentPrefix,
|
|
21
|
-
},
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
},
|
|
21
|
+
loggingOptions: {
|
|
22
|
+
logger: options.loggingOptions?.logger ?? logger.info,
|
|
23
|
+
},
|
|
24
|
+
credentials: {
|
|
25
|
+
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "subscription-key",
|
|
26
|
+
},
|
|
27
|
+
};
|
|
26
28
|
const client = getClient(endpointUrl, credentials, options);
|
|
27
29
|
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
|
|
28
30
|
client.pipeline.addPolicy({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mapsTimeZoneClient.js","sourceRoot":"","sources":["../../../src/generated/mapsTimeZoneClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC
|
|
1
|
+
{"version":3,"file":"mapsTimeZoneClient.js","sourceRoot":"","sources":["../../../src/generated/mapsTimeZoneClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAiB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAClC,WAA0B,EAC1B,EAAE,UAAU,GAAG,KAAK,EAAE,GAAG,OAAO,KAAgC,EAAE;IAElE,MAAM,WAAW,GACf,OAAO,CAAC,QAAQ,IAAI,OAAO,CAAC,OAAO,IAAI,6BAA6B,CAAC;IACvE,MAAM,aAAa,GAAG,0CAA0C,CAAC;IACjE,MAAM,eAAe,GACnB,OAAO,CAAC,gBAAgB,IAAI,OAAO,CAAC,gBAAgB,CAAC,eAAe;QAClE,CAAC,CAAC,GAAG,OAAO,CAAC,gBAAgB,CAAC,eAAe,IAAI,aAAa,EAAE;QAChE,CAAC,CAAC,GAAG,aAAa,EAAE,CAAC;IACzB,OAAO,GAAG;QACR,GAAG,OAAO;QACV,gBAAgB,EAAE;YAChB,eAAe;SAChB;QACD,cAAc,EAAE;YACd,MAAM,EAAE,OAAO,CAAC,cAAc,EAAE,MAAM,IAAI,MAAM,CAAC,IAAI;SACtD;QACD,WAAW,EAAE;YACX,gBAAgB,EACd,OAAO,CAAC,WAAW,EAAE,gBAAgB,IAAI,kBAAkB;SAC9D;KACF,CAAC;IACF,MAAM,MAAM,GAAG,SAAS,CACtB,WAAW,EACX,WAAW,EACX,OAAO,CACc,CAAC;IAExB,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,CAAC,CAAC;IAC3D,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;QACxB,IAAI,EAAE,wBAAwB;QAC9B,WAAW,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACzB,qDAAqD;YACrD,yEAAyE;YACzE,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC7B,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,UAAU,EAAE,CAAC;gBACvD,GAAG,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,GAAG,GAClB,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GACzD,eAAe,UAAU,EAAE,CAAC;YAC9B,CAAC;YAED,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC;QACnB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { getClient, ClientOptions } from \"@azure-rest/core-client\";\nimport { logger } from \"./logger.js\";\nimport { KeyCredential } from \"@azure/core-auth\";\nimport { MapsTimeZoneClient } from \"./clientDefinitions.js\";\n\n/** The optional parameters for the client */\nexport interface MapsTimeZoneClientOptions extends ClientOptions {\n /** The api version option of the client */\n apiVersion?: string;\n}\n\n/**\n * Initialize a new instance of `MapsTimeZoneClient`\n * @param credentials - uniquely identify client credential\n * @param options - the parameter for all optional parameters\n */\nexport default function createClient(\n credentials: KeyCredential,\n { apiVersion = \"1.0\", ...options }: MapsTimeZoneClientOptions = {},\n): MapsTimeZoneClient {\n const endpointUrl =\n options.endpoint ?? options.baseUrl ?? `https://atlas.microsoft.com`;\n const userAgentInfo = `azsdk-js-maps-timezone-rest/1.0.0-beta.1`;\n const userAgentPrefix =\n options.userAgentOptions && options.userAgentOptions.userAgentPrefix\n ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`\n : `${userAgentInfo}`;\n options = {\n ...options,\n userAgentOptions: {\n userAgentPrefix,\n },\n loggingOptions: {\n logger: options.loggingOptions?.logger ?? logger.info,\n },\n credentials: {\n apiKeyHeaderName:\n options.credentials?.apiKeyHeaderName ?? \"subscription-key\",\n },\n };\n const client = getClient(\n endpointUrl,\n credentials,\n options,\n ) as MapsTimeZoneClient;\n\n client.pipeline.removePolicy({ name: \"ApiVersionPolicy\" });\n client.pipeline.addPolicy({\n name: \"ClientApiVersionPolicy\",\n sendRequest: (req, next) => {\n // Use the apiVersion defined in request url directly\n // Append one if there is no apiVersion and we have one at client options\n const url = new URL(req.url);\n if (!url.searchParams.get(\"api-version\") && apiVersion) {\n req.url = `${req.url}${\n Array.from(url.searchParams.keys()).length > 0 ? \"&\" : \"?\"\n }api-version=${apiVersion}`;\n }\n\n return next(req);\n },\n });\n\n return client;\n}\n"]}
|