@azure-tools/rlc-common
Advanced tools
Comparing version 0.30.0-alpha.20240716.1 to 0.30.0-alpha.20240717.1
@@ -43,7 +43,7 @@ { | ||
"packages/rlc-common/src/metadata/buildPackageFile.ts": "0742b0540d7c0ffece2a9a16008d711a7d7da3ff", | ||
"packages/rlc-common/src/metadata/buildReadmeFile.ts": "31a19b86480b58799695af387065ac6f9cf6eff7", | ||
"packages/rlc-common/src/metadata/buildReadmeFile.ts": "184e1723127df234acde01ca9cf3db66135d0f7f", | ||
"packages/rlc-common/src/metadata/buildRollupConfig.ts": "4ed5a07876352ad6f506a7f5754cf306b6627692", | ||
"packages/rlc-common/src/metadata/buildTsConfig.ts": "376977d05a5b131a3f0190d969cb373e8d9580a8", | ||
"packages/rlc-common/src/metadata/buildVitestConfig.ts": "0e8fed4600c6727da03767e38adab03753e65840", | ||
"packages/rlc-common/src/metadata/packageJson/azurePackageCommon.ts": "0cafe4a7882befcdd0eb4d82870bd09bd2cbb953", | ||
"packages/rlc-common/src/metadata/packageJson/azurePackageCommon.ts": "7b385569e65b1079ac57aa15a94c12fb98017ad7", | ||
"packages/rlc-common/src/metadata/packageJson/buildAzureMonorepoPackage.ts": "4a918083a7f488541f09e5bff886fb588f76b9b8", | ||
@@ -50,0 +50,0 @@ "packages/rlc-common/src/metadata/packageJson/buildAzureStandalonePackage.ts": "fbd92933c7bfc711dea6ae98ba9f3a69555bb083", |
@@ -7,3 +7,3 @@ // Copyright (c) Microsoft Corporation. | ||
import { NameType, normalizeName } from "../helpers/nameUtils.js"; | ||
const azureReadmeTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
const azureReadmeRLCTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
@@ -84,2 +84,142 @@ {{ description }} | ||
`; | ||
const azureReadmeModularTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for {{ clientDescriptiveName }}. | ||
{{ description }} | ||
{{#if packageSourceURL}} | ||
[Source code]({{ packageSourceURL }}) | | ||
{{/if}} | ||
{{#if packageNPMURL}} | ||
[Package (NPM)]({{ packageNPMURL }}) | | ||
{{/if}} | ||
{{#if apiRefURL}} | ||
[API reference documentation]({{ apiRefURL }}) | | ||
{{/if}} | ||
{{#if samplesURL}} | ||
[Samples]({{samplesURL}}) | ||
{{/if}} | ||
## Getting started | ||
### Currently supported environments | ||
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) | ||
- Latest versions of Safari, Chrome, Edge and Firefox. | ||
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. | ||
{{#if azure}} | ||
### Prerequisites | ||
- An [Azure subscription][azure_sub]. | ||
{{/if}} | ||
{{#if isReleasablePackage}} | ||
### Install the \`{{ clientPackageName }}\` package | ||
Install the {{ clientDescriptiveName }} library for JavaScript with \`npm\`: | ||
\`\`\`bash | ||
npm install {{ clientPackageName }} | ||
\`\`\` | ||
{{/if}} | ||
{{#if azure}} | ||
{{#if addCredentials}} | ||
### Create and authenticate a \`{{ clientClassName}}\` | ||
To create a client object to access the {{ serviceName }} API, you will need the \`endpoint\` of your {{ serviceName }} resource and a \`credential\`. The {{ clientDescriptiveName }} can use Azure Active Directory credentials to authenticate. | ||
You can find the endpoint for your {{ serviceName }} resource in the [Azure Portal][azure_portal]. | ||
You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). | ||
To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the \`@azure/identity\` package: | ||
\`\`\`bash | ||
npm install @azure/identity | ||
\`\`\` | ||
You will also need to **register a new AAD application and grant access to {{ serviceName}}** by assigning the suitable role to your service principal (note: roles such as \`"Owner"\` will not grant the necessary permissions). | ||
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: \`AZURE_CLIENT_ID\`, \`AZURE_TENANT_ID\`, \`AZURE_CLIENT_SECRET\`. | ||
For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). | ||
{{#if azureArm}} | ||
\`\`\`javascript | ||
const { {{ clientClassName }} } = require("{{ clientPackageName }}"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. | ||
const subscriptionId = "00000000-0000-0000-0000-000000000000"; | ||
const client = new {{ clientClassName }}(new DefaultAzureCredential(), subscriptionId); | ||
// For client-side applications running in the browser, use this code instead: | ||
// const credential = new InteractiveBrowserCredential({ | ||
// tenantId: "<YOUR_TENANT_ID>", | ||
// clientId: "<YOUR_CLIENT_ID>" | ||
// }); | ||
// const client = new {{ clientClassName }}(credential, subscriptionId); | ||
\`\`\` | ||
{{else}} | ||
\`\`\`javascript | ||
const { {{ clientClassName }} } = require("{{ clientPackageName }}"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. | ||
const client = new {{ clientClassName }}("<endpoint>", new DefaultAzureCredential()); | ||
// For client-side applications running in the browser, use this code instead: | ||
// const credential = new InteractiveBrowserCredential({ | ||
// tenantId: "<YOUR_TENANT_ID>", | ||
// clientId: "<YOUR_CLIENT_ID>" | ||
// }); | ||
// const client = new {{ clientClassName }}("<endpoint>", credential); | ||
\`\`\` | ||
{{/if}} | ||
{{/if}}{{/if}} | ||
### JavaScript Bundle | ||
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). | ||
## Key concepts | ||
### {{ clientClassName }} | ||
\`{{ clientClassName }}\` is the primary interface for developers using the {{ clientDescriptiveName }} library. Explore the methods on this client object to understand the different features of the {{ serviceName }} service that you can access. | ||
{{#if azure}} | ||
## Troubleshooting | ||
### Logging | ||
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the \`AZURE_LOG_LEVEL\` environment variable to \`info\`. Alternatively, logging can be enabled at runtime by calling \`setLogLevel\` in the \`@azure/logger\`: | ||
\`\`\`javascript | ||
const { setLogLevel } = require("@azure/logger"); | ||
setLogLevel("info"); | ||
\`\`\` | ||
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs]({{ repoURL }}/tree/main/sdk/core/logger). | ||
{{#if samplesURL}} | ||
## Next steps | ||
Please take a look at the [samples]({{ samplesURL }}) directory for detailed examples on how to use this library. | ||
{{/if}} | ||
## Contributing | ||
If you'd like to contribute to this library, please read the [contributing guide]({{ contributingGuideURL }}) to learn more about how to build and test the code. | ||
## Related projects | ||
- [{{ projectName }}]({{ repoURL }}) | ||
[azure_sub]: https://azure.microsoft.com/free/ | ||
[azure_portal]: https://portal.azure.com | ||
{{#if identityPackageURL}}[azure_identity]: {{ identityPackageURL }} | ||
{{/if}}[defaultazurecredential]: {{ identityPackageURL }}#defaultazurecredential | ||
{{/if}} | ||
`; | ||
const nonBrandedReadmeTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
@@ -115,3 +255,3 @@ | ||
Install the {{ clientDescriptiveName }} REST client library for JavaScript with \`npm\`: | ||
Install the {{ clientDescriptiveName }} library for JavaScript with \`npm\`: | ||
@@ -125,3 +265,5 @@ \`\`\`bash | ||
const readmeFileContents = hbs.compile(model.options?.flavor === "azure" | ||
? azureReadmeTemplate | ||
? model.options.isModularLibrary | ||
? azureReadmeModularTemplate | ||
: azureReadmeRLCTemplate | ||
: nonBrandedReadmeTemplate, { noEscape: true }); | ||
@@ -143,3 +285,3 @@ return { | ||
// const packageDetails = model.options.packageDetails; | ||
const { packageDetails, azureOutputDirectory, productDocLink, dependencyInfo, multiClient, batch, serviceInfo } = model.options; | ||
const { packageDetails, azureOutputDirectory, productDocLink, dependencyInfo, multiClient, batch, serviceInfo, isTypeSpecTest } = model.options; | ||
const azureHuh = packageDetails?.scopeName === "azure" || | ||
@@ -164,3 +306,5 @@ packageDetails?.scopeName === "azure-rest"; | ||
clientPackageName: clientPackageName, | ||
clientDescriptiveName: `${serviceName} REST client`, | ||
clientDescriptiveName: model.options.isModularLibrary | ||
? `${serviceName} client` | ||
: `${serviceName} REST client`, | ||
description: serviceInfo?.description ?? packageDetails.description, | ||
@@ -177,3 +321,9 @@ serviceDocURL: productDocLink, | ||
hasMultiClients: multiClient && batch && batch.length > 1, | ||
azureArm: Boolean(model.options.azureArm) | ||
azureArm: Boolean(model.options.azureArm), | ||
azure: azureHuh, | ||
isReleasablePackage: !isTypeSpecTest, | ||
repoURL: repoURL, | ||
projectName: azureHuh ? "Microsoft Azure SDK for JavaScript" : undefined, | ||
identityPackageURL: repoURL && `${repoURL}/tree/main/sdk/identity/identity`, | ||
addCredentials: model.options.addCredentials | ||
}; | ||
@@ -180,0 +330,0 @@ } |
@@ -30,3 +30,3 @@ // Copyright (c) Microsoft Corporation. | ||
...dependencies, | ||
"@azure/core-lro": "3.0.0", | ||
"@azure/core-lro": "^3.0.0", | ||
"@azure/abort-controller": "^2.1.2" | ||
@@ -33,0 +33,0 @@ }; |
@@ -10,3 +10,3 @@ "use strict"; | ||
const nameUtils_js_1 = require("../helpers/nameUtils.js"); | ||
const azureReadmeTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
const azureReadmeRLCTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
@@ -87,2 +87,142 @@ {{ description }} | ||
`; | ||
const azureReadmeModularTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for {{ clientDescriptiveName }}. | ||
{{ description }} | ||
{{#if packageSourceURL}} | ||
[Source code]({{ packageSourceURL }}) | | ||
{{/if}} | ||
{{#if packageNPMURL}} | ||
[Package (NPM)]({{ packageNPMURL }}) | | ||
{{/if}} | ||
{{#if apiRefURL}} | ||
[API reference documentation]({{ apiRefURL }}) | | ||
{{/if}} | ||
{{#if samplesURL}} | ||
[Samples]({{samplesURL}}) | ||
{{/if}} | ||
## Getting started | ||
### Currently supported environments | ||
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) | ||
- Latest versions of Safari, Chrome, Edge and Firefox. | ||
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. | ||
{{#if azure}} | ||
### Prerequisites | ||
- An [Azure subscription][azure_sub]. | ||
{{/if}} | ||
{{#if isReleasablePackage}} | ||
### Install the \`{{ clientPackageName }}\` package | ||
Install the {{ clientDescriptiveName }} library for JavaScript with \`npm\`: | ||
\`\`\`bash | ||
npm install {{ clientPackageName }} | ||
\`\`\` | ||
{{/if}} | ||
{{#if azure}} | ||
{{#if addCredentials}} | ||
### Create and authenticate a \`{{ clientClassName}}\` | ||
To create a client object to access the {{ serviceName }} API, you will need the \`endpoint\` of your {{ serviceName }} resource and a \`credential\`. The {{ clientDescriptiveName }} can use Azure Active Directory credentials to authenticate. | ||
You can find the endpoint for your {{ serviceName }} resource in the [Azure Portal][azure_portal]. | ||
You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). | ||
To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the \`@azure/identity\` package: | ||
\`\`\`bash | ||
npm install @azure/identity | ||
\`\`\` | ||
You will also need to **register a new AAD application and grant access to {{ serviceName}}** by assigning the suitable role to your service principal (note: roles such as \`"Owner"\` will not grant the necessary permissions). | ||
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: \`AZURE_CLIENT_ID\`, \`AZURE_TENANT_ID\`, \`AZURE_CLIENT_SECRET\`. | ||
For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). | ||
{{#if azureArm}} | ||
\`\`\`javascript | ||
const { {{ clientClassName }} } = require("{{ clientPackageName }}"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. | ||
const subscriptionId = "00000000-0000-0000-0000-000000000000"; | ||
const client = new {{ clientClassName }}(new DefaultAzureCredential(), subscriptionId); | ||
// For client-side applications running in the browser, use this code instead: | ||
// const credential = new InteractiveBrowserCredential({ | ||
// tenantId: "<YOUR_TENANT_ID>", | ||
// clientId: "<YOUR_CLIENT_ID>" | ||
// }); | ||
// const client = new {{ clientClassName }}(credential, subscriptionId); | ||
\`\`\` | ||
{{else}} | ||
\`\`\`javascript | ||
const { {{ clientClassName }} } = require("{{ clientPackageName }}"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. | ||
const client = new {{ clientClassName }}("<endpoint>", new DefaultAzureCredential()); | ||
// For client-side applications running in the browser, use this code instead: | ||
// const credential = new InteractiveBrowserCredential({ | ||
// tenantId: "<YOUR_TENANT_ID>", | ||
// clientId: "<YOUR_CLIENT_ID>" | ||
// }); | ||
// const client = new {{ clientClassName }}("<endpoint>", credential); | ||
\`\`\` | ||
{{/if}} | ||
{{/if}}{{/if}} | ||
### JavaScript Bundle | ||
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). | ||
## Key concepts | ||
### {{ clientClassName }} | ||
\`{{ clientClassName }}\` is the primary interface for developers using the {{ clientDescriptiveName }} library. Explore the methods on this client object to understand the different features of the {{ serviceName }} service that you can access. | ||
{{#if azure}} | ||
## Troubleshooting | ||
### Logging | ||
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the \`AZURE_LOG_LEVEL\` environment variable to \`info\`. Alternatively, logging can be enabled at runtime by calling \`setLogLevel\` in the \`@azure/logger\`: | ||
\`\`\`javascript | ||
const { setLogLevel } = require("@azure/logger"); | ||
setLogLevel("info"); | ||
\`\`\` | ||
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs]({{ repoURL }}/tree/main/sdk/core/logger). | ||
{{#if samplesURL}} | ||
## Next steps | ||
Please take a look at the [samples]({{ samplesURL }}) directory for detailed examples on how to use this library. | ||
{{/if}} | ||
## Contributing | ||
If you'd like to contribute to this library, please read the [contributing guide]({{ contributingGuideURL }}) to learn more about how to build and test the code. | ||
## Related projects | ||
- [{{ projectName }}]({{ repoURL }}) | ||
[azure_sub]: https://azure.microsoft.com/free/ | ||
[azure_portal]: https://portal.azure.com | ||
{{#if identityPackageURL}}[azure_identity]: {{ identityPackageURL }} | ||
{{/if}}[defaultazurecredential]: {{ identityPackageURL }}#defaultazurecredential | ||
{{/if}} | ||
`; | ||
const nonBrandedReadmeTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
@@ -118,3 +258,3 @@ | ||
Install the {{ clientDescriptiveName }} REST client library for JavaScript with \`npm\`: | ||
Install the {{ clientDescriptiveName }} library for JavaScript with \`npm\`: | ||
@@ -129,3 +269,5 @@ \`\`\`bash | ||
const readmeFileContents = handlebars_1.default.compile(((_b = model.options) === null || _b === void 0 ? void 0 : _b.flavor) === "azure" | ||
? azureReadmeTemplate | ||
? model.options.isModularLibrary | ||
? azureReadmeModularTemplate | ||
: azureReadmeRLCTemplate | ||
: nonBrandedReadmeTemplate, { noEscape: true }); | ||
@@ -148,3 +290,3 @@ return { | ||
// const packageDetails = model.options.packageDetails; | ||
const { packageDetails, azureOutputDirectory, productDocLink, dependencyInfo, multiClient, batch, serviceInfo } = model.options; | ||
const { packageDetails, azureOutputDirectory, productDocLink, dependencyInfo, multiClient, batch, serviceInfo, isTypeSpecTest } = model.options; | ||
const azureHuh = (packageDetails === null || packageDetails === void 0 ? void 0 : packageDetails.scopeName) === "azure" || | ||
@@ -169,3 +311,5 @@ (packageDetails === null || packageDetails === void 0 ? void 0 : packageDetails.scopeName) === "azure-rest"; | ||
clientPackageName: clientPackageName, | ||
clientDescriptiveName: `${serviceName} REST client`, | ||
clientDescriptiveName: model.options.isModularLibrary | ||
? `${serviceName} client` | ||
: `${serviceName} REST client`, | ||
description: (_b = serviceInfo === null || serviceInfo === void 0 ? void 0 : serviceInfo.description) !== null && _b !== void 0 ? _b : packageDetails.description, | ||
@@ -182,3 +326,9 @@ serviceDocURL: productDocLink, | ||
hasMultiClients: multiClient && batch && batch.length > 1, | ||
azureArm: Boolean(model.options.azureArm) | ||
azureArm: Boolean(model.options.azureArm), | ||
azure: azureHuh, | ||
isReleasablePackage: !isTypeSpecTest, | ||
repoURL: repoURL, | ||
projectName: azureHuh ? "Microsoft Azure SDK for JavaScript" : undefined, | ||
identityPackageURL: repoURL && `${repoURL}/tree/main/sdk/identity/identity`, | ||
addCredentials: model.options.addCredentials | ||
}; | ||
@@ -185,0 +335,0 @@ } |
@@ -35,3 +35,3 @@ "use strict"; | ||
...dependencies, | ||
"@azure/core-lro": "3.0.0", | ||
"@azure/core-lro": "^3.0.0", | ||
"@azure/abort-controller": "^2.1.2" | ||
@@ -38,0 +38,0 @@ }; |
{ | ||
"name": "@azure-tools/rlc-common", | ||
"version": "0.30.0-alpha.20240716.1", | ||
"version": "0.30.0-alpha.20240717.1", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -10,3 +10,3 @@ // Copyright (c) Microsoft Corporation. | ||
const azureReadmeTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
const azureReadmeRLCTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
@@ -88,2 +88,143 @@ {{ description }} | ||
const azureReadmeModularTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
This package contains an isomorphic SDK (runs both in Node.js and in browsers) for {{ clientDescriptiveName }}. | ||
{{ description }} | ||
{{#if packageSourceURL}} | ||
[Source code]({{ packageSourceURL }}) | | ||
{{/if}} | ||
{{#if packageNPMURL}} | ||
[Package (NPM)]({{ packageNPMURL }}) | | ||
{{/if}} | ||
{{#if apiRefURL}} | ||
[API reference documentation]({{ apiRefURL }}) | | ||
{{/if}} | ||
{{#if samplesURL}} | ||
[Samples]({{samplesURL}}) | ||
{{/if}} | ||
## Getting started | ||
### Currently supported environments | ||
- [LTS versions of Node.js](https://github.com/nodejs/release#release-schedule) | ||
- Latest versions of Safari, Chrome, Edge and Firefox. | ||
See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUPPORT.md) for more details. | ||
{{#if azure}} | ||
### Prerequisites | ||
- An [Azure subscription][azure_sub]. | ||
{{/if}} | ||
{{#if isReleasablePackage}} | ||
### Install the \`{{ clientPackageName }}\` package | ||
Install the {{ clientDescriptiveName }} library for JavaScript with \`npm\`: | ||
\`\`\`bash | ||
npm install {{ clientPackageName }} | ||
\`\`\` | ||
{{/if}} | ||
{{#if azure}} | ||
{{#if addCredentials}} | ||
### Create and authenticate a \`{{ clientClassName}}\` | ||
To create a client object to access the {{ serviceName }} API, you will need the \`endpoint\` of your {{ serviceName }} resource and a \`credential\`. The {{ clientDescriptiveName }} can use Azure Active Directory credentials to authenticate. | ||
You can find the endpoint for your {{ serviceName }} resource in the [Azure Portal][azure_portal]. | ||
You can authenticate with Azure Active Directory using a credential from the [@azure/identity][azure_identity] library or [an existing AAD Token](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/identity/identity/samples/AzureIdentityExamples.md#authenticating-with-a-pre-fetched-access-token). | ||
To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, or other credential providers provided with the Azure SDK, please install the \`@azure/identity\` package: | ||
\`\`\`bash | ||
npm install @azure/identity | ||
\`\`\` | ||
You will also need to **register a new AAD application and grant access to {{ serviceName}}** by assigning the suitable role to your service principal (note: roles such as \`"Owner"\` will not grant the necessary permissions). | ||
Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: \`AZURE_CLIENT_ID\`, \`AZURE_TENANT_ID\`, \`AZURE_CLIENT_SECRET\`. | ||
For more information about how to create an Azure AD Application check out [this guide](https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal). | ||
{{#if azureArm}} | ||
\`\`\`javascript | ||
const { {{ clientClassName }} } = require("{{ clientPackageName }}"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. | ||
const subscriptionId = "00000000-0000-0000-0000-000000000000"; | ||
const client = new {{ clientClassName }}(new DefaultAzureCredential(), subscriptionId); | ||
// For client-side applications running in the browser, use this code instead: | ||
// const credential = new InteractiveBrowserCredential({ | ||
// tenantId: "<YOUR_TENANT_ID>", | ||
// clientId: "<YOUR_CLIENT_ID>" | ||
// }); | ||
// const client = new {{ clientClassName }}(credential, subscriptionId); | ||
\`\`\` | ||
{{else}} | ||
\`\`\`javascript | ||
const { {{ clientClassName }} } = require("{{ clientPackageName }}"); | ||
const { DefaultAzureCredential } = require("@azure/identity"); | ||
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details. | ||
const client = new {{ clientClassName }}("<endpoint>", new DefaultAzureCredential()); | ||
// For client-side applications running in the browser, use this code instead: | ||
// const credential = new InteractiveBrowserCredential({ | ||
// tenantId: "<YOUR_TENANT_ID>", | ||
// clientId: "<YOUR_CLIENT_ID>" | ||
// }); | ||
// const client = new {{ clientClassName }}("<endpoint>", credential); | ||
\`\`\` | ||
{{/if}} | ||
{{/if}}{{/if}} | ||
### JavaScript Bundle | ||
To use this client library in the browser, first you need to use a bundler. For details on how to do this, please refer to our [bundling documentation](https://aka.ms/AzureSDKBundling). | ||
## Key concepts | ||
### {{ clientClassName }} | ||
\`{{ clientClassName }}\` is the primary interface for developers using the {{ clientDescriptiveName }} library. Explore the methods on this client object to understand the different features of the {{ serviceName }} service that you can access. | ||
{{#if azure}} | ||
## Troubleshooting | ||
### Logging | ||
Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the \`AZURE_LOG_LEVEL\` environment variable to \`info\`. Alternatively, logging can be enabled at runtime by calling \`setLogLevel\` in the \`@azure/logger\`: | ||
\`\`\`javascript | ||
const { setLogLevel } = require("@azure/logger"); | ||
setLogLevel("info"); | ||
\`\`\` | ||
For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs]({{ repoURL }}/tree/main/sdk/core/logger). | ||
{{#if samplesURL}} | ||
## Next steps | ||
Please take a look at the [samples]({{ samplesURL }}) directory for detailed examples on how to use this library. | ||
{{/if}} | ||
## Contributing | ||
If you'd like to contribute to this library, please read the [contributing guide]({{ contributingGuideURL }}) to learn more about how to build and test the code. | ||
## Related projects | ||
- [{{ projectName }}]({{ repoURL }}) | ||
[azure_sub]: https://azure.microsoft.com/free/ | ||
[azure_portal]: https://portal.azure.com | ||
{{#if identityPackageURL}}[azure_identity]: {{ identityPackageURL }} | ||
{{/if}}[defaultazurecredential]: {{ identityPackageURL }}#defaultazurecredential | ||
{{/if}} | ||
`; | ||
const nonBrandedReadmeTemplate = `# {{ clientDescriptiveName }} library for JavaScript | ||
@@ -119,3 +260,3 @@ | ||
Install the {{ clientDescriptiveName }} REST client library for JavaScript with \`npm\`: | ||
Install the {{ clientDescriptiveName }} library for JavaScript with \`npm\`: | ||
@@ -166,2 +307,8 @@ \`\`\`bash | ||
azureArm?: boolean; | ||
/** Whether the package being generated is for an Azure service */ | ||
azure: boolean; | ||
/** Indicates if the package is a test/releasable package. */ | ||
isReleasablePackage?: boolean; | ||
/** The URL for impression */ | ||
impressionURL?: string; | ||
} | ||
@@ -173,3 +320,5 @@ | ||
model.options?.flavor === "azure" | ||
? azureReadmeTemplate | ||
? model.options.isModularLibrary | ||
? azureReadmeModularTemplate | ||
: azureReadmeRLCTemplate | ||
: nonBrandedReadmeTemplate, | ||
@@ -201,3 +350,4 @@ { noEscape: true } | ||
batch, | ||
serviceInfo | ||
serviceInfo, | ||
isTypeSpecTest | ||
} = model.options; | ||
@@ -228,3 +378,5 @@ | ||
clientPackageName: clientPackageName, | ||
clientDescriptiveName: `${serviceName} REST client`, | ||
clientDescriptiveName: model.options.isModularLibrary | ||
? `${serviceName} client` | ||
: `${serviceName} REST client`, | ||
description: serviceInfo?.description ?? packageDetails.description, | ||
@@ -241,3 +393,9 @@ serviceDocURL: productDocLink, | ||
hasMultiClients: multiClient && batch && batch.length > 1, | ||
azureArm: Boolean(model.options.azureArm) | ||
azureArm: Boolean(model.options.azureArm), | ||
azure: azureHuh, | ||
isReleasablePackage: !isTypeSpecTest, | ||
repoURL: repoURL, | ||
projectName: azureHuh ? "Microsoft Azure SDK for JavaScript" : undefined, | ||
identityPackageURL: repoURL && `${repoURL}/tree/main/sdk/identity/identity`, | ||
addCredentials: model.options.addCredentials | ||
}; | ||
@@ -244,0 +402,0 @@ } |
@@ -47,3 +47,3 @@ // Copyright (c) Microsoft Corporation. | ||
...dependencies, | ||
"@azure/core-lro": "3.0.0", | ||
"@azure/core-lro": "^3.0.0", | ||
"@azure/abort-controller": "^2.1.2" | ||
@@ -50,0 +50,0 @@ }; |
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
1191206
21525