Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[synapse] Migrate synapse client projects to use snippets extraction #33177

Merged
merged 82 commits into from
Feb 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
82 commits
Select commit Hold shift + click to select a range
3f802e2
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 24, 2025
20c146d
Migration: Update test config
mpodwysocki Feb 24, 2025
1d513c8
Migration: Clean up files
mpodwysocki Feb 24, 2025
273ff45
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 24, 2025
3e9a75b
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 24, 2025
89d62a3
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 24, 2025
4973f58
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 24, 2025
fa74b94
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 24, 2025
c26be9e
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 24, 2025
ae2316e
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 24, 2025
6d33f0f
Migration: npm run format
mpodwysocki Feb 24, 2025
cc449ac
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 24, 2025
7b49c32
Migration: Update test config
mpodwysocki Feb 24, 2025
94380b8
Migration: Clean up files
mpodwysocki Feb 24, 2025
a224ac7
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 24, 2025
6b30714
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 24, 2025
baa47fb
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 24, 2025
c2dbb10
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 24, 2025
9406761
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 24, 2025
692ccd1
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 24, 2025
696f3de
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 24, 2025
5594fd3
Migration: npm run format
mpodwysocki Feb 24, 2025
c43c7d7
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 24, 2025
8038044
Migration: Update test config
mpodwysocki Feb 24, 2025
094c46d
Migration: Clean up files
mpodwysocki Feb 24, 2025
b6b3e02
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 24, 2025
d95dc4d
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 24, 2025
fffbb06
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 24, 2025
d0aa884
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 24, 2025
a703e95
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 24, 2025
706c2dc
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 24, 2025
d0e7392
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 24, 2025
b4588d5
Migration: npm run format
mpodwysocki Feb 24, 2025
9cf2c2c
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 24, 2025
f7cfa78
Migration: Update test config
mpodwysocki Feb 24, 2025
4ba77e8
Migration: Clean up files
mpodwysocki Feb 24, 2025
558b533
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 24, 2025
7d7c8f3
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 24, 2025
970c1cb
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 24, 2025
22906b2
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 24, 2025
c040aea
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 24, 2025
fa8c200
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 24, 2025
4dcc1e0
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 24, 2025
c22da00
Migration: npm run format
mpodwysocki Feb 24, 2025
1c16db0
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 24, 2025
a8ead00
Migration: Update test config
mpodwysocki Feb 24, 2025
23b08f2
Migration: Clean up files
mpodwysocki Feb 24, 2025
60ec9d2
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 24, 2025
f617464
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 24, 2025
fa6d4e8
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 24, 2025
3ec9f9d
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 24, 2025
b94a0bf
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 24, 2025
75e517f
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 24, 2025
ff2a9d2
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 24, 2025
f2a98e3
Migration: npm run format
mpodwysocki Feb 24, 2025
f65c699
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 24, 2025
dd2c817
Migration: Update test config
mpodwysocki Feb 24, 2025
e9a0365
Migration: Clean up files
mpodwysocki Feb 24, 2025
7cd6243
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 24, 2025
f49cf07
Migration: Update test config
mpodwysocki Feb 24, 2025
9b4df31
Migration: Clean up files
mpodwysocki Feb 24, 2025
35060f8
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 24, 2025
ab02093
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 24, 2025
2c01354
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 24, 2025
cf8de80
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 24, 2025
bf24a8a
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 24, 2025
323271b
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 24, 2025
d96c792
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 24, 2025
325f0aa
Migration: npm run format
mpodwysocki Feb 24, 2025
1846a95
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 24, 2025
ea70c77
Migration: Update test config
mpodwysocki Feb 24, 2025
8d9152f
Migration: Clean up files
mpodwysocki Feb 24, 2025
670329f
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 24, 2025
208da59
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 24, 2025
e500774
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 24, 2025
f9ea115
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 24, 2025
d90a47a
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 24, 2025
2c8fe49
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 24, 2025
a68517f
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 24, 2025
3391833
Migration: npm run format
mpodwysocki Feb 24, 2025
252c266
[synapse] Migrate synapse projects to use snippets extraction
mpodwysocki Feb 24, 2025
169bd5c
[synapse] Migrate synapse projects to use snippets extraction
mpodwysocki Feb 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 11 additions & 16 deletions sdk/synapse/synapse-access-control-rest/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,20 @@ See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUP

## Examples

```ts
import AccessControl, { paginate } from "@azure-rest/synapse-access-control";
```ts snippet:ReadmeSampleCreateClient_Node
import AccessControl, { isUnexpected, paginate } from "@azure-rest/synapse-access-control";
import { DefaultAzureCredential } from "@azure/identity";

export async function main(): Promise<void> {
const client = AccessControl("<endpoint>", new DefaultAzureCredential());
const initialResponse = await client.path("/roleAssignments").get();
const client = AccessControl("<endpoint>", new DefaultAzureCredential());

if (initialResponse.status !== "200") {
throw initialResponse.body.error;
}

const assignments = paginate(client, initialResponse);
const initialResponse = await client.path("/roleAssignments").get();
if (isUnexpected(initialResponse)) {
throw initialResponse.body.error;
}

for await (const assignment of assignments) {
console.log(assignment.id);
}
const assignments = paginate(client, initialResponse);
for await (const assignment of assignments) {
console.log(`Role Assignment ID: ${assignment.id}`);
}
```

Expand All @@ -51,7 +48,7 @@ export async function main(): Promise<void> {

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

```ts
```ts snippet:SetLogLevel
import { setLogLevel } from "@azure/logger";

setLogLevel("info");
Expand All @@ -65,7 +62,5 @@ In the future, you'll find additional code samples here.

If you'd like to contribute to this library, please read the [contributing guide](https://github.com/Azure/azure-sdk-for-js/blob/main/CONTRIBUTING.md) to learn more about how to build and test the code.



[synapse_product_documentation]: https://learn.microsoft.com/rest/api/synapse/data-plane/role-assignments/create-role-assignment
[rest_client]: https://github.com/Azure/azure-sdk-for-js/blob/main/documentation/rest-clients.md
23 changes: 12 additions & 11 deletions sdk/synapse/synapse-access-control-rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"@azure-rest/core-client": "^2.3.1",
"@azure/core-auth": "^1.9.0",
"@azure/core-rest-pipeline": "^1.18.0",
"@azure/core-rest-pipeline": "^1.19.0",
"tslib": "^2.8.1"
},
"//metadata": {
Expand Down Expand Up @@ -37,22 +37,22 @@
"module": "./dist/esm/index.js",
"types": "./dist/commonjs/index.d.ts",
"devDependencies": {
"@azure/logger": "^1.0.0",
"@azure-tools/test-credential": "^2.0.0",
"@azure-tools/test-recorder": "^4.1.0",
"@azure-tools/test-utils-vitest": "^1.0.0",
"@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.7.0",
"@azure/logger": "^1.1.4",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
"@vitest/browser": "^3.0.6",
"@vitest/coverage-istanbul": "^3.0.6",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"playwright": "^1.49.0",
"playwright": "^1.50.1",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
"vitest": "^3.0.6"
},
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
Expand Down Expand Up @@ -82,7 +82,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"
},
"//sampleConfiguration": {
"productName": "Azure Synapse Access Control Rest",
Expand All @@ -99,6 +99,7 @@
"sideEffects": false,
"type": "module",
"tshy": {
"project": "./tsconfig.src.json",
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
Expand All @@ -111,8 +112,7 @@
"browser",
"react-native"
],
"selfLink": false,
"project": "./tsconfig.src.json"
"selfLink": false
},
"exports": {
"./package.json": "./package.json",
Expand All @@ -134,5 +134,6 @@
"default": "./dist/commonjs/index.js"
}
}
}
},
"react-native": "./dist/react-native/index.js"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,7 @@
import AccessControl, { isUnexpected } from "@azure-rest/synapse-access-control";
import { DefaultAzureCredential } from "@azure/identity";
import { randomUUID } from "@azure/core-util";
import dotenv from "dotenv";

dotenv.config();

import "dotenv/config";
const endpoint = process.env["ENDPOINT"] || "";

async function main(): Promise<void> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@

import AccessControl, { isUnexpected, paginate } from "@azure-rest/synapse-access-control";
import { DefaultAzureCredential } from "@azure/identity";
import dotenv from "dotenv";

dotenv.config();

import "dotenv/config";
const endpoint = process.env["ENDPOINT"] || "";

async function main() {
async function main(): Promise<void> {
const client = AccessControl(endpoint, new DefaultAzureCredential());
const initialResponse = await client.path("/roleAssignments").get();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
import AccessControl, { isUnexpected } from "@azure-rest/synapse-access-control";
import { DefaultAzureCredential } from "@azure/identity";
import { v4 } from "uuid";
import dotenv from "dotenv";

dotenv.config();

import "dotenv/config";
const endpoint = process.env["ENDPOINT"] || "";

async function main() {
async function main(): Promise<void> {
const client = AccessControl(endpoint, new DefaultAzureCredential());
const roleAssignmentId = v4();
// Id of the principal to give aassing the tole to.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@

import AccessControl, { isUnexpected, paginate } from "@azure-rest/synapse-access-control";
import { DefaultAzureCredential } from "@azure/identity";
import dotenv from "dotenv";

dotenv.config();

import "dotenv/config";
const endpoint = process.env["ENDPOINT"] || "";

async function main() {
async function main(): Promise<void> {
const client = AccessControl(endpoint, new DefaultAzureCredential());
const initialResponse = await client.path("/roleAssignments").get();

Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import "./env.js";

import type { AccessControlRestClient } from "../../../src/index.js";
import AccessControlClient from "../../../src/index.js";
import type { Recorder } from "@azure-tools/test-recorder";
Expand Down Expand Up @@ -41,8 +39,7 @@ export async function createClient(

export function getWorkspaceName(): string {
const url: string = env.ENDPOINT ?? "";
// eslint-disable-next-line no-useless-escape
const matches = url.match(/^(?:https?:\/\/)?(?:[^@\/\n]+@)?(?:www\.)?([^:\/?\n]+)/) ?? [];
const matches = url.match(/^(?:https?:\/\/)?(?:[^@/\n]+@)?(?:www\.)?([^:/?\n]+)/) ?? [];

if (matches.length < 2) {
throw new Error(`Could not extract workspace name from the environment ENDPOINT`);
Expand Down
27 changes: 27 additions & 0 deletions sdk/synapse/synapse-access-control-rest/test/snippets.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import AccessControl, { isUnexpected, paginate } 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 client = AccessControl("<endpoint>", new DefaultAzureCredential());
// @ts-preserve-whitespace
const initialResponse = await client.path("/roleAssignments").get();
if (isUnexpected(initialResponse)) {
throw initialResponse.body.error;
}
// @ts-preserve-whitespace
const assignments = paginate(client, initialResponse);
for await (const assignment of assignments) {
console.log(`Role Assignment ID: ${assignment.id}`);
}
});

it("SetLogLevel", async () => {
setLogLevel("info");
});
});
12 changes: 9 additions & 3 deletions sdk/synapse/synapse-access-control-rest/tsconfig.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default mergeConfig(
defineConfig({
test: {
include: ["dist-test/browser/test/**/*.spec.js"],
hookTimeout: 500000,
testTimeout: 500000,
testTimeout: 1200000,
hookTimeout: 1200000,
},
}),
);
4 changes: 2 additions & 2 deletions sdk/synapse/synapse-access-control-rest/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ export default mergeConfig(
viteConfig,
defineConfig({
test: {
hookTimeout: 500000,
testTimeout: 500000,
testTimeout: 1200000,
hookTimeout: 1200000,
},
}),
);
Original file line number Diff line number Diff line change
Expand Up @@ -5,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);
25 changes: 10 additions & 15 deletions sdk/synapse/synapse-access-control/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,30 @@ See our [support policy](https://github.com/Azure/azure-sdk-for-js/blob/main/SUP

## Examples

```ts
```ts snippet:ReadmeSampleCreateClient_Node
import { AccessControlClient } from "@azure/synapse-access-control";
import { DefaultAzureCredential } from "@azure/identity";

export async function main(): Promise<void> {
const credential = new DefaultAzureCredential();

const client = new AccessControlClient(
credential,
"https://mysynapse.dev.azuresynapse.net"
);
const list = await client.roleDefinitions.listRoleDefinitions();
for await (const item of list) {
console.log("item:", item);
}
const client = new AccessControlClient(
new DefaultAzureCredential(),
"https://mysynapse.dev.azuresynapse.net",
);

const roleDefinitions = await client.roleDefinitions.listRoleDefinitions();
for await (const roleDefinition of roleDefinitions) {
console.log(`Role Definition ID: ${roleDefinition.id}`);
}
```

## Related projects

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



## Troubleshooting

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

```ts
```ts snippet:SetLogLevel
import { setLogLevel } from "@azure/logger";

setLogLevel("info");
Expand Down
20 changes: 11 additions & 9 deletions sdk/synapse/synapse-access-control/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"@azure/core-auth": "^1.9.0",
"@azure/core-client": "^1.9.2",
"@azure/core-paging": "^1.6.2",
"@azure/core-rest-pipeline": "^1.18.0",
"@azure/core-rest-pipeline": "^1.19.0",
"@azure/core-tracing": "^1.2.0",
"tslib": "^2.8.1"
},
Expand Down Expand Up @@ -48,14 +48,15 @@
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/logger": "^1.1.4",
"@types/node": "^18.0.0",
"@vitest/browser": "^3.0.3",
"@vitest/coverage-istanbul": "^3.0.3",
"@vitest/browser": "^3.0.6",
"@vitest/coverage-istanbul": "^3.0.6",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"playwright": "^1.49.0",
"playwright": "^1.50.1",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
"vitest": "^3.0.6"
},
"bugs": {
"url": "https://github.com/Azure/azure-sdk-for-js/issues"
Expand Down Expand Up @@ -85,12 +86,13 @@
"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": true,
"type": "module",
"tshy": {
"project": "./tsconfig.src.json",
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
Expand All @@ -103,8 +105,7 @@
"browser",
"react-native"
],
"selfLink": false,
"project": "./tsconfig.src.json"
"selfLink": false
},
"exports": {
"./package.json": "./package.json",
Expand All @@ -126,5 +127,6 @@
"default": "./dist/commonjs/index.js"
}
}
}
},
"react-native": "./dist/react-native/index.js"
}

This file was deleted.

Loading
Loading