@azure/web-pubsub 1.1.4-alpha.20241028.1 → 1.1.4-alpha.20241030.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- {"version":3,"file":"integration.spec.js","sourceRoot":"","sources":["../../test/integration.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,SAAS,KAAK;IAKZ,IAAI,aAA6B,CAAC;IAClC,IAAI,YAAkC,CAAC;IAEvC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,aAAa,GAAG,OAAO,CAAC;QACxB,YAAY,GAAG,MAAM,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,OAAO,EAAE,aAAc;QACvB,MAAM,EAAE,YAAa;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,oBAAoB;IAExB,YACS,IAAqC,EACrC,QAAiB;QADjB,SAAI,GAAJ,IAAI,CAAiC;QACrC,aAAQ,GAAR,QAAQ,CAAS;QAExB,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC;QACtC,CAAC;IACH,CAAC;IAED,WAAW,CAAC,KAAyB,SAAS;QAC5C,OAAO,CACL,IAAI,CAAC,QAAQ;YACb,IAAI,CAAC,IAAI,YAAY,MAAM;YAC3B,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;YAClB,IAAI,CAAC,IAAI,CAAC,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MAAM,aAAa,CAAC,SAAS,CAAC,UAAU,EAAE;YACxC,WAAW,EAAE,YAAY;YACzB,MAAM,EAAE,2CAA2C;SACpD,CAAC,CAAC;QAEH,qCAAqC;QACrC,MAAM,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;YAC7C,MAAM,EAAE,2CAA2C;SACpD,CAAC,CAAC;QAEH,kBAAkB;QAClB,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7F,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACjC,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/* eslint-disable no-invalid-this */\nimport { WebPubSubServiceClient, odata } from \"../src/index\";\nimport { isLiveMode, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport { Context } from \"mocha\";\nimport { assert } from \"chai\";\nimport ws from \"ws\";\n\nfunction defer<T>(): {\n promise: Promise<T>;\n resolve: (t: T) => void;\n reject: (err: Error) => void;\n} {\n let actualResolve: (t: T) => void;\n let actualReject: (err: Error) => void;\n\n const promise = new Promise<T>((resolve, reject) => {\n actualResolve = resolve;\n actualReject = reject;\n });\n\n return {\n promise,\n resolve: actualResolve!,\n reject: actualReject!,\n };\n}\n\nclass SimpleWebSocketFrame {\n public dataAsString: string | undefined;\n constructor(\n public data: Buffer | ArrayBuffer | Buffer[],\n public isBinary: boolean,\n ) {\n if (!isBinary) {\n this.dataAsString = data.toString();\n }\n }\n\n isEndSignal(id: number | undefined = undefined): boolean {\n return (\n this.isBinary &&\n this.data instanceof Buffer &&\n this.data[0] === 5 &&\n this.data[1] === 1 &&\n this.data[2] === 1 &&\n (id === undefined || this.data[3] === id)\n );\n }\n\n toString(): string | undefined {\n if (this.isEndSignal()) {\n return \"|EndSignal|\";\n }\n if (!this.isBinary) {\n return this.dataAsString;\n } else {\n return this.data.toString();\n }\n }\n}\n\nclass PubSubWebSocketFrame {\n public message: any;\n public dataAsString: string;\n constructor(data: Buffer | ArrayBuffer | Buffer[], isBinary: boolean) {\n assert.isFalse(isBinary);\n this.dataAsString = data.toString();\n this.message = JSON.parse(this.dataAsString);\n }\n\n isEndSignal(): boolean {\n return this.message.dataType === \"binary\" && this.message.data === \"BQEB\";\n }\n\n toString(): string | undefined {\n if (this.isEndSignal()) {\n return \"|EndSignal|\";\n }\n\n return this.dataAsString;\n }\n}\n\nfunction getEndSignal(id: number | undefined = undefined): Uint8Array {\n // magic number 511\n const payload = new Uint8Array(id === undefined ? 3 : 4);\n payload[0] = 5;\n payload[1] = 1;\n payload[2] = 1;\n if (id !== undefined) {\n payload[3] = id;\n }\n return payload;\n}\n\ndescribe(\"ServiceClient to manage the connected WebSocket connections\", function () {\n it(\"Simple clients can receive expected messages with different content types\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"SimpleClientCanReceiveMessage\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 2);\n assert.equal(messages[0].dataAsString, '{\"message\":\"Hello world!\"}');\n assert.equal(messages[1].dataAsString, \"Hi there!\");\n });\n\n it(\"Simple clients can can join group and receive group messages\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"SimpleClientCanReceiveGroupMessage\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken({\n groups: [\"group1\", \"group2\"],\n });\n const end1Signal = defer<void>();\n const end2Signal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.isEndSignal(1)) {\n end1Signal.resolve();\n } else if (frame.isEndSignal(2)) {\n end2Signal.resolve();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n const group1Client = serviceClient.group(\"group1\");\n const group2Client = serviceClient.group(\"group2\");\n // send to all\n // Send a JSON message\n await group1Client.sendToAll({ message: \"Hello world from group1!\" });\n await group2Client.sendToAll(getEndSignal(1));\n // Send a plain text message\n await group2Client.sendToAll(\"Hi there from group2!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await group2Client.sendToAll(getEndSignal(2));\n });\n\n await end1Signal.promise;\n await end2Signal.promise;\n client.close();\n assert.equal(messages.length, 2);\n\n // order from different groups is not guaranteed\n assert.isTrue(\n messages.findIndex((s) => s.dataAsString === '{\"message\":\"Hello world from group1!\"}') > -1,\n );\n assert.isTrue(messages.findIndex((s) => s.dataAsString === \"Hi there from group2!\") > -1);\n });\n\n it(\"Subprotocol clients can receive expected messages with different content types\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"PubSubClientCanReceiveMessage\";\n const messages: PubSubWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n const connectedSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url, \"json.webpubsub.azure.v1\");\n client.on(\"message\", (data, isBinary) => {\n const frame = new PubSubWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.message.event === \"connected\") {\n connectedSignal.resolve();\n }\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n await connectedSignal.promise;\n\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 3);\n assert.equal(messages[0].message.event, \"connected\");\n assert.equal(\n messages[1].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"json\",\"data\":{\"message\":\"Hello world!\"}}',\n );\n assert.equal(\n messages[2].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"text\",\"data\":\"Hi there!\"}',\n );\n });\n\n it(\"Clients can receive messages with filters\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"ClientCanReceiveMessageWithFilters\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken({ groups: [\"groupA\"] });\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n // Send a JSON message to anonymous connections\n await serviceClient.sendToAll(\n { message: \"Hello world!\" },\n { filter: \"userId eq null\", messageTtlSeconds: 60 },\n );\n // Send a text message to connections in groupA but not in groupB\n const groupA = \"groupA\";\n const groupB = \"groupB\";\n await serviceClient.sendToAll(\"Hello world!\", {\n contentType: \"text/plain\",\n // use plain text \"'groupA' in groups and not('groupB' in groups)\"\n // or use the odata helper method\n filter: odata`${groupA} in groups and not(${groupB} in groups)`,\n messageTtlSeconds: 60,\n });\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 2);\n assert.equal(messages[0].dataAsString, '{\"message\":\"Hello world!\"}');\n assert.equal(messages[1].dataAsString, \"Hello world!\");\n });\n\n it(\"Clients can join or leave multiple groups with filter\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"ClientsCanJoinOrLeaveMultipleGroupsWithFilter\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken({ userId: \"user 1\" });\n const startSignal = defer<void>();\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client1 = new ws.WebSocket(token.url);\n const client2 = new ws.WebSocket(token.url);\n let opened = 0;\n\n const onOpen = (): void => {\n opened++;\n if (opened === 2) {\n startSignal.resolve();\n }\n };\n const onMessage = (data: Buffer | ArrayBuffer | Buffer[], isBinary: boolean): void => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n messages.push(frame);\n if (messages.length === 6) {\n endSignal.resolve();\n }\n };\n client1.on(\"open\", onOpen);\n client2.on(\"open\", onOpen);\n client1.on(\"message\", onMessage);\n client2.on(\"message\", onMessage);\n\n // Wait all clients opened\n await startSignal.promise;\n\n // Add filtered connections to group1 and group2\n await serviceClient.addConnectionsToGroups([\"group1\", \"group2\"], \"userId eq 'user 1'\");\n\n // send to connections in both group1 and group2\n await serviceClient.sendToAll(\n { message: \"Hi json!\" },\n { filter: \"'group1' in groups and 'group2' in groups\" },\n );\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi text!\", {\n contentType: \"text/plain\",\n filter: \"'group1' in groups and 'group2' in groups\",\n });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal(2), {\n filter: \"'group1' in groups and 'group2' in groups\",\n });\n\n // Timeout 1000 ms\n await Promise.race([new Promise((resolve) => setTimeout(resolve, 1000)), endSignal.promise]);\n assert.equal(messages.length, 6);\n client1.close();\n client2.close();\n });\n});\n"]}
1
+ {"version":3,"file":"integration.spec.js","sourceRoot":"","sources":["../../test/integration.spec.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,oCAAoC;AACpC,OAAO,EAAE,sBAAsB,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAC;AAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,SAAS,KAAK;IAKZ,IAAI,aAA6B,CAAC;IAClC,IAAI,YAAkC,CAAC;IAEvC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,aAAa,GAAG,OAAO,CAAC;QACxB,YAAY,GAAG,MAAM,CAAC;IACxB,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO;QACP,OAAO,EAAE,aAAc;QACvB,MAAM,EAAE,YAAa;KACtB,CAAC;AACJ,CAAC;AAED,MAAM,oBAAoB;IAExB,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AC,CAAC;QAC3B,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACjC,OAAO,CAAC,EAAE,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAEjC,0BAA0B;QAC1B,MAAM,WAAW,CAAC,OAAO,CAAC;QAE1B,gDAAgD;QAChD,MAAM,aAAa,CAAC,sBAAsB,CAAC,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,oBAAoB,CAAC,CAAC;QAEvF,gDAAgD;QAChD,MAAM,aAAa,CAAC,SAAS,CAC3B,EAAE,OAAO,EAAE,UAAU,EAAE,EACvB,EAAE,MAAM,EAAE,2CAA2C,EAAE,CACxD,CAAC;QAEF,4BAA4B;QAC5B,MAAM,aAAa,CAAC,SAAS,CAAC,UAAU,EAAE;YACxC,WAAW,EAAE,YAAY;YACzB,MAAM,EAAE,2CAA2C;SACpD,CAAC,CAAC;QAEH,qCAAqC;QACrC,MAAM,aAAa,CAAC,SAAS,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE;YAC7C,MAAM,EAAE,2CAA2C;SACpD,CAAC,CAAC;QAEH,kBAAkB;QAClB,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC;QAC7F,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;QACjC,OAAO,CAAC,KAAK,EAAE,CAAC;QAChB,OAAO,CAAC,KAAK,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n/* eslint-disable no-invalid-this */\nimport { WebPubSubServiceClient, odata } from \"../src/index\";\nimport { isLiveMode, assertEnvironmentVariable } from \"@azure-tools/test-recorder\";\nimport type { Context } from \"mocha\";\nimport { assert } from \"chai\";\nimport ws from \"ws\";\n\nfunction defer<T>(): {\n promise: Promise<T>;\n resolve: (t: T) => void;\n reject: (err: Error) => void;\n} {\n let actualResolve: (t: T) => void;\n let actualReject: (err: Error) => void;\n\n const promise = new Promise<T>((resolve, reject) => {\n actualResolve = resolve;\n actualReject = reject;\n });\n\n return {\n promise,\n resolve: actualResolve!,\n reject: actualReject!,\n };\n}\n\nclass SimpleWebSocketFrame {\n public dataAsString: string | undefined;\n constructor(\n public data: Buffer | ArrayBuffer | Buffer[],\n public isBinary: boolean,\n ) {\n if (!isBinary) {\n this.dataAsString = data.toString();\n }\n }\n\n isEndSignal(id: number | undefined = undefined): boolean {\n return (\n this.isBinary &&\n this.data instanceof Buffer &&\n this.data[0] === 5 &&\n this.data[1] === 1 &&\n this.data[2] === 1 &&\n (id === undefined || this.data[3] === id)\n );\n }\n\n toString(): string | undefined {\n if (this.isEndSignal()) {\n return \"|EndSignal|\";\n }\n if (!this.isBinary) {\n return this.dataAsString;\n } else {\n return this.data.toString();\n }\n }\n}\n\nclass PubSubWebSocketFrame {\n public message: any;\n public dataAsString: string;\n constructor(data: Buffer | ArrayBuffer | Buffer[], isBinary: boolean) {\n assert.isFalse(isBinary);\n this.dataAsString = data.toString();\n this.message = JSON.parse(this.dataAsString);\n }\n\n isEndSignal(): boolean {\n return this.message.dataType === \"binary\" && this.message.data === \"BQEB\";\n }\n\n toString(): string | undefined {\n if (this.isEndSignal()) {\n return \"|EndSignal|\";\n }\n\n return this.dataAsString;\n }\n}\n\nfunction getEndSignal(id: number | undefined = undefined): Uint8Array {\n // magic number 511\n const payload = new Uint8Array(id === undefined ? 3 : 4);\n payload[0] = 5;\n payload[1] = 1;\n payload[2] = 1;\n if (id !== undefined) {\n payload[3] = id;\n }\n return payload;\n}\n\ndescribe(\"ServiceClient to manage the connected WebSocket connections\", function () {\n it(\"Simple clients can receive expected messages with different content types\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"SimpleClientCanReceiveMessage\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 2);\n assert.equal(messages[0].dataAsString, '{\"message\":\"Hello world!\"}');\n assert.equal(messages[1].dataAsString, \"Hi there!\");\n });\n\n it(\"Simple clients can can join group and receive group messages\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"SimpleClientCanReceiveGroupMessage\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken({\n groups: [\"group1\", \"group2\"],\n });\n const end1Signal = defer<void>();\n const end2Signal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.isEndSignal(1)) {\n end1Signal.resolve();\n } else if (frame.isEndSignal(2)) {\n end2Signal.resolve();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n const group1Client = serviceClient.group(\"group1\");\n const group2Client = serviceClient.group(\"group2\");\n // send to all\n // Send a JSON message\n await group1Client.sendToAll({ message: \"Hello world from group1!\" });\n await group2Client.sendToAll(getEndSignal(1));\n // Send a plain text message\n await group2Client.sendToAll(\"Hi there from group2!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await group2Client.sendToAll(getEndSignal(2));\n });\n\n await end1Signal.promise;\n await end2Signal.promise;\n client.close();\n assert.equal(messages.length, 2);\n\n // order from different groups is not guaranteed\n assert.isTrue(\n messages.findIndex((s) => s.dataAsString === '{\"message\":\"Hello world from group1!\"}') > -1,\n );\n assert.isTrue(messages.findIndex((s) => s.dataAsString === \"Hi there from group2!\") > -1);\n });\n\n it(\"Subprotocol clients can receive expected messages with different content types\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"PubSubClientCanReceiveMessage\";\n const messages: PubSubWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken();\n const endSignal = defer<void>();\n const connectedSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url, \"json.webpubsub.azure.v1\");\n client.on(\"message\", (data, isBinary) => {\n const frame = new PubSubWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.message.event === \"connected\") {\n connectedSignal.resolve();\n }\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n await connectedSignal.promise;\n\n // send to all\n // Send a JSON message\n await serviceClient.sendToAll({ message: \"Hello world!\" });\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi there!\", { contentType: \"text/plain\" });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 3);\n assert.equal(messages[0].message.event, \"connected\");\n assert.equal(\n messages[1].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"json\",\"data\":{\"message\":\"Hello world!\"}}',\n );\n assert.equal(\n messages[2].dataAsString,\n '{\"type\":\"message\",\"from\":\"server\",\"dataType\":\"text\",\"data\":\"Hi there!\"}',\n );\n });\n\n it(\"Clients can receive messages with filters\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"ClientCanReceiveMessageWithFilters\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken({ groups: [\"groupA\"] });\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client = new ws.WebSocket(token.url);\n client.on(\"message\", (data, isBinary) => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n if (frame.isEndSignal()) {\n endSignal.resolve();\n client.close();\n } else {\n messages.push(frame);\n }\n });\n client.on(\"open\", async () => {\n // Send a JSON message to anonymous connections\n await serviceClient.sendToAll(\n { message: \"Hello world!\" },\n { filter: \"userId eq null\", messageTtlSeconds: 60 },\n );\n // Send a text message to connections in groupA but not in groupB\n const groupA = \"groupA\";\n const groupB = \"groupB\";\n await serviceClient.sendToAll(\"Hello world!\", {\n contentType: \"text/plain\",\n // use plain text \"'groupA' in groups and not('groupB' in groups)\"\n // or use the odata helper method\n filter: odata`${groupA} in groups and not(${groupB} in groups)`,\n messageTtlSeconds: 60,\n });\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal());\n });\n\n await endSignal.promise;\n\n assert.equal(messages.length, 2);\n assert.equal(messages[0].dataAsString, '{\"message\":\"Hello world!\"}');\n assert.equal(messages[1].dataAsString, \"Hello world!\");\n });\n\n it(\"Clients can join or leave multiple groups with filter\", async function (this: Context) {\n if (!isLiveMode()) this.skip();\n const hub = \"ClientsCanJoinOrLeaveMultipleGroupsWithFilter\";\n\n const messages: SimpleWebSocketFrame[] = [];\n\n // Get token\n const serviceClient = new WebPubSubServiceClient(\n assertEnvironmentVariable(\"WPS_CONNECTION_STRING\"),\n hub,\n );\n const token = await serviceClient.getClientAccessToken({ userId: \"user 1\" });\n const startSignal = defer<void>();\n const endSignal = defer<void>();\n // Start simple WebSocket connections\n const client1 = new ws.WebSocket(token.url);\n const client2 = new ws.WebSocket(token.url);\n let opened = 0;\n\n const onOpen = (): void => {\n opened++;\n if (opened === 2) {\n startSignal.resolve();\n }\n };\n const onMessage = (data: Buffer | ArrayBuffer | Buffer[], isBinary: boolean): void => {\n const frame = new SimpleWebSocketFrame(data, isBinary);\n console.log(frame.toString());\n messages.push(frame);\n if (messages.length === 6) {\n endSignal.resolve();\n }\n };\n client1.on(\"open\", onOpen);\n client2.on(\"open\", onOpen);\n client1.on(\"message\", onMessage);\n client2.on(\"message\", onMessage);\n\n // Wait all clients opened\n await startSignal.promise;\n\n // Add filtered connections to group1 and group2\n await serviceClient.addConnectionsToGroups([\"group1\", \"group2\"], \"userId eq 'user 1'\");\n\n // send to connections in both group1 and group2\n await serviceClient.sendToAll(\n { message: \"Hi json!\" },\n { filter: \"'group1' in groups and 'group2' in groups\" },\n );\n\n // Send a plain text message\n await serviceClient.sendToAll(\"Hi text!\", {\n contentType: \"text/plain\",\n filter: \"'group1' in groups and 'group2' in groups\",\n });\n\n // Send the binary end signal message\n await serviceClient.sendToAll(getEndSignal(2), {\n filter: \"'group1' in groups and 'group2' in groups\",\n });\n\n // Timeout 1000 ms\n await Promise.race([new Promise((resolve) => setTimeout(resolve, 1000)), endSignal.promise]);\n assert.equal(messages.length, 6);\n client1.close();\n client2.close();\n });\n});\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"testEnv.js","sourceRoot":"","sources":["../../test/testEnv.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,mBAAmB,GAA2B;IAClD,qBAAqB,EAAE,kDAAkD;IACzE,WAAW,EAAE,SAAS;IACtB,YAAY,EAAE,kBAAkB;IAChC,0BAA0B,EAAE,kBAAkB;CAC/C,CAAC;AAEF,MAAM,eAAe,GAAyB;IAC5C,mBAAmB;CACpB,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { RecorderStartOptions } from \"@azure-tools/test-recorder\";\n\nconst envSetupForPlayback: Record<string, string> = {\n WPS_CONNECTION_STRING: \"Endpoint=endpoint;AccessKey=api_key;Version=1.0;\",\n WPS_API_KEY: \"api_key\",\n WPS_ENDPOINT: \"https://endpoint\",\n WPS_REVERSE_PROXY_ENDPOINT: \"https://endpoint\",\n};\n\nconst recorderOptions: RecorderStartOptions = {\n envSetupForPlayback,\n};\n\nexport default recorderOptions;\n"]}
1
+ {"version":3,"file":"testEnv.js","sourceRoot":"","sources":["../../test/testEnv.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAIlC,MAAM,mBAAmB,GAA2B;IAClD,qBAAqB,EAAE,kDAAkD;IACzE,WAAW,EAAE,SAAS;IACtB,YAAY,EAAE,kBAAkB;IAChC,0BAA0B,EAAE,kBAAkB;CAC/C,CAAC;AAEF,MAAM,eAAe,GAAyB;IAC5C,mBAAmB;CACpB,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type { RecorderStartOptions } from \"@azure-tools/test-recorder\";\n\nconst envSetupForPlayback: Record<string, string> = {\n WPS_CONNECTION_STRING: \"Endpoint=endpoint;AccessKey=api_key;Version=1.0;\",\n WPS_API_KEY: \"api_key\",\n WPS_ENDPOINT: \"https://endpoint\",\n WPS_REVERSE_PROXY_ENDPOINT: \"https://endpoint\",\n};\n\nconst recorderOptions: RecorderStartOptions = {\n envSetupForPlayback,\n};\n\nexport default recorderOptions;\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@azure/web-pubsub",
3
- "version": "1.1.4-alpha.20241028.1",
3
+ "version": "1.1.4-alpha.20241030.1",
4
4
  "description": "Azure client library for Azure Web PubSub",
5
5
  "sdk-type": "client",
6
6
  "main": "dist/index.js",
@@ -1,8 +1,8 @@
1
1
  import { AzureKeyCredential } from '@azure/core-auth';
2
- import { CommonClientOptions } from '@azure/core-client';
3
- import { OperationOptions } from '@azure/core-client';
4
- import { RequestBodyType } from '@azure/core-rest-pipeline';
5
- import { TokenCredential } from '@azure/core-auth';
2
+ import type { CommonClientOptions } from '@azure/core-client';
3
+ import type { OperationOptions } from '@azure/core-client';
4
+ import type { RequestBodyType } from '@azure/core-rest-pipeline';
5
+ import type { TokenCredential } from '@azure/core-auth';
6
6
 
7
7
  export { AzureKeyCredential }
8
8