Skip to content

Commit 6797fe9

Browse files
[Form Recognizer] Regenerate with the latest swagger (Azure#22801)
* swagger * regenerate * Info -> Details * Apply suggestions from code review * Update sdk/formrecognizer/ai-form-recognizer/src/documentModelAdministrationClient.ts * test fixes * new reciordign * conflicts * fix test * changelog
1 parent 6eb5a1a commit 6797fe9

File tree

22 files changed

+431
-321
lines changed

22 files changed

+431
-321
lines changed

sdk/formrecognizer/ai-form-recognizer/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- Removed `PrebuiltModels` and all of its fields as well as related helper types. The strongly-typed functionality previously provided by `PrebuiltModels` is now provided by sample code that you can copy into your own project. See the [`prebuilt` samples directory](https://github.com/azure/azure-sdk-for-js/tree/main/sdk/formrecognizer/ai-form-recognizer/samples-dev/prebuilt/) for models compatible with the current Form Recognizer API.
1212
- Separated URL-based and file-based analysis inputs into two separate methods: `beginAnalyzeDocument` (for file stream inputs) and `beginAnalyzeDocumentFromUrl` (for URL-based inputs). Previously, both were accepted as inputs to a single `beginAnalyzeDocument` method, and a string value would be interpreted as if it were a URL, but this was confusing. The two inputs now have distinct signatures and documentation.
1313
- Removed the `beginExtractLayout`, `beginExtractGeneralDocument`, and `beginReadDocument` methods. Strongly-typed `DocumentModel` instances for the corresponding `prebuilt-layout`, `prebuilt-document`, and `prebuilt-read` models are located in the [`prebuilt` samples directory](https://github.com/azure/azure-sdk-for-js/tree/main/sdk/formrecognizer/ai-form-recognizer/samples-dev/prebuilt/).
14+
- Changed the suffix `-Info` for the methods and interfaces such as `DocumentModelAdministrationClient#getResourceInfo` and `DocumentModelInfo` to `-Details`.
1415

1516
### Bugs Fixed
1617

sdk/formrecognizer/ai-form-recognizer/bin/defaultFields.ts

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

4-
import { DocumentModelInfo } from "../src";
4+
import { DocumentModelDetails } from "../src";
55
import { Field } from "./utils";
66

77
/**
@@ -73,7 +73,7 @@ const documentFeatures = [...layoutFeatures, "keyValuePairs"];
7373
* @param model - the model to get the features of
7474
* @returns the list of features supported by the model
7575
*/
76-
export function getFeatures(model: DocumentModelInfo): string[] {
76+
export function getFeatures(model: DocumentModelDetails): string[] {
7777
return (
7878
(model as any).features ??
7979
{

sdk/formrecognizer/ai-form-recognizer/bin/writeModelCode.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// Licensed under the MIT license.
33

44
import { EOL } from "os";
5-
import { DocTypeInfo, DocumentModelInfo } from "../src";
5+
import { DocumentTypeDetails, DocumentModelDetails } from "../src";
66
import { DocumentFieldSchema } from "../src/generated";
77
import { DocumentField } from "../src/models";
88
import { defaultResultFields, getFeatures } from "./defaultFields";
@@ -24,7 +24,7 @@ const sampleHeader = `// Copyright (c) Microsoft Corporation.
2424
/**
2525
* Generate a header with the model information.
2626
*/
27-
function templateHeader(model: DocumentModelInfo): string {
27+
function templateHeader(model: DocumentModelDetails): string {
2828
return `${sampleHeader}
2929
3030
// Model: ${model.modelId}
@@ -41,7 +41,7 @@ function templateHeader(model: DocumentModelInfo): string {
4141
* @param model - the ModelInfo to generate code for
4242
* @returns a string of TypeScript source code
4343
*/
44-
export async function writeModelCode(model: DocumentModelInfo): Promise<string> {
44+
export async function writeModelCode(model: DocumentModelDetails): Promise<string> {
4545
let contents = templateHeader(model);
4646

4747
contents += 'import * as fr from "@azure/ai-form-recognizer";' + EOL + EOL;
@@ -141,7 +141,7 @@ export async function writeModelCode(model: DocumentModelInfo): Promise<string>
141141

142142
// Get the doc type variants of a model.
143143
function extractModelVariants(
144-
model: DocumentModelInfo,
144+
model: DocumentModelDetails,
145145
_rootSlug: string[]
146146
): Record<string, DocType> {
147147
const result: ReturnType<typeof extractModelVariants> = {};
@@ -408,7 +408,7 @@ function* flatMap<T1, T2>(it: Iterable<T1>, f: (v: T1) => T2 | Iterable<T2>): It
408408
/**
409409
* Helper interface for representing a DocType during generation, allowing for renaming and contextual, taxonomic naming.
410410
*/
411-
interface DocType extends DocTypeInfo {
411+
interface DocType extends DocumentTypeDetails {
412412
originalDocType: string;
413413
name: string;
414414
slug: string[];

sdk/formrecognizer/ai-form-recognizer/recordings/node/api_key_analysis_node_healthinsurancecard__us/recording_png_file_stream.json

Lines changed: 37 additions & 37 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/formrecognizer/ai-form-recognizer/recordings/node/api_key_analysis_node_tax__us__w2/recording_png_file_stream.json

Lines changed: 79 additions & 79 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/formrecognizer/ai-form-recognizer/recordings/node/api_key_analysis_node_vaccinationcard/recording_jpg_file_stream.json

Lines changed: 40 additions & 40 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/formrecognizer/ai-form-recognizer/review/ai-form-recognizer.api.md

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ export interface CopyAuthorization {
104104
}
105105

106106
// @public
107-
export function createModelFromSchema(schema: Omit<DocumentModelInfo, "createdDateTime">): DocumentModel<AnalyzeResult<unknown>>;
107+
export function createModelFromSchema(schema: Omit<DocumentModelDetails, "createdDateTime">): DocumentModel<AnalyzeResult<unknown>>;
108108

109109
// @public
110110
export interface CreateModelOptions extends OperationOptions, CommonModelCreationOptions, PollerOptions<DocumentModelOperationState> {
@@ -117,7 +117,7 @@ export interface CurrencyValue {
117117
}
118118

119119
// @public
120-
export interface CustomDocumentModelsInfo {
120+
export interface CustomDocumentModelsDetails {
121121
count: number;
122122
limit: number;
123123
}
@@ -126,18 +126,6 @@ export interface CustomDocumentModelsInfo {
126126
export interface DeleteModelOptions extends OperationOptions {
127127
}
128128

129-
// @public
130-
export interface DocTypeInfo {
131-
buildMode?: DocumentBuildMode;
132-
description?: string;
133-
fieldConfidence?: {
134-
[propertyName: string]: number;
135-
};
136-
fieldSchema: {
137-
[propertyName: string]: DocumentFieldSchema;
138-
};
139-
}
140-
141129
// @public
142130
export interface DocumentAddressField extends DocumentFieldCommon {
143131
kind: "address";
@@ -284,9 +272,9 @@ export class DocumentModelAdministrationClient {
284272
beginCopyModelTo(sourceModelId: string, authorization: CopyAuthorization, options?: BeginCopyModelOptions): Promise<DocumentModelPoller>;
285273
deleteModel(modelId: string, options?: DeleteModelOptions): Promise<void>;
286274
getCopyAuthorization(destinationModelId: string, options?: GetCopyAuthorizationOptions): Promise<CopyAuthorization>;
287-
getModel(modelId: string, options?: GetModelOptions): Promise<DocumentModelInfo>;
288-
getOperation(operationId: string, options?: GetOperationOptions): Promise<OperationInfo>;
289-
getResourceInfo(options?: GetResourceInfoOptions): Promise<ResourceInfo>;
275+
getModel(modelId: string, options?: GetModelOptions): Promise<DocumentModelDetails>;
276+
getOperation(operationId: string, options?: GetOperationOptions): Promise<OperationDetails>;
277+
getResourceDetails(options?: GetResourceDetailsOptions): Promise<ResourceDetails>;
290278
listModels(options?: ListModelsOptions): PagedAsyncIterableIterator<DocumentModelSummary>;
291279
listOperations(options?: ListOperationsOptions): PagedAsyncIterableIterator<OperationSummary>;
292280
}
@@ -305,14 +293,14 @@ export const DocumentModelBuildMode: {
305293
};
306294

307295
// @public
308-
export interface DocumentModelInfo extends DocumentModelSummary {
296+
export interface DocumentModelDetails extends DocumentModelSummary {
309297
docTypes?: {
310-
[propertyName: string]: DocTypeInfo;
298+
[propertyName: string]: DocumentTypeDetails;
311299
};
312300
}
313301

314302
// @public
315-
export interface DocumentModelOperationState extends PollOperationState<DocumentModelInfo> {
303+
export interface DocumentModelOperationState extends PollOperationState<DocumentModelDetails> {
316304
apiVersion?: string;
317305
createdOn: Date;
318306
lastUpdatedOn: Date;
@@ -323,7 +311,7 @@ export interface DocumentModelOperationState extends PollOperationState<Document
323311
}
324312

325313
// @public
326-
export type DocumentModelPoller = PollerLike<DocumentModelOperationState, DocumentModelInfo>;
314+
export type DocumentModelPoller = PollerLike<DocumentModelOperationState, DocumentModelDetails>;
327315

328316
// @public
329317
export interface DocumentModelSummary {
@@ -450,6 +438,18 @@ export interface DocumentTimeField extends DocumentFieldCommon {
450438
value?: string;
451439
}
452440

441+
// @public
442+
export interface DocumentTypeDetails {
443+
buildMode?: DocumentBuildMode;
444+
description?: string;
445+
fieldConfidence?: {
446+
[propertyName: string]: number;
447+
};
448+
fieldSchema: {
449+
[propertyName: string]: DocumentFieldSchema;
450+
};
451+
}
452+
453453
// @public
454454
export interface DocumentValueField<T> extends DocumentFieldCommon {
455455
value?: T;
@@ -500,10 +500,10 @@ export interface GetOperationOptions extends OperationOptions {
500500
}
501501

502502
// @public
503-
export type GetOperationResponse = OperationInfo;
503+
export type GetOperationResponse = OperationDetails;
504504

505505
// @public
506-
export interface GetResourceInfoOptions extends OperationOptions {
506+
export interface GetResourceDetailsOptions extends OperationOptions {
507507
}
508508

509509
// @public
@@ -530,7 +530,7 @@ export interface ListOperationsOptions extends OperationOptions {
530530
}
531531

532532
// @public
533-
export interface OperationInfo extends OperationSummary {
533+
export interface OperationDetails extends OperationSummary {
534534
error?: ErrorModel;
535535
result?: Record<string, unknown>;
536536
}
@@ -573,8 +573,8 @@ export interface PollerOptions<TState extends PollOperationState<unknown>> exten
573573
}
574574

575575
// @public
576-
export interface ResourceInfo {
577-
customDocumentModels: CustomDocumentModelsInfo;
576+
export interface ResourceDetails {
577+
customDocumentModels: CustomDocumentModelsDetails;
578578
}
579579

580580
// @public

sdk/formrecognizer/ai-form-recognizer/samples-dev/getInfo.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ async function main() {
1919

2020
const client = new DocumentModelAdministrationClient(endpoint, credential);
2121

22-
const info = await client.getResourceInfo();
22+
const info = await client.getResourceDetails();
2323

2424
console.log(
2525
`Custom document models: ${info.customDocumentModels.count} of ${info.customDocumentModels.limit}`

sdk/formrecognizer/ai-form-recognizer/src/documentModel.ts

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

4-
import { DocumentFieldSchema, DocumentModelInfo } from "./generated";
4+
import { DocumentFieldSchema, DocumentModelDetails } from "./generated";
55
import { AnalyzedDocument, AnalyzeResult } from "./lro/analysis";
66
import { DocumentField } from "./models/fields";
77
import { FormRecognizerApiVersion } from "./options";
@@ -87,7 +87,7 @@ function extractField(
8787
* @returns - a DocumentModel that encodes the schema
8888
*/
8989
export function createModelFromSchema(
90-
schema: Omit<DocumentModelInfo, "createdDateTime">
90+
schema: Omit<DocumentModelDetails, "createdDateTime">
9191
): DocumentModel<AnalyzeResult<unknown>> {
9292
return {
9393
modelId: schema.modelId,

sdk/formrecognizer/ai-form-recognizer/src/documentModelAdministrationClient.ts

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ import { SDK_VERSION } from "./constants";
99
import {
1010
CopyAuthorization,
1111
GeneratedClient,
12-
ResourceInfo,
12+
ResourceDetails,
1313
GetOperationResponse,
14-
DocumentModelInfo,
14+
DocumentModelDetails,
1515
DocumentModelSummary,
1616
OperationSummary,
17-
OperationInfo,
17+
OperationDetails,
1818
} from "./generated";
1919
import { accept1 } from "./generated/models/parameters";
2020
import {
@@ -29,7 +29,7 @@ import {
2929
DeleteModelOptions,
3030
DocumentModelAdministrationClientOptions,
3131
GetCopyAuthorizationOptions,
32-
GetResourceInfoOptions,
32+
GetResourceDetailsOptions,
3333
GetModelOptions,
3434
GetOperationOptions,
3535
ListModelsOptions,
@@ -173,16 +173,16 @@ export class DocumentModelAdministrationClient {
173173
* description: "This is an example model!"
174174
* });
175175
*
176-
* // Model building, like all other model creation operations, returns a poller that eventually produces a ModelInfo
176+
* // Model building, like all other model creation operations, returns a poller that eventually produces a ModelDetails
177177
* // object
178-
* const modelInfo = await poller.pollUntilDone();
178+
* const modelDetails = await poller.pollUntilDone();
179179
*
180180
* const {
181181
* modelId, // identical to the modelId given when creating the model
182182
* description, // identical to the description given when creating the model
183183
* createdDateTime, // the Date (timestamp) that the model was created
184184
* docTypes // information about the document types in the model and their field schemas
185-
* } = modelInfo;
185+
* } = modelDetails;
186186
* ```
187187
*
188188
* @param modelId - the unique ID of the model to create
@@ -242,15 +242,15 @@ export class DocumentModelAdministrationClient {
242242
* });
243243
*
244244
* // Model composition, like all other model creation operations, returns a poller that eventually produces a
245-
* // ModelInfo object
246-
* const modelInfo = await poller.pollUntilDone();
245+
* // ModelDetails object
246+
* const modelDetails = await poller.pollUntilDone();
247247
*
248248
* const {
249249
* modelId, // identical to the modelId given when creating the model
250250
* description, // identical to the description given when creating the model
251251
* createdDateTime, // the Date (timestamp) that the model was created
252252
* docTypes // information about the document types of the composed submodels
253-
* } = modelInfo;
253+
* } = modelDetails;
254254
* ```
255255
*
256256
* @param modelId - the unique ID of the model to create
@@ -342,16 +342,16 @@ export class DocumentModelAdministrationClient {
342342
* // Finally, use the _source_ client to copy the model and await the copy operation
343343
* const poller = await sourceClient.beginCopyModelTo("<source model ID>");
344344
*
345-
* // Model copying, like all other model creation operations, returns a poller that eventually produces a ModelInfo
345+
* // Model copying, like all other model creation operations, returns a poller that eventually produces a ModelDetails
346346
* // object
347-
* const modelInfo = await poller.pollUntilDone();
347+
* const modelDetails = await poller.pollUntilDone();
348348
*
349349
* const {
350350
* modelId, // identical to the modelId given when creating the copy authorization
351351
* description, // identical to the description given when creating the copy authorization
352352
* createdDateTime, // the Date (timestamp) that the model was created
353353
* docTypes // information about the document types of the model (identical to the original, source model)
354-
* } = modelInfo;
354+
* } = modelDetails;
355355
* ```
356356
*
357357
* @param sourceModelId - the unique ID of the source model that will be copied
@@ -382,7 +382,7 @@ export class DocumentModelAdministrationClient {
382382
* This is the meat of the above model creation operations.
383383
*
384384
* @param definition - operation definition (start operation method, request options)
385-
* @returns a model poller (produces a ModelInfo)
385+
* @returns a model poller (produces a ModelDetails)
386386
*/
387387
private async createDocumentModelPoller(
388388
definition: TrainingOperationDefinition
@@ -413,7 +413,7 @@ export class DocumentModelAdministrationClient {
413413
httpMethod: "GET",
414414
responses: {
415415
200: {
416-
bodyMapper: Mappers.OperationInfo,
416+
bodyMapper: Mappers.OperationDetails,
417417
},
418418
default: {
419419
bodyMapper: Mappers.ErrorResponse,
@@ -436,7 +436,7 @@ export class DocumentModelAdministrationClient {
436436
}
437437
);
438438

439-
const poller = await lro<DocumentModelInfo, DocumentModelOperationState>(
439+
const poller = await lro<DocumentModelDetails, DocumentModelOperationState>(
440440
{
441441
init: async () => toTrainingPollOperationState(await toInit()),
442442
poll: async ({ operationId }) =>
@@ -474,28 +474,28 @@ export class DocumentModelAdministrationClient {
474474
* ```javascript
475475
* const {
476476
* // Information about the custom models in the current resource
477-
* customDocumentModelInfo: {
477+
* customDocumentModelDetails: {
478478
* // The number of custom models in the current resource
479479
* count,
480480
* // The maximum number of models that the current resource can support
481481
* limit
482482
* }
483-
* } = await client.getInfo();
483+
* } = await client.getResourceDetails();
484484
* ```
485485
*
486486
* @param options - optional settings for the request
487487
* @returns basic information about this client's resource
488488
*/
489-
public getResourceInfo(options: GetResourceInfoOptions = {}): Promise<ResourceInfo> {
489+
public getResourceDetails(options: GetResourceDetailsOptions = {}): Promise<ResourceDetails> {
490490
return this._tracing.withSpan(
491-
"DocumentModelAdministrationClient.getResourceInfo",
491+
"DocumentModelAdministrationClient.getResourceDetails",
492492
options,
493-
(finalOptions) => this._restClient.getResourceInfo(finalOptions)
493+
(finalOptions) => this._restClient.getResourceDetails(finalOptions)
494494
);
495495
}
496496

497497
/**
498-
* Retrieves information about a model ({@link ModelInfo}) by ID.
498+
* Retrieves information about a model ({@link ModelDetails}) by ID.
499499
*
500500
* This method can retrieve information about custom as well as prebuilt models.
501501
*
@@ -536,7 +536,7 @@ export class DocumentModelAdministrationClient {
536536
* @param options - optional settings for the request
537537
* @returns information about the model with the given ID
538538
*/
539-
public getModel(modelId: string, options: GetModelOptions = {}): Promise<DocumentModelInfo> {
539+
public getModel(modelId: string, options: GetModelOptions = {}): Promise<DocumentModelDetails> {
540540
return this._tracing.withSpan(
541541
"DocumentModelAdministrationClient.getModel",
542542
options,
@@ -606,7 +606,7 @@ export class DocumentModelAdministrationClient {
606606
}
607607

608608
/**
609-
* Retrieves information about an operation (`OperationInfo`) by its ID.
609+
* Retrieves information about an operation (`OperationDetails`) by its ID.
610610
*
611611
* Operations represent non-analysis tasks, such as building, composing, or copying a model.
612612
*
@@ -633,7 +633,7 @@ export class DocumentModelAdministrationClient {
633633
public getOperation(
634634
operationId: string,
635635
options: GetOperationOptions = {}
636-
): Promise<OperationInfo> {
636+
): Promise<OperationDetails> {
637637
return this._tracing.withSpan(
638638
"DocumentModelAdministrationClient.getOperation",
639639
options,

0 commit comments

Comments
 (0)