From 335cc699631f9105e9409bc338e0bae2a6fafa20 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:48 -0500 Subject: [PATCH 01/24] Migration: Update package.json, tsconfig.json, and api-extractor.json --- sdk/deviceupdate/arm-deviceupdate/package.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/sdk/deviceupdate/arm-deviceupdate/package.json b/sdk/deviceupdate/arm-deviceupdate/package.json index 795db4168c06..b093a38351c9 100644 --- a/sdk/deviceupdate/arm-deviceupdate/package.json +++ b/sdk/deviceupdate/arm-deviceupdate/package.json @@ -8,13 +8,13 @@ "node": ">=18.0.0" }, "dependencies": { - "@azure/abort-controller": "^1.0.0", - "@azure/core-auth": "^1.3.0", - "@azure/core-client": "^1.7.0", + "@azure/abort-controller": "^2.1.2", + "@azure/core-auth": "^1.9.0", + "@azure/core-client": "^1.9.2", "@azure/core-lro": "^2.5.4", - "@azure/core-paging": "^1.2.0", - "@azure/core-rest-pipeline": "^1.12.0", - "tslib": "^2.2.0" + "@azure/core-paging": "^1.6.2", + "@azure/core-rest-pipeline": "^1.18.2", + "tslib": "^2.8.1" }, "keywords": [ "node", @@ -32,12 +32,12 @@ "@azure-tools/test-recorder": "^4.1.0", "@azure-tools/test-utils-vitest": "^1.0.0", "@azure/dev-tool": "^1.0.0", - "@azure/identity": "^4.0.1", + "@azure/identity": "^4.6.0", "@types/node": "^18.0.0", "@vitest/browser": "^3.0.3", "@vitest/coverage-istanbul": "^3.0.3", "dotenv": "^16.0.0", - "playwright": "^1.49.1", + "playwright": "^1.50.0", "typescript": "~5.7.2", "vitest": "^3.0.3" }, From 4117ac313317049fa4d921daac928250c200e76b Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:48 -0500 Subject: [PATCH 02/24] Migration: Update test config From 81b088a744645fc54c0b2784775084648420a12d Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:49 -0500 Subject: [PATCH 03/24] Migration: Clean up files From cfad50fde11063ec6594a30b4c8d7708c93016ff Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:53 -0500 Subject: [PATCH 04/24] Migration: Apply codemod: "fixSourceFile" --- .../v1/typescript/src/accountsCreateSample.ts | 4 +-- .../v1/typescript/src/accountsDeleteSample.ts | 4 +-- .../v1/typescript/src/accountsGetSample.ts | 4 +-- .../v1/typescript/src/accountsHeadSample.ts | 4 +-- .../src/accountsListByResourceGroupSample.ts | 4 +-- .../src/accountsListBySubscriptionSample.ts | 4 +-- .../v1/typescript/src/accountsUpdateSample.ts | 4 +-- .../src/checkNameAvailabilitySample.ts | 6 ++-- .../typescript/src/instancesCreateSample.ts | 4 +-- .../typescript/src/instancesDeleteSample.ts | 4 +-- .../v1/typescript/src/instancesGetSample.ts | 4 +-- .../v1/typescript/src/instancesHeadSample.ts | 4 +-- .../src/instancesListByAccountSample.ts | 4 +-- .../typescript/src/instancesUpdateSample.ts | 4 +-- .../v1/typescript/src/operationsListSample.ts | 4 +-- ...ntConnectionProxiesCreateOrUpdateSample.ts | 4 +-- ...teEndpointConnectionProxiesDeleteSample.ts | 4 +-- ...ivateEndpointConnectionProxiesGetSample.ts | 4 +-- ...intConnectionProxiesListByAccountSample.ts | 4 +-- ...esUpdatePrivateEndpointPropertiesSample.ts | 4 +-- ...EndpointConnectionProxiesValidateSample.ts | 4 +-- ...EndpointConnectionsCreateOrUpdateSample.ts | 4 +-- .../privateEndpointConnectionsDeleteSample.ts | 4 +-- .../privateEndpointConnectionsGetSample.ts | 4 +-- ...eEndpointConnectionsListByAccountSample.ts | 4 +-- .../src/privateLinkResourcesGetSample.ts | 4 +-- ...privateLinkResourcesListByAccountSample.ts | 4 +-- .../test/deviceupdate_operations_test.spec.ts | 28 +++++++++---------- 28 files changed, 69 insertions(+), 69 deletions(-) diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsCreateSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsCreateSample.ts index c027df1711c6..02ff24595ac5 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsCreateSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsCreateSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Creates or updates Account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Create.json */ -async function createsOrUpdatesAccount() { +async function createsOrUpdatesAccount(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -46,7 +46,7 @@ async function createsOrUpdatesAccount() { console.log(result); } -async function main() { +async function main(): Promise { createsOrUpdatesAccount(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsDeleteSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsDeleteSample.ts index cf163c99dd67..1012c87eeba3 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsDeleteSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsDeleteSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Deletes account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Delete.json */ -async function deletesAnAccount() { +async function deletesAnAccount(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -31,7 +31,7 @@ async function deletesAnAccount() { console.log(result); } -async function main() { +async function main(): Promise { deletesAnAccount(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsGetSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsGetSample.ts index d4ff472a190b..14c128d31056 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsGetSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsGetSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Returns account details for the given account name. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Get.json */ -async function getsAccountDetails() { +async function getsAccountDetails(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -28,7 +28,7 @@ async function getsAccountDetails() { console.log(result); } -async function main() { +async function main(): Promise { getsAccountDetails(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsHeadSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsHeadSample.ts index 9236e29f0624..7a7e95a596c6 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsHeadSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsHeadSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Checks whether account exists. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Head.json */ -async function checksWhetherAccountExists() { +async function checksWhetherAccountExists(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -28,7 +28,7 @@ async function checksWhetherAccountExists() { console.log(result); } -async function main() { +async function main(): Promise { checksWhetherAccountExists(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsListByResourceGroupSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsListByResourceGroupSample.ts index d3aa9891e805..46e7f090ad8d 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsListByResourceGroupSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsListByResourceGroupSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Returns list of Accounts. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_List.json */ -async function getsListOfAccounts() { +async function getsListOfAccounts(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -32,7 +32,7 @@ async function getsListOfAccounts() { console.log(resArray); } -async function main() { +async function main(): Promise { getsListOfAccounts(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsListBySubscriptionSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsListBySubscriptionSample.ts index 710b66b8d2f5..28f1eb87404f 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsListBySubscriptionSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsListBySubscriptionSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Returns list of Accounts. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_List.json */ -async function getListOfAccounts() { +async function getListOfAccounts(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -28,7 +28,7 @@ async function getListOfAccounts() { console.log(resArray); } -async function main() { +async function main(): Promise { getListOfAccounts(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsUpdateSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsUpdateSample.ts index 41b1843b9da8..125e154400b6 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsUpdateSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/accountsUpdateSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Updates account's patchable properties * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Accounts/Accounts_Update.json */ -async function updatesAccount() { +async function updatesAccount(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function updatesAccount() { console.log(result); } -async function main() { +async function main(): Promise { updatesAccount(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/checkNameAvailabilitySample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/checkNameAvailabilitySample.ts index aa901836a2f7..6453b750fbca 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/checkNameAvailabilitySample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/checkNameAvailabilitySample.ts @@ -18,7 +18,7 @@ import "dotenv/config"; * @summary Checks ADU resource name availability. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/CheckNameAvailability_AlreadyExists.json */ -async function checkNameAvailabilityAlreadyExists() { +async function checkNameAvailabilityAlreadyExists(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -38,7 +38,7 @@ async function checkNameAvailabilityAlreadyExists() { * @summary Checks ADU resource name availability. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/CheckNameAvailability_Available.json */ -async function checkNameAvailabilityAvailable() { +async function checkNameAvailabilityAvailable(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -52,7 +52,7 @@ async function checkNameAvailabilityAvailable() { console.log(result); } -async function main() { +async function main(): Promise { checkNameAvailabilityAlreadyExists(); checkNameAvailabilityAvailable(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesCreateSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesCreateSample.ts index 8774de11ee9c..24a2e05e8eef 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesCreateSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesCreateSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Creates or updates instance. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Create.json */ -async function createsOrUpdatesInstance() { +async function createsOrUpdatesInstance(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -50,7 +50,7 @@ async function createsOrUpdatesInstance() { console.log(result); } -async function main() { +async function main(): Promise { createsOrUpdatesInstance(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesDeleteSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesDeleteSample.ts index b54451bdbba8..aa134986979a 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesDeleteSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesDeleteSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Deletes instance. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Delete.json */ -async function deletesInstance() { +async function deletesInstance(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function deletesInstance() { console.log(result); } -async function main() { +async function main(): Promise { deletesInstance(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesGetSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesGetSample.ts index 0cfa71bb73a5..98e3f2a77dba 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesGetSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesGetSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Returns instance details for the given instance and account name. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Get.json */ -async function getsListOfInstances() { +async function getsListOfInstances(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function getsListOfInstances() { console.log(result); } -async function main() { +async function main(): Promise { getsListOfInstances(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesHeadSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesHeadSample.ts index f8030a1e9c22..c82f386328e2 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesHeadSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesHeadSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Checks whether instance exists. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Head.json */ -async function checksWhetherInstanceExists() { +async function checksWhetherInstanceExists(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function checksWhetherInstanceExists() { console.log(result); } -async function main() { +async function main(): Promise { checksWhetherInstanceExists(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesListByAccountSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesListByAccountSample.ts index 83b5afa23b42..98845b29efe6 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesListByAccountSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesListByAccountSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Returns instances for the given account name. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_ListByAccount.json */ -async function getsListOfInstancesByAccount() { +async function getsListOfInstancesByAccount(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -34,7 +34,7 @@ async function getsListOfInstancesByAccount() { console.log(resArray); } -async function main() { +async function main(): Promise { getsListOfInstancesByAccount(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesUpdateSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesUpdateSample.ts index ba62a7c9f51e..98cacb45bd6d 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesUpdateSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/instancesUpdateSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Updates instance's tags. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Instances/Instances_Update.json */ -async function updatesInstance() { +async function updatesInstance(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -35,7 +35,7 @@ async function updatesInstance() { console.log(result); } -async function main() { +async function main(): Promise { updatesInstance(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/operationsListSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/operationsListSample.ts index e89d6561bb9b..5b1a15c1cfd8 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/operationsListSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/operationsListSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Returns list of operations for Microsoft.DeviceUpdate resource provider. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/Operations_List.json */ -async function getsListOfOperations() { +async function getsListOfOperations(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -28,7 +28,7 @@ async function getsListOfOperations() { console.log(resArray); } -async function main() { +async function main(): Promise { getsListOfOperations(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesCreateOrUpdateSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesCreateOrUpdateSample.ts index 271eefffc541..6afa262132ae 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesCreateOrUpdateSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesCreateOrUpdateSample.ts @@ -18,7 +18,7 @@ import "dotenv/config"; * @summary (INTERNAL - DO NOT USE) Creates or updates the specified private endpoint connection proxy resource associated with the device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_CreateOrUpdate.json */ -async function privateEndpointConnectionProxyCreateOrUpdate() { +async function privateEndpointConnectionProxyCreateOrUpdate(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -61,7 +61,7 @@ async function privateEndpointConnectionProxyCreateOrUpdate() { console.log(result); } -async function main() { +async function main(): Promise { privateEndpointConnectionProxyCreateOrUpdate(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesDeleteSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesDeleteSample.ts index fafed3e8a940..db0f9696c8d9 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesDeleteSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesDeleteSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary (INTERNAL - DO NOT USE) Deletes the specified private endpoint connection proxy associated with the device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Delete.json */ -async function privateEndpointConnectionProxyDelete() { +async function privateEndpointConnectionProxyDelete(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function privateEndpointConnectionProxyDelete() { console.log(result); } -async function main() { +async function main(): Promise { privateEndpointConnectionProxyDelete(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesGetSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesGetSample.ts index 282275bdf853..b037874e66c7 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesGetSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesGetSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary (INTERNAL - DO NOT USE) Get the specified private endpoint connection proxy associated with the device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Get.json */ -async function privateEndpointConnectionProxyGet() { +async function privateEndpointConnectionProxyGet(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function privateEndpointConnectionProxyGet() { console.log(result); } -async function main() { +async function main(): Promise { privateEndpointConnectionProxyGet(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesListByAccountSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesListByAccountSample.ts index 988a6b5a3b97..b3ac77765853 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesListByAccountSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesListByAccountSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary (INTERNAL - DO NOT USE) List all private endpoint connection proxies in a device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_ListByAccount.json */ -async function privateEndpointConnectionProxyList() { +async function privateEndpointConnectionProxyList(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -34,7 +34,7 @@ async function privateEndpointConnectionProxyList() { console.log(resArray); } -async function main() { +async function main(): Promise { privateEndpointConnectionProxyList(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesSample.ts index ca3a734e7193..a9fddbb27cff 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesUpdatePrivateEndpointPropertiesSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary (INTERNAL - DO NOT USE) Updates a private endpoint inside the private endpoint connection proxy object. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_PrivateEndpointUpdate.json */ -async function privateEndpointConnectionProxyPrivateEndpointUpdate() { +async function privateEndpointConnectionProxyPrivateEndpointUpdate(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -43,7 +43,7 @@ async function privateEndpointConnectionProxyPrivateEndpointUpdate() { console.log(result); } -async function main() { +async function main(): Promise { privateEndpointConnectionProxyPrivateEndpointUpdate(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesValidateSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesValidateSample.ts index 5ce15d4f6afa..ee3a491a9d22 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesValidateSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionProxiesValidateSample.ts @@ -18,7 +18,7 @@ import "dotenv/config"; * @summary (INTERNAL - DO NOT USE) Validates a private endpoint connection proxy object. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnectionProxies/PrivateEndpointConnectionProxy_Validate.json */ -async function privateEndpointConnectionProxyValidate() { +async function privateEndpointConnectionProxyValidate(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -61,7 +61,7 @@ async function privateEndpointConnectionProxyValidate() { console.log(result); } -async function main() { +async function main(): Promise { privateEndpointConnectionProxyValidate(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts index 87d68081933f..84e56fff78ec 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsCreateOrUpdateSample.ts @@ -18,7 +18,7 @@ import "dotenv/config"; * @summary Update the state of specified private endpoint connection associated with the device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_CreateOrUpdate.json */ -async function privateEndpointConnectionCreateOrUpdate() { +async function privateEndpointConnectionCreateOrUpdate(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -43,7 +43,7 @@ async function privateEndpointConnectionCreateOrUpdate() { console.log(result); } -async function main() { +async function main(): Promise { privateEndpointConnectionCreateOrUpdate(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsDeleteSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsDeleteSample.ts index 8f3fc56f1bc9..8d793a6ddd2c 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsDeleteSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsDeleteSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Deletes the specified private endpoint connection associated with the device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Delete.json */ -async function privateEndpointConnectionDelete() { +async function privateEndpointConnectionDelete(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function privateEndpointConnectionDelete() { console.log(result); } -async function main() { +async function main(): Promise { privateEndpointConnectionDelete(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsGetSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsGetSample.ts index 9773d125a2df..c43798e6d8a7 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsGetSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsGetSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Get the specified private endpoint connection associated with the device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_Get.json */ -async function privateEndpointConnectionGet() { +async function privateEndpointConnectionGet(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function privateEndpointConnectionGet() { console.log(result); } -async function main() { +async function main(): Promise { privateEndpointConnectionGet(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsListByAccountSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsListByAccountSample.ts index 4777302c183a..f682e934b964 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsListByAccountSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateEndpointConnectionsListByAccountSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary List all private endpoint connections in a device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateEndpointConnections/PrivateEndpointConnection_ListByAccount.json */ -async function privateEndpointConnectionList() { +async function privateEndpointConnectionList(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -34,7 +34,7 @@ async function privateEndpointConnectionList() { console.log(resArray); } -async function main() { +async function main(): Promise { privateEndpointConnectionList(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateLinkResourcesGetSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateLinkResourcesGetSample.ts index 9a0717daa049..f0eb54ce7c4d 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateLinkResourcesGetSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateLinkResourcesGetSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary Get the specified private link resource associated with the device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateLinkResources/PrivateLinkResources_Get.json */ -async function privateLinkResourcesGet() { +async function privateLinkResourcesGet(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -33,7 +33,7 @@ async function privateLinkResourcesGet() { console.log(result); } -async function main() { +async function main(): Promise { privateLinkResourcesGet(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateLinkResourcesListByAccountSample.ts b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateLinkResourcesListByAccountSample.ts index 3037534458e1..44bf4c2bae30 100644 --- a/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateLinkResourcesListByAccountSample.ts +++ b/sdk/deviceupdate/arm-deviceupdate/samples/v1/typescript/src/privateLinkResourcesListByAccountSample.ts @@ -15,7 +15,7 @@ import "dotenv/config"; * @summary List all private link resources in a device update account. * x-ms-original-file: specification/deviceupdate/resource-manager/Microsoft.DeviceUpdate/stable/2023-07-01/examples/PrivateLinkResources/PrivateLinkResources_ListByAccount.json */ -async function privateLinkResourcesList() { +async function privateLinkResourcesList(): Promise { const subscriptionId = process.env["DEVICEUPDATE_SUBSCRIPTION_ID"] || "00000000-0000-0000-0000-000000000000"; @@ -34,7 +34,7 @@ async function privateLinkResourcesList() { console.log(resArray); } -async function main() { +async function main(): Promise { privateLinkResourcesList(); } diff --git a/sdk/deviceupdate/arm-deviceupdate/test/deviceupdate_operations_test.spec.ts b/sdk/deviceupdate/arm-deviceupdate/test/deviceupdate_operations_test.spec.ts index 91a4995484b2..b97d61a2718f 100644 --- a/sdk/deviceupdate/arm-deviceupdate/test/deviceupdate_operations_test.spec.ts +++ b/sdk/deviceupdate/arm-deviceupdate/test/deviceupdate_operations_test.spec.ts @@ -43,22 +43,22 @@ describe("DeviceUpdate test", () => { let resourceGroup: string; let resourcename: string; - beforeEach(async function (ctx) { - recorder = new Recorder(ctx); - await recorder.start(recorderOptions); - subscriptionId = env.SUBSCRIPTION_ID || ''; - // This is an example of how the environment variables are used - const credential = createTestCredential(); - client = new DeviceUpdate(credential, subscriptionId, recorder.configureClientOptions({})); - location = "eastus"; - resourceGroup = "myjstest"; - resourcename = "resourcetest"; + beforeEach(async (ctx) => { + recorder = new Recorder(ctx); + await recorder.start(recorderOptions); + subscriptionId = env.SUBSCRIPTION_ID || ''; + // This is an example of how the environment variables are used + const credential = createTestCredential(); + client = new DeviceUpdate(credential, subscriptionId, recorder.configureClientOptions({})); + location = "eastus"; + resourceGroup = "myjstest"; + resourcename = "resourcetest"; - }); + }); - afterEach(async function () { - await recorder.stop(); - }); + afterEach(async () => { + await recorder.stop(); + }); it("accounts create test", async function () { const res = await client.accounts.beginCreateAndWait( From e0d5fc6d607219ace79131c1602a16d6269e9b4c Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:54 -0500 Subject: [PATCH 05/24] Migration: Apply codemod: "fixTestingImports" From b7df039f1af968526fd811e486d427309ac8954f Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:54 -0500 Subject: [PATCH 06/24] Migration: Apply codemod: "replaceAssertIsRejected" From ac0401aa6104136f0cc5a459dae6e77a0ddbddf1 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:54 -0500 Subject: [PATCH 07/24] Migration: Apply codemod: "replaceSinonStub" From 2f2c25927f670358ed75cd07f7c3ab5e93493f88 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:55 -0500 Subject: [PATCH 08/24] Migration: Apply codemod: "addViHelper" From 13f1d5fca3f41eb1c797f0cecc634e29d4f0a517 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:55 -0500 Subject: [PATCH 09/24] Migration: Apply codemod: "replaceSupportTracing" From 932dfec383aa230769d3dc169fb505bb870cbfca Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:55 -0500 Subject: [PATCH 10/24] Migration: Apply codemod: "replaceTestUtils" From 676ccfaf9ba8996db934a3bb434997b5547be1d7 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:48:56 -0500 Subject: [PATCH 11/24] Migration: rushx format From 8241d3f6eab0b7eae490340cd8a7d6880c69c218 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:53:05 -0500 Subject: [PATCH 12/24] [deviceupdate] Migrate deviceupdate packages to snippet extraction --- sdk/deviceupdate/arm-deviceupdate/README.md | 33 ++++++---- sdk/deviceupdate/arm-deviceupdate/_meta.json | 2 +- .../arm-deviceupdate/package.json | 11 ++-- .../test/deviceupdate_operations_test.spec.ts | 63 +++++++++---------- .../arm-deviceupdate/test/snippets.spec.ts | 27 ++++++++ .../tsconfig.browser.config.json | 5 +- .../arm-deviceupdate/tsconfig.samples.json | 4 +- .../arm-deviceupdate/tsconfig.test.json | 5 +- .../arm-deviceupdate/vitest.browser.config.ts | 3 +- .../arm-deviceupdate/vitest.config.ts | 1 - .../arm-deviceupdate/vitest.esm.config.ts | 6 +- 11 files changed, 87 insertions(+), 73 deletions(-) create mode 100644 sdk/deviceupdate/arm-deviceupdate/test/snippets.spec.ts diff --git a/sdk/deviceupdate/arm-deviceupdate/README.md b/sdk/deviceupdate/arm-deviceupdate/README.md index 021807dce4ec..4ea6fdc46bfa 100644 --- a/sdk/deviceupdate/arm-deviceupdate/README.md +++ b/sdk/deviceupdate/arm-deviceupdate/README.md @@ -48,20 +48,28 @@ Set the values of the client ID, tenant ID, and client secret of the AAD applica 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). -```javascript -const { DeviceUpdate } = require("@azure/arm-deviceupdate"); -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. +Using Node.js and Node-like environments, you can use the `DefaultAzureCredential` class to authenticate the client. + +```ts snippet:ReadmeSampleCreateClient_Node +import { DeviceUpdate } from "@azure/arm-deviceupdate"; +import { DefaultAzureCredential } from "@azure/identity"; const subscriptionId = "00000000-0000-0000-0000-000000000000"; const client = new DeviceUpdate(new DefaultAzureCredential(), subscriptionId); +``` + +For browser environments, use the `InteractiveBrowserCredential` from the `@azure/identity` package to authenticate. -// For client-side applications running in the browser, use this code instead: -// const credential = new InteractiveBrowserCredential({ -// tenantId: "", -// clientId: "" -// }); -// const client = new DeviceUpdate(credential, subscriptionId); +```ts snippet:ReadmeSampleCreateClient_Browser +import { InteractiveBrowserCredential } from "@azure/identity"; +import { DeviceUpdate } from "@azure/arm-deviceupdate"; + +const subscriptionId = "00000000-0000-0000-0000-000000000000"; +const credential = new InteractiveBrowserCredential({ + tenantId: "", + clientId: "", +}); +const client = new DeviceUpdate(credential, subscriptionId); ``` ### JavaScript Bundle @@ -80,8 +88,9 @@ To use this client library in the browser, first you need to use a bundler. For 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"); +```ts snippet:SetLogLevel +import { setLogLevel } from "@azure/logger"; + setLogLevel("info"); ``` diff --git a/sdk/deviceupdate/arm-deviceupdate/_meta.json b/sdk/deviceupdate/arm-deviceupdate/_meta.json index 6d67d5713dcb..ff528c7a7582 100644 --- a/sdk/deviceupdate/arm-deviceupdate/_meta.json +++ b/sdk/deviceupdate/arm-deviceupdate/_meta.json @@ -5,4 +5,4 @@ "repository_url": "https://github.com/Azure/azure-rest-api-specs.git", "release_tool": "@azure-tools/js-sdk-release-tools@2.7.4", "use": "@autorest/typescript@6.0.13" -} \ No newline at end of file +} diff --git a/sdk/deviceupdate/arm-deviceupdate/package.json b/sdk/deviceupdate/arm-deviceupdate/package.json index b093a38351c9..21fb87f30d21 100644 --- a/sdk/deviceupdate/arm-deviceupdate/package.json +++ b/sdk/deviceupdate/arm-deviceupdate/package.json @@ -21,7 +21,8 @@ "azure", "typescript", "browser", - "isomorphic" + "isomorphic", + "cloud" ], "license": "MIT", "main": "./dist/commonjs/index.js", @@ -33,6 +34,7 @@ "@azure-tools/test-utils-vitest": "^1.0.0", "@azure/dev-tool": "^1.0.0", "@azure/identity": "^4.6.0", + "@azure/logger": "^1.1.4", "@types/node": "^18.0.0", "@vitest/browser": "^3.0.3", "@vitest/coverage-istanbul": "^3.0.3", @@ -41,10 +43,7 @@ "typescript": "~5.7.2", "vitest": "^3.0.3" }, - "repository": { - "type": "git", - "url": "https://github.com/Azure/azure-sdk-for-js.git" - }, + "repository": "github:Azure/azure-sdk-for-js", "bugs": { "url": "https://github.com/Azure/azure-sdk-for-js/issues" }, @@ -79,7 +78,7 @@ "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "echo skipped", "unit-test:node": "dev-tool run test:vitest", - "update-snippets": "echo skipped" + "update-snippets": "dev-tool run update-snippets" }, "sideEffects": false, "//metadata": { diff --git a/sdk/deviceupdate/arm-deviceupdate/test/deviceupdate_operations_test.spec.ts b/sdk/deviceupdate/arm-deviceupdate/test/deviceupdate_operations_test.spec.ts index b97d61a2718f..3edb2ac293b4 100644 --- a/sdk/deviceupdate/arm-deviceupdate/test/deviceupdate_operations_test.spec.ts +++ b/sdk/deviceupdate/arm-deviceupdate/test/deviceupdate_operations_test.spec.ts @@ -6,12 +6,8 @@ * Changes may cause incorrect behavior and will be lost if the code is regenerated. */ -import { - env, - Recorder, - RecorderStartOptions, - isPlaybackMode, -} from "@azure-tools/test-recorder"; +import type { RecorderStartOptions } from "@azure-tools/test-recorder"; +import { env, Recorder, isPlaybackMode } from "@azure-tools/test-recorder"; import { createTestCredential } from "@azure-tools/test-credential"; import { DeviceUpdate } from "../src/deviceUpdate.js"; import { describe, it, assert, beforeEach, afterEach } from "vitest"; @@ -20,7 +16,7 @@ const replaceableVariables: Record = { AZURE_CLIENT_ID: "azure_client_id", AZURE_CLIENT_SECRET: "azure_client_secret", AZURE_TENANT_ID: "88888888-8888-8888-8888-888888888888", - SUBSCRIPTION_ID: "azure_subscription_id" + SUBSCRIPTION_ID: "azure_subscription_id", }; const recorderOptions: RecorderStartOptions = { @@ -44,58 +40,55 @@ describe("DeviceUpdate test", () => { let resourcename: string; beforeEach(async (ctx) => { - recorder = new Recorder(ctx); - await recorder.start(recorderOptions); - subscriptionId = env.SUBSCRIPTION_ID || ''; - // This is an example of how the environment variables are used - const credential = createTestCredential(); - client = new DeviceUpdate(credential, subscriptionId, recorder.configureClientOptions({})); - location = "eastus"; - resourceGroup = "myjstest"; - resourcename = "resourcetest"; - - }); + recorder = new Recorder(ctx); + await recorder.start(recorderOptions); + subscriptionId = env.SUBSCRIPTION_ID || ""; + // This is an example of how the environment variables are used + const credential = createTestCredential(); + client = new DeviceUpdate(credential, subscriptionId, recorder.configureClientOptions({})); + location = "eastus"; + resourceGroup = "myjstest"; + resourcename = "resourcetest"; + }); afterEach(async () => { - await recorder.stop(); - }); + await recorder.stop(); + }); - it("accounts create test", async function () { + it("accounts create test", async () => { const res = await client.accounts.beginCreateAndWait( resourceGroup, resourcename, { identity: { - type: "SystemAssigned" + type: "SystemAssigned", }, - location + location, }, - testPollingOptions); + testPollingOptions, + ); assert.equal(res.name, resourcename); }); - it("accounts get test", async function () { - const res = await client.accounts.get( - resourceGroup, - resourcename); + it("accounts get test", async () => { + const res = await client.accounts.get(resourceGroup, resourcename); assert.equal(res.name, resourcename); }); - it("accounts list test", async function () { + it("accounts list test", async () => { const resArray = new Array(); - for await (let item of client.accounts.listByResourceGroup(resourceGroup)) { + for await (const item of client.accounts.listByResourceGroup(resourceGroup)) { resArray.push(item); } assert.equal(resArray.length, 1); }); - it("accounts delete test", async function () { + it("accounts delete test", async () => { const resArray = new Array(); - await client.accounts.beginDeleteAndWait(resourceGroup, resourcename - ) - for await (let item of client.accounts.listByResourceGroup(resourceGroup)) { + await client.accounts.beginDeleteAndWait(resourceGroup, resourcename); + for await (const item of client.accounts.listByResourceGroup(resourceGroup)) { resArray.push(item); } assert.equal(resArray.length, 0); }); -}) +}); diff --git a/sdk/deviceupdate/arm-deviceupdate/test/snippets.spec.ts b/sdk/deviceupdate/arm-deviceupdate/test/snippets.spec.ts new file mode 100644 index 000000000000..4e6436f9c156 --- /dev/null +++ b/sdk/deviceupdate/arm-deviceupdate/test/snippets.spec.ts @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { DeviceUpdate } from "../src/index.js"; +import { DefaultAzureCredential, InteractiveBrowserCredential } from "@azure/identity"; +import { setLogLevel } from "@azure/logger"; +import { describe, it } from "vitest"; + +describe("snippets", () => { + it("ReadmeSampleCreateClient_Node", async () => { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const client = new DeviceUpdate(new DefaultAzureCredential(), subscriptionId); + }); + + it("ReadmeSampleCreateClient_Browser", async () => { + const subscriptionId = "00000000-0000-0000-0000-000000000000"; + const credential = new InteractiveBrowserCredential({ + tenantId: "", + clientId: "", + }); + const client = new DeviceUpdate(credential, subscriptionId); + }); + + it("SetLogLevel", async () => { + setLogLevel("info"); + }); +}); diff --git a/sdk/deviceupdate/arm-deviceupdate/tsconfig.browser.config.json b/sdk/deviceupdate/arm-deviceupdate/tsconfig.browser.config.json index 0c8bafa97126..75871518e3a0 100644 --- a/sdk/deviceupdate/arm-deviceupdate/tsconfig.browser.config.json +++ b/sdk/deviceupdate/arm-deviceupdate/tsconfig.browser.config.json @@ -1,6 +1,3 @@ { - "extends": [ - "./tsconfig.test.json", - "../../../tsconfig.browser.base.json" - ] + "extends": ["./tsconfig.test.json", "../../../tsconfig.browser.base.json"] } diff --git a/sdk/deviceupdate/arm-deviceupdate/tsconfig.samples.json b/sdk/deviceupdate/arm-deviceupdate/tsconfig.samples.json index 65f66d83a10f..fcfd59d86ba6 100644 --- a/sdk/deviceupdate/arm-deviceupdate/tsconfig.samples.json +++ b/sdk/deviceupdate/arm-deviceupdate/tsconfig.samples.json @@ -2,9 +2,7 @@ "extends": "../../../tsconfig.samples.base.json", "compilerOptions": { "paths": { - "@azure/arm-deviceupdate": [ - "./dist/esm" - ] + "@azure/arm-deviceupdate": ["./dist/esm"] } } } diff --git a/sdk/deviceupdate/arm-deviceupdate/tsconfig.test.json b/sdk/deviceupdate/arm-deviceupdate/tsconfig.test.json index 3c2b783a8c1b..290ca214aebc 100644 --- a/sdk/deviceupdate/arm-deviceupdate/tsconfig.test.json +++ b/sdk/deviceupdate/arm-deviceupdate/tsconfig.test.json @@ -1,6 +1,3 @@ { - "extends": [ - "./tsconfig.src.json", - "../../../tsconfig.test.base.json" - ] + "extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"] } diff --git a/sdk/deviceupdate/arm-deviceupdate/vitest.browser.config.ts b/sdk/deviceupdate/arm-deviceupdate/vitest.browser.config.ts index 182729ab5ce9..10e70dbfa8ee 100644 --- a/sdk/deviceupdate/arm-deviceupdate/vitest.browser.config.ts +++ b/sdk/deviceupdate/arm-deviceupdate/vitest.browser.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -9,7 +8,7 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - include: ["dist-test/browser/test/**/*.spec.js",], + include: ["dist-test/browser/test/**/*.spec.js"], testTimeout: 1200000, hookTimeout: 1200000, }, diff --git a/sdk/deviceupdate/arm-deviceupdate/vitest.config.ts b/sdk/deviceupdate/arm-deviceupdate/vitest.config.ts index 40e031385dd8..86a71911ccc2 100644 --- a/sdk/deviceupdate/arm-deviceupdate/vitest.config.ts +++ b/sdk/deviceupdate/arm-deviceupdate/vitest.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. diff --git a/sdk/deviceupdate/arm-deviceupdate/vitest.esm.config.ts b/sdk/deviceupdate/arm-deviceupdate/vitest.esm.config.ts index a70127279fc9..5e9735e9b144 100644 --- a/sdk/deviceupdate/arm-deviceupdate/vitest.esm.config.ts +++ b/sdk/deviceupdate/arm-deviceupdate/vitest.esm.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -6,7 +5,4 @@ import { mergeConfig } from "vitest/config"; import vitestConfig from "./vitest.config.ts"; import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; -export default mergeConfig( - vitestConfig, - vitestEsmConfig -); +export default mergeConfig(vitestConfig, vitestEsmConfig); From 3b102a7decb58eb3886dec1fafcceaa9ed5e1951 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:10 -0500 Subject: [PATCH 13/24] Migration: Update package.json, tsconfig.json, and api-extractor.json --- .../iot-device-update-rest/package.json | 17 +++++++++-------- .../iot-device-update-rest/tsconfig.json | 12 +++++++++--- .../tsconfig.samples.json | 4 +++- .../iot-device-update-rest/tsconfig.test.json | 5 ++++- 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/sdk/deviceupdate/iot-device-update-rest/package.json b/sdk/deviceupdate/iot-device-update-rest/package.json index fd2f809f2f89..c6d55592074b 100644 --- a/sdk/deviceupdate/iot-device-update-rest/package.json +++ b/sdk/deviceupdate/iot-device-update-rest/package.json @@ -76,12 +76,12 @@ "sideEffects": false, "autoPublish": false, "dependencies": { - "@azure/core-lro": "^3.1.0", - "@azure/abort-controller": "^2.1.2", "@azure-rest/core-client": "^2.3.1", + "@azure/abort-controller": "^2.1.2", "@azure/core-auth": "^1.9.0", + "@azure/core-lro": "^3.1.0", "@azure/core-paging": "^1.6.2", - "@azure/core-rest-pipeline": "^1.18.0", + "@azure/core-rest-pipeline": "^1.18.2", "@azure/logger": "^1.1.4", "tslib": "^2.8.1" }, @@ -92,18 +92,19 @@ "@azure/core-util": "^1.11.0", "@azure/dev-tool": "^1.0.0", "@azure/eslint-plugin-azure-sdk": "^3.0.0", - "@azure/identity": "^4.0.1", + "@azure/identity": "^4.6.0", "@types/node": "^18.0.0", "@vitest/browser": "^3.0.3", "@vitest/coverage-istanbul": "^3.0.3", "dotenv": "^16.0.0", "eslint": "^9.9.0", - "playwright": "^1.49.0", + "playwright": "^1.50.0", "typescript": "~5.7.2", "vitest": "^3.0.3" }, "type": "module", "tshy": { + "project": "./tsconfig.src.json", "exports": { "./package.json": "./package.json", ".": "./src/index.ts" @@ -116,8 +117,7 @@ "browser", "react-native" ], - "selfLink": false, - "project": "./tsconfig.src.json" + "selfLink": false }, "exports": { "./package.json": "./package.json", @@ -139,5 +139,6 @@ "default": "./dist/commonjs/index.js" } } - } + }, + "react-native": "./dist/react-native/index.js" } diff --git a/sdk/deviceupdate/iot-device-update-rest/tsconfig.json b/sdk/deviceupdate/iot-device-update-rest/tsconfig.json index 273d9078a24a..19ceb382b521 100644 --- a/sdk/deviceupdate/iot-device-update-rest/tsconfig.json +++ b/sdk/deviceupdate/iot-device-update-rest/tsconfig.json @@ -1,7 +1,13 @@ { "references": [ - { "path": "./tsconfig.src.json" }, - { "path": "./tsconfig.samples.json" }, - { "path": "./tsconfig.test.json" } + { + "path": "./tsconfig.src.json" + }, + { + "path": "./tsconfig.samples.json" + }, + { + "path": "./tsconfig.test.json" + } ] } diff --git a/sdk/deviceupdate/iot-device-update-rest/tsconfig.samples.json b/sdk/deviceupdate/iot-device-update-rest/tsconfig.samples.json index adcc77d3d599..1a7d9b7350e2 100644 --- a/sdk/deviceupdate/iot-device-update-rest/tsconfig.samples.json +++ b/sdk/deviceupdate/iot-device-update-rest/tsconfig.samples.json @@ -2,7 +2,9 @@ "extends": "../../../tsconfig.samples.base.json", "compilerOptions": { "paths": { - "@azure-rest/iot-device-update": ["./dist/esm"] + "@azure-rest/iot-device-update": [ + "./dist/esm" + ] } } } diff --git a/sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json b/sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json index 290ca214aebc..3c2b783a8c1b 100644 --- a/sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json +++ b/sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json @@ -1,3 +1,6 @@ { - "extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"] + "extends": [ + "./tsconfig.src.json", + "../../../tsconfig.test.base.json" + ] } From 386c8084d54f1d129526af1f8cac50d3f86f1d78 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:11 -0500 Subject: [PATCH 14/24] Migration: Update test config --- .../iot-device-update-rest/tsconfig.browser.config.json | 5 ++++- .../iot-device-update-rest/vitest.browser.config.ts | 7 ++++--- sdk/deviceupdate/iot-device-update-rest/vitest.config.ts | 5 +++-- .../iot-device-update-rest/vitest.esm.config.ts | 1 + 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/sdk/deviceupdate/iot-device-update-rest/tsconfig.browser.config.json b/sdk/deviceupdate/iot-device-update-rest/tsconfig.browser.config.json index 75871518e3a0..0c8bafa97126 100644 --- a/sdk/deviceupdate/iot-device-update-rest/tsconfig.browser.config.json +++ b/sdk/deviceupdate/iot-device-update-rest/tsconfig.browser.config.json @@ -1,3 +1,6 @@ { - "extends": ["./tsconfig.test.json", "../../../tsconfig.browser.base.json"] + "extends": [ + "./tsconfig.test.json", + "../../../tsconfig.browser.base.json" + ] } diff --git a/sdk/deviceupdate/iot-device-update-rest/vitest.browser.config.ts b/sdk/deviceupdate/iot-device-update-rest/vitest.browser.config.ts index 50ec2d5489b0..182729ab5ce9 100644 --- a/sdk/deviceupdate/iot-device-update-rest/vitest.browser.config.ts +++ b/sdk/deviceupdate/iot-device-update-rest/vitest.browser.config.ts @@ -1,3 +1,4 @@ + // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -8,9 +9,9 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - include: ["dist-test/browser/test/**/*.spec.js"], - hookTimeout: 5000000, - testTimeout: 5000000, + include: ["dist-test/browser/test/**/*.spec.js",], + testTimeout: 1200000, + hookTimeout: 1200000, }, }), ); diff --git a/sdk/deviceupdate/iot-device-update-rest/vitest.config.ts b/sdk/deviceupdate/iot-device-update-rest/vitest.config.ts index 8849d7428190..40e031385dd8 100644 --- a/sdk/deviceupdate/iot-device-update-rest/vitest.config.ts +++ b/sdk/deviceupdate/iot-device-update-rest/vitest.config.ts @@ -1,3 +1,4 @@ + // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -8,8 +9,8 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - hookTimeout: 5000000, - testTimeout: 5000000, + testTimeout: 1200000, + hookTimeout: 1200000, }, }), ); diff --git a/sdk/deviceupdate/iot-device-update-rest/vitest.esm.config.ts b/sdk/deviceupdate/iot-device-update-rest/vitest.esm.config.ts index 2f6e757a54f7..a70127279fc9 100644 --- a/sdk/deviceupdate/iot-device-update-rest/vitest.esm.config.ts +++ b/sdk/deviceupdate/iot-device-update-rest/vitest.esm.config.ts @@ -1,3 +1,4 @@ + // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. From 2848c96861e455cf158eb0adbf947da239f8b4ff Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:11 -0500 Subject: [PATCH 15/24] Migration: Clean up files --- .../iot-device-update-rest/karma.conf.js | 133 ------------------ 1 file changed, 133 deletions(-) delete mode 100644 sdk/deviceupdate/iot-device-update-rest/karma.conf.js diff --git a/sdk/deviceupdate/iot-device-update-rest/karma.conf.js b/sdk/deviceupdate/iot-device-update-rest/karma.conf.js deleted file mode 100644 index 4fdf26c79ac0..000000000000 --- a/sdk/deviceupdate/iot-device-update-rest/karma.conf.js +++ /dev/null @@ -1,133 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT License. - -// https://github.com/karma-runner/karma-chrome-launcher -process.env.CHROME_BIN = require("puppeteer").executablePath(); -require("dotenv").config(); -const { relativeRecordingsPath } = require("@azure-tools/test-recorder"); -process.env.RECORDINGS_RELATIVE_PATH = relativeRecordingsPath(); - -module.exports = function (config) { - config.set({ - // base path that will be used to resolve all patterns (eg. files, exclude) - basePath: "./", - - // frameworks to use - // available frameworks: https://npmjs.org/browse/keyword/karma-adapter - frameworks: ["source-map-support", "mocha"], - - plugins: [ - "karma-mocha", - "karma-mocha-reporter", - "karma-chrome-launcher", - "karma-firefox-launcher", - "karma-env-preprocessor", - "karma-coverage", - "karma-sourcemap-loader", - "karma-junit-reporter", - "karma-source-map-support", - ], - - // list of files / patterns to load in the browser - files: [ - "dist-test/index.browser.js", - { - pattern: "dist-test/index.browser.js.map", - type: "html", - included: false, - served: true, - }, - ], - - // list of files / patterns to exclude - exclude: [], - - // preprocess matching files before serving them to the browser - // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor - preprocessors: { - "**/*.js": ["sourcemap", "env"], - // IMPORTANT: COMMENT following line if you want to debug in your browsers!! - // Preprocess source file to calculate code coverage, however this will make source file unreadable - // "dist-test/index.js": ["coverage"] - }, - - envPreprocessor: [ - "TEST_MODE", - "ENDPOINT", - "AZURE_CLIENT_SECRET", - "AZURE_CLIENT_ID", - "AZURE_TENANT_ID", - "SUBSCRIPTION_ID", - "RECORDINGS_RELATIVE_PATH", - ], - - // test results reporter to use - // possible values: 'dots', 'progress' - // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ["mocha", "coverage", "junit"], - - coverageReporter: { - // specify a common output directory - dir: "coverage-browser/", - reporters: [ - { type: "json", subdir: ".", file: "coverage.json" }, - { type: "lcovonly", subdir: ".", file: "lcov.info" }, - { type: "html", subdir: "html" }, - { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, - ], - }, - - junitReporter: { - outputDir: "", // results will be saved as $outputDir/$browserName.xml - outputFile: "test-results.browser.xml", // if included, results will be saved as $outputDir/$browserName/$outputFile - suite: "", // suite will become the package name attribute in xml testsuite element - useBrowserName: false, // add browser name to report and classes names - nameFormatter: undefined, // function (browser, result) to customize the name attribute in xml testcase element - classNameFormatter: undefined, // function (browser, result) to customize the classname attribute in xml testcase element - properties: {}, // key value pair of properties to add to the section of the report - }, - - // web server port - port: 9876, - - // enable / disable colors in the output (reporters and logs) - colors: true, - - // level of logging - // possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG - logLevel: config.LOG_INFO, - - // enable / disable watching file and executing tests whenever any file changes - autoWatch: false, - - // --no-sandbox allows our tests to run in Linux without having to change the system. - // --disable-web-security allows us to authenticate from the browser without having to write tests using interactive auth, which would be far more complex. - browsers: ["ChromeHeadlessNoSandbox"], - customLaunchers: { - ChromeHeadlessNoSandbox: { - base: "ChromeHeadless", - flags: ["--no-sandbox", "--disable-web-security"], - }, - }, - - // Continuous Integration mode - // if true, Karma captures browsers, runs the tests and exits - singleRun: false, - - // Concurrency level - // how many browser should be started simultaneous - concurrency: 1, - - browserNoActivityTimeout: 60000000, - browserDisconnectTimeout: 10000, - browserDisconnectTolerance: 3, - - client: { - mocha: { - // change Karma's debug.html to the mocha web reporter - reporter: "html", - timeout: "600000", - }, - }, - }); -}; From 42aad1b9a52cac17b28844ad37e9c23f102f3d30 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:14 -0500 Subject: [PATCH 16/24] Migration: Apply codemod: "fixSourceFile" --- .../samples/v1/typescript/src/deleteUpdate.ts | 7 ++----- .../samples/v1/typescript/src/deployUpdate.ts | 5 +---- .../samples/v1/typescript/src/getDevice.ts | 7 ++----- .../samples/v1/typescript/src/getUpdate.ts | 7 ++----- .../samples/v1/typescript/src/importUpdate.ts | 11 ++++------- .../samples/v1/typescript/src/listUpdates.ts | 7 ++----- 6 files changed, 13 insertions(+), 31 deletions(-) diff --git a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/deleteUpdate.ts b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/deleteUpdate.ts index db4fe95a8427..b1d1de1d1ffd 100644 --- a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/deleteUpdate.ts +++ b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/deleteUpdate.ts @@ -10,14 +10,11 @@ import DeviceUpdate, { getLongRunningPoller, isUnexpected } from "@azure-rest/iot-device-update"; import { DefaultAzureCredential } from "@azure/identity"; -import dotenv from "dotenv"; - -dotenv.config(); - +import "dotenv/config"; const endpoint = process.env["ENDPOINT"] || ""; const instanceId = process.env["INSTANCE_ID"] || ""; -async function main() { +async function main(): Promise { console.log("== Delete update =="); const updateProvider = process.env["DEVICEUPDATE_UPDATE_PROVIDER"] || ""; const updateName = process.env["DEVICEUPDATE_UPDATE_NAME"] || ""; diff --git a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/deployUpdate.ts b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/deployUpdate.ts index 5097ab93275b..384680c850b0 100644 --- a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/deployUpdate.ts +++ b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/deployUpdate.ts @@ -10,11 +10,8 @@ import DeviceUpdate, { getLongRunningPoller, isUnexpected } from "@azure-rest/iot-device-update"; import { DefaultAzureCredential } from "@azure/identity"; -import dotenv from "dotenv"; +import "dotenv/config"; import { randomUUID } from "@azure/core-util"; - -dotenv.config(); - const endpoint = process.env["ENDPOINT"] || ""; const instanceId = process.env["INSTANCE_ID"] || ""; diff --git a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/getDevice.ts b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/getDevice.ts index 1b28280ea714..b354350ba59a 100644 --- a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/getDevice.ts +++ b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/getDevice.ts @@ -9,14 +9,11 @@ import DeviceUpdate, { isUnexpected, paginate } from "@azure-rest/iot-device-update"; import { DefaultAzureCredential } from "@azure/identity"; -import dotenv from "dotenv"; - -dotenv.config(); - +import "dotenv/config"; const endpoint = process.env["ENDPOINT"] || ""; const instanceId = process.env["INSTANCE_ID"] || ""; -async function main() { +async function main(): Promise { console.log("== Get device =="); const groupId = process.env["DEVICEUPDATE_DEVICE_GROUP"] || ""; diff --git a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/getUpdate.ts b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/getUpdate.ts index 5ce5278d4e96..7f8a136bbfe7 100644 --- a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/getUpdate.ts +++ b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/getUpdate.ts @@ -9,14 +9,11 @@ import DeviceUpdate, { isUnexpected } from "@azure-rest/iot-device-update"; import { DefaultAzureCredential } from "@azure/identity"; -import dotenv from "dotenv"; - -dotenv.config(); - +import "dotenv/config"; const endpoint = process.env["ENDPOINT"] || ""; const instanceId = process.env["INSTANCE_ID"] || ""; -async function main() { +async function main(): Promise { console.log("== Get update =="); const provider = process.env["DEVICEUPDATE_UPDATE_PROVIDER"] || ""; const name = process.env["DEVICEUPDATE_UPDATE_NAME"] || ""; diff --git a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/importUpdate.ts b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/importUpdate.ts index 24872b17d2e6..f1cc7441aaad 100644 --- a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/importUpdate.ts +++ b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/importUpdate.ts @@ -8,19 +8,16 @@ */ import DeviceUpdate, { getLongRunningPoller, isUnexpected } from "@azure-rest/iot-device-update"; -import { readFileSync, statSync } from "fs"; +import { readFileSync, statSync } from "node:fs"; import { DefaultAzureCredential } from "@azure/identity"; import { computeSha256Hash } from "@azure/core-util"; -import dotenv from "dotenv"; -import { parse } from "path"; - -dotenv.config(); - +import "dotenv/config"; +import { parse } from "node:path"; const endpoint = process.env["ENDPOINT"] || ""; const instanceId = process.env["INSTANCE_ID"] || ""; -async function main() { +async function main(): Promise { console.log("== Import update =="); const payloadFile = process.env["DEVICEUPDATE_PAYLOAD_FILE"] || ""; const payloadUrl = process.env["DEVICEUPDATE_PAYLOAD_URL"] || ""; diff --git a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/listUpdates.ts b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/listUpdates.ts index f980f119019f..825e99e61b9a 100644 --- a/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/listUpdates.ts +++ b/sdk/deviceupdate/iot-device-update-rest/samples/v1/typescript/src/listUpdates.ts @@ -9,14 +9,11 @@ import DeviceUpdate, { isUnexpected, paginate } from "@azure-rest/iot-device-update"; import { DefaultAzureCredential } from "@azure/identity"; -import dotenv from "dotenv"; - -dotenv.config(); - +import "dotenv/config"; const endpoint = process.env["ENDPOINT"] || ""; const instanceId = process.env["INSTANCE_ID"] || ""; -async function main() { +async function main(): Promise { console.log("== List updates =="); const provider = process.env["DEVICEUPDATE_UPDATE_PROVIDER"] || ""; const name = process.env["DEVICEUPDATE_UPDATE_NAME"] || ""; From 8b0ca02548b5f5bcce30287269eb59441c9979fd Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:15 -0500 Subject: [PATCH 17/24] Migration: Apply codemod: "fixTestingImports" From b0ba01a983de8ac0699841a6562f20af48ae2d4c Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:15 -0500 Subject: [PATCH 18/24] Migration: Apply codemod: "replaceAssertIsRejected" From 2bc8e11fa4af02540591408956674842b808903e Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:15 -0500 Subject: [PATCH 19/24] Migration: Apply codemod: "replaceSinonStub" From ee05182a501f444333313f227acae735e7187b1d Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:16 -0500 Subject: [PATCH 20/24] Migration: Apply codemod: "addViHelper" From 7c2f0112aaf8117c253816b2a310ca0d00d351b4 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:16 -0500 Subject: [PATCH 21/24] Migration: Apply codemod: "replaceSupportTracing" From 2b18f4d162c83aa416ac5160f3cf9253e3354865 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:16 -0500 Subject: [PATCH 22/24] Migration: Apply codemod: "replaceTestUtils" From a1e37525ace825199c7ee23540db6d6dfd63e2a6 Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 17:54:18 -0500 Subject: [PATCH 23/24] Migration: rushx format --- .../iot-device-update-rest/tsconfig.browser.config.json | 5 +---- .../iot-device-update-rest/tsconfig.samples.json | 4 +--- sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json | 5 +---- 3 files changed, 3 insertions(+), 11 deletions(-) diff --git a/sdk/deviceupdate/iot-device-update-rest/tsconfig.browser.config.json b/sdk/deviceupdate/iot-device-update-rest/tsconfig.browser.config.json index 0c8bafa97126..75871518e3a0 100644 --- a/sdk/deviceupdate/iot-device-update-rest/tsconfig.browser.config.json +++ b/sdk/deviceupdate/iot-device-update-rest/tsconfig.browser.config.json @@ -1,6 +1,3 @@ { - "extends": [ - "./tsconfig.test.json", - "../../../tsconfig.browser.base.json" - ] + "extends": ["./tsconfig.test.json", "../../../tsconfig.browser.base.json"] } diff --git a/sdk/deviceupdate/iot-device-update-rest/tsconfig.samples.json b/sdk/deviceupdate/iot-device-update-rest/tsconfig.samples.json index 1a7d9b7350e2..adcc77d3d599 100644 --- a/sdk/deviceupdate/iot-device-update-rest/tsconfig.samples.json +++ b/sdk/deviceupdate/iot-device-update-rest/tsconfig.samples.json @@ -2,9 +2,7 @@ "extends": "../../../tsconfig.samples.base.json", "compilerOptions": { "paths": { - "@azure-rest/iot-device-update": [ - "./dist/esm" - ] + "@azure-rest/iot-device-update": ["./dist/esm"] } } } diff --git a/sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json b/sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json index 3c2b783a8c1b..290ca214aebc 100644 --- a/sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json +++ b/sdk/deviceupdate/iot-device-update-rest/tsconfig.test.json @@ -1,6 +1,3 @@ { - "extends": [ - "./tsconfig.src.json", - "../../../tsconfig.test.base.json" - ] + "extends": ["./tsconfig.src.json", "../../../tsconfig.test.base.json"] } From 05a2386994a353471582ac455eb936a1db48c8ca Mon Sep 17 00:00:00 2001 From: Matthew Podwysocki Date: Wed, 29 Jan 2025 18:02:50 -0500 Subject: [PATCH 24/24] [deviceupdate] Migrate deviceupdate packages to snippet extraction --- .../iot-device-update-rest/README.md | 28 +++++++---------- .../iot-device-update-rest/package.json | 2 +- .../test/snippets.spec.ts | 30 +++++++++++++++++++ .../vitest.browser.config.ts | 3 +- .../iot-device-update-rest/vitest.config.ts | 1 - .../vitest.esm.config.ts | 6 +--- 6 files changed, 44 insertions(+), 26 deletions(-) create mode 100644 sdk/deviceupdate/iot-device-update-rest/test/snippets.spec.ts diff --git a/sdk/deviceupdate/iot-device-update-rest/README.md b/sdk/deviceupdate/iot-device-update-rest/README.md index 123b53ad0db1..39bf23df1473 100644 --- a/sdk/deviceupdate/iot-device-update-rest/README.md +++ b/sdk/deviceupdate/iot-device-update-rest/README.md @@ -48,13 +48,12 @@ AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET Use the returned token credential to authenticate the client: -```typescript +```ts snippet:ReadmeSampleCreateClient_Node import DeviceUpdate from "@azure-rest/iot-device-update"; import { DefaultAzureCredential } from "@azure/identity"; -const client = DeviceUpdate( - "https://.api.adu.microsoft.com", - new DefaultAzureCredential(), -); + +const endpoint = "https://.api.adu.microsoft.com"; +const client = DeviceUpdate(endpoint, new DefaultAzureCredential()); ``` ## Key concepts @@ -69,22 +68,17 @@ The following section shows you how to initialize and authenticate your client, - [Get All Devices](#get-all-devices "Get All Devices") -```typescript +```ts snippet:ReadmeSampleGetAllDevices import DeviceUpdate from "@azure-rest/iot-device-update"; import { DefaultAzureCredential } from "@azure/identity"; -async function main() { - console.log("== List devices =="); - const client = DeviceUpdate(endpoint, new DefaultAzureCredential()); - - const result = await client - .path("/deviceupdate/{instanceId}/management/devices", instanceId) - .get(); +const endpoint = "https://.api.adu.microsoft.com"; +const client = DeviceUpdate(endpoint, new DefaultAzureCredential()); - console.log(result); -} +const instanceId = ""; +const result = await client.path("/deviceupdate/{instanceId}/management/devices", instanceId).get(); -main().catch(console.error); +console.log(result); ``` ## Troubleshooting @@ -93,7 +87,7 @@ main().catch(console.error); 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 +```ts snippet:SetLogLevel import { setLogLevel } from "@azure/logger"; setLogLevel("info"); diff --git a/sdk/deviceupdate/iot-device-update-rest/package.json b/sdk/deviceupdate/iot-device-update-rest/package.json index c6d55592074b..a22d38fa0352 100644 --- a/sdk/deviceupdate/iot-device-update-rest/package.json +++ b/sdk/deviceupdate/iot-device-update-rest/package.json @@ -71,7 +71,7 @@ "unit-test": "npm run unit-test:node && npm run unit-test:browser", "unit-test:browser": "npm run clean && dev-tool run build-package && dev-tool run build-test && dev-tool run test:vitest --browser", "unit-test:node": "dev-tool run test:vitest", - "update-snippets": "echo skipped" + "update-snippets": "dev-tool run update-snippets" }, "sideEffects": false, "autoPublish": false, diff --git a/sdk/deviceupdate/iot-device-update-rest/test/snippets.spec.ts b/sdk/deviceupdate/iot-device-update-rest/test/snippets.spec.ts new file mode 100644 index 000000000000..86c0deb9b848 --- /dev/null +++ b/sdk/deviceupdate/iot-device-update-rest/test/snippets.spec.ts @@ -0,0 +1,30 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import DeviceUpdate from "@azure-rest/iot-device-update"; +import { DefaultAzureCredential } from "@azure/identity"; +import { setLogLevel } from "@azure/logger"; +import { describe, it } from "vitest"; + +describe("snippets", () => { + it("ReadmeSampleCreateClient_Node", async () => { + const endpoint = "https://.api.adu.microsoft.com"; + const client = DeviceUpdate(endpoint, new DefaultAzureCredential()); + }); + + it("ReadmeSampleGetAllDevices", async () => { + const endpoint = "https://.api.adu.microsoft.com"; + const client = DeviceUpdate(endpoint, new DefaultAzureCredential()); + // @ts-preserve-whitespace + const instanceId = ""; + const result = await client + .path("/deviceupdate/{instanceId}/management/devices", instanceId) + .get(); + // @ts-preserve-whitespace + console.log(result); + }); + + it("SetLogLevel", async () => { + setLogLevel("info"); + }); +}); diff --git a/sdk/deviceupdate/iot-device-update-rest/vitest.browser.config.ts b/sdk/deviceupdate/iot-device-update-rest/vitest.browser.config.ts index 182729ab5ce9..10e70dbfa8ee 100644 --- a/sdk/deviceupdate/iot-device-update-rest/vitest.browser.config.ts +++ b/sdk/deviceupdate/iot-device-update-rest/vitest.browser.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -9,7 +8,7 @@ export default mergeConfig( viteConfig, defineConfig({ test: { - include: ["dist-test/browser/test/**/*.spec.js",], + include: ["dist-test/browser/test/**/*.spec.js"], testTimeout: 1200000, hookTimeout: 1200000, }, diff --git a/sdk/deviceupdate/iot-device-update-rest/vitest.config.ts b/sdk/deviceupdate/iot-device-update-rest/vitest.config.ts index 40e031385dd8..86a71911ccc2 100644 --- a/sdk/deviceupdate/iot-device-update-rest/vitest.config.ts +++ b/sdk/deviceupdate/iot-device-update-rest/vitest.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. diff --git a/sdk/deviceupdate/iot-device-update-rest/vitest.esm.config.ts b/sdk/deviceupdate/iot-device-update-rest/vitest.esm.config.ts index a70127279fc9..5e9735e9b144 100644 --- a/sdk/deviceupdate/iot-device-update-rest/vitest.esm.config.ts +++ b/sdk/deviceupdate/iot-device-update-rest/vitest.esm.config.ts @@ -1,4 +1,3 @@ - // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. @@ -6,7 +5,4 @@ import { mergeConfig } from "vitest/config"; import vitestConfig from "./vitest.config.ts"; import vitestEsmConfig from "../../../vitest.esm.shared.config.ts"; -export default mergeConfig( - vitestConfig, - vitestEsmConfig -); +export default mergeConfig(vitestConfig, vitestEsmConfig);