@azure-tools/rlc-common
Advanced tools
Comparing version 1.0.0-alpha.8.20230206.1 to 1.0.0-alpha.9.20230209.1
{ | ||
"files": { | ||
"packages/rlc-common/.rush/temp/shrinkwrap-deps.json": "cd279a89e927dc2cd7032cabe2d295ac13b304aa", | ||
"packages/rlc-common/.rush/temp/shrinkwrap-deps.json": "b562e73bfe5ba62f508baab0dff64e315c76fb89", | ||
"packages/rlc-common/.eslintrc.json": "9fa7b6e2fbe4e63955031b8f8556b51c0a16a46b", | ||
"packages/rlc-common/.prettierignore": "0f7a61c11bf3ac442a984b1136525710e0ebf6d3", | ||
"packages/rlc-common/.prettierrc": "83e03202b2f3ad5b8df166a965fea698eccb0f90", | ||
"packages/rlc-common/CHANGELOG.md": "e8baef79074dec770e997c63b63cb723482ba776", | ||
"packages/rlc-common/CHANGELOG.md": "7a343d645c31018412d3ac3c5e99371005553fbb", | ||
"packages/rlc-common/CONTRIBUTING.md": "e49bf8e171df33db3fbd8fde003be18e1b85c412", | ||
"packages/rlc-common/README.md": "4089f33033d3351a176a9d9c6dcaff93cbe9514d", | ||
"packages/rlc-common/package.json": "e06f3b9b1ffade94a0d4d4e5955c25552751276c", | ||
"packages/rlc-common/package.json": "303efa2614cd945ed5dbbd172e5a3630065cee06", | ||
"packages/rlc-common/publishPackage.js": "3512e26d1199937b1962f3b4189aa9c506d9da1a", | ||
"packages/rlc-common/src/buildClient.ts": "0c3122bc6173af28da228d42b663f8cf7e3365af", | ||
"packages/rlc-common/src/buildClient.ts": "7e90e7f20d3922e280873f16e451bb740696a996", | ||
"packages/rlc-common/src/buildClientDefinitions.ts": "9b497bd2683f45fb342f3d92ad885c8eed1576d8", | ||
@@ -24,14 +24,15 @@ "packages/rlc-common/src/buildIndexFile.ts": "57aff1232f84386e5d767b06991a05cb68ee3baf", | ||
"packages/rlc-common/src/buildSerializeHelper.ts": "cffee1e51b2abda13e7adaf113f3d39a09ef29a1", | ||
"packages/rlc-common/src/buildTopLevelIndexFile.ts": "7b52fdcafbff1559427c5545694fab02859c6098", | ||
"packages/rlc-common/src/buildTopLevelIndexFile.ts": "1169845076e1790a342d966b3b6c9d0d7658df85", | ||
"packages/rlc-common/src/helpers/nameConstructors.ts": "12ac7b5f39f469b4943b2e12513a2c909650090c", | ||
"packages/rlc-common/src/helpers/nameUtils.ts": "bf86e9989a525846deee1389602a42f33bf525f6", | ||
"packages/rlc-common/src/helpers/operationHelpers.ts": "d7ab38d9e825c0bc250df5ccf792ae01a13ae726", | ||
"packages/rlc-common/src/helpers/pathUtils.ts": "d40fc3a769ccf68ae2ca6a52889dbfe8e61a5c98", | ||
"packages/rlc-common/src/helpers/schemaHelpers.ts": "722c52837218b8cfafdc36fe29e675e0df4acb09", | ||
"packages/rlc-common/src/helpers/shortcutMethods.ts": "cd52b21e05192c7b3fce3ff26eae2ac03ab62679", | ||
"packages/rlc-common/src/index.ts": "ac8a63842d5c0868349eff11e54f7c444be28820", | ||
"packages/rlc-common/src/interfaces.ts": "bbb852c740227e3779c04ea527ba6c138d8d286d", | ||
"packages/rlc-common/src/interfaces.ts": "ab603924545087f984b15a47935ef96a16ff0514", | ||
"packages/rlc-common/src/metadata/buildApiExtractorConfig.ts": "4bcc63b3551d923d2881adb015b23978a2539e14", | ||
"packages/rlc-common/src/metadata/buildESLintConfig.ts": "b0530cba08bf5e29cc1d307b93363f66c1e6b81d", | ||
"packages/rlc-common/src/metadata/buildLicenseFile.ts": "ce4083770e48d3b0dd670f7efc324a7fed10dac4", | ||
"packages/rlc-common/src/metadata/buildPackageFile.ts": "6b06070d1ce36719feb2ccaefd87d232306429b9", | ||
"packages/rlc-common/src/metadata/buildPackageFile.ts": "d2fbb2659415032de55b044a5ad019eec19109e9", | ||
"packages/rlc-common/src/metadata/buildReadmeFile.ts": "649510f75d04ba8438202b92b83a56d3d3206efe", | ||
@@ -41,3 +42,3 @@ "packages/rlc-common/src/metadata/buildRollupConfig.ts": "56a0ac2b69266d8a3192981abc4c09fcde444634", | ||
"packages/rlc-common/src/static/paginateContent.ts": "48f146c05b7b803958dc1206680b7b6ce38010c5", | ||
"packages/rlc-common/src/static/pollingContent.ts": "c71c7c1b5916b44d4b7ac1a57b3bcdd77bf62a8b", | ||
"packages/rlc-common/src/static/pollingContent.ts": "1cf63416f9be4716167301dd29c5e913f19bad23", | ||
"packages/rlc-common/src/static/serializeHelper.ts": "0ddb576015992208f824f0f06f5c5e7de019c26e", | ||
@@ -44,0 +45,0 @@ "packages/rlc-common/src/test/buildEnvFile.ts": "4759b68f0216d2e060810b045baf47b6d5ecf849", |
@@ -20,6 +20,6 @@ { | ||
"@types/lodash@4.14.191": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", | ||
"@types/node@18.11.18": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==", | ||
"acorn-jsx@5.3.2_acorn@8.8.1": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", | ||
"@types/node@18.13.0": "sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==", | ||
"acorn-jsx@5.3.2_acorn@8.8.2": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", | ||
"acorn-walk@8.2.0": "sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA==", | ||
"acorn@8.8.1": "sha512-7zFpHzhnqYKrkYdUjF1HI1bzd0VygEGX8lFk4k5zVMqHEoES+P+7TKI+EvLO9WVMJ8eekdO0aDEK044xTXwPPA==", | ||
"acorn@8.8.2": "sha512-xjIYgE8HBrkpd/sJqOGNspf8uHG+NOHGOw6a/Urj8taM2EXfdNAH2oFcPeIFfsv3+kz/mJrS5VuMqbNLjCa2vw==", | ||
"ajv@6.12.6": "sha512-j3fVLgvTo527anyYyJOGTYJbG+vnnQYvE0m5mmkc1TK+nxAppkCLMIL0aZ4dblVCNoGShhm+kzE4ZUykBoMg4g==", | ||
@@ -48,6 +48,6 @@ "ansi-regex@5.0.1": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", | ||
"eslint-scope@7.1.1": "sha512-QKQM/UXpIiHcLqJ5AOyIW7XZmzjkzQXYE54n1++wb0u9V/abW3l9uQnxX8Z5Xd18xyKIMTUAyQ0k1e8pz6LUrw==", | ||
"eslint-utils@3.0.0_eslint@8.31.0": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", | ||
"eslint-utils@3.0.0_eslint@8.33.0": "sha512-uuQC43IGctw68pJA1RgbQS8/NP7rch6Cwd4j3ZBtgo4/8Flj4eGE7ZYSZRN3iq5pVUv6GPdW5Z1RFleo84uLDA==", | ||
"eslint-visitor-keys@2.1.0": "sha512-0rSmRBzXgDzIsD6mGdJgevzgezI534Cer5L/vyMX0kHzT/jiB43jRhd9YUlMGYLQy2zprNmoT8qasCGtY+QaKw==", | ||
"eslint-visitor-keys@3.3.0": "sha512-mQ+suqKJVyeuwGYHAdjMFqjCyfl8+Ldnxuyp3ldiMBFKkvytrXUZWaiPCEav8qDHKty44bD+qV1IP4T+w+xXRA==", | ||
"eslint@8.31.0": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==", | ||
"eslint@8.33.0": "sha512-WjOpFQgKK8VrCnAtl8We0SUOy/oVZ5NHykyMiagV1M9r8IFpIJX7DduK6n1mpfhlG7T1NLWm2SuD8QB7KFySaA==", | ||
"espree@9.4.1": "sha512-XwctdmTO6SIvCzd9810yyNzIrOrqNYV9Koizx4C/mRhf9uq0o4yHoCEU/670pOxOL/MSraektvSAji79kX90Vg==", | ||
@@ -73,3 +73,3 @@ "esquery@1.4.0": "sha512-cCDispWt5vHHtwMY2YrAQ4ibFkAL8RbH5YGBnZBc90MolvvfkkQcJro/aZiAQUlQ3qgrYS6D6v8Gc5G5CQsc9w==", | ||
"glob@7.2.3": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", | ||
"globals@13.19.0": "sha512-dkQ957uSRWHw7CFXLUtUHQI3g3aWApYhfNR2O6jn/907riyTYKVBmxYVROkBcY614FSSeSJh7Xm7SrUWCxvJMQ==", | ||
"globals@13.20.0": "sha512-Qg5QtVkCy/kv3FUSlu4ukeZDVf9ee0iXLAUYX13gbR17bnejFTzr4iS9bY7kwCf1NztRNm1t91fjOiyx4CSwPQ==", | ||
"graceful-fs@4.2.10": "sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==", | ||
@@ -89,3 +89,3 @@ "grapheme-splitter@1.0.4": "sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==", | ||
"isexe@2.0.0": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", | ||
"js-sdsl@4.2.0": "sha512-dyBIzQBDkCqCu+0upx25Y2jGdbTGxE9fshMsCdK0ViOongpV+n5tXRcZY9v7CaVQ79AGS9KA1KHtojxiM7aXSQ==", | ||
"js-sdsl@4.3.0": "sha512-mifzlm2+5nZ+lEcLJMoBK0/IH/bDg8XnJfd/Wq6IP+xoCjLZsTOnV2QpxlVbX9bMnkl5PdEjNtBJ9Cj1NjifhQ==", | ||
"js-yaml@4.1.0": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", | ||
@@ -103,3 +103,3 @@ "json-schema-traverse@0.4.1": "sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg==", | ||
"minimatch@3.1.2": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==", | ||
"minimatch@5.1.2": "sha512-bNH9mmM9qsJ2X4r2Nat1B//1dJVcn3+iBLa3IgqJ7EbGaDNepL9QSHOxN4ng33s52VMMhhIfgCYDk3C4ZmlDAg==", | ||
"minimatch@5.1.6": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", | ||
"minimist@1.2.7": "sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==", | ||
@@ -122,3 +122,3 @@ "mkdirp@1.0.4": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", | ||
"prettier@2.7.1": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", | ||
"punycode@2.2.0": "sha512-LN6QV1IJ9ZhxWTNdktaPClrNfp8xdSAYS0Zk2ddX7XsXZAxckMHPCBcHRo0cTcEIgYPRiGEkmji3Idkh2yFtYw==", | ||
"punycode@2.3.0": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", | ||
"queue-microtask@1.2.3": "sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==", | ||
@@ -139,3 +139,3 @@ "regexpp@3.2.0": "sha512-pq2bWo9mVD43nbts2wGv17XLiNLya+GklZ8kaDLV2Z08gDCsGpnKn9BFMepvWuHCbyVvY7J5o5+BVvoQbmlJLg==", | ||
"ts-morph@15.1.0": "sha512-RBsGE2sDzUXFTnv8Ba22QfeuKbgvAGJFuTN7HfmIRUkgT/NaVLfDM/8OFm2NlFkGlWEXdpW5OaFIp1jvqdDuOg==", | ||
"ts-node@10.9.1_ac04029d3cbd63a6e54d5c46a5abbdcb": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", | ||
"ts-node@10.9.1_ef29c9bcf41a251d679e24d73fe3f731": "sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw==", | ||
"type-check@0.4.0": "sha512-XleUoc9uwGXqjWwXaUTZAmzMcFZ5858QA2vvx1Ur5xIcixXIP+8LnFDgRplU30us6teqdlskFfu+ae4K79Ooew==", | ||
@@ -142,0 +142,0 @@ "type-fest@0.20.2": "sha512-Ne+eE4r0/iWnpAxD852z3A+N0Bt5RN//NjJwRd2VFHEmrywxf5vsZlh4R6lixl6B+wz/8d+maTSAkN1FIkI3LQ==", |
@@ -0,1 +1,8 @@ | ||
## 1.0.0-beta.9 (2023-02-06) | ||
- [Feature] Upgrade core-lro to 2.5.x, Please refer to pr [#1586](https://github.com/Azure/autorest.typescript/pull/1586). | ||
- [Feature] Support collection format, Please refer to pr [#1740](https://github.com/Azure/autorest.typescript/pull/1740). | ||
- [Feature] Support cadl compiler 0.39.0, Please refer to pr [#1732](https://github.com/Azure/autorest.typescript/pull/1732). | ||
- [Feature] Upgrade prettier version in the package.json, Please refer to pr [#1741](https://github.com/Azure/autorest.typescript/pull/1741). | ||
## 1.0.0-beta.8 (2023-01-09) | ||
@@ -2,0 +9,0 @@ |
@@ -64,20 +64,31 @@ // Copyright (c) Microsoft Corporation. | ||
? [] | ||
: [{ name: "credentials", type: credentialTypes.join(" | ") }]) | ||
: [ | ||
{ | ||
name: "credentials", | ||
type: credentialTypes.join(" | "), | ||
description: `uniquely identify client credential` | ||
} | ||
]) | ||
]; | ||
const allClientParams = [ | ||
...commonClientParams, | ||
{ | ||
name: "options", | ||
type: `${clientOptionsInterface?.name ?? "ClientOptions"} = {}`, | ||
description: "the parameter for all optional parameters" | ||
} | ||
]; | ||
const functionStatement = { | ||
isExported: true, | ||
name: `createClient`, | ||
parameters: [ | ||
...commonClientParams, | ||
{ | ||
name: "options", | ||
type: `${clientOptionsInterface?.name ?? "ClientOptions"} = {}` | ||
} | ||
], | ||
parameters: allClientParams, | ||
docs: [ | ||
{ | ||
description: `Initialize a new instance of the class ${clientInterfaceName} class. \n` + | ||
commonClientParams | ||
description: `Initialize a new instance of \`${clientInterfaceName}\` \n` + | ||
allClientParams | ||
.map((param) => { | ||
return `@param ${param.name} type: ${param.type} ${param.description ?? ""}`; | ||
return `@param ${param.name} type: ${param.type | ||
.split("=")[0] | ||
.split(" ") | ||
.join("")}, ${param.description ?? "The parameter " + param.name}`; | ||
}) | ||
@@ -84,0 +95,0 @@ .join("\n") |
@@ -6,2 +6,3 @@ // Copyright (c) Microsoft Corporation. | ||
import * as path from "path"; | ||
import { getRelativePartFromSrcPath } from "./helpers/pathUtils.js"; | ||
const batchOutputFolder = []; | ||
@@ -18,3 +19,3 @@ export function buildTopLevelIndex(model) { | ||
const moduleName = normalizeName(clientName, NameType.File); | ||
const relativePath = "." + srcPath.substring(srcPath.indexOf("/src/") + 4); | ||
const relativePath = "./" + getRelativePartFromSrcPath(srcPath); | ||
batchOutputFolder.push([relativePath, clientName, moduleName]); | ||
@@ -41,3 +42,3 @@ } | ||
const content = indexFile.getFullText(); | ||
const filePath = path.join(srcPath.substring(0, srcPath.indexOf("/src/") + 5), `index.ts`); | ||
const filePath = path.join(srcPath.substring(0, srcPath.indexOf(path.sep + "src") + 4), `index.ts`); | ||
return { path: filePath, content }; | ||
@@ -44,0 +45,0 @@ } |
// Copyright (c) Microsoft Corporation. | ||
// Licensed under the MIT License. | ||
import { Project } from "ts-morph"; | ||
import { NameType, normalizeName } from "../helpers/nameUtils.js"; | ||
import { hasPagingOperations, hasPollingOperations } from "../helpers/operationHelpers.js"; | ||
import { getRelativePartFromSrcPath } from "../helpers/pathUtils.js"; | ||
let hasPaging = false; | ||
let hasLRO = false; | ||
let clientFilePaths = []; | ||
export function buildPackageFile(model, hasSamplesGenerated = false) { | ||
@@ -35,3 +38,12 @@ const generateMetadata = Boolean(model.options?.generateMetadata); | ||
} | ||
const { packageDetails, generateTest, generateSample, azureOutputDirectory, azureSdkForJs, isCadlTest } = model.options; | ||
clientFilePaths.push(getClientFilePath(model)); | ||
hasPaging = hasPaging || hasPagingOperations(model); | ||
hasLRO = hasLRO || hasPollingOperations(model); | ||
const { packageDetails, generateTest, generateSample, azureOutputDirectory, azureSdkForJs, isCadlTest, sourceFrom, multiClient, batch } = model.options; | ||
if (multiClient && | ||
batch && | ||
batch.length > 1 && | ||
clientFilePaths.length < batch.length) { | ||
return; | ||
} | ||
const clientPackageName = packageDetails.name; | ||
@@ -42,4 +54,2 @@ let apiRefUrlQueryParameter = ""; | ||
} | ||
hasPaging = hasPaging || hasPagingOperations(model); | ||
hasLRO = hasLRO || hasPollingOperations(model); | ||
const packageInfo = { | ||
@@ -84,3 +94,5 @@ name: `${packageDetails.name}`, | ||
format: `prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore "src/**/*.ts" "*.{js,json}" ${appendPathWhenFormat(generateTest, generateSample)}`, | ||
"generate:client": "autorest --typescript swagger/README.md && npm run format", | ||
"generate:client": sourceFrom === "Swagger" | ||
? "autorest --typescript swagger/README.md && npm run format" | ||
: "echo skipped", | ||
"integration-test:browser": "echo skipped", | ||
@@ -133,9 +145,17 @@ "integration-test:node": "echo skipped", | ||
packageInfo["//metadata"] = { | ||
constantPaths: [ | ||
{ | ||
path: "swagger/README.md", | ||
prefix: "package-version" | ||
} | ||
] | ||
constantPaths: [] | ||
}; | ||
clientFilePaths.forEach((path) => { | ||
packageInfo["//metadata"].constantPaths.push({ | ||
path, | ||
prefix: "userAgentInfo" | ||
}); | ||
}); | ||
// Only generate this from Swagger spec | ||
if (sourceFrom === "Swagger") { | ||
packageInfo["//metadata"].constantPaths.push({ | ||
path: "swagger/README.md", | ||
prefix: "package-version" | ||
}); | ||
} | ||
packageInfo.scripts["build"] = | ||
@@ -154,3 +174,3 @@ "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local"; | ||
packageInfo.scripts["minify"] = `uglifyjs -c -m --comments --source-map "content='./dist/index.js.map'" -o ./dist/index.min.js ./dist/index.js`; | ||
packageInfo.devDependencies["@rollup/plugin-commonjs"] = "^21.0.1"; | ||
packageInfo.devDependencies["@rollup/plugin-commonjs"] = "^24.0.0"; | ||
packageInfo.devDependencies["@rollup/plugin-json"] = "^4.1.0"; | ||
@@ -253,2 +273,10 @@ packageInfo.devDependencies["@rollup/plugin-multi-entry"] = "^4.1.0"; | ||
} | ||
function getClientFilePath(model) { | ||
const { srcPath } = model; | ||
const sdkReletivePart = getRelativePartFromSrcPath(srcPath); | ||
const clientFilename = normalizeName(model.libraryName, NameType.File); | ||
return sdkReletivePart | ||
? `src/${sdkReletivePart}/${clientFilename}.ts` | ||
: `src/${clientFilename}.ts`; | ||
} | ||
//# sourceMappingURL=buildPackageFile.js.map |
@@ -1,1 +0,1 @@ | ||
{"name":"@azure-tools/rlc-common","version":"1.0.0-beta.8","description":"","type":"module","main":"dist/index.js","module":"dist-esm/index.js","exports":{".":{"types":"./types/index.d.ts","require":"./dist/index.js","import":"./dist-esm/index.js"}},"types":"./types/index.d.ts","scripts":{"lint":"eslint src --ext .ts --max-warnings=0","lint:fix":"eslint src --fix --ext .ts","format":"npm run -s prettier -- --write","check-format":"npm run prettier -- --check","prettier":"prettier --config ./.prettierrc src/**/*.ts","build":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node publishPackage.js","build:cjs":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig-cjs.json && node publishPackage.js","build:esm":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && node publishPackage.js","test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","dependencies":{"ts-morph":"^15.1.0","lodash":"^4.17.21","handlebars":"^4.7.7"},"devDependencies":{"@types/node":"^18.0.0","eslint":"^8.9.0","prettier":"~2.7.1","typescript":"~4.8.0","rimraf":"^3.0.2","@types/lodash":"^4.14.182","fs-extra":"^10.0.0","@types/fs-extra":"^8.1.0","ts-node":"^10.7.0"}} | ||
{"name":"@azure-tools/rlc-common","version":"1.0.0-beta.9","description":"","type":"module","main":"dist/index.js","module":"dist-esm/index.js","exports":{".":{"types":"./types/index.d.ts","require":"./dist/index.js","import":"./dist-esm/index.js"}},"types":"./types/index.d.ts","scripts":{"lint":"eslint src --ext .ts --max-warnings=0","lint:fix":"eslint src --fix --ext .ts","format":"npm run -s prettier -- --write","check-format":"npm run prettier -- --check","prettier":"prettier --config ./.prettierrc src/**/*.ts","build":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node publishPackage.js","build:cjs":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig-cjs.json && node publishPackage.js","build:esm":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && node publishPackage.js","test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","dependencies":{"ts-morph":"^15.1.0","lodash":"^4.17.21","handlebars":"^4.7.7"},"devDependencies":{"@types/node":"^18.0.0","eslint":"^8.9.0","prettier":"~2.7.1","typescript":"~4.8.0","rimraf":"^3.0.2","@types/lodash":"^4.14.182","fs-extra":"^10.0.0","@types/fs-extra":"^8.1.0","ts-node":"^10.7.0"}} |
@@ -66,2 +66,3 @@ export const pollingContent = ` | ||
{{else}} | ||
options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; | ||
return await createHttpPoller(poller, options); | ||
@@ -68,0 +69,0 @@ {{/if}} |
@@ -68,21 +68,32 @@ "use strict"; | ||
? [] | ||
: [{ name: "credentials", type: credentialTypes.join(" | ") }]) | ||
: [ | ||
{ | ||
name: "credentials", | ||
type: credentialTypes.join(" | "), | ||
description: `uniquely identify client credential` | ||
} | ||
]) | ||
]; | ||
const allClientParams = [ | ||
...commonClientParams, | ||
{ | ||
name: "options", | ||
type: `${(_e = clientOptionsInterface === null || clientOptionsInterface === void 0 ? void 0 : clientOptionsInterface.name) !== null && _e !== void 0 ? _e : "ClientOptions"} = {}`, | ||
description: "the parameter for all optional parameters" | ||
} | ||
]; | ||
const functionStatement = { | ||
isExported: true, | ||
name: `createClient`, | ||
parameters: [ | ||
...commonClientParams, | ||
{ | ||
name: "options", | ||
type: `${(_e = clientOptionsInterface === null || clientOptionsInterface === void 0 ? void 0 : clientOptionsInterface.name) !== null && _e !== void 0 ? _e : "ClientOptions"} = {}` | ||
} | ||
], | ||
parameters: allClientParams, | ||
docs: [ | ||
{ | ||
description: `Initialize a new instance of the class ${clientInterfaceName} class. \n` + | ||
commonClientParams | ||
description: `Initialize a new instance of \`${clientInterfaceName}\` \n` + | ||
allClientParams | ||
.map((param) => { | ||
var _a; | ||
return `@param ${param.name} type: ${param.type} ${(_a = param.description) !== null && _a !== void 0 ? _a : ""}`; | ||
return `@param ${param.name} type: ${param.type | ||
.split("=")[0] | ||
.split(" ") | ||
.join("")}, ${(_a = param.description) !== null && _a !== void 0 ? _a : "The parameter " + param.name}`; | ||
}) | ||
@@ -89,0 +100,0 @@ .join("\n") |
@@ -9,2 +9,3 @@ "use strict"; | ||
const path = require("path"); | ||
const pathUtils_js_1 = require("./helpers/pathUtils.js"); | ||
const batchOutputFolder = []; | ||
@@ -21,3 +22,3 @@ function buildTopLevelIndex(model) { | ||
const moduleName = (0, nameUtils_js_1.normalizeName)(clientName, nameUtils_js_1.NameType.File); | ||
const relativePath = "." + srcPath.substring(srcPath.indexOf("/src/") + 4); | ||
const relativePath = "./" + (0, pathUtils_js_1.getRelativePartFromSrcPath)(srcPath); | ||
batchOutputFolder.push([relativePath, clientName, moduleName]); | ||
@@ -44,3 +45,3 @@ } | ||
const content = indexFile.getFullText(); | ||
const filePath = path.join(srcPath.substring(0, srcPath.indexOf("/src/") + 5), `index.ts`); | ||
const filePath = path.join(srcPath.substring(0, srcPath.indexOf(path.sep + "src") + 4), `index.ts`); | ||
return { path: filePath, content }; | ||
@@ -47,0 +48,0 @@ } |
@@ -7,5 +7,8 @@ "use strict"; | ||
const ts_morph_1 = require("ts-morph"); | ||
const nameUtils_js_1 = require("../helpers/nameUtils.js"); | ||
const operationHelpers_js_1 = require("../helpers/operationHelpers.js"); | ||
const pathUtils_js_1 = require("../helpers/pathUtils.js"); | ||
let hasPaging = false; | ||
let hasLRO = false; | ||
let clientFilePaths = []; | ||
function buildPackageFile(model, hasSamplesGenerated = false) { | ||
@@ -42,3 +45,12 @@ var _a; | ||
} | ||
const { packageDetails, generateTest, generateSample, azureOutputDirectory, azureSdkForJs, isCadlTest } = model.options; | ||
clientFilePaths.push(getClientFilePath(model)); | ||
hasPaging = hasPaging || (0, operationHelpers_js_1.hasPagingOperations)(model); | ||
hasLRO = hasLRO || (0, operationHelpers_js_1.hasPollingOperations)(model); | ||
const { packageDetails, generateTest, generateSample, azureOutputDirectory, azureSdkForJs, isCadlTest, sourceFrom, multiClient, batch } = model.options; | ||
if (multiClient && | ||
batch && | ||
batch.length > 1 && | ||
clientFilePaths.length < batch.length) { | ||
return; | ||
} | ||
const clientPackageName = packageDetails.name; | ||
@@ -49,4 +61,2 @@ let apiRefUrlQueryParameter = ""; | ||
} | ||
hasPaging = hasPaging || (0, operationHelpers_js_1.hasPagingOperations)(model); | ||
hasLRO = hasLRO || (0, operationHelpers_js_1.hasPollingOperations)(model); | ||
const packageInfo = { | ||
@@ -91,3 +101,5 @@ name: `${packageDetails.name}`, | ||
format: `prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore "src/**/*.ts" "*.{js,json}" ${appendPathWhenFormat(generateTest, generateSample)}`, | ||
"generate:client": "autorest --typescript swagger/README.md && npm run format", | ||
"generate:client": sourceFrom === "Swagger" | ||
? "autorest --typescript swagger/README.md && npm run format" | ||
: "echo skipped", | ||
"integration-test:browser": "echo skipped", | ||
@@ -132,9 +144,17 @@ "integration-test:node": "echo skipped", | ||
packageInfo["//metadata"] = { | ||
constantPaths: [ | ||
{ | ||
path: "swagger/README.md", | ||
prefix: "package-version" | ||
} | ||
] | ||
constantPaths: [] | ||
}; | ||
clientFilePaths.forEach((path) => { | ||
packageInfo["//metadata"].constantPaths.push({ | ||
path, | ||
prefix: "userAgentInfo" | ||
}); | ||
}); | ||
// Only generate this from Swagger spec | ||
if (sourceFrom === "Swagger") { | ||
packageInfo["//metadata"].constantPaths.push({ | ||
path: "swagger/README.md", | ||
prefix: "package-version" | ||
}); | ||
} | ||
packageInfo.scripts["build"] = | ||
@@ -153,3 +173,3 @@ "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local"; | ||
packageInfo.scripts["minify"] = `uglifyjs -c -m --comments --source-map "content='./dist/index.js.map'" -o ./dist/index.min.js ./dist/index.js`; | ||
packageInfo.devDependencies["@rollup/plugin-commonjs"] = "^21.0.1"; | ||
packageInfo.devDependencies["@rollup/plugin-commonjs"] = "^24.0.0"; | ||
packageInfo.devDependencies["@rollup/plugin-json"] = "^4.1.0"; | ||
@@ -252,2 +272,10 @@ packageInfo.devDependencies["@rollup/plugin-multi-entry"] = "^4.1.0"; | ||
} | ||
function getClientFilePath(model) { | ||
const { srcPath } = model; | ||
const sdkReletivePart = (0, pathUtils_js_1.getRelativePartFromSrcPath)(srcPath); | ||
const clientFilename = (0, nameUtils_js_1.normalizeName)(model.libraryName, nameUtils_js_1.NameType.File); | ||
return sdkReletivePart | ||
? `src/${sdkReletivePart}/${clientFilename}.ts` | ||
: `src/${clientFilename}.ts`; | ||
} | ||
//# sourceMappingURL=buildPackageFile.js.map |
@@ -1,1 +0,1 @@ | ||
{"name":"@azure-tools/rlc-common","version":"1.0.0-beta.8","description":"","type":"commonjs","main":"dist/index.js","module":"dist-esm/index.js","exports":{".":{"types":"./types/index.d.ts","require":"./dist/index.js","import":"./dist-esm/index.js"}},"types":"./types/index.d.ts","scripts":{"lint":"eslint src --ext .ts --max-warnings=0","lint:fix":"eslint src --fix --ext .ts","format":"npm run -s prettier -- --write","check-format":"npm run prettier -- --check","prettier":"prettier --config ./.prettierrc src/**/*.ts","build":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node publishPackage.js","build:cjs":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig-cjs.json && node publishPackage.js","build:esm":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && node publishPackage.js","test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","dependencies":{"ts-morph":"^15.1.0","lodash":"^4.17.21","handlebars":"^4.7.7"},"devDependencies":{"@types/node":"^18.0.0","eslint":"^8.9.0","prettier":"~2.7.1","typescript":"~4.8.0","rimraf":"^3.0.2","@types/lodash":"^4.14.182","fs-extra":"^10.0.0","@types/fs-extra":"^8.1.0","ts-node":"^10.7.0"}} | ||
{"name":"@azure-tools/rlc-common","version":"1.0.0-beta.9","description":"","type":"commonjs","main":"dist/index.js","module":"dist-esm/index.js","exports":{".":{"types":"./types/index.d.ts","require":"./dist/index.js","import":"./dist-esm/index.js"}},"types":"./types/index.d.ts","scripts":{"lint":"eslint src --ext .ts --max-warnings=0","lint:fix":"eslint src --fix --ext .ts","format":"npm run -s prettier -- --write","check-format":"npm run prettier -- --check","prettier":"prettier --config ./.prettierrc src/**/*.ts","build":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && tsc -p tsconfig-cjs.json && node publishPackage.js","build:cjs":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig-cjs.json && node publishPackage.js","build:esm":"rimraf dist/* dist-esm/* types/* && tsc -p tsconfig.json && node publishPackage.js","test":"echo \"Error: no test specified\" && exit 1"},"keywords":[],"author":"","license":"ISC","dependencies":{"ts-morph":"^15.1.0","lodash":"^4.17.21","handlebars":"^4.7.7"},"devDependencies":{"@types/node":"^18.0.0","eslint":"^8.9.0","prettier":"~2.7.1","typescript":"~4.8.0","rimraf":"^3.0.2","@types/lodash":"^4.14.182","fs-extra":"^10.0.0","@types/fs-extra":"^8.1.0","ts-node":"^10.7.0"}} |
@@ -69,2 +69,3 @@ "use strict"; | ||
{{else}} | ||
options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; | ||
return await createHttpPoller(poller, options); | ||
@@ -71,0 +72,0 @@ {{/if}} |
{ | ||
"name": "@azure-tools/rlc-common", | ||
"version": "1.0.0-alpha.8.20230206.1", | ||
"version": "1.0.0-alpha.9.20230209.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -97,23 +97,34 @@ // Copyright (c) Microsoft Corporation. | ||
? [] | ||
: [{ name: "credentials", type: credentialTypes.join(" | ") }]) | ||
: [ | ||
{ | ||
name: "credentials", | ||
type: credentialTypes.join(" | "), | ||
description: `uniquely identify client credential` | ||
} | ||
]) | ||
]; | ||
const allClientParams = [ | ||
...commonClientParams, | ||
{ | ||
name: "options", | ||
type: `${clientOptionsInterface?.name ?? "ClientOptions"} = {}`, | ||
description: "the parameter for all optional parameters" | ||
} | ||
]; | ||
const functionStatement = { | ||
isExported: true, | ||
name: `createClient`, | ||
parameters: [ | ||
...commonClientParams, | ||
{ | ||
name: "options", | ||
type: `${clientOptionsInterface?.name ?? "ClientOptions"} = {}` | ||
} | ||
], | ||
parameters: allClientParams, | ||
docs: [ | ||
{ | ||
description: | ||
`Initialize a new instance of the class ${clientInterfaceName} class. \n` + | ||
commonClientParams | ||
`Initialize a new instance of \`${clientInterfaceName}\` \n` + | ||
allClientParams | ||
.map((param) => { | ||
return `@param ${param.name} type: ${param.type} ${ | ||
param.description ?? "" | ||
return `@param ${param.name} type: ${param.type | ||
.split("=")[0] | ||
.split(" ") | ||
.join("")}, ${ | ||
param.description ?? "The parameter " + param.name | ||
}`; | ||
@@ -120,0 +131,0 @@ }) |
@@ -8,2 +8,3 @@ // Copyright (c) Microsoft Corporation. | ||
import * as path from "path"; | ||
import { getRelativePartFromSrcPath } from "./helpers/pathUtils.js"; | ||
@@ -22,3 +23,3 @@ const batchOutputFolder: [string, string, string][] = []; | ||
const moduleName = normalizeName(clientName, NameType.File); | ||
const relativePath = "." + srcPath.substring(srcPath.indexOf("/src/") + 4); | ||
const relativePath = "./" + getRelativePartFromSrcPath(srcPath); | ||
batchOutputFolder.push([relativePath, clientName, moduleName]); | ||
@@ -47,5 +48,8 @@ } | ||
const content = indexFile.getFullText(); | ||
const filePath = path.join(srcPath.substring(0, srcPath.indexOf("/src/") + 5), `index.ts`); | ||
const filePath = path.join( | ||
srcPath.substring(0, srcPath.indexOf(path.sep + "src") + 4), | ||
`index.ts` | ||
); | ||
return { path: filePath, content }; | ||
} | ||
} |
@@ -103,2 +103,3 @@ // Copyright (c) Microsoft Corporation. | ||
azureArm?: boolean; | ||
sourceFrom?: "Cadl" | "Swagger"; | ||
} | ||
@@ -105,0 +106,0 @@ |
@@ -5,2 +5,3 @@ // Copyright (c) Microsoft Corporation. | ||
import { Project } from "ts-morph"; | ||
import { NameType, normalizeName } from "../helpers/nameUtils.js"; | ||
import { | ||
@@ -10,2 +11,3 @@ hasPagingOperations, | ||
} from "../helpers/operationHelpers.js"; | ||
import { getRelativePartFromSrcPath } from "../helpers/pathUtils.js"; | ||
import { RLCModel } from "../interfaces.js"; | ||
@@ -15,2 +17,4 @@ | ||
let hasLRO = false; | ||
let clientFilePaths: string[] = []; | ||
export function buildPackageFile(model: RLCModel, hasSamplesGenerated = false) { | ||
@@ -51,2 +55,6 @@ const generateMetadata = Boolean(model.options?.generateMetadata); | ||
clientFilePaths.push(getClientFilePath(model)); | ||
hasPaging = hasPaging || hasPagingOperations(model); | ||
hasLRO = hasLRO || hasPollingOperations(model); | ||
const { | ||
@@ -58,4 +66,15 @@ packageDetails, | ||
azureSdkForJs, | ||
isCadlTest | ||
isCadlTest, | ||
sourceFrom, | ||
multiClient, | ||
batch | ||
} = model.options; | ||
if ( | ||
multiClient && | ||
batch && | ||
batch.length > 1 && | ||
clientFilePaths.length < batch.length | ||
) { | ||
return; | ||
} | ||
@@ -67,4 +86,3 @@ const clientPackageName = packageDetails.name; | ||
} | ||
hasPaging = hasPaging || hasPagingOperations(model); | ||
hasLRO = hasLRO || hasPollingOperations(model); | ||
const packageInfo: Record<string, any> = { | ||
@@ -120,3 +138,5 @@ name: `${packageDetails.name}`, | ||
"generate:client": | ||
"autorest --typescript swagger/README.md && npm run format", | ||
sourceFrom === "Swagger" | ||
? "autorest --typescript swagger/README.md && npm run format" | ||
: "echo skipped", | ||
"integration-test:browser": "echo skipped", | ||
@@ -175,9 +195,17 @@ "integration-test:node": "echo skipped", | ||
packageInfo["//metadata"] = { | ||
constantPaths: [ | ||
{ | ||
path: "swagger/README.md", | ||
prefix: "package-version" | ||
} | ||
] | ||
constantPaths: [] | ||
}; | ||
clientFilePaths.forEach((path) => { | ||
packageInfo["//metadata"].constantPaths.push({ | ||
path, | ||
prefix: "userAgentInfo" | ||
}); | ||
}); | ||
// Only generate this from Swagger spec | ||
if (sourceFrom === "Swagger") { | ||
packageInfo["//metadata"].constantPaths.push({ | ||
path: "swagger/README.md", | ||
prefix: "package-version" | ||
}); | ||
} | ||
packageInfo.scripts["build"] = | ||
@@ -197,3 +225,3 @@ "npm run clean && tsc -p . && dev-tool run bundle && mkdirp ./review && api-extractor run --local"; | ||
] = `uglifyjs -c -m --comments --source-map "content='./dist/index.js.map'" -o ./dist/index.min.js ./dist/index.js`; | ||
packageInfo.devDependencies["@rollup/plugin-commonjs"] = "^21.0.1"; | ||
packageInfo.devDependencies["@rollup/plugin-commonjs"] = "^24.0.0"; | ||
packageInfo.devDependencies["@rollup/plugin-json"] = "^4.1.0"; | ||
@@ -307,1 +335,10 @@ packageInfo.devDependencies["@rollup/plugin-multi-entry"] = "^4.1.0"; | ||
} | ||
function getClientFilePath(model: RLCModel) { | ||
const { srcPath } = model; | ||
const sdkReletivePart = getRelativePartFromSrcPath(srcPath); | ||
const clientFilename = normalizeName(model.libraryName, NameType.File); | ||
return sdkReletivePart | ||
? `src/${sdkReletivePart}/${clientFilename}.ts` | ||
: `src/${clientFilename}.ts`; | ||
} |
@@ -66,2 +66,3 @@ export const pollingContent = ` | ||
{{else}} | ||
options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true; | ||
return await createHttpPoller(poller, options); | ||
@@ -68,0 +69,0 @@ {{/if}} |
@@ -91,2 +91,3 @@ export interface RLCModel { | ||
azureArm?: boolean; | ||
sourceFrom?: "Cadl" | "Swagger"; | ||
} | ||
@@ -93,0 +94,0 @@ export interface ServiceInfo { |
@@ -1,1 +0,1 @@ | ||
export declare const pollingContent = "\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\n{{#if useLegacyLro}}\nimport {\n LongRunningOperation,\n LroEngine,\n LroEngineOptions,\n LroResponse,\n PollerLike,\n PollOperationState\n} from \"@azure/core-lro\";\n{{else}}\nimport {\n CreateHttpPollerOptions,\n LongRunningOperation,\n LroResponse,\n OperationState,\n SimplePollerLike,\n createHttpPoller\n} from \"@azure/core-lro\";\n{{/if}}\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n {{#if useLegacyLro}}\n options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}\n ): PollerLike<PollOperationState<TResult>, TResult> {\n {{else}}\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}\n ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n {{/if}} \n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async path => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n initialResponse.request.url;\n return lroResponse;\n }\n };\n\n {{#if useLegacyLro}}\n return new LroEngine(poller, options);\n {{else}}\n return await createHttpPoller(poller, options);\n {{/if}}\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult\n): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(\n `Status code of the response is not a number. Value: ${response.status}`\n );\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body\n }\n };\n}\n"; | ||
export declare const pollingContent = "\nimport { Client, HttpResponse } from \"@azure-rest/core-client\";\n{{#if useLegacyLro}}\nimport {\n LongRunningOperation,\n LroEngine,\n LroEngineOptions,\n LroResponse,\n PollerLike,\n PollOperationState\n} from \"@azure/core-lro\";\n{{else}}\nimport {\n CreateHttpPollerOptions,\n LongRunningOperation,\n LroResponse,\n OperationState,\n SimplePollerLike,\n createHttpPoller\n} from \"@azure/core-lro\";\n{{/if}}\n/**\n * Helper function that builds a Poller object to help polling a long running operation.\n * @param client - Client to use for sending the request to get additional pages.\n * @param initialResponse - The initial response.\n * @param options - Options to set a resume state or custom polling interval.\n * @returns - A poller object to poll for operation state updates and eventually get the final response.\n */\nexport {{#unless useLegacyLro}}async {{/unless}}function getLongRunningPoller<TResult extends HttpResponse>(\n client: Client,\n initialResponse: TResult,\n {{#if useLegacyLro}}\n options: LroEngineOptions<TResult, PollOperationState<TResult>> = {}\n ): PollerLike<PollOperationState<TResult>, TResult> {\n {{else}}\n options: CreateHttpPollerOptions<TResult, OperationState<TResult>> = {}\n ): Promise<SimplePollerLike<OperationState<TResult>, TResult>> {\n {{/if}} \n const poller: LongRunningOperation<TResult> = {\n requestMethod: initialResponse.request.method,\n requestPath: initialResponse.request.url,\n sendInitialRequest: async () => {\n // In the case of Rest Clients we are building the LRO poller object from a response that's the reason\n // we are not triggering the initial request here, just extracting the information from the\n // response we were provided.\n return getLroResponse(initialResponse);\n },\n sendPollRequest: async path => {\n // This is the callback that is going to be called to poll the service\n // to get the latest status. We use the client provided and the polling path\n // which is an opaque URL provided by caller, the service sends this in one of the following headers: operation-location, azure-asyncoperation or location\n // depending on the lro pattern that the service implements. If non is provided we default to the initial path.\n const response = await client\n .pathUnchecked(path ?? initialResponse.request.url)\n .get();\n const lroResponse = getLroResponse(response as TResult);\n lroResponse.rawResponse.headers[\"x-ms-original-url\"] =\n initialResponse.request.url;\n return lroResponse;\n }\n };\n\n {{#if useLegacyLro}}\n return new LroEngine(poller, options);\n {{else}}\n options.resolveOnUnsuccessful = options.resolveOnUnsuccessful ?? true;\n return await createHttpPoller(poller, options);\n {{/if}}\n}\n\n/**\n * Converts a Rest Client response to a response that the LRO implementation understands\n * @param response - a rest client http response\n * @returns - An LRO response that the LRO implementation understands\n */\nfunction getLroResponse<TResult extends HttpResponse>(\n response: TResult\n): LroResponse<TResult> {\n if (Number.isNaN(response.status)) {\n throw new TypeError(\n `Status code of the response is not a number. Value: ${response.status}`\n );\n }\n\n return {\n flatResponse: response,\n rawResponse: {\n ...response,\n statusCode: Number.parseInt(response.status),\n body: response.body\n }\n };\n}\n"; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
670939
232
11788