Skip to content

Commit 28d9737

Browse files
Using the latest typespec commit ID and re-generating the SDK (#30940)
Using the latest typespec commit ID and re-generating the SDK
1 parent 0fb6d49 commit 28d9737

File tree

14 files changed

+141
-78
lines changed

14 files changed

+141
-78
lines changed

sdk/translation/ai-translation-document-rest/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@
4848
"dependencies": {
4949
"@azure/core-rest-pipeline": "^1.8.0",
5050
"@azure/logger": "^1.0.0",
51-
"@azure/core-paging": "^1.2.0",
51+
"@azure/core-paging": "^1.5.0",
5252
"@azure-rest/core-client": "^2.0.0",
5353
"@azure/core-auth": "^1.6.0",
5454
"tslib": "^2.6.2",
55-
"@azure/core-lro": "3.0.0-beta.1",
56-
"@azure/abort-controller": "^2.0.0"
55+
"@azure/core-lro": "^3.0.0",
56+
"@azure/abort-controller": "^2.1.2"
5757
},
5858
"devDependencies": {
5959
"@azure/storage-blob": "^12.23.0",

sdk/translation/ai-translation-document-rest/review/ai-translation-document.api.md

Lines changed: 16 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,6 @@ import { AbortSignalLike } from '@azure/abort-controller';
88
import { CancelOnProgress } from '@azure/core-lro';
99
import { Client } from '@azure-rest/core-client';
1010
import { ClientOptions } from '@azure-rest/core-client';
11-
import { createFile } from '@azure/core-rest-pipeline';
12-
import { createFileFromStream } from '@azure/core-rest-pipeline';
13-
import { CreateFileFromStreamOptions } from '@azure/core-rest-pipeline';
14-
import { CreateFileOptions } from '@azure/core-rest-pipeline';
1511
import { CreateHttpPollerOptions } from '@azure/core-lro';
1612
import { ErrorResponse } from '@azure-rest/core-client';
1713
import { HttpResponse } from '@azure-rest/core-client';
@@ -59,17 +55,9 @@ export interface CancelTranslationDefaultResponse extends HttpResponse {
5955
export type CancelTranslationParameters = RequestParameters;
6056

6157
// @public
62-
function createClient(endpointParam: string, credentials: TokenCredential | KeyCredential, options?: ClientOptions): DocumentTranslationClient;
58+
function createClient(endpointParam: string, credentials: TokenCredential | KeyCredential, { apiVersion, ...options }?: DocumentTranslationClientOptions): DocumentTranslationClient;
6359
export default createClient;
6460

65-
export { createFile }
66-
67-
export { createFileFromStream }
68-
69-
export { CreateFileFromStreamOptions }
70-
71-
export { CreateFileOptions }
72-
7361
// @public
7462
export interface DocumentFilter {
7563
prefix?: string;
@@ -103,6 +91,7 @@ export interface DocumentTranslate {
10391

10492
// @public (undocumented)
10593
export interface DocumentTranslate200Headers {
94+
"content-type": "application/octet-stream";
10695
"x-ms-client-request-id"?: string;
10796
}
10897

@@ -117,8 +106,7 @@ export interface DocumentTranslate200Response extends HttpResponse {
117106

118107
// @public (undocumented)
119108
export interface DocumentTranslateBodyParam {
120-
// (undocumented)
121-
body?: DocumentTranslateContent;
109+
body: DocumentTranslateContent;
122110
}
123111

124112
// @public
@@ -201,6 +189,11 @@ export type DocumentTranslationClient = Client & {
201189
path: Routes;
202190
};
203191

192+
// @public
193+
export interface DocumentTranslationClientOptions extends ClientOptions {
194+
apiVersion?: string;
195+
}
196+
204197
// @public
205198
export interface FileFormatOutput {
206199
contentTypes: string[];
@@ -212,7 +205,7 @@ export interface FileFormatOutput {
212205
}
213206

214207
// @public
215-
export type FileFormatType = "document" | "glossary" | string;
208+
export type FileFormatType = string;
216209

217210
// @public
218211
export type GetArrayType<T> = T extends Array<infer TData> ? TData : never;
@@ -494,6 +487,7 @@ export interface SimplePollerLike<TState extends OperationState<TResult>, TResul
494487
getOperationState(): TState;
495488
getResult(): TResult | undefined;
496489
isDone(): boolean;
490+
// @deprecated
497491
isStopped(): boolean;
498492
onProgress(callback: (state: TState) => void): CancelOnProgress;
499493
poll(options?: {
@@ -521,7 +515,7 @@ export interface SourceInput {
521515
// @public (undocumented)
522516
export interface StartTranslation {
523517
get(options?: GetTranslationsStatusParameters): StreamableMethod<GetTranslationsStatus200Response | GetTranslationsStatusDefaultResponse>;
524-
post(options?: StartTranslationParameters): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
518+
post(options: StartTranslationParameters): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
525519
}
526520

527521
// @public (undocumented)
@@ -539,8 +533,7 @@ export interface StartTranslation202Response extends HttpResponse {
539533

540534
// @public (undocumented)
541535
export interface StartTranslationBodyParam {
542-
// (undocumented)
543-
body?: StartTranslationDetails;
536+
body: StartTranslationDetails;
544537
}
545538

546539
// @public (undocumented)
@@ -573,7 +566,7 @@ export interface StartTranslationLogicalResponse extends HttpResponse {
573566
export type StartTranslationParameters = StartTranslationBodyParam & RequestParameters;
574567

575568
// @public
576-
export type StatusOutput = "NotStarted" | "Running" | "Succeeded" | "Failed" | "Cancelled" | "Cancelling" | "ValidationFailed" | string;
569+
export type StatusOutput = string;
577570

578571
// @public
579572
export interface StatusSummaryOutput {
@@ -587,10 +580,10 @@ export interface StatusSummaryOutput {
587580
}
588581

589582
// @public
590-
export type StorageInputType = "Folder" | "File" | string;
583+
export type StorageInputType = string;
591584

592585
// @public
593-
export type StorageSource = "AzureBlob" | string;
586+
export type StorageSource = string;
594587

595588
// @public
596589
export interface SupportedFileFormatsOutput {
@@ -607,7 +600,7 @@ export interface TargetInput {
607600
}
608601

609602
// @public
610-
export type TranslationErrorCodeOutput = "InvalidRequest" | "InvalidArgument" | "InternalServerError" | "ServiceUnavailable" | "ResourceNotFound" | "Unauthorized" | "RequestRateTooHigh" | string;
603+
export type TranslationErrorCodeOutput = string;
611604

612605
// @public
613606
export interface TranslationErrorOutput {

sdk/translation/ai-translation-document-rest/src/clientDefinitions.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
// Copyright (c) Microsoft Corporation.
5+
// Licensed under the MIT license.
6+
47
import {
58
DocumentTranslateParameters,
69
StartTranslationParameters,
@@ -61,7 +64,7 @@ export interface StartTranslation {
6164
* must be unique.
6265
*/
6366
post(
64-
options?: StartTranslationParameters,
67+
options: StartTranslationParameters,
6568
): StreamableMethod<StartTranslation202Response | StartTranslationDefaultResponse>;
6669
/**
6770
* Returns a list of batch requests submitted and the status for each

sdk/translation/ai-translation-document-rest/src/documentTranslationClient.ts

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
// Copyright (c) Microsoft Corporation.
5+
// Licensed under the MIT license.
6+
47
import { getClient, ClientOptions } from "@azure-rest/core-client";
58
import { logger } from "./logger";
69
import { TokenCredential, KeyCredential } from "@azure/core-auth";
710
import { DocumentTranslationClient } from "./clientDefinitions";
811

12+
/** The optional parameters for the client */
13+
export interface DocumentTranslationClientOptions extends ClientOptions {
14+
/** The api version option of the client */
15+
apiVersion?: string;
16+
}
17+
918
/**
1019
* Initialize a new instance of `DocumentTranslationClient`
1120
* @param endpointParam - Supported document Translation endpoint, protocol and hostname, for example: https://{TranslatorResourceName}.cognitiveservices.azure.com/translator.
@@ -15,11 +24,10 @@ import { DocumentTranslationClient } from "./clientDefinitions";
1524
export default function createClient(
1625
endpointParam: string,
1726
credentials: TokenCredential | KeyCredential,
18-
options: ClientOptions = {},
27+
{ apiVersion = "2024-05-01", ...options }: DocumentTranslationClientOptions = {},
1928
): DocumentTranslationClient {
2029
const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}/translator`;
21-
options.apiVersion = options.apiVersion ?? "2024-05-01";
22-
const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.2`;
30+
const userAgentInfo = `azsdk-js-ai-translation-document-rest/1.0.0-beta.1`;
2331
const userAgentPrefix =
2432
options.userAgentOptions && options.userAgentOptions.userAgentPrefix
2533
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
@@ -37,8 +45,24 @@ export default function createClient(
3745
apiKeyHeaderName: options.credentials?.apiKeyHeaderName ?? "Ocp-Apim-Subscription-Key",
3846
},
3947
};
40-
4148
const client = getClient(endpointUrl, credentials, options) as DocumentTranslationClient;
4249

50+
client.pipeline.removePolicy({ name: "ApiVersionPolicy" });
51+
client.pipeline.addPolicy({
52+
name: "ClientApiVersionPolicy",
53+
sendRequest: (req, next) => {
54+
// Use the apiVersion defined in request url directly
55+
// Append one if there is no apiVersion and we have one at client options
56+
const url = new URL(req.url);
57+
if (!url.searchParams.get("api-version") && apiVersion) {
58+
req.url = `${req.url}${
59+
Array.from(url.searchParams.keys()).length > 0 ? "&" : "?"
60+
}api-version=${apiVersion}`;
61+
}
62+
63+
return next(req);
64+
},
65+
});
66+
4367
return client;
4468
}
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
// Copyright (c) Microsoft Corporation.
5+
// Licensed under the MIT license.
6+
47
import DocumentTranslationClient from "./documentTranslationClient";
58

69
export * from "./documentTranslationClient";
@@ -12,11 +15,5 @@ export * from "./models";
1215
export * from "./outputModels";
1316
export * from "./paginateHelper";
1417
export * from "./pollingHelper";
15-
export {
16-
createFile,
17-
createFileFromStream,
18-
type CreateFileOptions,
19-
type CreateFileFromStreamOptions,
20-
} from "@azure/core-rest-pipeline";
2118

2219
export default DocumentTranslationClient;

sdk/translation/ai-translation-document-rest/src/isUnexpected.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
// Copyright (c) Microsoft Corporation.
5+
// Licensed under the MIT license.
6+
47
import {
58
DocumentTranslate200Response,
69
DocumentTranslateDefaultResponse,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
// Copyright (c) Microsoft Corporation.
5+
// Licensed under the MIT license.
6+
47
import { createClientLogger } from "@azure/logger";
58
export const logger = createClientLogger("ai-translation-document");

sdk/translation/ai-translation-document-rest/src/models.ts

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
// Copyright (c) Microsoft Corporation.
22
// Licensed under the MIT License.
33

4+
// Copyright (c) Microsoft Corporation.
5+
// Licensed under the MIT license.
6+
47
export interface DocumentTranslateContentDocumentPartDescriptor {
58
name: "document";
69
body: string | Uint8Array | ReadableStream<Uint8Array> | NodeJS.ReadableStream | File;
@@ -27,7 +30,11 @@ export interface BatchRequest {
2730
source: SourceInput;
2831
/** Location of the destination for the output */
2932
targets: Array<TargetInput>;
30-
/** Storage type of the input documents source string */
33+
/**
34+
* Storage type of the input documents source string
35+
*
36+
* Possible values: "Folder", "File"
37+
*/
3138
storageType?: StorageInputType;
3239
}
3340

@@ -42,7 +49,11 @@ export interface SourceInput {
4249
* If none is specified, we will perform auto detect on the document
4350
*/
4451
language?: string;
45-
/** Storage Source */
52+
/**
53+
* Storage Source
54+
*
55+
* Possible values: "AzureBlob"
56+
*/
4657
storageSource?: StorageSource;
4758
}
4859

@@ -73,7 +84,11 @@ export interface TargetInput {
7384
language: string;
7485
/** List of Glossary */
7586
glossaries?: Array<Glossary>;
76-
/** Storage Source */
87+
/**
88+
* Storage Source
89+
*
90+
* Possible values: "AzureBlob"
91+
*/
7792
storageSource?: StorageSource;
7893
}
7994

@@ -92,7 +107,11 @@ export interface Glossary {
92107
format: string;
93108
/** Optional Version. If not specified, default is used. */
94109
version?: string;
95-
/** Storage Source */
110+
/**
111+
* Storage Source
112+
*
113+
* Possible values: "AzureBlob"
114+
*/
96115
storageSource?: StorageSource;
97116
}
98117

@@ -104,8 +123,8 @@ export type DocumentTranslateContent =
104123
| DocumentTranslateContentGlossaryPartDescriptor
105124
>;
106125
/** Alias for StorageSource */
107-
export type StorageSource = "AzureBlob" | string;
126+
export type StorageSource = string;
108127
/** Alias for StorageInputType */
109-
export type StorageInputType = "Folder" | "File" | string;
128+
export type StorageInputType = string;
110129
/** Alias for FileFormatType */
111-
export type FileFormatType = "document" | "glossary" | string;
130+
export type FileFormatType = string;

0 commit comments

Comments
 (0)