Skip to content

Commit 2d609dd

Browse files
authored
[oep] Migrate oep projects to use snippets extraction (#33075)
### Packages impacted by this PR - @azure/arm-oep ### Issues associated with this PR - #32416 ### Describe the problem that is addressed by this PR Updates all projects under `oep` to use snippets extraction. ### What are the possible designs available to address the problem? If there are more than one possible design, why was the one in this PR chosen? ### Are there test cases added in this PR? _(If not, why?)_ ### Provide a list of related PRs _(if any)_ ### Command used to generate this PR:**_(Applicable only to SDK release request PRs)_ ### Checklists - [ ] Added impacted package name to the issue description - [ ] Does this PR needs any fixes in the SDK Generator?** _(If so, create an Issue in the [Autorest/typescript](https://github.com/Azure/autorest.typescript) repository and link it here)_ - [ ] Added a changelog (if necessary)
1 parent d75f1de commit 2d609dd

File tree

77 files changed

+759
-817
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+759
-817
lines changed

Diff for: common/config/rush/pnpm-lock.yaml

+438-423
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: sdk/oep/arm-oep/README.md

+21-14
Original file line numberDiff line numberDiff line change
@@ -48,23 +48,31 @@ Set the values of the client ID, tenant ID, and client secret of the AAD applica
4848

4949
For more information about how to create an Azure AD Application check out [this guide](https://learn.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal).
5050

51-
```javascript
52-
const { OpenEnergyPlatformManagementServiceAPIs } = require("@azure/arm-oep");
53-
const { DefaultAzureCredential } = require("@azure/identity");
54-
// For client-side applications running in the browser, use InteractiveBrowserCredential instead of DefaultAzureCredential. See https://aka.ms/azsdk/js/identity/examples for more details.
51+
Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client.
52+
53+
```ts snippet:ReadmeSampleCreateClient_Node
54+
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
55+
import { DefaultAzureCredential } from "@azure/identity";
5556

5657
const subscriptionId = "00000000-0000-0000-0000-000000000000";
5758
const client = new OpenEnergyPlatformManagementServiceAPIs(
5859
new DefaultAzureCredential(),
5960
subscriptionId,
6061
);
62+
```
63+
64+
For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate.
65+
66+
```ts snippet:ReadmeSampleCreateClient_Browser
67+
import { InteractiveBrowserCredential } from "@azure/identity";
68+
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
6169

62-
// For client-side applications running in the browser, use this code instead:
63-
// const credential = new InteractiveBrowserCredential({
64-
// tenantId: "<YOUR_TENANT_ID>",
65-
// clientId: "<YOUR_CLIENT_ID>"
66-
// });
67-
// const client = new OpenEnergyPlatformManagementServiceAPIs(credential, subscriptionId);
70+
const subscriptionId = "00000000-0000-0000-0000-000000000000";
71+
const credential = new InteractiveBrowserCredential({
72+
tenantId: "<YOUR_TENANT_ID>",
73+
clientId: "<YOUR_CLIENT_ID>",
74+
});
75+
const client = new OpenEnergyPlatformManagementServiceAPIs(credential, subscriptionId);
6876
```
6977

7078
### JavaScript Bundle
@@ -83,8 +91,9 @@ To use this client library in the browser, first you need to use a bundler. For
8391

8492
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`:
8593

86-
```javascript
87-
const { setLogLevel } = require("@azure/logger");
94+
```ts snippet:SetLogLevel
95+
import { setLogLevel } from "@azure/logger";
96+
8897
setLogLevel("info");
8998
```
9099

@@ -102,8 +111,6 @@ If you'd like to contribute to this library, please read the [contributing guide
102111

103112
- [Microsoft Azure SDK for JavaScript](https://github.com/Azure/azure-sdk-for-js)
104113

105-
106-
107114
[azure_cli]: https://learn.microsoft.com/cli/azure
108115
[azure_sub]: https://azure.microsoft.com/free/
109116
[azure_sub]: https://azure.microsoft.com/free/

Diff for: sdk/oep/arm-oep/_meta.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"repository_url": "https://github.com/Azure/azure-rest-api-specs.git",
66
"release_tool": "@azure-tools/[email protected]",
77
"use": "@autorest/[email protected]"
8-
}
8+
}

Diff for: sdk/oep/arm-oep/api-extractor.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
3-
"mainEntryPointFilePath": "./dist-esm/src/index.d.ts",
3+
"mainEntryPointFilePath": "dist/esm/index.d.ts",
44
"docModel": {
55
"enabled": true
66
},
@@ -11,7 +11,7 @@
1111
"dtsRollup": {
1212
"enabled": true,
1313
"untrimmedFilePath": "",
14-
"publicTrimmedFilePath": "./types/arm-oep.d.ts"
14+
"publicTrimmedFilePath": "dist/arm-oep.d.ts"
1515
},
1616
"messages": {
1717
"tsdocMessageReporting": {
@@ -28,4 +28,4 @@
2828
}
2929
}
3030
}
31-
}
31+
}

Diff for: sdk/oep/arm-oep/package.json

+69-40
Original file line numberDiff line numberDiff line change
@@ -8,65 +8,54 @@
88
"node": ">=18.0.0"
99
},
1010
"dependencies": {
11-
"@azure/abort-controller": "^1.0.0",
12-
"@azure/core-auth": "^1.3.0",
13-
"@azure/core-client": "^1.6.1",
11+
"@azure/abort-controller": "^2.1.2",
12+
"@azure/core-auth": "^1.9.0",
13+
"@azure/core-client": "^1.9.2",
1414
"@azure/core-lro": "^2.2.0",
15-
"@azure/core-paging": "^1.2.0",
16-
"@azure/core-rest-pipeline": "^1.8.0",
17-
"tslib": "^2.2.0"
15+
"@azure/core-paging": "^1.6.2",
16+
"@azure/core-rest-pipeline": "^1.19.0",
17+
"tslib": "^2.8.1"
1818
},
1919
"keywords": [
2020
"node",
2121
"azure",
2222
"typescript",
2323
"browser",
24-
"isomorphic"
24+
"isomorphic",
25+
"cloud"
2526
],
2627
"license": "MIT",
27-
"main": "./dist/index.js",
28-
"module": "./dist-esm/src/index.js",
29-
"types": "./types/arm-oep.d.ts",
28+
"main": "./dist/commonjs/index.js",
29+
"module": "./dist/esm/index.js",
30+
"types": "./dist/commonjs/index.d.ts",
3031
"devDependencies": {
31-
"@azure-tools/test-credential": "^1.0.0",
32-
"@azure-tools/test-recorder": "^3.0.0",
32+
"@azure-tools/test-credential": "^2.0.0",
33+
"@azure-tools/test-recorder": "^4.1.0",
34+
"@azure-tools/test-utils-vitest": "^1.0.0",
3335
"@azure/dev-tool": "^1.0.0",
34-
"@azure/identity": "^4.0.1",
35-
"@types/chai": "^4.2.8",
36-
"@types/mocha": "^10.0.0",
36+
"@azure/identity": "^4.6.0",
37+
"@azure/logger": "^1.1.4",
3738
"@types/node": "^18.0.0",
38-
"chai": "^4.2.0",
39-
"mocha": "^11.0.2",
40-
"ts-node": "^10.0.0",
41-
"typescript": "~5.7.2"
39+
"@vitest/browser": "^3.0.5",
40+
"@vitest/coverage-istanbul": "^3.0.5",
41+
"playwright": "^1.50.1",
42+
"typescript": "~5.7.2",
43+
"vitest": "^3.0.5"
4244
},
4345
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/oep/arm-oep",
44-
"repository": {
45-
"type": "git",
46-
"url": "https://github.com/Azure/azure-sdk-for-js.git"
47-
},
46+
"repository": "github:Azure/azure-sdk-for-js",
4847
"bugs": {
4948
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
5049
},
5150
"files": [
52-
"dist/**/*.js",
53-
"dist/**/*.js.map",
54-
"dist/**/*.d.ts",
55-
"dist/**/*.d.ts.map",
56-
"dist-esm/**/*.js",
57-
"dist-esm/**/*.js.map",
58-
"dist-esm/**/*.d.ts",
59-
"dist-esm/**/*.d.ts.map",
60-
"src/**/*.ts",
51+
"dist/",
6152
"README.md",
6253
"LICENSE",
63-
"tsconfig.json",
64-
"review/*",
65-
"CHANGELOG.md",
66-
"types/*"
54+
"review/",
55+
"CHANGELOG.md"
6756
],
6857
"scripts": {
69-
"build": "npm run clean && tsc && dev-tool run bundle && npm run minify && npm run extract-api",
58+
"build": "npm run clean && dev-tool run build-package && dev-tool run extract-api",
7059
"build:browser": "echo skipped",
7160
"build:node": "echo skipped",
7261
"build:samples": "echo skipped.",
@@ -78,7 +67,7 @@
7867
"format": "echo skipped",
7968
"integration-test": "npm run integration-test:node && npm run integration-test:browser",
8069
"integration-test:browser": "echo skipped",
81-
"integration-test:node": "dev-tool run test:node-ts-input -- --timeout 1200000 'test/*.ts'",
70+
"integration-test:node": "dev-tool run test:vitest --esm",
8271
"lint": "echo skipped",
8372
"minify": "dev-tool run vendored uglifyjs -c -m --comments --source-map \"content='./dist/index.js.map'\" -o ./dist/index.min.js ./dist/index.js",
8473
"pack": "npm pack 2>&1",
@@ -88,8 +77,8 @@
8877
"test:node": "echo skipped",
8978
"unit-test": "npm run unit-test:node && npm run unit-test:browser",
9079
"unit-test:browser": "echo skipped",
91-
"unit-test:node": "dev-tool run vendored cross-env TEST_MODE=playback npm run integration-test:node",
92-
"update-snippets": "echo skipped"
80+
"unit-test:node": "dev-tool run test:vitest",
81+
"update-snippets": "dev-tool run update-snippets"
9382
},
9483
"sideEffects": false,
9584
"//metadata": {
@@ -108,5 +97,45 @@
10897
],
10998
"disableDocsMs": true,
11099
"apiRefLink": "https://learn.microsoft.com/javascript/api/@azure/arm-oep?view=azure-node-preview"
100+
},
101+
"type": "module",
102+
"tshy": {
103+
"project": "./tsconfig.src.json",
104+
"exports": {
105+
"./package.json": "./package.json",
106+
".": "./src/index.ts"
107+
},
108+
"dialects": [
109+
"esm",
110+
"commonjs"
111+
],
112+
"esmDialects": [
113+
"browser",
114+
"react-native"
115+
],
116+
"selfLink": false
117+
},
118+
"browser": "./dist/browser/index.js",
119+
"react-native": "./dist/react-native/index.js",
120+
"exports": {
121+
"./package.json": "./package.json",
122+
".": {
123+
"browser": {
124+
"types": "./dist/browser/index.d.ts",
125+
"default": "./dist/browser/index.js"
126+
},
127+
"react-native": {
128+
"types": "./dist/react-native/index.d.ts",
129+
"default": "./dist/react-native/index.js"
130+
},
131+
"import": {
132+
"types": "./dist/esm/index.d.ts",
133+
"default": "./dist/esm/index.js"
134+
},
135+
"require": {
136+
"types": "./dist/commonjs/index.d.ts",
137+
"default": "./dist/commonjs/index.js"
138+
}
139+
}
111140
}
112141
}

Diff for: sdk/oep/arm-oep/samples-dev/energyServicesCreateSample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DefaultAzureCredential } from "@azure/identity";
1414
* @summary Method that gets called if subscribed for ResourceCreationBegin trigger.
1515
* x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2021-06-01-preview/examples/OepResource_Create.json
1616
*/
17-
async function oepResourceCreate() {
17+
async function oepResourceCreate(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const resourceName = "DummyResourceName";

Diff for: sdk/oep/arm-oep/samples-dev/energyServicesDeleteSample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DefaultAzureCredential } from "@azure/identity";
1414
* @summary Deletes oep resource
1515
* x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2021-06-01-preview/examples/OepResource_Delete.json
1616
*/
17-
async function oepResourceDelete() {
17+
async function oepResourceDelete(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const resourceName = "DummyResourceName";

Diff for: sdk/oep/arm-oep/samples-dev/energyServicesGetSample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DefaultAzureCredential } from "@azure/identity";
1414
* @summary Returns oep resource for a given name.
1515
* x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2021-06-01-preview/examples/OepResource_Get.json
1616
*/
17-
async function oepResourceGet() {
17+
async function oepResourceGet(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const resourceName = "DummyResourceName";

Diff for: sdk/oep/arm-oep/samples-dev/energyServicesListByResourceGroupSample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DefaultAzureCredential } from "@azure/identity";
1414
* @summary Returns list of oep resources..
1515
* x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2021-06-01-preview/examples/OepResource_ListByResourceGroup.json
1616
*/
17-
async function oepResourceListByResourceGroup() {
17+
async function oepResourceListByResourceGroup(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const credential = new DefaultAzureCredential();

Diff for: sdk/oep/arm-oep/samples-dev/energyServicesListBySubscriptionSample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DefaultAzureCredential } from "@azure/identity";
1414
* @summary Lists a collection of oep resources under the given Azure Subscription ID.
1515
* x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2021-06-01-preview/examples/OepResource_ListBySubscriptionId.json
1616
*/
17-
async function oepResourceListBySubscriptionId() {
17+
async function oepResourceListBySubscriptionId(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const credential = new DefaultAzureCredential();
2020
const client = new OpenEnergyPlatformManagementServiceAPIs(credential, subscriptionId);

Diff for: sdk/oep/arm-oep/samples-dev/energyServicesUpdateSample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DefaultAzureCredential } from "@azure/identity";
1414
* @summary
1515
* x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2021-06-01-preview/examples/OepResource_Update.json
1616
*/
17-
async function oepResourceUpdate() {
17+
async function oepResourceUpdate(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const resourceName = "DummyResourceName";

Diff for: sdk/oep/arm-oep/samples-dev/locationsCheckNameAvailability.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import type { CheckNameAvailabilityRequest } from "@azure/arm-oep";
1515
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
1616
import { DefaultAzureCredential } from "@azure/identity";
1717

18-
async function locationsCheckNameAvailability() {
18+
async function locationsCheckNameAvailability(): Promise<void> {
1919
const subscriptionId = "00000000-0000-0000-0000-000000000000";
2020
const body: CheckNameAvailabilityRequest = {
2121
name: "sample-name",

Diff for: sdk/oep/arm-oep/samples-dev/locationsCheckNameAvailabilitySample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { DefaultAzureCredential } from "@azure/identity";
1515
* @summary Checks the name availability of the resource with requested resource name.
1616
* x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2021-06-01-preview/examples/Locations_CheckNameAvailability.json
1717
*/
18-
async function locationsCheckNameAvailability() {
18+
async function locationsCheckNameAvailability(): Promise<void> {
1919
const subscriptionId = "00000000-0000-0000-0000-000000000000";
2020
const body: CheckNameAvailabilityRequest = {
2121
name: "sample-name",

Diff for: sdk/oep/arm-oep/samples-dev/oepResourceCreate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
1515
import { DefaultAzureCredential } from "@azure/identity";
1616

17-
async function oepResourceCreate() {
17+
async function oepResourceCreate(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const resourceName = "DummyResourceName";

Diff for: sdk/oep/arm-oep/samples-dev/oepResourceDelete.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
1515
import { DefaultAzureCredential } from "@azure/identity";
1616

17-
async function oepResourceDelete() {
17+
async function oepResourceDelete(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const resourceName = "DummyResourceName";

Diff for: sdk/oep/arm-oep/samples-dev/oepResourceGet.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
1515
import { DefaultAzureCredential } from "@azure/identity";
1616

17-
async function oepResourceGet() {
17+
async function oepResourceGet(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const resourceName = "DummyResourceName";

Diff for: sdk/oep/arm-oep/samples-dev/oepResourceListByResourceGroup.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
1515
import { DefaultAzureCredential } from "@azure/identity";
1616

17-
async function oepResourceListByResourceGroup() {
17+
async function oepResourceListByResourceGroup(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const credential = new DefaultAzureCredential();

Diff for: sdk/oep/arm-oep/samples-dev/oepResourceListBySubscriptionId.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
1515
import { DefaultAzureCredential } from "@azure/identity";
1616

17-
async function oepResourceListBySubscriptionId() {
17+
async function oepResourceListBySubscriptionId(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const credential = new DefaultAzureCredential();
2020
const client = new OpenEnergyPlatformManagementServiceAPIs(credential, subscriptionId);

Diff for: sdk/oep/arm-oep/samples-dev/oepResourceUpdate.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
1515
import { DefaultAzureCredential } from "@azure/identity";
1616

17-
async function oepResourceUpdate() {
17+
async function oepResourceUpdate(): Promise<void> {
1818
const subscriptionId = "0000000-0000-0000-0000-000000000001";
1919
const resourceGroupName = "DummyResourceGroupName";
2020
const resourceName = "DummyResourceName";

Diff for: sdk/oep/arm-oep/samples-dev/operationsList.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { OpenEnergyPlatformManagementServiceAPIs } from "@azure/arm-oep";
1515
import { DefaultAzureCredential } from "@azure/identity";
1616

17-
async function operationsList() {
17+
async function operationsList(): Promise<void> {
1818
const subscriptionId = "00000000-0000-0000-0000-000000000000";
1919
const credential = new DefaultAzureCredential();
2020
const client = new OpenEnergyPlatformManagementServiceAPIs(credential, subscriptionId);

Diff for: sdk/oep/arm-oep/samples-dev/operationsListSample.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { DefaultAzureCredential } from "@azure/identity";
1414
* @summary Lists the available operations of Microsoft.OpenEnergyPlatform resource provider.
1515
* x-ms-original-file: specification/oep/resource-manager/Microsoft.OpenEnergyPlatform/preview/2021-06-01-preview/examples/Operations_List.json
1616
*/
17-
async function operationsList() {
17+
async function operationsList(): Promise<void> {
1818
const subscriptionId = "00000000-0000-0000-0000-000000000000";
1919
const credential = new DefaultAzureCredential();
2020
const client = new OpenEnergyPlatformManagementServiceAPIs(credential, subscriptionId);

0 commit comments

Comments
 (0)