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

Add client libraries #11385

Merged
merged 1 commit into from
Sep 22, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
335 changes: 333 additions & 2 deletions common/config/rush/pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions eng/.docsettings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ omitted_paths:
- eng/*
- sdk/*/arm-*
- sdk/cognitiveservices/*
- sdk/communication/*/test/README.md
- sdk/identity/identity/test/manual/*
- sdk/identity/identity/test/manual-integration/*
- sdk/test-utils/perfstress/README.md
Expand Down
10 changes: 5 additions & 5 deletions eng/pipelines/templates/steps/analyze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,11 @@ steps:
displayName: "Audit libraries"

- ${{ each artifact in parameters.Artifacts }}:
- template: /eng/common/pipelines/templates/steps/verify-changelog.yml
parameters:
PackageName: ${{artifact.name}}
ServiceName: ${{parameters.ServiceDirectory}}
ForRelease: false
- template: /eng/common/pipelines/templates/steps/verify-changelog.yml
parameters:
PackageName: ${{artifact.name}}
ServiceName: ${{parameters.ServiceDirectory}}
ForRelease: false

- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
# ComponentGovernance is currently unable to run on pull requests of public projects. Running on non-PR
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/templates/steps/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ steps:
displayName: "Build libraries"

- pwsh: |
eng/tools/check-api-warning.ps1
eng/tools/check-api-warning.ps1
displayName: "Check api extractor output changes"

- script: |
Expand Down
8 changes: 4 additions & 4 deletions eng/pipelines/templates/steps/test.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
parameters:
Artifacts: []
ServiceDirectory: not-specified

steps:
- script: |
node common/scripts/install-run-rush.js install
Expand All @@ -27,7 +27,7 @@ steps:
node eng/tools/rush-runner.js unit-test:node "${{parameters.ServiceDirectory}}" --verbose -p max
displayName: "Test libraries"
condition: and(succeeded(),eq(variables['TestType'], 'node'))

# Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times.
# The default on Windows is "cores - 1" (microsoft/rushstack#436).
- script: |
Expand Down Expand Up @@ -56,7 +56,7 @@ steps:
# PublishTestResults.searchFolder only supports absolute paths, not relative.
- task: PublishTestResults@2
inputs:
searchFolder: '$(System.DefaultWorkingDirectory)/sdk'
searchFolder: "$(System.DefaultWorkingDirectory)/sdk"
testResultsFiles: "**/test-results.xml"
testRunTitle: "$(OSName) - NodeJS - Unit Tests - [Node $(NodeTestVersion)]"
condition: and(always(),eq(variables['TestType'], 'node'))
Expand All @@ -66,7 +66,7 @@ steps:
# PublishTestResults.searchFolder only supports absolute paths, not relative.
- task: PublishTestResults@2
inputs:
searchFolder: '$(System.DefaultWorkingDirectory)/sdk'
searchFolder: "$(System.DefaultWorkingDirectory)/sdk"
testResultsFiles: "**/test-results.browser.xml"
testRunTitle: "$(OSName) - Browser - Unit Tests - [Node $(NodeTestVersion)]"
condition: and(always(),eq(variables['TestType'], 'browser'))
Expand Down
20 changes: 20 additions & 0 deletions rush.json
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,26 @@
"projectFolder": "sdk/search/search-documents",
"versionPolicyName": "client"
},
{
"packageName": "@azure/communication-administration",
"projectFolder": "sdk/communication/communication-administration",
"versionPolicyName": "client"
},
{
"packageName": "@azure/communication-chat",
"projectFolder": "sdk/communication/communication-chat",
"versionPolicyName": "client"
},
{
"packageName": "@azure/communication-common",
"projectFolder": "sdk/communication/communication-common",
"versionPolicyName": "client"
},
{
"packageName": "@azure/communication-sms",
"projectFolder": "sdk/communication/communication-sms",
"versionPolicyName": "client"
},
{
"packageName": "@azure/core-amqp",
"projectFolder": "sdk/core/core-amqp",
Expand Down
8 changes: 8 additions & 0 deletions sdk/communication/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,11 @@ extends:
parameters:
ServiceDirectory: communication
Artifacts:
- name: azure-communication-common
safeName: azurecommunicationcommon
- name: azure-communication-administration
safeName: azurecommunicationadministration
- name: azure-communication-sms
safeName: azurecommunicationsms
- name: azure-communication-chat
safeName: azurecommunicationchat
18 changes: 18 additions & 0 deletions sdk/communication/communication-administration/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"plugins": ["@azure/azure-sdk"],
"extends": ["plugin:@azure/azure-sdk/azure-sdk-base"],
"rules": {
"@azure/azure-sdk/ts-naming-options": "off"
// "@azure/azure-sdk/ts-config-declaration": "off",
// "@azure/azure-sdk/ts-config-allowsyntheticdefaultimports": "off",
// "@azure/azure-sdk/ts-config-esmoduleinterop": "off",
// "@azure/azure-sdk/ts-config-forceconsistentcasinginfilenames": "off",
// "@azure/azure-sdk/ts-config-importhelpers": "off",
// "@azure/azure-sdk/ts-config-module": "off",
// "@azure/azure-sdk/ts-config-moduleresolution": "off",
// "@azure/azure-sdk/ts-config-sourcemap": "off",
// "@azure/azure-sdk/ts-config-strict": "off",
// "@azure/azure-sdk/ts-config-target": "off",
// "@azure/azure-sdk/ts-config-lib": "off"
}
}
2 changes: 2 additions & 0 deletions sdk/communication/communication-administration/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/**/code-model-v*
/docGen
42 changes: 42 additions & 0 deletions sdk/communication/communication-administration/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Debug Mocha Test [Without Rollup]",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-r",
"ts-node/register",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/test/*.spec.ts"
],
"env": { "TS_NODE_COMPILER_OPTIONS": "{\"module\": \"commonjs\"}" },
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen",
"protocol": "inspector"
},
{
"type": "node",
"request": "launch",
"name": "Debug Unit Tests",
"program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
"args": [
"-u",
"tdd",
"--timeout",
"999999",
"--colors",
"${workspaceFolder}/dist-test/index.node.js"
],
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "npm: build:test"
}
]
}
5 changes: 5 additions & 0 deletions sdk/communication/communication-administration/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Release History

## 1.0.0-beta.1 (2020-09-22)

The Azure Communication Administration Client library contains code which facilitates user token administration.
21 changes: 21 additions & 0 deletions sdk/communication/communication-administration/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2020 Microsoft

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
83 changes: 83 additions & 0 deletions sdk/communication/communication-administration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Azure Communication Administration client library for JavaScript

The Azure Communication Administration library lets the developer create/delete users and issue tokens for Communication Services. Users and tokens can then be used when adding Chat or Calling to an app.

## Getting started

### Prerequisites

- An [Azure subscription][azure_sub].
- An existing Communication Services resource. If you need to create the resource, you can use the [Azure Portal][azure_portal] or [Azure CLI][azure_cli].

### Installing

```bash
npm install @azure/communication-administration
```

## Key concepts

### CommunicationIdentityClient

`CommunicationIdentityClient` provides methods to manage users and their tokens.

## Examples

## Authentication

You can get a key and/or connection string from your Communication Services resource in [Azure Portal][azure_portal]. Once you have a key, you may authenticate with any of the following methods:

### Create `KeyCredential` with `AzureKeyCredential` before initializing CommunicationIdentityClient

```typescript
import { AzureKeyCredential } from "@azure/core-auth";
import { CommunicationIdentityClient } from "@azure/communication-administration";

const credential = new AzureKeyCredential(KEY);
const client = new CommunicationIdentityClient(HOST, credential);
```

### Using a connection string

```typescript
import { CommunicationIdentityClient } from "@azure/communication-administration";

const connectionString = `endpoint=HOST;accessKey=KEY`;
const client = new CommunicationIdentityClient(connectionString);
```

## Usage

### Create a user and token

Here we create an instance of the `CommunicationIdentityClient` class, create a user, then issue a chat scoped token for the user.

```typescript
import { CommunicationIdentityClient } from "@azure/communication-administration";

const client = new CommunicationIdentityClient(CONNECTION_STRING);
const user = await client.createUser();
const { token } = await client.issueToken(user, ["chat"]);
```

## Troubleshooting

## Next steps

Please take a look at the
[samples]<!--(https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/communication/communication-administration/samples)-->
directory for detailed examples on how to use this library.

## Contributing

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

## Related projects

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

[azure_cli]: https://docs.microsoft.com/cli/azure
[azure_sub]: https://azure.microsoft.com/free/
[azure_portal]: https://portal.azure.com

![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcommunication%2Fcommunication-administration%2FREADME.png)
35 changes: 35 additions & 0 deletions sdk/communication/communication-administration/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"mainEntryPointFilePath": "types/src/index.d.ts",
"docModel": {
"enabled": true
},
"apiReport": {
"enabled": true,
"reportFolder": "./review"
},
"dtsRollup": {
"enabled": true,
"untrimmedFilePath": "",
"publicTrimmedFilePath": "./types/communication-administration.d.ts"
},
"messages": {
"tsdocMessageReporting": {
"default": {
"logLevel": "none"
}
},
"extractorMessageReporting": {
"ae-forgotten-export": {
"logLevel": "error",
"addToApiReportFile": false
},
"ae-missing-release-tag": {
"logLevel": "none"
},
"ae-unresolved-link": {
"logLevel": "error"
}
}
}
}
Loading