From 4e1c0e5921e29e7e8a1d2eab1cb0be837796f4a5 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 6 Apr 2021 19:17:28 +0000 Subject: [PATCH 01/37] Add new azure-rest/core-client package --- common/config/rush/common-versions.json | 4 +- .../tools/dev-tool/src/util/resolveProject.ts | 2 +- rush.json | 10 ++ sdk/core-rest/ci.yml | 42 ++++++ sdk/core-rest/core-client/CHANGELOG.md | 3 + sdk/core-rest/core-client/LICENSE | 21 +++ sdk/core-rest/core-client/README.md | 35 +++++ sdk/core-rest/core-client/api-extractor.json | 31 ++++ sdk/core-rest/core-client/karma.conf.js | 115 ++++++++++++++ sdk/core-rest/core-client/package.json | 105 +++++++++++++ .../core-client/review/core-client.api.md | 89 +++++++++++ sdk/core-rest/core-client/rollup.config.js | 2 + .../core-client/src/clientHelpers.ts | 69 +++++++++ sdk/core-rest/core-client/src/common.ts | 52 +++++++ sdk/core-rest/core-client/src/dom.d.ts | 4 + sdk/core-rest/core-client/src/getClient.ts | 140 ++++++++++++++++++ sdk/core-rest/core-client/src/index.ts | 4 + .../core-client/src/pathClientTypes.ts | 38 +++++ sdk/core-rest/core-client/src/sendRequest.ts | 90 +++++++++++ sdk/core-rest/core-client/src/url.browser.ts | 7 + sdk/core-rest/core-client/src/url.ts | 4 + sdk/core-rest/core-client/src/urlHelpers.ts | 42 ++++++ sdk/core-rest/core-client/test/test.spec.ts | 6 + sdk/core-rest/core-client/tsconfig.json | 11 ++ sdk/core-rest/core-client/tsdoc.json | 4 + 25 files changed, 928 insertions(+), 2 deletions(-) create mode 100644 sdk/core-rest/ci.yml create mode 100644 sdk/core-rest/core-client/CHANGELOG.md create mode 100644 sdk/core-rest/core-client/LICENSE create mode 100644 sdk/core-rest/core-client/README.md create mode 100644 sdk/core-rest/core-client/api-extractor.json create mode 100644 sdk/core-rest/core-client/karma.conf.js create mode 100644 sdk/core-rest/core-client/package.json create mode 100644 sdk/core-rest/core-client/review/core-client.api.md create mode 100644 sdk/core-rest/core-client/rollup.config.js create mode 100644 sdk/core-rest/core-client/src/clientHelpers.ts create mode 100644 sdk/core-rest/core-client/src/common.ts create mode 100644 sdk/core-rest/core-client/src/dom.d.ts create mode 100644 sdk/core-rest/core-client/src/getClient.ts create mode 100644 sdk/core-rest/core-client/src/index.ts create mode 100644 sdk/core-rest/core-client/src/pathClientTypes.ts create mode 100644 sdk/core-rest/core-client/src/sendRequest.ts create mode 100644 sdk/core-rest/core-client/src/url.browser.ts create mode 100644 sdk/core-rest/core-client/src/url.ts create mode 100644 sdk/core-rest/core-client/src/urlHelpers.ts create mode 100644 sdk/core-rest/core-client/test/test.spec.ts create mode 100644 sdk/core-rest/core-client/tsconfig.json create mode 100644 sdk/core-rest/core-client/tsdoc.json diff --git a/common/config/rush/common-versions.json b/common/config/rush/common-versions.json index fe5b6e4f660f..37f61e32c77d 100644 --- a/common/config/rush/common-versions.json +++ b/common/config/rush/common-versions.json @@ -67,6 +67,8 @@ // @azure/event-processor-host is on a much lower major version "@azure/ms-rest-nodeauth": ["^0.9.2"], // Idenity is moving from v1 to v2. Moving all packages to v2 is going to take a bit of time, in the mean time we could use v2 on the perf-identity tests. - "@azure/identity": ["^2.0.0-beta.1"] + "@azure/identity": ["^2.0.0-beta.1"], + "@microsoft/api-extractor": ["7.13.2"], + "prettier": ["2.2.1"] } } diff --git a/common/tools/dev-tool/src/util/resolveProject.ts b/common/tools/dev-tool/src/util/resolveProject.ts index 52cba4bcbb2f..6151ed02e235 100644 --- a/common/tools/dev-tool/src/util/resolveProject.ts +++ b/common/tools/dev-tool/src/util/resolveProject.ts @@ -71,7 +71,7 @@ export interface ProjectInfo { async function isAzureSDKPackage(fileName: string): Promise { const f = await import(fileName); - if ((f.name as string).startsWith("@azure/")) { + if ((f.name as string).startsWith("@azure/") || (f.name as string).startsWith("@azure-rest/")) { return true; } else { return false; diff --git a/rush.json b/rush.json index 51e737c0a858..1e52df23a16d 100644 --- a/rush.json +++ b/rush.json @@ -332,6 +332,11 @@ "projectFolder": "sdk/appconfiguration/app-configuration", "versionPolicyName": "client" }, + { + "packageName": "@azure-rest/ai-document-translator", + "projectFolder": "sdk/documenttranslator/ai-document-translator", + "versionPolicyName": "client" + }, { "packageName": "@azure/ai-anomaly-detector", "projectFolder": "sdk/anomalydetector/ai-anomaly-detector", @@ -402,6 +407,11 @@ "projectFolder": "sdk/core/core-amqp", "versionPolicyName": "core" }, + { + "packageName": "@azure-rest/core-client", + "projectFolder": "sdk/core-rest/core-client", + "versionPolicyName": "core" + }, { "packageName": "@azure/core-asynciterator-polyfill", "projectFolder": "sdk/core/core-asynciterator-polyfill", diff --git a/sdk/core-rest/ci.yml b/sdk/core-rest/ci.yml new file mode 100644 index 000000000000..4261131a25ce --- /dev/null +++ b/sdk/core-rest/ci.yml @@ -0,0 +1,42 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - master + - main + - release/* + - hotfix/* + paths: + include: + - sdk/core-rest/ + - eng/ + - common/ + - rush.json + exclude: + - common/smoke-test/ + +pr: + branches: + include: + - master + - main + - feature/* + - release/* + - hotfix/* + paths: + include: + - sdk/core-rest/ + - eng/ + - common/ + - rush.json + exclude: + - common/smoke-test/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: core-rest + Artifacts: + - name: azure-rest-core-client + safeName: azurerestcoreclient diff --git a/sdk/core-rest/core-client/CHANGELOG.md b/sdk/core-rest/core-client/CHANGELOG.md new file mode 100644 index 000000000000..4144f75694a0 --- /dev/null +++ b/sdk/core-rest/core-client/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) diff --git a/sdk/core-rest/core-client/LICENSE b/sdk/core-rest/core-client/LICENSE new file mode 100644 index 000000000000..ea8fb1516028 --- /dev/null +++ b/sdk/core-rest/core-client/LICENSE @@ -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. diff --git a/sdk/core-rest/core-client/README.md b/sdk/core-rest/core-client/README.md new file mode 100644 index 000000000000..523df6b70253 --- /dev/null +++ b/sdk/core-rest/core-client/README.md @@ -0,0 +1,35 @@ +# Azure Core Service client library for JavaScript (Experimental) + +This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript). Specifically for low level clients + +## Getting started + +### Requirements + +- [Node.js](https://nodejs.org) version > 8.x + +### Installation + +This package is primarily used in generated code and not meant to be consumed directly by end users. + +## Key concepts + +## Examples + +Examples can be found in the `samples` folder. + +## Next steps + +You can build and run the tests locally by executing `rushx test`. Explore the `test` folder to see advanced usage and behavior of the public classes. + +Learn more about [AutoRest](https://github.com/Azure/autorest) and the [autorest.typescript extension](https://github.com/Azure/autorest.typescript) for generating a compatible client on top of this package. + +## Troubleshooting + +If you run into issues while using this library, please feel free to [file an issue](https://github.com/Azure/azure-sdk-for-js/issues/new). + +## 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. + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcore%2Fcore-client%2FREADME.png) diff --git a/sdk/core-rest/core-client/api-extractor.json b/sdk/core-rest/core-client/api-extractor.json new file mode 100644 index 000000000000..e7ce14879ecd --- /dev/null +++ b/sdk/core-rest/core-client/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$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/src/latest/core-client.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} diff --git a/sdk/core-rest/core-client/karma.conf.js b/sdk/core-rest/core-client/karma.conf.js new file mode 100644 index 000000000000..2b48912e0ae6 --- /dev/null +++ b/sdk/core-rest/core-client/karma.conf.js @@ -0,0 +1,115 @@ +// https://github.com/karma-runner/karma-chrome-launcher +process.env.CHROME_BIN = require("puppeteer").executablePath(); + +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: ["mocha"], + + plugins: [ + "karma-mocha", + "karma-mocha-reporter", + "karma-chrome-launcher", + "karma-edge-launcher", + "karma-firefox-launcher", + "karma-ie-launcher", + "karma-env-preprocessor", + "karma-coverage", + "karma-sourcemap-loader", + "karma-junit-reporter", + ], + + // list of files / patterns to load in the browser + files: [ + // Uncomment the cdn link below for the polyfill service to support IE11 missing features + // Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys + // "https://cdn.polyfill.io/v2/polyfill.js?features=Symbol,Promise,String.prototype.startsWith,String.prototype.endsWith,String.prototype.repeat,String.prototype.includes,Array.prototype.includes,Object.keys|always", + "dist-test/index.browser.js", + ], + + // 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.browser.js": ["coverage"] + }, + + // inject following environment values into browser testing with window.__env__ + // environment values MUST be exported or set with same console running "karma start" + // https://www.npmjs.com/package/karma-env-preprocessor + // EXAMPLE: envPreprocessor: ["ACCOUNT_NAME", "ACCOUNT_SAS"], + + // 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, + + // start these browsers + // available browser launchers: https://npmjs.org/browse/keyword/karma-launcher + // 'ChromeHeadless', 'Chrome', 'Firefox', 'Edge', 'IE' + browsers: ["ChromeHeadless"], + + // Continuous Integration mode + // if true, Karma captures browsers, runs the tests and exits + singleRun: true, + + // Concurrency level + // how many browser should be started simultaneous + concurrency: 1, + + browserNoActivityTimeout: 600000, + browserDisconnectTimeout: 10000, + browserDisconnectTolerance: 3, + + client: { + mocha: { + // change Karma's debug.html to the mocha web reporter + reporter: "html", + timeout: "600000", + }, + }, + }); +}; diff --git a/sdk/core-rest/core-client/package.json b/sdk/core-rest/core-client/package.json new file mode 100644 index 000000000000..5ce07592211b --- /dev/null +++ b/sdk/core-rest/core-client/package.json @@ -0,0 +1,105 @@ +{ + "name": "@azure-rest/core-client", + "version": "1.0.0-beta.1", + "description": "Core library for interfacing with AutoRest low level generated code", + "sdk-type": "client", + "main": "dist/index.js", + "module": "dist-esm/src/index.js", + "browser": { + "./dist-esm/src/url.js": "./dist-esm/src/url.browser.js" + }, + "types": "types/src/latest/core-client.d.ts", + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build:browser": "npm run build:ts && cross-env ONLY_BROWSER=true rollup -c 2>&1", + "build:node": "npm run build:ts && cross-env ONLY_NODE=true rollup -c 2>&1", + "build:samples": "echo Skipped.", + "build:test": "npm run build:ts && npm run bundle:test", + "build:test:browser": "npm run build:ts && npm run bundle:test:browser", + "build:test:node": "npm run build:ts && npm run bundle:test:node", + "build:ts": "tsc -p .", + "build": "npm run build:ts && rollup -c 2>&1 && api-extractor run --local", + "bundle:test": "rollup -c rollup.test.config.js 2>&1", + "bundle:test:browser": "cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1", + "bundle:test:node": "cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1", + "check-format": "prettier --list-different \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "clean": "rimraf dist dist-* types *.tgz *.log", + "execute:samples": "echo skipped", + "extract-api": "npm run build:ts && api-extractor run --local", + "format": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", + "integration-test:browser": "echo skipped", + "integration-test:node": "echo skipped", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", + "lint": "eslint package.json api-extractor.json src test --ext .ts", + "pack": "npm pack 2>&1", + "prebuild": "npm run clean", + "test:browser": "npm run build:test:browser && npm run unit-test:browser && npm run integration-test:browser", + "test:node": "npm run build:test:node && npm run unit-test:node && npm run integration-test:node", + "test": "npm run clean && npm run build:ts && npm run bundle:test:node && npm run unit-test:node && npm run bundle:test:browser && npm run unit-test:browser && npm run integration-test:node && npm run integration-test:browser", + "unit-test:browser": "karma start --single-run", + "unit-test:node": "cross-env TS_NODE_FILES=true mocha -r esm -r ts-node/register --timeout 50000 --reporter ../../../common/tools/mocha-multi-reporter.js --colors --exclude \"test/**/*.browser.ts\" \"test/**/*.ts\"", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src" + }, + "files": [ + "dist/", + "dist-esm/src/", + "types/src/latest/core-client.d.ts", + "README.md", + "LICENSE" + ], + "repository": "github:Azure/azure-sdk-for-js", + "keywords": [ + "azure", + "cloud" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "engines": { + "node": ">=8.0.0" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/core-rest/core-client/", + "sideEffects": false, + "prettier": "@azure/eslint-plugin-azure-sdk/prettier.json", + "dependencies": { + "@azure/core-auth": "^1.3.0", + "@azure/core-rest-pipeline": "^1.0.0", + "tslib": "^2.0.0" + }, + "devDependencies": { + "@microsoft/api-extractor": "7.13.2", + "@types/chai": "^4.1.6", + "@types/mocha": "^7.0.2", + "@types/node": "^8.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure/dev-tool": "^1.0.0", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "eslint": "^7.15.0", + "inherits": "^2.0.3", + "karma": "^6.2.0", + "karma-chrome-launcher": "^3.0.0", + "karma-coverage": "^2.0.0", + "karma-edge-launcher": "^0.4.2", + "karma-env-preprocessor": "^0.1.1", + "karma-firefox-launcher": "^1.1.0", + "karma-ie-launcher": "^1.0.0", + "karma-junit-reporter": "^2.0.1", + "karma-mocha": "^2.0.1", + "karma-mocha-reporter": "^2.2.5", + "karma-sourcemap-loader": "^0.3.8", + "mocha": "^7.1.1", + "mocha-junit-reporter": "^1.18.0", + "prettier": "2.2.1", + "rimraf": "^3.0.0", + "rollup": "^1.16.3", + "sinon": "^9.0.2", + "typescript": "~4.2.0", + "util": "^0.12.1", + "typedoc": "0.15.2" + } +} diff --git a/sdk/core-rest/core-client/review/core-client.api.md b/sdk/core-rest/core-client/review/core-client.api.md new file mode 100644 index 000000000000..cf8c97ba09fe --- /dev/null +++ b/sdk/core-rest/core-client/review/core-client.api.md @@ -0,0 +1,89 @@ +## API Report File for "@azure-rest/core-client" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { KeyCredential } from '@azure/core-auth'; +import { Pipeline } from '@azure/core-rest-pipeline'; +import { PipelineOptions } from '@azure/core-rest-pipeline'; +import { PipelineRequest } from '@azure/core-rest-pipeline'; +import { RawHttpHeaders } from '@azure/core-rest-pipeline'; +import { TokenCredential } from '@azure/core-auth'; + +// @public +export interface Client { + path: (path: string, ...args: Array) => { + get: (options?: RequestParameters) => Promise; + post: (options?: RequestParameters) => Promise; + put: (options?: RequestParameters) => Promise; + patch: (options?: RequestParameters) => Promise; + delete: (options?: RequestParameters) => Promise; + head: (options?: RequestParameters) => Promise; + options: (options?: RequestParameters) => Promise; + trace: (options?: RequestParameters) => Promise; + }; + pathUnchecked: (path: string, ...args: Array) => { + get: (options?: RequestParameters) => Promise; + post: (options?: RequestParameters) => Promise; + put: (options?: RequestParameters) => Promise; + patch: (options?: RequestParameters) => Promise; + delete: (options?: RequestParameters) => Promise; + head: (options?: RequestParameters) => Promise; + options: (options?: RequestParameters) => Promise; + trace: (options?: RequestParameters) => Promise; + }; +} + +// @public +export type ClientOptions = PipelineOptions & { + credentials?: { + scopes?: string | string[]; + apiKeyHeaderName?: string; + }; + baseUrl?: string; +}; + +// @public +export function createDefaultPipeline(baseUrl: string, credential?: TokenCredential | KeyCredential, options?: ClientOptions): Pipeline; + +// @public +export function getClient(baseUrl: string, options?: PipelineOptions): Client; + +// @public +export function getClient(baseUrl: string, credentials?: TokenCredential | KeyCredential, options?: PipelineOptions): Client; + +// @public +export type HttpResponse = { + request: PipelineRequest; + status: number; + headers: RawHttpHeaders; + body: unknown; + bodyAsText?: string | null; + blobBody?: Promise; + readableStreamBody?: NodeJS.ReadableStream; +}; + +// @public +export type PathUncheckedResponse = HttpResponse & { + body: any; +}; + +// @public +export type RequestParameters = { + headers?: RawHttpHeaders; + body?: unknown; + queryParameters?: { + [key: string]: any; + }; + contentType?: string; + allowInsecureConnection?: boolean; +}; + +// @public +export type RouteParams = TRoute extends `{${infer _Param}}/${infer Tail}` ? [pathParam: string, ...pathParams: RouteParams] : TRoute extends `{${infer _Param}}` ? [pathParam: string] : TRoute extends `${infer _Prefix}:${infer Tail}` ? RouteParams<`{${Tail}}`> : []; + + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/core-rest/core-client/rollup.config.js b/sdk/core-rest/core-client/rollup.config.js new file mode 100644 index 000000000000..26e83ddfafa4 --- /dev/null +++ b/sdk/core-rest/core-client/rollup.config.js @@ -0,0 +1,2 @@ +import { makeConfig } from "@azure/dev-tool/shared-config/rollup"; +export default makeConfig(require("./package.json")); diff --git a/sdk/core-rest/core-client/src/clientHelpers.ts b/sdk/core-rest/core-client/src/clientHelpers.ts new file mode 100644 index 000000000000..8397355ad26b --- /dev/null +++ b/sdk/core-rest/core-client/src/clientHelpers.ts @@ -0,0 +1,69 @@ +import { + createPipelineFromOptions, + bearerTokenAuthenticationPolicy, + Pipeline, + createDefaultHttpClient, + HttpClient, + PipelinePolicy, + PipelineRequest, + SendRequest, + PipelineResponse, +} from "@azure/core-rest-pipeline"; +import { TokenCredential, KeyCredential, isTokenCredential } from "@azure/core-auth"; +import { ClientOptions } from "./common"; + +let cachedHttpsClient: HttpClient | undefined; +const API_KEY_HEADER_NAME = "Ocp-Apim-Subscription-Key"; + +/** + * Creates a default rest pipeline to re-use accross Rest Level Clients + */ +export function createDefaultPipeline( + baseUrl: string, + credential?: TokenCredential | KeyCredential, + options: ClientOptions = {} +): Pipeline { + const pipeline = createPipelineFromOptions(options); + + if (credential) { + const credentialPolicy = isTokenCredential(credential) + ? bearerTokenAuthenticationPolicy({ + credential, + scopes: options.credentials?.scopes || `${baseUrl}/.default`, + }) + : keyCredentialAuthenticationPolicy( + credential, + options.credentials?.apiKeyHeaderName || API_KEY_HEADER_NAME + ); + + pipeline.addPolicy(credentialPolicy); + } + + return pipeline; +} + +export function getCachedDefaultHttpsClient(): HttpClient { + if (!cachedHttpsClient) { + cachedHttpsClient = createDefaultHttpClient(); + } + + return cachedHttpsClient; +} + +/** + * The programmatic identifier of the bearerTokenAuthenticationPolicy. + */ +export const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy"; + +export function keyCredentialAuthenticationPolicy( + credential: KeyCredential, + apiKeyHeaderName: string +): PipelinePolicy { + return { + name: keyCredentialAuthenticationPolicyName, + async sendRequest(request: PipelineRequest, next: SendRequest): Promise { + request.headers.set(apiKeyHeaderName, credential.key); + return next(request); + }, + }; +} diff --git a/sdk/core-rest/core-client/src/common.ts b/sdk/core-rest/core-client/src/common.ts new file mode 100644 index 000000000000..640b19f2bb12 --- /dev/null +++ b/sdk/core-rest/core-client/src/common.ts @@ -0,0 +1,52 @@ +import { PipelineRequest, PipelineOptions, RawHttpHeaders } from "@azure/core-rest-pipeline"; + +/** + * General options that a Rest Level Client can take + */ +export type ClientOptions = PipelineOptions & { + credentials?: { + scopes?: string | string[]; + apiKeyHeaderName?: string; + }; + baseUrl?: string; +}; + +/** + * Represents the shape of an HttpResponse + */ +export type HttpResponse = { + /** + * The request that generated this response. + */ + request: PipelineRequest; + /** + * The HTTP status code of the response. + */ + status: number; + /** + * The HTTP response headers. + */ + headers: RawHttpHeaders; + /** + * Parsed body + */ + body: unknown; + /** + * The response body as text (string format) + */ + bodyAsText?: string | null; + /** + * BROWSER ONLY + * + * The response body as a browser Blob. + * Always undefined in node.js. + */ + blobBody?: Promise; + /** + * NODEJS ONLY + * + * The response body as a node.js Readable stream. + * Always undefined in the browser. + */ + readableStreamBody?: NodeJS.ReadableStream; +}; diff --git a/sdk/core-rest/core-client/src/dom.d.ts b/sdk/core-rest/core-client/src/dom.d.ts new file mode 100644 index 000000000000..88bcf1442b2f --- /dev/null +++ b/sdk/core-rest/core-client/src/dom.d.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/// diff --git a/sdk/core-rest/core-client/src/getClient.ts b/sdk/core-rest/core-client/src/getClient.ts new file mode 100644 index 000000000000..6252437c6047 --- /dev/null +++ b/sdk/core-rest/core-client/src/getClient.ts @@ -0,0 +1,140 @@ +import { isTokenCredential, KeyCredential, TokenCredential } from "@azure/core-auth"; +import { PipelineOptions } from "@azure/core-rest-pipeline"; +import { createDefaultPipeline } from "./clientHelpers"; +import { HttpResponse } from "./common"; +import { RequestParameters } from "./pathClientTypes"; +import { sendRequest } from "./sendRequest"; +import { buildRequestUrl } from "./urlHelpers"; + +/** + * Type to use with pathUnchecked, overrides the body type to any to allow flexibility + */ +export type PathUncheckedResponse = HttpResponse & { body: any }; + +/** + * Shape of a Rest Level Client + */ +export interface Client { + /** + * This method will be used to send request that would check the path to provide + * strong types + */ + path: ( + path: string, + ...args: Array + ) => { + get: (options?: RequestParameters) => Promise; + post: (options?: RequestParameters) => Promise; + put: (options?: RequestParameters) => Promise; + patch: (options?: RequestParameters) => Promise; + delete: (options?: RequestParameters) => Promise; + head: (options?: RequestParameters) => Promise; + options: (options?: RequestParameters) => Promise; + trace: (options?: RequestParameters) => Promise; + }; + /** + * This method allows arbitrary paths and doesn't provide strong types + */ + pathUnchecked: ( + path: string, + ...args: Array + ) => { + get: (options?: RequestParameters) => Promise; + post: (options?: RequestParameters) => Promise; + put: (options?: RequestParameters) => Promise; + patch: (options?: RequestParameters) => Promise; + delete: (options?: RequestParameters) => Promise; + head: (options?: RequestParameters) => Promise; + options: (options?: RequestParameters) => Promise; + trace: (options?: RequestParameters) => Promise; + }; +} + +/** + * Creates a client with a default pipeline + * @param baseUrl Base endpoint for the client + * @param options Client options + */ +export function getClient(baseUrl: string, options?: PipelineOptions): Client; +/** + * Creates a client with a default pipeline + * @param baseUrl Base endpoint for the client + * @param credentials Credentials to authenticate the requests + * @param options Client options + */ +export function getClient( + baseUrl: string, + credentials?: TokenCredential | KeyCredential, + options?: PipelineOptions +): Client; +export function getClient( + baseUrl: string, + credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | PipelineOptions, + opts: PipelineOptions = {} +): Client { + let credentials: TokenCredential | KeyCredential | undefined; + let options = opts; + + if (credentialsOrPipelineOptions) { + if (isCredential(credentialsOrPipelineOptions)) { + credentials = credentialsOrPipelineOptions; + options = opts; + } else { + options = credentialsOrPipelineOptions || {}; + } + } + + const pipeline = createDefaultPipeline(baseUrl, credentials, options); + pipeline.removePolicy({ name: "exponentialRetryPolicy" }); + const client = (path: string, ...args: Array) => { + return { + get: (options: RequestParameters = {}): Promise => { + const url = buildRequestUrl(baseUrl, path, args, options); + return sendRequest("GET", url, pipeline, options); + }, + post: (options: RequestParameters = {}): Promise => { + const url = buildRequestUrl(baseUrl, path, args, options); + return sendRequest("POST", url, pipeline, options); + }, + put: (options: RequestParameters = {}): Promise => { + const url = buildRequestUrl(baseUrl, path, args, options); + return sendRequest("PUT", url, pipeline, options); + }, + patch: (options: RequestParameters = {}): Promise => { + const url = buildRequestUrl(baseUrl, path, args, options); + return sendRequest("PATCH", url, pipeline, options); + }, + delete: (options: RequestParameters = {}): Promise => { + const url = buildRequestUrl(baseUrl, path, args, options); + return sendRequest("DELETE", url, pipeline, options); + }, + head: (options: RequestParameters = {}): Promise => { + const url = buildRequestUrl(baseUrl, path, args, options); + return sendRequest("HEAD", url, pipeline, options); + }, + options: (options: RequestParameters = {}): Promise => { + const url = buildRequestUrl(baseUrl, path, args, options); + return sendRequest("OPTIONS", url, pipeline, options); + }, + trace: (options: RequestParameters = {}): Promise => { + const url = buildRequestUrl(baseUrl, path, args, options); + return sendRequest("TRACE", url, pipeline, options); + }, + }; + }; + + return { + path: client, + pathUnchecked: client, + }; +} + +function isCredential( + param: (TokenCredential | KeyCredential) | PipelineOptions +): param is TokenCredential | KeyCredential { + if ((param as any).key || isTokenCredential(param)) { + return true; + } + + return false; +} diff --git a/sdk/core-rest/core-client/src/index.ts b/sdk/core-rest/core-client/src/index.ts new file mode 100644 index 000000000000..f920da46cb97 --- /dev/null +++ b/sdk/core-rest/core-client/src/index.ts @@ -0,0 +1,4 @@ +export { createDefaultPipeline } from "./clientHelpers"; +export * from "./common"; +export * from "./getClient"; +export * from "./pathClientTypes"; diff --git a/sdk/core-rest/core-client/src/pathClientTypes.ts b/sdk/core-rest/core-client/src/pathClientTypes.ts new file mode 100644 index 000000000000..77a780300fe3 --- /dev/null +++ b/sdk/core-rest/core-client/src/pathClientTypes.ts @@ -0,0 +1,38 @@ +import { RawHttpHeaders } from "@azure/core-rest-pipeline"; + +/** + * Shape of the default request parameters, this may be overriden by the specific + * request types to provide strong types + */ +export type RequestParameters = { + /** + * Headers to send along with the request + */ + headers?: RawHttpHeaders; + /** + * Body to send with the request + */ + body?: unknown; + /** + * Query parameters to send with the request + */ + queryParameters?: { [key: string]: any }; + /** + * Set an explicit content-type to send with the request + */ + contentType?: string; + /** Set to true if the request is sent over HTTP instead of HTTPS */ + allowInsecureConnection?: boolean; +}; + +/** + * Helper type used to detect parameters in a path template + * keys surounded by {} will be considered a path parameter + */ +export type RouteParams = TRoute extends `{${infer _Param}}/${infer Tail}` + ? [pathParam: string, ...pathParams: RouteParams] + : TRoute extends `{${infer _Param}}` + ? [pathParam: string] + : TRoute extends `${infer _Prefix}:${infer Tail}` + ? RouteParams<`{${Tail}}`> + : []; diff --git a/sdk/core-rest/core-client/src/sendRequest.ts b/sdk/core-rest/core-client/src/sendRequest.ts new file mode 100644 index 000000000000..32cec1187a90 --- /dev/null +++ b/sdk/core-rest/core-client/src/sendRequest.ts @@ -0,0 +1,90 @@ +import { + createHttpHeaders, + createPipelineRequest, + HttpMethods, + Pipeline, + RawHttpHeaders, +} from "@azure/core-rest-pipeline"; +import { getCachedDefaultHttpsClient } from "./clientHelpers"; +import { RequestParameters } from "./pathClientTypes"; +import { HttpResponse } from "./common"; + +/** + * Helper function to send request used by the client + * @param method method to use to send the request + * @param url url to send the request to + * @param pipeline pipeline with the policies to run when sending the request + * @param options request options + * @returns returns and HttpResponse + */ +export async function sendRequest( + method: HttpMethods, + url: string, + pipeline: Pipeline, + options: RequestParameters = {} +): Promise { + const httpClient = getCachedDefaultHttpsClient(); + + const headers = createHttpHeaders({ + accept: "application/json", + "content-type": options.contentType || getContentType(options.body), + ...(options.headers ? options.headers : {}), + }); + + const body = JSON.stringify(options.body); + + const request = createPipelineRequest({ + url: url.toString(), + method, + body, + headers, + allowInsecureConnection: options.allowInsecureConnection, + }); + + const result = await pipeline.sendRequest(httpClient, request); + let rawHeaders: RawHttpHeaders = {}; + for (const [key, value] of result.headers) { + rawHeaders[key] = value; + } + + let parsedBody = undefined; + + try { + parsedBody = result.bodyAsText ? JSON.parse(result.bodyAsText) : undefined; + } catch { + parsedBody = undefined; + } + + return { + bodyAsText: result.bodyAsText, + request, + headers: rawHeaders, + status: result.status, + body: parsedBody, + }; +} + +/** + * Function to determine the content-type of a body + * this is used if an explicit content-type is not provided + * @param body body in the request + * @returns returns the content-type + */ +function getContentType(body: any): string { + try { + const jsonBody = JSON.stringify(body); + JSON.parse(jsonBody); + return "application/json; charset=UTF-8"; + } catch {} + + if (typeof body === "string") { + return "text/plain"; + } + + if (ArrayBuffer.isView(body)) { + return "application/octet-stream"; + } + + // Default, we may want to log a warning + return "application/json; charset=UTF-8"; +} diff --git a/sdk/core-rest/core-client/src/url.browser.ts b/sdk/core-rest/core-client/src/url.browser.ts new file mode 100644 index 000000000000..085c11b25cf4 --- /dev/null +++ b/sdk/core-rest/core-client/src/url.browser.ts @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +const url = URL; +const urlSearchParams = URLSearchParams; + +export { url as URL, urlSearchParams as URLSearchParams }; diff --git a/sdk/core-rest/core-client/src/url.ts b/sdk/core-rest/core-client/src/url.ts new file mode 100644 index 000000000000..993e69798f9e --- /dev/null +++ b/sdk/core-rest/core-client/src/url.ts @@ -0,0 +1,4 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +export { URL, URLSearchParams } from "url"; diff --git a/sdk/core-rest/core-client/src/urlHelpers.ts b/sdk/core-rest/core-client/src/urlHelpers.ts new file mode 100644 index 000000000000..8a431a285a14 --- /dev/null +++ b/sdk/core-rest/core-client/src/urlHelpers.ts @@ -0,0 +1,42 @@ +import { RequestParameters } from "./pathClientTypes"; + +/** + * Builds the request url, filling in query and path parameters + * @param baseUrl base url which can be a template url + * @param routePath path to append to the baseUrl + * @param pathParameters values of the path parameters + * @param options request parameters including query parameters + * @returns a full url with path and query parameters + */ +export function buildRequestUrl( + baseUrl: string, + routePath: string, + pathParameters: string[], + options: RequestParameters = {} +): string { + let path = routePath; + + if (path.startsWith("https://") || path.startsWith("http://")) { + return path; + } + + for (const pathParam of pathParameters) { + path = path.replace(/{([^\/]+)}/, pathParam); + } + + const url = new URL(`${baseUrl}/${path}`); + + if (options.queryParameters) { + const queryParams = options.queryParameters; + for (const key of Object.keys(queryParams)) { + url.searchParams.append(key, (queryParams as any)[key]); + } + } + + return ( + url + .toString() + // Remove double forward slashes + .replace(/([^:]\/)\/+/g, "$1") + ); +} diff --git a/sdk/core-rest/core-client/test/test.spec.ts b/sdk/core-rest/core-client/test/test.spec.ts new file mode 100644 index 000000000000..6c0f49e9989b --- /dev/null +++ b/sdk/core-rest/core-client/test/test.spec.ts @@ -0,0 +1,6 @@ +import { assert } from "chai"; +describe("hello world", () => { + it("should pass", () => { + assert.equal(1, 1); + }); +}); diff --git a/sdk/core-rest/core-client/tsconfig.json b/sdk/core-rest/core-client/tsconfig.json new file mode 100644 index 000000000000..455ac455f5a7 --- /dev/null +++ b/sdk/core-rest/core-client/tsconfig.json @@ -0,0 +1,11 @@ +{ + "extends": "../../../tsconfig.package", + "compilerOptions": { + "outDir": "./dist-esm", + "declarationDir": "./types", + "paths": { + "@azure/ai-text-analytics": ["./src/index"] + } + }, + "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"] +} diff --git a/sdk/core-rest/core-client/tsdoc.json b/sdk/core-rest/core-client/tsdoc.json new file mode 100644 index 000000000000..81c5a8a2aa2f --- /dev/null +++ b/sdk/core-rest/core-client/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["../../../tsdoc.json"] +} From 6657d88b15c2cd038033142ed5b059c2d4f3cddb Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 6 Apr 2021 19:25:29 +0000 Subject: [PATCH 02/37] Add document translation package --- .../ai-document-translator/LICENSE | 21 + .../ai-document-translator/api-extractor.json | 31 + .../ai-document-translator/karma.conf.js | 145 +++ .../ai-document-translator/package.json | 103 ++ .../review/ai-document-translator.api.md | 899 ++++++++++++++++++ .../ai-document-translator/rollup.config.js | 3 + .../ai-document-translator/sample.env | 7 + .../samples-dev/listFormats.ts | 35 + .../samples-dev/translateFromBlob.ts | 122 +++ .../samples/v1/javascript/README.md | 66 ++ .../samples/v1/javascript/listFormats.js | 34 + .../samples/v1/javascript/package.json | 32 + .../samples/v1/javascript/sample.env | 7 + .../v1/javascript/translateFromBlob.js | 121 +++ .../samples/v1/typescript/README.md | 79 ++ .../samples/v1/typescript/package.json | 40 + .../samples/v1/typescript/sample.env | 7 + .../samples/v1/typescript/src/listFormats.ts | 34 + .../v1/typescript/src/translateFromBlob.ts | 121 +++ .../samples/v1/typescript/tsconfig.json | 17 + .../src/documentTranslationClient.ts | 286 ++++++ .../ai-document-translator/src/index.ts | 6 + .../ai-document-translator/src/models.ts | 219 +++++ .../ai-document-translator/src/parameters.ts | 101 ++ .../ai-document-translator/src/responses.ts | 420 ++++++++ .../ai-document-translator/swagger/README.md | 22 + .../ai-document-translator/test/text.spec.ts | 1 + .../ai-document-translator/tsconfig.json | 16 + .../ai-document-translator/tsdoc.json | 4 + sdk/documenttranslator/ci.yml | 32 + 30 files changed, 3031 insertions(+) create mode 100644 sdk/documenttranslator/ai-document-translator/LICENSE create mode 100644 sdk/documenttranslator/ai-document-translator/api-extractor.json create mode 100644 sdk/documenttranslator/ai-document-translator/karma.conf.js create mode 100644 sdk/documenttranslator/ai-document-translator/package.json create mode 100644 sdk/documenttranslator/ai-document-translator/review/ai-document-translator.api.md create mode 100644 sdk/documenttranslator/ai-document-translator/rollup.config.js create mode 100644 sdk/documenttranslator/ai-document-translator/sample.env create mode 100644 sdk/documenttranslator/ai-document-translator/samples-dev/listFormats.ts create mode 100644 sdk/documenttranslator/ai-document-translator/samples-dev/translateFromBlob.ts create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/javascript/README.md create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/javascript/listFormats.js create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/javascript/package.json create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/javascript/sample.env create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/javascript/translateFromBlob.js create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/typescript/README.md create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/typescript/package.json create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/typescript/sample.env create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/listFormats.ts create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/translateFromBlob.ts create mode 100644 sdk/documenttranslator/ai-document-translator/samples/v1/typescript/tsconfig.json create mode 100644 sdk/documenttranslator/ai-document-translator/src/documentTranslationClient.ts create mode 100644 sdk/documenttranslator/ai-document-translator/src/index.ts create mode 100644 sdk/documenttranslator/ai-document-translator/src/models.ts create mode 100644 sdk/documenttranslator/ai-document-translator/src/parameters.ts create mode 100644 sdk/documenttranslator/ai-document-translator/src/responses.ts create mode 100644 sdk/documenttranslator/ai-document-translator/swagger/README.md create mode 100644 sdk/documenttranslator/ai-document-translator/test/text.spec.ts create mode 100644 sdk/documenttranslator/ai-document-translator/tsconfig.json create mode 100644 sdk/documenttranslator/ai-document-translator/tsdoc.json create mode 100644 sdk/documenttranslator/ci.yml diff --git a/sdk/documenttranslator/ai-document-translator/LICENSE b/sdk/documenttranslator/ai-document-translator/LICENSE new file mode 100644 index 000000000000..ea8fb1516028 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/LICENSE @@ -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. diff --git a/sdk/documenttranslator/ai-document-translator/api-extractor.json b/sdk/documenttranslator/ai-document-translator/api-extractor.json new file mode 100644 index 000000000000..a48e9e8b796d --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/api-extractor.json @@ -0,0 +1,31 @@ +{ + "$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/ai-document-translator.d.ts" + }, + "messages": { + "tsdocMessageReporting": { + "default": { + "logLevel": "none" + } + }, + "extractorMessageReporting": { + "ae-missing-release-tag": { + "logLevel": "none" + }, + "ae-unresolved-link": { + "logLevel": "none" + } + } + } +} diff --git a/sdk/documenttranslator/ai-document-translator/karma.conf.js b/sdk/documenttranslator/ai-document-translator/karma.conf.js new file mode 100644 index 000000000000..23a7f0ce2627 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/karma.conf.js @@ -0,0 +1,145 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +// https://github.com/karma-runner/karma-chrome-launcher +process.env.CHROME_BIN = require("puppeteer").executablePath(); +require("dotenv").config(); +const { + jsonRecordingFilterFunction, + isPlaybackMode, + isSoftRecordMode, + isRecordMode +} = require("@azure/test-utils-recorder"); + +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-edge-launcher", + "karma-firefox-launcher", + "karma-ie-launcher", + "karma-env-preprocessor", + "karma-coverage", + "karma-sourcemap-loader", + "karma-junit-reporter", + "karma-json-to-file-reporter", + "karma-source-map-support", + "karma-json-preprocessor" + ], + + // 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 } + ].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []), + + // 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"], + "recordings/browsers/**/*.json": ["json"] + // 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", + "TEXT_ANALYTICS_API_KEY", + "TEXT_ANALYTICS_API_KEY_ALT", + "AZURE_CLIENT_ID", + "AZURE_CLIENT_SECRET", + "AZURE_TENANT_ID" + ], + + // test results reporter to use + // possible values: 'dots', 'progress' + // available reporters: https://npmjs.org/browse/keyword/karma-reporter + reporters: ["mocha", "coverage", "junit", "json-to-file"], + + 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 + }, + + jsonToFileReporter: { + filter: jsonRecordingFilterFunction, + outputPath: "." + }, + + // 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, + browserConsoleLogOptions: { + terminal: !isRecordMode() + }, + + client: { + mocha: { + // change Karma's debug.html to the mocha web reporter + reporter: "html", + timeout: 0 + } + } + }); +}; diff --git a/sdk/documenttranslator/ai-document-translator/package.json b/sdk/documenttranslator/ai-document-translator/package.json new file mode 100644 index 000000000000..36751eb49329 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/package.json @@ -0,0 +1,103 @@ +{ + "name": "@azure-rest/ai-document-translator", + "sdk-type": "client", + "author": "Microsoft Corporation", + "description": "An isomorphic low level client library for the Azure Document Translator service.", + "version": "1.0.0-beta.1", + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "license": "MIT", + "main": "./dist/index.js", + "module": "./dist-esm/src/index.js", + "types": "./types/ai-document-translator.d.ts", + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator/README.md", + "repository": "github:Azure/azure-sdk-for-js", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "files": [ + "dist/", + "dist-esm/src/", + "types/ai-document-translator.d.ts", + "README.md", + "LICENSE" + ], + "//metadata": { + "constantPaths": [ + { + "path": "src/constants.ts", + "prefix": "SDK_VERSION" + } + ] + }, + "engines": { + "node": ">=8.0.0" + }, + "//sampleConfiguration": { + "productName": "Azure Document Translator", + "productSlugs": [ + "azure", + "azure-cognitive-services", + "azure-document-translator" + ], + "requiredResources": { + "Azure Cognitive Services instance": "https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account" + } + }, + "scripts": { + "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1", + "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1", + "build:samples": "echo Obsolete.", + "build:test": "tsc -p . && rollup -c 2>&1", + "build": "tsc -p . && rollup -c 2>&1 && api-extractor run --local", + "build:debug": "tsc -p . && rollup -c 2>&1 && api-extractor run --local", + "check-format": "prettier --list-different --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", + "clean": "rimraf dist dist-browser dist-esm test-dist temp types *.tgz *.log", + "execute:samples": "dev-tool samples run samples-dev", + "extract-api": "tsc -p . && api-extractor run --local", + "format": "prettier --write --config ../../../.prettierrc.json --ignore-path ../../../.prettierignore \"src/**/*.ts\" \"test/**/*.ts\" \"samples-dev/**/*.ts\" \"*.{js,json}\"", + "integration-test:browser": "karma start --single-run", + "integration-test:node": "nyc mocha -r esm --require source-map-support/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 5000000 --full-trace \"dist-esm/test/{,!(browser)/**/}*.spec.js\"", + "integration-test": "npm run integration-test:node && npm run integration-test:browser", + "lint:fix": "eslint package.json api-extractor.json src test --ext .ts --fix --fix-type [problem,suggestion]", + "lint": "eslint package.json api-extractor.json src test --ext .ts", + "pack": "npm pack 2>&1", + "prebuild": "npm run clean", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", + "test:node": "npm run clean && npm run build:test && npm run unit-test:node", + "test": "npm run clean && npm run build:test && npm run unit-test", + "unit-test:browser": "karma start --single-run", + "unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"", + "unit-test": "npm run unit-test:node && npm run unit-test:browser", + "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src" + }, + "sideEffects": false, + "autoPublish": false, + "dependencies": { + "@azure/core-auth": "^1.3.0", + "@azure-rest/core-client": "1.0.0-beta.1", + "@azure/core-rest-pipeline": "^1.0.0", + "@azure/logger": "^1.0.0", + "tslib": "^2.0.0" + }, + "devDependencies": { + "@azure/dev-tool": "^1.0.0", + "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@microsoft/api-extractor": "7.13.2", + "dotenv": "^8.2.0", + "@types/node": "^8.0.0", + "eslint": "^7.15.0", + "prettier": "^1.16.4", + "rollup": "^1.16.3", + "source-map-support": "^0.5.9", + "typescript": "~4.2.0", + "typedoc": "0.15.2" + } +} diff --git a/sdk/documenttranslator/ai-document-translator/review/ai-document-translator.api.md b/sdk/documenttranslator/ai-document-translator/review/ai-document-translator.api.md new file mode 100644 index 000000000000..0a435c4965c8 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/review/ai-document-translator.api.md @@ -0,0 +1,899 @@ +## API Report File for "@azure-rest/ai-document-translator" + +> Do not edit this file. It is a report generated by [API Extractor](https://api-extractor.com/). + +```ts + +import { Client } from '@azure-rest/core-client'; +import { ClientOptions } from '@azure-rest/core-client'; +import { HttpResponse } from '@azure-rest/core-client'; +import { KeyCredential } from '@azure/core-auth'; +import { RawHttpHeaders } from '@azure/core-rest-pipeline'; +import { RequestParameters } from '@azure-rest/core-client'; +import { TokenCredential } from '@azure/core-auth'; + +// @public (undocumented) +export interface BatchRequest { + source: SourceInput; + storageType?: StorageInputType; + targets: TargetInput[]; +} + +// @public (undocumented) +export interface BatchStatusDetail { + createdDateTimeUtc: Date; + error?: ErrorV2; + id: string; + lastActionDateTimeUtc: Date; + status: Status; + // (undocumented) + summary: StatusSummary; +} + +// @public (undocumented) +export interface BatchStatusResponse { + nextLink?: string; + value: BatchStatusDetail[]; +} + +// @public (undocumented) +export interface BatchSubmissionRequest { + inputs: BatchRequest[]; +} + +// @public (undocumented) +export interface CancelOperation { + delete(options?: CancelOperationParameters): Promise; + get(options?: GetOperationStatusParameters): Promise; +} + +// @public (undocumented) +export interface CancelOperation200Properties { + // (undocumented) + body: BatchStatusDetail; + // (undocumented) + status: 200; +} + +// @public (undocumented) +export type CancelOperation200Response = CancelOperation200Properties & HttpResponse; + +// @public (undocumented) +export interface CancelOperation401Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 401; +} + +// @public (undocumented) +export type CancelOperation401Response = CancelOperation401Properties & HttpResponse; + +// @public (undocumented) +export interface CancelOperation404Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 404; +} + +// @public (undocumented) +export type CancelOperation404Response = CancelOperation404Properties & HttpResponse; + +// @public (undocumented) +export interface CancelOperation429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type CancelOperation429Response = CancelOperation429Properties & HttpResponse; + +// @public (undocumented) +export interface CancelOperation500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type CancelOperation500Response = CancelOperation500Properties & HttpResponse; + +// @public (undocumented) +export interface CancelOperation503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type CancelOperation503Response = CancelOperation503Properties & HttpResponse; + +// @public (undocumented) +export type CancelOperationParameters = RequestParameters; + +// @public (undocumented) +export interface DocumentFilter { + prefix?: string; + suffix?: string; +} + +// @public (undocumented) +export interface DocumentStatusDetail { + characterCharged?: number; + createdDateTimeUtc: Date; + error?: ErrorV2; + id: string; + lastActionDateTimeUtc: Date; + path?: string; + progress: number; + sourcePath: string; + status: Status; + to: string; +} + +// @public (undocumented) +export interface DocumentStatusResponse { + nextLink?: string; + value: DocumentStatusDetail[]; +} + +// @public (undocumented) +function DocumentTranslation(endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslationClient; + +export default DocumentTranslation; + +// @public (undocumented) +export type DocumentTranslationClient = Client & { + path: Routes; +}; + +// @public (undocumented) +export interface DocumentTranslationFactory { + // (undocumented) + (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; +} + +// @public (undocumented) +export type ErrorCodeV2 = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "ResourceNotFound" | "Unauthorized" | "RequestRateTooHigh"; + +// @public (undocumented) +export interface ErrorResponseV2 { + error?: ErrorV2; +} + +// @public (undocumented) +export interface ErrorV2 { + code: ErrorCodeV2; + innerError?: InnerErrorV2; + message: string; + target?: string; +} + +// @public (undocumented) +export interface FileFormat { + contentTypes: string[]; + defaultVersion?: string; + fileExtensions: string[]; + format: string; + versions?: string[]; +} + +// @public (undocumented) +export interface FileFormatListResult { + value: FileFormat[]; +} + +// @public (undocumented) +export interface GetDocumentFormats { + get(options?: GetDocumentFormatsParameters): Promise; +} + +// @public (undocumented) +export interface GetDocumentFormats200Headers { + "retry-after"?: string; +} + +// @public (undocumented) +export interface GetDocumentFormats200Properties { + // (undocumented) + body: FileFormatListResult; + // (undocumented) + headers: GetDocumentFormats200Headers & RawHttpHeaders; + // (undocumented) + status: 200; +} + +// @public (undocumented) +export type GetDocumentFormats200Response = HttpResponse & GetDocumentFormats200Properties; + +// @public (undocumented) +export interface GetDocumentFormats429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type GetDocumentFormats429Response = GetDocumentFormats429Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentFormats500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type GetDocumentFormats500Response = GetDocumentFormats500Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentFormats503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type GetDocumentFormats503Response = GetDocumentFormats503Properties & HttpResponse; + +// @public (undocumented) +export type GetDocumentFormatsParameters = RequestParameters; + +// @public (undocumented) +export interface GetDocumentStatus { + get(options?: GetDocumentStatusParameters): Promise; +} + +// @public (undocumented) +export interface GetDocumentStatus200Headers { + "retry-after"?: string; + etag?: string; +} + +// @public (undocumented) +export interface GetDocumentStatus200Properties { + // (undocumented) + body: DocumentStatusDetail; + // (undocumented) + headers: GetDocumentStatus200Headers & RawHttpHeaders; + // (undocumented) + status: 200; +} + +// @public (undocumented) +export type GetDocumentStatus200Response = GetDocumentStatus200Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentStatus401Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 401; +} + +// @public (undocumented) +export type GetDocumentStatus401Response = GetDocumentStatus401Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentStatus404Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 404; +} + +// @public (undocumented) +export type GetDocumentStatus404Response = GetDocumentStatus404Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentStatus429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type GetDocumentStatus429Response = GetDocumentStatus429Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentStatus500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type GetDocumentStatus500Response = GetDocumentStatus500Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentStatus503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type GetDocumentStatus503Response = GetDocumentStatus503Properties & HttpResponse; + +// @public (undocumented) +export type GetDocumentStatusParameters = RequestParameters; + +// @public (undocumented) +export interface GetDocumentStorageSource { + get(options?: GetDocumentStorageSourceParameters): Promise; +} + +// @public (undocumented) +export interface GetDocumentStorageSource200Headers { + "retry-after"?: string; +} + +// @public (undocumented) +export interface GetDocumentStorageSource200Properties { + // (undocumented) + body: StorageSourceListResult; + // (undocumented) + headers: GetDocumentStorageSource200Headers & RawHttpHeaders; + // (undocumented) + status: 200; +} + +// @public (undocumented) +export type GetDocumentStorageSource200Response = GetDocumentStorageSource200Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentStorageSource429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type GetDocumentStorageSource429Response = GetDocumentStorageSource429Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentStorageSource500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type GetDocumentStorageSource500Response = GetDocumentStorageSource500Properties & HttpResponse; + +// @public (undocumented) +export interface GetDocumentStorageSource503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type GetDocumentStorageSource503Response = GetDocumentStorageSource503Properties & HttpResponse; + +// @public (undocumented) +export type GetDocumentStorageSourceParameters = RequestParameters; + +// @public (undocumented) +export interface GetGlossaryFormats { + get(options?: GetGlossaryFormatsParameters): Promise; +} + +// @public (undocumented) +export interface GetGlossaryFormats200Headers { + "retry-after"?: string; +} + +// @public (undocumented) +export interface GetGlossaryFormats200Properties { + // (undocumented) + body: FileFormatListResult; + // (undocumented) + headers: GetGlossaryFormats200Headers & RawHttpHeaders; + // (undocumented) + status: 200; +} + +// @public (undocumented) +export type GetGlossaryFormats200Response = GetGlossaryFormats200Properties & HttpResponse; + +// @public (undocumented) +export interface GetGlossaryFormats429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type GetGlossaryFormats429Response = GetGlossaryFormats429Properties & HttpResponse; + +// @public (undocumented) +export interface GetGlossaryFormats500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type GetGlossaryFormats500Response = GetGlossaryFormats500Properties & HttpResponse; + +// @public (undocumented) +export interface GetGlossaryFormats503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type GetGlossaryFormats503Response = GetGlossaryFormats503Properties & HttpResponse; + +// @public (undocumented) +export type GetGlossaryFormatsParameters = RequestParameters; + +// @public (undocumented) +export interface GetOperationDocumentsStatus { + get(options?: GetOperationDocumentsStatusParameters): Promise; +} + +// @public (undocumented) +export interface GetOperationDocumentsStatus200Headers { + "retry-after"?: string; + etag?: string; +} + +// @public (undocumented) +export interface GetOperationDocumentsStatus200Properties { + // (undocumented) + body: DocumentStatusResponse; + // (undocumented) + headers: GetOperationDocumentsStatus200Headers & RawHttpHeaders; + // (undocumented) + status: 200; +} + +// @public (undocumented) +export type GetOperationDocumentsStatus200Response = GetOperationDocumentsStatus200Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationDocumentsStatus400Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 400; +} + +// @public (undocumented) +export type GetOperationDocumentsStatus400Response = GetOperationDocumentsStatus400Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationDocumentsStatus401Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 401; +} + +// @public (undocumented) +export type GetOperationDocumentsStatus401Response = GetOperationDocumentsStatus401Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationDocumentsStatus404Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 404; +} + +// @public (undocumented) +export type GetOperationDocumentsStatus404Response = GetOperationDocumentsStatus404Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationDocumentsStatus429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type GetOperationDocumentsStatus429Response = GetOperationDocumentsStatus429Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationDocumentsStatus500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type GetOperationDocumentsStatus500Response = GetOperationDocumentsStatus500Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationDocumentsStatus503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type GetOperationDocumentsStatus503Response = GetOperationDocumentsStatus503Properties & HttpResponse; + +// @public (undocumented) +export type GetOperationDocumentsStatusParameters = RequestParameters & GetOperationDocumentsStatusQueryParam; + +// @public (undocumented) +export interface GetOperationDocumentsStatusQueryParam { + // (undocumented) + queryParameters?: GetOperationDocumentsStatusQueryParamProperties; +} + +// @public (undocumented) +export interface GetOperationDocumentsStatusQueryParamProperties { + $maxpagesize?: number; + $orderBy?: string[]; + $skip?: number; + $top?: number; + createdDateTimeUtcEnd?: Date; + createdDateTimeUtcStart?: Date; + ids?: string[]; + statuses?: string[]; +} + +// @public (undocumented) +export interface GetOperations { + get(options?: GetOperationsParameters): Promise; + post(options?: SubmitBatchRequestParameters): Promise; +} + +// @public (undocumented) +export interface GetOperations200Headers { + "retry-after"?: string; + etag?: string; +} + +// @public (undocumented) +export interface GetOperations200Properties { + // (undocumented) + body: BatchStatusResponse; + // (undocumented) + headers: GetOperations200Headers & RawHttpHeaders; + // (undocumented) + status: 200; +} + +// @public (undocumented) +export type GetOperations200Response = GetOperations200Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperations400Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 400; +} + +// @public (undocumented) +export type GetOperations400Response = GetOperations400Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperations401Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 401; +} + +// @public (undocumented) +export type GetOperations401Response = GetOperations401Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperations429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type GetOperations429Response = GetOperations429Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperations500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type GetOperations500Response = GetOperations500Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperations503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type GetOperations503Response = GetOperations503Properties & HttpResponse; + +// @public (undocumented) +export type GetOperationsParameters = RequestParameters & GetOperationsQueryParam; + +// @public (undocumented) +export interface GetOperationsQueryParam { + // (undocumented) + queryParameters?: GetOperationsQueryParamProperties; +} + +// @public (undocumented) +export interface GetOperationsQueryParamProperties { + $maxpagesize?: number; + $orderBy?: string[]; + $skip?: number; + $top?: number; + createdDateTimeUtcEnd?: Date; + createdDateTimeUtcStart?: Date; + ids?: string[]; + statuses?: string[]; +} + +// @public (undocumented) +export interface GetOperationStatus200Headers { + "retry-after"?: string; + etag?: string; +} + +// @public (undocumented) +export interface GetOperationStatus200Properties { + // (undocumented) + body: BatchStatusDetail; + // (undocumented) + headers: GetOperationStatus200Headers & RawHttpHeaders; + // (undocumented) + status: 200; +} + +// @public (undocumented) +export type GetOperationStatus200Response = GetOperationStatus200Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationStatus401Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 401; +} + +// @public (undocumented) +export type GetOperationStatus401Response = GetOperationStatus401Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationStatus404Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 404; +} + +// @public (undocumented) +export type GetOperationStatus404Response = GetOperationStatus404Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationStatus429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type GetOperationStatus429Response = GetOperationStatus429Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationStatus500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type GetOperationStatus500Response = GetOperationStatus500Properties & HttpResponse; + +// @public (undocumented) +export interface GetOperationStatus503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type GetOperationStatus503Response = GetOperationStatus503Properties & HttpResponse; + +// @public (undocumented) +export type GetOperationStatusParameters = RequestParameters; + +// @public (undocumented) +export interface Glossary { + format: string; + glossaryUrl: string; + storageSource?: StorageSource; + version?: string; +} + +// @public (undocumented) +export interface InnerErrorV2 { + code: string; + innerError?: InnerErrorV2; + message: string; + target?: string; +} + +// @public (undocumented) +export interface Routes { + // (undocumented) + (path: "/batches"): GetOperations; + // (undocumented) + (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; + // (undocumented) + (path: "/batches/{id}", id: string): CancelOperation; + // (undocumented) + (path: "/batches/{id}/documents", id: string): GetOperationDocumentsStatus; + // (undocumented) + (path: "/documents/formats"): GetDocumentFormats; + // (undocumented) + (path: "/glossaries/formats"): GetGlossaryFormats; + // (undocumented) + (path: "/storagesources"): GetDocumentStorageSource; +} + +// @public (undocumented) +export interface SourceInput { + // (undocumented) + filter?: DocumentFilter; + language?: string; + sourceUrl: string; + storageSource?: StorageSource; +} + +// @public (undocumented) +export type Status = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Cancelled" | "Cancelling" | "ValidationFailed"; + +// @public (undocumented) +export interface StatusSummary { + cancelled: number; + failed: number; + inProgress: number; + notYetStarted: number; + success: number; + total: number; + totalCharacterCharged: number; +} + +// @public (undocumented) +export type StorageInputType = "Folder" | "File"; + +// @public (undocumented) +export type StorageSource = "AzureBlob"; + +// @public (undocumented) +export interface StorageSourceListResult { + value: "AzureBlob"[]; +} + +// @public (undocumented) +export interface SubmitBatchRequest202Headers { + "operation-location"?: string; +} + +// @public (undocumented) +export interface SubmitBatchRequest202Properties { + // (undocumented) + headers: SubmitBatchRequest202Headers & RawHttpHeaders; + // (undocumented) + status: 202; +} + +// @public (undocumented) +export type SubmitBatchRequest202Response = SubmitBatchRequest202Properties & HttpResponse; + +// @public (undocumented) +export interface SubmitBatchRequest400Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 400; +} + +// @public (undocumented) +export type SubmitBatchRequest400Response = SubmitBatchRequest400Properties & HttpResponse; + +// @public (undocumented) +export interface SubmitBatchRequest401Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 401; +} + +// @public (undocumented) +export type SubmitBatchRequest401Response = SubmitBatchRequest401Properties & HttpResponse; + +// @public (undocumented) +export interface SubmitBatchRequest429Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 429; +} + +// @public (undocumented) +export type SubmitBatchRequest429Response = SubmitBatchRequest429Properties & HttpResponse; + +// @public (undocumented) +export interface SubmitBatchRequest500Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 500; +} + +// @public (undocumented) +export type SubmitBatchRequest500Response = SubmitBatchRequest500Properties & HttpResponse; + +// @public (undocumented) +export interface SubmitBatchRequest503Properties { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: 503; +} + +// @public (undocumented) +export type SubmitBatchRequest503Response = SubmitBatchRequest503Properties & HttpResponse; + +// @public (undocumented) +export interface SubmitBatchRequestBodyParam { + // (undocumented) + body?: BatchSubmissionRequest; +} + +// @public (undocumented) +export type SubmitBatchRequestParameters = RequestParameters & SubmitBatchRequestBodyParam; + +// @public (undocumented) +export interface TargetInput { + category?: string; + glossaries?: Glossary[]; + language: string; + storageSource?: StorageSource; + targetUrl: string; +} + + +// (No @packageDocumentation comment for this package) + +``` diff --git a/sdk/documenttranslator/ai-document-translator/rollup.config.js b/sdk/documenttranslator/ai-document-translator/rollup.config.js new file mode 100644 index 000000000000..5d7deee44c14 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/rollup.config.js @@ -0,0 +1,3 @@ +import { makeConfig } from "@azure/dev-tool/shared-config/rollup"; + +export default makeConfig(require("./package.json")); diff --git a/sdk/documenttranslator/ai-document-translator/sample.env b/sdk/documenttranslator/ai-document-translator/sample.env new file mode 100644 index 000000000000..700e9d42eebd --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/sample.env @@ -0,0 +1,7 @@ +# API key to authenticate service calls +DOCUMENT_TRANSLATOR_API_KEY= +# Document translation service endpoint +ENDPOINT= +# URLs to the Source and Target Azure Storage Blob containers +SOURCE_CONTAINER= +TARGET_CONTAINER= diff --git a/sdk/documenttranslator/ai-document-translator/samples-dev/listFormats.ts b/sdk/documenttranslator/ai-document-translator/samples-dev/listFormats.ts new file mode 100644 index 000000000000..e7a811a5a495 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples-dev/listFormats.ts @@ -0,0 +1,35 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how to make a simple call to the Azure Document Translator + * service to get a list of supported file formats + * + * @summary gets a list of all supported document formats + * @azsdk-weight 40 + */ + +import DocumentTranslator from "@azure-rest/ai-document-translator"; + +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || "document-translator endpoint"; +const apiKey = process.env["DOCUMENT_TRANSLATOR_API_KEY"] || ""; + +export async function main() { + console.log("== List supported document formats sample =="); + + const client = DocumentTranslator(endpoint, { key: apiKey }); + const formats = await client.path("/documents/formats").get(); + + if (formats.status !== 200) { + throw formats.body.error; + } + + console.log(formats.body.value.map((v) => v.format).join("\n")); +} + +main().catch((err) => { + console.error(err); +}); diff --git a/sdk/documenttranslator/ai-document-translator/samples-dev/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator/samples-dev/translateFromBlob.ts new file mode 100644 index 000000000000..4de3af800393 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples-dev/translateFromBlob.ts @@ -0,0 +1,122 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how translate a colletion of documents stored in a Azure Storage Blob container + * and output the translated documents to another container. + * Translating documents is considered a Long Running Operation because it may take a long time to complete, + * specially if translating large files or a batch with several files. + * To handle these long running operations we need to call a few different endpoints, to track the status of the operation + * @summary translates a collection of documents + * @azsdk-weight 40 + */ + +import DocumentTranslator, { BatchSubmissionRequest } from "@azure-rest/ai-document-translator"; + +import * as dotenv from "dotenv"; +dotenv.config(); + +/** + * These are states of the Long Running Operation considered as terminal + * that means that the operation has finished + */ +const terminalStates = ["Succeeded", "Failed", "Cancelled", "ValidationFailed"]; + +// Document Translation service endpoint +const endpoint = process.env["ENDPOINT"] || "document-translator endpoint"; +// Api key to authenticate the requests +const apiKey = process.env["DOCUMENT_TRANSLATOR_API_KEY"] || ""; +/** + * Azure Storage Blob containers, sourceContainer has the documents to be translated + * and targetContainer is the container where the translated documents will be output + */ +const sourceContainer = process.env["SOURCE_CONTAINER"] || ""; +const targetContainer = process.env["TARGET_CONTAINER"] || ""; + +/** + * This is the body that we need to send to the /batch endpoint + * to start a translation job on all the documents in sourceContainer + */ +const batchSubmissionRequest: BatchSubmissionRequest = { + inputs: [ + { + source: { sourceUrl: sourceContainer }, + targets: [{ language: "fr", targetUrl: targetContainer }] + } + ] +}; + +export async function main() { + console.log("== Translate documents in a container sample =="); + + // Create a new client + const client = DocumentTranslator(endpoint, { key: apiKey }); + + // Call the /batches path to initiate the translation job + const formats = await client.path("/batches").post({ + body: batchSubmissionRequest + }); + + // If we get a non-success status code, throw an error + if (formats.status !== 202) { + throw formats.body.error; + } + + // The initial response contains an operation-location header which indicates + // the url in which we can poll for the status of the operation + // this URL is in a format in which the last part of the url is the operationId + // we can extract that ID and use it to call "/batches/{id}" + const batchId = extractBatchId(formats.headers["operation-location"]); + + /** + * We need to keep polling for the operation state until we find a terminal state + * once we reached the terminal state we can proceed and access the translated documents + * or throw an error in case something failed + */ + // Setting up the batch status path to reuse it in the loop + const checkStatus = client.path("/batches/{id}", batchId); + let operationState; + do { + // We just call get on checkStatus and store the current state + operationState = await checkStatus.get(); + + // If we get a non-success status code, throw the error + if (operationState.status !== 200) { + throw operationState.body.error; + } + + // The checkStatus operation returns a retry-after header that contains the + // time in seconds to wait before sending the next polling request + const waitTime = Number.parseInt(operationState.headers["retry-after"] || "5"); + await wait(waitTime); + } while (!terminalStates.includes(operationState.body.status)); + + // Now that the operation is complete, we can list the translated documents + const documents = await client.path("/batches/{id}/documents", batchId).get(); + + if (documents.status !== 200) { + throw documents.body.error; + } + + console.log(documents.body.value.map((doc) => doc.path).join("\n")); +} + +// Helper function to wait/sleep for N seconds +function wait(seconds: number): Promise { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, seconds * 1000); + }); +} + +// Helper function that extracts the batch id from operation-location header +function extractBatchId(batchUrl: string = "") { + const parts = batchUrl.split("/"); + + return parts[parts.length - 1]; +} + +main().catch((err) => { + console.error(err); +}); diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/README.md b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/README.md new file mode 100644 index 000000000000..a067434d7dce --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/README.md @@ -0,0 +1,66 @@ +--- +page_type: sample +languages: + - javascript +products: + - azure + - azure-cognitive-services + - azure-document-translator +urlFragment: ai-document-translator-javascript +--- + +# Azure Document Translator client library samples for JavaScript + +These sample programs show how to use the JavaScript client libraries for Azure Document Translator in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------- | --------------------------------------------- | +| [listFormats.js][listformats] | gets a list of all supported document formats | +| [translateFromBlob.js][translatefromblob] | translates a collection of documents | + +## Prerequisites + +The sample programs are compatible with Node.js >=12.0.0. + +You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: + +- [Azure Cognitive Services instance][createinstance_azurecognitiveservicesinstance] + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +3. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node listFormats.js +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env ENDPOINT="" DOCUMENT_TRANSLATOR_API_KEY="" node listFormats.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[listformats]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/listFormats.js +[translatefromblob]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/translateFromBlob.js +[apiref]: https://docs.microsoft.com/javascript/api/@azure/ai-document-translator +[freesub]: https://azure.microsoft.com/free/ +[createinstance_azurecognitiveservicesinstance]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account +[package]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator/README.md diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/listFormats.js b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/listFormats.js new file mode 100644 index 000000000000..2ac681765c59 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/listFormats.js @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how to make a simple call to the Azure Document Translator + * service to get a list of supported file formats + * + * @summary gets a list of all supported document formats + */ + +const DocumentTranslator = require("@azure-rest/ai-document-translator"); + +const dotenv = require("dotenv"); +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || "document-translator endpoint"; +const apiKey = process.env["DOCUMENT_TRANSLATOR_API_KEY"] || ""; + +async function main() { + console.log("== List supported document formats sample =="); + + const client = DocumentTranslator(endpoint, { key: apiKey }); + const formats = await client.path("/documents/formats").get(); + + if (formats.status !== 200) { + throw formats.body.error; + } + + console.log(formats.body.value.map((v) => v.format).join("\n")); +} + +main().catch((err) => { + console.error(err); +}); diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/package.json b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/package.json new file mode 100644 index 000000000000..66ca589c2823 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/package.json @@ -0,0 +1,32 @@ +{ + "name": "azure-ai-document-translator-samples-js", + "private": true, + "version": "1.0.0", + "description": "Azure Document Translator client library samples for JavaScript", + "engine": { + "node": ">=12.0.0" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/documenttranslator/ai-document-translator" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator", + "dependencies": { + "@azure-rest/ai-document-translator": "next", + "dotenv": "latest" + } +} diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/sample.env b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/sample.env new file mode 100644 index 000000000000..700e9d42eebd --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/sample.env @@ -0,0 +1,7 @@ +# API key to authenticate service calls +DOCUMENT_TRANSLATOR_API_KEY= +# Document translation service endpoint +ENDPOINT= +# URLs to the Source and Target Azure Storage Blob containers +SOURCE_CONTAINER= +TARGET_CONTAINER= diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/translateFromBlob.js b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/translateFromBlob.js new file mode 100644 index 000000000000..6a9fad2fe1c1 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/translateFromBlob.js @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how translate a colletion of documents stored in a Azure Storage Blob container + * and output the translated documents to another container. + * Translating documents is considered a Long Running Operation because it may take a long time to complete, + * specially if translating large files or a batch with several files. + * To handle these long running operations we need to call a few different endpoints, to track the status of the operation + * @summary translates a collection of documents + */ + +const DocumentTranslator = require("@azure-rest/ai-document-translator"); + +const dotenv = require("dotenv"); +dotenv.config(); + +/** + * These are states of the Long Running Operation considered as terminal + * that means that the operation has finished + */ +const terminalStates = ["Succeeded", "Failed", "Cancelled", "ValidationFailed"]; + +// Document Translation service endpoint +const endpoint = process.env["ENDPOINT"] || "document-translator endpoint"; +// Api key to authenticate the requests +const apiKey = process.env["DOCUMENT_TRANSLATOR_API_KEY"] || ""; +/** + * Azure Storage Blob containers, sourceContainer has the documents to be translated + * and targetContainer is the container where the translated documents will be output + */ +const sourceContainer = process.env["SOURCE_CONTAINER"] || ""; +const targetContainer = process.env["TARGET_CONTAINER"] || ""; + +/** + * This is the body that we need to send to the /batch endpoint + * to start a translation job on all the documents in sourceContainer + */ +const batchSubmissionRequest = { + inputs: [ + { + source: { sourceUrl: sourceContainer }, + targets: [{ language: "fr", targetUrl: targetContainer }] + } + ] +}; + +async function main() { + console.log("== Translate documents in a container sample =="); + + // Create a new client + const client = DocumentTranslator(endpoint, { key: apiKey }); + + // Call the /batches path to initiate the translation job + const formats = await client.path("/batches").post({ + body: batchSubmissionRequest + }); + + // If we get a non-success status code, throw an error + if (formats.status !== 202) { + throw formats.body.error; + } + + // The initial response contains an operation-location header which indicates + // the url in which we can poll for the status of the operation + // this URL is in a format in which the last part of the url is the operationId + // we can extract that ID and use it to call "/batches/{id}" + const batchId = extractBatchId(formats.headers["operation-location"]); + + /** + * We need to keep polling for the operation state until we find a terminal state + * once we reached the terminal state we can proceed and access the translated documents + * or throw an error in case something failed + */ + // Setting up the batch status path to reuse it in the loop + const checkStatus = client.path("/batches/{id}", batchId); + let operationState; + do { + // We just call get on checkStatus and store the current state + operationState = await checkStatus.get(); + + // If we get a non-success status code, throw the error + if (operationState.status !== 200) { + throw operationState.body.error; + } + + // The checkStatus operation returns a retry-after header that contains the + // time in seconds to wait before sending the next polling request + const waitTime = Number.parseInt(operationState.headers["retry-after"] || "5"); + await wait(waitTime); + } while (!terminalStates.includes(operationState.body.status)); + + // Now that the operation is complete, we can list the translated documents + const documents = await client.path("/batches/{id}/documents", batchId).get(); + + if (documents.status !== 200) { + throw documents.body.error; + } + + console.log(documents.body.value.map((doc) => doc.path).join("\n")); +} + +// Helper function to wait/sleep for N seconds +function wait(seconds) { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, seconds * 1000); + }); +} + +// Helper function that extracts the batch id from operation-location header +function extractBatchId(batchUrl = "") { + const parts = batchUrl.split("/"); + + return parts[parts.length - 1]; +} + +main().catch((err) => { + console.error(err); +}); diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/README.md b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/README.md new file mode 100644 index 000000000000..e263e3cdc538 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/README.md @@ -0,0 +1,79 @@ +--- +page_type: sample +languages: + - typescript +products: + - azure + - azure-cognitive-services + - azure-document-translator +urlFragment: ai-document-translator-typescript +--- + +# Azure Document Translator client library samples for TypeScript + +These sample programs show how to use the TypeScript client libraries for Azure Document Translator in some common scenarios. + +| **File Name** | **Description** | +| ----------------------------------------- | --------------------------------------------- | +| [listFormats.ts][listformats] | gets a list of all supported document formats | +| [translateFromBlob.ts][translatefromblob] | translates a collection of documents | + +## Prerequisites + +The sample programs are compatible with Node.js >=12.0.0. + +Before running the samples in Node, they must be compiled to JavaScript using the TypeScript compiler. For more information on TypeScript, see the [TypeScript documentation][typescript]. Install the TypeScript compiler using: + +```bash +npm install -g typescript +``` + +You need [an Azure subscription][freesub] and the following Azure resources to run these sample programs: + +- [Azure Cognitive Services instance][createinstance_azurecognitiveservicesinstance] + +Samples retrieve credentials to access the service endpoint from environment variables. Alternatively, edit the source code to include the appropriate credentials. See each individual sample for details on which environment variables/credentials it requires to function. + +Adapting the samples to run in the browser may require some additional consideration. For details, please see the [package README][package]. + +## Setup + +To run the samples using the published version of the package: + +1. Install the dependencies using `npm`: + +```bash +npm install +``` + +2. Compile the samples: + +```bash +npm run build +``` + +3. Edit the file `sample.env`, adding the correct credentials to access the Azure service and run the samples. Then rename the file from `sample.env` to just `.env`. The sample programs will read this file automatically. + +4. Run whichever samples you like (note that some samples may require additional setup, see the table above): + +```bash +node dist/listFormats.ts +``` + +Alternatively, run a single sample with the correct environment variables set (setting up the `.env` file is not required if you do this), for example (cross-platform): + +```bash +npx cross-env ENDPOINT="" DOCUMENT_TRANSLATOR_API_KEY="" node dist/listFormats.js +``` + +## Next Steps + +Take a look at our [API Documentation][apiref] for more information about the APIs that are available in the clients. + +[listformats]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/listFormats.ts +[translatefromblob]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/translateFromBlob.ts +[apiref]: https://docs.microsoft.com/javascript/api/@azure/ai-document-translator +[freesub]: https://azure.microsoft.com/free/ +[createinstance_azurecognitiveservicesinstance]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account +[package]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator/README.md +[typescript]: https://www.typescriptlang.org/docs/home.html diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/package.json b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/package.json new file mode 100644 index 000000000000..4b8dd7bfdee6 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/package.json @@ -0,0 +1,40 @@ +{ + "name": "azure-ai-document-translator-samples-ts", + "private": true, + "version": "1.0.0", + "description": "Azure Document Translator client library samples for TypeScript", + "engine": { + "node": ">=12.0.0" + }, + "scripts": { + "build": "tsc", + "prebuild": "rimraf dist/" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/Azure/azure-sdk-for-js.git", + "directory": "sdk/documenttranslator/ai-document-translator" + }, + "keywords": [ + "node", + "azure", + "cloud", + "typescript", + "browser", + "isomorphic" + ], + "author": "Microsoft Corporation", + "license": "MIT", + "bugs": { + "url": "https://github.com/Azure/azure-sdk-for-js/issues" + }, + "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator", + "dependencies": { + "@azure-rest/ai-document-translator": "next", + "dotenv": "latest" + }, + "devDependencies": { + "typescript": "~4.2.0", + "rimraf": "latest" + } +} diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/sample.env b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/sample.env new file mode 100644 index 000000000000..700e9d42eebd --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/sample.env @@ -0,0 +1,7 @@ +# API key to authenticate service calls +DOCUMENT_TRANSLATOR_API_KEY= +# Document translation service endpoint +ENDPOINT= +# URLs to the Source and Target Azure Storage Blob containers +SOURCE_CONTAINER= +TARGET_CONTAINER= diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/listFormats.ts b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/listFormats.ts new file mode 100644 index 000000000000..0baaaf7f8067 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/listFormats.ts @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how to make a simple call to the Azure Document Translator + * service to get a list of supported file formats + * + * @summary gets a list of all supported document formats + */ + +import DocumentTranslator from "@azure-rest/ai-document-translator"; + +import * as dotenv from "dotenv"; +dotenv.config(); + +const endpoint = process.env["ENDPOINT"] || "document-translator endpoint"; +const apiKey = process.env["DOCUMENT_TRANSLATOR_API_KEY"] || ""; + +export async function main() { + console.log("== List supported document formats sample =="); + + const client = DocumentTranslator(endpoint, { key: apiKey }); + const formats = await client.path("/documents/formats").get(); + + if (formats.status !== 200) { + throw formats.body.error; + } + + console.log(formats.body.value.map((v) => v.format).join("\n")); +} + +main().catch((err) => { + console.error(err); +}); diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/translateFromBlob.ts new file mode 100644 index 000000000000..6ea39f8b4040 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/src/translateFromBlob.ts @@ -0,0 +1,121 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** + * This sample demonstrates how translate a colletion of documents stored in a Azure Storage Blob container + * and output the translated documents to another container. + * Translating documents is considered a Long Running Operation because it may take a long time to complete, + * specially if translating large files or a batch with several files. + * To handle these long running operations we need to call a few different endpoints, to track the status of the operation + * @summary translates a collection of documents + */ + +import DocumentTranslator, { BatchSubmissionRequest } from "@azure-rest/ai-document-translator"; + +import * as dotenv from "dotenv"; +dotenv.config(); + +/** + * These are states of the Long Running Operation considered as terminal + * that means that the operation has finished + */ +const terminalStates = ["Succeeded", "Failed", "Cancelled", "ValidationFailed"]; + +// Document Translation service endpoint +const endpoint = process.env["ENDPOINT"] || "document-translator endpoint"; +// Api key to authenticate the requests +const apiKey = process.env["DOCUMENT_TRANSLATOR_API_KEY"] || ""; +/** + * Azure Storage Blob containers, sourceContainer has the documents to be translated + * and targetContainer is the container where the translated documents will be output + */ +const sourceContainer = process.env["SOURCE_CONTAINER"] || ""; +const targetContainer = process.env["TARGET_CONTAINER"] || ""; + +/** + * This is the body that we need to send to the /batch endpoint + * to start a translation job on all the documents in sourceContainer + */ +const batchSubmissionRequest: BatchSubmissionRequest = { + inputs: [ + { + source: { sourceUrl: sourceContainer }, + targets: [{ language: "fr", targetUrl: targetContainer }] + } + ] +}; + +export async function main() { + console.log("== Translate documents in a container sample =="); + + // Create a new client + const client = DocumentTranslator(endpoint, { key: apiKey }); + + // Call the /batches path to initiate the translation job + const formats = await client.path("/batches").post({ + body: batchSubmissionRequest + }); + + // If we get a non-success status code, throw an error + if (formats.status !== 202) { + throw formats.body.error; + } + + // The initial response contains an operation-location header which indicates + // the url in which we can poll for the status of the operation + // this URL is in a format in which the last part of the url is the operationId + // we can extract that ID and use it to call "/batches/{id}" + const batchId = extractBatchId(formats.headers["operation-location"]); + + /** + * We need to keep polling for the operation state until we find a terminal state + * once we reached the terminal state we can proceed and access the translated documents + * or throw an error in case something failed + */ + // Setting up the batch status path to reuse it in the loop + const checkStatus = client.path("/batches/{id}", batchId); + let operationState; + do { + // We just call get on checkStatus and store the current state + operationState = await checkStatus.get(); + + // If we get a non-success status code, throw the error + if (operationState.status !== 200) { + throw operationState.body.error; + } + + // The checkStatus operation returns a retry-after header that contains the + // time in seconds to wait before sending the next polling request + const waitTime = Number.parseInt(operationState.headers["retry-after"] || "5"); + await wait(waitTime); + } while (!terminalStates.includes(operationState.body.status)); + + // Now that the operation is complete, we can list the translated documents + const documents = await client.path("/batches/{id}/documents", batchId).get(); + + if (documents.status !== 200) { + throw documents.body.error; + } + + console.log(documents.body.value.map((doc) => doc.path).join("\n")); +} + +// Helper function to wait/sleep for N seconds +function wait(seconds: number): Promise { + return new Promise((resolve) => { + setTimeout(() => { + resolve(); + }, seconds * 1000); + }); +} + +// Helper function that extracts the batch id from operation-location header +function extractBatchId(batchUrl: string = "") { + const parts = batchUrl.split("/"); + + return parts[parts.length - 1]; +} + +main().catch((err) => { + console.error(err); +}); diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/tsconfig.json b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/tsconfig.json new file mode 100644 index 000000000000..416c2dd82e00 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "ES2018", + "module": "commonjs", + "moduleResolution": "node", + "resolveJsonModule": true, + "esModuleInterop": true, + "allowSyntheticDefaultImports": true, + "strict": true, + "alwaysStrict": true, + "outDir": "dist", + "rootDir": "src" + }, + "include": [ + "src/**.ts" + ] +} diff --git a/sdk/documenttranslator/ai-document-translator/src/documentTranslationClient.ts b/sdk/documenttranslator/ai-document-translator/src/documentTranslationClient.ts new file mode 100644 index 000000000000..4589bd693a41 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/src/documentTranslationClient.ts @@ -0,0 +1,286 @@ +import { + SubmitBatchRequestParameters, + GetOperationsParameters, + GetDocumentStatusParameters, + GetOperationStatusParameters, + CancelOperationParameters, + GetOperationDocumentsStatusParameters, + GetDocumentFormatsParameters, + GetGlossaryFormatsParameters, + GetDocumentStorageSourceParameters +} from "./parameters"; +import { + SubmitBatchRequest202Response, + SubmitBatchRequest400Response, + SubmitBatchRequest401Response, + SubmitBatchRequest429Response, + SubmitBatchRequest500Response, + SubmitBatchRequest503Response, + GetOperations200Response, + GetOperations400Response, + GetOperations401Response, + GetOperations429Response, + GetOperations500Response, + GetOperations503Response, + GetDocumentStatus200Response, + GetDocumentStatus401Response, + GetDocumentStatus404Response, + GetDocumentStatus429Response, + GetDocumentStatus500Response, + GetDocumentStatus503Response, + GetOperationStatus200Response, + GetOperationStatus401Response, + GetOperationStatus404Response, + GetOperationStatus429Response, + GetOperationStatus500Response, + GetOperationStatus503Response, + CancelOperation200Response, + CancelOperation401Response, + CancelOperation404Response, + CancelOperation429Response, + CancelOperation500Response, + CancelOperation503Response, + GetOperationDocumentsStatus200Response, + GetOperationDocumentsStatus400Response, + GetOperationDocumentsStatus401Response, + GetOperationDocumentsStatus404Response, + GetOperationDocumentsStatus429Response, + GetOperationDocumentsStatus500Response, + GetOperationDocumentsStatus503Response, + GetDocumentFormats200Response, + GetDocumentFormats429Response, + GetDocumentFormats500Response, + GetDocumentFormats503Response, + GetGlossaryFormats200Response, + GetGlossaryFormats429Response, + GetGlossaryFormats500Response, + GetGlossaryFormats503Response, + GetDocumentStorageSource200Response, + GetDocumentStorageSource429Response, + GetDocumentStorageSource500Response, + GetDocumentStorageSource503Response +} from "./responses"; +import { getClient, ClientOptions, Client } from "@azure-rest/core-client"; +import { KeyCredential, TokenCredential } from "@azure/core-auth"; + +export interface GetOperations { + /** + * Use this API to submit a bulk (batch) translation request to the Document Translation service. + * Each request can contain multiple documents and must contain a source and destination container for each document. + * + * The prefix and suffix filter (if supplied) are used to filter folders. The prefix is applied to the subpath after the container name. + * + * Glossaries / Translation memory can be included in the request and are applied by the service when the document is translated. + * + * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. + * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. + */ + post( + options?: SubmitBatchRequestParameters + ): Promise< + | SubmitBatchRequest202Response + | SubmitBatchRequest400Response + | SubmitBatchRequest401Response + | SubmitBatchRequest429Response + | SubmitBatchRequest500Response + | SubmitBatchRequest503Response + >; + /** + * Returns a list of batch requests submitted and the status for each request. + * This list only contains batch requests submitted by the user (based on the resource). + * + * If the number of requests exceeds our paging limit, server-side paging is used. Paginated responses indicate a partial result and include a continuation token in the response. + * The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled operations. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * The server honors the values specified by the client. However, clients must be prepared to handle responses that contain a different page size or contain a continuation token. + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ + get( + options?: GetOperationsParameters + ): Promise< + | GetOperations200Response + | GetOperations400Response + | GetOperations401Response + | GetOperations429Response + | GetOperations500Response + | GetOperations503Response + >; +} + +export interface GetDocumentStatus { + /** Returns the translation status for a specific document based on the request Id and document Id. */ + get( + options?: GetDocumentStatusParameters + ): Promise< + | GetDocumentStatus200Response + | GetDocumentStatus401Response + | GetDocumentStatus404Response + | GetDocumentStatus429Response + | GetDocumentStatus500Response + | GetDocumentStatus503Response + >; +} + +export interface CancelOperation { + /** + * Returns the status for a document translation request. + * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. + */ + get( + options?: GetOperationStatusParameters + ): Promise< + | GetOperationStatus200Response + | GetOperationStatus401Response + | GetOperationStatus404Response + | GetOperationStatus429Response + | GetOperationStatus500Response + | GetOperationStatus503Response + >; + /** + * Cancel a currently processing or queued operation. + * Cancel a currently processing or queued operation. + * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * All documents that have completed translation will not be cancelled and will be charged. + * All pending documents will be cancelled if possible. + */ + delete( + options?: CancelOperationParameters + ): Promise< + | CancelOperation200Response + | CancelOperation401Response + | CancelOperation404Response + | CancelOperation429Response + | CancelOperation500Response + | CancelOperation503Response + >; +} + +export interface GetOperationDocumentsStatus { + /** + * Returns the status for all documents in a batch document translation request. + * + * If the number of documents in the response exceeds our paging limit, server-side paging is used. + * Paginated responses indicate a partial result and include a continuation token in the response. The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled documents. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ + get( + options?: GetOperationDocumentsStatusParameters + ): Promise< + | GetOperationDocumentsStatus200Response + | GetOperationDocumentsStatus400Response + | GetOperationDocumentsStatus401Response + | GetOperationDocumentsStatus404Response + | GetOperationDocumentsStatus429Response + | GetOperationDocumentsStatus500Response + | GetOperationDocumentsStatus503Response + >; +} + +export interface GetDocumentFormats { + /** + * The list of supported document formats supported by the Document Translation service. + * The list includes the common file extension, as well as the content-type if using the upload API. + */ + get( + options?: GetDocumentFormatsParameters + ): Promise< + | GetDocumentFormats200Response + | GetDocumentFormats429Response + | GetDocumentFormats500Response + | GetDocumentFormats503Response + >; +} + +export interface GetGlossaryFormats { + /** + * The list of supported glossary formats supported by the Document Translation service. + * The list includes the common file extension used. + */ + get( + options?: GetGlossaryFormatsParameters + ): Promise< + | GetGlossaryFormats200Response + | GetGlossaryFormats429Response + | GetGlossaryFormats500Response + | GetGlossaryFormats503Response + >; +} + +export interface GetDocumentStorageSource { + /** Returns a list of storage sources/options supported by the Document Translation service. */ + get( + options?: GetDocumentStorageSourceParameters + ): Promise< + | GetDocumentStorageSource200Response + | GetDocumentStorageSource429Response + | GetDocumentStorageSource500Response + | GetDocumentStorageSource503Response + >; +} + +export interface Routes { + (path: "/batches"): GetOperations; + (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; + (path: "/batches/{id}", id: string): CancelOperation; + (path: "/batches/{id}/documents", id: string): GetOperationDocumentsStatus; + (path: "/documents/formats"): GetDocumentFormats; + (path: "/glossaries/formats"): GetGlossaryFormats; + (path: "/storagesources"): GetDocumentStorageSource; +} + +export type DocumentTranslationClient = Client & { + path: Routes; +}; + +export interface DocumentTranslationFactory { + (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; +} + +export default function DocumentTranslation( + endpoint: string, + credentials: TokenCredential | KeyCredential, + options: ClientOptions = {} +): DocumentTranslationClient { + const baseUrl = + options.baseUrl || + "{endpoint}/translator/text/batch/v1.0-preview.1".replace(/{endpoint}/g, endpoint); + options = { + ...options, + credentials: { + scopes: ["https://cognitiveservices.azure.com/.default"], + apiKeyHeaderName: "Ocp-Apim-Subscription-Key" + } + }; + + return getClient(baseUrl, credentials, options) as DocumentTranslationClient; +} diff --git a/sdk/documenttranslator/ai-document-translator/src/index.ts b/sdk/documenttranslator/ai-document-translator/src/index.ts new file mode 100644 index 000000000000..15f116153569 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/src/index.ts @@ -0,0 +1,6 @@ +import DocumentTranslator from "./documentTranslationClient"; +export * from "./documentTranslationClient"; +export * from "./models"; +export * from "./parameters"; +export * from "./responses"; +export default DocumentTranslator; diff --git a/sdk/documenttranslator/ai-document-translator/src/models.ts b/sdk/documenttranslator/ai-document-translator/src/models.ts new file mode 100644 index 000000000000..1789ef0d000e --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/src/models.ts @@ -0,0 +1,219 @@ +export interface BatchSubmissionRequest { + /** The input list of documents or folders containing documents */ + inputs: BatchRequest[]; +} + +export interface BatchRequest { + /** Source of the input documents */ + source: SourceInput; + /** Location of the destination for the output */ + targets: TargetInput[]; + /** Storage type of the input documents source string */ + storageType?: StorageInputType; +} + +export interface SourceInput { + /** Location of the folder / container or single file with your documents */ + sourceUrl: string; + /** */ + filter?: DocumentFilter; + /** + * Language code + * If none is specified, we will perform auto detect on the document + */ + language?: string; + /** Storage Source */ + storageSource?: StorageSource; +} + +export interface DocumentFilter { + /** + * A case-sensitive prefix string to filter documents in the source path for translation. + * For example, when using a Azure storage blob Uri, use the prefix to restrict sub folders for translation. + */ + prefix?: string; + /** + * A case-sensitive suffix string to filter documents in the source path for translation. + * This is most often use for file extensions + */ + suffix?: string; +} + +export interface TargetInput { + /** Location of the folder / container with your documents */ + targetUrl: string; + /** Category / custom system for translation request */ + category?: string; + /** Target Language */ + language: string; + /** List of Glossary */ + glossaries?: Glossary[]; + /** Storage Source */ + storageSource?: StorageSource; +} + +export interface Glossary { + /** + * Location of the glossary. + * We will use the file extension to extract the formatting if the format parameter is not supplied. + * + * If the translation language pair is not present in the glossary, it will not be applied + */ + glossaryUrl: string; + /** Format */ + format: string; + /** Optional Version. If not specified, default is used. */ + version?: string; + /** Storage Source */ + storageSource?: StorageSource; +} + +export interface ErrorResponseV2 { + /** This contains an outer error with error code, message, details, target and an inner error with more descriptive details. */ + error?: ErrorV2; +} + +export interface ErrorV2 { + /** Enums containing high level error codes. */ + code: ErrorCodeV2; + /** Gets high level error message. */ + message: string; + /** + * Gets the source of the error. + * For example it would be "documents" or "document id" in case of invalid document. + */ + target?: string; + /** + * New Inner Error format which conforms to Cognitive Services API Guidelines which is available at https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow. + * This contains required properties ErrorCode, message and optional properties target, details(key value pair), inner error(this can be nested). + */ + innerError?: InnerErrorV2; +} + +export interface InnerErrorV2 { + /** Gets code error string. */ + code: string; + /** Gets high level error message. */ + message: string; + /** + * Gets the source of the error. + * For example it would be "documents" or "document id" in case of invalid document. + */ + target?: string; + /** + * New Inner Error format which conforms to Cognitive Services API Guidelines which is available at https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow. + * This contains required properties ErrorCode, message and optional properties target, details(key value pair), inner error(this can be nested). + */ + innerError?: InnerErrorV2; +} + +export interface BatchStatusResponse { + /** The summary status of individual operation */ + value: BatchStatusDetail[]; + /** Url for the next page. Null if no more pages available */ + nextLink?: string; +} + +export interface BatchStatusDetail { + /** Id of the operation. */ + id: string; + /** Operation created date time */ + createdDateTimeUtc: Date; + /** Date time in which the operation's status has been updated */ + lastActionDateTimeUtc: Date; + /** List of possible statuses for job or document */ + status: Status; + /** This contains an outer error with error code, message, details, target and an inner error with more descriptive details. */ + error?: ErrorV2; + /** */ + summary: StatusSummary; +} + +export interface StatusSummary { + /** Total count */ + total: number; + /** Failed count */ + failed: number; + /** Number of Success */ + success: number; + /** Number of in progress */ + inProgress: number; + /** Count of not yet started */ + notYetStarted: number; + /** Number of cancelled */ + cancelled: number; + /** Total characters charged by the API */ + totalCharacterCharged: number; +} + +export interface DocumentStatusDetail { + /** Location of the document or folder */ + path?: string; + /** Location of the source document */ + sourcePath: string; + /** Operation created date time */ + createdDateTimeUtc: Date; + /** Date time in which the operation's status has been updated */ + lastActionDateTimeUtc: Date; + /** List of possible statuses for job or document */ + status: Status; + /** To language */ + to: string; + /** This contains an outer error with error code, message, details, target and an inner error with more descriptive details. */ + error?: ErrorV2; + /** Progress of the translation if available */ + progress: number; + /** Document Id */ + id: string; + /** Character charged by the API */ + characterCharged?: number; +} + +export interface DocumentStatusResponse { + /** The detail status of individual documents */ + value: DocumentStatusDetail[]; + /** Url for the next page. Null if no more pages available */ + nextLink?: string; +} + +export interface FileFormatListResult { + /** list of objects */ + value: FileFormat[]; +} + +export interface FileFormat { + /** Name of the format */ + format: string; + /** Supported file extension for this format */ + fileExtensions: string[]; + /** Supported Content-Types for this format */ + contentTypes: string[]; + /** Default version if none is specified */ + defaultVersion?: string; + /** Supported Version */ + versions?: string[]; +} + +export interface StorageSourceListResult { + /** list of objects */ + value: "AzureBlob"[]; +} + +export type StorageSource = "AzureBlob"; +export type StorageInputType = "Folder" | "File"; +export type ErrorCodeV2 = + | "InvalidRequest" + | "InvalidArgument" + | "InternalServerError" + | "ServiceUnavailable" + | "ResourceNotFound" + | "Unauthorized" + | "RequestRateTooHigh"; +export type Status = + | "NotStarted" + | "Running" + | "Succeeded" + | "Failed" + | "Cancelled" + | "Cancelling" + | "ValidationFailed"; diff --git a/sdk/documenttranslator/ai-document-translator/src/parameters.ts b/sdk/documenttranslator/ai-document-translator/src/parameters.ts new file mode 100644 index 000000000000..830da04b960b --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/src/parameters.ts @@ -0,0 +1,101 @@ +import { RequestParameters } from "@azure-rest/core-client"; +import { BatchSubmissionRequest } from "./models"; + +export interface SubmitBatchRequestBodyParam { + body?: BatchSubmissionRequest; +} + +export type SubmitBatchRequestParameters = RequestParameters & SubmitBatchRequestBodyParam; + +export interface GetOperationsQueryParamProperties { + /** + * $top indicates the total number of records the user wants to be returned across all pages. + * + * Clients MAY use $top and $skip query parameters to specify a number of results to return and an offset into the collection. + * When both $top and $skip are given by a client, the server SHOULD first apply $skip and then $top on the collection. + * + * Note: If the server can't honor $top and/or $skip, the server MUST return an error to the client informing about it instead of just ignoring the query options. + */ + $top?: number; + /** + * $skip indicates the number of records to skip from the list of records held by the server based on the sorting method specified. By default, we sort by descending start time. + * + * Clients MAY use $top and $skip query parameters to specify a number of results to return and an offset into the collection. + * When both $top and $skip are given by a client, the server SHOULD first apply $skip and then $top on the collection. + * + * Note: If the server can't honor $top and/or $skip, the server MUST return an error to the client informing about it instead of just ignoring the query options. + */ + $skip?: number; + /** + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * Clients MAY request server-driven paging with a specific page size by specifying a $maxpagesize preference. The server SHOULD honor this preference if the specified page size is smaller than the server's default page size. + */ + $maxpagesize?: number; + /** Ids to use in filtering */ + ids?: string[]; + /** Statuses to use in filtering */ + statuses?: string[]; + /** the start datetime to get items after */ + createdDateTimeUtcStart?: Date; + /** the end datetime to get items before */ + createdDateTimeUtcEnd?: Date; + /** the sorting query for the collection (ex: 'CreatedDateTimeUtc asc', 'CreatedDateTimeUtc desc') */ + $orderBy?: string[]; +} + +export interface GetOperationsQueryParam { + queryParameters?: GetOperationsQueryParamProperties; +} + +export type GetOperationsParameters = RequestParameters & GetOperationsQueryParam; +export type GetDocumentStatusParameters = RequestParameters; +export type GetOperationStatusParameters = RequestParameters; +export type CancelOperationParameters = RequestParameters; + +export interface GetOperationDocumentsStatusQueryParamProperties { + /** + * $top indicates the total number of records the user wants to be returned across all pages. + * + * Clients MAY use $top and $skip query parameters to specify a number of results to return and an offset into the collection. + * When both $top and $skip are given by a client, the server SHOULD first apply $skip and then $top on the collection. + * + * Note: If the server can't honor $top and/or $skip, the server MUST return an error to the client informing about it instead of just ignoring the query options. + */ + $top?: number; + /** + * $skip indicates the number of records to skip from the list of records held by the server based on the sorting method specified. By default, we sort by descending start time. + * + * Clients MAY use $top and $skip query parameters to specify a number of results to return and an offset into the collection. + * When both $top and $skip are given by a client, the server SHOULD first apply $skip and then $top on the collection. + * + * Note: If the server can't honor $top and/or $skip, the server MUST return an error to the client informing about it instead of just ignoring the query options. + */ + $skip?: number; + /** + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * Clients MAY request server-driven paging with a specific page size by specifying a $maxpagesize preference. The server SHOULD honor this preference if the specified page size is smaller than the server's default page size. + */ + $maxpagesize?: number; + /** Ids to use in filtering */ + ids?: string[]; + /** Statuses to use in filtering */ + statuses?: string[]; + /** the start datetime to get items after */ + createdDateTimeUtcStart?: Date; + /** the end datetime to get items before */ + createdDateTimeUtcEnd?: Date; + /** the sorting query for the collection (ex: 'CreatedDateTimeUtc asc', 'CreatedDateTimeUtc desc') */ + $orderBy?: string[]; +} + +export interface GetOperationDocumentsStatusQueryParam { + queryParameters?: GetOperationDocumentsStatusQueryParamProperties; +} + +export type GetOperationDocumentsStatusParameters = RequestParameters & + GetOperationDocumentsStatusQueryParam; +export type GetDocumentFormatsParameters = RequestParameters; +export type GetGlossaryFormatsParameters = RequestParameters; +export type GetDocumentStorageSourceParameters = RequestParameters; diff --git a/sdk/documenttranslator/ai-document-translator/src/responses.ts b/sdk/documenttranslator/ai-document-translator/src/responses.ts new file mode 100644 index 000000000000..9b8d5049f6eb --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/src/responses.ts @@ -0,0 +1,420 @@ +import { + ErrorResponseV2, + BatchStatusResponse, + DocumentStatusDetail, + BatchStatusDetail, + DocumentStatusResponse, + FileFormatListResult, + StorageSourceListResult +} from "./models"; +import { HttpResponse } from "@azure-rest/core-client"; +import { RawHttpHeaders } from "@azure/core-rest-pipeline"; + +export interface SubmitBatchRequest202Headers { + /** Location of batch the operation */ + "operation-location"?: string; +} + +export type SubmitBatchRequest202Response = SubmitBatchRequest202Properties & HttpResponse; + +export interface SubmitBatchRequest202Properties { + status: 202; + headers: SubmitBatchRequest202Headers & RawHttpHeaders; +} + +export type SubmitBatchRequest400Response = SubmitBatchRequest400Properties & HttpResponse; + +export interface SubmitBatchRequest400Properties { + status: 400; + body: ErrorResponseV2; +} + +export type SubmitBatchRequest401Response = SubmitBatchRequest401Properties & HttpResponse; + +export interface SubmitBatchRequest401Properties { + status: 401; + body: ErrorResponseV2; +} + +export type SubmitBatchRequest429Response = SubmitBatchRequest429Properties & HttpResponse; + +export interface SubmitBatchRequest429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type SubmitBatchRequest500Response = SubmitBatchRequest500Properties & HttpResponse; + +export interface SubmitBatchRequest500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type SubmitBatchRequest503Response = SubmitBatchRequest503Properties & HttpResponse; + +export interface SubmitBatchRequest503Properties { + status: 503; + body: ErrorResponseV2; +} + +export interface GetOperations200Headers { + /** Indicates how long to wait before making a new request. */ + "retry-after"?: string; + /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ + etag?: string; +} + +export type GetOperations200Response = GetOperations200Properties & HttpResponse; + +export interface GetOperations200Properties { + status: 200; + body: BatchStatusResponse; + headers: GetOperations200Headers & RawHttpHeaders; +} + +export type GetOperations400Response = GetOperations400Properties & HttpResponse; + +export interface GetOperations400Properties { + status: 400; + body: ErrorResponseV2; +} + +export type GetOperations401Response = GetOperations401Properties & HttpResponse; + +export interface GetOperations401Properties { + status: 401; + body: ErrorResponseV2; +} + +export type GetOperations429Response = GetOperations429Properties & HttpResponse; + +export interface GetOperations429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type GetOperations500Response = GetOperations500Properties & HttpResponse; + +export interface GetOperations500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type GetOperations503Response = GetOperations503Properties & HttpResponse; + +export interface GetOperations503Properties { + status: 503; + body: ErrorResponseV2; +} + +export interface GetDocumentStatus200Headers { + /** Indicates how long to wait before making a new request. */ + "retry-after"?: string; + /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ + etag?: string; +} + +export type GetDocumentStatus200Response = GetDocumentStatus200Properties & HttpResponse; + +export interface GetDocumentStatus200Properties { + status: 200; + body: DocumentStatusDetail; + headers: GetDocumentStatus200Headers & RawHttpHeaders; +} + +export type GetDocumentStatus401Response = GetDocumentStatus401Properties & HttpResponse; + +export interface GetDocumentStatus401Properties { + status: 401; + body: ErrorResponseV2; +} + +export type GetDocumentStatus404Response = GetDocumentStatus404Properties & HttpResponse; + +export interface GetDocumentStatus404Properties { + status: 404; + body: ErrorResponseV2; +} + +export type GetDocumentStatus429Response = GetDocumentStatus429Properties & HttpResponse; + +export interface GetDocumentStatus429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type GetDocumentStatus500Response = GetDocumentStatus500Properties & HttpResponse; + +export interface GetDocumentStatus500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type GetDocumentStatus503Response = GetDocumentStatus503Properties & HttpResponse; + +export interface GetDocumentStatus503Properties { + status: 503; + body: ErrorResponseV2; +} + +export interface GetOperationStatus200Headers { + /** Indicates how long to wait before making a new request. */ + "retry-after"?: string; + /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ + etag?: string; +} + +export type GetOperationStatus200Response = GetOperationStatus200Properties & HttpResponse; + +export interface GetOperationStatus200Properties { + status: 200; + body: BatchStatusDetail; + headers: GetOperationStatus200Headers & RawHttpHeaders; +} + +export type GetOperationStatus401Response = GetOperationStatus401Properties & HttpResponse; + +export interface GetOperationStatus401Properties { + status: 401; + body: ErrorResponseV2; +} + +export type GetOperationStatus404Response = GetOperationStatus404Properties & HttpResponse; + +export interface GetOperationStatus404Properties { + status: 404; + body: ErrorResponseV2; +} + +export type GetOperationStatus429Response = GetOperationStatus429Properties & HttpResponse; + +export interface GetOperationStatus429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type GetOperationStatus500Response = GetOperationStatus500Properties & HttpResponse; + +export interface GetOperationStatus500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type GetOperationStatus503Response = GetOperationStatus503Properties & HttpResponse; + +export interface GetOperationStatus503Properties { + status: 503; + body: ErrorResponseV2; +} + +export type CancelOperation200Response = CancelOperation200Properties & HttpResponse; + +export interface CancelOperation200Properties { + status: 200; + body: BatchStatusDetail; +} + +export type CancelOperation401Response = CancelOperation401Properties & HttpResponse; + +export interface CancelOperation401Properties { + status: 401; + body: ErrorResponseV2; +} + +export type CancelOperation404Response = CancelOperation404Properties & HttpResponse; + +export interface CancelOperation404Properties { + status: 404; + body: ErrorResponseV2; +} + +export type CancelOperation429Response = CancelOperation429Properties & HttpResponse; + +export interface CancelOperation429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type CancelOperation500Response = CancelOperation500Properties & HttpResponse; + +export interface CancelOperation500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type CancelOperation503Response = CancelOperation503Properties & HttpResponse; + +export interface CancelOperation503Properties { + status: 503; + body: ErrorResponseV2; +} + +export interface GetOperationDocumentsStatus200Headers { + /** Indicates how long to wait before making a new request. */ + "retry-after"?: string; + /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ + etag?: string; +} + +export type GetOperationDocumentsStatus200Response = GetOperationDocumentsStatus200Properties & + HttpResponse; + +export interface GetOperationDocumentsStatus200Properties { + status: 200; + body: DocumentStatusResponse; + headers: GetOperationDocumentsStatus200Headers & RawHttpHeaders; +} + +export type GetOperationDocumentsStatus400Response = GetOperationDocumentsStatus400Properties & + HttpResponse; + +export interface GetOperationDocumentsStatus400Properties { + status: 400; + body: ErrorResponseV2; +} + +export type GetOperationDocumentsStatus401Response = GetOperationDocumentsStatus401Properties & + HttpResponse; + +export interface GetOperationDocumentsStatus401Properties { + status: 401; + body: ErrorResponseV2; +} + +export type GetOperationDocumentsStatus404Response = GetOperationDocumentsStatus404Properties & + HttpResponse; + +export interface GetOperationDocumentsStatus404Properties { + status: 404; + body: ErrorResponseV2; +} + +export type GetOperationDocumentsStatus429Response = GetOperationDocumentsStatus429Properties & + HttpResponse; + +export interface GetOperationDocumentsStatus429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type GetOperationDocumentsStatus500Response = GetOperationDocumentsStatus500Properties & + HttpResponse; + +export interface GetOperationDocumentsStatus500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type GetOperationDocumentsStatus503Response = GetOperationDocumentsStatus503Properties & + HttpResponse; + +export interface GetOperationDocumentsStatus503Properties { + status: 503; + body: ErrorResponseV2; +} + +export interface GetDocumentFormats200Headers { + /** Indicates how long to wait before making a new request. */ + "retry-after"?: string; +} + +export type GetDocumentFormats200Response = HttpResponse & GetDocumentFormats200Properties; + +export interface GetDocumentFormats200Properties { + status: 200; + body: FileFormatListResult; + headers: GetDocumentFormats200Headers & RawHttpHeaders; +} + +export type GetDocumentFormats429Response = GetDocumentFormats429Properties & HttpResponse; + +export interface GetDocumentFormats429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type GetDocumentFormats500Response = GetDocumentFormats500Properties & HttpResponse; + +export interface GetDocumentFormats500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type GetDocumentFormats503Response = GetDocumentFormats503Properties & HttpResponse; + +export interface GetDocumentFormats503Properties { + status: 503; + body: ErrorResponseV2; +} + +export interface GetGlossaryFormats200Headers { + /** Indicates how long to wait before making a new request. */ + "retry-after"?: string; +} + +export type GetGlossaryFormats200Response = GetGlossaryFormats200Properties & HttpResponse; + +export interface GetGlossaryFormats200Properties { + status: 200; + body: FileFormatListResult; + headers: GetGlossaryFormats200Headers & RawHttpHeaders; +} + +export type GetGlossaryFormats429Response = GetGlossaryFormats429Properties & HttpResponse; + +export interface GetGlossaryFormats429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type GetGlossaryFormats500Response = GetGlossaryFormats500Properties & HttpResponse; + +export interface GetGlossaryFormats500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type GetGlossaryFormats503Response = GetGlossaryFormats503Properties & HttpResponse; + +export interface GetGlossaryFormats503Properties { + status: 503; + body: ErrorResponseV2; +} + +export interface GetDocumentStorageSource200Headers { + /** Indicates how long to wait before making a new request. */ + "retry-after"?: string; +} + +export type GetDocumentStorageSource200Response = GetDocumentStorageSource200Properties & + HttpResponse; + +export interface GetDocumentStorageSource200Properties { + status: 200; + body: StorageSourceListResult; + headers: GetDocumentStorageSource200Headers & RawHttpHeaders; +} + +export type GetDocumentStorageSource429Response = GetDocumentStorageSource429Properties & + HttpResponse; + +export interface GetDocumentStorageSource429Properties { + status: 429; + body: ErrorResponseV2; +} + +export type GetDocumentStorageSource500Response = GetDocumentStorageSource500Properties & + HttpResponse; + +export interface GetDocumentStorageSource500Properties { + status: 500; + body: ErrorResponseV2; +} + +export type GetDocumentStorageSource503Response = GetDocumentStorageSource503Properties & + HttpResponse; + +export interface GetDocumentStorageSource503Properties { + status: 503; + body: ErrorResponseV2; +} diff --git a/sdk/documenttranslator/ai-document-translator/swagger/README.md b/sdk/documenttranslator/ai-document-translator/swagger/README.md new file mode 100644 index 000000000000..73a17b444136 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/swagger/README.md @@ -0,0 +1,22 @@ +# Azure Text Analytics TypeScript Protocol Layer + +> see https://aka.ms/autorest + +## Configuration + +```yaml +package-name: "@azure-rest/ai-document-translation" +title: DocumentTranslation +description: Document translation Client +generate-metadata: false +license-header: MICROSOFT_MIT_NO_VERSION +output-folder: ../ +source-code-folder-path: ./src +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cognitiveservices/data-plane/TranslatorText/preview/v1.0-preview.1/TranslatorBatch.json +package-version: 1.0.0-beta.1 +hide-clients: true +low-level-client: true +add-credentials: true +credential-scopes: "https://cognitiveservices.azure.com/.default" +credential-key-header-name: "Ocp-Apim-Subscription-Key" +``` diff --git a/sdk/documenttranslator/ai-document-translator/test/text.spec.ts b/sdk/documenttranslator/ai-document-translator/test/text.spec.ts new file mode 100644 index 000000000000..30e24c7f0b3a --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/test/text.spec.ts @@ -0,0 +1 @@ +export const x = "foo"; diff --git a/sdk/documenttranslator/ai-document-translator/tsconfig.json b/sdk/documenttranslator/ai-document-translator/tsconfig.json new file mode 100644 index 000000000000..379f3bd27110 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/tsconfig.json @@ -0,0 +1,16 @@ +{ + "extends": "../../../tsconfig.package", + "compilerOptions": { + "outDir": "./dist-esm", + "declarationDir": "./types", + "paths": { + "@azure-rest/ai-document-translator": ["./src/index"] + } + }, + "include": [ + "src/**/*.ts", + "test/**/*.ts", + "samples-dev/**/*.ts", + "../documentTranslationClient.ts" + ] +} diff --git a/sdk/documenttranslator/ai-document-translator/tsdoc.json b/sdk/documenttranslator/ai-document-translator/tsdoc.json new file mode 100644 index 000000000000..81c5a8a2aa2f --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator/tsdoc.json @@ -0,0 +1,4 @@ +{ + "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", + "extends": ["../../../tsdoc.json"] +} diff --git a/sdk/documenttranslator/ci.yml b/sdk/documenttranslator/ci.yml new file mode 100644 index 000000000000..3464af4012e4 --- /dev/null +++ b/sdk/documenttranslator/ci.yml @@ -0,0 +1,32 @@ +# NOTE: Please refer to https://aka.ms/azsdk/engsys/ci-yaml before editing this file. + +trigger: + branches: + include: + - master + - main + - release/* + - hotfix/* + paths: + include: + - sdk/documenttranslator/ + +pr: + branches: + include: + - master + - main + - feature/* + - release/* + - hotfix/* + paths: + include: + - sdk/documenttranslator/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: documenttranslator + Artifacts: + - name: azure-rest-ai-document-translator + safeName: azurerestaidocumenttranslator From 4317c7ecd77d3e11a846fc4d693b8121d56207f8 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 7 Apr 2021 01:08:55 +0000 Subject: [PATCH 03/37] Address PR feedback --- common/config/rush/common-versions.json | 1 + dataplane.code-workspace | 8 +++ rush.json | 2 +- sdk/core-rest/core-client/README.md | 2 +- sdk/core-rest/core-client/package.json | 2 +- .../core-client/review/core-client.api.md | 9 +-- .../core-client/src/clientHelpers.ts | 57 +++++++------------ sdk/core-rest/core-client/src/common.ts | 30 +--------- .../src/keyCredentialAuthenticationPolicy.ts | 25 ++++++++ sdk/core-rest/core-client/src/sendRequest.ts | 19 +------ sdk/core-rest/core-client/src/urlHelpers.ts | 2 +- sdk/core-rest/core-client/tsconfig.json | 7 +-- .../LICENSE | 0 .../api-extractor.json | 0 .../karma.conf.js | 0 .../package.json | 2 +- .../review/ai-document-translator.api.md | 10 ++-- .../rollup.config.js | 0 .../sample.env | 0 .../samples-dev/listFormats.ts | 0 .../samples-dev/translateFromBlob.ts | 7 +-- .../samples/v1/javascript/README.md | 6 +- .../samples/v1/javascript/listFormats.js | 0 .../samples/v1/javascript/package.json | 4 +- .../samples/v1/javascript/sample.env | 0 .../v1/javascript/translateFromBlob.js | 7 +-- .../samples/v1/typescript/README.md | 6 +- .../samples/v1/typescript/package.json | 4 +- .../samples/v1/typescript/sample.env | 0 .../samples/v1/typescript/src/listFormats.ts | 0 .../v1/typescript/src/translateFromBlob.ts | 7 +-- .../samples/v1/typescript/tsconfig.json | 0 .../src/documentTranslator.ts} | 6 +- .../src/index.ts | 4 +- .../src/models.ts | 0 .../src/parameters.ts | 0 .../src/responses.ts | 0 .../swagger/README.md | 0 .../test/text.spec.ts | 0 .../tsconfig.json | 0 .../tsdoc.json | 0 41 files changed, 97 insertions(+), 130 deletions(-) create mode 100644 sdk/core-rest/core-client/src/keyCredentialAuthenticationPolicy.ts rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/LICENSE (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/api-extractor.json (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/karma.conf.js (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/package.json (97%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/review/ai-document-translator.api.md (99%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/rollup.config.js (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/sample.env (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples-dev/listFormats.ts (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples-dev/translateFromBlob.ts (95%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/javascript/README.md (91%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/javascript/listFormats.js (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/javascript/package.json (85%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/javascript/sample.env (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/javascript/translateFromBlob.js (95%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/typescript/README.md (92%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/typescript/package.json (87%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/typescript/sample.env (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/typescript/src/listFormats.ts (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/typescript/src/translateFromBlob.ts (95%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/samples/v1/typescript/tsconfig.json (100%) rename sdk/documenttranslator/{ai-document-translator/src/documentTranslationClient.ts => ai-document-translator-rest/src/documentTranslator.ts} (98%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/src/index.ts (52%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/src/models.ts (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/src/parameters.ts (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/src/responses.ts (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/swagger/README.md (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/test/text.spec.ts (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/tsconfig.json (100%) rename sdk/documenttranslator/{ai-document-translator => ai-document-translator-rest}/tsdoc.json (100%) diff --git a/common/config/rush/common-versions.json b/common/config/rush/common-versions.json index 37f61e32c77d..ff495a2de733 100644 --- a/common/config/rush/common-versions.json +++ b/common/config/rush/common-versions.json @@ -68,6 +68,7 @@ "@azure/ms-rest-nodeauth": ["^0.9.2"], // Idenity is moving from v1 to v2. Moving all packages to v2 is going to take a bit of time, in the mean time we could use v2 on the perf-identity tests. "@azure/identity": ["^2.0.0-beta.1"], + // Issue #14771 tracks updating to these versions "@microsoft/api-extractor": ["7.13.2"], "prettier": ["2.2.1"] } diff --git a/dataplane.code-workspace b/dataplane.code-workspace index 95a184304572..856932e1110e 100644 --- a/dataplane.code-workspace +++ b/dataplane.code-workspace @@ -52,6 +52,14 @@ "name": "core-client", "path": "sdk/core/core-client" }, + { + "name": "rest-core-client", + "path": "sdk/core-rest/core-client" + }, + { + "name": "ai-document-translator", + "path": "sdk/documenttranslator/ai-document-translator-rest" + }, { "name": "core-crypto", "path": "sdk/core/core-crypto" diff --git a/rush.json b/rush.json index 1e52df23a16d..45a617e334c3 100644 --- a/rush.json +++ b/rush.json @@ -334,7 +334,7 @@ }, { "packageName": "@azure-rest/ai-document-translator", - "projectFolder": "sdk/documenttranslator/ai-document-translator", + "projectFolder": "sdk/documenttranslator/ai-document-translator-rest", "versionPolicyName": "client" }, { diff --git a/sdk/core-rest/core-client/README.md b/sdk/core-rest/core-client/README.md index 523df6b70253..c677cf8da8d6 100644 --- a/sdk/core-rest/core-client/README.md +++ b/sdk/core-rest/core-client/README.md @@ -1,6 +1,6 @@ # Azure Core Service client library for JavaScript (Experimental) -This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript). Specifically for low level clients +This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript). Specifically for rest level clients ## Getting started diff --git a/sdk/core-rest/core-client/package.json b/sdk/core-rest/core-client/package.json index 5ce07592211b..29eef8749c6a 100644 --- a/sdk/core-rest/core-client/package.json +++ b/sdk/core-rest/core-client/package.json @@ -1,7 +1,7 @@ { "name": "@azure-rest/core-client", "version": "1.0.0-beta.1", - "description": "Core library for interfacing with AutoRest low level generated code", + "description": "Core library for interfacing with AutoRest rest level generated code", "sdk-type": "client", "main": "dist/index.js", "module": "dist-esm/src/index.js", diff --git a/sdk/core-rest/core-client/review/core-client.api.md b/sdk/core-rest/core-client/review/core-client.api.md index cf8c97ba09fe..1bd5038b0bba 100644 --- a/sdk/core-rest/core-client/review/core-client.api.md +++ b/sdk/core-rest/core-client/review/core-client.api.md @@ -7,7 +7,7 @@ import { KeyCredential } from '@azure/core-auth'; import { Pipeline } from '@azure/core-rest-pipeline'; import { PipelineOptions } from '@azure/core-rest-pipeline'; -import { PipelineRequest } from '@azure/core-rest-pipeline'; +import { PipelineResponse } from '@azure/core-rest-pipeline'; import { RawHttpHeaders } from '@azure/core-rest-pipeline'; import { TokenCredential } from '@azure/core-auth'; @@ -54,14 +54,9 @@ export function getClient(baseUrl: string, options?: PipelineOptions): Client; export function getClient(baseUrl: string, credentials?: TokenCredential | KeyCredential, options?: PipelineOptions): Client; // @public -export type HttpResponse = { - request: PipelineRequest; - status: number; +export type HttpResponse = Omit & { headers: RawHttpHeaders; body: unknown; - bodyAsText?: string | null; - blobBody?: Promise; - readableStreamBody?: NodeJS.ReadableStream; }; // @public diff --git a/sdk/core-rest/core-client/src/clientHelpers.ts b/sdk/core-rest/core-client/src/clientHelpers.ts index 8397355ad26b..1456333c1645 100644 --- a/sdk/core-rest/core-client/src/clientHelpers.ts +++ b/sdk/core-rest/core-client/src/clientHelpers.ts @@ -5,15 +5,12 @@ import { createDefaultHttpClient, HttpClient, PipelinePolicy, - PipelineRequest, - SendRequest, - PipelineResponse, } from "@azure/core-rest-pipeline"; import { TokenCredential, KeyCredential, isTokenCredential } from "@azure/core-auth"; import { ClientOptions } from "./common"; +import { keyCredentialAuthenticationPolicy } from "./keyCredentialAuthenticationPolicy"; -let cachedHttpsClient: HttpClient | undefined; -const API_KEY_HEADER_NAME = "Ocp-Apim-Subscription-Key"; +let cachedHttpClient: HttpClient | undefined; /** * Creates a default rest pipeline to re-use accross Rest Level Clients @@ -24,18 +21,24 @@ export function createDefaultPipeline( options: ClientOptions = {} ): Pipeline { const pipeline = createPipelineFromOptions(options); + pipeline.removePolicy({ name: "exponentialRetryPolicy" }); if (credential) { - const credentialPolicy = isTokenCredential(credential) - ? bearerTokenAuthenticationPolicy({ - credential, - scopes: options.credentials?.scopes || `${baseUrl}/.default`, - }) - : keyCredentialAuthenticationPolicy( - credential, - options.credentials?.apiKeyHeaderName || API_KEY_HEADER_NAME - ); - + let credentialPolicy: PipelinePolicy; + if (isTokenCredential(credential)) { + credentialPolicy = bearerTokenAuthenticationPolicy({ + credential, + scopes: options.credentials?.scopes || `${baseUrl}/.default`, + }); + } else { + if (!options.credentials?.apiKeyHeaderName) { + throw new Error(`Missing API Key Header Name`); + } + credentialPolicy = keyCredentialAuthenticationPolicy( + credential, + options.credentials?.apiKeyHeaderName + ); + } pipeline.addPolicy(credentialPolicy); } @@ -43,27 +46,9 @@ export function createDefaultPipeline( } export function getCachedDefaultHttpsClient(): HttpClient { - if (!cachedHttpsClient) { - cachedHttpsClient = createDefaultHttpClient(); + if (!cachedHttpClient) { + cachedHttpClient = createDefaultHttpClient(); } - return cachedHttpsClient; -} - -/** - * The programmatic identifier of the bearerTokenAuthenticationPolicy. - */ -export const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy"; - -export function keyCredentialAuthenticationPolicy( - credential: KeyCredential, - apiKeyHeaderName: string -): PipelinePolicy { - return { - name: keyCredentialAuthenticationPolicyName, - async sendRequest(request: PipelineRequest, next: SendRequest): Promise { - request.headers.set(apiKeyHeaderName, credential.key); - return next(request); - }, - }; + return cachedHttpClient; } diff --git a/sdk/core-rest/core-client/src/common.ts b/sdk/core-rest/core-client/src/common.ts index 640b19f2bb12..74c4cd3a3661 100644 --- a/sdk/core-rest/core-client/src/common.ts +++ b/sdk/core-rest/core-client/src/common.ts @@ -1,4 +1,4 @@ -import { PipelineRequest, PipelineOptions, RawHttpHeaders } from "@azure/core-rest-pipeline"; +import { PipelineOptions, RawHttpHeaders, PipelineResponse } from "@azure/core-rest-pipeline"; /** * General options that a Rest Level Client can take @@ -14,15 +14,7 @@ export type ClientOptions = PipelineOptions & { /** * Represents the shape of an HttpResponse */ -export type HttpResponse = { - /** - * The request that generated this response. - */ - request: PipelineRequest; - /** - * The HTTP status code of the response. - */ - status: number; +export type HttpResponse = Omit & { /** * The HTTP response headers. */ @@ -31,22 +23,4 @@ export type HttpResponse = { * Parsed body */ body: unknown; - /** - * The response body as text (string format) - */ - bodyAsText?: string | null; - /** - * BROWSER ONLY - * - * The response body as a browser Blob. - * Always undefined in node.js. - */ - blobBody?: Promise; - /** - * NODEJS ONLY - * - * The response body as a node.js Readable stream. - * Always undefined in the browser. - */ - readableStreamBody?: NodeJS.ReadableStream; }; diff --git a/sdk/core-rest/core-client/src/keyCredentialAuthenticationPolicy.ts b/sdk/core-rest/core-client/src/keyCredentialAuthenticationPolicy.ts new file mode 100644 index 000000000000..c25339eeebda --- /dev/null +++ b/sdk/core-rest/core-client/src/keyCredentialAuthenticationPolicy.ts @@ -0,0 +1,25 @@ +import { KeyCredential } from "@azure/core-auth"; +import { + PipelinePolicy, + PipelineRequest, + PipelineResponse, + SendRequest, +} from "@azure/core-rest-pipeline"; + +/** + * The programmatic identifier of the bearerTokenAuthenticationPolicy. + */ +export const keyCredentialAuthenticationPolicyName = "keyCredentialAuthenticationPolicy"; + +export function keyCredentialAuthenticationPolicy( + credential: KeyCredential, + apiKeyHeaderName: string +): PipelinePolicy { + return { + name: keyCredentialAuthenticationPolicyName, + async sendRequest(request: PipelineRequest, next: SendRequest): Promise { + request.headers.set(apiKeyHeaderName, credential.key); + return next(request); + }, + }; +} diff --git a/sdk/core-rest/core-client/src/sendRequest.ts b/sdk/core-rest/core-client/src/sendRequest.ts index 32cec1187a90..acdf9548d92f 100644 --- a/sdk/core-rest/core-client/src/sendRequest.ts +++ b/sdk/core-rest/core-client/src/sendRequest.ts @@ -34,7 +34,7 @@ export async function sendRequest( const body = JSON.stringify(options.body); const request = createPipelineRequest({ - url: url.toString(), + url, method, body, headers, @@ -42,10 +42,7 @@ export async function sendRequest( }); const result = await pipeline.sendRequest(httpClient, request); - let rawHeaders: RawHttpHeaders = {}; - for (const [key, value] of result.headers) { - rawHeaders[key] = value; - } + const rawHeaders: RawHttpHeaders = result.headers.toJSON(); let parsedBody = undefined; @@ -71,20 +68,10 @@ export async function sendRequest( * @returns returns the content-type */ function getContentType(body: any): string { - try { - const jsonBody = JSON.stringify(body); - JSON.parse(jsonBody); - return "application/json; charset=UTF-8"; - } catch {} - - if (typeof body === "string") { - return "text/plain"; - } - if (ArrayBuffer.isView(body)) { return "application/octet-stream"; } - // Default, we may want to log a warning + // By default return json return "application/json; charset=UTF-8"; } diff --git a/sdk/core-rest/core-client/src/urlHelpers.ts b/sdk/core-rest/core-client/src/urlHelpers.ts index 8a431a285a14..136e97ef4f39 100644 --- a/sdk/core-rest/core-client/src/urlHelpers.ts +++ b/sdk/core-rest/core-client/src/urlHelpers.ts @@ -29,7 +29,7 @@ export function buildRequestUrl( if (options.queryParameters) { const queryParams = options.queryParameters; for (const key of Object.keys(queryParams)) { - url.searchParams.append(key, (queryParams as any)[key]); + url.searchParams.append(key, queryParams[key]); } } diff --git a/sdk/core-rest/core-client/tsconfig.json b/sdk/core-rest/core-client/tsconfig.json index 455ac455f5a7..3863167ddb92 100644 --- a/sdk/core-rest/core-client/tsconfig.json +++ b/sdk/core-rest/core-client/tsconfig.json @@ -2,10 +2,7 @@ "extends": "../../../tsconfig.package", "compilerOptions": { "outDir": "./dist-esm", - "declarationDir": "./types", - "paths": { - "@azure/ai-text-analytics": ["./src/index"] - } + "declarationDir": "./types" }, - "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts"] + "include": ["src/**/*.ts", "test/**/*.ts"] } diff --git a/sdk/documenttranslator/ai-document-translator/LICENSE b/sdk/documenttranslator/ai-document-translator-rest/LICENSE similarity index 100% rename from sdk/documenttranslator/ai-document-translator/LICENSE rename to sdk/documenttranslator/ai-document-translator-rest/LICENSE diff --git a/sdk/documenttranslator/ai-document-translator/api-extractor.json b/sdk/documenttranslator/ai-document-translator-rest/api-extractor.json similarity index 100% rename from sdk/documenttranslator/ai-document-translator/api-extractor.json rename to sdk/documenttranslator/ai-document-translator-rest/api-extractor.json diff --git a/sdk/documenttranslator/ai-document-translator/karma.conf.js b/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js similarity index 100% rename from sdk/documenttranslator/ai-document-translator/karma.conf.js rename to sdk/documenttranslator/ai-document-translator-rest/karma.conf.js diff --git a/sdk/documenttranslator/ai-document-translator/package.json b/sdk/documenttranslator/ai-document-translator-rest/package.json similarity index 97% rename from sdk/documenttranslator/ai-document-translator/package.json rename to sdk/documenttranslator/ai-document-translator-rest/package.json index 36751eb49329..f11d814fa3e3 100644 --- a/sdk/documenttranslator/ai-document-translator/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/package.json @@ -2,7 +2,7 @@ "name": "@azure-rest/ai-document-translator", "sdk-type": "client", "author": "Microsoft Corporation", - "description": "An isomorphic low level client library for the Azure Document Translator service.", + "description": "An isomorphic rest level client library for the Azure Document Translator service.", "version": "1.0.0-beta.1", "keywords": [ "node", diff --git a/sdk/documenttranslator/ai-document-translator/review/ai-document-translator.api.md b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md similarity index 99% rename from sdk/documenttranslator/ai-document-translator/review/ai-document-translator.api.md rename to sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md index 0a435c4965c8..2eb3f0e4f60b 100644 --- a/sdk/documenttranslator/ai-document-translator/review/ai-document-translator.api.md +++ b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md @@ -142,11 +142,6 @@ export interface DocumentStatusResponse { value: DocumentStatusDetail[]; } -// @public (undocumented) -function DocumentTranslation(endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslationClient; - -export default DocumentTranslation; - // @public (undocumented) export type DocumentTranslationClient = Client & { path: Routes; @@ -158,6 +153,11 @@ export interface DocumentTranslationFactory { (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; } +// @public (undocumented) +function DocumentTranslator(endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslationClient; + +export default DocumentTranslator; + // @public (undocumented) export type ErrorCodeV2 = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "ResourceNotFound" | "Unauthorized" | "RequestRateTooHigh"; diff --git a/sdk/documenttranslator/ai-document-translator/rollup.config.js b/sdk/documenttranslator/ai-document-translator-rest/rollup.config.js similarity index 100% rename from sdk/documenttranslator/ai-document-translator/rollup.config.js rename to sdk/documenttranslator/ai-document-translator-rest/rollup.config.js diff --git a/sdk/documenttranslator/ai-document-translator/sample.env b/sdk/documenttranslator/ai-document-translator-rest/sample.env similarity index 100% rename from sdk/documenttranslator/ai-document-translator/sample.env rename to sdk/documenttranslator/ai-document-translator-rest/sample.env diff --git a/sdk/documenttranslator/ai-document-translator/samples-dev/listFormats.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts similarity index 100% rename from sdk/documenttranslator/ai-document-translator/samples-dev/listFormats.ts rename to sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts diff --git a/sdk/documenttranslator/ai-document-translator/samples-dev/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts similarity index 95% rename from sdk/documenttranslator/ai-document-translator/samples-dev/translateFromBlob.ts rename to sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts index 4de3af800393..2cc9013eaabe 100644 --- a/sdk/documenttranslator/ai-document-translator/samples-dev/translateFromBlob.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts @@ -87,7 +87,8 @@ export async function main() { // The checkStatus operation returns a retry-after header that contains the // time in seconds to wait before sending the next polling request - const waitTime = Number.parseInt(operationState.headers["retry-after"] || "5"); + const parsedRetryAfter = Number.parseInt(operationState.headers["retry-after"] || "5"); + const waitTime = Number.isInteger(parsedRetryAfter) ? parsedRetryAfter : 5; await wait(waitTime); } while (!terminalStates.includes(operationState.body.status)); @@ -104,9 +105,7 @@ export async function main() { // Helper function to wait/sleep for N seconds function wait(seconds: number): Promise { return new Promise((resolve) => { - setTimeout(() => { - resolve(); - }, seconds * 1000); + setTimeout(resolve, seconds * 1000); }); } diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md similarity index 91% rename from sdk/documenttranslator/ai-document-translator/samples/v1/javascript/README.md rename to sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md index a067434d7dce..e46838aa48b7 100644 --- a/sdk/documenttranslator/ai-document-translator/samples/v1/javascript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md @@ -58,9 +58,9 @@ npx cross-env ENDPOINT="" DOCUMENT_TRANSLATOR_API_KEY=" { - setTimeout(() => { - resolve(); - }, seconds * 1000); + setTimeout(resolve, seconds * 1000); }); } diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md similarity index 92% rename from sdk/documenttranslator/ai-document-translator/samples/v1/typescript/README.md rename to sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md index e263e3cdc538..d69b6df9740a 100644 --- a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md @@ -70,10 +70,10 @@ npx cross-env ENDPOINT="" DOCUMENT_TRANSLATOR_API_KEY=" { return new Promise((resolve) => { - setTimeout(() => { - resolve(); - }, seconds * 1000); + setTimeout(resolve, seconds * 1000); }); } diff --git a/sdk/documenttranslator/ai-document-translator/samples/v1/typescript/tsconfig.json b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/tsconfig.json similarity index 100% rename from sdk/documenttranslator/ai-document-translator/samples/v1/typescript/tsconfig.json rename to sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/tsconfig.json diff --git a/sdk/documenttranslator/ai-document-translator/src/documentTranslationClient.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts similarity index 98% rename from sdk/documenttranslator/ai-document-translator/src/documentTranslationClient.ts rename to sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index 4589bd693a41..996a180082db 100644 --- a/sdk/documenttranslator/ai-document-translator/src/documentTranslationClient.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -266,14 +266,12 @@ export interface DocumentTranslationFactory { (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; } -export default function DocumentTranslation( +export default function DocumentTranslator( endpoint: string, credentials: TokenCredential | KeyCredential, options: ClientOptions = {} ): DocumentTranslationClient { - const baseUrl = - options.baseUrl || - "{endpoint}/translator/text/batch/v1.0-preview.1".replace(/{endpoint}/g, endpoint); + const baseUrl = options.baseUrl || `${endpoint}/translator/text/batch/v1.0-preview.1`; options = { ...options, credentials: { diff --git a/sdk/documenttranslator/ai-document-translator/src/index.ts b/sdk/documenttranslator/ai-document-translator-rest/src/index.ts similarity index 52% rename from sdk/documenttranslator/ai-document-translator/src/index.ts rename to sdk/documenttranslator/ai-document-translator-rest/src/index.ts index 15f116153569..b4f5c01a926e 100644 --- a/sdk/documenttranslator/ai-document-translator/src/index.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/index.ts @@ -1,5 +1,5 @@ -import DocumentTranslator from "./documentTranslationClient"; -export * from "./documentTranslationClient"; +import DocumentTranslator from "./documentTranslator"; +export * from "./documentTranslator"; export * from "./models"; export * from "./parameters"; export * from "./responses"; diff --git a/sdk/documenttranslator/ai-document-translator/src/models.ts b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts similarity index 100% rename from sdk/documenttranslator/ai-document-translator/src/models.ts rename to sdk/documenttranslator/ai-document-translator-rest/src/models.ts diff --git a/sdk/documenttranslator/ai-document-translator/src/parameters.ts b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts similarity index 100% rename from sdk/documenttranslator/ai-document-translator/src/parameters.ts rename to sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts diff --git a/sdk/documenttranslator/ai-document-translator/src/responses.ts b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts similarity index 100% rename from sdk/documenttranslator/ai-document-translator/src/responses.ts rename to sdk/documenttranslator/ai-document-translator-rest/src/responses.ts diff --git a/sdk/documenttranslator/ai-document-translator/swagger/README.md b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md similarity index 100% rename from sdk/documenttranslator/ai-document-translator/swagger/README.md rename to sdk/documenttranslator/ai-document-translator-rest/swagger/README.md diff --git a/sdk/documenttranslator/ai-document-translator/test/text.spec.ts b/sdk/documenttranslator/ai-document-translator-rest/test/text.spec.ts similarity index 100% rename from sdk/documenttranslator/ai-document-translator/test/text.spec.ts rename to sdk/documenttranslator/ai-document-translator-rest/test/text.spec.ts diff --git a/sdk/documenttranslator/ai-document-translator/tsconfig.json b/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json similarity index 100% rename from sdk/documenttranslator/ai-document-translator/tsconfig.json rename to sdk/documenttranslator/ai-document-translator-rest/tsconfig.json diff --git a/sdk/documenttranslator/ai-document-translator/tsdoc.json b/sdk/documenttranslator/ai-document-translator-rest/tsdoc.json similarity index 100% rename from sdk/documenttranslator/ai-document-translator/tsdoc.json rename to sdk/documenttranslator/ai-document-translator-rest/tsdoc.json From d6318905f7d7e8101675c247eb1a42bcf2a43351 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 7 Apr 2021 02:56:53 +0000 Subject: [PATCH 04/37] Update generated code with more comments --- .../review/ai-document-translator.api.md | 231 ++++--- .../src/documentTranslator.ts | 19 +- .../src/responses.ts | 624 ++++++++++++++++-- .../swagger/README.md | 6 +- 4 files changed, 680 insertions(+), 200 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md index 2eb3f0e4f60b..ce865be5e271 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md +++ b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md @@ -55,8 +55,8 @@ export interface CancelOperation200Properties { status: 200; } -// @public (undocumented) -export type CancelOperation200Response = CancelOperation200Properties & HttpResponse; +// @public +export type CancelOperation200Response = HttpResponse & CancelOperation200Properties; // @public (undocumented) export interface CancelOperation401Properties { @@ -66,8 +66,8 @@ export interface CancelOperation401Properties { status: 401; } -// @public (undocumented) -export type CancelOperation401Response = CancelOperation401Properties & HttpResponse; +// @public +export type CancelOperation401Response = HttpResponse & CancelOperation401Properties; // @public (undocumented) export interface CancelOperation404Properties { @@ -77,8 +77,8 @@ export interface CancelOperation404Properties { status: 404; } -// @public (undocumented) -export type CancelOperation404Response = CancelOperation404Properties & HttpResponse; +// @public +export type CancelOperation404Response = HttpResponse & CancelOperation404Properties; // @public (undocumented) export interface CancelOperation429Properties { @@ -88,8 +88,8 @@ export interface CancelOperation429Properties { status: 429; } -// @public (undocumented) -export type CancelOperation429Response = CancelOperation429Properties & HttpResponse; +// @public +export type CancelOperation429Response = HttpResponse & CancelOperation429Properties; // @public (undocumented) export interface CancelOperation500Properties { @@ -99,8 +99,8 @@ export interface CancelOperation500Properties { status: 500; } -// @public (undocumented) -export type CancelOperation500Response = CancelOperation500Properties & HttpResponse; +// @public +export type CancelOperation500Response = HttpResponse & CancelOperation500Properties; // @public (undocumented) export interface CancelOperation503Properties { @@ -110,8 +110,8 @@ export interface CancelOperation503Properties { status: 503; } -// @public (undocumented) -export type CancelOperation503Response = CancelOperation503Properties & HttpResponse; +// @public +export type CancelOperation503Response = HttpResponse & CancelOperation503Properties; // @public (undocumented) export type CancelOperationParameters = RequestParameters; @@ -143,21 +143,21 @@ export interface DocumentStatusResponse { } // @public (undocumented) -export type DocumentTranslationClient = Client & { +export type DocumentTranslator = Client & { path: Routes; }; // @public (undocumented) -export interface DocumentTranslationFactory { +function DocumentTranslator_2(endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslator; + +export default DocumentTranslator_2; + +// @public (undocumented) +export interface DocumentTranslatorFactory { // (undocumented) (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; } -// @public (undocumented) -function DocumentTranslator(endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslationClient; - -export default DocumentTranslator; - // @public (undocumented) export type ErrorCodeV2 = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "ResourceNotFound" | "Unauthorized" | "RequestRateTooHigh"; @@ -203,12 +203,12 @@ export interface GetDocumentFormats200Properties { // (undocumented) body: FileFormatListResult; // (undocumented) - headers: GetDocumentFormats200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetDocumentFormats200Headers; // (undocumented) status: 200; } -// @public (undocumented) +// @public export type GetDocumentFormats200Response = HttpResponse & GetDocumentFormats200Properties; // @public (undocumented) @@ -219,8 +219,8 @@ export interface GetDocumentFormats429Properties { status: 429; } -// @public (undocumented) -export type GetDocumentFormats429Response = GetDocumentFormats429Properties & HttpResponse; +// @public +export type GetDocumentFormats429Response = HttpResponse & GetDocumentFormats429Properties; // @public (undocumented) export interface GetDocumentFormats500Properties { @@ -230,8 +230,8 @@ export interface GetDocumentFormats500Properties { status: 500; } -// @public (undocumented) -export type GetDocumentFormats500Response = GetDocumentFormats500Properties & HttpResponse; +// @public +export type GetDocumentFormats500Response = HttpResponse & GetDocumentFormats500Properties; // @public (undocumented) export interface GetDocumentFormats503Properties { @@ -241,8 +241,8 @@ export interface GetDocumentFormats503Properties { status: 503; } -// @public (undocumented) -export type GetDocumentFormats503Response = GetDocumentFormats503Properties & HttpResponse; +// @public +export type GetDocumentFormats503Response = HttpResponse & GetDocumentFormats503Properties; // @public (undocumented) export type GetDocumentFormatsParameters = RequestParameters; @@ -263,13 +263,13 @@ export interface GetDocumentStatus200Properties { // (undocumented) body: DocumentStatusDetail; // (undocumented) - headers: GetDocumentStatus200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetDocumentStatus200Headers; // (undocumented) status: 200; } -// @public (undocumented) -export type GetDocumentStatus200Response = GetDocumentStatus200Properties & HttpResponse; +// @public +export type GetDocumentStatus200Response = HttpResponse & GetDocumentStatus200Properties; // @public (undocumented) export interface GetDocumentStatus401Properties { @@ -279,8 +279,8 @@ export interface GetDocumentStatus401Properties { status: 401; } -// @public (undocumented) -export type GetDocumentStatus401Response = GetDocumentStatus401Properties & HttpResponse; +// @public +export type GetDocumentStatus401Response = HttpResponse & GetDocumentStatus401Properties; // @public (undocumented) export interface GetDocumentStatus404Properties { @@ -290,8 +290,8 @@ export interface GetDocumentStatus404Properties { status: 404; } -// @public (undocumented) -export type GetDocumentStatus404Response = GetDocumentStatus404Properties & HttpResponse; +// @public +export type GetDocumentStatus404Response = HttpResponse & GetDocumentStatus404Properties; // @public (undocumented) export interface GetDocumentStatus429Properties { @@ -301,8 +301,8 @@ export interface GetDocumentStatus429Properties { status: 429; } -// @public (undocumented) -export type GetDocumentStatus429Response = GetDocumentStatus429Properties & HttpResponse; +// @public +export type GetDocumentStatus429Response = HttpResponse & GetDocumentStatus429Properties; // @public (undocumented) export interface GetDocumentStatus500Properties { @@ -312,8 +312,8 @@ export interface GetDocumentStatus500Properties { status: 500; } -// @public (undocumented) -export type GetDocumentStatus500Response = GetDocumentStatus500Properties & HttpResponse; +// @public +export type GetDocumentStatus500Response = HttpResponse & GetDocumentStatus500Properties; // @public (undocumented) export interface GetDocumentStatus503Properties { @@ -323,8 +323,8 @@ export interface GetDocumentStatus503Properties { status: 503; } -// @public (undocumented) -export type GetDocumentStatus503Response = GetDocumentStatus503Properties & HttpResponse; +// @public +export type GetDocumentStatus503Response = HttpResponse & GetDocumentStatus503Properties; // @public (undocumented) export type GetDocumentStatusParameters = RequestParameters; @@ -344,13 +344,13 @@ export interface GetDocumentStorageSource200Properties { // (undocumented) body: StorageSourceListResult; // (undocumented) - headers: GetDocumentStorageSource200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetDocumentStorageSource200Headers; // (undocumented) status: 200; } -// @public (undocumented) -export type GetDocumentStorageSource200Response = GetDocumentStorageSource200Properties & HttpResponse; +// @public +export type GetDocumentStorageSource200Response = HttpResponse & GetDocumentStorageSource200Properties; // @public (undocumented) export interface GetDocumentStorageSource429Properties { @@ -360,8 +360,8 @@ export interface GetDocumentStorageSource429Properties { status: 429; } -// @public (undocumented) -export type GetDocumentStorageSource429Response = GetDocumentStorageSource429Properties & HttpResponse; +// @public +export type GetDocumentStorageSource429Response = HttpResponse & GetDocumentStorageSource429Properties; // @public (undocumented) export interface GetDocumentStorageSource500Properties { @@ -371,8 +371,8 @@ export interface GetDocumentStorageSource500Properties { status: 500; } -// @public (undocumented) -export type GetDocumentStorageSource500Response = GetDocumentStorageSource500Properties & HttpResponse; +// @public +export type GetDocumentStorageSource500Response = HttpResponse & GetDocumentStorageSource500Properties; // @public (undocumented) export interface GetDocumentStorageSource503Properties { @@ -382,8 +382,8 @@ export interface GetDocumentStorageSource503Properties { status: 503; } -// @public (undocumented) -export type GetDocumentStorageSource503Response = GetDocumentStorageSource503Properties & HttpResponse; +// @public +export type GetDocumentStorageSource503Response = HttpResponse & GetDocumentStorageSource503Properties; // @public (undocumented) export type GetDocumentStorageSourceParameters = RequestParameters; @@ -403,13 +403,13 @@ export interface GetGlossaryFormats200Properties { // (undocumented) body: FileFormatListResult; // (undocumented) - headers: GetGlossaryFormats200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetGlossaryFormats200Headers; // (undocumented) status: 200; } -// @public (undocumented) -export type GetGlossaryFormats200Response = GetGlossaryFormats200Properties & HttpResponse; +// @public +export type GetGlossaryFormats200Response = HttpResponse & GetGlossaryFormats200Properties; // @public (undocumented) export interface GetGlossaryFormats429Properties { @@ -419,8 +419,8 @@ export interface GetGlossaryFormats429Properties { status: 429; } -// @public (undocumented) -export type GetGlossaryFormats429Response = GetGlossaryFormats429Properties & HttpResponse; +// @public +export type GetGlossaryFormats429Response = HttpResponse & GetGlossaryFormats429Properties; // @public (undocumented) export interface GetGlossaryFormats500Properties { @@ -430,8 +430,8 @@ export interface GetGlossaryFormats500Properties { status: 500; } -// @public (undocumented) -export type GetGlossaryFormats500Response = GetGlossaryFormats500Properties & HttpResponse; +// @public +export type GetGlossaryFormats500Response = HttpResponse & GetGlossaryFormats500Properties; // @public (undocumented) export interface GetGlossaryFormats503Properties { @@ -441,8 +441,8 @@ export interface GetGlossaryFormats503Properties { status: 503; } -// @public (undocumented) -export type GetGlossaryFormats503Response = GetGlossaryFormats503Properties & HttpResponse; +// @public +export type GetGlossaryFormats503Response = HttpResponse & GetGlossaryFormats503Properties; // @public (undocumented) export type GetGlossaryFormatsParameters = RequestParameters; @@ -463,13 +463,13 @@ export interface GetOperationDocumentsStatus200Properties { // (undocumented) body: DocumentStatusResponse; // (undocumented) - headers: GetOperationDocumentsStatus200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetOperationDocumentsStatus200Headers; // (undocumented) status: 200; } -// @public (undocumented) -export type GetOperationDocumentsStatus200Response = GetOperationDocumentsStatus200Properties & HttpResponse; +// @public +export type GetOperationDocumentsStatus200Response = HttpResponse & GetOperationDocumentsStatus200Properties; // @public (undocumented) export interface GetOperationDocumentsStatus400Properties { @@ -479,8 +479,8 @@ export interface GetOperationDocumentsStatus400Properties { status: 400; } -// @public (undocumented) -export type GetOperationDocumentsStatus400Response = GetOperationDocumentsStatus400Properties & HttpResponse; +// @public +export type GetOperationDocumentsStatus400Response = HttpResponse & GetOperationDocumentsStatus400Properties; // @public (undocumented) export interface GetOperationDocumentsStatus401Properties { @@ -490,8 +490,8 @@ export interface GetOperationDocumentsStatus401Properties { status: 401; } -// @public (undocumented) -export type GetOperationDocumentsStatus401Response = GetOperationDocumentsStatus401Properties & HttpResponse; +// @public +export type GetOperationDocumentsStatus401Response = HttpResponse & GetOperationDocumentsStatus401Properties; // @public (undocumented) export interface GetOperationDocumentsStatus404Properties { @@ -501,8 +501,8 @@ export interface GetOperationDocumentsStatus404Properties { status: 404; } -// @public (undocumented) -export type GetOperationDocumentsStatus404Response = GetOperationDocumentsStatus404Properties & HttpResponse; +// @public +export type GetOperationDocumentsStatus404Response = HttpResponse & GetOperationDocumentsStatus404Properties; // @public (undocumented) export interface GetOperationDocumentsStatus429Properties { @@ -512,8 +512,8 @@ export interface GetOperationDocumentsStatus429Properties { status: 429; } -// @public (undocumented) -export type GetOperationDocumentsStatus429Response = GetOperationDocumentsStatus429Properties & HttpResponse; +// @public +export type GetOperationDocumentsStatus429Response = HttpResponse & GetOperationDocumentsStatus429Properties; // @public (undocumented) export interface GetOperationDocumentsStatus500Properties { @@ -523,8 +523,8 @@ export interface GetOperationDocumentsStatus500Properties { status: 500; } -// @public (undocumented) -export type GetOperationDocumentsStatus500Response = GetOperationDocumentsStatus500Properties & HttpResponse; +// @public +export type GetOperationDocumentsStatus500Response = HttpResponse & GetOperationDocumentsStatus500Properties; // @public (undocumented) export interface GetOperationDocumentsStatus503Properties { @@ -534,8 +534,8 @@ export interface GetOperationDocumentsStatus503Properties { status: 503; } -// @public (undocumented) -export type GetOperationDocumentsStatus503Response = GetOperationDocumentsStatus503Properties & HttpResponse; +// @public +export type GetOperationDocumentsStatus503Response = HttpResponse & GetOperationDocumentsStatus503Properties; // @public (undocumented) export type GetOperationDocumentsStatusParameters = RequestParameters & GetOperationDocumentsStatusQueryParam; @@ -575,13 +575,13 @@ export interface GetOperations200Properties { // (undocumented) body: BatchStatusResponse; // (undocumented) - headers: GetOperations200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetOperations200Headers; // (undocumented) status: 200; } -// @public (undocumented) -export type GetOperations200Response = GetOperations200Properties & HttpResponse; +// @public +export type GetOperations200Response = HttpResponse & GetOperations200Properties; // @public (undocumented) export interface GetOperations400Properties { @@ -591,8 +591,8 @@ export interface GetOperations400Properties { status: 400; } -// @public (undocumented) -export type GetOperations400Response = GetOperations400Properties & HttpResponse; +// @public +export type GetOperations400Response = HttpResponse & GetOperations400Properties; // @public (undocumented) export interface GetOperations401Properties { @@ -602,8 +602,8 @@ export interface GetOperations401Properties { status: 401; } -// @public (undocumented) -export type GetOperations401Response = GetOperations401Properties & HttpResponse; +// @public +export type GetOperations401Response = HttpResponse & GetOperations401Properties; // @public (undocumented) export interface GetOperations429Properties { @@ -613,8 +613,8 @@ export interface GetOperations429Properties { status: 429; } -// @public (undocumented) -export type GetOperations429Response = GetOperations429Properties & HttpResponse; +// @public +export type GetOperations429Response = HttpResponse & GetOperations429Properties; // @public (undocumented) export interface GetOperations500Properties { @@ -624,8 +624,8 @@ export interface GetOperations500Properties { status: 500; } -// @public (undocumented) -export type GetOperations500Response = GetOperations500Properties & HttpResponse; +// @public +export type GetOperations500Response = HttpResponse & GetOperations500Properties; // @public (undocumented) export interface GetOperations503Properties { @@ -635,8 +635,8 @@ export interface GetOperations503Properties { status: 503; } -// @public (undocumented) -export type GetOperations503Response = GetOperations503Properties & HttpResponse; +// @public +export type GetOperations503Response = HttpResponse & GetOperations503Properties; // @public (undocumented) export type GetOperationsParameters = RequestParameters & GetOperationsQueryParam; @@ -670,13 +670,13 @@ export interface GetOperationStatus200Properties { // (undocumented) body: BatchStatusDetail; // (undocumented) - headers: GetOperationStatus200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetOperationStatus200Headers; // (undocumented) status: 200; } -// @public (undocumented) -export type GetOperationStatus200Response = GetOperationStatus200Properties & HttpResponse; +// @public +export type GetOperationStatus200Response = HttpResponse & GetOperationStatus200Properties; // @public (undocumented) export interface GetOperationStatus401Properties { @@ -686,8 +686,8 @@ export interface GetOperationStatus401Properties { status: 401; } -// @public (undocumented) -export type GetOperationStatus401Response = GetOperationStatus401Properties & HttpResponse; +// @public +export type GetOperationStatus401Response = HttpResponse & GetOperationStatus401Properties; // @public (undocumented) export interface GetOperationStatus404Properties { @@ -697,8 +697,8 @@ export interface GetOperationStatus404Properties { status: 404; } -// @public (undocumented) -export type GetOperationStatus404Response = GetOperationStatus404Properties & HttpResponse; +// @public +export type GetOperationStatus404Response = HttpResponse & GetOperationStatus404Properties; // @public (undocumented) export interface GetOperationStatus429Properties { @@ -708,8 +708,8 @@ export interface GetOperationStatus429Properties { status: 429; } -// @public (undocumented) -export type GetOperationStatus429Response = GetOperationStatus429Properties & HttpResponse; +// @public +export type GetOperationStatus429Response = HttpResponse & GetOperationStatus429Properties; // @public (undocumented) export interface GetOperationStatus500Properties { @@ -719,8 +719,8 @@ export interface GetOperationStatus500Properties { status: 500; } -// @public (undocumented) -export type GetOperationStatus500Response = GetOperationStatus500Properties & HttpResponse; +// @public +export type GetOperationStatus500Response = HttpResponse & GetOperationStatus500Properties; // @public (undocumented) export interface GetOperationStatus503Properties { @@ -730,8 +730,8 @@ export interface GetOperationStatus503Properties { status: 503; } -// @public (undocumented) -export type GetOperationStatus503Response = GetOperationStatus503Properties & HttpResponse; +// @public +export type GetOperationStatus503Response = HttpResponse & GetOperationStatus503Properties; // @public (undocumented) export type GetOperationStatusParameters = RequestParameters; @@ -754,19 +754,12 @@ export interface InnerErrorV2 { // @public (undocumented) export interface Routes { - // (undocumented) (path: "/batches"): GetOperations; - // (undocumented) (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; - // (undocumented) (path: "/batches/{id}", id: string): CancelOperation; - // (undocumented) (path: "/batches/{id}/documents", id: string): GetOperationDocumentsStatus; - // (undocumented) (path: "/documents/formats"): GetDocumentFormats; - // (undocumented) (path: "/glossaries/formats"): GetGlossaryFormats; - // (undocumented) (path: "/storagesources"): GetDocumentStorageSource; } @@ -812,13 +805,13 @@ export interface SubmitBatchRequest202Headers { // @public (undocumented) export interface SubmitBatchRequest202Properties { // (undocumented) - headers: SubmitBatchRequest202Headers & RawHttpHeaders; + headers: RawHttpHeaders & SubmitBatchRequest202Headers; // (undocumented) status: 202; } -// @public (undocumented) -export type SubmitBatchRequest202Response = SubmitBatchRequest202Properties & HttpResponse; +// @public +export type SubmitBatchRequest202Response = HttpResponse & SubmitBatchRequest202Properties; // @public (undocumented) export interface SubmitBatchRequest400Properties { @@ -828,8 +821,8 @@ export interface SubmitBatchRequest400Properties { status: 400; } -// @public (undocumented) -export type SubmitBatchRequest400Response = SubmitBatchRequest400Properties & HttpResponse; +// @public +export type SubmitBatchRequest400Response = HttpResponse & SubmitBatchRequest400Properties; // @public (undocumented) export interface SubmitBatchRequest401Properties { @@ -839,8 +832,8 @@ export interface SubmitBatchRequest401Properties { status: 401; } -// @public (undocumented) -export type SubmitBatchRequest401Response = SubmitBatchRequest401Properties & HttpResponse; +// @public +export type SubmitBatchRequest401Response = HttpResponse & SubmitBatchRequest401Properties; // @public (undocumented) export interface SubmitBatchRequest429Properties { @@ -850,8 +843,8 @@ export interface SubmitBatchRequest429Properties { status: 429; } -// @public (undocumented) -export type SubmitBatchRequest429Response = SubmitBatchRequest429Properties & HttpResponse; +// @public +export type SubmitBatchRequest429Response = HttpResponse & SubmitBatchRequest429Properties; // @public (undocumented) export interface SubmitBatchRequest500Properties { @@ -861,8 +854,8 @@ export interface SubmitBatchRequest500Properties { status: 500; } -// @public (undocumented) -export type SubmitBatchRequest500Response = SubmitBatchRequest500Properties & HttpResponse; +// @public +export type SubmitBatchRequest500Response = HttpResponse & SubmitBatchRequest500Properties; // @public (undocumented) export interface SubmitBatchRequest503Properties { @@ -872,8 +865,8 @@ export interface SubmitBatchRequest503Properties { status: 503; } -// @public (undocumented) -export type SubmitBatchRequest503Response = SubmitBatchRequest503Properties & HttpResponse; +// @public +export type SubmitBatchRequest503Response = HttpResponse & SubmitBatchRequest503Properties; // @public (undocumented) export interface SubmitBatchRequestBodyParam { diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index 996a180082db..2f0c82017b16 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -249,20 +249,27 @@ export interface GetDocumentStorageSource { } export interface Routes { + /** Resource for '/batches' has methods for the following verbs: post, get */ (path: "/batches"): GetOperations; + /** Resource for '/batches/{id}/documents/{documentId}' has methods for the following verbs: get */ (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; + /** Resource for '/batches/{id}' has methods for the following verbs: get, delete */ (path: "/batches/{id}", id: string): CancelOperation; + /** Resource for '/batches/{id}/documents' has methods for the following verbs: get */ (path: "/batches/{id}/documents", id: string): GetOperationDocumentsStatus; + /** Resource for '/documents/formats' has methods for the following verbs: get */ (path: "/documents/formats"): GetDocumentFormats; + /** Resource for '/glossaries/formats' has methods for the following verbs: get */ (path: "/glossaries/formats"): GetGlossaryFormats; + /** Resource for '/storagesources' has methods for the following verbs: get */ (path: "/storagesources"): GetDocumentStorageSource; } -export type DocumentTranslationClient = Client & { +export type DocumentTranslator = Client & { path: Routes; }; -export interface DocumentTranslationFactory { +export interface DocumentTranslatorFactory { (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; } @@ -270,8 +277,10 @@ export default function DocumentTranslator( endpoint: string, credentials: TokenCredential | KeyCredential, options: ClientOptions = {} -): DocumentTranslationClient { - const baseUrl = options.baseUrl || `${endpoint}/translator/text/batch/v1.0-preview.1`; +): DocumentTranslator { + const baseUrl = + options.baseUrl || + "{endpoint}/translator/text/batch/v1.0-preview.1".replace(/{endpoint}/g, endpoint); options = { ...options, credentials: { @@ -280,5 +289,5 @@ export default function DocumentTranslator( } }; - return getClient(baseUrl, credentials, options) as DocumentTranslationClient; + return getClient(baseUrl, credentials, options) as DocumentTranslator; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts index 9b8d5049f6eb..fbe1ad5a5f7f 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts @@ -15,42 +15,108 @@ export interface SubmitBatchRequest202Headers { "operation-location"?: string; } -export type SubmitBatchRequest202Response = SubmitBatchRequest202Properties & HttpResponse; +/** + * Use this API to submit a bulk (batch) translation request to the Document Translation service. + * Each request can contain multiple documents and must contain a source and destination container for each document. + * + * The prefix and suffix filter (if supplied) are used to filter folders. The prefix is applied to the subpath after the container name. + * + * Glossaries / Translation memory can be included in the request and are applied by the service when the document is translated. + * + * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. + * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. + */ +export type SubmitBatchRequest202Response = HttpResponse & SubmitBatchRequest202Properties; export interface SubmitBatchRequest202Properties { status: 202; - headers: SubmitBatchRequest202Headers & RawHttpHeaders; -} - -export type SubmitBatchRequest400Response = SubmitBatchRequest400Properties & HttpResponse; + headers: RawHttpHeaders & SubmitBatchRequest202Headers; +} + +/** + * Use this API to submit a bulk (batch) translation request to the Document Translation service. + * Each request can contain multiple documents and must contain a source and destination container for each document. + * + * The prefix and suffix filter (if supplied) are used to filter folders. The prefix is applied to the subpath after the container name. + * + * Glossaries / Translation memory can be included in the request and are applied by the service when the document is translated. + * + * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. + * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. + */ +export type SubmitBatchRequest400Response = HttpResponse & SubmitBatchRequest400Properties; export interface SubmitBatchRequest400Properties { status: 400; body: ErrorResponseV2; } -export type SubmitBatchRequest401Response = SubmitBatchRequest401Properties & HttpResponse; +/** + * Use this API to submit a bulk (batch) translation request to the Document Translation service. + * Each request can contain multiple documents and must contain a source and destination container for each document. + * + * The prefix and suffix filter (if supplied) are used to filter folders. The prefix is applied to the subpath after the container name. + * + * Glossaries / Translation memory can be included in the request and are applied by the service when the document is translated. + * + * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. + * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. + */ +export type SubmitBatchRequest401Response = HttpResponse & SubmitBatchRequest401Properties; export interface SubmitBatchRequest401Properties { status: 401; body: ErrorResponseV2; } -export type SubmitBatchRequest429Response = SubmitBatchRequest429Properties & HttpResponse; +/** + * Use this API to submit a bulk (batch) translation request to the Document Translation service. + * Each request can contain multiple documents and must contain a source and destination container for each document. + * + * The prefix and suffix filter (if supplied) are used to filter folders. The prefix is applied to the subpath after the container name. + * + * Glossaries / Translation memory can be included in the request and are applied by the service when the document is translated. + * + * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. + * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. + */ +export type SubmitBatchRequest429Response = HttpResponse & SubmitBatchRequest429Properties; export interface SubmitBatchRequest429Properties { status: 429; body: ErrorResponseV2; } -export type SubmitBatchRequest500Response = SubmitBatchRequest500Properties & HttpResponse; +/** + * Use this API to submit a bulk (batch) translation request to the Document Translation service. + * Each request can contain multiple documents and must contain a source and destination container for each document. + * + * The prefix and suffix filter (if supplied) are used to filter folders. The prefix is applied to the subpath after the container name. + * + * Glossaries / Translation memory can be included in the request and are applied by the service when the document is translated. + * + * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. + * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. + */ +export type SubmitBatchRequest500Response = HttpResponse & SubmitBatchRequest500Properties; export interface SubmitBatchRequest500Properties { status: 500; body: ErrorResponseV2; } -export type SubmitBatchRequest503Response = SubmitBatchRequest503Properties & HttpResponse; +/** + * Use this API to submit a bulk (batch) translation request to the Document Translation service. + * Each request can contain multiple documents and must contain a source and destination container for each document. + * + * The prefix and suffix filter (if supplied) are used to filter folders. The prefix is applied to the subpath after the container name. + * + * Glossaries / Translation memory can be included in the request and are applied by the service when the document is translated. + * + * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. + * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. + */ +export type SubmitBatchRequest503Response = HttpResponse & SubmitBatchRequest503Properties; export interface SubmitBatchRequest503Properties { status: 503; @@ -64,43 +130,193 @@ export interface GetOperations200Headers { etag?: string; } -export type GetOperations200Response = GetOperations200Properties & HttpResponse; +/** + * Returns a list of batch requests submitted and the status for each request. + * This list only contains batch requests submitted by the user (based on the resource). + * + * If the number of requests exceeds our paging limit, server-side paging is used. Paginated responses indicate a partial result and include a continuation token in the response. + * The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled operations. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * The server honors the values specified by the client. However, clients must be prepared to handle responses that contain a different page size or contain a continuation token. + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperations200Response = HttpResponse & GetOperations200Properties; export interface GetOperations200Properties { status: 200; body: BatchStatusResponse; - headers: GetOperations200Headers & RawHttpHeaders; -} - -export type GetOperations400Response = GetOperations400Properties & HttpResponse; + headers: RawHttpHeaders & GetOperations200Headers; +} + +/** + * Returns a list of batch requests submitted and the status for each request. + * This list only contains batch requests submitted by the user (based on the resource). + * + * If the number of requests exceeds our paging limit, server-side paging is used. Paginated responses indicate a partial result and include a continuation token in the response. + * The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled operations. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * The server honors the values specified by the client. However, clients must be prepared to handle responses that contain a different page size or contain a continuation token. + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperations400Response = HttpResponse & GetOperations400Properties; export interface GetOperations400Properties { status: 400; body: ErrorResponseV2; } -export type GetOperations401Response = GetOperations401Properties & HttpResponse; +/** + * Returns a list of batch requests submitted and the status for each request. + * This list only contains batch requests submitted by the user (based on the resource). + * + * If the number of requests exceeds our paging limit, server-side paging is used. Paginated responses indicate a partial result and include a continuation token in the response. + * The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled operations. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * The server honors the values specified by the client. However, clients must be prepared to handle responses that contain a different page size or contain a continuation token. + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperations401Response = HttpResponse & GetOperations401Properties; export interface GetOperations401Properties { status: 401; body: ErrorResponseV2; } -export type GetOperations429Response = GetOperations429Properties & HttpResponse; +/** + * Returns a list of batch requests submitted and the status for each request. + * This list only contains batch requests submitted by the user (based on the resource). + * + * If the number of requests exceeds our paging limit, server-side paging is used. Paginated responses indicate a partial result and include a continuation token in the response. + * The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled operations. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * The server honors the values specified by the client. However, clients must be prepared to handle responses that contain a different page size or contain a continuation token. + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperations429Response = HttpResponse & GetOperations429Properties; export interface GetOperations429Properties { status: 429; body: ErrorResponseV2; } -export type GetOperations500Response = GetOperations500Properties & HttpResponse; +/** + * Returns a list of batch requests submitted and the status for each request. + * This list only contains batch requests submitted by the user (based on the resource). + * + * If the number of requests exceeds our paging limit, server-side paging is used. Paginated responses indicate a partial result and include a continuation token in the response. + * The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled operations. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * The server honors the values specified by the client. However, clients must be prepared to handle responses that contain a different page size or contain a continuation token. + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperations500Response = HttpResponse & GetOperations500Properties; export interface GetOperations500Properties { status: 500; body: ErrorResponseV2; } -export type GetOperations503Response = GetOperations503Properties & HttpResponse; +/** + * Returns a list of batch requests submitted and the status for each request. + * This list only contains batch requests submitted by the user (based on the resource). + * + * If the number of requests exceeds our paging limit, server-side paging is used. Paginated responses indicate a partial result and include a continuation token in the response. + * The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled operations. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * The server honors the values specified by the client. However, clients must be prepared to handle responses that contain a different page size or contain a continuation token. + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperations503Response = HttpResponse & GetOperations503Properties; export interface GetOperations503Properties { status: 503; @@ -114,43 +330,49 @@ export interface GetDocumentStatus200Headers { etag?: string; } -export type GetDocumentStatus200Response = GetDocumentStatus200Properties & HttpResponse; +/** Returns the translation status for a specific document based on the request Id and document Id. */ +export type GetDocumentStatus200Response = HttpResponse & GetDocumentStatus200Properties; export interface GetDocumentStatus200Properties { status: 200; body: DocumentStatusDetail; - headers: GetDocumentStatus200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetDocumentStatus200Headers; } -export type GetDocumentStatus401Response = GetDocumentStatus401Properties & HttpResponse; +/** Returns the translation status for a specific document based on the request Id and document Id. */ +export type GetDocumentStatus401Response = HttpResponse & GetDocumentStatus401Properties; export interface GetDocumentStatus401Properties { status: 401; body: ErrorResponseV2; } -export type GetDocumentStatus404Response = GetDocumentStatus404Properties & HttpResponse; +/** Returns the translation status for a specific document based on the request Id and document Id. */ +export type GetDocumentStatus404Response = HttpResponse & GetDocumentStatus404Properties; export interface GetDocumentStatus404Properties { status: 404; body: ErrorResponseV2; } -export type GetDocumentStatus429Response = GetDocumentStatus429Properties & HttpResponse; +/** Returns the translation status for a specific document based on the request Id and document Id. */ +export type GetDocumentStatus429Response = HttpResponse & GetDocumentStatus429Properties; export interface GetDocumentStatus429Properties { status: 429; body: ErrorResponseV2; } -export type GetDocumentStatus500Response = GetDocumentStatus500Properties & HttpResponse; +/** Returns the translation status for a specific document based on the request Id and document Id. */ +export type GetDocumentStatus500Response = HttpResponse & GetDocumentStatus500Properties; export interface GetDocumentStatus500Properties { status: 500; body: ErrorResponseV2; } -export type GetDocumentStatus503Response = GetDocumentStatus503Properties & HttpResponse; +/** Returns the translation status for a specific document based on the request Id and document Id. */ +export type GetDocumentStatus503Response = HttpResponse & GetDocumentStatus503Properties; export interface GetDocumentStatus503Properties { status: 503; @@ -164,85 +386,151 @@ export interface GetOperationStatus200Headers { etag?: string; } -export type GetOperationStatus200Response = GetOperationStatus200Properties & HttpResponse; +/** + * Returns the status for a document translation request. + * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. + */ +export type GetOperationStatus200Response = HttpResponse & GetOperationStatus200Properties; export interface GetOperationStatus200Properties { status: 200; body: BatchStatusDetail; - headers: GetOperationStatus200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetOperationStatus200Headers; } -export type GetOperationStatus401Response = GetOperationStatus401Properties & HttpResponse; +/** + * Returns the status for a document translation request. + * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. + */ +export type GetOperationStatus401Response = HttpResponse & GetOperationStatus401Properties; export interface GetOperationStatus401Properties { status: 401; body: ErrorResponseV2; } -export type GetOperationStatus404Response = GetOperationStatus404Properties & HttpResponse; +/** + * Returns the status for a document translation request. + * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. + */ +export type GetOperationStatus404Response = HttpResponse & GetOperationStatus404Properties; export interface GetOperationStatus404Properties { status: 404; body: ErrorResponseV2; } -export type GetOperationStatus429Response = GetOperationStatus429Properties & HttpResponse; +/** + * Returns the status for a document translation request. + * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. + */ +export type GetOperationStatus429Response = HttpResponse & GetOperationStatus429Properties; export interface GetOperationStatus429Properties { status: 429; body: ErrorResponseV2; } -export type GetOperationStatus500Response = GetOperationStatus500Properties & HttpResponse; +/** + * Returns the status for a document translation request. + * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. + */ +export type GetOperationStatus500Response = HttpResponse & GetOperationStatus500Properties; export interface GetOperationStatus500Properties { status: 500; body: ErrorResponseV2; } -export type GetOperationStatus503Response = GetOperationStatus503Properties & HttpResponse; +/** + * Returns the status for a document translation request. + * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. + */ +export type GetOperationStatus503Response = HttpResponse & GetOperationStatus503Properties; export interface GetOperationStatus503Properties { status: 503; body: ErrorResponseV2; } -export type CancelOperation200Response = CancelOperation200Properties & HttpResponse; +/** + * Cancel a currently processing or queued operation. + * Cancel a currently processing or queued operation. + * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * All documents that have completed translation will not be cancelled and will be charged. + * All pending documents will be cancelled if possible. + */ +export type CancelOperation200Response = HttpResponse & CancelOperation200Properties; export interface CancelOperation200Properties { status: 200; body: BatchStatusDetail; } -export type CancelOperation401Response = CancelOperation401Properties & HttpResponse; +/** + * Cancel a currently processing or queued operation. + * Cancel a currently processing or queued operation. + * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * All documents that have completed translation will not be cancelled and will be charged. + * All pending documents will be cancelled if possible. + */ +export type CancelOperation401Response = HttpResponse & CancelOperation401Properties; export interface CancelOperation401Properties { status: 401; body: ErrorResponseV2; } -export type CancelOperation404Response = CancelOperation404Properties & HttpResponse; +/** + * Cancel a currently processing or queued operation. + * Cancel a currently processing or queued operation. + * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * All documents that have completed translation will not be cancelled and will be charged. + * All pending documents will be cancelled if possible. + */ +export type CancelOperation404Response = HttpResponse & CancelOperation404Properties; export interface CancelOperation404Properties { status: 404; body: ErrorResponseV2; } -export type CancelOperation429Response = CancelOperation429Properties & HttpResponse; +/** + * Cancel a currently processing or queued operation. + * Cancel a currently processing or queued operation. + * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * All documents that have completed translation will not be cancelled and will be charged. + * All pending documents will be cancelled if possible. + */ +export type CancelOperation429Response = HttpResponse & CancelOperation429Properties; export interface CancelOperation429Properties { status: 429; body: ErrorResponseV2; } -export type CancelOperation500Response = CancelOperation500Properties & HttpResponse; +/** + * Cancel a currently processing or queued operation. + * Cancel a currently processing or queued operation. + * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * All documents that have completed translation will not be cancelled and will be charged. + * All pending documents will be cancelled if possible. + */ +export type CancelOperation500Response = HttpResponse & CancelOperation500Properties; export interface CancelOperation500Properties { status: 500; body: ErrorResponseV2; } -export type CancelOperation503Response = CancelOperation503Properties & HttpResponse; +/** + * Cancel a currently processing or queued operation. + * Cancel a currently processing or queued operation. + * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * All documents that have completed translation will not be cancelled and will be charged. + * All pending documents will be cancelled if possible. + */ +export type CancelOperation503Response = HttpResponse & CancelOperation503Properties; export interface CancelOperation503Properties { status: 503; @@ -256,57 +544,211 @@ export interface GetOperationDocumentsStatus200Headers { etag?: string; } -export type GetOperationDocumentsStatus200Response = GetOperationDocumentsStatus200Properties & - HttpResponse; +/** + * Returns the status for all documents in a batch document translation request. + * + * If the number of documents in the response exceeds our paging limit, server-side paging is used. + * Paginated responses indicate a partial result and include a continuation token in the response. The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled documents. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperationDocumentsStatus200Response = HttpResponse & + GetOperationDocumentsStatus200Properties; export interface GetOperationDocumentsStatus200Properties { status: 200; body: DocumentStatusResponse; - headers: GetOperationDocumentsStatus200Headers & RawHttpHeaders; -} - -export type GetOperationDocumentsStatus400Response = GetOperationDocumentsStatus400Properties & - HttpResponse; + headers: RawHttpHeaders & GetOperationDocumentsStatus200Headers; +} + +/** + * Returns the status for all documents in a batch document translation request. + * + * If the number of documents in the response exceeds our paging limit, server-side paging is used. + * Paginated responses indicate a partial result and include a continuation token in the response. The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled documents. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperationDocumentsStatus400Response = HttpResponse & + GetOperationDocumentsStatus400Properties; export interface GetOperationDocumentsStatus400Properties { status: 400; body: ErrorResponseV2; } -export type GetOperationDocumentsStatus401Response = GetOperationDocumentsStatus401Properties & - HttpResponse; +/** + * Returns the status for all documents in a batch document translation request. + * + * If the number of documents in the response exceeds our paging limit, server-side paging is used. + * Paginated responses indicate a partial result and include a continuation token in the response. The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled documents. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperationDocumentsStatus401Response = HttpResponse & + GetOperationDocumentsStatus401Properties; export interface GetOperationDocumentsStatus401Properties { status: 401; body: ErrorResponseV2; } -export type GetOperationDocumentsStatus404Response = GetOperationDocumentsStatus404Properties & - HttpResponse; +/** + * Returns the status for all documents in a batch document translation request. + * + * If the number of documents in the response exceeds our paging limit, server-side paging is used. + * Paginated responses indicate a partial result and include a continuation token in the response. The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled documents. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperationDocumentsStatus404Response = HttpResponse & + GetOperationDocumentsStatus404Properties; export interface GetOperationDocumentsStatus404Properties { status: 404; body: ErrorResponseV2; } -export type GetOperationDocumentsStatus429Response = GetOperationDocumentsStatus429Properties & - HttpResponse; +/** + * Returns the status for all documents in a batch document translation request. + * + * If the number of documents in the response exceeds our paging limit, server-side paging is used. + * Paginated responses indicate a partial result and include a continuation token in the response. The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled documents. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperationDocumentsStatus429Response = HttpResponse & + GetOperationDocumentsStatus429Properties; export interface GetOperationDocumentsStatus429Properties { status: 429; body: ErrorResponseV2; } -export type GetOperationDocumentsStatus500Response = GetOperationDocumentsStatus500Properties & - HttpResponse; +/** + * Returns the status for all documents in a batch document translation request. + * + * If the number of documents in the response exceeds our paging limit, server-side paging is used. + * Paginated responses indicate a partial result and include a continuation token in the response. The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled documents. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperationDocumentsStatus500Response = HttpResponse & + GetOperationDocumentsStatus500Properties; export interface GetOperationDocumentsStatus500Properties { status: 500; body: ErrorResponseV2; } -export type GetOperationDocumentsStatus503Response = GetOperationDocumentsStatus503Properties & - HttpResponse; +/** + * Returns the status for all documents in a batch document translation request. + * + * If the number of documents in the response exceeds our paging limit, server-side paging is used. + * Paginated responses indicate a partial result and include a continuation token in the response. The absence of a continuation token means that no additional pages are available. + * + * $top, $skip and $maxpagesize query parameters can be used to specify a number of results to return and an offset for the collection. + * + * $top indicates the total number of records the user wants to be returned across all pages. + * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * + * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). + * The default sorting is descending by createdDateTimeUtc. + * Some query parameters can be used to filter the returned list (ex: "status=Succeeded,Cancelled") will only return succeeded and cancelled documents. + * createdDateTimeUtcStart and createdDateTimeUtcEnd can be used combined or separately to specify a range of datetime to filter the returned list by. + * The supported filtering query parameters are (status, ids, createdDateTimeUtcStart, createdDateTimeUtcEnd). + * + * When both $top and $skip are included, the server should first apply $skip and then $top on the collection. + * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. + * This reduces the risk of the client making assumptions about the data returned. + */ +export type GetOperationDocumentsStatus503Response = HttpResponse & + GetOperationDocumentsStatus503Properties; export interface GetOperationDocumentsStatus503Properties { status: 503; @@ -318,29 +760,45 @@ export interface GetDocumentFormats200Headers { "retry-after"?: string; } +/** + * The list of supported document formats supported by the Document Translation service. + * The list includes the common file extension, as well as the content-type if using the upload API. + */ export type GetDocumentFormats200Response = HttpResponse & GetDocumentFormats200Properties; export interface GetDocumentFormats200Properties { status: 200; body: FileFormatListResult; - headers: GetDocumentFormats200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetDocumentFormats200Headers; } -export type GetDocumentFormats429Response = GetDocumentFormats429Properties & HttpResponse; +/** + * The list of supported document formats supported by the Document Translation service. + * The list includes the common file extension, as well as the content-type if using the upload API. + */ +export type GetDocumentFormats429Response = HttpResponse & GetDocumentFormats429Properties; export interface GetDocumentFormats429Properties { status: 429; body: ErrorResponseV2; } -export type GetDocumentFormats500Response = GetDocumentFormats500Properties & HttpResponse; +/** + * The list of supported document formats supported by the Document Translation service. + * The list includes the common file extension, as well as the content-type if using the upload API. + */ +export type GetDocumentFormats500Response = HttpResponse & GetDocumentFormats500Properties; export interface GetDocumentFormats500Properties { status: 500; body: ErrorResponseV2; } -export type GetDocumentFormats503Response = GetDocumentFormats503Properties & HttpResponse; +/** + * The list of supported document formats supported by the Document Translation service. + * The list includes the common file extension, as well as the content-type if using the upload API. + */ +export type GetDocumentFormats503Response = HttpResponse & GetDocumentFormats503Properties; export interface GetDocumentFormats503Properties { status: 503; @@ -352,29 +810,45 @@ export interface GetGlossaryFormats200Headers { "retry-after"?: string; } -export type GetGlossaryFormats200Response = GetGlossaryFormats200Properties & HttpResponse; +/** + * The list of supported glossary formats supported by the Document Translation service. + * The list includes the common file extension used. + */ +export type GetGlossaryFormats200Response = HttpResponse & GetGlossaryFormats200Properties; export interface GetGlossaryFormats200Properties { status: 200; body: FileFormatListResult; - headers: GetGlossaryFormats200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetGlossaryFormats200Headers; } -export type GetGlossaryFormats429Response = GetGlossaryFormats429Properties & HttpResponse; +/** + * The list of supported glossary formats supported by the Document Translation service. + * The list includes the common file extension used. + */ +export type GetGlossaryFormats429Response = HttpResponse & GetGlossaryFormats429Properties; export interface GetGlossaryFormats429Properties { status: 429; body: ErrorResponseV2; } -export type GetGlossaryFormats500Response = GetGlossaryFormats500Properties & HttpResponse; +/** + * The list of supported glossary formats supported by the Document Translation service. + * The list includes the common file extension used. + */ +export type GetGlossaryFormats500Response = HttpResponse & GetGlossaryFormats500Properties; export interface GetGlossaryFormats500Properties { status: 500; body: ErrorResponseV2; } -export type GetGlossaryFormats503Response = GetGlossaryFormats503Properties & HttpResponse; +/** + * The list of supported glossary formats supported by the Document Translation service. + * The list includes the common file extension used. + */ +export type GetGlossaryFormats503Response = HttpResponse & GetGlossaryFormats503Properties; export interface GetGlossaryFormats503Properties { status: 503; @@ -386,33 +860,37 @@ export interface GetDocumentStorageSource200Headers { "retry-after"?: string; } -export type GetDocumentStorageSource200Response = GetDocumentStorageSource200Properties & - HttpResponse; +/** Returns a list of storage sources/options supported by the Document Translation service. */ +export type GetDocumentStorageSource200Response = HttpResponse & + GetDocumentStorageSource200Properties; export interface GetDocumentStorageSource200Properties { status: 200; body: StorageSourceListResult; - headers: GetDocumentStorageSource200Headers & RawHttpHeaders; + headers: RawHttpHeaders & GetDocumentStorageSource200Headers; } -export type GetDocumentStorageSource429Response = GetDocumentStorageSource429Properties & - HttpResponse; +/** Returns a list of storage sources/options supported by the Document Translation service. */ +export type GetDocumentStorageSource429Response = HttpResponse & + GetDocumentStorageSource429Properties; export interface GetDocumentStorageSource429Properties { status: 429; body: ErrorResponseV2; } -export type GetDocumentStorageSource500Response = GetDocumentStorageSource500Properties & - HttpResponse; +/** Returns a list of storage sources/options supported by the Document Translation service. */ +export type GetDocumentStorageSource500Response = HttpResponse & + GetDocumentStorageSource500Properties; export interface GetDocumentStorageSource500Properties { status: 500; body: ErrorResponseV2; } -export type GetDocumentStorageSource503Response = GetDocumentStorageSource503Properties & - HttpResponse; +/** Returns a list of storage sources/options supported by the Document Translation service. */ +export type GetDocumentStorageSource503Response = HttpResponse & + GetDocumentStorageSource503Properties; export interface GetDocumentStorageSource503Properties { status: 503; diff --git a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md index 73a17b444136..de382a528dba 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md @@ -5,9 +5,9 @@ ## Configuration ```yaml -package-name: "@azure-rest/ai-document-translation" -title: DocumentTranslation -description: Document translation Client +package-name: "@azure-rest/ai-document-translator" +title: DocumentTranslator +description: Document Translator Client generate-metadata: false license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ From ca6c8300d54f235272dd4ee519b8a0ace2b9452f Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 7 Apr 2021 16:16:13 +0000 Subject: [PATCH 05/37] Fix build script --- sdk/core-rest/core-client/package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core-rest/core-client/package.json b/sdk/core-rest/core-client/package.json index 29eef8749c6a..a4299566e9fd 100644 --- a/sdk/core-rest/core-client/package.json +++ b/sdk/core-rest/core-client/package.json @@ -19,7 +19,7 @@ "build:test:node": "npm run build:ts && npm run bundle:test:node", "build:ts": "tsc -p .", "build": "npm run build:ts && rollup -c 2>&1 && api-extractor run --local", - "bundle:test": "rollup -c rollup.test.config.js 2>&1", + "bundle:test": "tsc -p . && rollup -c 2>&1", "bundle:test:browser": "cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1", "bundle:test:node": "cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1", "check-format": "prettier --list-different \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", From c9ee36fa884e95f5da2949fe0ca3474b5ae14ae3 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 7 Apr 2021 18:48:53 +0000 Subject: [PATCH 06/37] Fix path check and make status code a string --- .../core-client/review/core-client.api.md | 14 +- sdk/core-rest/core-client/src/common.ts | 6 +- sdk/core-rest/core-client/src/getClient.ts | 15 +- sdk/core-rest/core-client/src/sendRequest.ts | 2 +- .../ai-document-translator-rest/package.json | 4 +- .../review/ai-document-translator.api.md | 361 ++++++------------ .../samples-dev/listFormats.ts | 4 +- .../samples-dev/translateFromBlob.ts | 8 +- .../src/documentTranslator.ts | 17 +- .../src/parameters.ts | 6 +- .../src/responses.ts | 305 +++++---------- .../ai-document-translator-rest/tsconfig.json | 6 +- sdk/documenttranslator/ci.yml | 2 +- 13 files changed, 243 insertions(+), 507 deletions(-) diff --git a/sdk/core-rest/core-client/review/core-client.api.md b/sdk/core-rest/core-client/review/core-client.api.md index 1bd5038b0bba..14113a1f0007 100644 --- a/sdk/core-rest/core-client/review/core-client.api.md +++ b/sdk/core-rest/core-client/review/core-client.api.md @@ -13,16 +13,7 @@ import { TokenCredential } from '@azure/core-auth'; // @public export interface Client { - path: (path: string, ...args: Array) => { - get: (options?: RequestParameters) => Promise; - post: (options?: RequestParameters) => Promise; - put: (options?: RequestParameters) => Promise; - patch: (options?: RequestParameters) => Promise; - delete: (options?: RequestParameters) => Promise; - head: (options?: RequestParameters) => Promise; - options: (options?: RequestParameters) => Promise; - trace: (options?: RequestParameters) => Promise; - }; + path: unknown; pathUnchecked: (path: string, ...args: Array) => { get: (options?: RequestParameters) => Promise; post: (options?: RequestParameters) => Promise; @@ -54,9 +45,10 @@ export function getClient(baseUrl: string, options?: PipelineOptions): Client; export function getClient(baseUrl: string, credentials?: TokenCredential | KeyCredential, options?: PipelineOptions): Client; // @public -export type HttpResponse = Omit & { +export type HttpResponse = Omit & { headers: RawHttpHeaders; body: unknown; + status: string; }; // @public diff --git a/sdk/core-rest/core-client/src/common.ts b/sdk/core-rest/core-client/src/common.ts index 74c4cd3a3661..690030859d54 100644 --- a/sdk/core-rest/core-client/src/common.ts +++ b/sdk/core-rest/core-client/src/common.ts @@ -14,7 +14,7 @@ export type ClientOptions = PipelineOptions & { /** * Represents the shape of an HttpResponse */ -export type HttpResponse = Omit & { +export type HttpResponse = Omit & { /** * The HTTP response headers. */ @@ -23,4 +23,8 @@ export type HttpResponse = Omit & { * Parsed body */ body: unknown; + /** + * The HTTP status code of the response. + */ + status: string; }; diff --git a/sdk/core-rest/core-client/src/getClient.ts b/sdk/core-rest/core-client/src/getClient.ts index 6252437c6047..c96d544166a7 100644 --- a/sdk/core-rest/core-client/src/getClient.ts +++ b/sdk/core-rest/core-client/src/getClient.ts @@ -19,19 +19,7 @@ export interface Client { * This method will be used to send request that would check the path to provide * strong types */ - path: ( - path: string, - ...args: Array - ) => { - get: (options?: RequestParameters) => Promise; - post: (options?: RequestParameters) => Promise; - put: (options?: RequestParameters) => Promise; - patch: (options?: RequestParameters) => Promise; - delete: (options?: RequestParameters) => Promise; - head: (options?: RequestParameters) => Promise; - options: (options?: RequestParameters) => Promise; - trace: (options?: RequestParameters) => Promise; - }; + path: unknown; /** * This method allows arbitrary paths and doesn't provide strong types */ @@ -85,7 +73,6 @@ export function getClient( } const pipeline = createDefaultPipeline(baseUrl, credentials, options); - pipeline.removePolicy({ name: "exponentialRetryPolicy" }); const client = (path: string, ...args: Array) => { return { get: (options: RequestParameters = {}): Promise => { diff --git a/sdk/core-rest/core-client/src/sendRequest.ts b/sdk/core-rest/core-client/src/sendRequest.ts index acdf9548d92f..c11fa0556ddc 100644 --- a/sdk/core-rest/core-client/src/sendRequest.ts +++ b/sdk/core-rest/core-client/src/sendRequest.ts @@ -56,7 +56,7 @@ export async function sendRequest( bodyAsText: result.bodyAsText, request, headers: rawHeaders, - status: result.status, + status: `${result.status}`, body: parsedBody, }; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/package.json b/sdk/documenttranslator/ai-document-translator-rest/package.json index f11d814fa3e3..d03366c68a45 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/package.json @@ -76,7 +76,7 @@ "unit-test:browser": "karma start --single-run", "unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"", "unit-test": "npm run unit-test:node && npm run unit-test:browser", - "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src" + "docs": "typedoc --excludePrivate --excludeExternals --out ./dist/docs ./src" }, "sideEffects": false, "autoPublish": false, @@ -98,6 +98,6 @@ "rollup": "^1.16.3", "source-map-support": "^0.5.9", "typescript": "~4.2.0", - "typedoc": "0.15.2" + "typedoc": "0.20.35" } } diff --git a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md index ce865be5e271..5ffd3279bff4 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md +++ b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md @@ -47,72 +47,54 @@ export interface CancelOperation { get(options?: GetOperationStatusParameters): Promise; } -// @public (undocumented) -export interface CancelOperation200Properties { +// @public +export interface CancelOperation200Response extends HttpResponse { // (undocumented) body: BatchStatusDetail; // (undocumented) - status: 200; + status: "200"; } // @public -export type CancelOperation200Response = HttpResponse & CancelOperation200Properties; - -// @public (undocumented) -export interface CancelOperation401Properties { +export interface CancelOperation401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 401; + status: "401"; } // @public -export type CancelOperation401Response = HttpResponse & CancelOperation401Properties; - -// @public (undocumented) -export interface CancelOperation404Properties { +export interface CancelOperation404Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 404; + status: "404"; } // @public -export type CancelOperation404Response = HttpResponse & CancelOperation404Properties; - -// @public (undocumented) -export interface CancelOperation429Properties { +export interface CancelOperation429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type CancelOperation429Response = HttpResponse & CancelOperation429Properties; - -// @public (undocumented) -export interface CancelOperation500Properties { +export interface CancelOperation500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type CancelOperation500Response = HttpResponse & CancelOperation500Properties; - -// @public (undocumented) -export interface CancelOperation503Properties { +export interface CancelOperation503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type CancelOperation503Response = HttpResponse & CancelOperation503Properties; - // @public (undocumented) export type CancelOperationParameters = RequestParameters; @@ -198,52 +180,40 @@ export interface GetDocumentFormats200Headers { "retry-after"?: string; } -// @public (undocumented) -export interface GetDocumentFormats200Properties { +// @public +export interface GetDocumentFormats200Response extends HttpResponse { // (undocumented) body: FileFormatListResult; // (undocumented) headers: RawHttpHeaders & GetDocumentFormats200Headers; // (undocumented) - status: 200; + status: "200"; } // @public -export type GetDocumentFormats200Response = HttpResponse & GetDocumentFormats200Properties; - -// @public (undocumented) -export interface GetDocumentFormats429Properties { +export interface GetDocumentFormats429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type GetDocumentFormats429Response = HttpResponse & GetDocumentFormats429Properties; - -// @public (undocumented) -export interface GetDocumentFormats500Properties { +export interface GetDocumentFormats500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type GetDocumentFormats500Response = HttpResponse & GetDocumentFormats500Properties; - -// @public (undocumented) -export interface GetDocumentFormats503Properties { +export interface GetDocumentFormats503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type GetDocumentFormats503Response = HttpResponse & GetDocumentFormats503Properties; - // @public (undocumented) export type GetDocumentFormatsParameters = RequestParameters; @@ -258,74 +228,56 @@ export interface GetDocumentStatus200Headers { etag?: string; } -// @public (undocumented) -export interface GetDocumentStatus200Properties { +// @public +export interface GetDocumentStatus200Response extends HttpResponse { // (undocumented) body: DocumentStatusDetail; // (undocumented) headers: RawHttpHeaders & GetDocumentStatus200Headers; // (undocumented) - status: 200; + status: "200"; } // @public -export type GetDocumentStatus200Response = HttpResponse & GetDocumentStatus200Properties; - -// @public (undocumented) -export interface GetDocumentStatus401Properties { +export interface GetDocumentStatus401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 401; + status: "401"; } // @public -export type GetDocumentStatus401Response = HttpResponse & GetDocumentStatus401Properties; - -// @public (undocumented) -export interface GetDocumentStatus404Properties { +export interface GetDocumentStatus404Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 404; + status: "404"; } // @public -export type GetDocumentStatus404Response = HttpResponse & GetDocumentStatus404Properties; - -// @public (undocumented) -export interface GetDocumentStatus429Properties { +export interface GetDocumentStatus429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type GetDocumentStatus429Response = HttpResponse & GetDocumentStatus429Properties; - -// @public (undocumented) -export interface GetDocumentStatus500Properties { +export interface GetDocumentStatus500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type GetDocumentStatus500Response = HttpResponse & GetDocumentStatus500Properties; - -// @public (undocumented) -export interface GetDocumentStatus503Properties { +export interface GetDocumentStatus503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type GetDocumentStatus503Response = HttpResponse & GetDocumentStatus503Properties; - // @public (undocumented) export type GetDocumentStatusParameters = RequestParameters; @@ -339,52 +291,40 @@ export interface GetDocumentStorageSource200Headers { "retry-after"?: string; } -// @public (undocumented) -export interface GetDocumentStorageSource200Properties { +// @public +export interface GetDocumentStorageSource200Response extends HttpResponse { // (undocumented) body: StorageSourceListResult; // (undocumented) headers: RawHttpHeaders & GetDocumentStorageSource200Headers; // (undocumented) - status: 200; + status: "200"; } // @public -export type GetDocumentStorageSource200Response = HttpResponse & GetDocumentStorageSource200Properties; - -// @public (undocumented) -export interface GetDocumentStorageSource429Properties { +export interface GetDocumentStorageSource429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type GetDocumentStorageSource429Response = HttpResponse & GetDocumentStorageSource429Properties; - -// @public (undocumented) -export interface GetDocumentStorageSource500Properties { +export interface GetDocumentStorageSource500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type GetDocumentStorageSource500Response = HttpResponse & GetDocumentStorageSource500Properties; - -// @public (undocumented) -export interface GetDocumentStorageSource503Properties { +export interface GetDocumentStorageSource503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type GetDocumentStorageSource503Response = HttpResponse & GetDocumentStorageSource503Properties; - // @public (undocumented) export type GetDocumentStorageSourceParameters = RequestParameters; @@ -398,52 +338,40 @@ export interface GetGlossaryFormats200Headers { "retry-after"?: string; } -// @public (undocumented) -export interface GetGlossaryFormats200Properties { +// @public +export interface GetGlossaryFormats200Response extends HttpResponse { // (undocumented) body: FileFormatListResult; // (undocumented) headers: RawHttpHeaders & GetGlossaryFormats200Headers; // (undocumented) - status: 200; + status: "200"; } // @public -export type GetGlossaryFormats200Response = HttpResponse & GetGlossaryFormats200Properties; - -// @public (undocumented) -export interface GetGlossaryFormats429Properties { +export interface GetGlossaryFormats429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type GetGlossaryFormats429Response = HttpResponse & GetGlossaryFormats429Properties; - -// @public (undocumented) -export interface GetGlossaryFormats500Properties { +export interface GetGlossaryFormats500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type GetGlossaryFormats500Response = HttpResponse & GetGlossaryFormats500Properties; - -// @public (undocumented) -export interface GetGlossaryFormats503Properties { +export interface GetGlossaryFormats503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type GetGlossaryFormats503Response = HttpResponse & GetGlossaryFormats503Properties; - // @public (undocumented) export type GetGlossaryFormatsParameters = RequestParameters; @@ -458,85 +386,64 @@ export interface GetOperationDocumentsStatus200Headers { etag?: string; } -// @public (undocumented) -export interface GetOperationDocumentsStatus200Properties { +// @public +export interface GetOperationDocumentsStatus200Response extends HttpResponse { // (undocumented) body: DocumentStatusResponse; // (undocumented) headers: RawHttpHeaders & GetOperationDocumentsStatus200Headers; // (undocumented) - status: 200; + status: "200"; } // @public -export type GetOperationDocumentsStatus200Response = HttpResponse & GetOperationDocumentsStatus200Properties; - -// @public (undocumented) -export interface GetOperationDocumentsStatus400Properties { +export interface GetOperationDocumentsStatus400Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 400; + status: "400"; } // @public -export type GetOperationDocumentsStatus400Response = HttpResponse & GetOperationDocumentsStatus400Properties; - -// @public (undocumented) -export interface GetOperationDocumentsStatus401Properties { +export interface GetOperationDocumentsStatus401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 401; + status: "401"; } // @public -export type GetOperationDocumentsStatus401Response = HttpResponse & GetOperationDocumentsStatus401Properties; - -// @public (undocumented) -export interface GetOperationDocumentsStatus404Properties { +export interface GetOperationDocumentsStatus404Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 404; + status: "404"; } // @public -export type GetOperationDocumentsStatus404Response = HttpResponse & GetOperationDocumentsStatus404Properties; - -// @public (undocumented) -export interface GetOperationDocumentsStatus429Properties { +export interface GetOperationDocumentsStatus429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type GetOperationDocumentsStatus429Response = HttpResponse & GetOperationDocumentsStatus429Properties; - -// @public (undocumented) -export interface GetOperationDocumentsStatus500Properties { +export interface GetOperationDocumentsStatus500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type GetOperationDocumentsStatus500Response = HttpResponse & GetOperationDocumentsStatus500Properties; - -// @public (undocumented) -export interface GetOperationDocumentsStatus503Properties { +export interface GetOperationDocumentsStatus503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type GetOperationDocumentsStatus503Response = HttpResponse & GetOperationDocumentsStatus503Properties; - // @public (undocumented) export type GetOperationDocumentsStatusParameters = RequestParameters & GetOperationDocumentsStatusQueryParam; @@ -570,74 +477,56 @@ export interface GetOperations200Headers { etag?: string; } -// @public (undocumented) -export interface GetOperations200Properties { +// @public +export interface GetOperations200Response extends HttpResponse { // (undocumented) body: BatchStatusResponse; // (undocumented) headers: RawHttpHeaders & GetOperations200Headers; // (undocumented) - status: 200; + status: "200"; } // @public -export type GetOperations200Response = HttpResponse & GetOperations200Properties; - -// @public (undocumented) -export interface GetOperations400Properties { +export interface GetOperations400Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 400; + status: "400"; } // @public -export type GetOperations400Response = HttpResponse & GetOperations400Properties; - -// @public (undocumented) -export interface GetOperations401Properties { +export interface GetOperations401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 401; + status: "401"; } // @public -export type GetOperations401Response = HttpResponse & GetOperations401Properties; - -// @public (undocumented) -export interface GetOperations429Properties { +export interface GetOperations429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type GetOperations429Response = HttpResponse & GetOperations429Properties; - -// @public (undocumented) -export interface GetOperations500Properties { +export interface GetOperations500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type GetOperations500Response = HttpResponse & GetOperations500Properties; - -// @public (undocumented) -export interface GetOperations503Properties { +export interface GetOperations503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type GetOperations503Response = HttpResponse & GetOperations503Properties; - // @public (undocumented) export type GetOperationsParameters = RequestParameters & GetOperationsQueryParam; @@ -665,74 +554,56 @@ export interface GetOperationStatus200Headers { etag?: string; } -// @public (undocumented) -export interface GetOperationStatus200Properties { +// @public +export interface GetOperationStatus200Response extends HttpResponse { // (undocumented) body: BatchStatusDetail; // (undocumented) headers: RawHttpHeaders & GetOperationStatus200Headers; // (undocumented) - status: 200; + status: "200"; } // @public -export type GetOperationStatus200Response = HttpResponse & GetOperationStatus200Properties; - -// @public (undocumented) -export interface GetOperationStatus401Properties { +export interface GetOperationStatus401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 401; + status: "401"; } // @public -export type GetOperationStatus401Response = HttpResponse & GetOperationStatus401Properties; - -// @public (undocumented) -export interface GetOperationStatus404Properties { +export interface GetOperationStatus404Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 404; + status: "404"; } // @public -export type GetOperationStatus404Response = HttpResponse & GetOperationStatus404Properties; - -// @public (undocumented) -export interface GetOperationStatus429Properties { +export interface GetOperationStatus429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type GetOperationStatus429Response = HttpResponse & GetOperationStatus429Properties; - -// @public (undocumented) -export interface GetOperationStatus500Properties { +export interface GetOperationStatus500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type GetOperationStatus500Response = HttpResponse & GetOperationStatus500Properties; - -// @public (undocumented) -export interface GetOperationStatus503Properties { +export interface GetOperationStatus503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type GetOperationStatus503Response = HttpResponse & GetOperationStatus503Properties; - // @public (undocumented) export type GetOperationStatusParameters = RequestParameters; @@ -802,72 +673,54 @@ export interface SubmitBatchRequest202Headers { "operation-location"?: string; } -// @public (undocumented) -export interface SubmitBatchRequest202Properties { +// @public +export interface SubmitBatchRequest202Response extends HttpResponse { // (undocumented) headers: RawHttpHeaders & SubmitBatchRequest202Headers; // (undocumented) - status: 202; + status: "202"; } // @public -export type SubmitBatchRequest202Response = HttpResponse & SubmitBatchRequest202Properties; - -// @public (undocumented) -export interface SubmitBatchRequest400Properties { +export interface SubmitBatchRequest400Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 400; + status: "400"; } // @public -export type SubmitBatchRequest400Response = HttpResponse & SubmitBatchRequest400Properties; - -// @public (undocumented) -export interface SubmitBatchRequest401Properties { +export interface SubmitBatchRequest401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 401; + status: "401"; } // @public -export type SubmitBatchRequest401Response = HttpResponse & SubmitBatchRequest401Properties; - -// @public (undocumented) -export interface SubmitBatchRequest429Properties { +export interface SubmitBatchRequest429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 429; + status: "429"; } // @public -export type SubmitBatchRequest429Response = HttpResponse & SubmitBatchRequest429Properties; - -// @public (undocumented) -export interface SubmitBatchRequest500Properties { +export interface SubmitBatchRequest500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 500; + status: "500"; } // @public -export type SubmitBatchRequest500Response = HttpResponse & SubmitBatchRequest500Properties; - -// @public (undocumented) -export interface SubmitBatchRequest503Properties { +export interface SubmitBatchRequest503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) - status: 503; + status: "503"; } -// @public -export type SubmitBatchRequest503Response = HttpResponse & SubmitBatchRequest503Properties; - // @public (undocumented) export interface SubmitBatchRequestBodyParam { // (undocumented) diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts index e7a811a5a495..ad67d42a2025 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts @@ -9,7 +9,7 @@ * @azsdk-weight 40 */ -import DocumentTranslator from "@azure-rest/ai-document-translator"; +import DocumentTranslator from "../"; //"@azure-rest/ai-document-translator"; import * as dotenv from "dotenv"; dotenv.config(); @@ -23,7 +23,7 @@ export async function main() { const client = DocumentTranslator(endpoint, { key: apiKey }); const formats = await client.path("/documents/formats").get(); - if (formats.status !== 200) { + if (formats.status !== "200") { throw formats.body.error; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts index 2cc9013eaabe..69c721e2b511 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts @@ -11,7 +11,7 @@ * @azsdk-weight 40 */ -import DocumentTranslator, { BatchSubmissionRequest } from "@azure-rest/ai-document-translator"; +import DocumentTranslator, { BatchSubmissionRequest } from "../"; // "@azure-rest/ai-document-translator"; import * as dotenv from "dotenv"; dotenv.config(); @@ -58,7 +58,7 @@ export async function main() { }); // If we get a non-success status code, throw an error - if (formats.status !== 202) { + if (formats.status !== "202") { throw formats.body.error; } @@ -81,7 +81,7 @@ export async function main() { operationState = await checkStatus.get(); // If we get a non-success status code, throw the error - if (operationState.status !== 200) { + if (operationState.status !== "200") { throw operationState.body.error; } @@ -95,7 +95,7 @@ export async function main() { // Now that the operation is complete, we can list the translated documents const documents = await client.path("/batches/{id}/documents", batchId).get(); - if (documents.status !== 200) { + if (documents.status !== "200") { throw documents.body.error; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index 2f0c82017b16..e3f6af890074 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -252,7 +252,11 @@ export interface Routes { /** Resource for '/batches' has methods for the following verbs: post, get */ (path: "/batches"): GetOperations; /** Resource for '/batches/{id}/documents/{documentId}' has methods for the following verbs: get */ - (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; + ( + path: "/batches/{id}/documents/{documentId}", + id: string, + documentId: string + ): GetDocumentStatus; /** Resource for '/batches/{id}' has methods for the following verbs: get, delete */ (path: "/batches/{id}", id: string): CancelOperation; /** Resource for '/batches/{id}/documents' has methods for the following verbs: get */ @@ -270,7 +274,11 @@ export type DocumentTranslator = Client & { }; export interface DocumentTranslatorFactory { - (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; + ( + endpoint: string, + credentials: TokenCredential | KeyCredential, + options?: ClientOptions + ): void; } export default function DocumentTranslator( @@ -280,7 +288,10 @@ export default function DocumentTranslator( ): DocumentTranslator { const baseUrl = options.baseUrl || - "{endpoint}/translator/text/batch/v1.0-preview.1".replace(/{endpoint}/g, endpoint); + "{endpoint}/translator/text/batch/v1.0-preview.1".replace( + /{endpoint}/g, + endpoint + ); options = { ...options, credentials: { diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts index 830da04b960b..9280534b86d2 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts @@ -5,7 +5,8 @@ export interface SubmitBatchRequestBodyParam { body?: BatchSubmissionRequest; } -export type SubmitBatchRequestParameters = RequestParameters & SubmitBatchRequestBodyParam; +export type SubmitBatchRequestParameters = RequestParameters & + SubmitBatchRequestBodyParam; export interface GetOperationsQueryParamProperties { /** @@ -48,7 +49,8 @@ export interface GetOperationsQueryParam { queryParameters?: GetOperationsQueryParamProperties; } -export type GetOperationsParameters = RequestParameters & GetOperationsQueryParam; +export type GetOperationsParameters = RequestParameters & + GetOperationsQueryParam; export type GetDocumentStatusParameters = RequestParameters; export type GetOperationStatusParameters = RequestParameters; export type CancelOperationParameters = RequestParameters; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts index fbe1ad5a5f7f..0c0c153debfa 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts @@ -26,10 +26,8 @@ export interface SubmitBatchRequest202Headers { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export type SubmitBatchRequest202Response = HttpResponse & SubmitBatchRequest202Properties; - -export interface SubmitBatchRequest202Properties { - status: 202; +export interface SubmitBatchRequest202Response extends HttpResponse { + status: "202"; headers: RawHttpHeaders & SubmitBatchRequest202Headers; } @@ -44,10 +42,8 @@ export interface SubmitBatchRequest202Properties { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export type SubmitBatchRequest400Response = HttpResponse & SubmitBatchRequest400Properties; - -export interface SubmitBatchRequest400Properties { - status: 400; +export interface SubmitBatchRequest400Response extends HttpResponse { + status: "400"; body: ErrorResponseV2; } @@ -62,10 +58,8 @@ export interface SubmitBatchRequest400Properties { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export type SubmitBatchRequest401Response = HttpResponse & SubmitBatchRequest401Properties; - -export interface SubmitBatchRequest401Properties { - status: 401; +export interface SubmitBatchRequest401Response extends HttpResponse { + status: "401"; body: ErrorResponseV2; } @@ -80,10 +74,8 @@ export interface SubmitBatchRequest401Properties { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export type SubmitBatchRequest429Response = HttpResponse & SubmitBatchRequest429Properties; - -export interface SubmitBatchRequest429Properties { - status: 429; +export interface SubmitBatchRequest429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } @@ -98,10 +90,8 @@ export interface SubmitBatchRequest429Properties { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export type SubmitBatchRequest500Response = HttpResponse & SubmitBatchRequest500Properties; - -export interface SubmitBatchRequest500Properties { - status: 500; +export interface SubmitBatchRequest500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } @@ -116,10 +106,8 @@ export interface SubmitBatchRequest500Properties { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export type SubmitBatchRequest503Response = HttpResponse & SubmitBatchRequest503Properties; - -export interface SubmitBatchRequest503Properties { - status: 503; +export interface SubmitBatchRequest503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } @@ -155,10 +143,8 @@ export interface GetOperations200Headers { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperations200Response = HttpResponse & GetOperations200Properties; - -export interface GetOperations200Properties { - status: 200; +export interface GetOperations200Response extends HttpResponse { + status: "200"; body: BatchStatusResponse; headers: RawHttpHeaders & GetOperations200Headers; } @@ -188,10 +174,8 @@ export interface GetOperations200Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperations400Response = HttpResponse & GetOperations400Properties; - -export interface GetOperations400Properties { - status: 400; +export interface GetOperations400Response extends HttpResponse { + status: "400"; body: ErrorResponseV2; } @@ -220,10 +204,8 @@ export interface GetOperations400Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperations401Response = HttpResponse & GetOperations401Properties; - -export interface GetOperations401Properties { - status: 401; +export interface GetOperations401Response extends HttpResponse { + status: "401"; body: ErrorResponseV2; } @@ -252,10 +234,8 @@ export interface GetOperations401Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperations429Response = HttpResponse & GetOperations429Properties; - -export interface GetOperations429Properties { - status: 429; +export interface GetOperations429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } @@ -284,10 +264,8 @@ export interface GetOperations429Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperations500Response = HttpResponse & GetOperations500Properties; - -export interface GetOperations500Properties { - status: 500; +export interface GetOperations500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } @@ -316,10 +294,8 @@ export interface GetOperations500Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperations503Response = HttpResponse & GetOperations503Properties; - -export interface GetOperations503Properties { - status: 503; +export interface GetOperations503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } @@ -331,51 +307,39 @@ export interface GetDocumentStatus200Headers { } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export type GetDocumentStatus200Response = HttpResponse & GetDocumentStatus200Properties; - -export interface GetDocumentStatus200Properties { - status: 200; +export interface GetDocumentStatus200Response extends HttpResponse { + status: "200"; body: DocumentStatusDetail; headers: RawHttpHeaders & GetDocumentStatus200Headers; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export type GetDocumentStatus401Response = HttpResponse & GetDocumentStatus401Properties; - -export interface GetDocumentStatus401Properties { - status: 401; +export interface GetDocumentStatus401Response extends HttpResponse { + status: "401"; body: ErrorResponseV2; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export type GetDocumentStatus404Response = HttpResponse & GetDocumentStatus404Properties; - -export interface GetDocumentStatus404Properties { - status: 404; +export interface GetDocumentStatus404Response extends HttpResponse { + status: "404"; body: ErrorResponseV2; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export type GetDocumentStatus429Response = HttpResponse & GetDocumentStatus429Properties; - -export interface GetDocumentStatus429Properties { - status: 429; +export interface GetDocumentStatus429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export type GetDocumentStatus500Response = HttpResponse & GetDocumentStatus500Properties; - -export interface GetDocumentStatus500Properties { - status: 500; +export interface GetDocumentStatus500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export type GetDocumentStatus503Response = HttpResponse & GetDocumentStatus503Properties; - -export interface GetDocumentStatus503Properties { - status: 503; +export interface GetDocumentStatus503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } @@ -390,10 +354,8 @@ export interface GetOperationStatus200Headers { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export type GetOperationStatus200Response = HttpResponse & GetOperationStatus200Properties; - -export interface GetOperationStatus200Properties { - status: 200; +export interface GetOperationStatus200Response extends HttpResponse { + status: "200"; body: BatchStatusDetail; headers: RawHttpHeaders & GetOperationStatus200Headers; } @@ -402,10 +364,8 @@ export interface GetOperationStatus200Properties { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export type GetOperationStatus401Response = HttpResponse & GetOperationStatus401Properties; - -export interface GetOperationStatus401Properties { - status: 401; +export interface GetOperationStatus401Response extends HttpResponse { + status: "401"; body: ErrorResponseV2; } @@ -413,10 +373,8 @@ export interface GetOperationStatus401Properties { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export type GetOperationStatus404Response = HttpResponse & GetOperationStatus404Properties; - -export interface GetOperationStatus404Properties { - status: 404; +export interface GetOperationStatus404Response extends HttpResponse { + status: "404"; body: ErrorResponseV2; } @@ -424,10 +382,8 @@ export interface GetOperationStatus404Properties { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export type GetOperationStatus429Response = HttpResponse & GetOperationStatus429Properties; - -export interface GetOperationStatus429Properties { - status: 429; +export interface GetOperationStatus429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } @@ -435,10 +391,8 @@ export interface GetOperationStatus429Properties { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export type GetOperationStatus500Response = HttpResponse & GetOperationStatus500Properties; - -export interface GetOperationStatus500Properties { - status: 500; +export interface GetOperationStatus500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } @@ -446,10 +400,8 @@ export interface GetOperationStatus500Properties { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export type GetOperationStatus503Response = HttpResponse & GetOperationStatus503Properties; - -export interface GetOperationStatus503Properties { - status: 503; +export interface GetOperationStatus503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } @@ -460,10 +412,8 @@ export interface GetOperationStatus503Properties { * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export type CancelOperation200Response = HttpResponse & CancelOperation200Properties; - -export interface CancelOperation200Properties { - status: 200; +export interface CancelOperation200Response extends HttpResponse { + status: "200"; body: BatchStatusDetail; } @@ -474,10 +424,8 @@ export interface CancelOperation200Properties { * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export type CancelOperation401Response = HttpResponse & CancelOperation401Properties; - -export interface CancelOperation401Properties { - status: 401; +export interface CancelOperation401Response extends HttpResponse { + status: "401"; body: ErrorResponseV2; } @@ -488,10 +436,8 @@ export interface CancelOperation401Properties { * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export type CancelOperation404Response = HttpResponse & CancelOperation404Properties; - -export interface CancelOperation404Properties { - status: 404; +export interface CancelOperation404Response extends HttpResponse { + status: "404"; body: ErrorResponseV2; } @@ -502,10 +448,8 @@ export interface CancelOperation404Properties { * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export type CancelOperation429Response = HttpResponse & CancelOperation429Properties; - -export interface CancelOperation429Properties { - status: 429; +export interface CancelOperation429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } @@ -516,10 +460,8 @@ export interface CancelOperation429Properties { * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export type CancelOperation500Response = HttpResponse & CancelOperation500Properties; - -export interface CancelOperation500Properties { - status: 500; +export interface CancelOperation500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } @@ -530,10 +472,8 @@ export interface CancelOperation500Properties { * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export type CancelOperation503Response = HttpResponse & CancelOperation503Properties; - -export interface CancelOperation503Properties { - status: 503; +export interface CancelOperation503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } @@ -566,11 +506,8 @@ export interface GetOperationDocumentsStatus200Headers { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperationDocumentsStatus200Response = HttpResponse & - GetOperationDocumentsStatus200Properties; - -export interface GetOperationDocumentsStatus200Properties { - status: 200; +export interface GetOperationDocumentsStatus200Response extends HttpResponse { + status: "200"; body: DocumentStatusResponse; headers: RawHttpHeaders & GetOperationDocumentsStatus200Headers; } @@ -597,11 +534,8 @@ export interface GetOperationDocumentsStatus200Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperationDocumentsStatus400Response = HttpResponse & - GetOperationDocumentsStatus400Properties; - -export interface GetOperationDocumentsStatus400Properties { - status: 400; +export interface GetOperationDocumentsStatus400Response extends HttpResponse { + status: "400"; body: ErrorResponseV2; } @@ -627,11 +561,8 @@ export interface GetOperationDocumentsStatus400Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperationDocumentsStatus401Response = HttpResponse & - GetOperationDocumentsStatus401Properties; - -export interface GetOperationDocumentsStatus401Properties { - status: 401; +export interface GetOperationDocumentsStatus401Response extends HttpResponse { + status: "401"; body: ErrorResponseV2; } @@ -657,11 +588,8 @@ export interface GetOperationDocumentsStatus401Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperationDocumentsStatus404Response = HttpResponse & - GetOperationDocumentsStatus404Properties; - -export interface GetOperationDocumentsStatus404Properties { - status: 404; +export interface GetOperationDocumentsStatus404Response extends HttpResponse { + status: "404"; body: ErrorResponseV2; } @@ -687,11 +615,8 @@ export interface GetOperationDocumentsStatus404Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperationDocumentsStatus429Response = HttpResponse & - GetOperationDocumentsStatus429Properties; - -export interface GetOperationDocumentsStatus429Properties { - status: 429; +export interface GetOperationDocumentsStatus429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } @@ -717,11 +642,8 @@ export interface GetOperationDocumentsStatus429Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperationDocumentsStatus500Response = HttpResponse & - GetOperationDocumentsStatus500Properties; - -export interface GetOperationDocumentsStatus500Properties { - status: 500; +export interface GetOperationDocumentsStatus500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } @@ -747,11 +669,8 @@ export interface GetOperationDocumentsStatus500Properties { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export type GetOperationDocumentsStatus503Response = HttpResponse & - GetOperationDocumentsStatus503Properties; - -export interface GetOperationDocumentsStatus503Properties { - status: 503; +export interface GetOperationDocumentsStatus503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } @@ -764,10 +683,8 @@ export interface GetDocumentFormats200Headers { * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ -export type GetDocumentFormats200Response = HttpResponse & GetDocumentFormats200Properties; - -export interface GetDocumentFormats200Properties { - status: 200; +export interface GetDocumentFormats200Response extends HttpResponse { + status: "200"; body: FileFormatListResult; headers: RawHttpHeaders & GetDocumentFormats200Headers; } @@ -776,10 +693,8 @@ export interface GetDocumentFormats200Properties { * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ -export type GetDocumentFormats429Response = HttpResponse & GetDocumentFormats429Properties; - -export interface GetDocumentFormats429Properties { - status: 429; +export interface GetDocumentFormats429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } @@ -787,10 +702,8 @@ export interface GetDocumentFormats429Properties { * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ -export type GetDocumentFormats500Response = HttpResponse & GetDocumentFormats500Properties; - -export interface GetDocumentFormats500Properties { - status: 500; +export interface GetDocumentFormats500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } @@ -798,10 +711,8 @@ export interface GetDocumentFormats500Properties { * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ -export type GetDocumentFormats503Response = HttpResponse & GetDocumentFormats503Properties; - -export interface GetDocumentFormats503Properties { - status: 503; +export interface GetDocumentFormats503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } @@ -814,10 +725,8 @@ export interface GetGlossaryFormats200Headers { * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ -export type GetGlossaryFormats200Response = HttpResponse & GetGlossaryFormats200Properties; - -export interface GetGlossaryFormats200Properties { - status: 200; +export interface GetGlossaryFormats200Response extends HttpResponse { + status: "200"; body: FileFormatListResult; headers: RawHttpHeaders & GetGlossaryFormats200Headers; } @@ -826,10 +735,8 @@ export interface GetGlossaryFormats200Properties { * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ -export type GetGlossaryFormats429Response = HttpResponse & GetGlossaryFormats429Properties; - -export interface GetGlossaryFormats429Properties { - status: 429; +export interface GetGlossaryFormats429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } @@ -837,10 +744,8 @@ export interface GetGlossaryFormats429Properties { * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ -export type GetGlossaryFormats500Response = HttpResponse & GetGlossaryFormats500Properties; - -export interface GetGlossaryFormats500Properties { - status: 500; +export interface GetGlossaryFormats500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } @@ -848,10 +753,8 @@ export interface GetGlossaryFormats500Properties { * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ -export type GetGlossaryFormats503Response = HttpResponse & GetGlossaryFormats503Properties; - -export interface GetGlossaryFormats503Properties { - status: 503; +export interface GetGlossaryFormats503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } @@ -861,38 +764,26 @@ export interface GetDocumentStorageSource200Headers { } /** Returns a list of storage sources/options supported by the Document Translation service. */ -export type GetDocumentStorageSource200Response = HttpResponse & - GetDocumentStorageSource200Properties; - -export interface GetDocumentStorageSource200Properties { - status: 200; +export interface GetDocumentStorageSource200Response extends HttpResponse { + status: "200"; body: StorageSourceListResult; headers: RawHttpHeaders & GetDocumentStorageSource200Headers; } /** Returns a list of storage sources/options supported by the Document Translation service. */ -export type GetDocumentStorageSource429Response = HttpResponse & - GetDocumentStorageSource429Properties; - -export interface GetDocumentStorageSource429Properties { - status: 429; +export interface GetDocumentStorageSource429Response extends HttpResponse { + status: "429"; body: ErrorResponseV2; } /** Returns a list of storage sources/options supported by the Document Translation service. */ -export type GetDocumentStorageSource500Response = HttpResponse & - GetDocumentStorageSource500Properties; - -export interface GetDocumentStorageSource500Properties { - status: 500; +export interface GetDocumentStorageSource500Response extends HttpResponse { + status: "500"; body: ErrorResponseV2; } /** Returns a list of storage sources/options supported by the Document Translation service. */ -export type GetDocumentStorageSource503Response = HttpResponse & - GetDocumentStorageSource503Properties; - -export interface GetDocumentStorageSource503Properties { - status: 503; +export interface GetDocumentStorageSource503Response extends HttpResponse { + status: "503"; body: ErrorResponseV2; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json b/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json index 379f3bd27110..7e100e00d71d 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json +++ b/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json @@ -3,14 +3,10 @@ "compilerOptions": { "outDir": "./dist-esm", "declarationDir": "./types", - "paths": { - "@azure-rest/ai-document-translator": ["./src/index"] - } }, "include": [ "src/**/*.ts", "test/**/*.ts", - "samples-dev/**/*.ts", - "../documentTranslationClient.ts" + "samples-dev/**/*.ts" ] } diff --git a/sdk/documenttranslator/ci.yml b/sdk/documenttranslator/ci.yml index 3464af4012e4..6e2e2a65d3d7 100644 --- a/sdk/documenttranslator/ci.yml +++ b/sdk/documenttranslator/ci.yml @@ -28,5 +28,5 @@ extends: parameters: ServiceDirectory: documenttranslator Artifacts: - - name: azure-rest-ai-document-translator + - name: azure-ai-document-translator-rest safeName: azurerestaidocumenttranslator From 176a96ff32024624d271c5c5e8ef1fb04f8476ce Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 7 Apr 2021 19:06:20 +0000 Subject: [PATCH 07/37] update samples --- .../ai-document-translator-rest/samples-dev/listFormats.ts | 2 +- .../samples-dev/translateFromBlob.ts | 2 +- .../ai-document-translator-rest/tsconfig.json | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts index ad67d42a2025..06c8863f9540 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/listFormats.ts @@ -9,7 +9,7 @@ * @azsdk-weight 40 */ -import DocumentTranslator from "../"; //"@azure-rest/ai-document-translator"; +import DocumentTranslator from "@azure-rest/ai-document-translator"; import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts index 69c721e2b511..90fb5f04e7b7 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts @@ -11,7 +11,7 @@ * @azsdk-weight 40 */ -import DocumentTranslator, { BatchSubmissionRequest } from "../"; // "@azure-rest/ai-document-translator"; +import DocumentTranslator, { BatchSubmissionRequest } from "@azure-rest/ai-document-translator"; import * as dotenv from "dotenv"; dotenv.config(); diff --git a/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json b/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json index 7e100e00d71d..bf3c8799bb85 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json +++ b/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json @@ -3,10 +3,14 @@ "compilerOptions": { "outDir": "./dist-esm", "declarationDir": "./types", + "paths": { + "@azure-rest/ai-document-translator": ["./src/index"] + } }, "include": [ "src/**/*.ts", "test/**/*.ts", - "samples-dev/**/*.ts" + "samples-dev/**/*.ts", + "../documentTranslation.ts" ] } From 79253c6b21091496aff27aabc375df7075d8a9a3 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 8 Apr 2021 00:33:16 +0000 Subject: [PATCH 08/37] Address PR comments --- .../tools/dev-tool/src/util/resolveProject.ts | 2 +- sdk/core-rest/core-client/README.md | 2 +- .../core-client/src/clientHelpers.ts | 2 +- sdk/core-rest/core-client/src/getClient.ts | 2 +- .../ai-document-translator-rest/package.json | 25 ++++++++++++++++++- .../samples-dev/translateFromBlob.ts | 3 +++ .../samples/v1/javascript/README.md | 1 + .../samples/v1/typescript/README.md | 1 + .../test/test.spec.ts | 6 +++++ .../test/text.spec.ts | 1 - sdk/documenttranslator/ci.yml | 2 +- 11 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts delete mode 100644 sdk/documenttranslator/ai-document-translator-rest/test/text.spec.ts diff --git a/common/tools/dev-tool/src/util/resolveProject.ts b/common/tools/dev-tool/src/util/resolveProject.ts index 6151ed02e235..992aca95c193 100644 --- a/common/tools/dev-tool/src/util/resolveProject.ts +++ b/common/tools/dev-tool/src/util/resolveProject.ts @@ -71,7 +71,7 @@ export interface ProjectInfo { async function isAzureSDKPackage(fileName: string): Promise { const f = await import(fileName); - if ((f.name as string).startsWith("@azure/") || (f.name as string).startsWith("@azure-rest/")) { + if (/^@azure(-[a-z]+)?\//.test(f.name)) { return true; } else { return false; diff --git a/sdk/core-rest/core-client/README.md b/sdk/core-rest/core-client/README.md index c677cf8da8d6..daa670fd9420 100644 --- a/sdk/core-rest/core-client/README.md +++ b/sdk/core-rest/core-client/README.md @@ -32,4 +32,4 @@ If you run into issues while using this library, please feel free to [file an is 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. -![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcore%2Fcore-client%2FREADME.png) +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fcore-rest%2Fcore-client%2FREADME.png) diff --git a/sdk/core-rest/core-client/src/clientHelpers.ts b/sdk/core-rest/core-client/src/clientHelpers.ts index 1456333c1645..b01f9026be89 100644 --- a/sdk/core-rest/core-client/src/clientHelpers.ts +++ b/sdk/core-rest/core-client/src/clientHelpers.ts @@ -28,7 +28,7 @@ export function createDefaultPipeline( if (isTokenCredential(credential)) { credentialPolicy = bearerTokenAuthenticationPolicy({ credential, - scopes: options.credentials?.scopes || `${baseUrl}/.default`, + scopes: options.credentials?.scopes ?? `${baseUrl}/.default`, }); } else { if (!options.credentials?.apiKeyHeaderName) { diff --git a/sdk/core-rest/core-client/src/getClient.ts b/sdk/core-rest/core-client/src/getClient.ts index c96d544166a7..974b9397f85c 100644 --- a/sdk/core-rest/core-client/src/getClient.ts +++ b/sdk/core-rest/core-client/src/getClient.ts @@ -119,7 +119,7 @@ export function getClient( function isCredential( param: (TokenCredential | KeyCredential) | PipelineOptions ): param is TokenCredential | KeyCredential { - if ((param as any).key || isTokenCredential(param)) { + if ((param as KeyCredential).key !== undefined || isTokenCredential(param)) { return true; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/package.json b/sdk/documenttranslator/ai-document-translator-rest/package.json index d03366c68a45..4fb6c4100671 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/package.json @@ -98,6 +98,29 @@ "rollup": "^1.16.3", "source-map-support": "^0.5.9", "typescript": "~4.2.0", - "typedoc": "0.20.35" + "typedoc": "0.15.2", + "@types/mocha": "^7.0.2", + "karma": "^6.2.0", + "karma-chrome-launcher": "^3.0.0", + "karma-coverage": "^2.0.0", + "karma-edge-launcher": "^0.4.2", + "karma-env-preprocessor": "^0.1.1", + "karma-firefox-launcher": "^1.1.0", + "karma-ie-launcher": "^1.0.0", + "karma-json-preprocessor": "^0.3.3", + "karma-json-to-file-reporter": "^1.0.1", + "karma-junit-reporter": "^2.0.1", + "karma-mocha": "^2.0.1", + "karma-mocha-reporter": "^2.2.5", + "karma-sourcemap-loader": "^0.3.8", + "karma-source-map-support": "~1.4.0", + "mocha": "^7.1.1", + "mocha-junit-reporter": "^1.18.0", + "nyc": "^14.0.0", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "@types/chai": "^4.1.6", + "rimraf": "^3.0.0", + "@azure/test-utils-recorder": "^1.0.0" } } diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts index 90fb5f04e7b7..a60f90e65930 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts @@ -4,9 +4,12 @@ /** * This sample demonstrates how translate a colletion of documents stored in a Azure Storage Blob container * and output the translated documents to another container. + * * Translating documents is considered a Long Running Operation because it may take a long time to complete, * specially if translating large files or a batch with several files. + * * To handle these long running operations we need to call a few different endpoints, to track the status of the operation + * * @summary translates a collection of documents * @azsdk-weight 40 */ diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md index e46838aa48b7..63ae00cc17c7 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md @@ -7,6 +7,7 @@ products: - azure-cognitive-services - azure-document-translator urlFragment: ai-document-translator-javascript +disableDocsMs: true --- # Azure Document Translator client library samples for JavaScript diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md index d69b6df9740a..e48808174213 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md @@ -7,6 +7,7 @@ products: - azure-cognitive-services - azure-document-translator urlFragment: ai-document-translator-typescript +disableDocsMs: true --- # Azure Document Translator client library samples for TypeScript diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts b/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts new file mode 100644 index 000000000000..3f5bc769ab8e --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts @@ -0,0 +1,6 @@ +import { assert } from "chai"; +describe("Test", () => { + it("should pass", () => { + assert.equal(1, 1); + }); +}); diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/text.spec.ts b/sdk/documenttranslator/ai-document-translator-rest/test/text.spec.ts deleted file mode 100644 index 30e24c7f0b3a..000000000000 --- a/sdk/documenttranslator/ai-document-translator-rest/test/text.spec.ts +++ /dev/null @@ -1 +0,0 @@ -export const x = "foo"; diff --git a/sdk/documenttranslator/ci.yml b/sdk/documenttranslator/ci.yml index 6e2e2a65d3d7..3464af4012e4 100644 --- a/sdk/documenttranslator/ci.yml +++ b/sdk/documenttranslator/ci.yml @@ -28,5 +28,5 @@ extends: parameters: ServiceDirectory: documenttranslator Artifacts: - - name: azure-ai-document-translator-rest + - name: azure-rest-ai-document-translator safeName: azurerestaidocumenttranslator From 8a74b3c6b2167e2ee786c1b3fc93f9106bd1641c Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 8 Apr 2021 06:13:36 +0000 Subject: [PATCH 09/37] Format --- common/config/rush/pnpm-lock.yaml | 234 ++++++++++++++++-- .../src/documentTranslator.ts | 17 +- .../src/parameters.ts | 6 +- .../ai-document-translator-rest/tsconfig.json | 7 +- 4 files changed, 217 insertions(+), 47 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index bfc6a79f0c8c..c13e50a721eb 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -1,6 +1,7 @@ dependencies: '@rush-temp/abort-controller': file:projects/abort-controller.tgz '@rush-temp/ai-anomaly-detector': file:projects/ai-anomaly-detector.tgz + '@rush-temp/ai-document-translator': file:projects/ai-document-translator.tgz '@rush-temp/ai-form-recognizer': file:projects/ai-form-recognizer.tgz '@rush-temp/ai-metrics-advisor': file:projects/ai-metrics-advisor.tgz '@rush-temp/ai-text-analytics': file:projects/ai-text-analytics.tgz @@ -16,6 +17,7 @@ dependencies: '@rush-temp/core-asynciterator-polyfill': file:projects/core-asynciterator-polyfill.tgz '@rush-temp/core-auth': file:projects/core-auth.tgz '@rush-temp/core-client': file:projects/core-client.tgz + '@rush-temp/core-client-1': file:projects/core-client-1.tgz '@rush-temp/core-crypto': file:projects/core-crypto.tgz '@rush-temp/core-http': file:projects/core-http.tgz '@rush-temp/core-lro': file:projects/core-lro.tgz @@ -466,7 +468,7 @@ packages: integrity: sha512-ZQI11Uz1j0HJohb9JZLRD8z0moVcPks1AFW4Q/Gcl67+QvH4aKEJti7fjCcipEEZYb/qzLSO8U6IZgPYytsiJQ== /@azure/msal-node/1.0.1: dependencies: - '@azure/msal-common': 4.0.3 + '@azure/msal-common': 4.1.1 axios: 0.21.1 jsonwebtoken: 8.5.1 uuid: 8.3.2 @@ -720,6 +722,13 @@ packages: node: '>=8' resolution: integrity: sha512-ZXRY4jNvVgSVQ8DL3LTcakaAtXwTVUxE81hslsyD2AtoXW/wVob10HkOJ1X/pAlcI7D+2YoZKg5do8G/w6RYgA== + /@microsoft/api-extractor-model/7.12.2: + dependencies: + '@microsoft/tsdoc': 0.12.24 + '@rushstack/node-core-library': 3.36.0 + dev: false + resolution: + integrity: sha512-EU+U09Mj65zUH0qwPF4PFJiL6Y+PQQE/RRGEHEDGJJzab/mRQDpKOyrzSdb00xvcd/URehIHJqC55cY2Y4jGOA== /@microsoft/api-extractor-model/7.7.10: dependencies: '@microsoft/tsdoc': 0.12.19 @@ -727,6 +736,23 @@ packages: dev: false resolution: integrity: sha512-gMFDXwUgoQYz9TgatyNPALDdZN4xBC3Un3fGwlzME+vM13PoJ26pGuqI7kv/OlK9+q2sgrEdxWns8D3UnLf2TA== + /@microsoft/api-extractor/7.13.2: + dependencies: + '@microsoft/api-extractor-model': 7.12.2 + '@microsoft/tsdoc': 0.12.24 + '@rushstack/node-core-library': 3.36.0 + '@rushstack/rig-package': 0.2.10 + '@rushstack/ts-command-line': 4.7.8 + colors: 1.2.5 + lodash: 4.17.21 + resolve: 1.17.0 + semver: 7.3.5 + source-map: 0.6.1 + typescript: 4.1.5 + dev: false + hasBin: true + resolution: + integrity: sha512-2fD0c8OxZW+e6NTaxbtrdNxXVuX7aqil3+cqig3pKsHymvUuRJVCEAcAJmZrJ/ENqYXNiB265EyqOT6VxbMysw== /@microsoft/api-extractor/7.7.11: dependencies: '@microsoft/api-extractor-model': 7.7.10 @@ -755,6 +781,10 @@ packages: dev: false resolution: integrity: sha512-IpgPxHrNxZiMNUSXqR1l/gePKPkfAmIKoDRP9hp7OwjU29ZR8WCJsOJ8iBKgw0Qk+pFwR+8Y1cy8ImLY6e9m4A== + /@microsoft/tsdoc/0.12.24: + dev: false + resolution: + integrity: sha512-Mfmij13RUTmHEMi9vRUhMXD7rnGR2VvxeNYtaGtaJ4redwwjT4UXYJ+nzmVJF7hhd4pn/Fx5sncDKxMVFJSWPg== /@microsoft/tsdoc/0.13.0: dev: false resolution: @@ -947,6 +977,27 @@ packages: dev: false resolution: integrity: sha512-1+FoymIdr9W9k0D8fdZBBPwi5YcMwh/RyESuL5bY29rLICFxSLOPK+ImVZ1OcWj9GEMsvDx5pNpJ311mHQk+MA== + /@rushstack/node-core-library/3.36.0: + dependencies: + '@types/node': 10.17.13 + colors: 1.2.5 + fs-extra: 7.0.1 + import-lazy: 4.0.0 + jju: 1.4.0 + resolve: 1.17.0 + semver: 7.3.5 + timsort: 0.3.0 + z-schema: 3.18.4 + dev: false + resolution: + integrity: sha512-bID2vzXpg8zweXdXgQkKToEdZwVrVCN9vE9viTRk58gqzYaTlz4fMId6V3ZfpXN6H0d319uGi2KDlm+lUEeqCg== + /@rushstack/rig-package/0.2.10: + dependencies: + resolve: 1.17.0 + strip-json-comments: 3.1.1 + dev: false + resolution: + integrity: sha512-WXYerEJEPf8bS3ruqfM57NnwXtA7ehn8VJjLjrjls6eSduE5CRydcob/oBTzlHKsQ7N196XKlqQl9P6qIyYG2A== /@rushstack/ts-command-line/4.3.13: dependencies: '@types/argparse': 1.0.33 @@ -955,6 +1006,15 @@ packages: dev: false resolution: integrity: sha512-BUBbjYu67NJGQkpHu8aYm7kDoMFizL1qx78+72XE3mX/vDdXYJzw/FWS7TPcMJmY4kNlYs979v2B0Q0qa2wRiw== + /@rushstack/ts-command-line/4.7.8: + dependencies: + '@types/argparse': 1.0.38 + argparse: 1.0.10 + colors: 1.2.5 + string-argv: 0.3.1 + dev: false + resolution: + integrity: sha512-8ghIWhkph7NnLCMDJtthpsb7TMOsVGXVDvmxjE/CeklTqjbbUFBjGXizJfpbEkRQTELuZQ2+vGn7sGwIWKN2uA== /@sinonjs/commons/1.8.2: dependencies: type-detect: 4.0.8 @@ -989,6 +1049,10 @@ packages: dev: false resolution: integrity: sha512-VQgHxyPMTj3hIlq9SY1mctqx+Jj8kpQfoLvDlVSDNOyuYs8JYfkuY3OW/4+dO657yPmNhHpePRx0/Tje5ImNVQ== + /@types/argparse/1.0.38: + dev: false + resolution: + integrity: sha512-ebDJ9b0e702Yr7pWgB0jzm+CX4Srzz8RcXtLJDJB+BSccqMa36uyH/zUsSYao5+BD1ytv3k3rPYCq4mAE1hsXA== /@types/async-lock/1.1.2: dev: false resolution: @@ -996,7 +1060,7 @@ packages: /@types/body-parser/1.19.0: dependencies: '@types/connect': 3.4.34 - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-W98JrE0j2K78swW4ukqMleo8R7h/pFETjM2DQ90MF6XK2i4LO4W3gQ71Lt4w3bfm2EvVSyWHplECvB5sK22yFQ== @@ -1018,7 +1082,7 @@ packages: integrity: sha512-vI5iOAsez9+roLS3M3+Xx7w+WRuDtSmF8bQkrbcIJ2sC1PcDgVoA0WGpa+bIrJ+y8zqY2oi//fUctkxtIcXJCw== /@types/chalk/2.2.0: dependencies: - chalk: 3.0.0 + chalk: 4.1.0 deprecated: This is a stub types definition for chalk (https://github.com/chalk/chalk). chalk provides its own type definitions, so you don't need @types/chalk installed! dev: false resolution: @@ -1029,7 +1093,7 @@ packages: integrity: sha512-bsjleuRKWmGqajMerkzox19aGbscQX5rmmvvXl3wlIp5gMG1HgkiwPxsN5p070fBDKTNSPgojVbuY1+HWMbFhg== /@types/connect/3.4.34: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-ePPA/JuI+X0vb+gSWlPKOY0NdNAie/rPUqX2GUPpbZwiKTkSPhjXWuee47E4MtE54QVzGCQMQkAL6JhV2E1+cQ== @@ -1062,7 +1126,7 @@ packages: integrity: sha512-c5ciR06jK8u9BstrmJyO97m+klJrrhCf9u3rLu3DEAJBirxRqSCvDQoYKmxuYwQI5SZChAWu+tq9oVlGRuzPAg== /@types/express-serve-static-core/4.17.19: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 '@types/qs': 6.9.6 '@types/range-parser': 1.2.3 dev: false @@ -1083,20 +1147,20 @@ packages: integrity: sha512-mky/O83TXmGY39P1H9YbUpjV6l6voRYlufqfFCvel8l1phuy8HRjdWc1rrPuN53ITBJlbyMSV6z3niOySO5pgQ== /@types/fs-extra/8.1.1: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-TcUlBem321DFQzBNuz8p0CLLKp0VvF/XH9E4KHNmgwyp4E3AfgI5cjiIVZWlbfThBop2qxFIh4+LeY6hVWWZ2w== /@types/glob/7.1.3: dependencies: '@types/minimatch': 3.0.4 - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w== /@types/is-buffer/2.0.0: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-0f7N/e3BAz32qDYvgB4d2cqv1DqUwvGxHkXsrucICn8la1Vb6Yl6Eg8mPScGwUiqHJeE7diXlzaK+QMA9m4Gxw== @@ -1114,7 +1178,7 @@ packages: integrity: sha512-TtLis3HRTt7wLfdpkDBem6vs+MbEGMsC7ob5gNYsJV40tHNAFxw00HMMsEHsg9FWduD38NtACWuSqQpXbFulUg== /@types/jws/3.2.3: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-g54CHxwvaHvyJyeuZqe7VQujV9SfCXwEkboJp355INPL+kjlS3Aq153EHptaeO/Cch/NPJ1i2sHz0sDDizn7LQ== @@ -1128,7 +1192,7 @@ packages: integrity: sha512-5tXH6Bx/kNGd3MgffdmP4dy2Z+G4eaXw0SE81Tq3BNadtnMR5/ySMzX4SLEzHJzSmPNn4HIdpQsBvXMUykr58w== /@types/md5/2.3.0: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-556YJ7ejzxIqSSxzyGGpctuZOarNZJt/zlEkhmmDc1f/slOEANHuwu2ZX7YaZ40rMiWoxt8GvAhoDpW1cmSy6A== @@ -1154,13 +1218,13 @@ packages: integrity: sha512-ZvO2tAcjmMi8V/5Z3JsyofMe3hasRcaw88cto5etSVMwVQfeivGAlEYmaQgceUSVYFofVjT+ioHsATjdWcFt1w== /@types/mock-fs/4.10.0: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-FQ5alSzmHMmliqcL36JqIA4Yyn9jyJKvRSGV3mvPh108VFatX7naJDzSG4fnFQNZFq9dIx0Dzoe6ddflMB2Xkg== /@types/mock-require/2.0.0: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-nOgjoE5bBiDeiA+z41i95makyHUSMWQMOPocP+J67Pqx/68HAXaeWN1NFtrAYYV6LrISIZZ8vKHm/a50k0f6Sg== @@ -1170,7 +1234,7 @@ packages: integrity: sha512-DPxmjiDwubsNmguG5X4fEJ+XCyzWM3GXWsqQlvUcjJKa91IOoJUy51meDr0GkzK64qqNcq85ymLlyjoct9tInw== /@types/node-fetch/2.5.10: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 form-data: 3.0.1 dev: false resolution: @@ -1213,7 +1277,7 @@ packages: integrity: sha512-ewFXqrQHlFsgc09MK5jP5iR7vumV/BYayNC6PgJO2LPe8vrnNFyjQjSppfEngITi0qvfKtzFvgKymGheFM9UOA== /@types/resolve/1.17.1: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-yy7HuzQhj0dhGpD8RLXSZWEkLsV9ibvxvi6EiJ3bkqLAO1RGo0WbkWQiwpRlSFymTJRz0d3k5LM3kkx8ArDbLw== @@ -1224,7 +1288,7 @@ packages: /@types/serve-static/1.13.9: dependencies: '@types/mime': 1.3.2 - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-ZFqF6qa48XsPdjXV5Gsz0Zqmux2PerNd3a/ktL45mHpa19cuMi/cL8tcxdAx497yRh+QtYPuofjT9oWw9P7nkA== @@ -1240,7 +1304,7 @@ packages: integrity: sha512-dIPoZ3g5gcx9zZEszaxLSVTvMReD3xxyyDnQUjA6IYDG9Ba2AV0otMPs+77sG9ojB4Qr2N2Vk5RnKeuA0X/0bg== /@types/stoppable/1.1.0: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-BRR23Q9CJduH7AM6mk4JRttd8XyFkb4qIPZu4mdLF+VoP+wcjIxIWIKiBbN78NBbEuynrAyMPtzOHnIp2B/JPQ== @@ -1250,7 +1314,7 @@ packages: integrity: sha512-I99sngh224D0M7XgW1s120zxCt3VYQ3IQsuw3P3jbq5GG4yc79+ZjyKznyOGIQrflfylLgcfekeZW/vk0yng6A== /@types/tunnel/0.0.1: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-AOqu6bQu5MSWwYvehMXLukFHnupHrpZ8nvgae5Ggie9UwzDR1CCwoXgSSWNZJuyOlCdfdsWMA5F2LlmvyoTv8A== @@ -1264,13 +1328,13 @@ packages: integrity: sha512-eQ9qFW/fhfGJF8WKHGEHZEyVWfZxrT+6CLIJGBcZPfxUh/+BnEj+UCGYMlr9qZuX/2AltsvwrGqp0LhEW8D0zQ== /@types/ws/7.4.1: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-ISCK1iFnR+jYv7+jLNX0wDqesZ/5RAeY3wUx6QaphmocphU61h+b+PHjS18TF4WIPTu/MMzxIq2PHr32o2TS5Q== /@types/xml2js/0.4.8: dependencies: - '@types/node': 8.10.66 + '@types/node': 14.14.37 dev: false resolution: integrity: sha512-EyvT83ezOdec7BhDaEcsklWy7RSIdi6CNe95tmOAK0yx/Lm30C9K75snT3fYayK59ApC2oyW+rcHErdG05FHJA== @@ -2343,7 +2407,7 @@ packages: integrity: sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== /debug/3.2.6: dependencies: - ms: 2.1.1 + ms: 2.1.3 deprecated: Debug versions >=3.2.0 <3.2.7 || >=4 <4.3.1 have a low-severity ReDos regression when used in a Node.js environment. It is recommended you upgrade to 3.2.7 or 4.3.1. (https://github.com/visionmedia/debug/issues/797) dev: false resolution: @@ -3827,6 +3891,12 @@ packages: node: '>=6' resolution: integrity: sha512-veYYhQa+D1QBKznvhUHxb8faxlrwUnxseDAbAp457E0wLNio2bOSKnjYDhMj+YiAq61xrMGhQk9iXVk5FzgQMw== + /import-lazy/4.0.0: + dev: false + engines: + node: '>=8' + resolution: + integrity: sha512-rKtvo6a868b5Hu3heneU+L4yEQ4jYKLtjpnPeUdK7h0yzXGmyBTypknlkCvHFBqfX9YlorEiMM6Dnq/5atfHkw== /imurmurhash/0.1.4: dev: false engines: @@ -5706,6 +5776,13 @@ packages: hasBin: true resolution: integrity: sha512-s7PoyDv/II1ObgQunCbB9PdLmUcBZcnWOcxDh7O0N/UwDEsHyqkW+Qh28jW+mVuCdx7gLB0BotYI1Y6uI9iyew== + /prettier/2.2.1: + dev: false + engines: + node: '>=10.13.0' + hasBin: true + resolution: + integrity: sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q== /priorityqueuejs/1.0.0: dev: false resolution: @@ -6123,6 +6200,12 @@ packages: dev: false resolution: integrity: sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= + /resolve/1.17.0: + dependencies: + path-parse: 1.0.6 + dev: false + resolution: + integrity: sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w== /resolve/1.19.0: dependencies: is-core-module: 2.2.0 @@ -6257,7 +6340,7 @@ packages: /rollup/1.32.1: dependencies: '@types/estree': 0.0.47 - '@types/node': 8.10.66 + '@types/node': 14.14.37 acorn: 7.4.1 dev: false hasBin: true @@ -6713,6 +6796,12 @@ packages: node: '>=0.10.0' resolution: integrity: sha1-J5siXfHVgrH1TmWt3UNS4Y+qBxM= + /string-argv/0.3.1: + dev: false + engines: + node: '>=0.6.19' + resolution: + integrity: sha512-a1uQGz7IyVy9YwhqjZIZu1c8JO8dNIe20xBmSS6qu9kv++k3JGzCVmprbNN5Kn+BgzD5E7YYwg1CcjuJMRNsvg== /string-width/1.0.2: dependencies: code-point-at: 1.1.0 @@ -7169,6 +7258,13 @@ packages: hasBin: true resolution: integrity: sha512-kdMjTiekY+z/ubJCATUPlRDl39vXYiMV9iyeMuEuXZh2we6zz80uovNN2WlAxmmdE/Z/YQe+EbOEXB5RHEED3w== + /typescript/4.1.5: + dev: false + engines: + node: '>=4.2.0' + hasBin: true + resolution: + integrity: sha512-6OSu9PTIzmn9TCDiovULTnET6BgXtDYL4Gg4szY+cGsc3JP1dQL8qvE8kShTRx1NIw4Q9IBHlwODjkjWEtMUyA== /typescript/4.2.4: dev: false engines: @@ -7715,6 +7811,46 @@ packages: integrity: sha512-XXxiTKF9En0QbRE2AqVfCMzzUeLkmkh/iy/3AjF3q6Xw7FMBSe2cMdBmW6x0GfdiRFM3Adq+yI1rbba5xMyoQA== tarball: file:projects/ai-anomaly-detector.tgz version: 0.0.0 + file:projects/ai-document-translator.tgz: + dependencies: + '@microsoft/api-extractor': 7.13.2 + '@types/chai': 4.2.16 + '@types/mocha': 7.0.2 + '@types/node': 8.10.66 + chai: 4.3.4 + cross-env: 7.0.3 + dotenv: 8.2.0 + eslint: 7.23.0 + karma: 6.3.2 + karma-chrome-launcher: 3.1.0 + karma-coverage: 2.0.3 + karma-edge-launcher: 0.4.2_karma@6.3.2 + karma-env-preprocessor: 0.1.1 + karma-firefox-launcher: 1.3.0 + karma-ie-launcher: 1.0.0_karma@6.3.2 + karma-json-preprocessor: 0.3.3_karma@6.3.2 + karma-json-to-file-reporter: 1.0.1 + karma-junit-reporter: 2.0.1_karma@6.3.2 + karma-mocha: 2.0.1 + karma-mocha-reporter: 2.2.5_karma@6.3.2 + karma-source-map-support: 1.4.0 + karma-sourcemap-loader: 0.3.8 + mocha: 7.2.0 + mocha-junit-reporter: 1.23.3_mocha@7.2.0 + nyc: 14.1.1 + prettier: 1.19.1 + rimraf: 3.0.2 + rollup: 1.32.1 + source-map-support: 0.5.19 + tslib: 2.2.0 + typedoc: 0.15.2 + typescript: 4.2.4 + dev: false + name: '@rush-temp/ai-document-translator' + resolution: + integrity: sha512-rDLxnotxbZpbq8g1KSYqpzjyT0mll3vjeVUOQLTMjDQ3m5b+3nQqtoCgqIVja7pUGm5qkB7dJAkCK1JVAxR9Ig== + tarball: file:projects/ai-document-translator.tgz + version: 0.0.0 file:projects/ai-form-recognizer.tgz: dependencies: '@azure/core-tracing': 1.0.0-preview.11 @@ -8375,7 +8511,7 @@ packages: integrity: sha512-/FcyvPOvKjNPulEcKL64t6cl870h1H5UEoucinxeXxFQ0TEyHRnXafG4PhBpm7RBtFzba7MlnbYrVHWwlPum9Q== tarball: file:projects/core-auth.tgz version: 0.0.0 - file:projects/core-client.tgz: + file:projects/core-client-1.tgz: dependencies: '@azure/core-tracing': 1.0.0-preview.11 '@azure/core-xml': 1.0.0-beta.1 @@ -8419,9 +8555,58 @@ packages: typescript: 4.2.4 util: 0.12.3 dev: false + name: '@rush-temp/core-client-1' + resolution: + integrity: sha512-21H/GvL5vjCaXYQD8ETNkbn4a2s35EY9ohVTqK7bR996ytd0gTX1XCcwlbLrnPFJpJD22X2oCZBmwx3tUDsJag== + tarball: file:projects/core-client-1.tgz + version: 0.0.0 + file:projects/core-client.tgz: + dependencies: + '@azure/core-tracing': 1.0.0-preview.11 + '@azure/core-xml': 1.0.0-beta.1 + '@microsoft/api-extractor': 7.13.2 + '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 + '@rollup/plugin-json': 4.1.0_rollup@1.32.1 + '@rollup/plugin-multi-entry': 3.0.1_rollup@1.32.1 + '@rollup/plugin-node-resolve': 8.4.0_rollup@1.32.1 + '@rollup/plugin-replace': 2.4.2_rollup@1.32.1 + '@types/chai': 4.2.16 + '@types/mocha': 7.0.2 + '@types/node': 8.10.66 + '@types/sinon': 9.0.11 + chai: 4.3.4 + cross-env: 7.0.3 + downlevel-dts: 0.4.0 + eslint: 7.23.0 + inherits: 2.0.4 + karma: 6.3.2 + karma-chrome-launcher: 3.1.0 + karma-coverage: 2.0.3 + karma-edge-launcher: 0.4.2_karma@6.3.2 + karma-env-preprocessor: 0.1.1 + karma-firefox-launcher: 1.3.0 + karma-ie-launcher: 1.0.0_karma@6.3.2 + karma-junit-reporter: 2.0.1_karma@6.3.2 + karma-mocha: 2.0.1 + karma-mocha-reporter: 2.2.5_karma@6.3.2 + karma-sourcemap-loader: 0.3.8 + mocha: 7.2.0 + mocha-junit-reporter: 1.23.3_mocha@7.2.0 + prettier: 2.2.1 + rimraf: 3.0.2 + rollup: 1.32.1 + rollup-plugin-sourcemaps: 0.4.2_rollup@1.32.1 + rollup-plugin-terser: 5.3.1_rollup@1.32.1 + rollup-plugin-visualizer: 4.2.2_rollup@1.32.1 + sinon: 9.2.4 + tslib: 2.2.0 + typedoc: 0.15.2 + typescript: 4.2.4 + util: 0.12.3 + dev: false name: '@rush-temp/core-client' resolution: - integrity: sha512-Jp4ZvsXrtFOmdt0S1LJGYxgHqum4nZeuQ9vP9EfQB7JXAOvHQOET1R/0+8xZuFrngPVIkZzQYy6mjo+/9kw5zg== + integrity: sha512-ysfQQBePlUwpeDJmTUCRqYxf/zHdH+UTQ+EAByVTDOvM/2ekmsXjwhJIBwp78vBnQURbtNjIuSFYKk2od3amBg== tarball: file:projects/core-client.tgz version: 0.0.0 file:projects/core-crypto.tgz: @@ -10844,9 +11029,11 @@ packages: integrity: sha512-+z4Le1dPD7946nToxQrse/mrMXuoJDo2Cko9iUDRTFxF2+1vs9a2WEawBV2iW4KckezsAyswjjxTrWYFl5Vyyg== tarball: file:projects/test-utils-recorder.tgz version: 0.0.0 +registry: '' specifiers: '@rush-temp/abort-controller': file:./projects/abort-controller.tgz '@rush-temp/ai-anomaly-detector': file:./projects/ai-anomaly-detector.tgz + '@rush-temp/ai-document-translator': file:./projects/ai-document-translator.tgz '@rush-temp/ai-form-recognizer': file:./projects/ai-form-recognizer.tgz '@rush-temp/ai-metrics-advisor': file:./projects/ai-metrics-advisor.tgz '@rush-temp/ai-text-analytics': file:./projects/ai-text-analytics.tgz @@ -10862,6 +11049,7 @@ specifiers: '@rush-temp/core-asynciterator-polyfill': file:./projects/core-asynciterator-polyfill.tgz '@rush-temp/core-auth': file:./projects/core-auth.tgz '@rush-temp/core-client': file:./projects/core-client.tgz + '@rush-temp/core-client-1': file:./projects/core-client-1.tgz '@rush-temp/core-crypto': file:./projects/core-crypto.tgz '@rush-temp/core-http': file:./projects/core-http.tgz '@rush-temp/core-lro': file:./projects/core-lro.tgz diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index e3f6af890074..2f0c82017b16 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -252,11 +252,7 @@ export interface Routes { /** Resource for '/batches' has methods for the following verbs: post, get */ (path: "/batches"): GetOperations; /** Resource for '/batches/{id}/documents/{documentId}' has methods for the following verbs: get */ - ( - path: "/batches/{id}/documents/{documentId}", - id: string, - documentId: string - ): GetDocumentStatus; + (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; /** Resource for '/batches/{id}' has methods for the following verbs: get, delete */ (path: "/batches/{id}", id: string): CancelOperation; /** Resource for '/batches/{id}/documents' has methods for the following verbs: get */ @@ -274,11 +270,7 @@ export type DocumentTranslator = Client & { }; export interface DocumentTranslatorFactory { - ( - endpoint: string, - credentials: TokenCredential | KeyCredential, - options?: ClientOptions - ): void; + (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; } export default function DocumentTranslator( @@ -288,10 +280,7 @@ export default function DocumentTranslator( ): DocumentTranslator { const baseUrl = options.baseUrl || - "{endpoint}/translator/text/batch/v1.0-preview.1".replace( - /{endpoint}/g, - endpoint - ); + "{endpoint}/translator/text/batch/v1.0-preview.1".replace(/{endpoint}/g, endpoint); options = { ...options, credentials: { diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts index 9280534b86d2..830da04b960b 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts @@ -5,8 +5,7 @@ export interface SubmitBatchRequestBodyParam { body?: BatchSubmissionRequest; } -export type SubmitBatchRequestParameters = RequestParameters & - SubmitBatchRequestBodyParam; +export type SubmitBatchRequestParameters = RequestParameters & SubmitBatchRequestBodyParam; export interface GetOperationsQueryParamProperties { /** @@ -49,8 +48,7 @@ export interface GetOperationsQueryParam { queryParameters?: GetOperationsQueryParamProperties; } -export type GetOperationsParameters = RequestParameters & - GetOperationsQueryParam; +export type GetOperationsParameters = RequestParameters & GetOperationsQueryParam; export type GetDocumentStatusParameters = RequestParameters; export type GetOperationStatusParameters = RequestParameters; export type CancelOperationParameters = RequestParameters; diff --git a/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json b/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json index bf3c8799bb85..d817377ed4d5 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json +++ b/sdk/documenttranslator/ai-document-translator-rest/tsconfig.json @@ -7,10 +7,5 @@ "@azure-rest/ai-document-translator": ["./src/index"] } }, - "include": [ - "src/**/*.ts", - "test/**/*.ts", - "samples-dev/**/*.ts", - "../documentTranslation.ts" - ] + "include": ["src/**/*.ts", "test/**/*.ts", "samples-dev/**/*.ts", "../documentTranslation.ts"] } From 0212ee564f3d00df9f5b2ffd196412081284b02e Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Mon, 12 Apr 2021 20:49:51 +0000 Subject: [PATCH 10/37] Add readme and Fix lint --- .../src/rules/ts-package-json-name.ts | 10 +- .../ai-document-translator-rest/README.md | 237 ++++++++++++++++++ .../api-extractor.json | 2 +- .../ai-document-translator-rest/package.json | 2 +- .../review/ai-document-translator.api.md | 12 +- .../src/documentTranslator.ts | 19 +- .../ai-document-translator-rest/src/index.ts | 3 + .../ai-document-translator-rest/src/models.ts | 2 + .../src/parameters.ts | 7 +- .../src/responses.ts | 29 ++- .../test/test.spec.ts | 3 + 11 files changed, 290 insertions(+), 36 deletions(-) create mode 100644 sdk/documenttranslator/ai-document-translator-rest/README.md diff --git a/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-name.ts b/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-name.ts index 5184efb8d35f..86c017f525f5 100644 --- a/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-name.ts +++ b/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-name.ts @@ -18,7 +18,7 @@ import { stripFileName } from "../utils/verifiers"; export = { meta: getRuleMetaData( "ts-package-json-name", - "force package.json's name value to be set to @azure/" + "force package.json's name value to be set to @azure/ or @azure-/" ), create: (context: Rule.RuleContext): Rule.RuleListener => { const verifiers = getVerifiers(context, { @@ -32,24 +32,24 @@ export = { // check to see if name exists at the outermost level "ExpressionStatement > ObjectExpression": verifiers.existsInFile, - // check the node corresponding to name to see if its value is @azure/ + // check the node corresponding to name to see if its value is @azure/ or @azure-/ "ExpressionStatement > ObjectExpression > Property[key.value='name']": ( node: Property ): void => { const nodeValue = node.value as Literal; const name = nodeValue.value as string; - if (!name.startsWith("@azure/")) { + if (!/^@azure(-[a-z]+)?\//.test(name)) { context.report({ node: nodeValue, - message: "name is not set to @azure/" + message: "name is not set to @azure/ or @azure-/" }); return; } const packageDirectory = stripPath(stripFileName(fileName)); const packageBaseName = stripPath(name); - if (!/^@azure\/([a-z]+-)*[a-z]+$/.test(name)) { + if (!/^@azure(-[a-z]+)?\/([a-z]+-)*[a-z]+$/.test(name)) { context.report({ node: nodeValue, message: "service name is not in kebab-case (lowercase and separated by hyphens)" diff --git a/sdk/documenttranslator/ai-document-translator-rest/README.md b/sdk/documenttranslator/ai-document-translator-rest/README.md new file mode 100644 index 000000000000..cf92183ff51c --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/README.md @@ -0,0 +1,237 @@ +# Azure Document Translator Rest-Level library for JavaScript + +[Azure Document Translator](https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview) is a cloud-based feature of the Azure Translator service and is part of the Azure Cognitive Service family of REST APIs. The Document Translation API translates documents to and from 90 languages and dialects while preserving document structure and data format. + +**Note:** This Rest Level Library targets Azure Document Translator service API version v1.0-preview.1. + +Use the client library to: + +| Feature | Description | +| --------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ | +| Translate large files | Translate whole documents asynchronously. | +| Translate numerous files | Translate multiple files to and from 90 languages and dialects. | +| Preserve source file presentation | Translate files while preserving the original layout and format. | +| Apply custom translation | Translate documents using general and [custom translation](https://docs.microsoft.com/azure/cognitive-services/translator/customization#custom-translator) models. | +| Apply custom glossaries | Translate documents using custom glossaries. | + +[Source code](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/) | +[Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-document-translator) | +[API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/ai-document-translator) | +[Product documentation](https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview) | +[Samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/samples) + +## Getting started + +### Currently supported environments + +- Node.js version 14.x.x or higher + +### Prerequisites + +- An [Azure subscription][azure_sub]. +- An existing [Translator Service][translator_resource] resource. If you need to create the resource, you can use the [Azure Portal][azure_portal] or [Azure CLI][azure_cli]. + +### Install the `@azure-rest/ai-document-translator` package + +Install the Azure Document Translator client library for JavaScript with `npm`: + +```bash +npm install @azure-rest/ai-document-translator +``` + +### Create a Document Translation resource + +Document Translation supports [single-service access][single_service] only. +To access the service, create a Translator resource. + +You can create the resource using + +**Option 1:** [Azure Portal][translator_resource] + +**Option 2:** [Azure CLI][azure_cli_create_dt_resource]. +Below is an example of how you can create a Document Translation resource using the CLI: + +```bash +# Create a new resource group to hold the document translation resource - +# if using an existing resource group, skip this step +az group create --name my-resource-group --location westus2 +``` + +```bash +# Create document translation +az cognitiveservices account create \ + --name document-translation-resource \ + --custom-domain document-translation-resource \ + --resource-group my-resource-group \ + --kind TextTranslation \ + --sku S1 \ + --location westus2 \ + --yes +``` + +### Create and authenticate a `DocumentTranslator` + +#### Looking up the endpoint + +You can find the endpoint for your Document Translation resource using the +[Azure Portal][azure_portal_get_endpoint]. + +> Note that the service requires a custom domain endpoint. Follow the instructions in the above link to format your endpoint: +> https://{NAME-OF-YOUR-RESOURCE}.cognitiveservices.azure.com/ + +#### Using an API Key + +The API key can be found in the Azure Portal or by running the following Azure CLI command: + +```bash +az cognitiveservices account keys list --name "resource-name" --resource-group "resource-group-name" +``` + +Once you have an API key and endpoint, you can use the `AzureKeyCredential` class to authenticate the client as follows: + +```javascript +const DocumentTranslator = require("@azure-azure/ai-document-translator"); + +const client = DocumentTranslator("", { key: "" }); +``` + +#### Using an Azure Active Directory Credential + +Client API key authentication is used in most of the examples, but you can also authenticate with Azure Active Directory using the [Azure Identity library][azure_identity]. To use the [DefaultAzureCredential][defaultazurecredential] provider shown below, +or other credential providers provided with the Azure SDK, please install the `@azure/identity` package: + +```bash +npm install @azure/identity +``` + +You will also need to [register a new AAD application][register_aad_app] and grant access to Document Translator by assigning the `"Managed Application Contributor Role"` role to your service principal (note: other roles such as `"Owner"` will not grant the necessary permissions, only `"Managed Application Contributor Role"` will suffice to run the examples and the sample code). + +Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`. + +```javascript +const DocumentTranslator = require("@azure-rest/ai-document-translator"); +const { DefaultAzureCredential } = require("@azure/identity"); + +const client = DocumentTranslator("", new DefaultAzureCredential()); +``` + +## Key concepts + +The Document Translation service requires that you upload your files to an Azure Blob Storage source container and provide +a target container where the translated documents can be written. SAS tokens to the containers (or files) are used to +access the documents and create the translated documents in the target container. Additional information about setting this up can be found in +the service documentation: + +- [Set up Azure Blob Storage containers][source_containers] with your documents +- Optionally apply [glossaries][glossary] or a [custom model for translation][custom_model] +- Generate [SAS tokens][sas_token] to your containers (or files) with the appropriate [permissions][sas_token_permissions] + +### DocumentTranslator + +Interaction with the Document Translation rest library begins with an instance of the `DocumentTranslation`. +The client provides operations for: + +- Creating a translation job to translate documents in your source container(s) and write results to you target container(s). +- Checking the status of individual documents in the translation job and monitoring each document's progress. +- Enumerating all past and current translation jobs with the option to wait until the job(s) finish. +- Identifying supported glossary and document formats. + +### Translation Input + +To create a translation job, send a post request with body of type `BatchSubmissionRequest` to the `"/batches/"` path.. +Creating a `BatchSubmissionRequest` requires that you pass the SAS URLs to your source and target containers (or files) +and the target language(s) for translation. + +A single source container with documents can be translated to many different languages: + +```typescript +import { BatchSubmissionRequest } from "@azure-rest/ai-document-translator"; +const batchSubmissionRequest: BatchSubmissionRequest = { + inputs: [ + { + source: { sourceUrl: "" }, + targets: [{ language: "fr", targetUrl: "" }] + } + ] +}; +``` + +Or multiple different sources can be provided each with their own targets. + +```typescript +import { BatchSubmissionRequest } from "@azure-rest/ai-document-translator"; +const batchSubmissionRequest: BatchSubmissionRequest = { + inputs: [ + { + source: { sourceUrl: "" }, + targets: [ + { language: "fr", targetUrl: "" }, + { language: "de", targetUrl: "" } + ] + }, + { + source: { sourceUrl: "" }, + targets: [ + { language: "fr", targetUrl: "" }, + { language: "de", targetUrl: "" } + ] + } + ] +}; +``` + +> Note: the target_url for each target language must be unique. + +See the service documentation for all [supported languages][supported_languages]. + +## Examples + +Please refer to the samples folder to see code samples, including: + +- [List Supported Formats][https://github.com/azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translatefromblob.ts] +- [Translate documents][https://github.com/azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/listformats.ts] + +## Troubleshooting + +### Logging + +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 +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/master/sdk/core/logger). + +## Next steps + +Please take a look at the [samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/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) + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-js%2Fsdk%2Fdocumenttranslator%2Fai-document-translator-rest%2FREADME.png) + +[azure_cli]: https://docs.microsoft.com/cli/azure +[azure_sub]: https://azure.microsoft.com/free/ +[translator_resource]: https://ms.portal.azure.com/#create/Microsoft.CognitiveServicesTextTranslation +[azure_portal]: https://portal.azure.com +[azure_identity]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity +[cognitive_auth]: https://docs.microsoft.com/azure/cognitive-services/authentication +[register_aad_app]: https://docs.microsoft.com/azure/cognitive-services/authentication#assign-a-role-to-a-service-principal +[defaultazurecredential]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/identity/identity#defaultazurecredential +[azure_cli_create_dt_resource]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account-cli?tabs=windows +[azure_portal_get_endpoint]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/get-started-with-document-translation?tabs=csharp#get-your-custom-domain-name-and-subscription-key +[source_containers]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/get-started-with-document-translation?tabs=csharp#create-your-azure-blob-storage-containers +[glossary]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview#supported-glossary-formats +[custom_model]: https://docs.microsoft.com/azure/cognitive-services/translator/custom-translator/quickstart-build-deploy-custom-model +[sas_token]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/create-sas-tokens?tabs=Containers#create-your-sas-tokens-with-azure-storage-explorer +[sas_token_permissions]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/get-started-with-document-translation?tabs=csharp#create-sas-access-tokens-for-document-translation +[supported_languages]: https://docs.microsoft.com/azure/cognitive-services/translator/language-support#translate diff --git a/sdk/documenttranslator/ai-document-translator-rest/api-extractor.json b/sdk/documenttranslator/ai-document-translator-rest/api-extractor.json index a48e9e8b796d..65fde67917d4 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/api-extractor.json +++ b/sdk/documenttranslator/ai-document-translator-rest/api-extractor.json @@ -11,7 +11,7 @@ "dtsRollup": { "enabled": true, "untrimmedFilePath": "", - "publicTrimmedFilePath": "./types/ai-document-translator.d.ts" + "publicTrimmedFilePath": "./types/ai-document-translator-rest.d.ts" }, "messages": { "tsdocMessageReporting": { diff --git a/sdk/documenttranslator/ai-document-translator-rest/package.json b/sdk/documenttranslator/ai-document-translator-rest/package.json index 4fb6c4100671..01470f735871 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/package.json @@ -15,7 +15,7 @@ "license": "MIT", "main": "./dist/index.js", "module": "./dist-esm/src/index.js", - "types": "./types/ai-document-translator.d.ts", + "types": "./types/ai-document-translator-rest.d.ts", "homepage": "https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator/README.md", "repository": "github:Azure/azure-sdk-for-js", "bugs": { diff --git a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md index 5ffd3279bff4..ab9395956810 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md +++ b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md @@ -125,14 +125,14 @@ export interface DocumentStatusResponse { } // @public (undocumented) -export type DocumentTranslator = Client & { - path: Routes; -}; +function DocumentTranslator(endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslatorClient; -// @public (undocumented) -function DocumentTranslator_2(endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslator; +export default DocumentTranslator; -export default DocumentTranslator_2; +// @public (undocumented) +export type DocumentTranslatorClient = Client & { + path: Routes; +}; // @public (undocumented) export interface DocumentTranslatorFactory { diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index 2f0c82017b16..b821201d81f0 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { SubmitBatchRequestParameters, GetOperationsParameters, @@ -96,7 +99,7 @@ export interface GetOperations { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -181,7 +184,7 @@ export interface GetOperationDocumentsStatus { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -251,11 +254,11 @@ export interface GetDocumentStorageSource { export interface Routes { /** Resource for '/batches' has methods for the following verbs: post, get */ (path: "/batches"): GetOperations; - /** Resource for '/batches/{id}/documents/{documentId}' has methods for the following verbs: get */ + /** Resource for '/batches/\{id\}/documents/\{documentId\}' has methods for the following verbs: get */ (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; - /** Resource for '/batches/{id}' has methods for the following verbs: get, delete */ + /** Resource for '/batches/\{id\}' has methods for the following verbs: get, delete */ (path: "/batches/{id}", id: string): CancelOperation; - /** Resource for '/batches/{id}/documents' has methods for the following verbs: get */ + /** Resource for '/batches/\{id\}/documents' has methods for the following verbs: get */ (path: "/batches/{id}/documents", id: string): GetOperationDocumentsStatus; /** Resource for '/documents/formats' has methods for the following verbs: get */ (path: "/documents/formats"): GetDocumentFormats; @@ -265,7 +268,7 @@ export interface Routes { (path: "/storagesources"): GetDocumentStorageSource; } -export type DocumentTranslator = Client & { +export type DocumentTranslatorClient = Client & { path: Routes; }; @@ -277,7 +280,7 @@ export default function DocumentTranslator( endpoint: string, credentials: TokenCredential | KeyCredential, options: ClientOptions = {} -): DocumentTranslator { +): DocumentTranslatorClient { const baseUrl = options.baseUrl || "{endpoint}/translator/text/batch/v1.0-preview.1".replace(/{endpoint}/g, endpoint); @@ -289,5 +292,5 @@ export default function DocumentTranslator( } }; - return getClient(baseUrl, credentials, options) as DocumentTranslator; + return getClient(baseUrl, credentials, options) as DocumentTranslatorClient; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/index.ts b/sdk/documenttranslator/ai-document-translator-rest/src/index.ts index b4f5c01a926e..0f55ca1bc988 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/index.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/index.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import DocumentTranslator from "./documentTranslator"; export * from "./documentTranslator"; export * from "./models"; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/models.ts b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts index 1789ef0d000e..554b2da9b049 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/models.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts @@ -1,3 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. export interface BatchSubmissionRequest { /** The input list of documents or folders containing documents */ inputs: BatchRequest[]; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts index 830da04b960b..135be88f43fb 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { RequestParameters } from "@azure-rest/core-client"; import { BatchSubmissionRequest } from "./models"; @@ -27,7 +30,7 @@ export interface GetOperationsQueryParamProperties { */ $skip?: number; /** - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * Clients MAY request server-driven paging with a specific page size by specifying a $maxpagesize preference. The server SHOULD honor this preference if the specified page size is smaller than the server's default page size. */ @@ -73,7 +76,7 @@ export interface GetOperationDocumentsStatusQueryParamProperties { */ $skip?: number; /** - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * Clients MAY request server-driven paging with a specific page size by specifying a $maxpagesize preference. The server SHOULD honor this preference if the specified page size is smaller than the server's default page size. */ diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts index 0c0c153debfa..08aca340535b 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { ErrorResponseV2, BatchStatusResponse, @@ -129,7 +132,7 @@ export interface GetOperations200Headers { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -160,7 +163,7 @@ export interface GetOperations200Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -190,7 +193,7 @@ export interface GetOperations400Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -220,7 +223,7 @@ export interface GetOperations401Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -250,7 +253,7 @@ export interface GetOperations429Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -280,7 +283,7 @@ export interface GetOperations500Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -494,7 +497,7 @@ export interface GetOperationDocumentsStatus200Headers { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -522,7 +525,7 @@ export interface GetOperationDocumentsStatus200Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -549,7 +552,7 @@ export interface GetOperationDocumentsStatus400Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -576,7 +579,7 @@ export interface GetOperationDocumentsStatus401Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -603,7 +606,7 @@ export interface GetOperationDocumentsStatus404Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -630,7 +633,7 @@ export interface GetOperationDocumentsStatus429Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -657,7 +660,7 @@ export interface GetOperationDocumentsStatus500Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), @nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts b/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts index 3f5bc769ab8e..9a0da259f912 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts @@ -1,3 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + import { assert } from "chai"; describe("Test", () => { it("should pass", () => { From 85fd8b474d518ecf13c025d587bddea6458dc683 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Mon, 12 Apr 2021 22:35:50 +0000 Subject: [PATCH 11/37] Address PR feedback --- common/config/rush/pnpm-lock.yaml | 4 +-- sdk/core-rest/core-client/README.md | 2 +- .../core-client/review/core-client.api.md | 12 +++---- sdk/core-rest/core-client/src/common.ts | 8 +++-- sdk/core-rest/core-client/src/index.ts | 5 +++ .../core-client/src/pathClientTypes.ts | 7 +++- sdk/core-rest/core-client/src/sendRequest.ts | 9 +++--- sdk/core-rest/core-client/src/urlHelpers.ts | 6 +++- .../ai-document-translator-rest/karma.conf.js | 32 +++++++++---------- .../ai-document-translator-rest/package.json | 4 +-- .../review/ai-document-translator.api.md | 2 -- .../samples-dev/translateFromBlob.ts | 8 ++--- .../samples/v1/javascript/README.md | 4 +-- .../samples/v1/javascript/listFormats.js | 2 +- .../samples/v1/javascript/package.json | 2 +- .../v1/javascript/translateFromBlob.js | 9 ++++-- .../samples/v1/typescript/README.md | 4 +-- .../samples/v1/typescript/package.json | 2 +- .../samples/v1/typescript/src/listFormats.ts | 2 +- .../v1/typescript/src/translateFromBlob.ts | 17 ++++++---- .../src/documentTranslator.ts | 8 ++--- .../ai-document-translator-rest/src/index.ts | 5 +++ .../ai-document-translator-rest/src/models.ts | 1 + .../src/responses.ts | 28 ++++++++-------- 24 files changed, 104 insertions(+), 79 deletions(-) diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index c13e50a721eb..a2f67e5919fb 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -7838,7 +7838,7 @@ packages: mocha: 7.2.0 mocha-junit-reporter: 1.23.3_mocha@7.2.0 nyc: 14.1.1 - prettier: 1.19.1 + prettier: 2.2.1 rimraf: 3.0.2 rollup: 1.32.1 source-map-support: 0.5.19 @@ -7848,7 +7848,7 @@ packages: dev: false name: '@rush-temp/ai-document-translator' resolution: - integrity: sha512-rDLxnotxbZpbq8g1KSYqpzjyT0mll3vjeVUOQLTMjDQ3m5b+3nQqtoCgqIVja7pUGm5qkB7dJAkCK1JVAxR9Ig== + integrity: sha512-N6NditA1ysjzHQqcQQNyInb0nddtoPnjl35QJL/1DVeoAC8n5H1LgKGLWc39APweT1fn5+oO+1hjgK4vHd5uHA== tarball: file:projects/ai-document-translator.tgz version: 0.0.0 file:projects/ai-form-recognizer.tgz: diff --git a/sdk/core-rest/core-client/README.md b/sdk/core-rest/core-client/README.md index daa670fd9420..5189e059830e 100644 --- a/sdk/core-rest/core-client/README.md +++ b/sdk/core-rest/core-client/README.md @@ -1,4 +1,4 @@ -# Azure Core Service client library for JavaScript (Experimental) +# Azure Rest Core Client library for JavaScript (Experimental) This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript). Specifically for rest level clients diff --git a/sdk/core-rest/core-client/review/core-client.api.md b/sdk/core-rest/core-client/review/core-client.api.md index 14113a1f0007..1b843826a1ee 100644 --- a/sdk/core-rest/core-client/review/core-client.api.md +++ b/sdk/core-rest/core-client/review/core-client.api.md @@ -7,7 +7,7 @@ import { KeyCredential } from '@azure/core-auth'; import { Pipeline } from '@azure/core-rest-pipeline'; import { PipelineOptions } from '@azure/core-rest-pipeline'; -import { PipelineResponse } from '@azure/core-rest-pipeline'; +import { PipelineRequest } from '@azure/core-rest-pipeline'; import { RawHttpHeaders } from '@azure/core-rest-pipeline'; import { TokenCredential } from '@azure/core-auth'; @@ -45,7 +45,8 @@ export function getClient(baseUrl: string, options?: PipelineOptions): Client; export function getClient(baseUrl: string, credentials?: TokenCredential | KeyCredential, options?: PipelineOptions): Client; // @public -export type HttpResponse = Omit & { +export type HttpResponse = { + request: PipelineRequest; headers: RawHttpHeaders; body: unknown; status: string; @@ -59,10 +60,9 @@ export type PathUncheckedResponse = HttpResponse & { // @public export type RequestParameters = { headers?: RawHttpHeaders; + accept?: string; body?: unknown; - queryParameters?: { - [key: string]: any; - }; + queryParameters?: Record; contentType?: string; allowInsecureConnection?: boolean; }; @@ -71,6 +71,4 @@ export type RequestParameters = { export type RouteParams = TRoute extends `{${infer _Param}}/${infer Tail}` ? [pathParam: string, ...pathParams: RouteParams] : TRoute extends `{${infer _Param}}` ? [pathParam: string] : TRoute extends `${infer _Prefix}:${infer Tail}` ? RouteParams<`{${Tail}}`> : []; -// (No @packageDocumentation comment for this package) - ``` diff --git a/sdk/core-rest/core-client/src/common.ts b/sdk/core-rest/core-client/src/common.ts index 690030859d54..63e5dbbece3d 100644 --- a/sdk/core-rest/core-client/src/common.ts +++ b/sdk/core-rest/core-client/src/common.ts @@ -1,4 +1,4 @@ -import { PipelineOptions, RawHttpHeaders, PipelineResponse } from "@azure/core-rest-pipeline"; +import { PipelineOptions, RawHttpHeaders, PipelineRequest } from "@azure/core-rest-pipeline"; /** * General options that a Rest Level Client can take @@ -14,7 +14,11 @@ export type ClientOptions = PipelineOptions & { /** * Represents the shape of an HttpResponse */ -export type HttpResponse = Omit & { +export type HttpResponse = { + /** + * The request that generated this response. + */ + request: PipelineRequest; /** * The HTTP response headers. */ diff --git a/sdk/core-rest/core-client/src/index.ts b/sdk/core-rest/core-client/src/index.ts index f920da46cb97..060d5a49f5c1 100644 --- a/sdk/core-rest/core-client/src/index.ts +++ b/sdk/core-rest/core-client/src/index.ts @@ -1,3 +1,8 @@ +/** + * Azure Rest Core Client library for JavaScript + * @packageDocumentation + */ + export { createDefaultPipeline } from "./clientHelpers"; export * from "./common"; export * from "./getClient"; diff --git a/sdk/core-rest/core-client/src/pathClientTypes.ts b/sdk/core-rest/core-client/src/pathClientTypes.ts index 77a780300fe3..6ce3e28a0db8 100644 --- a/sdk/core-rest/core-client/src/pathClientTypes.ts +++ b/sdk/core-rest/core-client/src/pathClientTypes.ts @@ -9,6 +9,11 @@ export type RequestParameters = { * Headers to send along with the request */ headers?: RawHttpHeaders; + /** + * Sets the accept header to send to the service + * defaults to 'application/json' + */ + accept?: string; /** * Body to send with the request */ @@ -16,7 +21,7 @@ export type RequestParameters = { /** * Query parameters to send with the request */ - queryParameters?: { [key: string]: any }; + queryParameters?: Record; /** * Set an explicit content-type to send with the request */ diff --git a/sdk/core-rest/core-client/src/sendRequest.ts b/sdk/core-rest/core-client/src/sendRequest.ts index c11fa0556ddc..d581594056a7 100644 --- a/sdk/core-rest/core-client/src/sendRequest.ts +++ b/sdk/core-rest/core-client/src/sendRequest.ts @@ -25,14 +25,14 @@ export async function sendRequest( ): Promise { const httpClient = getCachedDefaultHttpsClient(); + const body = options.body !== undefined ? JSON.stringify(options.body) : undefined; + const headers = createHttpHeaders({ - accept: "application/json", - "content-type": options.contentType || getContentType(options.body), + ...(body !== undefined && { accept: options.accept ?? "application/json" }), + "content-type": options.contentType ?? getContentType(options.body), ...(options.headers ? options.headers : {}), }); - const body = JSON.stringify(options.body); - const request = createPipelineRequest({ url, method, @@ -53,7 +53,6 @@ export async function sendRequest( } return { - bodyAsText: result.bodyAsText, request, headers: rawHeaders, status: `${result.status}`, diff --git a/sdk/core-rest/core-client/src/urlHelpers.ts b/sdk/core-rest/core-client/src/urlHelpers.ts index 136e97ef4f39..07d201085fdb 100644 --- a/sdk/core-rest/core-client/src/urlHelpers.ts +++ b/sdk/core-rest/core-client/src/urlHelpers.ts @@ -29,7 +29,11 @@ export function buildRequestUrl( if (options.queryParameters) { const queryParams = options.queryParameters; for (const key of Object.keys(queryParams)) { - url.searchParams.append(key, queryParams[key]); + const param = queryParams[key] as any; + if (!param.toString || typeof param.toString !== "function") { + throw new Error(`Query parameters must be able to be represented as string, ${key} can't`); + } + url.searchParams.append(key, param.toString()); } } diff --git a/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js b/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js index 23a7f0ce2627..a123c1345a6c 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js +++ b/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js @@ -8,10 +8,10 @@ const { jsonRecordingFilterFunction, isPlaybackMode, isSoftRecordMode, - isRecordMode + isRecordMode, } = require("@azure/test-utils-recorder"); -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "./", @@ -33,13 +33,13 @@ module.exports = function(config) { "karma-junit-reporter", "karma-json-to-file-reporter", "karma-source-map-support", - "karma-json-preprocessor" + "karma-json-preprocessor", ], // 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 } + { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true }, ].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []), // list of files / patterns to exclude @@ -49,7 +49,7 @@ module.exports = function(config) { // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { "**/*.js": ["sourcemap", "env"], - "recordings/browsers/**/*.json": ["json"] + "recordings/browsers/**/*.json": ["json"], // 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"] @@ -62,7 +62,7 @@ module.exports = function(config) { "TEXT_ANALYTICS_API_KEY_ALT", "AZURE_CLIENT_ID", "AZURE_CLIENT_SECRET", - "AZURE_TENANT_ID" + "AZURE_TENANT_ID", ], // test results reporter to use @@ -77,8 +77,8 @@ module.exports = function(config) { { type: "json", subdir: ".", file: "coverage.json" }, { type: "lcovonly", subdir: ".", file: "lcov.info" }, { type: "html", subdir: "html" }, - { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" } - ] + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], }, junitReporter: { @@ -88,12 +88,12 @@ module.exports = function(config) { 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 + properties: {}, // key value pair of properties to add to the section of the report }, jsonToFileReporter: { filter: jsonRecordingFilterFunction, - outputPath: "." + outputPath: ".", }, // web server port @@ -115,8 +115,8 @@ module.exports = function(config) { customLaunchers: { ChromeHeadlessNoSandbox: { base: "ChromeHeadless", - flags: ["--no-sandbox", "--disable-web-security"] - } + flags: ["--no-sandbox", "--disable-web-security"], + }, }, // Continuous Integration mode @@ -131,15 +131,15 @@ module.exports = function(config) { browserDisconnectTimeout: 10000, browserDisconnectTolerance: 3, browserConsoleLogOptions: { - terminal: !isRecordMode() + terminal: !isRecordMode(), }, client: { mocha: { // change Karma's debug.html to the mocha web reporter reporter: "html", - timeout: 0 - } - } + timeout: 0, + }, + }, }); }; diff --git a/sdk/documenttranslator/ai-document-translator-rest/package.json b/sdk/documenttranslator/ai-document-translator-rest/package.json index 01470f735871..4db565f15e8f 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/package.json @@ -40,7 +40,7 @@ "node": ">=8.0.0" }, "//sampleConfiguration": { - "productName": "Azure Document Translator", + "productName": "Azure Document Translator rest", "productSlugs": [ "azure", "azure-cognitive-services", @@ -94,7 +94,7 @@ "dotenv": "^8.2.0", "@types/node": "^8.0.0", "eslint": "^7.15.0", - "prettier": "^1.16.4", + "prettier": "2.2.1", "rollup": "^1.16.3", "source-map-support": "^0.5.9", "typescript": "~4.2.0", diff --git a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md index ab9395956810..c822ac545d81 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md +++ b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md @@ -740,6 +740,4 @@ export interface TargetInput { } -// (No @packageDocumentation comment for this package) - ``` diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts index a60f90e65930..08e0f734ad32 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts @@ -44,9 +44,9 @@ const batchSubmissionRequest: BatchSubmissionRequest = { inputs: [ { source: { sourceUrl: sourceContainer }, - targets: [{ language: "fr", targetUrl: targetContainer }] - } - ] + targets: [{ language: "fr", targetUrl: targetContainer }], + }, + ], }; export async function main() { @@ -57,7 +57,7 @@ export async function main() { // Call the /batches path to initiate the translation job const formats = await client.path("/batches").post({ - body: batchSubmissionRequest + body: batchSubmissionRequest, }); // If we get a non-success status code, throw an error diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md index 63ae00cc17c7..980f48fe5aaa 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md @@ -10,9 +10,9 @@ urlFragment: ai-document-translator-javascript disableDocsMs: true --- -# Azure Document Translator client library samples for JavaScript +# Azure Document Translator rest client library samples for JavaScript -These sample programs show how to use the JavaScript client libraries for Azure Document Translator in some common scenarios. +These sample programs show how to use the JavaScript client libraries for Azure Document Translator rest in some common scenarios. | **File Name** | **Description** | | ----------------------------------------- | --------------------------------------------- | diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/listFormats.js b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/listFormats.js index 2ac681765c59..ec87c13ba91b 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/listFormats.js +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/listFormats.js @@ -22,7 +22,7 @@ async function main() { const client = DocumentTranslator(endpoint, { key: apiKey }); const formats = await client.path("/documents/formats").get(); - if (formats.status !== 200) { + if (formats.status !== "200") { throw formats.body.error; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/package.json b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/package.json index 6e6ac20f77a5..5d7803d1ad10 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/package.json @@ -2,7 +2,7 @@ "name": "azure-ai-document-translator-samples-js", "private": true, "version": "1.0.0", - "description": "Azure Document Translator client library samples for JavaScript", + "description": "Azure Document Translator rest client library samples for JavaScript", "engine": { "node": ">=12.0.0" }, diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/translateFromBlob.js b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/translateFromBlob.js index c4e4d3ca8e51..4f3a3602c999 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/translateFromBlob.js +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/translateFromBlob.js @@ -4,9 +4,12 @@ /** * This sample demonstrates how translate a colletion of documents stored in a Azure Storage Blob container * and output the translated documents to another container. + * * Translating documents is considered a Long Running Operation because it may take a long time to complete, * specially if translating large files or a batch with several files. + * * To handle these long running operations we need to call a few different endpoints, to track the status of the operation + * * @summary translates a collection of documents */ @@ -57,7 +60,7 @@ async function main() { }); // If we get a non-success status code, throw an error - if (formats.status !== 202) { + if (formats.status !== "202") { throw formats.body.error; } @@ -80,7 +83,7 @@ async function main() { operationState = await checkStatus.get(); // If we get a non-success status code, throw the error - if (operationState.status !== 200) { + if (operationState.status !== "200") { throw operationState.body.error; } @@ -94,7 +97,7 @@ async function main() { // Now that the operation is complete, we can list the translated documents const documents = await client.path("/batches/{id}/documents", batchId).get(); - if (documents.status !== 200) { + if (documents.status !== "200") { throw documents.body.error; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md index e48808174213..d1d87b925161 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md @@ -10,9 +10,9 @@ urlFragment: ai-document-translator-typescript disableDocsMs: true --- -# Azure Document Translator client library samples for TypeScript +# Azure Document Translator rest client library samples for TypeScript -These sample programs show how to use the TypeScript client libraries for Azure Document Translator in some common scenarios. +These sample programs show how to use the TypeScript client libraries for Azure Document Translator rest in some common scenarios. | **File Name** | **Description** | | ----------------------------------------- | --------------------------------------------- | diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/package.json b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/package.json index c7ba10223e05..9bb6ff39c404 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/package.json @@ -2,7 +2,7 @@ "name": "azure-ai-document-translator-samples-ts", "private": true, "version": "1.0.0", - "description": "Azure Document Translator client library samples for TypeScript", + "description": "Azure Document Translator rest client library samples for TypeScript", "engine": { "node": ">=12.0.0" }, diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/listFormats.ts b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/listFormats.ts index 0baaaf7f8067..e6ad05e13f3b 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/listFormats.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/listFormats.ts @@ -22,7 +22,7 @@ export async function main() { const client = DocumentTranslator(endpoint, { key: apiKey }); const formats = await client.path("/documents/formats").get(); - if (formats.status !== 200) { + if (formats.status !== "200") { throw formats.body.error; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts index c2a863a3db53..b32584d53f36 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts @@ -4,9 +4,12 @@ /** * This sample demonstrates how translate a colletion of documents stored in a Azure Storage Blob container * and output the translated documents to another container. + * * Translating documents is considered a Long Running Operation because it may take a long time to complete, * specially if translating large files or a batch with several files. + * * To handle these long running operations we need to call a few different endpoints, to track the status of the operation + * * @summary translates a collection of documents */ @@ -40,9 +43,9 @@ const batchSubmissionRequest: BatchSubmissionRequest = { inputs: [ { source: { sourceUrl: sourceContainer }, - targets: [{ language: "fr", targetUrl: targetContainer }] - } - ] + targets: [{ language: "fr", targetUrl: targetContainer }], + }, + ], }; export async function main() { @@ -53,11 +56,11 @@ export async function main() { // Call the /batches path to initiate the translation job const formats = await client.path("/batches").post({ - body: batchSubmissionRequest + body: batchSubmissionRequest, }); // If we get a non-success status code, throw an error - if (formats.status !== 202) { + if (formats.status !== "202") { throw formats.body.error; } @@ -80,7 +83,7 @@ export async function main() { operationState = await checkStatus.get(); // If we get a non-success status code, throw the error - if (operationState.status !== 200) { + if (operationState.status !== "200") { throw operationState.body.error; } @@ -94,7 +97,7 @@ export async function main() { // Now that the operation is complete, we can list the translated documents const documents = await client.path("/batches/{id}/documents", batchId).get(); - if (documents.status !== 200) { + if (documents.status !== "200") { throw documents.body.error; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index b821201d81f0..0cb6f0946a73 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -10,7 +10,7 @@ import { GetOperationDocumentsStatusParameters, GetDocumentFormatsParameters, GetGlossaryFormatsParameters, - GetDocumentStorageSourceParameters + GetDocumentStorageSourceParameters, } from "./parameters"; import { SubmitBatchRequest202Response, @@ -61,7 +61,7 @@ import { GetDocumentStorageSource200Response, GetDocumentStorageSource429Response, GetDocumentStorageSource500Response, - GetDocumentStorageSource503Response + GetDocumentStorageSource503Response, } from "./responses"; import { getClient, ClientOptions, Client } from "@azure-rest/core-client"; import { KeyCredential, TokenCredential } from "@azure/core-auth"; @@ -288,8 +288,8 @@ export default function DocumentTranslator( ...options, credentials: { scopes: ["https://cognitiveservices.azure.com/.default"], - apiKeyHeaderName: "Ocp-Apim-Subscription-Key" - } + apiKeyHeaderName: "Ocp-Apim-Subscription-Key", + }, }; return getClient(baseUrl, credentials, options) as DocumentTranslatorClient; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/index.ts b/sdk/documenttranslator/ai-document-translator-rest/src/index.ts index 0f55ca1bc988..8292d658ba6f 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/index.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/index.ts @@ -1,6 +1,11 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. +/** + * A rest library for working with the Azure Document Translator service. + * @packageDocumentation + */ + import DocumentTranslator from "./documentTranslator"; export * from "./documentTranslator"; export * from "./models"; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/models.ts b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts index 554b2da9b049..ef7a33de60a9 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/models.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts @@ -1,5 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. + export interface BatchSubmissionRequest { /** The input list of documents or folders containing documents */ inputs: BatchRequest[]; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts index 08aca340535b..15bc00f34040 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts @@ -8,7 +8,7 @@ import { BatchStatusDetail, DocumentStatusResponse, FileFormatListResult, - StorageSourceListResult + StorageSourceListResult, } from "./models"; import { HttpResponse } from "@azure-rest/core-client"; import { RawHttpHeaders } from "@azure/core-rest-pipeline"; @@ -132,7 +132,7 @@ export interface GetOperations200Headers { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -163,7 +163,7 @@ export interface GetOperations200Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -193,7 +193,7 @@ export interface GetOperations400Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -223,7 +223,7 @@ export interface GetOperations401Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -253,7 +253,7 @@ export interface GetOperations429Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -283,7 +283,7 @@ export interface GetOperations500Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of batches based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -497,7 +497,7 @@ export interface GetOperationDocumentsStatus200Headers { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -525,7 +525,7 @@ export interface GetOperationDocumentsStatus200Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -552,7 +552,7 @@ export interface GetOperationDocumentsStatus400Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -579,7 +579,7 @@ export interface GetOperationDocumentsStatus401Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -606,7 +606,7 @@ export interface GetOperationDocumentsStatus404Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -633,7 +633,7 @@ export interface GetOperationDocumentsStatus429Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. @@ -660,7 +660,7 @@ export interface GetOperationDocumentsStatus500Response extends HttpResponse { * * $top indicates the total number of records the user wants to be returned across all pages. * $skip indicates the number of records to skip from the list of document status held by the server based on the sorting method specified. By default, we sort by descending start time. - * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. + * $maxpagesize is the maximum items returned in a page. If more items are requested via $top (or $top is not specified and there are more items to be returned), \@nextLink will contain the link to the next page. * * $orderBy query parameter can be used to sort the returned list (ex "$orderBy=createdDateTimeUtc asc" or "$orderBy=createdDateTimeUtc desc"). * The default sorting is descending by createdDateTimeUtc. From 7621ae0dd87a40645edf0747a4cbe6683d75ce91 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Mon, 12 Apr 2021 22:42:57 +0000 Subject: [PATCH 12/37] Interpolate path param --- .../ai-document-translator-rest/src/documentTranslator.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index 0cb6f0946a73..0bb9a4b35315 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -281,9 +281,7 @@ export default function DocumentTranslator( credentials: TokenCredential | KeyCredential, options: ClientOptions = {} ): DocumentTranslatorClient { - const baseUrl = - options.baseUrl || - "{endpoint}/translator/text/batch/v1.0-preview.1".replace(/{endpoint}/g, endpoint); + const baseUrl = options.baseUrl ?? `${endpoint}/translator/text/batch/v1.0-preview.1`; options = { ...options, credentials: { From 5a3492dee714d84107fd95b8fc0add74085f1f2f Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Mon, 12 Apr 2021 22:53:17 +0000 Subject: [PATCH 13/37] Remove eslint changes --- .../src/rules/ts-package-json-name.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-name.ts b/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-name.ts index 86c017f525f5..5184efb8d35f 100644 --- a/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-name.ts +++ b/common/tools/eslint-plugin-azure-sdk/src/rules/ts-package-json-name.ts @@ -18,7 +18,7 @@ import { stripFileName } from "../utils/verifiers"; export = { meta: getRuleMetaData( "ts-package-json-name", - "force package.json's name value to be set to @azure/ or @azure-/" + "force package.json's name value to be set to @azure/" ), create: (context: Rule.RuleContext): Rule.RuleListener => { const verifiers = getVerifiers(context, { @@ -32,24 +32,24 @@ export = { // check to see if name exists at the outermost level "ExpressionStatement > ObjectExpression": verifiers.existsInFile, - // check the node corresponding to name to see if its value is @azure/ or @azure-/ + // check the node corresponding to name to see if its value is @azure/ "ExpressionStatement > ObjectExpression > Property[key.value='name']": ( node: Property ): void => { const nodeValue = node.value as Literal; const name = nodeValue.value as string; - if (!/^@azure(-[a-z]+)?\//.test(name)) { + if (!name.startsWith("@azure/")) { context.report({ node: nodeValue, - message: "name is not set to @azure/ or @azure-/" + message: "name is not set to @azure/" }); return; } const packageDirectory = stripPath(stripFileName(fileName)); const packageBaseName = stripPath(name); - if (!/^@azure(-[a-z]+)?\/([a-z]+-)*[a-z]+$/.test(name)) { + if (!/^@azure\/([a-z]+-)*[a-z]+$/.test(name)) { context.report({ node: nodeValue, message: "service name is not in kebab-case (lowercase and separated by hyphens)" From 9c42550756ebcc40589cc1321a3c9f0ccdafae31 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Mon, 12 Apr 2021 23:18:51 +0000 Subject: [PATCH 14/37] Fix readme --- sdk/documenttranslator/ai-document-translator-rest/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/README.md b/sdk/documenttranslator/ai-document-translator-rest/README.md index cf92183ff51c..4f7ceccb570b 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/README.md @@ -1,4 +1,4 @@ -# Azure Document Translator Rest-Level library for JavaScript +# Azure Document Translator Rest-Level client library for JavaScript [Azure Document Translator](https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview) is a cloud-based feature of the Azure Translator service and is part of the Azure Cognitive Service family of REST APIs. The Document Translation API translates documents to and from 90 languages and dialects while preserving document structure and data format. From 00c932f0ab09441a6720fab70bc106d9d65219b5 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 00:02:54 +0000 Subject: [PATCH 15/37] Add sanity test for DocumentTranslator --- .../ai-document-translator-rest/karma.conf.js | 40 +++++++--------- .../ai-document-translator-rest/package.json | 34 +++++++------ ...d_list_all_available_document_formats.json | 32 +++++++++++++ ...uld_list_all_available_document_formats.js | 40 ++++++++++++++++ .../swagger/README.md | 2 + .../test/public/listFormats.spec.ts | 33 +++++++++++++ .../test/public/utils/env.browser.ts | 2 + .../test/public/utils/env.ts | 6 +++ .../test/public/utils/recordedClient.ts | 48 +++++++++++++++++++ .../test/test.spec.ts | 9 ---- 10 files changed, 198 insertions(+), 48 deletions(-) create mode 100644 sdk/documenttranslator/ai-document-translator-rest/recordings/browsers/list_document_formats/recording_should_list_all_available_document_formats.json create mode 100644 sdk/documenttranslator/ai-document-translator-rest/recordings/node/list_document_formats/recording_should_list_all_available_document_formats.js create mode 100644 sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts create mode 100644 sdk/documenttranslator/ai-document-translator-rest/test/public/utils/env.browser.ts create mode 100644 sdk/documenttranslator/ai-document-translator-rest/test/public/utils/env.ts create mode 100644 sdk/documenttranslator/ai-document-translator-rest/test/public/utils/recordedClient.ts delete mode 100644 sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts diff --git a/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js b/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js index a123c1345a6c..0006573963a0 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js +++ b/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js @@ -8,10 +8,10 @@ const { jsonRecordingFilterFunction, isPlaybackMode, isSoftRecordMode, - isRecordMode, + isRecordMode } = require("@azure/test-utils-recorder"); -module.exports = function (config) { +module.exports = function(config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "./", @@ -33,13 +33,13 @@ module.exports = function (config) { "karma-junit-reporter", "karma-json-to-file-reporter", "karma-source-map-support", - "karma-json-preprocessor", + "karma-json-preprocessor" ], // 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 }, + { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true } ].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []), // list of files / patterns to exclude @@ -49,21 +49,13 @@ module.exports = function (config) { // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { "**/*.js": ["sourcemap", "env"], - "recordings/browsers/**/*.json": ["json"], + "recordings/browsers/**/*.json": ["json"] // 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", - "TEXT_ANALYTICS_API_KEY", - "TEXT_ANALYTICS_API_KEY_ALT", - "AZURE_CLIENT_ID", - "AZURE_CLIENT_SECRET", - "AZURE_TENANT_ID", - ], + envPreprocessor: ["TEST_MODE", "ENDPOINT", "DOCUMENT_TRANSLATOR_API_KEY"], // test results reporter to use // possible values: 'dots', 'progress' @@ -77,8 +69,8 @@ module.exports = function (config) { { type: "json", subdir: ".", file: "coverage.json" }, { type: "lcovonly", subdir: ".", file: "lcov.info" }, { type: "html", subdir: "html" }, - { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, - ], + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" } + ] }, junitReporter: { @@ -88,12 +80,12 @@ module.exports = function (config) { 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 + properties: {} // key value pair of properties to add to the section of the report }, jsonToFileReporter: { filter: jsonRecordingFilterFunction, - outputPath: ".", + outputPath: "." }, // web server port @@ -115,8 +107,8 @@ module.exports = function (config) { customLaunchers: { ChromeHeadlessNoSandbox: { base: "ChromeHeadless", - flags: ["--no-sandbox", "--disable-web-security"], - }, + flags: ["--no-sandbox", "--disable-web-security"] + } }, // Continuous Integration mode @@ -131,15 +123,15 @@ module.exports = function (config) { browserDisconnectTimeout: 10000, browserDisconnectTolerance: 3, browserConsoleLogOptions: { - terminal: !isRecordMode(), + terminal: !isRecordMode() }, client: { mocha: { // change Karma's debug.html to the mocha web reporter reporter: "html", - timeout: 0, - }, - }, + timeout: 0 + } + } }); }; diff --git a/sdk/documenttranslator/ai-document-translator-rest/package.json b/sdk/documenttranslator/ai-document-translator-rest/package.json index 4db565f15e8f..593c30be3e3c 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/package.json @@ -50,6 +50,9 @@ "Azure Cognitive Services instance": "https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account" } }, + "browser": { + "./dist-esm/test/public/utils/env.js": "./dist-esm/test/public/utils/env.browser.js" + }, "scripts": { "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1", @@ -90,17 +93,16 @@ "devDependencies": { "@azure/dev-tool": "^1.0.0", "@azure/eslint-plugin-azure-sdk": "^3.0.0", + "@azure/identity": "^1.1.0", + "@azure/test-utils-recorder": "^1.0.0", "@microsoft/api-extractor": "7.13.2", - "dotenv": "^8.2.0", + "@types/chai": "^4.1.6", + "@types/mocha": "^7.0.2", "@types/node": "^8.0.0", + "chai": "^4.2.0", + "cross-env": "^7.0.2", + "dotenv": "^8.2.0", "eslint": "^7.15.0", - "prettier": "2.2.1", - "rollup": "^1.16.3", - "source-map-support": "^0.5.9", - "typescript": "~4.2.0", - "typedoc": "0.15.2", - "@types/mocha": "^7.0.2", - "karma": "^6.2.0", "karma-chrome-launcher": "^3.0.0", "karma-coverage": "^2.0.0", "karma-edge-launcher": "^0.4.2", @@ -110,17 +112,19 @@ "karma-json-preprocessor": "^0.3.3", "karma-json-to-file-reporter": "^1.0.1", "karma-junit-reporter": "^2.0.1", - "karma-mocha": "^2.0.1", "karma-mocha-reporter": "^2.2.5", - "karma-sourcemap-loader": "^0.3.8", + "karma-mocha": "^2.0.1", "karma-source-map-support": "~1.4.0", - "mocha": "^7.1.1", + "karma-sourcemap-loader": "^0.3.8", + "karma": "^6.2.0", "mocha-junit-reporter": "^1.18.0", + "mocha": "^7.1.1", "nyc": "^14.0.0", - "chai": "^4.2.0", - "cross-env": "^7.0.2", - "@types/chai": "^4.1.6", + "prettier": "2.2.1", "rimraf": "^3.0.0", - "@azure/test-utils-recorder": "^1.0.0" + "rollup": "^1.16.3", + "source-map-support": "^0.5.9", + "typedoc": "0.15.2", + "typescript": "~4.2.0" } } diff --git a/sdk/documenttranslator/ai-document-translator-rest/recordings/browsers/list_document_formats/recording_should_list_all_available_document_formats.json b/sdk/documenttranslator/ai-document-translator-rest/recordings/browsers/list_document_formats/recording_should_list_all_available_document_formats.json new file mode 100644 index 000000000000..bb582338eb6a --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/recordings/browsers/list_document_formats/recording_should_list_all_available_document_formats.json @@ -0,0 +1,32 @@ +{ + "recordings": [ + { + "method": "GET", + "url": "https://endpoint/translator/text/batch/v1.0-preview.1/documents/formats", + "query": {}, + "requestBody": null, + "status": 200, + "response": "{\"value\":[{\"format\":\"PlainText\",\"fileExtensions\":[\".txt\"],\"contentTypes\":[\"text/plain\"],\"versions\":[]},{\"format\":\"OpenXmlWord\",\"fileExtensions\":[\".docx\"],\"contentTypes\":[\"application/vnd.openxmlformats-officedocument.wordprocessingml.document\"],\"versions\":[]},{\"format\":\"OpenXmlPresentation\",\"fileExtensions\":[\".pptx\"],\"contentTypes\":[\"application/vnd.openxmlformats-officedocument.presentationml.presentation\"],\"versions\":[]},{\"format\":\"OpenXmlSpreadsheet\",\"fileExtensions\":[\".xlsx\"],\"contentTypes\":[\"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\"],\"versions\":[]},{\"format\":\"OutlookMailMessage\",\"fileExtensions\":[\".msg\"],\"contentTypes\":[\"application/vnd.ms-outlook\"],\"versions\":[]},{\"format\":\"HtmlFile\",\"fileExtensions\":[\".html\",\".htm\"],\"contentTypes\":[\"text/html\"],\"versions\":[]},{\"format\":\"PortableDocumentFormat\",\"fileExtensions\":[\".pdf\"],\"contentTypes\":[\"application/pdf\"],\"versions\":[]},{\"format\":\"XLIFF\",\"fileExtensions\":[\".xlf\"],\"contentTypes\":[\"application/xliff+xml\"],\"versions\":[\"1.0\",\"1.1\",\"1.2\"]},{\"format\":\"TSV\",\"fileExtensions\":[\".tsv\",\".tab\"],\"contentTypes\":[\"text/tab-separated-values\"],\"versions\":[]},{\"format\":\"CSV\",\"fileExtensions\":[\".csv\"],\"contentTypes\":[\"text/csv\"],\"versions\":[]},{\"format\":\"RichTextFormat\",\"fileExtensions\":[\".rtf\"],\"contentTypes\":[\"application/rtf\"],\"versions\":[]},{\"format\":\"WordDocument\",\"fileExtensions\":[\".doc\"],\"contentTypes\":[\"application/msword\"],\"versions\":[]},{\"format\":\"PowerpointPresentation\",\"fileExtensions\":[\".ppt\"],\"contentTypes\":[\"application/vnd.ms-powerpoint\"],\"versions\":[]},{\"format\":\"ExcelSpreadsheet\",\"fileExtensions\":[\".xls\"],\"contentTypes\":[\"application/vnd.ms-excel\"],\"versions\":[]},{\"format\":\"OpenDocumentText\",\"fileExtensions\":[\".odt\"],\"contentTypes\":[\"application/vnd.oasis.opendocument.text\"],\"versions\":[]},{\"format\":\"OpenDocumentPresentation\",\"fileExtensions\":[\".odp\"],\"contentTypes\":[\"application/vnd.oasis.opendocument.presentation\"],\"versions\":[]},{\"format\":\"OpenDocumentSpreadsheet\",\"fileExtensions\":[\".ods\"],\"contentTypes\":[\"application/vnd.oasis.opendocument.spreadsheet\"],\"versions\":[]}]}", + "responseHeaders": { + "apim-request-id": "d34d7507-17cb-42c1-9e44-d9601a08c143", + "cache-control": "public,max-age=1", + "content-encoding": "gzip", + "content-type": "application/json; charset=utf-8", + "date": "Tue, 13 Apr 2021 00:01:11 GMT", + "etag": "\"44A88B37BE223B6C068718250B179D652514ABB810E8DD9DCD271B2759493859\"", + "retry-after": "1", + "strict-transport-security": "max-age=31536000; includeSubDomains; preload", + "transfer-encoding": "chunked", + "vary": "Accept-Encoding", + "x-content-type-options": "nosniff", + "x-powered-by": "ASP.NET", + "x-requestid": "d34d7507-17cb-42c1-9e44-d9601a08c143" + } + } + ], + "uniqueTestInfo": { + "uniqueName": {}, + "newDate": {} + }, + "hash": "d092f9b6f1e00f195619b98a389ccd32" +} \ No newline at end of file diff --git a/sdk/documenttranslator/ai-document-translator-rest/recordings/node/list_document_formats/recording_should_list_all_available_document_formats.js b/sdk/documenttranslator/ai-document-translator-rest/recordings/node/list_document_formats/recording_should_list_all_available_document_formats.js new file mode 100644 index 000000000000..8ea5c320f6b6 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/recordings/node/list_document_formats/recording_should_list_all_available_document_formats.js @@ -0,0 +1,40 @@ +let nock = require('nock'); + +module.exports.hash = "0ca3e29b892f5298b8efa775881d1dbb"; + +module.exports.testInfo = {"uniqueName":{},"newDate":{}} + +nock('https://endpoint', {"encodedQueryParams":true}) + .get('/translator/text/batch/v1.0-preview.1/documents/formats') + .reply(200, ["1f8b0800000000000400ad55514fc23010fe2f7d1586f8c8ab42349148842889e1a1ae3768ecd6a62d6386f0dfbd6e0c31ac5b35be6cd9eeeefbbededdbeed494ec516c8e86d4f12a9536ac988cc04e5d9020a4b7a24e102c68585cc709919cc2391c5c0aa476299e16bbbf85450beb7583050aed44573d075c5ead03b037f52902d53f12a356b8667322e9af0a95282c7d462e220cf582411a84845056cfa3249780c58bc4db12ada21bed232066378b64e45544742c4cd34184c2db99a452a65ff41a43ae34189e78f2132e7584099d90078265508f30f2acd370d8aace85ad56dad90f2634ab99862fbe91a9ad5a5661d222e454115622beb3d8a9b204933d706a3187177efee96396d1433a92d7d177077eccca40a342f084bba0e774cf1d22d1f1f2613df603bd10bc193e4aab838121946d7083a8c86e5f586fc245dcc5f3c5fbdc95d03b101de0662ac6f40514d2db07e692ca6f584b73eb218c97c2cc79817f499c71b675e6dd3d1b6b37fc7142f8d33b07a11bc46d645921ae7531d4bb703ad24cf6c902b057e51ea84da4a3e2e6208b299405a70789dd656b7d5ff0b922ce8a0921a6e4a773b99995ba16001dd1d974cfd51c8afccbe16d4390ac98246d1a0e7cce52fe4ac0e5fdc22565b28080000"], [ + 'Cache-Control', + 'public,max-age=1', + 'Transfer-Encoding', + 'chunked', + 'Content-Type', + 'application/json; charset=utf-8', + 'Content-Encoding', + 'gzip', + 'ETag', + '"44A88B37BE223B6C068718250B179D652514ABB810E8DD9DCD271B2759493859"', + 'Retry-After', + '1', + 'Vary', + 'Accept-Encoding', + 'X-RequestId', + 'dcee9cb2-e45a-47f0-bd44-0c38c03ed251', + 'Set-Cookie', + 'ARRAffinity=5dd610bbbfcdcce1e8b7e036dad4b7c92b91df5adc2f4b536e67d2a5eff0940e;Path=/;HttpOnly;Secure;Domain=doctrans.westus.microsofttranslator.com', + 'Set-Cookie', + 'ARRAffinitySameSite=5dd610bbbfcdcce1e8b7e036dad4b7c92b91df5adc2f4b536e67d2a5eff0940e;Path=/;HttpOnly;SameSite=None;Secure;Domain=doctrans.westus.microsofttranslator.com', + 'X-Powered-By', + 'ASP.NET', + 'apim-request-id', + 'dcee9cb2-e45a-47f0-bd44-0c38c03ed251', + 'Strict-Transport-Security', + 'max-age=31536000; includeSubDomains; preload', + 'x-content-type-options', + 'nosniff', + 'Date', + 'Tue, 13 Apr 2021 00:01:09 GMT' +]); diff --git a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md index de382a528dba..7eb3dd136ee5 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md @@ -19,4 +19,6 @@ low-level-client: true add-credentials: true credential-scopes: "https://cognitiveservices.azure.com/.default" credential-key-header-name: "Ocp-Apim-Subscription-Key" +use-extension: + "@autorest/typescript": "~/projects/autorest.typescript" ``` diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts b/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts new file mode 100644 index 000000000000..990ff5664dc3 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. +import { DocumentTranslatorClient } from "../../src"; +import { Recorder } from "@azure/test-utils-recorder"; + +import { assert } from "chai"; +import { createClient, createRecorder } from "./utils/recordedClient"; +import { Context } from "mocha"; +import { fail } from "assert"; + +describe("List Document Formats", () => { + let recorder: Recorder; + let client: DocumentTranslatorClient; + + beforeEach(function(this: Context) { + recorder = createRecorder(this); + client = createClient(); + }); + + afterEach(async function() { + await recorder.stop(); + }); + + it("should list all available document formats", async () => { + const result = await client.path("/documents/formats").get(); + + if (result.status !== "200") { + fail(`GET "/documents/formats" failed with ${result.status}`); + } + + assert.equal(result.body.value.length, 17); + }); +}); diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/env.browser.ts b/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/env.browser.ts new file mode 100644 index 000000000000..fd2aca680c7b --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/env.browser.ts @@ -0,0 +1,2 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/env.ts b/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/env.ts new file mode 100644 index 000000000000..0e06855b73ae --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/env.ts @@ -0,0 +1,6 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +import * as dotenv from "dotenv"; + +dotenv.config(); diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/recordedClient.ts b/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..b58bad58ced1 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/recordedClient.ts @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +/// + +import { Context } from "mocha"; + +import { env, Recorder, record, RecorderEnvironmentSetup } from "@azure/test-utils-recorder"; +import DocumentTranslator, { DocumentTranslatorClient } from "../../../src"; + +import "./env"; +import { ClientOptions } from "@azure-rest/core-client"; + +const replaceableVariables: { [k: string]: string } = { + DOCUMENT_TRANSLATOR_API_KEY: "api_key", + ENDPOINT: "https://endpoint/" +}; + +export const environmentSetup: RecorderEnvironmentSetup = { + replaceableVariables, + customizationsOnRecordings: [ + (recording: string): string => + recording.replace(/"access_token"\s?:\s?"[^"]*"/g, `"access_token":"access_token"`), + // If we put ENDPOINT in replaceableVariables above, it will not capture + // the endpoint string used with nock, which will be expanded to + // https://:443/ and therefore will not match, so we have to do + // this instead. + (recording: string): string => { + const replaced = recording.replace("endpoint:443", "endpoint"); + return replaced; + } + ], + queryParametersToSkip: [] +}; + +export function createClient(options?: ClientOptions): DocumentTranslatorClient { + let credential = { key: env.DOCUMENT_TRANSLATOR_API_KEY }; + return DocumentTranslator(env.ENDPOINT, credential, options); +} + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export function createRecorder(context: Context): Recorder { + return record(context, environmentSetup); +} diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts b/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts deleted file mode 100644 index 9a0da259f912..000000000000 --- a/sdk/documenttranslator/ai-document-translator-rest/test/test.spec.ts +++ /dev/null @@ -1,9 +0,0 @@ -// Copyright (c) Microsoft Corporation. -// Licensed under the MIT license. - -import { assert } from "chai"; -describe("Test", () => { - it("should pass", () => { - assert.equal(1, 1); - }); -}); From 5040779819484e8da0590f8f55588a351dbd053f Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 00:24:25 +0000 Subject: [PATCH 16/37] Add clientHelpers unit test --- sdk/core-rest/core-client/package.json | 15 ++-- .../core-client/test/clientHelpers.spec.ts | 87 +++++++++++++++++++ sdk/core-rest/core-client/test/test.spec.ts | 6 -- 3 files changed, 92 insertions(+), 16 deletions(-) create mode 100644 sdk/core-rest/core-client/test/clientHelpers.spec.ts delete mode 100644 sdk/core-rest/core-client/test/test.spec.ts diff --git a/sdk/core-rest/core-client/package.json b/sdk/core-rest/core-client/package.json index a4299566e9fd..96338f3d9089 100644 --- a/sdk/core-rest/core-client/package.json +++ b/sdk/core-rest/core-client/package.json @@ -14,14 +14,9 @@ "build:browser": "npm run build:ts && cross-env ONLY_BROWSER=true rollup -c 2>&1", "build:node": "npm run build:ts && cross-env ONLY_NODE=true rollup -c 2>&1", "build:samples": "echo Skipped.", - "build:test": "npm run build:ts && npm run bundle:test", - "build:test:browser": "npm run build:ts && npm run bundle:test:browser", - "build:test:node": "npm run build:ts && npm run bundle:test:node", + "build:test": "tsc -p . && rollup -c 2>&1", "build:ts": "tsc -p .", "build": "npm run build:ts && rollup -c 2>&1 && api-extractor run --local", - "bundle:test": "tsc -p . && rollup -c 2>&1", - "bundle:test:browser": "cross-env ONLY_BROWSER=true rollup -c rollup.test.config.js 2>&1", - "bundle:test:node": "cross-env ONLY_NODE=true rollup -c rollup.test.config.js 2>&1", "check-format": "prettier --list-different \"src/**/*.ts\" \"test/**/*.ts\" \"*.{js,json}\"", "clean": "rimraf dist dist-* types *.tgz *.log", "execute:samples": "echo skipped", @@ -34,11 +29,11 @@ "lint": "eslint package.json api-extractor.json src test --ext .ts", "pack": "npm pack 2>&1", "prebuild": "npm run clean", - "test:browser": "npm run build:test:browser && npm run unit-test:browser && npm run integration-test:browser", - "test:node": "npm run build:test:node && npm run unit-test:node && npm run integration-test:node", - "test": "npm run clean && npm run build:ts && npm run bundle:test:node && npm run unit-test:node && npm run bundle:test:browser && npm run unit-test:browser && npm run integration-test:node && npm run integration-test:browser", + "test:browser": "npm run clean && npm run build:test && npm run unit-test:browser", + "test:node": "npm run clean && npm run build:test && npm run unit-test:node", + "test": "npm run clean && npm run build:test && npm run unit-test", "unit-test:browser": "karma start --single-run", - "unit-test:node": "cross-env TS_NODE_FILES=true mocha -r esm -r ts-node/register --timeout 50000 --reporter ../../../common/tools/mocha-multi-reporter.js --colors --exclude \"test/**/*.browser.ts\" \"test/**/*.ts\"", + "unit-test:node": "mocha -r esm --require ts-node/register --reporter ../../../common/tools/mocha-multi-reporter.js --timeout 1200000 --full-trace \"test/{,!(browser)/**/}*.spec.ts\"", "unit-test": "npm run unit-test:node && npm run unit-test:browser", "docs": "typedoc --excludePrivate --excludeNotExported --excludeExternals --stripInternal --mode file --out ./dist/docs ./src" }, diff --git a/sdk/core-rest/core-client/test/clientHelpers.spec.ts b/sdk/core-rest/core-client/test/clientHelpers.spec.ts new file mode 100644 index 000000000000..243212766c5e --- /dev/null +++ b/sdk/core-rest/core-client/test/clientHelpers.spec.ts @@ -0,0 +1,87 @@ +import { createDefaultPipeline } from "../src/clientHelpers"; +import { assert } from "chai"; +import { bearerTokenAuthenticationPolicyName } from "@azure/core-rest-pipeline"; +import { keyCredentialAuthenticationPolicyName } from "../src/keyCredentialAuthenticationPolicy"; +import { TokenCredential } from "@azure/core-auth"; +import { fail } from "assert"; +describe("clientHelpers", () => { + const mockBaseUrl = "https://example.org"; + it("should create a default pipeline with no credentials", () => { + const pipeline = createDefaultPipeline(mockBaseUrl); + const policies = pipeline.getOrderedPolicies(); + + assert.isDefined(policies, "default pipeline should contain policies"); + assert.isUndefined( + policies.find((p) => p.name === "exponentialRetryPolicy"), + "pipeline shouldn't have exponentialRetryPolicy" + ); + + assert.isUndefined( + policies.find((p) => p.name === bearerTokenAuthenticationPolicyName), + "pipeline shouldn't have bearerTokenAuthenticationPolicyName" + ); + + assert.isUndefined( + policies.find((p) => p.name === keyCredentialAuthenticationPolicyName), + "pipeline shouldn't have keyCredentialAuthenticationPolicyName" + ); + }); + + it("should throw if key credentials but no Api Header Name", () => { + try { + createDefaultPipeline(mockBaseUrl, { key: "mockKey" }); + fail("Expected to throw an error"); + } catch (error) { + assert.equal((error as Error).message, "Missing API Key Header Name"); + } + }); + + it("should create a default pipeline with key credentials", () => { + const pipeline = createDefaultPipeline( + mockBaseUrl, + { key: "mockKey" }, + { credentials: { apiKeyHeaderName: "apiHeader" } } + ); + const policies = pipeline.getOrderedPolicies(); + + assert.isDefined(policies, "default pipeline should contain policies"); + assert.isUndefined( + policies.find((p) => p.name === "exponentialRetryPolicy"), + "pipeline shouldn't have exponentialRetryPolicy" + ); + + assert.isUndefined( + policies.find((p) => p.name === bearerTokenAuthenticationPolicyName), + "pipeline shouldn't have bearerTokenAuthenticationPolicyName" + ); + + assert.isDefined( + policies.find((p) => p.name === keyCredentialAuthenticationPolicyName), + "pipeline shouldn have keyCredentialAuthenticationPolicyName" + ); + }); + + it("should create a default pipeline with TokenCredential", () => { + const mockCredential: TokenCredential = { + getToken: async () => ({ expiresOnTimestamp: 0, token: "mockToken" }), + }; + const pipeline = createDefaultPipeline(mockBaseUrl, mockCredential); + const policies = pipeline.getOrderedPolicies(); + + assert.isDefined(policies, "default pipeline should contain policies"); + assert.isUndefined( + policies.find((p) => p.name === "exponentialRetryPolicy"), + "pipeline shouldn't have exponentialRetryPolicy" + ); + + assert.isDefined( + policies.find((p) => p.name === bearerTokenAuthenticationPolicyName), + "pipeline should have bearerTokenAuthenticationPolicyName" + ); + + assert.isUndefined( + policies.find((p) => p.name === keyCredentialAuthenticationPolicyName), + "pipeline shouldn have keyCredentialAuthenticationPolicyName" + ); + }); +}); diff --git a/sdk/core-rest/core-client/test/test.spec.ts b/sdk/core-rest/core-client/test/test.spec.ts deleted file mode 100644 index 6c0f49e9989b..000000000000 --- a/sdk/core-rest/core-client/test/test.spec.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { assert } from "chai"; -describe("hello world", () => { - it("should pass", () => { - assert.equal(1, 1); - }); -}); From 4be22bbbfc2431d60dfe2a246f85a42a976c97ef Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 00:26:18 +0000 Subject: [PATCH 17/37] Fix core-client readme --- sdk/core-rest/core-client/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sdk/core-rest/core-client/README.md b/sdk/core-rest/core-client/README.md index 5189e059830e..418204b89dd7 100644 --- a/sdk/core-rest/core-client/README.md +++ b/sdk/core-rest/core-client/README.md @@ -1,4 +1,4 @@ -# Azure Rest Core Client library for JavaScript (Experimental) +# Azure Rest Core client library for JavaScript (Experimental) This library is primarily intended to be used in code generated by [AutoRest](https://github.com/Azure/Autorest) and [`autorest.typescript`](https://github.com/Azure/autorest.typescript). Specifically for rest level clients From 52c37f011079c5d04490f1f0d0c77bc4aa1582b9 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 00:51:34 +0000 Subject: [PATCH 18/37] Fix broken links --- sdk/documenttranslator/ai-document-translator-rest/README.md | 2 +- .../ai-document-translator-rest/samples/v1/javascript/README.md | 2 +- .../ai-document-translator-rest/samples/v1/typescript/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/README.md b/sdk/documenttranslator/ai-document-translator-rest/README.md index 4f7ceccb570b..0aaf454736ee 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/README.md @@ -16,7 +16,7 @@ Use the client library to: [Source code](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/) | [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-document-translator) | -[API reference documentation](https://docs.microsoft.com/javascript/api/@azure-rest/ai-document-translator) | +[API reference documentation](https://docs.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/overview) | [Product documentation](https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview) | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/samples) diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md index 980f48fe5aaa..b96282a4d797 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md @@ -61,7 +61,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP [listformats]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/listFormats.js [translatefromblob]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/translateFromBlob.js -[apiref]: https://docs.microsoft.com/javascript/api/@azure/ai-document-translator +[apiref]: https://docs.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/overview [freesub]: https://azure.microsoft.com/free/ [createinstance_azurecognitiveservicesinstance]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account [package]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/README.md diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md index d1d87b925161..276b96a27f2b 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md @@ -73,7 +73,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP [listformats]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/listFormats.ts [translatefromblob]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts -[apiref]: https://docs.microsoft.com/javascript/api/@azure/ai-document-translator +[apiref]: https://docs.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/overview [freesub]: https://azure.microsoft.com/free/ [createinstance_azurecognitiveservicesinstance]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account [package]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/README.md From 817b8569f391bf87e1b70cf1ea3fe20dddc90eef Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 02:19:00 +0000 Subject: [PATCH 19/37] remove locale from links --- sdk/documenttranslator/ai-document-translator-rest/README.md | 2 +- .../ai-document-translator-rest/samples/v1/javascript/README.md | 2 +- .../ai-document-translator-rest/samples/v1/typescript/README.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/README.md b/sdk/documenttranslator/ai-document-translator-rest/README.md index 0aaf454736ee..a7cf3769011d 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/README.md @@ -16,7 +16,7 @@ Use the client library to: [Source code](https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/) | [Package (NPM)](https://www.npmjs.com/package/@azure-rest/ai-document-translator) | -[API reference documentation](https://docs.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/overview) | +[API reference documentation](https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview) | [Product documentation](https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview) | [Samples](https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/samples) diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md index b96282a4d797..257b5e1bddd0 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/README.md @@ -61,7 +61,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP [listformats]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/listFormats.js [translatefromblob]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/javascript/translateFromBlob.js -[apiref]: https://docs.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/overview +[apiref]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview [freesub]: https://azure.microsoft.com/free/ [createinstance_azurecognitiveservicesinstance]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account [package]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/README.md diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md index 276b96a27f2b..6ae96f291677 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/README.md @@ -73,7 +73,7 @@ Take a look at our [API Documentation][apiref] for more information about the AP [listformats]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/listFormats.ts [translatefromblob]: https://github.com/Azure/azure-sdk-for-js/blob/master/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts -[apiref]: https://docs.microsoft.com/en-us/azure/cognitive-services/translator/document-translation/overview +[apiref]: https://docs.microsoft.com/azure/cognitive-services/translator/document-translation/overview [freesub]: https://azure.microsoft.com/free/ [createinstance_azurecognitiveservicesinstance]: https://docs.microsoft.com/azure/cognitive-services/cognitive-services-apis-create-account [package]: https://github.com/Azure/azure-sdk-for-js/tree/master/sdk/documenttranslator/ai-document-translator-rest/README.md From 35d1982aa1f3e23c4784024aed942f81a9276ab5 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 02:21:09 +0000 Subject: [PATCH 20/37] Add changelog --- .../ai-document-translator-rest/CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 sdk/documenttranslator/ai-document-translator-rest/CHANGELOG.md diff --git a/sdk/documenttranslator/ai-document-translator-rest/CHANGELOG.md b/sdk/documenttranslator/ai-document-translator-rest/CHANGELOG.md new file mode 100644 index 000000000000..4144f75694a0 --- /dev/null +++ b/sdk/documenttranslator/ai-document-translator-rest/CHANGELOG.md @@ -0,0 +1,3 @@ +# Release History + +## 1.0.0-beta.1 (Unreleased) From 9e219b04823d835abd565c8d9410b813009987ce Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 05:56:51 +0000 Subject: [PATCH 21/37] Fix url import --- sdk/core-rest/core-client/src/urlHelpers.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/core-rest/core-client/src/urlHelpers.ts b/sdk/core-rest/core-client/src/urlHelpers.ts index 07d201085fdb..b2048cbee603 100644 --- a/sdk/core-rest/core-client/src/urlHelpers.ts +++ b/sdk/core-rest/core-client/src/urlHelpers.ts @@ -1,4 +1,5 @@ import { RequestParameters } from "./pathClientTypes"; +import { URL } from "./url"; /** * Builds the request url, filling in query and path parameters From 7db7c8d3b95f60c40a88efaa36c32ee5a223e0b7 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 20:54:08 +0000 Subject: [PATCH 22/37] Format and updated names --- .../ai-document-translator-rest/karma.conf.js | 30 +- .../review/ai-document-translator.api.md | 340 +++++++++--------- .../src/documentTranslator.ts | 266 +++++++------- .../src/parameters.ts | 33 +- .../src/responses.ts | 166 ++++----- .../swagger/README.md | 4 +- .../test/public/listFormats.spec.ts | 4 +- .../test/public/utils/recordedClient.ts | 6 +- 8 files changed, 424 insertions(+), 425 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js b/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js index 0006573963a0..00d005abbcaa 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js +++ b/sdk/documenttranslator/ai-document-translator-rest/karma.conf.js @@ -8,10 +8,10 @@ const { jsonRecordingFilterFunction, isPlaybackMode, isSoftRecordMode, - isRecordMode + isRecordMode, } = require("@azure/test-utils-recorder"); -module.exports = function(config) { +module.exports = function (config) { config.set({ // base path that will be used to resolve all patterns (eg. files, exclude) basePath: "./", @@ -33,13 +33,13 @@ module.exports = function(config) { "karma-junit-reporter", "karma-json-to-file-reporter", "karma-source-map-support", - "karma-json-preprocessor" + "karma-json-preprocessor", ], // 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 } + { pattern: "dist-test/index.browser.js.map", type: "html", included: false, served: true }, ].concat(isPlaybackMode() || isSoftRecordMode() ? ["recordings/browsers/**/*.json"] : []), // list of files / patterns to exclude @@ -49,7 +49,7 @@ module.exports = function(config) { // available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor preprocessors: { "**/*.js": ["sourcemap", "env"], - "recordings/browsers/**/*.json": ["json"] + "recordings/browsers/**/*.json": ["json"], // 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"] @@ -69,8 +69,8 @@ module.exports = function(config) { { type: "json", subdir: ".", file: "coverage.json" }, { type: "lcovonly", subdir: ".", file: "lcov.info" }, { type: "html", subdir: "html" }, - { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" } - ] + { type: "cobertura", subdir: ".", file: "cobertura-coverage.xml" }, + ], }, junitReporter: { @@ -80,12 +80,12 @@ module.exports = function(config) { 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 + properties: {}, // key value pair of properties to add to the section of the report }, jsonToFileReporter: { filter: jsonRecordingFilterFunction, - outputPath: "." + outputPath: ".", }, // web server port @@ -107,8 +107,8 @@ module.exports = function(config) { customLaunchers: { ChromeHeadlessNoSandbox: { base: "ChromeHeadless", - flags: ["--no-sandbox", "--disable-web-security"] - } + flags: ["--no-sandbox", "--disable-web-security"], + }, }, // Continuous Integration mode @@ -123,15 +123,15 @@ module.exports = function(config) { browserDisconnectTimeout: 10000, browserDisconnectTolerance: 3, browserConsoleLogOptions: { - terminal: !isRecordMode() + terminal: !isRecordMode(), }, client: { mocha: { // change Karma's debug.html to the mocha web reporter reporter: "html", - timeout: 0 - } - } + timeout: 0, + }, + }, }); }; diff --git a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md index c822ac545d81..d52c74f6d19a 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md +++ b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md @@ -42,13 +42,13 @@ export interface BatchSubmissionRequest { } // @public (undocumented) -export interface CancelOperation { - delete(options?: CancelOperationParameters): Promise; - get(options?: GetOperationStatusParameters): Promise; +export interface CancelTranslation { + delete(options?: CancelTranslationParameters): Promise; + get(options?: GetTranslationStatusParameters): Promise; } // @public -export interface CancelOperation200Response extends HttpResponse { +export interface CancelTranslation200Response extends HttpResponse { // (undocumented) body: BatchStatusDetail; // (undocumented) @@ -56,7 +56,7 @@ export interface CancelOperation200Response extends HttpResponse { } // @public -export interface CancelOperation401Response extends HttpResponse { +export interface CancelTranslation401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -64,7 +64,7 @@ export interface CancelOperation401Response extends HttpResponse { } // @public -export interface CancelOperation404Response extends HttpResponse { +export interface CancelTranslation404Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -72,7 +72,7 @@ export interface CancelOperation404Response extends HttpResponse { } // @public -export interface CancelOperation429Response extends HttpResponse { +export interface CancelTranslation429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -80,7 +80,7 @@ export interface CancelOperation429Response extends HttpResponse { } // @public -export interface CancelOperation500Response extends HttpResponse { +export interface CancelTranslation500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -88,7 +88,7 @@ export interface CancelOperation500Response extends HttpResponse { } // @public -export interface CancelOperation503Response extends HttpResponse { +export interface CancelTranslation503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -96,7 +96,7 @@ export interface CancelOperation503Response extends HttpResponse { } // @public (undocumented) -export type CancelOperationParameters = RequestParameters; +export type CancelTranslationParameters = RequestParameters; // @public (undocumented) export interface DocumentFilter { @@ -171,27 +171,44 @@ export interface FileFormatListResult { } // @public (undocumented) -export interface GetDocumentFormats { - get(options?: GetDocumentFormatsParameters): Promise; +export interface GetDocument { + get(options?: GetDocumentParameters): Promise; } // @public (undocumented) -export interface GetDocumentFormats200Headers { +export interface GetDocument200Headers { "retry-after"?: string; + etag?: string; } // @public -export interface GetDocumentFormats200Response extends HttpResponse { +export interface GetDocument200Response extends HttpResponse { // (undocumented) - body: FileFormatListResult; + body: DocumentStatusDetail; // (undocumented) - headers: RawHttpHeaders & GetDocumentFormats200Headers; + headers: RawHttpHeaders & GetDocument200Headers; // (undocumented) status: "200"; } // @public -export interface GetDocumentFormats429Response extends HttpResponse { +export interface GetDocument401Response extends HttpResponse { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: "401"; +} + +// @public +export interface GetDocument404Response extends HttpResponse { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: "404"; +} + +// @public +export interface GetDocument429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -199,7 +216,7 @@ export interface GetDocumentFormats429Response extends HttpResponse { } // @public -export interface GetDocumentFormats500Response extends HttpResponse { +export interface GetDocument500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -207,7 +224,7 @@ export interface GetDocumentFormats500Response extends HttpResponse { } // @public -export interface GetDocumentFormats503Response extends HttpResponse { +export interface GetDocument503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -215,31 +232,39 @@ export interface GetDocumentFormats503Response extends HttpResponse { } // @public (undocumented) -export type GetDocumentFormatsParameters = RequestParameters; +export type GetDocumentParameters = RequestParameters; // @public (undocumented) -export interface GetDocumentStatus { - get(options?: GetDocumentStatusParameters): Promise; +export interface GetDocuments { + get(options?: GetDocumentsParameters): Promise; } // @public (undocumented) -export interface GetDocumentStatus200Headers { +export interface GetDocuments200Headers { "retry-after"?: string; etag?: string; } // @public -export interface GetDocumentStatus200Response extends HttpResponse { +export interface GetDocuments200Response extends HttpResponse { // (undocumented) - body: DocumentStatusDetail; + body: DocumentStatusResponse; // (undocumented) - headers: RawHttpHeaders & GetDocumentStatus200Headers; + headers: RawHttpHeaders & GetDocuments200Headers; // (undocumented) status: "200"; } // @public -export interface GetDocumentStatus401Response extends HttpResponse { +export interface GetDocuments400Response extends HttpResponse { + // (undocumented) + body: ErrorResponseV2; + // (undocumented) + status: "400"; +} + +// @public +export interface GetDocuments401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -247,7 +272,7 @@ export interface GetDocumentStatus401Response extends HttpResponse { } // @public -export interface GetDocumentStatus404Response extends HttpResponse { +export interface GetDocuments404Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -255,7 +280,7 @@ export interface GetDocumentStatus404Response extends HttpResponse { } // @public -export interface GetDocumentStatus429Response extends HttpResponse { +export interface GetDocuments429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -263,7 +288,7 @@ export interface GetDocumentStatus429Response extends HttpResponse { } // @public -export interface GetDocumentStatus500Response extends HttpResponse { +export interface GetDocuments500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -271,7 +296,7 @@ export interface GetDocumentStatus500Response extends HttpResponse { } // @public -export interface GetDocumentStatus503Response extends HttpResponse { +export interface GetDocuments503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -279,30 +304,48 @@ export interface GetDocumentStatus503Response extends HttpResponse { } // @public (undocumented) -export type GetDocumentStatusParameters = RequestParameters; +export type GetDocumentsParameters = RequestParameters & GetDocumentsQueryParam; + +// @public (undocumented) +export interface GetDocumentsQueryParam { + // (undocumented) + queryParameters?: GetDocumentsQueryParamProperties; +} + +// @public (undocumented) +export interface GetDocumentsQueryParamProperties { + $maxpagesize?: number; + $orderBy?: string[]; + $skip?: number; + $top?: number; + createdDateTimeUtcEnd?: Date; + createdDateTimeUtcStart?: Date; + ids?: string[]; + statuses?: string[]; +} // @public (undocumented) -export interface GetDocumentStorageSource { - get(options?: GetDocumentStorageSourceParameters): Promise; +export interface GetSupportedDocumentFormats { + get(options?: GetSupportedDocumentFormatsParameters): Promise; } // @public (undocumented) -export interface GetDocumentStorageSource200Headers { +export interface GetSupportedDocumentFormats200Headers { "retry-after"?: string; } // @public -export interface GetDocumentStorageSource200Response extends HttpResponse { +export interface GetSupportedDocumentFormats200Response extends HttpResponse { // (undocumented) - body: StorageSourceListResult; + body: FileFormatListResult; // (undocumented) - headers: RawHttpHeaders & GetDocumentStorageSource200Headers; + headers: RawHttpHeaders & GetSupportedDocumentFormats200Headers; // (undocumented) status: "200"; } // @public -export interface GetDocumentStorageSource429Response extends HttpResponse { +export interface GetSupportedDocumentFormats429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -310,7 +353,7 @@ export interface GetDocumentStorageSource429Response extends HttpResponse { } // @public -export interface GetDocumentStorageSource500Response extends HttpResponse { +export interface GetSupportedDocumentFormats500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -318,7 +361,7 @@ export interface GetDocumentStorageSource500Response extends HttpResponse { } // @public -export interface GetDocumentStorageSource503Response extends HttpResponse { +export interface GetSupportedDocumentFormats503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -326,30 +369,30 @@ export interface GetDocumentStorageSource503Response extends HttpResponse { } // @public (undocumented) -export type GetDocumentStorageSourceParameters = RequestParameters; +export type GetSupportedDocumentFormatsParameters = RequestParameters; // @public (undocumented) -export interface GetGlossaryFormats { - get(options?: GetGlossaryFormatsParameters): Promise; +export interface GetSupportedGlossaryFormats { + get(options?: GetSupportedGlossaryFormatsParameters): Promise; } // @public (undocumented) -export interface GetGlossaryFormats200Headers { +export interface GetSupportedGlossaryFormats200Headers { "retry-after"?: string; } // @public -export interface GetGlossaryFormats200Response extends HttpResponse { +export interface GetSupportedGlossaryFormats200Response extends HttpResponse { // (undocumented) body: FileFormatListResult; // (undocumented) - headers: RawHttpHeaders & GetGlossaryFormats200Headers; + headers: RawHttpHeaders & GetSupportedGlossaryFormats200Headers; // (undocumented) status: "200"; } // @public -export interface GetGlossaryFormats429Response extends HttpResponse { +export interface GetSupportedGlossaryFormats429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -357,7 +400,7 @@ export interface GetGlossaryFormats429Response extends HttpResponse { } // @public -export interface GetGlossaryFormats500Response extends HttpResponse { +export interface GetSupportedGlossaryFormats500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -365,7 +408,7 @@ export interface GetGlossaryFormats500Response extends HttpResponse { } // @public -export interface GetGlossaryFormats503Response extends HttpResponse { +export interface GetSupportedGlossaryFormats503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -373,55 +416,30 @@ export interface GetGlossaryFormats503Response extends HttpResponse { } // @public (undocumented) -export type GetGlossaryFormatsParameters = RequestParameters; +export type GetSupportedGlossaryFormatsParameters = RequestParameters; // @public (undocumented) -export interface GetOperationDocumentsStatus { - get(options?: GetOperationDocumentsStatusParameters): Promise; +export interface GetSupportedStorageSources { + get(options?: GetSupportedStorageSourcesParameters): Promise; } // @public (undocumented) -export interface GetOperationDocumentsStatus200Headers { +export interface GetSupportedStorageSources200Headers { "retry-after"?: string; - etag?: string; } // @public -export interface GetOperationDocumentsStatus200Response extends HttpResponse { +export interface GetSupportedStorageSources200Response extends HttpResponse { // (undocumented) - body: DocumentStatusResponse; + body: StorageSourceListResult; // (undocumented) - headers: RawHttpHeaders & GetOperationDocumentsStatus200Headers; + headers: RawHttpHeaders & GetSupportedStorageSources200Headers; // (undocumented) status: "200"; } // @public -export interface GetOperationDocumentsStatus400Response extends HttpResponse { - // (undocumented) - body: ErrorResponseV2; - // (undocumented) - status: "400"; -} - -// @public -export interface GetOperationDocumentsStatus401Response extends HttpResponse { - // (undocumented) - body: ErrorResponseV2; - // (undocumented) - status: "401"; -} - -// @public -export interface GetOperationDocumentsStatus404Response extends HttpResponse { - // (undocumented) - body: ErrorResponseV2; - // (undocumented) - status: "404"; -} - -// @public -export interface GetOperationDocumentsStatus429Response extends HttpResponse { +export interface GetSupportedStorageSources429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -429,7 +447,7 @@ export interface GetOperationDocumentsStatus429Response extends HttpResponse { } // @public -export interface GetOperationDocumentsStatus500Response extends HttpResponse { +export interface GetSupportedStorageSources500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -437,7 +455,7 @@ export interface GetOperationDocumentsStatus500Response extends HttpResponse { } // @public -export interface GetOperationDocumentsStatus503Response extends HttpResponse { +export interface GetSupportedStorageSources503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -445,50 +463,32 @@ export interface GetOperationDocumentsStatus503Response extends HttpResponse { } // @public (undocumented) -export type GetOperationDocumentsStatusParameters = RequestParameters & GetOperationDocumentsStatusQueryParam; +export type GetSupportedStorageSourcesParameters = RequestParameters; // @public (undocumented) -export interface GetOperationDocumentsStatusQueryParam { - // (undocumented) - queryParameters?: GetOperationDocumentsStatusQueryParamProperties; +export interface GetTranslations { + get(options?: GetTranslationsParameters): Promise; + post(options?: StartTranslationParameters): Promise; } // @public (undocumented) -export interface GetOperationDocumentsStatusQueryParamProperties { - $maxpagesize?: number; - $orderBy?: string[]; - $skip?: number; - $top?: number; - createdDateTimeUtcEnd?: Date; - createdDateTimeUtcStart?: Date; - ids?: string[]; - statuses?: string[]; -} - -// @public (undocumented) -export interface GetOperations { - get(options?: GetOperationsParameters): Promise; - post(options?: SubmitBatchRequestParameters): Promise; -} - -// @public (undocumented) -export interface GetOperations200Headers { +export interface GetTranslations200Headers { "retry-after"?: string; etag?: string; } // @public -export interface GetOperations200Response extends HttpResponse { +export interface GetTranslations200Response extends HttpResponse { // (undocumented) body: BatchStatusResponse; // (undocumented) - headers: RawHttpHeaders & GetOperations200Headers; + headers: RawHttpHeaders & GetTranslations200Headers; // (undocumented) status: "200"; } // @public -export interface GetOperations400Response extends HttpResponse { +export interface GetTranslations400Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -496,7 +496,7 @@ export interface GetOperations400Response extends HttpResponse { } // @public -export interface GetOperations401Response extends HttpResponse { +export interface GetTranslations401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -504,7 +504,7 @@ export interface GetOperations401Response extends HttpResponse { } // @public -export interface GetOperations429Response extends HttpResponse { +export interface GetTranslations429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -512,7 +512,7 @@ export interface GetOperations429Response extends HttpResponse { } // @public -export interface GetOperations500Response extends HttpResponse { +export interface GetTranslations500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -520,7 +520,7 @@ export interface GetOperations500Response extends HttpResponse { } // @public -export interface GetOperations503Response extends HttpResponse { +export interface GetTranslations503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -528,16 +528,16 @@ export interface GetOperations503Response extends HttpResponse { } // @public (undocumented) -export type GetOperationsParameters = RequestParameters & GetOperationsQueryParam; +export type GetTranslationsParameters = RequestParameters & GetTranslationsQueryParam; // @public (undocumented) -export interface GetOperationsQueryParam { +export interface GetTranslationsQueryParam { // (undocumented) - queryParameters?: GetOperationsQueryParamProperties; + queryParameters?: GetTranslationsQueryParamProperties; } // @public (undocumented) -export interface GetOperationsQueryParamProperties { +export interface GetTranslationsQueryParamProperties { $maxpagesize?: number; $orderBy?: string[]; $skip?: number; @@ -549,23 +549,23 @@ export interface GetOperationsQueryParamProperties { } // @public (undocumented) -export interface GetOperationStatus200Headers { +export interface GetTranslationStatus200Headers { "retry-after"?: string; etag?: string; } // @public -export interface GetOperationStatus200Response extends HttpResponse { +export interface GetTranslationStatus200Response extends HttpResponse { // (undocumented) body: BatchStatusDetail; // (undocumented) - headers: RawHttpHeaders & GetOperationStatus200Headers; + headers: RawHttpHeaders & GetTranslationStatus200Headers; // (undocumented) status: "200"; } // @public -export interface GetOperationStatus401Response extends HttpResponse { +export interface GetTranslationStatus401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -573,7 +573,7 @@ export interface GetOperationStatus401Response extends HttpResponse { } // @public -export interface GetOperationStatus404Response extends HttpResponse { +export interface GetTranslationStatus404Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -581,7 +581,7 @@ export interface GetOperationStatus404Response extends HttpResponse { } // @public -export interface GetOperationStatus429Response extends HttpResponse { +export interface GetTranslationStatus429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -589,7 +589,7 @@ export interface GetOperationStatus429Response extends HttpResponse { } // @public -export interface GetOperationStatus500Response extends HttpResponse { +export interface GetTranslationStatus500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -597,7 +597,7 @@ export interface GetOperationStatus500Response extends HttpResponse { } // @public -export interface GetOperationStatus503Response extends HttpResponse { +export interface GetTranslationStatus503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -605,7 +605,7 @@ export interface GetOperationStatus503Response extends HttpResponse { } // @public (undocumented) -export type GetOperationStatusParameters = RequestParameters; +export type GetTranslationStatusParameters = RequestParameters; // @public (undocumented) export interface Glossary { @@ -625,13 +625,13 @@ export interface InnerErrorV2 { // @public (undocumented) export interface Routes { - (path: "/batches"): GetOperations; - (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; - (path: "/batches/{id}", id: string): CancelOperation; - (path: "/batches/{id}/documents", id: string): GetOperationDocumentsStatus; - (path: "/documents/formats"): GetDocumentFormats; - (path: "/glossaries/formats"): GetGlossaryFormats; - (path: "/storagesources"): GetDocumentStorageSource; + (path: "/batches"): GetTranslations; + (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocument; + (path: "/batches/{id}", id: string): CancelTranslation; + (path: "/batches/{id}/documents", id: string): GetDocuments; + (path: "/documents/formats"): GetSupportedDocumentFormats; + (path: "/glossaries/formats"): GetSupportedGlossaryFormats; + (path: "/storagesources"): GetSupportedStorageSources; } // @public (undocumented) @@ -644,45 +644,20 @@ export interface SourceInput { } // @public (undocumented) -export type Status = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Cancelled" | "Cancelling" | "ValidationFailed"; - -// @public (undocumented) -export interface StatusSummary { - cancelled: number; - failed: number; - inProgress: number; - notYetStarted: number; - success: number; - total: number; - totalCharacterCharged: number; -} - -// @public (undocumented) -export type StorageInputType = "Folder" | "File"; - -// @public (undocumented) -export type StorageSource = "AzureBlob"; - -// @public (undocumented) -export interface StorageSourceListResult { - value: "AzureBlob"[]; -} - -// @public (undocumented) -export interface SubmitBatchRequest202Headers { +export interface StartTranslation202Headers { "operation-location"?: string; } // @public -export interface SubmitBatchRequest202Response extends HttpResponse { +export interface StartTranslation202Response extends HttpResponse { // (undocumented) - headers: RawHttpHeaders & SubmitBatchRequest202Headers; + headers: RawHttpHeaders & StartTranslation202Headers; // (undocumented) status: "202"; } // @public -export interface SubmitBatchRequest400Response extends HttpResponse { +export interface StartTranslation400Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -690,7 +665,7 @@ export interface SubmitBatchRequest400Response extends HttpResponse { } // @public -export interface SubmitBatchRequest401Response extends HttpResponse { +export interface StartTranslation401Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -698,7 +673,7 @@ export interface SubmitBatchRequest401Response extends HttpResponse { } // @public -export interface SubmitBatchRequest429Response extends HttpResponse { +export interface StartTranslation429Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -706,7 +681,7 @@ export interface SubmitBatchRequest429Response extends HttpResponse { } // @public -export interface SubmitBatchRequest500Response extends HttpResponse { +export interface StartTranslation500Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -714,7 +689,7 @@ export interface SubmitBatchRequest500Response extends HttpResponse { } // @public -export interface SubmitBatchRequest503Response extends HttpResponse { +export interface StartTranslation503Response extends HttpResponse { // (undocumented) body: ErrorResponseV2; // (undocumented) @@ -722,13 +697,38 @@ export interface SubmitBatchRequest503Response extends HttpResponse { } // @public (undocumented) -export interface SubmitBatchRequestBodyParam { +export interface StartTranslationBodyParam { // (undocumented) body?: BatchSubmissionRequest; } // @public (undocumented) -export type SubmitBatchRequestParameters = RequestParameters & SubmitBatchRequestBodyParam; +export type StartTranslationParameters = RequestParameters & StartTranslationBodyParam; + +// @public (undocumented) +export type Status = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Cancelled" | "Cancelling" | "ValidationFailed"; + +// @public (undocumented) +export interface StatusSummary { + cancelled: number; + failed: number; + inProgress: number; + notYetStarted: number; + success: number; + total: number; + totalCharacterCharged: number; +} + +// @public (undocumented) +export type StorageInputType = "Folder" | "File"; + +// @public (undocumented) +export type StorageSource = "AzureBlob"; + +// @public (undocumented) +export interface StorageSourceListResult { + value: "AzureBlob"[]; +} // @public (undocumented) export interface TargetInput { diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index 0bb9a4b35315..d43fa87a76da 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -2,71 +2,71 @@ // Licensed under the MIT license. import { - SubmitBatchRequestParameters, - GetOperationsParameters, - GetDocumentStatusParameters, - GetOperationStatusParameters, - CancelOperationParameters, - GetOperationDocumentsStatusParameters, - GetDocumentFormatsParameters, - GetGlossaryFormatsParameters, - GetDocumentStorageSourceParameters, + StartTranslationParameters, + GetTranslationsParameters, + GetDocumentParameters, + GetTranslationStatusParameters, + CancelTranslationParameters, + GetDocumentsParameters, + GetSupportedDocumentFormatsParameters, + GetSupportedGlossaryFormatsParameters, + GetSupportedStorageSourcesParameters, } from "./parameters"; import { - SubmitBatchRequest202Response, - SubmitBatchRequest400Response, - SubmitBatchRequest401Response, - SubmitBatchRequest429Response, - SubmitBatchRequest500Response, - SubmitBatchRequest503Response, - GetOperations200Response, - GetOperations400Response, - GetOperations401Response, - GetOperations429Response, - GetOperations500Response, - GetOperations503Response, - GetDocumentStatus200Response, - GetDocumentStatus401Response, - GetDocumentStatus404Response, - GetDocumentStatus429Response, - GetDocumentStatus500Response, - GetDocumentStatus503Response, - GetOperationStatus200Response, - GetOperationStatus401Response, - GetOperationStatus404Response, - GetOperationStatus429Response, - GetOperationStatus500Response, - GetOperationStatus503Response, - CancelOperation200Response, - CancelOperation401Response, - CancelOperation404Response, - CancelOperation429Response, - CancelOperation500Response, - CancelOperation503Response, - GetOperationDocumentsStatus200Response, - GetOperationDocumentsStatus400Response, - GetOperationDocumentsStatus401Response, - GetOperationDocumentsStatus404Response, - GetOperationDocumentsStatus429Response, - GetOperationDocumentsStatus500Response, - GetOperationDocumentsStatus503Response, - GetDocumentFormats200Response, - GetDocumentFormats429Response, - GetDocumentFormats500Response, - GetDocumentFormats503Response, - GetGlossaryFormats200Response, - GetGlossaryFormats429Response, - GetGlossaryFormats500Response, - GetGlossaryFormats503Response, - GetDocumentStorageSource200Response, - GetDocumentStorageSource429Response, - GetDocumentStorageSource500Response, - GetDocumentStorageSource503Response, + StartTranslation202Response, + StartTranslation400Response, + StartTranslation401Response, + StartTranslation429Response, + StartTranslation500Response, + StartTranslation503Response, + GetTranslations200Response, + GetTranslations400Response, + GetTranslations401Response, + GetTranslations429Response, + GetTranslations500Response, + GetTranslations503Response, + GetDocument200Response, + GetDocument401Response, + GetDocument404Response, + GetDocument429Response, + GetDocument500Response, + GetDocument503Response, + GetTranslationStatus200Response, + GetTranslationStatus401Response, + GetTranslationStatus404Response, + GetTranslationStatus429Response, + GetTranslationStatus500Response, + GetTranslationStatus503Response, + CancelTranslation200Response, + CancelTranslation401Response, + CancelTranslation404Response, + CancelTranslation429Response, + CancelTranslation500Response, + CancelTranslation503Response, + GetDocuments200Response, + GetDocuments400Response, + GetDocuments401Response, + GetDocuments404Response, + GetDocuments429Response, + GetDocuments500Response, + GetDocuments503Response, + GetSupportedDocumentFormats200Response, + GetSupportedDocumentFormats429Response, + GetSupportedDocumentFormats500Response, + GetSupportedDocumentFormats503Response, + GetSupportedGlossaryFormats200Response, + GetSupportedGlossaryFormats429Response, + GetSupportedGlossaryFormats500Response, + GetSupportedGlossaryFormats503Response, + GetSupportedStorageSources200Response, + GetSupportedStorageSources429Response, + GetSupportedStorageSources500Response, + GetSupportedStorageSources503Response, } from "./responses"; import { getClient, ClientOptions, Client } from "@azure-rest/core-client"; import { KeyCredential, TokenCredential } from "@azure/core-auth"; -export interface GetOperations { +export interface GetTranslations { /** * Use this API to submit a bulk (batch) translation request to the Document Translation service. * Each request can contain multiple documents and must contain a source and destination container for each document. @@ -79,14 +79,14 @@ export interface GetOperations { * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ post( - options?: SubmitBatchRequestParameters + options?: StartTranslationParameters ): Promise< - | SubmitBatchRequest202Response - | SubmitBatchRequest400Response - | SubmitBatchRequest401Response - | SubmitBatchRequest429Response - | SubmitBatchRequest500Response - | SubmitBatchRequest503Response + | StartTranslation202Response + | StartTranslation400Response + | StartTranslation401Response + | StartTranslation429Response + | StartTranslation500Response + | StartTranslation503Response >; /** * Returns a list of batch requests submitted and the status for each request. @@ -114,66 +114,66 @@ export interface GetOperations { * This reduces the risk of the client making assumptions about the data returned. */ get( - options?: GetOperationsParameters + options?: GetTranslationsParameters ): Promise< - | GetOperations200Response - | GetOperations400Response - | GetOperations401Response - | GetOperations429Response - | GetOperations500Response - | GetOperations503Response + | GetTranslations200Response + | GetTranslations400Response + | GetTranslations401Response + | GetTranslations429Response + | GetTranslations500Response + | GetTranslations503Response >; } -export interface GetDocumentStatus { +export interface GetDocument { /** Returns the translation status for a specific document based on the request Id and document Id. */ get( - options?: GetDocumentStatusParameters + options?: GetDocumentParameters ): Promise< - | GetDocumentStatus200Response - | GetDocumentStatus401Response - | GetDocumentStatus404Response - | GetDocumentStatus429Response - | GetDocumentStatus500Response - | GetDocumentStatus503Response + | GetDocument200Response + | GetDocument401Response + | GetDocument404Response + | GetDocument429Response + | GetDocument500Response + | GetDocument503Response >; } -export interface CancelOperation { +export interface CancelTranslation { /** * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ get( - options?: GetOperationStatusParameters + options?: GetTranslationStatusParameters ): Promise< - | GetOperationStatus200Response - | GetOperationStatus401Response - | GetOperationStatus404Response - | GetOperationStatus429Response - | GetOperationStatus500Response - | GetOperationStatus503Response + | GetTranslationStatus200Response + | GetTranslationStatus401Response + | GetTranslationStatus404Response + | GetTranslationStatus429Response + | GetTranslationStatus500Response + | GetTranslationStatus503Response >; /** - * Cancel a currently processing or queued operation. - * Cancel a currently processing or queued operation. - * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * Cancel a currently processing or queued translation. + * Cancel a currently processing or queued translation. + * A translation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ delete( - options?: CancelOperationParameters + options?: CancelTranslationParameters ): Promise< - | CancelOperation200Response - | CancelOperation401Response - | CancelOperation404Response - | CancelOperation429Response - | CancelOperation500Response - | CancelOperation503Response + | CancelTranslation200Response + | CancelTranslation401Response + | CancelTranslation404Response + | CancelTranslation429Response + | CancelTranslation500Response + | CancelTranslation503Response >; } -export interface GetOperationDocumentsStatus { +export interface GetDocuments { /** * Returns the status for all documents in a batch document translation request. * @@ -197,75 +197,75 @@ export interface GetOperationDocumentsStatus { * This reduces the risk of the client making assumptions about the data returned. */ get( - options?: GetOperationDocumentsStatusParameters + options?: GetDocumentsParameters ): Promise< - | GetOperationDocumentsStatus200Response - | GetOperationDocumentsStatus400Response - | GetOperationDocumentsStatus401Response - | GetOperationDocumentsStatus404Response - | GetOperationDocumentsStatus429Response - | GetOperationDocumentsStatus500Response - | GetOperationDocumentsStatus503Response + | GetDocuments200Response + | GetDocuments400Response + | GetDocuments401Response + | GetDocuments404Response + | GetDocuments429Response + | GetDocuments500Response + | GetDocuments503Response >; } -export interface GetDocumentFormats { +export interface GetSupportedDocumentFormats { /** * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ get( - options?: GetDocumentFormatsParameters + options?: GetSupportedDocumentFormatsParameters ): Promise< - | GetDocumentFormats200Response - | GetDocumentFormats429Response - | GetDocumentFormats500Response - | GetDocumentFormats503Response + | GetSupportedDocumentFormats200Response + | GetSupportedDocumentFormats429Response + | GetSupportedDocumentFormats500Response + | GetSupportedDocumentFormats503Response >; } -export interface GetGlossaryFormats { +export interface GetSupportedGlossaryFormats { /** * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ get( - options?: GetGlossaryFormatsParameters + options?: GetSupportedGlossaryFormatsParameters ): Promise< - | GetGlossaryFormats200Response - | GetGlossaryFormats429Response - | GetGlossaryFormats500Response - | GetGlossaryFormats503Response + | GetSupportedGlossaryFormats200Response + | GetSupportedGlossaryFormats429Response + | GetSupportedGlossaryFormats500Response + | GetSupportedGlossaryFormats503Response >; } -export interface GetDocumentStorageSource { +export interface GetSupportedStorageSources { /** Returns a list of storage sources/options supported by the Document Translation service. */ get( - options?: GetDocumentStorageSourceParameters + options?: GetSupportedStorageSourcesParameters ): Promise< - | GetDocumentStorageSource200Response - | GetDocumentStorageSource429Response - | GetDocumentStorageSource500Response - | GetDocumentStorageSource503Response + | GetSupportedStorageSources200Response + | GetSupportedStorageSources429Response + | GetSupportedStorageSources500Response + | GetSupportedStorageSources503Response >; } export interface Routes { /** Resource for '/batches' has methods for the following verbs: post, get */ - (path: "/batches"): GetOperations; + (path: "/batches"): GetTranslations; /** Resource for '/batches/\{id\}/documents/\{documentId\}' has methods for the following verbs: get */ - (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; + (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocument; /** Resource for '/batches/\{id\}' has methods for the following verbs: get, delete */ - (path: "/batches/{id}", id: string): CancelOperation; + (path: "/batches/{id}", id: string): CancelTranslation; /** Resource for '/batches/\{id\}/documents' has methods for the following verbs: get */ - (path: "/batches/{id}/documents", id: string): GetOperationDocumentsStatus; + (path: "/batches/{id}/documents", id: string): GetDocuments; /** Resource for '/documents/formats' has methods for the following verbs: get */ - (path: "/documents/formats"): GetDocumentFormats; + (path: "/documents/formats"): GetSupportedDocumentFormats; /** Resource for '/glossaries/formats' has methods for the following verbs: get */ - (path: "/glossaries/formats"): GetGlossaryFormats; + (path: "/glossaries/formats"): GetSupportedGlossaryFormats; /** Resource for '/storagesources' has methods for the following verbs: get */ - (path: "/storagesources"): GetDocumentStorageSource; + (path: "/storagesources"): GetSupportedStorageSources; } export type DocumentTranslatorClient = Client & { diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts index 135be88f43fb..3ac16267d8cf 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts @@ -4,13 +4,13 @@ import { RequestParameters } from "@azure-rest/core-client"; import { BatchSubmissionRequest } from "./models"; -export interface SubmitBatchRequestBodyParam { +export interface StartTranslationBodyParam { body?: BatchSubmissionRequest; } -export type SubmitBatchRequestParameters = RequestParameters & SubmitBatchRequestBodyParam; +export type StartTranslationParameters = RequestParameters & StartTranslationBodyParam; -export interface GetOperationsQueryParamProperties { +export interface GetTranslationsQueryParamProperties { /** * $top indicates the total number of records the user wants to be returned across all pages. * @@ -47,16 +47,16 @@ export interface GetOperationsQueryParamProperties { $orderBy?: string[]; } -export interface GetOperationsQueryParam { - queryParameters?: GetOperationsQueryParamProperties; +export interface GetTranslationsQueryParam { + queryParameters?: GetTranslationsQueryParamProperties; } -export type GetOperationsParameters = RequestParameters & GetOperationsQueryParam; -export type GetDocumentStatusParameters = RequestParameters; -export type GetOperationStatusParameters = RequestParameters; -export type CancelOperationParameters = RequestParameters; +export type GetTranslationsParameters = RequestParameters & GetTranslationsQueryParam; +export type GetDocumentParameters = RequestParameters; +export type GetTranslationStatusParameters = RequestParameters; +export type CancelTranslationParameters = RequestParameters; -export interface GetOperationDocumentsStatusQueryParamProperties { +export interface GetDocumentsQueryParamProperties { /** * $top indicates the total number of records the user wants to be returned across all pages. * @@ -93,12 +93,11 @@ export interface GetOperationDocumentsStatusQueryParamProperties { $orderBy?: string[]; } -export interface GetOperationDocumentsStatusQueryParam { - queryParameters?: GetOperationDocumentsStatusQueryParamProperties; +export interface GetDocumentsQueryParam { + queryParameters?: GetDocumentsQueryParamProperties; } -export type GetOperationDocumentsStatusParameters = RequestParameters & - GetOperationDocumentsStatusQueryParam; -export type GetDocumentFormatsParameters = RequestParameters; -export type GetGlossaryFormatsParameters = RequestParameters; -export type GetDocumentStorageSourceParameters = RequestParameters; +export type GetDocumentsParameters = RequestParameters & GetDocumentsQueryParam; +export type GetSupportedDocumentFormatsParameters = RequestParameters; +export type GetSupportedGlossaryFormatsParameters = RequestParameters; +export type GetSupportedStorageSourcesParameters = RequestParameters; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts index 15bc00f34040..c2f9ee95b358 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts @@ -13,7 +13,7 @@ import { import { HttpResponse } from "@azure-rest/core-client"; import { RawHttpHeaders } from "@azure/core-rest-pipeline"; -export interface SubmitBatchRequest202Headers { +export interface StartTranslation202Headers { /** Location of batch the operation */ "operation-location"?: string; } @@ -29,9 +29,9 @@ export interface SubmitBatchRequest202Headers { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export interface SubmitBatchRequest202Response extends HttpResponse { +export interface StartTranslation202Response extends HttpResponse { status: "202"; - headers: RawHttpHeaders & SubmitBatchRequest202Headers; + headers: RawHttpHeaders & StartTranslation202Headers; } /** @@ -45,7 +45,7 @@ export interface SubmitBatchRequest202Response extends HttpResponse { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export interface SubmitBatchRequest400Response extends HttpResponse { +export interface StartTranslation400Response extends HttpResponse { status: "400"; body: ErrorResponseV2; } @@ -61,7 +61,7 @@ export interface SubmitBatchRequest400Response extends HttpResponse { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export interface SubmitBatchRequest401Response extends HttpResponse { +export interface StartTranslation401Response extends HttpResponse { status: "401"; body: ErrorResponseV2; } @@ -77,7 +77,7 @@ export interface SubmitBatchRequest401Response extends HttpResponse { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export interface SubmitBatchRequest429Response extends HttpResponse { +export interface StartTranslation429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } @@ -93,7 +93,7 @@ export interface SubmitBatchRequest429Response extends HttpResponse { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export interface SubmitBatchRequest500Response extends HttpResponse { +export interface StartTranslation500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } @@ -109,12 +109,12 @@ export interface SubmitBatchRequest500Response extends HttpResponse { * If the glossary is invalid or unreachable during translation, an error is indicated in the document status. * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ -export interface SubmitBatchRequest503Response extends HttpResponse { +export interface StartTranslation503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } -export interface GetOperations200Headers { +export interface GetTranslations200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ @@ -146,10 +146,10 @@ export interface GetOperations200Headers { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperations200Response extends HttpResponse { +export interface GetTranslations200Response extends HttpResponse { status: "200"; body: BatchStatusResponse; - headers: RawHttpHeaders & GetOperations200Headers; + headers: RawHttpHeaders & GetTranslations200Headers; } /** @@ -177,7 +177,7 @@ export interface GetOperations200Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperations400Response extends HttpResponse { +export interface GetTranslations400Response extends HttpResponse { status: "400"; body: ErrorResponseV2; } @@ -207,7 +207,7 @@ export interface GetOperations400Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperations401Response extends HttpResponse { +export interface GetTranslations401Response extends HttpResponse { status: "401"; body: ErrorResponseV2; } @@ -237,7 +237,7 @@ export interface GetOperations401Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperations429Response extends HttpResponse { +export interface GetTranslations429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } @@ -267,7 +267,7 @@ export interface GetOperations429Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperations500Response extends HttpResponse { +export interface GetTranslations500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } @@ -297,12 +297,12 @@ export interface GetOperations500Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperations503Response extends HttpResponse { +export interface GetTranslations503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } -export interface GetDocumentStatus200Headers { +export interface GetDocument200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ @@ -310,43 +310,43 @@ export interface GetDocumentStatus200Headers { } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocumentStatus200Response extends HttpResponse { +export interface GetDocument200Response extends HttpResponse { status: "200"; body: DocumentStatusDetail; - headers: RawHttpHeaders & GetDocumentStatus200Headers; + headers: RawHttpHeaders & GetDocument200Headers; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocumentStatus401Response extends HttpResponse { +export interface GetDocument401Response extends HttpResponse { status: "401"; body: ErrorResponseV2; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocumentStatus404Response extends HttpResponse { +export interface GetDocument404Response extends HttpResponse { status: "404"; body: ErrorResponseV2; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocumentStatus429Response extends HttpResponse { +export interface GetDocument429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocumentStatus500Response extends HttpResponse { +export interface GetDocument500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocumentStatus503Response extends HttpResponse { +export interface GetDocument503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } -export interface GetOperationStatus200Headers { +export interface GetTranslationStatus200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ @@ -357,17 +357,17 @@ export interface GetOperationStatus200Headers { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export interface GetOperationStatus200Response extends HttpResponse { +export interface GetTranslationStatus200Response extends HttpResponse { status: "200"; body: BatchStatusDetail; - headers: RawHttpHeaders & GetOperationStatus200Headers; + headers: RawHttpHeaders & GetTranslationStatus200Headers; } /** * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export interface GetOperationStatus401Response extends HttpResponse { +export interface GetTranslationStatus401Response extends HttpResponse { status: "401"; body: ErrorResponseV2; } @@ -376,7 +376,7 @@ export interface GetOperationStatus401Response extends HttpResponse { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export interface GetOperationStatus404Response extends HttpResponse { +export interface GetTranslationStatus404Response extends HttpResponse { status: "404"; body: ErrorResponseV2; } @@ -385,7 +385,7 @@ export interface GetOperationStatus404Response extends HttpResponse { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export interface GetOperationStatus429Response extends HttpResponse { +export interface GetTranslationStatus429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } @@ -394,7 +394,7 @@ export interface GetOperationStatus429Response extends HttpResponse { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export interface GetOperationStatus500Response extends HttpResponse { +export interface GetTranslationStatus500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } @@ -403,84 +403,84 @@ export interface GetOperationStatus500Response extends HttpResponse { * Returns the status for a document translation request. * The status includes the overall request status, as well as the status for documents that are being translated as part of that request. */ -export interface GetOperationStatus503Response extends HttpResponse { +export interface GetTranslationStatus503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } /** - * Cancel a currently processing or queued operation. - * Cancel a currently processing or queued operation. - * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * Cancel a currently processing or queued translation. + * Cancel a currently processing or queued translation. + * A translation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export interface CancelOperation200Response extends HttpResponse { +export interface CancelTranslation200Response extends HttpResponse { status: "200"; body: BatchStatusDetail; } /** - * Cancel a currently processing or queued operation. - * Cancel a currently processing or queued operation. - * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * Cancel a currently processing or queued translation. + * Cancel a currently processing or queued translation. + * A translation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export interface CancelOperation401Response extends HttpResponse { +export interface CancelTranslation401Response extends HttpResponse { status: "401"; body: ErrorResponseV2; } /** - * Cancel a currently processing or queued operation. - * Cancel a currently processing or queued operation. - * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * Cancel a currently processing or queued translation. + * Cancel a currently processing or queued translation. + * A translation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export interface CancelOperation404Response extends HttpResponse { +export interface CancelTranslation404Response extends HttpResponse { status: "404"; body: ErrorResponseV2; } /** - * Cancel a currently processing or queued operation. - * Cancel a currently processing or queued operation. - * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * Cancel a currently processing or queued translation. + * Cancel a currently processing or queued translation. + * A translation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export interface CancelOperation429Response extends HttpResponse { +export interface CancelTranslation429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } /** - * Cancel a currently processing or queued operation. - * Cancel a currently processing or queued operation. - * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * Cancel a currently processing or queued translation. + * Cancel a currently processing or queued translation. + * A translation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export interface CancelOperation500Response extends HttpResponse { +export interface CancelTranslation500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } /** - * Cancel a currently processing or queued operation. - * Cancel a currently processing or queued operation. - * An operation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. + * Cancel a currently processing or queued translation. + * Cancel a currently processing or queued translation. + * A translation will not be cancelled if it is already completed or failed or cancelling. A bad request will be returned. * All documents that have completed translation will not be cancelled and will be charged. * All pending documents will be cancelled if possible. */ -export interface CancelOperation503Response extends HttpResponse { +export interface CancelTranslation503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } -export interface GetOperationDocumentsStatus200Headers { +export interface GetDocuments200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ @@ -509,10 +509,10 @@ export interface GetOperationDocumentsStatus200Headers { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperationDocumentsStatus200Response extends HttpResponse { +export interface GetDocuments200Response extends HttpResponse { status: "200"; body: DocumentStatusResponse; - headers: RawHttpHeaders & GetOperationDocumentsStatus200Headers; + headers: RawHttpHeaders & GetDocuments200Headers; } /** @@ -537,7 +537,7 @@ export interface GetOperationDocumentsStatus200Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperationDocumentsStatus400Response extends HttpResponse { +export interface GetDocuments400Response extends HttpResponse { status: "400"; body: ErrorResponseV2; } @@ -564,7 +564,7 @@ export interface GetOperationDocumentsStatus400Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperationDocumentsStatus401Response extends HttpResponse { +export interface GetDocuments401Response extends HttpResponse { status: "401"; body: ErrorResponseV2; } @@ -591,7 +591,7 @@ export interface GetOperationDocumentsStatus401Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperationDocumentsStatus404Response extends HttpResponse { +export interface GetDocuments404Response extends HttpResponse { status: "404"; body: ErrorResponseV2; } @@ -618,7 +618,7 @@ export interface GetOperationDocumentsStatus404Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperationDocumentsStatus429Response extends HttpResponse { +export interface GetDocuments429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } @@ -645,7 +645,7 @@ export interface GetOperationDocumentsStatus429Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperationDocumentsStatus500Response extends HttpResponse { +export interface GetDocuments500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } @@ -672,12 +672,12 @@ export interface GetOperationDocumentsStatus500Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetOperationDocumentsStatus503Response extends HttpResponse { +export interface GetDocuments503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } -export interface GetDocumentFormats200Headers { +export interface GetSupportedDocumentFormats200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; } @@ -686,17 +686,17 @@ export interface GetDocumentFormats200Headers { * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ -export interface GetDocumentFormats200Response extends HttpResponse { +export interface GetSupportedDocumentFormats200Response extends HttpResponse { status: "200"; body: FileFormatListResult; - headers: RawHttpHeaders & GetDocumentFormats200Headers; + headers: RawHttpHeaders & GetSupportedDocumentFormats200Headers; } /** * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ -export interface GetDocumentFormats429Response extends HttpResponse { +export interface GetSupportedDocumentFormats429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } @@ -705,7 +705,7 @@ export interface GetDocumentFormats429Response extends HttpResponse { * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ -export interface GetDocumentFormats500Response extends HttpResponse { +export interface GetSupportedDocumentFormats500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } @@ -714,12 +714,12 @@ export interface GetDocumentFormats500Response extends HttpResponse { * The list of supported document formats supported by the Document Translation service. * The list includes the common file extension, as well as the content-type if using the upload API. */ -export interface GetDocumentFormats503Response extends HttpResponse { +export interface GetSupportedDocumentFormats503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } -export interface GetGlossaryFormats200Headers { +export interface GetSupportedGlossaryFormats200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; } @@ -728,17 +728,17 @@ export interface GetGlossaryFormats200Headers { * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ -export interface GetGlossaryFormats200Response extends HttpResponse { +export interface GetSupportedGlossaryFormats200Response extends HttpResponse { status: "200"; body: FileFormatListResult; - headers: RawHttpHeaders & GetGlossaryFormats200Headers; + headers: RawHttpHeaders & GetSupportedGlossaryFormats200Headers; } /** * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ -export interface GetGlossaryFormats429Response extends HttpResponse { +export interface GetSupportedGlossaryFormats429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } @@ -747,7 +747,7 @@ export interface GetGlossaryFormats429Response extends HttpResponse { * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ -export interface GetGlossaryFormats500Response extends HttpResponse { +export interface GetSupportedGlossaryFormats500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } @@ -756,37 +756,37 @@ export interface GetGlossaryFormats500Response extends HttpResponse { * The list of supported glossary formats supported by the Document Translation service. * The list includes the common file extension used. */ -export interface GetGlossaryFormats503Response extends HttpResponse { +export interface GetSupportedGlossaryFormats503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } -export interface GetDocumentStorageSource200Headers { +export interface GetSupportedStorageSources200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; } /** Returns a list of storage sources/options supported by the Document Translation service. */ -export interface GetDocumentStorageSource200Response extends HttpResponse { +export interface GetSupportedStorageSources200Response extends HttpResponse { status: "200"; body: StorageSourceListResult; - headers: RawHttpHeaders & GetDocumentStorageSource200Headers; + headers: RawHttpHeaders & GetSupportedStorageSources200Headers; } /** Returns a list of storage sources/options supported by the Document Translation service. */ -export interface GetDocumentStorageSource429Response extends HttpResponse { +export interface GetSupportedStorageSources429Response extends HttpResponse { status: "429"; body: ErrorResponseV2; } /** Returns a list of storage sources/options supported by the Document Translation service. */ -export interface GetDocumentStorageSource500Response extends HttpResponse { +export interface GetSupportedStorageSources500Response extends HttpResponse { status: "500"; body: ErrorResponseV2; } /** Returns a list of storage sources/options supported by the Document Translation service. */ -export interface GetDocumentStorageSource503Response extends HttpResponse { +export interface GetSupportedStorageSources503Response extends HttpResponse { status: "503"; body: ErrorResponseV2; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md index 7eb3dd136ee5..7f6da9658aff 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md @@ -12,7 +12,7 @@ generate-metadata: false license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ source-code-folder-path: ./src -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/master/specification/cognitiveservices/data-plane/TranslatorText/preview/v1.0-preview.1/TranslatorBatch.json +input-file: /home/jmanuelh/projects/azure-rest-api-specs/specification/cognitiveservices/data-plane/TranslatorText/preview/v1.0-preview.1/TranslatorBatch.json package-version: 1.0.0-beta.1 hide-clients: true low-level-client: true @@ -20,5 +20,5 @@ add-credentials: true credential-scopes: "https://cognitiveservices.azure.com/.default" credential-key-header-name: "Ocp-Apim-Subscription-Key" use-extension: - "@autorest/typescript": "~/projects/autorest.typescript" + "@autorest/typescript": "https://aka.ms/azsdk/typescript/rlc" ``` diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts b/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts index 990ff5664dc3..437c97b1a8d5 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts @@ -12,12 +12,12 @@ describe("List Document Formats", () => { let recorder: Recorder; let client: DocumentTranslatorClient; - beforeEach(function(this: Context) { + beforeEach(function (this: Context) { recorder = createRecorder(this); client = createClient(); }); - afterEach(async function() { + afterEach(async function () { await recorder.stop(); }); diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/recordedClient.ts b/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/recordedClient.ts index b58bad58ced1..1d255b3a7975 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/recordedClient.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/test/public/utils/recordedClient.ts @@ -13,7 +13,7 @@ import { ClientOptions } from "@azure-rest/core-client"; const replaceableVariables: { [k: string]: string } = { DOCUMENT_TRANSLATOR_API_KEY: "api_key", - ENDPOINT: "https://endpoint/" + ENDPOINT: "https://endpoint/", }; export const environmentSetup: RecorderEnvironmentSetup = { @@ -28,9 +28,9 @@ export const environmentSetup: RecorderEnvironmentSetup = { (recording: string): string => { const replaced = recording.replace("endpoint:443", "endpoint"); return replaced; - } + }, ], - queryParametersToSkip: [] + queryParametersToSkip: [], }; export function createClient(options?: ClientOptions): DocumentTranslatorClient { From 0c02f377e3a762c28fc9c7f28e62f6f9141cc70a Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 22:58:02 +0000 Subject: [PATCH 23/37] Update with latest swagger --- .../src/documentTranslator.ts | 4 +- .../ai-document-translator-rest/src/models.ts | 20 ++--- .../src/parameters.ts | 2 +- .../src/responses.ts | 82 +++++++++---------- .../swagger/README.md | 2 +- 5 files changed, 55 insertions(+), 55 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index d43fa87a76da..3b5df4cca6aa 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -79,7 +79,7 @@ export interface GetTranslations { * If a file with the same name already exists at the destination, it will be overwritten. The targetUrl for each target language must be unique. */ post( - options?: StartTranslationParameters + options: StartTranslationParameters ): Promise< | StartTranslation202Response | StartTranslation400Response @@ -281,7 +281,7 @@ export default function DocumentTranslator( credentials: TokenCredential | KeyCredential, options: ClientOptions = {} ): DocumentTranslatorClient { - const baseUrl = options.baseUrl ?? `${endpoint}/translator/text/batch/v1.0-preview.1`; + const baseUrl = options.baseUrl ?? `${endpoint}/translator/text/batch/v1.0`; options = { ...options, credentials: { diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/models.ts b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts index ef7a33de60a9..7b232eacdedc 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/models.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts @@ -71,14 +71,14 @@ export interface Glossary { storageSource?: StorageSource; } -export interface ErrorResponseV2 { +export interface TranslationErrorResponse { /** This contains an outer error with error code, message, details, target and an inner error with more descriptive details. */ - error?: ErrorV2; + error?: TranslationError; } -export interface ErrorV2 { +export interface TranslationError { /** Enums containing high level error codes. */ - code: ErrorCodeV2; + code: TranslationErrorCode; /** Gets high level error message. */ message: string; /** @@ -90,10 +90,10 @@ export interface ErrorV2 { * New Inner Error format which conforms to Cognitive Services API Guidelines which is available at https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow. * This contains required properties ErrorCode, message and optional properties target, details(key value pair), inner error(this can be nested). */ - innerError?: InnerErrorV2; + innerError?: InnerTranslationError; } -export interface InnerErrorV2 { +export interface InnerTranslationError { /** Gets code error string. */ code: string; /** Gets high level error message. */ @@ -107,7 +107,7 @@ export interface InnerErrorV2 { * New Inner Error format which conforms to Cognitive Services API Guidelines which is available at https://microsoft.sharepoint.com/%3Aw%3A/t/CognitiveServicesPMO/EUoytcrjuJdKpeOKIK_QRC8BPtUYQpKBi8JsWyeDMRsWlQ?e=CPq8ow. * This contains required properties ErrorCode, message and optional properties target, details(key value pair), inner error(this can be nested). */ - innerError?: InnerErrorV2; + innerError?: InnerTranslationError; } export interface BatchStatusResponse { @@ -127,7 +127,7 @@ export interface BatchStatusDetail { /** List of possible statuses for job or document */ status: Status; /** This contains an outer error with error code, message, details, target and an inner error with more descriptive details. */ - error?: ErrorV2; + error?: TranslationError; /** */ summary: StatusSummary; } @@ -163,7 +163,7 @@ export interface DocumentStatusDetail { /** To language */ to: string; /** This contains an outer error with error code, message, details, target and an inner error with more descriptive details. */ - error?: ErrorV2; + error?: TranslationError; /** Progress of the translation if available */ progress: number; /** Document Id */ @@ -204,7 +204,7 @@ export interface StorageSourceListResult { export type StorageSource = "AzureBlob"; export type StorageInputType = "Folder" | "File"; -export type ErrorCodeV2 = +export type TranslationErrorCode = | "InvalidRequest" | "InvalidArgument" | "InternalServerError" diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts index 3ac16267d8cf..60238d91355e 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts @@ -5,7 +5,7 @@ import { RequestParameters } from "@azure-rest/core-client"; import { BatchSubmissionRequest } from "./models"; export interface StartTranslationBodyParam { - body?: BatchSubmissionRequest; + body: BatchSubmissionRequest; } export type StartTranslationParameters = RequestParameters & StartTranslationBodyParam; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts index c2f9ee95b358..a6b320c942a0 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts @@ -2,7 +2,7 @@ // Licensed under the MIT license. import { - ErrorResponseV2, + TranslationErrorResponse, BatchStatusResponse, DocumentStatusDetail, BatchStatusDetail, @@ -47,7 +47,7 @@ export interface StartTranslation202Response extends HttpResponse { */ export interface StartTranslation400Response extends HttpResponse { status: "400"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -63,7 +63,7 @@ export interface StartTranslation400Response extends HttpResponse { */ export interface StartTranslation401Response extends HttpResponse { status: "401"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -79,7 +79,7 @@ export interface StartTranslation401Response extends HttpResponse { */ export interface StartTranslation429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -95,7 +95,7 @@ export interface StartTranslation429Response extends HttpResponse { */ export interface StartTranslation500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -111,7 +111,7 @@ export interface StartTranslation500Response extends HttpResponse { */ export interface StartTranslation503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } export interface GetTranslations200Headers { @@ -179,7 +179,7 @@ export interface GetTranslations200Response extends HttpResponse { */ export interface GetTranslations400Response extends HttpResponse { status: "400"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -209,7 +209,7 @@ export interface GetTranslations400Response extends HttpResponse { */ export interface GetTranslations401Response extends HttpResponse { status: "401"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -239,7 +239,7 @@ export interface GetTranslations401Response extends HttpResponse { */ export interface GetTranslations429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -269,7 +269,7 @@ export interface GetTranslations429Response extends HttpResponse { */ export interface GetTranslations500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -299,7 +299,7 @@ export interface GetTranslations500Response extends HttpResponse { */ export interface GetTranslations503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } export interface GetDocument200Headers { @@ -319,31 +319,31 @@ export interface GetDocument200Response extends HttpResponse { /** Returns the translation status for a specific document based on the request Id and document Id. */ export interface GetDocument401Response extends HttpResponse { status: "401"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** Returns the translation status for a specific document based on the request Id and document Id. */ export interface GetDocument404Response extends HttpResponse { status: "404"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** Returns the translation status for a specific document based on the request Id and document Id. */ export interface GetDocument429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** Returns the translation status for a specific document based on the request Id and document Id. */ export interface GetDocument500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** Returns the translation status for a specific document based on the request Id and document Id. */ export interface GetDocument503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } export interface GetTranslationStatus200Headers { @@ -369,7 +369,7 @@ export interface GetTranslationStatus200Response extends HttpResponse { */ export interface GetTranslationStatus401Response extends HttpResponse { status: "401"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -378,7 +378,7 @@ export interface GetTranslationStatus401Response extends HttpResponse { */ export interface GetTranslationStatus404Response extends HttpResponse { status: "404"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -387,7 +387,7 @@ export interface GetTranslationStatus404Response extends HttpResponse { */ export interface GetTranslationStatus429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -396,7 +396,7 @@ export interface GetTranslationStatus429Response extends HttpResponse { */ export interface GetTranslationStatus500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -405,7 +405,7 @@ export interface GetTranslationStatus500Response extends HttpResponse { */ export interface GetTranslationStatus503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -429,7 +429,7 @@ export interface CancelTranslation200Response extends HttpResponse { */ export interface CancelTranslation401Response extends HttpResponse { status: "401"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -441,7 +441,7 @@ export interface CancelTranslation401Response extends HttpResponse { */ export interface CancelTranslation404Response extends HttpResponse { status: "404"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -453,7 +453,7 @@ export interface CancelTranslation404Response extends HttpResponse { */ export interface CancelTranslation429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -465,7 +465,7 @@ export interface CancelTranslation429Response extends HttpResponse { */ export interface CancelTranslation500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -477,7 +477,7 @@ export interface CancelTranslation500Response extends HttpResponse { */ export interface CancelTranslation503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } export interface GetDocuments200Headers { @@ -539,7 +539,7 @@ export interface GetDocuments200Response extends HttpResponse { */ export interface GetDocuments400Response extends HttpResponse { status: "400"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -566,7 +566,7 @@ export interface GetDocuments400Response extends HttpResponse { */ export interface GetDocuments401Response extends HttpResponse { status: "401"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -593,7 +593,7 @@ export interface GetDocuments401Response extends HttpResponse { */ export interface GetDocuments404Response extends HttpResponse { status: "404"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -620,7 +620,7 @@ export interface GetDocuments404Response extends HttpResponse { */ export interface GetDocuments429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -647,7 +647,7 @@ export interface GetDocuments429Response extends HttpResponse { */ export interface GetDocuments500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -674,7 +674,7 @@ export interface GetDocuments500Response extends HttpResponse { */ export interface GetDocuments503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } export interface GetSupportedDocumentFormats200Headers { @@ -698,7 +698,7 @@ export interface GetSupportedDocumentFormats200Response extends HttpResponse { */ export interface GetSupportedDocumentFormats429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -707,7 +707,7 @@ export interface GetSupportedDocumentFormats429Response extends HttpResponse { */ export interface GetSupportedDocumentFormats500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -716,7 +716,7 @@ export interface GetSupportedDocumentFormats500Response extends HttpResponse { */ export interface GetSupportedDocumentFormats503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } export interface GetSupportedGlossaryFormats200Headers { @@ -740,7 +740,7 @@ export interface GetSupportedGlossaryFormats200Response extends HttpResponse { */ export interface GetSupportedGlossaryFormats429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -749,7 +749,7 @@ export interface GetSupportedGlossaryFormats429Response extends HttpResponse { */ export interface GetSupportedGlossaryFormats500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** @@ -758,7 +758,7 @@ export interface GetSupportedGlossaryFormats500Response extends HttpResponse { */ export interface GetSupportedGlossaryFormats503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } export interface GetSupportedStorageSources200Headers { @@ -776,17 +776,17 @@ export interface GetSupportedStorageSources200Response extends HttpResponse { /** Returns a list of storage sources/options supported by the Document Translation service. */ export interface GetSupportedStorageSources429Response extends HttpResponse { status: "429"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** Returns a list of storage sources/options supported by the Document Translation service. */ export interface GetSupportedStorageSources500Response extends HttpResponse { status: "500"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } /** Returns a list of storage sources/options supported by the Document Translation service. */ export interface GetSupportedStorageSources503Response extends HttpResponse { status: "503"; - body: ErrorResponseV2; + body: TranslationErrorResponse; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md index 7f6da9658aff..1be9eef5c7e9 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md @@ -12,7 +12,7 @@ generate-metadata: false license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ source-code-folder-path: ./src -input-file: /home/jmanuelh/projects/azure-rest-api-specs/specification/cognitiveservices/data-plane/TranslatorText/preview/v1.0-preview.1/TranslatorBatch.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/fa72181c6b05abf1d96d65d380092f3efe3129ba/specification/cognitiveservices/data-plane/TranslatorText/stable/v1.0/TranslatorBatch.json package-version: 1.0.0-beta.1 hide-clients: true low-level-client: true From 3846bbd71877510fb3e187ab454f0aed592bb4d7 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Tue, 13 Apr 2021 23:04:04 +0000 Subject: [PATCH 24/37] Add regenerate script --- sdk/documenttranslator/ai-document-translator-rest/package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/documenttranslator/ai-document-translator-rest/package.json b/sdk/documenttranslator/ai-document-translator-rest/package.json index 593c30be3e3c..82b2cec6cec1 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/package.json +++ b/sdk/documenttranslator/ai-document-translator-rest/package.json @@ -55,6 +55,7 @@ }, "scripts": { "audit": "node ../../../common/scripts/rush-audit.js && rimraf node_modules package-lock.json && npm i --package-lock-only 2>&1 && npm audit", + "regenerate": "autorest --typescript swagger/README.md && npm run format", "build:browser": "tsc -p . && cross-env ONLY_BROWSER=true rollup -c 2>&1", "build:node": "tsc -p . && cross-env ONLY_NODE=true rollup -c 2>&1", "build:samples": "echo Obsolete.", From abd41f56a515c4d6d978b6d5511616be4005cab1 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 14 Apr 2021 00:25:01 +0000 Subject: [PATCH 25/37] update endpoint --- .../ai-document-translator-rest/src/documentTranslator.ts | 2 +- .../ai-document-translator-rest/swagger/README.md | 2 +- .../test/public/listFormats.spec.ts | 3 +-- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index 3b5df4cca6aa..e28914226ce9 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -281,7 +281,7 @@ export default function DocumentTranslator( credentials: TokenCredential | KeyCredential, options: ClientOptions = {} ): DocumentTranslatorClient { - const baseUrl = options.baseUrl ?? `${endpoint}/translator/text/batch/v1.0`; + const baseUrl = options.baseUrl ?? `${endpoint}/translator/text/batch/v1.0-preview.1`; options = { ...options, credentials: { diff --git a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md index 1be9eef5c7e9..994cc9aa86de 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md @@ -12,7 +12,7 @@ generate-metadata: false license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ source-code-folder-path: ./src -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/fa72181c6b05abf1d96d65d380092f3efe3129ba/specification/cognitiveservices/data-plane/TranslatorText/stable/v1.0/TranslatorBatch.json +input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/fa72181c6b05abf1d96d65d380092f3efe3129ba/specification/cognitiveservices/data-plane/TranslatorText/preview/v1.0-preview.1/TranslatorBatch.json package-version: 1.0.0-beta.1 hide-clients: true low-level-client: true diff --git a/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts b/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts index 437c97b1a8d5..d3e4fa25e527 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/test/public/listFormats.spec.ts @@ -6,7 +6,6 @@ import { Recorder } from "@azure/test-utils-recorder"; import { assert } from "chai"; import { createClient, createRecorder } from "./utils/recordedClient"; import { Context } from "mocha"; -import { fail } from "assert"; describe("List Document Formats", () => { let recorder: Recorder; @@ -25,7 +24,7 @@ describe("List Document Formats", () => { const result = await client.path("/documents/formats").get(); if (result.status !== "200") { - fail(`GET "/documents/formats" failed with ${result.status}`); + assert.fail(`GET "/documents/formats" failed with ${result.status}`); } assert.equal(result.body.value.length, 17); From ffd60a3817cf274bcb6d1a921ff7d781d52ea866 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 14 Apr 2021 01:29:36 +0000 Subject: [PATCH 26/37] Update latest swagger --- sdk/core-rest/core-client/src/sendRequest.ts | 6 +- .../review/ai-document-translator.api.md | 336 +++++++++--------- .../samples-dev/translateFromBlob.ts | 4 +- .../v1/typescript/src/translateFromBlob.ts | 4 +- .../src/documentTranslator.ts | 100 +++--- .../ai-document-translator-rest/src/models.ts | 18 +- .../src/parameters.ts | 22 +- .../src/responses.ts | 78 ++-- 8 files changed, 285 insertions(+), 283 deletions(-) diff --git a/sdk/core-rest/core-client/src/sendRequest.ts b/sdk/core-rest/core-client/src/sendRequest.ts index d581594056a7..3101718b0526 100644 --- a/sdk/core-rest/core-client/src/sendRequest.ts +++ b/sdk/core-rest/core-client/src/sendRequest.ts @@ -28,8 +28,10 @@ export async function sendRequest( const body = options.body !== undefined ? JSON.stringify(options.body) : undefined; const headers = createHttpHeaders({ - ...(body !== undefined && { accept: options.accept ?? "application/json" }), - "content-type": options.contentType ?? getContentType(options.body), + accept: options.accept ?? "application/json", + ...(body !== undefined && { + "content-type": options.contentType ?? getContentType(options.body), + }), ...(options.headers ? options.headers : {}), }); diff --git a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md index d52c74f6d19a..c4f34e7b33a4 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md +++ b/sdk/documenttranslator/ai-document-translator-rest/review/ai-document-translator.api.md @@ -19,28 +19,6 @@ export interface BatchRequest { targets: TargetInput[]; } -// @public (undocumented) -export interface BatchStatusDetail { - createdDateTimeUtc: Date; - error?: ErrorV2; - id: string; - lastActionDateTimeUtc: Date; - status: Status; - // (undocumented) - summary: StatusSummary; -} - -// @public (undocumented) -export interface BatchStatusResponse { - nextLink?: string; - value: BatchStatusDetail[]; -} - -// @public (undocumented) -export interface BatchSubmissionRequest { - inputs: BatchRequest[]; -} - // @public (undocumented) export interface CancelTranslation { delete(options?: CancelTranslationParameters): Promise; @@ -50,7 +28,7 @@ export interface CancelTranslation { // @public export interface CancelTranslation200Response extends HttpResponse { // (undocumented) - body: BatchStatusDetail; + body: TranslationStatus; // (undocumented) status: "200"; } @@ -58,7 +36,7 @@ export interface CancelTranslation200Response extends HttpResponse { // @public export interface CancelTranslation401Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "401"; } @@ -66,7 +44,7 @@ export interface CancelTranslation401Response extends HttpResponse { // @public export interface CancelTranslation404Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "404"; } @@ -74,7 +52,7 @@ export interface CancelTranslation404Response extends HttpResponse { // @public export interface CancelTranslation429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } @@ -82,7 +60,7 @@ export interface CancelTranslation429Response extends HttpResponse { // @public export interface CancelTranslation500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } @@ -90,7 +68,7 @@ export interface CancelTranslation500Response extends HttpResponse { // @public export interface CancelTranslation503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } @@ -105,10 +83,16 @@ export interface DocumentFilter { } // @public (undocumented) -export interface DocumentStatusDetail { +export interface DocumentsStatus { + nextLink?: string; + value: DocumentStatus[]; +} + +// @public (undocumented) +export interface DocumentStatus { characterCharged?: number; createdDateTimeUtc: Date; - error?: ErrorV2; + error?: TranslationError; id: string; lastActionDateTimeUtc: Date; path?: string; @@ -118,12 +102,6 @@ export interface DocumentStatusDetail { to: string; } -// @public (undocumented) -export interface DocumentStatusResponse { - nextLink?: string; - value: DocumentStatusDetail[]; -} - // @public (undocumented) function DocumentTranslator(endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslatorClient; @@ -140,22 +118,6 @@ export interface DocumentTranslatorFactory { (endpoint: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): void; } -// @public (undocumented) -export type ErrorCodeV2 = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "ResourceNotFound" | "Unauthorized" | "RequestRateTooHigh"; - -// @public (undocumented) -export interface ErrorResponseV2 { - error?: ErrorV2; -} - -// @public (undocumented) -export interface ErrorV2 { - code: ErrorCodeV2; - innerError?: InnerErrorV2; - message: string; - target?: string; -} - // @public (undocumented) export interface FileFormat { contentTypes: string[]; @@ -166,163 +128,158 @@ export interface FileFormat { } // @public (undocumented) -export interface FileFormatListResult { - value: FileFormat[]; -} - -// @public (undocumented) -export interface GetDocument { - get(options?: GetDocumentParameters): Promise; +export interface GetDocumentsStatus { + get(options?: GetDocumentsStatusParameters): Promise; } // @public (undocumented) -export interface GetDocument200Headers { +export interface GetDocumentsStatus200Headers { "retry-after"?: string; etag?: string; } // @public -export interface GetDocument200Response extends HttpResponse { +export interface GetDocumentsStatus200Response extends HttpResponse { // (undocumented) - body: DocumentStatusDetail; + body: DocumentsStatus; // (undocumented) - headers: RawHttpHeaders & GetDocument200Headers; + headers: RawHttpHeaders & GetDocumentsStatus200Headers; // (undocumented) status: "200"; } // @public -export interface GetDocument401Response extends HttpResponse { +export interface GetDocumentsStatus400Response extends HttpResponse { + // (undocumented) + body: TranslationErrorResponse; + // (undocumented) + status: "400"; +} + +// @public +export interface GetDocumentsStatus401Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "401"; } // @public -export interface GetDocument404Response extends HttpResponse { +export interface GetDocumentsStatus404Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "404"; } // @public -export interface GetDocument429Response extends HttpResponse { +export interface GetDocumentsStatus429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } // @public -export interface GetDocument500Response extends HttpResponse { +export interface GetDocumentsStatus500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } // @public -export interface GetDocument503Response extends HttpResponse { +export interface GetDocumentsStatus503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } // @public (undocumented) -export type GetDocumentParameters = RequestParameters; +export type GetDocumentsStatusParameters = RequestParameters & GetDocumentsStatusQueryParam; + +// @public (undocumented) +export interface GetDocumentsStatusQueryParam { + // (undocumented) + queryParameters?: GetDocumentsStatusQueryParamProperties; +} + +// @public (undocumented) +export interface GetDocumentsStatusQueryParamProperties { + $maxpagesize?: number; + $orderBy?: string[]; + $skip?: number; + $top?: number; + createdDateTimeUtcEnd?: Date; + createdDateTimeUtcStart?: Date; + ids?: string[]; + statuses?: string[]; +} // @public (undocumented) -export interface GetDocuments { - get(options?: GetDocumentsParameters): Promise; +export interface GetDocumentStatus { + get(options?: GetDocumentStatusParameters): Promise; } // @public (undocumented) -export interface GetDocuments200Headers { +export interface GetDocumentStatus200Headers { "retry-after"?: string; etag?: string; } // @public -export interface GetDocuments200Response extends HttpResponse { +export interface GetDocumentStatus200Response extends HttpResponse { // (undocumented) - body: DocumentStatusResponse; + body: DocumentStatus; // (undocumented) - headers: RawHttpHeaders & GetDocuments200Headers; + headers: RawHttpHeaders & GetDocumentStatus200Headers; // (undocumented) status: "200"; } // @public -export interface GetDocuments400Response extends HttpResponse { - // (undocumented) - body: ErrorResponseV2; - // (undocumented) - status: "400"; -} - -// @public -export interface GetDocuments401Response extends HttpResponse { +export interface GetDocumentStatus401Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "401"; } // @public -export interface GetDocuments404Response extends HttpResponse { +export interface GetDocumentStatus404Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "404"; } // @public -export interface GetDocuments429Response extends HttpResponse { +export interface GetDocumentStatus429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } // @public -export interface GetDocuments500Response extends HttpResponse { +export interface GetDocumentStatus500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } // @public -export interface GetDocuments503Response extends HttpResponse { +export interface GetDocumentStatus503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } // @public (undocumented) -export type GetDocumentsParameters = RequestParameters & GetDocumentsQueryParam; - -// @public (undocumented) -export interface GetDocumentsQueryParam { - // (undocumented) - queryParameters?: GetDocumentsQueryParamProperties; -} - -// @public (undocumented) -export interface GetDocumentsQueryParamProperties { - $maxpagesize?: number; - $orderBy?: string[]; - $skip?: number; - $top?: number; - createdDateTimeUtcEnd?: Date; - createdDateTimeUtcStart?: Date; - ids?: string[]; - statuses?: string[]; -} +export type GetDocumentStatusParameters = RequestParameters; // @public (undocumented) export interface GetSupportedDocumentFormats { @@ -337,7 +294,7 @@ export interface GetSupportedDocumentFormats200Headers { // @public export interface GetSupportedDocumentFormats200Response extends HttpResponse { // (undocumented) - body: FileFormatListResult; + body: SupportedFileFormats; // (undocumented) headers: RawHttpHeaders & GetSupportedDocumentFormats200Headers; // (undocumented) @@ -347,7 +304,7 @@ export interface GetSupportedDocumentFormats200Response extends HttpResponse { // @public export interface GetSupportedDocumentFormats429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } @@ -355,7 +312,7 @@ export interface GetSupportedDocumentFormats429Response extends HttpResponse { // @public export interface GetSupportedDocumentFormats500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } @@ -363,7 +320,7 @@ export interface GetSupportedDocumentFormats500Response extends HttpResponse { // @public export interface GetSupportedDocumentFormats503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } @@ -384,7 +341,7 @@ export interface GetSupportedGlossaryFormats200Headers { // @public export interface GetSupportedGlossaryFormats200Response extends HttpResponse { // (undocumented) - body: FileFormatListResult; + body: SupportedFileFormats; // (undocumented) headers: RawHttpHeaders & GetSupportedGlossaryFormats200Headers; // (undocumented) @@ -394,7 +351,7 @@ export interface GetSupportedGlossaryFormats200Response extends HttpResponse { // @public export interface GetSupportedGlossaryFormats429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } @@ -402,7 +359,7 @@ export interface GetSupportedGlossaryFormats429Response extends HttpResponse { // @public export interface GetSupportedGlossaryFormats500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } @@ -410,7 +367,7 @@ export interface GetSupportedGlossaryFormats500Response extends HttpResponse { // @public export interface GetSupportedGlossaryFormats503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } @@ -431,7 +388,7 @@ export interface GetSupportedStorageSources200Headers { // @public export interface GetSupportedStorageSources200Response extends HttpResponse { // (undocumented) - body: StorageSourceListResult; + body: SupportedStorageSources; // (undocumented) headers: RawHttpHeaders & GetSupportedStorageSources200Headers; // (undocumented) @@ -441,7 +398,7 @@ export interface GetSupportedStorageSources200Response extends HttpResponse { // @public export interface GetSupportedStorageSources429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } @@ -449,7 +406,7 @@ export interface GetSupportedStorageSources429Response extends HttpResponse { // @public export interface GetSupportedStorageSources500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } @@ -457,7 +414,7 @@ export interface GetSupportedStorageSources500Response extends HttpResponse { // @public export interface GetSupportedStorageSources503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } @@ -466,78 +423,78 @@ export interface GetSupportedStorageSources503Response extends HttpResponse { export type GetSupportedStorageSourcesParameters = RequestParameters; // @public (undocumented) -export interface GetTranslations { - get(options?: GetTranslationsParameters): Promise; - post(options?: StartTranslationParameters): Promise; +export interface GetTranslationsStatus { + get(options?: GetTranslationsStatusParameters): Promise; + post(options: StartTranslationParameters): Promise; } // @public (undocumented) -export interface GetTranslations200Headers { +export interface GetTranslationsStatus200Headers { "retry-after"?: string; etag?: string; } // @public -export interface GetTranslations200Response extends HttpResponse { +export interface GetTranslationsStatus200Response extends HttpResponse { // (undocumented) - body: BatchStatusResponse; + body: TranslationsStatus; // (undocumented) - headers: RawHttpHeaders & GetTranslations200Headers; + headers: RawHttpHeaders & GetTranslationsStatus200Headers; // (undocumented) status: "200"; } // @public -export interface GetTranslations400Response extends HttpResponse { +export interface GetTranslationsStatus400Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "400"; } // @public -export interface GetTranslations401Response extends HttpResponse { +export interface GetTranslationsStatus401Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "401"; } // @public -export interface GetTranslations429Response extends HttpResponse { +export interface GetTranslationsStatus429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } // @public -export interface GetTranslations500Response extends HttpResponse { +export interface GetTranslationsStatus500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } // @public -export interface GetTranslations503Response extends HttpResponse { +export interface GetTranslationsStatus503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } // @public (undocumented) -export type GetTranslationsParameters = RequestParameters & GetTranslationsQueryParam; +export type GetTranslationsStatusParameters = RequestParameters & GetTranslationsStatusQueryParam; // @public (undocumented) -export interface GetTranslationsQueryParam { +export interface GetTranslationsStatusQueryParam { // (undocumented) - queryParameters?: GetTranslationsQueryParamProperties; + queryParameters?: GetTranslationsStatusQueryParamProperties; } // @public (undocumented) -export interface GetTranslationsQueryParamProperties { +export interface GetTranslationsStatusQueryParamProperties { $maxpagesize?: number; $orderBy?: string[]; $skip?: number; @@ -557,7 +514,7 @@ export interface GetTranslationStatus200Headers { // @public export interface GetTranslationStatus200Response extends HttpResponse { // (undocumented) - body: BatchStatusDetail; + body: TranslationStatus; // (undocumented) headers: RawHttpHeaders & GetTranslationStatus200Headers; // (undocumented) @@ -567,7 +524,7 @@ export interface GetTranslationStatus200Response extends HttpResponse { // @public export interface GetTranslationStatus401Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "401"; } @@ -575,7 +532,7 @@ export interface GetTranslationStatus401Response extends HttpResponse { // @public export interface GetTranslationStatus404Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "404"; } @@ -583,7 +540,7 @@ export interface GetTranslationStatus404Response extends HttpResponse { // @public export interface GetTranslationStatus429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } @@ -591,7 +548,7 @@ export interface GetTranslationStatus429Response extends HttpResponse { // @public export interface GetTranslationStatus500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } @@ -599,7 +556,7 @@ export interface GetTranslationStatus500Response extends HttpResponse { // @public export interface GetTranslationStatus503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } @@ -616,19 +573,19 @@ export interface Glossary { } // @public (undocumented) -export interface InnerErrorV2 { +export interface InnerTranslationError { code: string; - innerError?: InnerErrorV2; + innerError?: InnerTranslationError; message: string; target?: string; } // @public (undocumented) export interface Routes { - (path: "/batches"): GetTranslations; - (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocument; + (path: "/batches"): GetTranslationsStatus; + (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; (path: "/batches/{id}", id: string): CancelTranslation; - (path: "/batches/{id}/documents", id: string): GetDocuments; + (path: "/batches/{id}/documents", id: string): GetDocumentsStatus; (path: "/documents/formats"): GetSupportedDocumentFormats; (path: "/glossaries/formats"): GetSupportedGlossaryFormats; (path: "/storagesources"): GetSupportedStorageSources; @@ -659,7 +616,7 @@ export interface StartTranslation202Response extends HttpResponse { // @public export interface StartTranslation400Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "400"; } @@ -667,7 +624,7 @@ export interface StartTranslation400Response extends HttpResponse { // @public export interface StartTranslation401Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "401"; } @@ -675,7 +632,7 @@ export interface StartTranslation401Response extends HttpResponse { // @public export interface StartTranslation429Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "429"; } @@ -683,7 +640,7 @@ export interface StartTranslation429Response extends HttpResponse { // @public export interface StartTranslation500Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "500"; } @@ -691,7 +648,7 @@ export interface StartTranslation500Response extends HttpResponse { // @public export interface StartTranslation503Response extends HttpResponse { // (undocumented) - body: ErrorResponseV2; + body: TranslationErrorResponse; // (undocumented) status: "503"; } @@ -699,7 +656,12 @@ export interface StartTranslation503Response extends HttpResponse { // @public (undocumented) export interface StartTranslationBodyParam { // (undocumented) - body?: BatchSubmissionRequest; + body: StartTranslationDetails; +} + +// @public (undocumented) +export interface StartTranslationDetails { + inputs: BatchRequest[]; } // @public (undocumented) @@ -726,7 +688,12 @@ export type StorageInputType = "Folder" | "File"; export type StorageSource = "AzureBlob"; // @public (undocumented) -export interface StorageSourceListResult { +export interface SupportedFileFormats { + value: FileFormat[]; +} + +// @public (undocumented) +export interface SupportedStorageSources { value: "AzureBlob"[]; } @@ -739,5 +706,38 @@ export interface TargetInput { targetUrl: string; } +// @public (undocumented) +export interface TranslationError { + code: TranslationErrorCode; + innerError?: InnerTranslationError; + message: string; + target?: string; +} + +// @public (undocumented) +export type TranslationErrorCode = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "ResourceNotFound" | "Unauthorized" | "RequestRateTooHigh"; + +// @public (undocumented) +export interface TranslationErrorResponse { + error?: TranslationError; +} + +// @public (undocumented) +export interface TranslationsStatus { + nextLink?: string; + value: TranslationStatus[]; +} + +// @public (undocumented) +export interface TranslationStatus { + createdDateTimeUtc: Date; + error?: TranslationError; + id: string; + lastActionDateTimeUtc: Date; + status: Status; + // (undocumented) + summary: StatusSummary; +} + ``` diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts index 08e0f734ad32..f91934681670 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples-dev/translateFromBlob.ts @@ -14,7 +14,7 @@ * @azsdk-weight 40 */ -import DocumentTranslator, { BatchSubmissionRequest } from "@azure-rest/ai-document-translator"; +import DocumentTranslator, { StartTranslationDetails } from "@azure-rest/ai-document-translator"; import * as dotenv from "dotenv"; dotenv.config(); @@ -40,7 +40,7 @@ const targetContainer = process.env["TARGET_CONTAINER"] || ""; * This is the body that we need to send to the /batch endpoint * to start a translation job on all the documents in sourceContainer */ -const batchSubmissionRequest: BatchSubmissionRequest = { +const batchSubmissionRequest: StartTranslationDetails = { inputs: [ { source: { sourceUrl: sourceContainer }, diff --git a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts index b32584d53f36..f41e708ef4b3 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/samples/v1/typescript/src/translateFromBlob.ts @@ -13,7 +13,7 @@ * @summary translates a collection of documents */ -import DocumentTranslator, { BatchSubmissionRequest } from "@azure-rest/ai-document-translator"; +import DocumentTranslator, { StartTranslationDetails } from "@azure-rest/ai-document-translator"; import * as dotenv from "dotenv"; dotenv.config(); @@ -39,7 +39,7 @@ const targetContainer = process.env["TARGET_CONTAINER"] || ""; * This is the body that we need to send to the /batch endpoint * to start a translation job on all the documents in sourceContainer */ -const batchSubmissionRequest: BatchSubmissionRequest = { +const batchSubmissionRequest: StartTranslationDetails = { inputs: [ { source: { sourceUrl: sourceContainer }, diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts index e28914226ce9..4fa8377a030e 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/documentTranslator.ts @@ -3,11 +3,11 @@ import { StartTranslationParameters, - GetTranslationsParameters, - GetDocumentParameters, + GetTranslationsStatusParameters, + GetDocumentStatusParameters, GetTranslationStatusParameters, CancelTranslationParameters, - GetDocumentsParameters, + GetDocumentsStatusParameters, GetSupportedDocumentFormatsParameters, GetSupportedGlossaryFormatsParameters, GetSupportedStorageSourcesParameters, @@ -19,18 +19,18 @@ import { StartTranslation429Response, StartTranslation500Response, StartTranslation503Response, - GetTranslations200Response, - GetTranslations400Response, - GetTranslations401Response, - GetTranslations429Response, - GetTranslations500Response, - GetTranslations503Response, - GetDocument200Response, - GetDocument401Response, - GetDocument404Response, - GetDocument429Response, - GetDocument500Response, - GetDocument503Response, + GetTranslationsStatus200Response, + GetTranslationsStatus400Response, + GetTranslationsStatus401Response, + GetTranslationsStatus429Response, + GetTranslationsStatus500Response, + GetTranslationsStatus503Response, + GetDocumentStatus200Response, + GetDocumentStatus401Response, + GetDocumentStatus404Response, + GetDocumentStatus429Response, + GetDocumentStatus500Response, + GetDocumentStatus503Response, GetTranslationStatus200Response, GetTranslationStatus401Response, GetTranslationStatus404Response, @@ -43,13 +43,13 @@ import { CancelTranslation429Response, CancelTranslation500Response, CancelTranslation503Response, - GetDocuments200Response, - GetDocuments400Response, - GetDocuments401Response, - GetDocuments404Response, - GetDocuments429Response, - GetDocuments500Response, - GetDocuments503Response, + GetDocumentsStatus200Response, + GetDocumentsStatus400Response, + GetDocumentsStatus401Response, + GetDocumentsStatus404Response, + GetDocumentsStatus429Response, + GetDocumentsStatus500Response, + GetDocumentsStatus503Response, GetSupportedDocumentFormats200Response, GetSupportedDocumentFormats429Response, GetSupportedDocumentFormats500Response, @@ -66,7 +66,7 @@ import { import { getClient, ClientOptions, Client } from "@azure-rest/core-client"; import { KeyCredential, TokenCredential } from "@azure/core-auth"; -export interface GetTranslations { +export interface GetTranslationsStatus { /** * Use this API to submit a bulk (batch) translation request to the Document Translation service. * Each request can contain multiple documents and must contain a source and destination container for each document. @@ -114,28 +114,28 @@ export interface GetTranslations { * This reduces the risk of the client making assumptions about the data returned. */ get( - options?: GetTranslationsParameters + options?: GetTranslationsStatusParameters ): Promise< - | GetTranslations200Response - | GetTranslations400Response - | GetTranslations401Response - | GetTranslations429Response - | GetTranslations500Response - | GetTranslations503Response + | GetTranslationsStatus200Response + | GetTranslationsStatus400Response + | GetTranslationsStatus401Response + | GetTranslationsStatus429Response + | GetTranslationsStatus500Response + | GetTranslationsStatus503Response >; } -export interface GetDocument { +export interface GetDocumentStatus { /** Returns the translation status for a specific document based on the request Id and document Id. */ get( - options?: GetDocumentParameters + options?: GetDocumentStatusParameters ): Promise< - | GetDocument200Response - | GetDocument401Response - | GetDocument404Response - | GetDocument429Response - | GetDocument500Response - | GetDocument503Response + | GetDocumentStatus200Response + | GetDocumentStatus401Response + | GetDocumentStatus404Response + | GetDocumentStatus429Response + | GetDocumentStatus500Response + | GetDocumentStatus503Response >; } @@ -173,7 +173,7 @@ export interface CancelTranslation { >; } -export interface GetDocuments { +export interface GetDocumentsStatus { /** * Returns the status for all documents in a batch document translation request. * @@ -197,15 +197,15 @@ export interface GetDocuments { * This reduces the risk of the client making assumptions about the data returned. */ get( - options?: GetDocumentsParameters + options?: GetDocumentsStatusParameters ): Promise< - | GetDocuments200Response - | GetDocuments400Response - | GetDocuments401Response - | GetDocuments404Response - | GetDocuments429Response - | GetDocuments500Response - | GetDocuments503Response + | GetDocumentsStatus200Response + | GetDocumentsStatus400Response + | GetDocumentsStatus401Response + | GetDocumentsStatus404Response + | GetDocumentsStatus429Response + | GetDocumentsStatus500Response + | GetDocumentsStatus503Response >; } @@ -253,13 +253,13 @@ export interface GetSupportedStorageSources { export interface Routes { /** Resource for '/batches' has methods for the following verbs: post, get */ - (path: "/batches"): GetTranslations; + (path: "/batches"): GetTranslationsStatus; /** Resource for '/batches/\{id\}/documents/\{documentId\}' has methods for the following verbs: get */ - (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocument; + (path: "/batches/{id}/documents/{documentId}", id: string, documentId: string): GetDocumentStatus; /** Resource for '/batches/\{id\}' has methods for the following verbs: get, delete */ (path: "/batches/{id}", id: string): CancelTranslation; /** Resource for '/batches/\{id\}/documents' has methods for the following verbs: get */ - (path: "/batches/{id}/documents", id: string): GetDocuments; + (path: "/batches/{id}/documents", id: string): GetDocumentsStatus; /** Resource for '/documents/formats' has methods for the following verbs: get */ (path: "/documents/formats"): GetSupportedDocumentFormats; /** Resource for '/glossaries/formats' has methods for the following verbs: get */ diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/models.ts b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts index 7b232eacdedc..e4b93709bca5 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/models.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/models.ts @@ -1,7 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -export interface BatchSubmissionRequest { +export interface StartTranslationDetails { /** The input list of documents or folders containing documents */ inputs: BatchRequest[]; } @@ -110,14 +110,14 @@ export interface InnerTranslationError { innerError?: InnerTranslationError; } -export interface BatchStatusResponse { +export interface TranslationsStatus { /** The summary status of individual operation */ - value: BatchStatusDetail[]; + value: TranslationStatus[]; /** Url for the next page. Null if no more pages available */ nextLink?: string; } -export interface BatchStatusDetail { +export interface TranslationStatus { /** Id of the operation. */ id: string; /** Operation created date time */ @@ -149,7 +149,7 @@ export interface StatusSummary { totalCharacterCharged: number; } -export interface DocumentStatusDetail { +export interface DocumentStatus { /** Location of the document or folder */ path?: string; /** Location of the source document */ @@ -172,14 +172,14 @@ export interface DocumentStatusDetail { characterCharged?: number; } -export interface DocumentStatusResponse { +export interface DocumentsStatus { /** The detail status of individual documents */ - value: DocumentStatusDetail[]; + value: DocumentStatus[]; /** Url for the next page. Null if no more pages available */ nextLink?: string; } -export interface FileFormatListResult { +export interface SupportedFileFormats { /** list of objects */ value: FileFormat[]; } @@ -197,7 +197,7 @@ export interface FileFormat { versions?: string[]; } -export interface StorageSourceListResult { +export interface SupportedStorageSources { /** list of objects */ value: "AzureBlob"[]; } diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts index 60238d91355e..60b9cbb0e33e 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/parameters.ts @@ -2,15 +2,15 @@ // Licensed under the MIT license. import { RequestParameters } from "@azure-rest/core-client"; -import { BatchSubmissionRequest } from "./models"; +import { StartTranslationDetails } from "./models"; export interface StartTranslationBodyParam { - body: BatchSubmissionRequest; + body: StartTranslationDetails; } export type StartTranslationParameters = RequestParameters & StartTranslationBodyParam; -export interface GetTranslationsQueryParamProperties { +export interface GetTranslationsStatusQueryParamProperties { /** * $top indicates the total number of records the user wants to be returned across all pages. * @@ -47,16 +47,16 @@ export interface GetTranslationsQueryParamProperties { $orderBy?: string[]; } -export interface GetTranslationsQueryParam { - queryParameters?: GetTranslationsQueryParamProperties; +export interface GetTranslationsStatusQueryParam { + queryParameters?: GetTranslationsStatusQueryParamProperties; } -export type GetTranslationsParameters = RequestParameters & GetTranslationsQueryParam; -export type GetDocumentParameters = RequestParameters; +export type GetTranslationsStatusParameters = RequestParameters & GetTranslationsStatusQueryParam; +export type GetDocumentStatusParameters = RequestParameters; export type GetTranslationStatusParameters = RequestParameters; export type CancelTranslationParameters = RequestParameters; -export interface GetDocumentsQueryParamProperties { +export interface GetDocumentsStatusQueryParamProperties { /** * $top indicates the total number of records the user wants to be returned across all pages. * @@ -93,11 +93,11 @@ export interface GetDocumentsQueryParamProperties { $orderBy?: string[]; } -export interface GetDocumentsQueryParam { - queryParameters?: GetDocumentsQueryParamProperties; +export interface GetDocumentsStatusQueryParam { + queryParameters?: GetDocumentsStatusQueryParamProperties; } -export type GetDocumentsParameters = RequestParameters & GetDocumentsQueryParam; +export type GetDocumentsStatusParameters = RequestParameters & GetDocumentsStatusQueryParam; export type GetSupportedDocumentFormatsParameters = RequestParameters; export type GetSupportedGlossaryFormatsParameters = RequestParameters; export type GetSupportedStorageSourcesParameters = RequestParameters; diff --git a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts index a6b320c942a0..5a56d92627af 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts +++ b/sdk/documenttranslator/ai-document-translator-rest/src/responses.ts @@ -3,12 +3,12 @@ import { TranslationErrorResponse, - BatchStatusResponse, - DocumentStatusDetail, - BatchStatusDetail, - DocumentStatusResponse, - FileFormatListResult, - StorageSourceListResult, + TranslationsStatus, + DocumentStatus, + TranslationStatus, + DocumentsStatus, + SupportedFileFormats, + SupportedStorageSources, } from "./models"; import { HttpResponse } from "@azure-rest/core-client"; import { RawHttpHeaders } from "@azure/core-rest-pipeline"; @@ -114,7 +114,7 @@ export interface StartTranslation503Response extends HttpResponse { body: TranslationErrorResponse; } -export interface GetTranslations200Headers { +export interface GetTranslationsStatus200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ @@ -146,10 +146,10 @@ export interface GetTranslations200Headers { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetTranslations200Response extends HttpResponse { +export interface GetTranslationsStatus200Response extends HttpResponse { status: "200"; - body: BatchStatusResponse; - headers: RawHttpHeaders & GetTranslations200Headers; + body: TranslationsStatus; + headers: RawHttpHeaders & GetTranslationsStatus200Headers; } /** @@ -177,7 +177,7 @@ export interface GetTranslations200Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetTranslations400Response extends HttpResponse { +export interface GetTranslationsStatus400Response extends HttpResponse { status: "400"; body: TranslationErrorResponse; } @@ -207,7 +207,7 @@ export interface GetTranslations400Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetTranslations401Response extends HttpResponse { +export interface GetTranslationsStatus401Response extends HttpResponse { status: "401"; body: TranslationErrorResponse; } @@ -237,7 +237,7 @@ export interface GetTranslations401Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetTranslations429Response extends HttpResponse { +export interface GetTranslationsStatus429Response extends HttpResponse { status: "429"; body: TranslationErrorResponse; } @@ -267,7 +267,7 @@ export interface GetTranslations429Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetTranslations500Response extends HttpResponse { +export interface GetTranslationsStatus500Response extends HttpResponse { status: "500"; body: TranslationErrorResponse; } @@ -297,12 +297,12 @@ export interface GetTranslations500Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetTranslations503Response extends HttpResponse { +export interface GetTranslationsStatus503Response extends HttpResponse { status: "503"; body: TranslationErrorResponse; } -export interface GetDocument200Headers { +export interface GetDocumentStatus200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ @@ -310,38 +310,38 @@ export interface GetDocument200Headers { } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocument200Response extends HttpResponse { +export interface GetDocumentStatus200Response extends HttpResponse { status: "200"; - body: DocumentStatusDetail; - headers: RawHttpHeaders & GetDocument200Headers; + body: DocumentStatus; + headers: RawHttpHeaders & GetDocumentStatus200Headers; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocument401Response extends HttpResponse { +export interface GetDocumentStatus401Response extends HttpResponse { status: "401"; body: TranslationErrorResponse; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocument404Response extends HttpResponse { +export interface GetDocumentStatus404Response extends HttpResponse { status: "404"; body: TranslationErrorResponse; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocument429Response extends HttpResponse { +export interface GetDocumentStatus429Response extends HttpResponse { status: "429"; body: TranslationErrorResponse; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocument500Response extends HttpResponse { +export interface GetDocumentStatus500Response extends HttpResponse { status: "500"; body: TranslationErrorResponse; } /** Returns the translation status for a specific document based on the request Id and document Id. */ -export interface GetDocument503Response extends HttpResponse { +export interface GetDocumentStatus503Response extends HttpResponse { status: "503"; body: TranslationErrorResponse; } @@ -359,7 +359,7 @@ export interface GetTranslationStatus200Headers { */ export interface GetTranslationStatus200Response extends HttpResponse { status: "200"; - body: BatchStatusDetail; + body: TranslationStatus; headers: RawHttpHeaders & GetTranslationStatus200Headers; } @@ -417,7 +417,7 @@ export interface GetTranslationStatus503Response extends HttpResponse { */ export interface CancelTranslation200Response extends HttpResponse { status: "200"; - body: BatchStatusDetail; + body: TranslationStatus; } /** @@ -480,7 +480,7 @@ export interface CancelTranslation503Response extends HttpResponse { body: TranslationErrorResponse; } -export interface GetDocuments200Headers { +export interface GetDocumentsStatus200Headers { /** Indicates how long to wait before making a new request. */ "retry-after"?: string; /** The ETag response-header field provides the current value of the entity tag for the requested variant. Used with If-Match, If-None-Match and If-Range to implement optimistic concurrency control. */ @@ -509,10 +509,10 @@ export interface GetDocuments200Headers { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetDocuments200Response extends HttpResponse { +export interface GetDocumentsStatus200Response extends HttpResponse { status: "200"; - body: DocumentStatusResponse; - headers: RawHttpHeaders & GetDocuments200Headers; + body: DocumentsStatus; + headers: RawHttpHeaders & GetDocumentsStatus200Headers; } /** @@ -537,7 +537,7 @@ export interface GetDocuments200Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetDocuments400Response extends HttpResponse { +export interface GetDocumentsStatus400Response extends HttpResponse { status: "400"; body: TranslationErrorResponse; } @@ -564,7 +564,7 @@ export interface GetDocuments400Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetDocuments401Response extends HttpResponse { +export interface GetDocumentsStatus401Response extends HttpResponse { status: "401"; body: TranslationErrorResponse; } @@ -591,7 +591,7 @@ export interface GetDocuments401Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetDocuments404Response extends HttpResponse { +export interface GetDocumentsStatus404Response extends HttpResponse { status: "404"; body: TranslationErrorResponse; } @@ -618,7 +618,7 @@ export interface GetDocuments404Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetDocuments429Response extends HttpResponse { +export interface GetDocumentsStatus429Response extends HttpResponse { status: "429"; body: TranslationErrorResponse; } @@ -645,7 +645,7 @@ export interface GetDocuments429Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetDocuments500Response extends HttpResponse { +export interface GetDocumentsStatus500Response extends HttpResponse { status: "500"; body: TranslationErrorResponse; } @@ -672,7 +672,7 @@ export interface GetDocuments500Response extends HttpResponse { * Note: If the server can't honor $top and/or $skip, the server must return an error to the client informing about it instead of just ignoring the query options. * This reduces the risk of the client making assumptions about the data returned. */ -export interface GetDocuments503Response extends HttpResponse { +export interface GetDocumentsStatus503Response extends HttpResponse { status: "503"; body: TranslationErrorResponse; } @@ -688,7 +688,7 @@ export interface GetSupportedDocumentFormats200Headers { */ export interface GetSupportedDocumentFormats200Response extends HttpResponse { status: "200"; - body: FileFormatListResult; + body: SupportedFileFormats; headers: RawHttpHeaders & GetSupportedDocumentFormats200Headers; } @@ -730,7 +730,7 @@ export interface GetSupportedGlossaryFormats200Headers { */ export interface GetSupportedGlossaryFormats200Response extends HttpResponse { status: "200"; - body: FileFormatListResult; + body: SupportedFileFormats; headers: RawHttpHeaders & GetSupportedGlossaryFormats200Headers; } @@ -769,7 +769,7 @@ export interface GetSupportedStorageSources200Headers { /** Returns a list of storage sources/options supported by the Document Translation service. */ export interface GetSupportedStorageSources200Response extends HttpResponse { status: "200"; - body: StorageSourceListResult; + body: SupportedStorageSources; headers: RawHttpHeaders & GetSupportedStorageSources200Headers; } From 4db984ac60f1fa54c2cda80abbc22a78241f01ff Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 14 Apr 2021 01:35:03 +0000 Subject: [PATCH 27/37] Add sendRequest tests --- .../core-client/test/sendRequest.spec.ts | 92 +++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 sdk/core-rest/core-client/test/sendRequest.spec.ts diff --git a/sdk/core-rest/core-client/test/sendRequest.spec.ts b/sdk/core-rest/core-client/test/sendRequest.spec.ts new file mode 100644 index 000000000000..69659cc5a89a --- /dev/null +++ b/sdk/core-rest/core-client/test/sendRequest.spec.ts @@ -0,0 +1,92 @@ +import { sendRequest } from "../src/sendRequest"; +import { assert } from "chai"; +import { + createEmptyPipeline, + createHttpHeaders, + Pipeline, + PipelineResponse, +} from "@azure/core-rest-pipeline"; +describe("sendRequest", () => { + const mockBaseUrl = "https://example.org"; + + it("should send request with json body", async () => { + const mockPipeline: Pipeline = createEmptyPipeline(); + const expectedBody = { foo: "foo" }; + mockPipeline.sendRequest = async (_client, request) => { + assert.equal(request.body, JSON.stringify(expectedBody)); + return { headers: createHttpHeaders() } as PipelineResponse; + }; + + await sendRequest("POST", mockBaseUrl, mockPipeline, { body: expectedBody }); + }); + + it("should send request with undefined body", async () => { + const mockPipeline: Pipeline = createEmptyPipeline(); + mockPipeline.sendRequest = async (_client, request) => { + assert.equal(request.body, undefined); + return { headers: createHttpHeaders() } as PipelineResponse; + }; + + await sendRequest("POST", mockBaseUrl, mockPipeline, { body: undefined }); + }); + + it("should set custom content-type", async () => { + const mockPipeline: Pipeline = createEmptyPipeline(); + mockPipeline.sendRequest = async (_client, request) => { + assert.equal(request.headers.get("content-type"), "testContent"); + return { headers: createHttpHeaders() } as PipelineResponse; + }; + + await sendRequest("POST", mockBaseUrl, mockPipeline, { contentType: "testContent", body: {} }); + }); + + it("should not set content-type if no body is present", async () => { + const mockPipeline: Pipeline = createEmptyPipeline(); + mockPipeline.sendRequest = async (_client, request) => { + assert.equal(request.headers.get("content-type"), undefined); + return { headers: createHttpHeaders() } as PipelineResponse; + }; + + await sendRequest("POST", mockBaseUrl, mockPipeline, { contentType: "testContent" }); + }); + + it("should set custom accept", async () => { + const mockPipeline: Pipeline = createEmptyPipeline(); + mockPipeline.sendRequest = async (_client, request) => { + assert.equal(request.headers.get("accept"), "testContent"); + return { headers: createHttpHeaders() } as PipelineResponse; + }; + + await sendRequest("POST", mockBaseUrl, mockPipeline, { accept: "testContent" }); + }); + + it("should set custom headers", async () => { + const mockPipeline: Pipeline = createEmptyPipeline(); + mockPipeline.sendRequest = async (_client, request) => { + assert.equal(request.headers.get("foo"), "foo"); + return { headers: createHttpHeaders() } as PipelineResponse; + }; + + await sendRequest("POST", mockBaseUrl, mockPipeline, { headers: { foo: "foo" } }); + }); + + it("should set octet-stream when binary body", async () => { + const mockPipeline: Pipeline = createEmptyPipeline(); + mockPipeline.sendRequest = async (_client, request) => { + assert.equal(request.headers.get("content-type"), "application/octet-stream"); + return { headers: createHttpHeaders() } as PipelineResponse; + }; + + await sendRequest("POST", mockBaseUrl, mockPipeline, { body: new Uint8Array() }); + }); + + it("should set application/json by default if not binary", async () => { + const mockPipeline: Pipeline = createEmptyPipeline(); + mockPipeline.sendRequest = async (_client, request) => { + assert.equal(request.headers.get("content-type"), "application/json; charset=UTF-8"); + return { headers: createHttpHeaders() } as PipelineResponse; + }; + + await sendRequest("POST", mockBaseUrl, mockPipeline, { body: "test" }); + }); +}); From f77a88b314de2b79a24ff762850fc023f76328f5 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 14 Apr 2021 01:53:31 +0000 Subject: [PATCH 28/37] Add url helpers test --- .../core-client/test/urlHelpers.spec.ts | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 sdk/core-rest/core-client/test/urlHelpers.spec.ts diff --git a/sdk/core-rest/core-client/test/urlHelpers.spec.ts b/sdk/core-rest/core-client/test/urlHelpers.spec.ts new file mode 100644 index 000000000000..ff97632387de --- /dev/null +++ b/sdk/core-rest/core-client/test/urlHelpers.spec.ts @@ -0,0 +1,47 @@ +import { buildRequestUrl } from "../src/urlHelpers"; +import { assert } from "chai"; +describe("urlHelpers", () => { + const mockBaseUrl = "https://example.org"; + + it("should handle double forward slashes", () => { + const result = buildRequestUrl(`${mockBaseUrl}/`, "/foo/{id}", ["one"]); + + assert.equal(result, `https://example.org/foo/one`); + }); + + it("should append path and fill path parameters", () => { + const result = buildRequestUrl(mockBaseUrl, "/foo/{id}", ["one"]); + + assert.equal(result, `https://example.org/foo/one`); + }); + + it("should append path, fill path parameters and append query parameters", () => { + const result = buildRequestUrl(mockBaseUrl, "/foo/{id}", ["one"], { + queryParameters: { foo: "1", bar: "two" }, + }); + + assert.equal(result, `https://example.org/foo/one?foo=1&bar=two`); + }); + + it("should append path and append query parameters", () => { + const result = buildRequestUrl(mockBaseUrl, "/foo", [], { + queryParameters: { foo: "1", bar: "two" }, + }); + + assert.equal(result, `https://example.org/foo?foo=1&bar=two`); + }); + + it("should append query parameters to an url with existing params", () => { + const result = buildRequestUrl(mockBaseUrl, "/foo?existing=hey", [], { + queryParameters: { foo: "1", bar: "two" }, + }); + + assert.equal(result, `https://example.org/foo?existing=hey&foo=1&bar=two`); + }); + + it("should handle full urls as path", () => { + const result = buildRequestUrl(mockBaseUrl, "https://example2.org", []); + + assert.equal(result, `https://example2.org`); + }); +}); From 1a3c36fd73ecf0cd03e680dd60f6568d5c7611f4 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Wed, 14 Apr 2021 22:29:30 +0000 Subject: [PATCH 29/37] Update core-client --- .../core-client/review/core-client.api.md | 5 +- sdk/core-rest/core-client/src/common.ts | 18 +++++- sdk/core-rest/core-client/src/getClient.ts | 62 ++++++++++++------- 3 files changed, 58 insertions(+), 27 deletions(-) diff --git a/sdk/core-rest/core-client/review/core-client.api.md b/sdk/core-rest/core-client/review/core-client.api.md index 1b843826a1ee..ee62ba2e81ab 100644 --- a/sdk/core-rest/core-client/review/core-client.api.md +++ b/sdk/core-rest/core-client/review/core-client.api.md @@ -29,10 +29,11 @@ export interface Client { // @public export type ClientOptions = PipelineOptions & { credentials?: { - scopes?: string | string[]; + scopes?: string[]; apiKeyHeaderName?: string; }; baseUrl?: string; + apiVersion?: string; }; // @public @@ -42,7 +43,7 @@ export function createDefaultPipeline(baseUrl: string, credential?: TokenCredent export function getClient(baseUrl: string, options?: PipelineOptions): Client; // @public -export function getClient(baseUrl: string, credentials?: TokenCredential | KeyCredential, options?: PipelineOptions): Client; +export function getClient(baseUrl: string, credentials?: TokenCredential | KeyCredential, options?: ClientOptions): Client; // @public export type HttpResponse = { diff --git a/sdk/core-rest/core-client/src/common.ts b/sdk/core-rest/core-client/src/common.ts index 63e5dbbece3d..70a87a092ede 100644 --- a/sdk/core-rest/core-client/src/common.ts +++ b/sdk/core-rest/core-client/src/common.ts @@ -4,11 +4,27 @@ import { PipelineOptions, RawHttpHeaders, PipelineRequest } from "@azure/core-re * General options that a Rest Level Client can take */ export type ClientOptions = PipelineOptions & { + /** + * Credentials information + */ credentials?: { - scopes?: string | string[]; + /** + * Authentication scopes for AAD + */ + scopes?: string[]; + /** + * Heder name for Client Secret authentication + */ apiKeyHeaderName?: string; }; + /** + * Base url for the client + */ baseUrl?: string; + /** + * Options for setting a custom apiVersion. + */ + apiVersion?: string; }; /** diff --git a/sdk/core-rest/core-client/src/getClient.ts b/sdk/core-rest/core-client/src/getClient.ts index 974b9397f85c..8ab21578345c 100644 --- a/sdk/core-rest/core-client/src/getClient.ts +++ b/sdk/core-rest/core-client/src/getClient.ts @@ -1,7 +1,7 @@ import { isTokenCredential, KeyCredential, TokenCredential } from "@azure/core-auth"; -import { PipelineOptions } from "@azure/core-rest-pipeline"; +import { HttpMethods, Pipeline, PipelineOptions } from "@azure/core-rest-pipeline"; import { createDefaultPipeline } from "./clientHelpers"; -import { HttpResponse } from "./common"; +import { ClientOptions, HttpResponse } from "./common"; import { RequestParameters } from "./pathClientTypes"; import { sendRequest } from "./sendRequest"; import { buildRequestUrl } from "./urlHelpers"; @@ -53,59 +53,51 @@ export function getClient(baseUrl: string, options?: PipelineOptions): Client; export function getClient( baseUrl: string, credentials?: TokenCredential | KeyCredential, - options?: PipelineOptions + options?: ClientOptions ): Client; export function getClient( baseUrl: string, credentialsOrPipelineOptions?: (TokenCredential | KeyCredential) | PipelineOptions, - opts: PipelineOptions = {} + options: ClientOptions = {} ): Client { let credentials: TokenCredential | KeyCredential | undefined; - let options = opts; + let clientOptions = options; if (credentialsOrPipelineOptions) { if (isCredential(credentialsOrPipelineOptions)) { credentials = credentialsOrPipelineOptions; - options = opts; + clientOptions = options; } else { - options = credentialsOrPipelineOptions || {}; + clientOptions = credentialsOrPipelineOptions || {}; } } - const pipeline = createDefaultPipeline(baseUrl, credentials, options); + const pipeline = createDefaultPipeline(baseUrl, credentials, clientOptions); const client = (path: string, ...args: Array) => { return { get: (options: RequestParameters = {}): Promise => { - const url = buildRequestUrl(baseUrl, path, args, options); - return sendRequest("GET", url, pipeline, options); + return buildSendRequest("GET", clientOptions, baseUrl, path, pipeline, options, args); }, post: (options: RequestParameters = {}): Promise => { - const url = buildRequestUrl(baseUrl, path, args, options); - return sendRequest("POST", url, pipeline, options); + return buildSendRequest("POST", clientOptions, baseUrl, path, pipeline, options, args); }, put: (options: RequestParameters = {}): Promise => { - const url = buildRequestUrl(baseUrl, path, args, options); - return sendRequest("PUT", url, pipeline, options); + return buildSendRequest("PUT", clientOptions, baseUrl, path, pipeline, options, args); }, patch: (options: RequestParameters = {}): Promise => { - const url = buildRequestUrl(baseUrl, path, args, options); - return sendRequest("PATCH", url, pipeline, options); + return buildSendRequest("PATCH", clientOptions, baseUrl, path, pipeline, options, args); }, delete: (options: RequestParameters = {}): Promise => { - const url = buildRequestUrl(baseUrl, path, args, options); - return sendRequest("DELETE", url, pipeline, options); + return buildSendRequest("DELETE", clientOptions, baseUrl, path, pipeline, options, args); }, head: (options: RequestParameters = {}): Promise => { - const url = buildRequestUrl(baseUrl, path, args, options); - return sendRequest("HEAD", url, pipeline, options); + return buildSendRequest("HEAD", clientOptions, baseUrl, path, pipeline, options, args); }, options: (options: RequestParameters = {}): Promise => { - const url = buildRequestUrl(baseUrl, path, args, options); - return sendRequest("OPTIONS", url, pipeline, options); + return buildSendRequest("OPTIONS", clientOptions, baseUrl, path, pipeline, options, args); }, trace: (options: RequestParameters = {}): Promise => { - const url = buildRequestUrl(baseUrl, path, args, options); - return sendRequest("TRACE", url, pipeline, options); + return buildSendRequest("TRACE", clientOptions, baseUrl, path, pipeline, options, args); }, }; }; @@ -116,6 +108,28 @@ export function getClient( }; } +function buildSendRequest( + method: HttpMethods, + clientOptions: ClientOptions, + baseUrl: string, + path: string, + pipeline: Pipeline, + requestOptions: RequestParameters = {}, + args: string[] = [] +) { + // If the client has an api-version and the request doesn't specify one, inject the one in the client options + if (!requestOptions.queryParameters?.["api-version"] && clientOptions.apiVersion) { + if (!requestOptions.queryParameters) { + requestOptions.queryParameters = {}; + } + + requestOptions.queryParameters["api-version"] = clientOptions.apiVersion; + } + + const url = buildRequestUrl(baseUrl, path, args, requestOptions); + return sendRequest(method, url, pipeline, requestOptions); +} + function isCredential( param: (TokenCredential | KeyCredential) | PipelineOptions ): param is TokenCredential | KeyCredential { From a7f415545e0f75c0bf36f6f49539f7c2a49b4443 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 15 Apr 2021 00:35:12 +0000 Subject: [PATCH 30/37] Skip identity tracing test --- .../swagger/README.md | 18 +++++++++++++++++- .../public/node/deviceCodeCredential.spec.ts | 2 +- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md index 994cc9aa86de..06dd739eadae 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md @@ -12,7 +12,7 @@ generate-metadata: false license-header: MICROSOFT_MIT_NO_VERSION output-folder: ../ source-code-folder-path: ./src -input-file: https://raw.githubusercontent.com/Azure/azure-rest-api-specs/fa72181c6b05abf1d96d65d380092f3efe3129ba/specification/cognitiveservices/data-plane/TranslatorText/preview/v1.0-preview.1/TranslatorBatch.json +input-file: https://github.com/Azure/azure-rest-api-specs/blob/ebbdda9f9ba6cab2fbd4efccad59019a62649ea6/specification/cognitiveservices/data-plane/TranslatorText/preview/v1.0-preview.1/TranslatorBatch.json package-version: 1.0.0-beta.1 hide-clients: true low-level-client: true @@ -22,3 +22,19 @@ credential-key-header-name: "Ocp-Apim-Subscription-Key" use-extension: "@autorest/typescript": "https://aka.ms/azsdk/typescript/rlc" ``` + +```yaml +directive: + - from: swagger-document + where: $.definitions.StartTranslationDetails + transform: > + throw new Error("Hello World 1") +``` + +```yaml +directive: + - from: swagger-document + where: $.definitions + transform: > + throw new Error("Hello World 2") +``` diff --git a/sdk/identity/identity/test/public/node/deviceCodeCredential.spec.ts b/sdk/identity/identity/test/public/node/deviceCodeCredential.spec.ts index e2293e1d6dca..539152da87d6 100644 --- a/sdk/identity/identity/test/public/node/deviceCodeCredential.spec.ts +++ b/sdk/identity/identity/test/public/node/deviceCodeCredential.spec.ts @@ -116,7 +116,7 @@ describe("DeviceCodeCredential", function() { assert.ok(account); }); - it("supports tracing", async function(this: Context) { + it.skip("supports tracing", async function(this: Context) { // These tests should not run live because this credential requires user interaction. if (isLiveMode()) { this.skip(); From 9d7011b24fbf49f5d2c6db21b354860b2aec1978 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 15 Apr 2021 00:36:47 +0000 Subject: [PATCH 31/37] Remove transforms --- .../swagger/README.md | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md index 06dd739eadae..9b0f8c0cf585 100644 --- a/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md +++ b/sdk/documenttranslator/ai-document-translator-rest/swagger/README.md @@ -22,19 +22,3 @@ credential-key-header-name: "Ocp-Apim-Subscription-Key" use-extension: "@autorest/typescript": "https://aka.ms/azsdk/typescript/rlc" ``` - -```yaml -directive: - - from: swagger-document - where: $.definitions.StartTranslationDetails - transform: > - throw new Error("Hello World 1") -``` - -```yaml -directive: - - from: swagger-document - where: $.definitions - transform: > - throw new Error("Hello World 2") -``` From d73c11f05907911ea0f42fb9d039afef2b1e6816 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 15 Apr 2021 01:34:46 +0000 Subject: [PATCH 32/37] Make path of type Function --- sdk/core-rest/core-client/review/core-client.api.md | 2 +- sdk/core-rest/core-client/src/getClient.ts | 2 +- .../identity/test/public/node/deviceCodeCredential.spec.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/core-rest/core-client/review/core-client.api.md b/sdk/core-rest/core-client/review/core-client.api.md index ee62ba2e81ab..a543dc4e88f7 100644 --- a/sdk/core-rest/core-client/review/core-client.api.md +++ b/sdk/core-rest/core-client/review/core-client.api.md @@ -13,7 +13,7 @@ import { TokenCredential } from '@azure/core-auth'; // @public export interface Client { - path: unknown; + path: Function; pathUnchecked: (path: string, ...args: Array) => { get: (options?: RequestParameters) => Promise; post: (options?: RequestParameters) => Promise; diff --git a/sdk/core-rest/core-client/src/getClient.ts b/sdk/core-rest/core-client/src/getClient.ts index 8ab21578345c..d9b3323b9423 100644 --- a/sdk/core-rest/core-client/src/getClient.ts +++ b/sdk/core-rest/core-client/src/getClient.ts @@ -19,7 +19,7 @@ export interface Client { * This method will be used to send request that would check the path to provide * strong types */ - path: unknown; + path: Function; /** * This method allows arbitrary paths and doesn't provide strong types */ diff --git a/sdk/identity/identity/test/public/node/deviceCodeCredential.spec.ts b/sdk/identity/identity/test/public/node/deviceCodeCredential.spec.ts index 539152da87d6..e2293e1d6dca 100644 --- a/sdk/identity/identity/test/public/node/deviceCodeCredential.spec.ts +++ b/sdk/identity/identity/test/public/node/deviceCodeCredential.spec.ts @@ -116,7 +116,7 @@ describe("DeviceCodeCredential", function() { assert.ok(account); }); - it.skip("supports tracing", async function(this: Context) { + it("supports tracing", async function(this: Context) { // These tests should not run live because this credential requires user interaction. if (isLiveMode()) { this.skip(); From 6f537514d6b8384ea72e1addb93781a03f258009 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 15 Apr 2021 03:13:42 +0000 Subject: [PATCH 33/37] Test verify samples fix --- eng/common/pipelines/templates/steps/verify-samples.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index fcd87d2cc911..25ec73b00c6c 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -7,7 +7,6 @@ parameters: default: eng/common/scripts - name: Condition type: boolean - default: succeeded() steps: - pwsh: | From a1f37b90384681fb9265b987e6cce44bca607b8a Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 15 Apr 2021 03:21:01 +0000 Subject: [PATCH 34/37] template condition --- eng/common/pipelines/templates/steps/verify-samples.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index 25ec73b00c6c..05844393c026 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -5,8 +5,6 @@ parameters: - name: ScriptDirectory type: string default: eng/common/scripts - - name: Condition - type: boolean steps: - pwsh: | @@ -15,4 +13,3 @@ steps: Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}\Test-SampleMetadata.ps1 -AllowParentProducts displayName: Verify sample metadata workingDirectory: $(Build.SourcesDirectory) - condition: ${{ parameters.Condition }} From b40897082b5328af0744e4edd86690e8350c69b5 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 15 Apr 2021 03:23:53 +0000 Subject: [PATCH 35/37] Use succeeded directly --- eng/common/pipelines/templates/steps/verify-samples.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index 05844393c026..2337fb55be96 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -13,3 +13,4 @@ steps: Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}\Test-SampleMetadata.ps1 -AllowParentProducts displayName: Verify sample metadata workingDirectory: $(Build.SourcesDirectory) + condition: succeeded() From 47465d8c8fa4494e1c72bff0259215e53b0e2b55 Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 15 Apr 2021 03:37:04 +0000 Subject: [PATCH 36/37] Use forward slash --- eng/common/pipelines/templates/steps/verify-samples.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index 2337fb55be96..92f9fb10dab4 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -10,7 +10,7 @@ steps: - pwsh: | # If the last path segment is an absolute path it will be used entirely. $root = [System.IO.Path]::Combine('$(Build.SourcesDireectory)', 'sdk', '${{ parameters.ServiceDirectory }}') - Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}\Test-SampleMetadata.ps1 -AllowParentProducts + Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}/Test-SampleMetadata.ps1 -AllowParentProducts displayName: Verify sample metadata workingDirectory: $(Build.SourcesDirectory) condition: succeeded() From ded126bf443544e3bccb15d4cf96ce36af16f92a Mon Sep 17 00:00:00 2001 From: Jose Manuel Heredia Hidalgo Date: Thu, 15 Apr 2021 05:36:25 +0000 Subject: [PATCH 37/37] Revert changes to docs check --- eng/common/pipelines/templates/steps/verify-samples.yml | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/eng/common/pipelines/templates/steps/verify-samples.yml b/eng/common/pipelines/templates/steps/verify-samples.yml index 92f9fb10dab4..fcd87d2cc911 100644 --- a/eng/common/pipelines/templates/steps/verify-samples.yml +++ b/eng/common/pipelines/templates/steps/verify-samples.yml @@ -5,12 +5,15 @@ parameters: - name: ScriptDirectory type: string default: eng/common/scripts + - name: Condition + type: boolean + default: succeeded() steps: - pwsh: | # If the last path segment is an absolute path it will be used entirely. $root = [System.IO.Path]::Combine('$(Build.SourcesDireectory)', 'sdk', '${{ parameters.ServiceDirectory }}') - Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}/Test-SampleMetadata.ps1 -AllowParentProducts + Get-ChildItem $root -Filter *.md -Recurse | ${{ parameters.ScriptDirectory }}\Test-SampleMetadata.ps1 -AllowParentProducts displayName: Verify sample metadata workingDirectory: $(Build.SourcesDirectory) - condition: succeeded() + condition: ${{ parameters.Condition }}