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

[web-pubsub] Migrate web-pubsub projects to use snippets extraction #33188

Merged
merged 48 commits into from
Feb 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
83be951
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 25, 2025
a33a7a8
Migration: Update test config
mpodwysocki Feb 25, 2025
0c477b2
Migration: Clean up files
mpodwysocki Feb 25, 2025
05f4b70
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 25, 2025
a31aa27
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 25, 2025
1dccbea
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 25, 2025
7f3d4ff
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 25, 2025
96fd53e
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 25, 2025
25880ac
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 25, 2025
ce8b356
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 25, 2025
0aec983
Migration: npm run format
mpodwysocki Feb 25, 2025
94f4d4c
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 25, 2025
12d82f7
Migration: Update test config
mpodwysocki Feb 25, 2025
9602ee7
Migration: Clean up files
mpodwysocki Feb 25, 2025
351b295
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 25, 2025
7854605
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 25, 2025
ceea573
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 25, 2025
b329a6f
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 25, 2025
70447c6
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 25, 2025
69f43f3
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 25, 2025
20a5fb5
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 25, 2025
179baeb
Migration: npm run format
mpodwysocki Feb 25, 2025
bc3b7bc
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 25, 2025
69cbf97
Migration: Update test config
mpodwysocki Feb 25, 2025
922dd55
Migration: Clean up files
mpodwysocki Feb 25, 2025
9dc1d4a
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 25, 2025
3c9adda
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 25, 2025
c9fb898
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 25, 2025
6b76ba3
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 25, 2025
d07fe64
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 25, 2025
adf65a5
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 25, 2025
9f32d8e
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 25, 2025
b492cb1
Migration: npm run format
mpodwysocki Feb 25, 2025
374f53c
Migration: Update package.json, tsconfig.json, and api-extractor.json
mpodwysocki Feb 25, 2025
060a294
Migration: Update test config
mpodwysocki Feb 25, 2025
73d97d4
Migration: Clean up files
mpodwysocki Feb 25, 2025
34bd5d3
Migration: Apply codemod: "fixSourceFile"
mpodwysocki Feb 25, 2025
88ccea7
Migration: Apply codemod: "fixTestingImports"
mpodwysocki Feb 25, 2025
7e75851
Migration: Apply codemod: "replaceAssertIsRejected"
mpodwysocki Feb 25, 2025
8bd2412
Migration: Apply codemod: "replaceSinonStub"
mpodwysocki Feb 25, 2025
0f350c9
Migration: Apply codemod: "addViHelper"
mpodwysocki Feb 25, 2025
26f0149
Migration: Apply codemod: "replaceSupportTracing"
mpodwysocki Feb 25, 2025
dac0c63
Migration: Apply codemod: "replaceTestUtils"
mpodwysocki Feb 25, 2025
d9bb712
Migration: npm run format
mpodwysocki Feb 25, 2025
7c34e9c
[web-pubsub] Migrate web-pubsub projects to use snippets extraction
mpodwysocki Feb 25, 2025
09e1b5b
[web-pubsub] Migrate web-pubsub projects to use snippets extraction
mpodwysocki Feb 25, 2025
776b797
[web-pubsub] Migrate web-pubsub projects to use snippets extraction
mpodwysocki Feb 25, 2025
04f3eb7
[web-pubsub] Migrate web-pubsub projects to use snippets extraction
mpodwysocki Feb 25, 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
36 changes: 20 additions & 16 deletions common/config/rush/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 23 additions & 8 deletions sdk/web-pubsub/web-pubsub-client-protobuf/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Web PubSub client protobuf protocol library for JavaScript

[Azure Web PubSub](https://aka.ms/awps/doc) is a cloud service that helps developers easily build real-time features in web applications with publish-subscribe patterns at scale.
[Azure Web PubSub](https://aka.ms/awps/doc) is a cloud service that helps developers easily build real-time features in web applications with publish-subscribe patterns at scale.

You can use this library to add protobuf subprotocols including `protobuf.reliable.webpubsub.azure.v1` and `protobuf.webpubsub.azure.v1` support to `@azure/web-pubsub-client` library.


## Getting started

### Currently supported environments
Expand All @@ -24,39 +23,55 @@ npm install @azure/web-pubsub-client-protobuf

### 2. Use Protobuf protocols

```javascript
const client = new WebPubSubClient("client-access-url", { protocol: WebPubSubProtobufReliableProtocol() });
```ts snippet:ReadmeSampleCreateClient
import { WebPubSubClient } from "@azure/web-pubsub-client";
import { WebPubSubProtobufReliableProtocol } from "@azure/web-pubsub-client-protobuf";

const client = new WebPubSubClient("client-access-url", {
protocol: WebPubSubProtobufReliableProtocol(),
});
```

## Troubleshooting

- ### Enable logs
### Enable logs

You can set the following environment variable to get the debug logs when using this library.
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`.

```bash
export AZURE_LOG_LEVEL=verbose
```

Alternatively, logging can be enabled at runtime by calling `setLogLevel` in the `@azure/logger`:

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

setLogLevel("info");
```

For more detailed instructions on how to enable logs, you can look at the [@azure/logger package docs](https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/core/logger).

- ### Live Trace

Use [Live Trace tool][live_trace] from Web PubSub portal to view the live traffic.

---

## Additional resources

- Learn more about client permission, see [permissions](https://learn.microsoft.com/azure/azure-web-pubsub/reference-json-reliable-webpubsub-subprotocol#permissions)

- [Server SDK - JavaScript documentation](https://aka.ms/awps/sdk/js)
- [Server SDK - JavaScript documentation](https://aka.ms/awps/sdk/js)
- [Product documentation](https://aka.ms/awps/doc)
- [Samples][samples_ref]

---

## Contributing

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.


[azure_sub]: https://azure.microsoft.com/free/
[samples_ref]: https://github.com/Azure/azure-webpubsub/tree/main/samples/javascript/
[create_instance]: https://learn.microsoft.com/azure/azure-web-pubsub/howto-develop-create-instance
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./dist/web-pubsub-client-protobuf.d.ts"
"publicTrimmedFilePath": "dist/web-pubsub-client-protobuf.d.ts"
},
"messages": {
"tsdocMessageReporting": {
Expand Down
41 changes: 26 additions & 15 deletions sdk/web-pubsub/web-pubsub-client-protobuf/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@
"type": "module",
"main": "./dist/commonjs/index.js",
"module": "./dist/esm/index.js",
"browser": {
"buffer": "buffer",
"default": "dist/browser/index.js"
},
"browser": "./dist/browser/index.js",
"types": "./dist/commonjs/index.d.ts",
"scripts": {
"build": "npm run clean && npm run build-protobuf && dev-tool run build-package && npm run copy-files && dev-tool run extract-api",
Expand Down Expand Up @@ -39,13 +36,11 @@
"test:node": "npm run build:test && npm run unit-test:node && npm run integration-test:node",
"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 --no-test-proxy",
"update-snippets": "echo skipped"
"unit-test:node": "dev-tool run test:vitest",
"update-snippets": "dev-tool run update-snippets"
},
"files": [
"dist/",
"types/web-pubsub-client-protobuf.d.ts",
"types/web-pubsub-client-protobuf.d.ts.map",
"README.md",
"LICENSE"
],
Expand All @@ -65,25 +60,28 @@
"homepage": "https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/web-pubsub/web-pubsub-client/README.md",
"sideEffects": false,
"dependencies": {
"@azure/logger": "^1.0.0",
"@azure/logger": "^1.1.4",
"@azure/web-pubsub-client": "1.0.0-beta.2",
"long": "^5.3.1",
"protobufjs": "^7.4.0",
"tslib": "^2.6.2"
"tslib": "^2.8.1"
},
"devDependencies": {
"@azure-tools/test-utils-vitest": "^1.0.0",
"@azure/dev-tool": "^1.0.0",
"@azure/eslint-plugin-azure-sdk": "^3.0.0",
"@azure/web-pubsub": "^1.1.0",
"@types/node": "^18.0.0",
"@vitest/coverage-istanbul": "^3.0.3",
"@vitest/browser": "^3.0.6",
"@vitest/coverage-istanbul": "^3.0.6",
"cpy-cli": "^5.0.0",
"dotenv": "^16.0.0",
"eslint": "^9.9.0",
"move-file-cli": "^3.0.0",
"playwright": "^1.50.1",
"protobufjs-cli": "^1.1.3",
"typescript": "~5.7.2",
"vitest": "^3.0.3"
"vitest": "^3.0.6"
},
"//sampleConfiguration": {
"productName": "Azure Web PubSub Client",
Expand All @@ -92,6 +90,7 @@
]
},
"tshy": {
"project": "./tsconfig.src.json",
"exports": {
"./package.json": "./package.json",
".": "./src/index.ts"
Expand All @@ -100,12 +99,23 @@
"esm",
"commonjs"
],
"selfLink": false,
"project": "./tsconfig.src.json"
"esmDialects": [
"browser",
"react-native"
],
"selfLink": false
},
"exports": {
"./package.json": "./package.json",
".": {
"browser": {
"types": "./dist/browser/index.d.ts",
"default": "./dist/browser/index.js"
},
"react-native": {
"types": "./dist/react-native/index.d.ts",
"default": "./dist/react-native/index.js"
},
"import": {
"types": "./dist/esm/index.d.ts",
"default": "./dist/esm/index.js"
Expand All @@ -115,5 +125,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 @@ -5,13 +5,13 @@
* @summary Basic usage of web-pubsub-client
*/

import {
WebPubSubClient,
import type {
WebPubSubClientCredential,
SendToGroupOptions,
GetClientAccessUrlOptions,
WebPubSubClientOptions,
} from "@azure/web-pubsub-client";
import { WebPubSubClient } from "@azure/web-pubsub-client";
import { WebPubSubProtobufReliableProtocol } from "@azure/web-pubsub-client-protobuf";
import { WebPubSubServiceClient } from "@azure/web-pubsub";
import "dotenv/config";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const fetchClientAccessUrl = async (_: GetClientAccessUrlOptions) => {
).url;
};

async function main() {
async function main(): Promise<void> {
let client = new WebPubSubClient(
{
getClientAccessUrl: fetchClientAccessUrl,
Expand Down
19 changes: 19 additions & 0 deletions sdk/web-pubsub/web-pubsub-client-protobuf/test/snippets.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import { setLogLevel } from "@azure/logger";
import { WebPubSubClient } from "@azure/web-pubsub-client";
import { describe, it } from "vitest";
import { WebPubSubProtobufReliableProtocol } from "../src/index.js";

describe("snippets", () => {
it("ReadmeSampleCreateClient", async () => {
const client = new WebPubSubClient("client-access-url", {
protocol: WebPubSubProtobufReliableProtocol(),
});
});

it("SetLogLevel", async () => {
setLogLevel("info");
});
});
12 changes: 9 additions & 3 deletions sdk/web-pubsub/web-pubsub-client-protobuf/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"
}
]
}
Loading