Textract - AWS API Codegen

API Documentation | Deno Module Docs | Original docs from AWS-JS-SDK

Customize Generated Module

Only include specific operations:
Include documentation comments:

Example Import

import { Textract } from "https://aws-api.deno.dev/v0.3/services/textract.ts";


Generated Source (the actual code)

// Autogenerated API client for: Amazon Textract
// Generation parameters:
//   aws-sdk-js definitions from v2.1060.0
//   AWS service UID: textract-2018-06-27
//   code generation: v0.3
//   generated at: 2025-09-19
//
// Originally served at https://aws-api.deno.dev/v0.3/services/textract.ts


import * as Base64 from "https://deno.land/std@0.120.0/encoding/base64.ts";
import * as client from "https://deno.land/x/aws_api@v0.6.0/client/common.ts";
import * as cmnP from "https://deno.land/x/aws_api@v0.6.0/encoding/common.ts";
import * as jsonP from "https://deno.land/x/aws_api@v0.6.0/encoding/json.ts";
function serializeBlob(input: string | Uint8Array | null | undefined) {
  if (input == null) return input;
  return Base64.encode(input);
}

export class Textract {
  #client: client.ServiceClient;
  constructor(apiFactory: client.ApiFactory) {
    this.#client = apiFactory.buildServiceClient(Textract.ApiMetadata);
  }

  static ApiMetadata: client.ApiMetadata = {
    "apiVersion": "2018-06-27",
    "endpointPrefix": "textract",
    "jsonVersion": "1.1",
    "protocol": "json",
    "serviceFullName": "Amazon Textract",
    "serviceId": "Textract",
    "signatureVersion": "v4",
    "targetPrefix": "Textract",
    "uid": "textract-2018-06-27"
  };

  /** Analyzes an input document for relationships between detected items. */
  async analyzeDocument(
    params: AnalyzeDocumentRequest,
    opts: client.RequestOptions = {},
  ): Promise<AnalyzeDocumentResponse> {
    const body: jsonP.JSONObject = {
      Document: fromDocument(params["Document"]),
      FeatureTypes: params["FeatureTypes"],
      HumanLoopConfig: fromHumanLoopConfig(params["HumanLoopConfig"]),
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "AnalyzeDocument",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "DocumentMetadata": toDocumentMetadata,
        "Blocks": [toBlock],
        "HumanLoopActivationOutput": toHumanLoopActivationOutput,
        "AnalyzeDocumentModelVersion": "s",
      },
    }, await resp.json());
  }

  /** `AnalyzeExpense` synchronously analyzes an input document for financially related relationships between text. */
  async analyzeExpense(
    params: AnalyzeExpenseRequest,
    opts: client.RequestOptions = {},
  ): Promise<AnalyzeExpenseResponse> {
    const body: jsonP.JSONObject = {
      Document: fromDocument(params["Document"]),
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "AnalyzeExpense",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "DocumentMetadata": toDocumentMetadata,
        "ExpenseDocuments": [toExpenseDocument],
      },
    }, await resp.json());
  }

  /** Analyzes identity documents for relevant information. */
  async analyzeID(
    params: AnalyzeIDRequest,
    opts: client.RequestOptions = {},
  ): Promise<AnalyzeIDResponse> {
    const body: jsonP.JSONObject = {
      DocumentPages: params["DocumentPages"]?.map(x => fromDocument(x)),
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "AnalyzeID",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "IdentityDocuments": [toIdentityDocument],
        "DocumentMetadata": toDocumentMetadata,
        "AnalyzeIDModelVersion": "s",
      },
    }, await resp.json());
  }

  /** Detects text in the input document. */
  async detectDocumentText(
    params: DetectDocumentTextRequest,
    opts: client.RequestOptions = {},
  ): Promise<DetectDocumentTextResponse> {
    const body: jsonP.JSONObject = {
      Document: fromDocument(params["Document"]),
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "DetectDocumentText",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "DocumentMetadata": toDocumentMetadata,
        "Blocks": [toBlock],
        "DetectDocumentTextModelVersion": "s",
      },
    }, await resp.json());
  }

  /** Gets the results for an Amazon Textract asynchronous operation that analyzes text in a document. */
  async getDocumentAnalysis(
    params: GetDocumentAnalysisRequest,
    opts: client.RequestOptions = {},
  ): Promise<GetDocumentAnalysisResponse> {
    const body: jsonP.JSONObject = {
      JobId: params["JobId"],
      MaxResults: params["MaxResults"],
      NextToken: params["NextToken"],
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "GetDocumentAnalysis",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "DocumentMetadata": toDocumentMetadata,
        "JobStatus": (x: jsonP.JSONValue) => cmnP.readEnum<JobStatus>(x),
        "NextToken": "s",
        "Blocks": [toBlock],
        "Warnings": [toWarning],
        "StatusMessage": "s",
        "AnalyzeDocumentModelVersion": "s",
      },
    }, await resp.json());
  }

  /** Gets the results for an Amazon Textract asynchronous operation that detects text in a document. */
  async getDocumentTextDetection(
    params: GetDocumentTextDetectionRequest,
    opts: client.RequestOptions = {},
  ): Promise<GetDocumentTextDetectionResponse> {
    const body: jsonP.JSONObject = {
      JobId: params["JobId"],
      MaxResults: params["MaxResults"],
      NextToken: params["NextToken"],
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "GetDocumentTextDetection",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "DocumentMetadata": toDocumentMetadata,
        "JobStatus": (x: jsonP.JSONValue) => cmnP.readEnum<JobStatus>(x),
        "NextToken": "s",
        "Blocks": [toBlock],
        "Warnings": [toWarning],
        "StatusMessage": "s",
        "DetectDocumentTextModelVersion": "s",
      },
    }, await resp.json());
  }

  /** Gets the results for an Amazon Textract asynchronous operation that analyzes invoices and receipts. */
  async getExpenseAnalysis(
    params: GetExpenseAnalysisRequest,
    opts: client.RequestOptions = {},
  ): Promise<GetExpenseAnalysisResponse> {
    const body: jsonP.JSONObject = {
      JobId: params["JobId"],
      MaxResults: params["MaxResults"],
      NextToken: params["NextToken"],
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "GetExpenseAnalysis",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "DocumentMetadata": toDocumentMetadata,
        "JobStatus": (x: jsonP.JSONValue) => cmnP.readEnum<JobStatus>(x),
        "NextToken": "s",
        "ExpenseDocuments": [toExpenseDocument],
        "Warnings": [toWarning],
        "StatusMessage": "s",
        "AnalyzeExpenseModelVersion": "s",
      },
    }, await resp.json());
  }

  /** Starts the asynchronous analysis of an input document for relationships between detected items such as key-value pairs, tables, and selection elements. */
  async startDocumentAnalysis(
    params: StartDocumentAnalysisRequest,
    opts: client.RequestOptions = {},
  ): Promise<StartDocumentAnalysisResponse> {
    const body: jsonP.JSONObject = {
      DocumentLocation: fromDocumentLocation(params["DocumentLocation"]),
      FeatureTypes: params["FeatureTypes"],
      ClientRequestToken: params["ClientRequestToken"],
      JobTag: params["JobTag"],
      NotificationChannel: fromNotificationChannel(params["NotificationChannel"]),
      OutputConfig: fromOutputConfig(params["OutputConfig"]),
      KMSKeyId: params["KMSKeyId"],
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "StartDocumentAnalysis",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "JobId": "s",
      },
    }, await resp.json());
  }

  /** Starts the asynchronous detection of text in a document. */
  async startDocumentTextDetection(
    params: StartDocumentTextDetectionRequest,
    opts: client.RequestOptions = {},
  ): Promise<StartDocumentTextDetectionResponse> {
    const body: jsonP.JSONObject = {
      DocumentLocation: fromDocumentLocation(params["DocumentLocation"]),
      ClientRequestToken: params["ClientRequestToken"],
      JobTag: params["JobTag"],
      NotificationChannel: fromNotificationChannel(params["NotificationChannel"]),
      OutputConfig: fromOutputConfig(params["OutputConfig"]),
      KMSKeyId: params["KMSKeyId"],
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "StartDocumentTextDetection",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "JobId": "s",
      },
    }, await resp.json());
  }

  /** Starts the asynchronous analysis of invoices or receipts for data like contact information, items purchased, and vendor names. */
  async startExpenseAnalysis(
    params: StartExpenseAnalysisRequest,
    opts: client.RequestOptions = {},
  ): Promise<StartExpenseAnalysisResponse> {
    const body: jsonP.JSONObject = {
      DocumentLocation: fromDocumentLocation(params["DocumentLocation"]),
      ClientRequestToken: params["ClientRequestToken"],
      JobTag: params["JobTag"],
      NotificationChannel: fromNotificationChannel(params["NotificationChannel"]),
      OutputConfig: fromOutputConfig(params["OutputConfig"]),
      KMSKeyId: params["KMSKeyId"],
    };
    const resp = await this.#client.performRequest({
      opts, body,
      action: "StartExpenseAnalysis",
    });
    return jsonP.readObj({
      required: {},
      optional: {
        "JobId": "s",
      },
    }, await resp.json());
  }

}

// refs: 1 - tags: named, input
export interface AnalyzeDocumentRequest {
  /** The input document as base64-encoded bytes or an Amazon S3 object. */
  Document: Document;
  /** A list of the types of analysis to perform. */
  FeatureTypes: FeatureType[];
  /** Sets the configuration for the human in the loop workflow for analyzing documents. */
  HumanLoopConfig?: HumanLoopConfig | null;
}

// refs: 1 - tags: named, input
export interface AnalyzeExpenseRequest {
  Document: Document;
}

// refs: 1 - tags: named, input
export interface AnalyzeIDRequest {
  /** The document being passed to AnalyzeID. */
  DocumentPages: Document[];
}

// refs: 1 - tags: named, input
export interface DetectDocumentTextRequest {
  /** The input document as base64-encoded bytes or an Amazon S3 object. */
  Document: Document;
}

// refs: 1 - tags: named, input
export interface GetDocumentAnalysisRequest {
  /** A unique identifier for the text-detection job. */
  JobId: string;
  /** The maximum number of results to return per paginated call. */
  MaxResults?: number | null;
  /** If the previous response was incomplete (because there are more blocks to retrieve), Amazon Textract returns a pagination token in the response. */
  NextToken?: string | null;
}

// refs: 1 - tags: named, input
export interface GetDocumentTextDetectionRequest {
  /** A unique identifier for the text detection job. */
  JobId: string;
  /** The maximum number of results to return per paginated call. */
  MaxResults?: number | null;
  /** If the previous response was incomplete (because there are more blocks to retrieve), Amazon Textract returns a pagination token in the response. */
  NextToken?: string | null;
}

// refs: 1 - tags: named, input
export interface GetExpenseAnalysisRequest {
  /** A unique identifier for the text detection job. */
  JobId: string;
  /** The maximum number of results to return per paginated call. */
  MaxResults?: number | null;
  /** If the previous response was incomplete (because there are more blocks to retrieve), Amazon Textract returns a pagination token in the response. */
  NextToken?: string | null;
}

// refs: 1 - tags: named, input
export interface StartDocumentAnalysisRequest {
  /** The location of the document to be processed. */
  DocumentLocation: DocumentLocation;
  /** A list of the types of analysis to perform. */
  FeatureTypes: FeatureType[];
  /** The idempotent token that you use to identify the start request. */
  ClientRequestToken?: string | null;
  /** An identifier that you specify that's included in the completion notification published to the Amazon SNS topic. */
  JobTag?: string | null;
  /** The Amazon SNS topic ARN that you want Amazon Textract to publish the completion status of the operation to. */
  NotificationChannel?: NotificationChannel | null;
  /** Sets if the output will go to a customer defined bucket. */
  OutputConfig?: OutputConfig | null;
  /** The KMS key used to encrypt the inference results. */
  KMSKeyId?: string | null;
}

// refs: 1 - tags: named, input
export interface StartDocumentTextDetectionRequest {
  /** The location of the document to be processed. */
  DocumentLocation: DocumentLocation;
  /** The idempotent token that's used to identify the start request. */
  ClientRequestToken?: string | null;
  /** An identifier that you specify that's included in the completion notification published to the Amazon SNS topic. */
  JobTag?: string | null;
  /** The Amazon SNS topic ARN that you want Amazon Textract to publish the completion status of the operation to. */
  NotificationChannel?: NotificationChannel | null;
  /** Sets if the output will go to a customer defined bucket. */
  OutputConfig?: OutputConfig | null;
  /** The KMS key used to encrypt the inference results. */
  KMSKeyId?: string | null;
}

// refs: 1 - tags: named, input
export interface StartExpenseAnalysisRequest {
  /** The location of the document to be processed. */
  DocumentLocation: DocumentLocation;
  /** The idempotent token that's used to identify the start request. */
  ClientRequestToken?: string | null;
  /** An identifier you specify that's included in the completion notification published to the Amazon SNS topic. */
  JobTag?: string | null;
  /** The Amazon SNS topic ARN that you want Amazon Textract to publish the completion status of the operation to. */
  NotificationChannel?: NotificationChannel | null;
  /** Sets if the output will go to a customer defined bucket. */
  OutputConfig?: OutputConfig | null;
  /** The KMS key used to encrypt the inference results. */
  KMSKeyId?: string | null;
}

// refs: 1 - tags: named, output
export interface AnalyzeDocumentResponse {
  /** Metadata about the analyzed document. */
  DocumentMetadata?: DocumentMetadata | null;
  /** The items that are detected and analyzed by `AnalyzeDocument`. */
  Blocks?: Block[] | null;
  /** Shows the results of the human in the loop evaluation. */
  HumanLoopActivationOutput?: HumanLoopActivationOutput | null;
  /** The version of the model used to analyze the document. */
  AnalyzeDocumentModelVersion?: string | null;
}

// refs: 1 - tags: named, output
export interface AnalyzeExpenseResponse {
  DocumentMetadata?: DocumentMetadata | null;
  /** The expenses detected by Amazon Textract. */
  ExpenseDocuments?: ExpenseDocument[] | null;
}

// refs: 1 - tags: named, output
export interface AnalyzeIDResponse {
  /** The list of documents processed by AnalyzeID. */
  IdentityDocuments?: IdentityDocument[] | null;
  DocumentMetadata?: DocumentMetadata | null;
  /** The version of the AnalyzeIdentity API being used to process documents. */
  AnalyzeIDModelVersion?: string | null;
}

// refs: 1 - tags: named, output
export interface DetectDocumentTextResponse {
  /** Metadata about the document. */
  DocumentMetadata?: DocumentMetadata | null;
  /** An array of `Block` objects that contain the text that's detected in the document. */
  Blocks?: Block[] | null;
  /**  */
  DetectDocumentTextModelVersion?: string | null;
}

// refs: 1 - tags: named, output
export interface GetDocumentAnalysisResponse {
  /** Information about a document that Amazon Textract processed. */
  DocumentMetadata?: DocumentMetadata | null;
  /** The current status of the text detection job. */
  JobStatus?: JobStatus | null;
  /** If the response is truncated, Amazon Textract returns this token. */
  NextToken?: string | null;
  /** The results of the text-analysis operation. */
  Blocks?: Block[] | null;
  /** A list of warnings that occurred during the document-analysis operation. */
  Warnings?: Warning[] | null;
  /** Returns if the detection job could not be completed. */
  StatusMessage?: string | null;
  /**  */
  AnalyzeDocumentModelVersion?: string | null;
}

// refs: 1 - tags: named, output
export interface GetDocumentTextDetectionResponse {
  /** Information about a document that Amazon Textract processed. */
  DocumentMetadata?: DocumentMetadata | null;
  /** The current status of the text detection job. */
  JobStatus?: JobStatus | null;
  /** If the response is truncated, Amazon Textract returns this token. */
  NextToken?: string | null;
  /** The results of the text-detection operation. */
  Blocks?: Block[] | null;
  /** A list of warnings that occurred during the text-detection operation for the document. */
  Warnings?: Warning[] | null;
  /** Returns if the detection job could not be completed. */
  StatusMessage?: string | null;
  /**  */
  DetectDocumentTextModelVersion?: string | null;
}

// refs: 1 - tags: named, output
export interface GetExpenseAnalysisResponse {
  /** Information about a document that Amazon Textract processed. */
  DocumentMetadata?: DocumentMetadata | null;
  /** The current status of the text detection job. */
  JobStatus?: JobStatus | null;
  /** If the response is truncated, Amazon Textract returns this token. */
  NextToken?: string | null;
  /** The expenses detected by Amazon Textract. */
  ExpenseDocuments?: ExpenseDocument[] | null;
  /** A list of warnings that occurred during the text-detection operation for the document. */
  Warnings?: Warning[] | null;
  /** Returns if the detection job could not be completed. */
  StatusMessage?: string | null;
  /** The current model version of AnalyzeExpense. */
  AnalyzeExpenseModelVersion?: string | null;
}

// refs: 1 - tags: named, output
export interface StartDocumentAnalysisResponse {
  /** The identifier for the document text detection job. */
  JobId?: string | null;
}

// refs: 1 - tags: named, output
export interface StartDocumentTextDetectionResponse {
  /** The identifier of the text detection job for the document. */
  JobId?: string | null;
}

// refs: 1 - tags: named, output
export interface StartExpenseAnalysisResponse {
  /** A unique identifier for the text detection job. */
  JobId?: string | null;
}

// refs: 4 - tags: input, named, interface
/** The input document, either as bytes or as an S3 object. */
export interface Document {
  /** A blob of base64-encoded document bytes. */
  Bytes?: Uint8Array | string | null;
  /** Identifies an S3 object as the document source. */
  S3Object?: S3Object | null;
}
function fromDocument(input?: Document | null): jsonP.JSONValue {
  if (!input) return input;
  return {
    Bytes: serializeBlob(input["Bytes"]),
    S3Object: fromS3Object(input["S3Object"]),
  }
}

// refs: 7 - tags: input, named, interface
/** The S3 bucket name and file name that identifies the document. */
export interface S3Object {
  /** The name of the S3 bucket. */
  Bucket?: string | null;
  /** The file name of the input document. */
  Name?: string | null;
  /** If the bucket has versioning enabled, you can specify the object version. */
  Version?: string | null;
}
function fromS3Object(input?: S3Object | null): jsonP.JSONValue {
  if (!input) return input;
  return {
    Bucket: input["Bucket"],
    Name: input["Name"],
    Version: input["Version"],
  }
}

// refs: 2 - tags: input, named, enum
export type FeatureType =
| "TABLES"
| "FORMS"
| cmnP.UnexpectedEnumValue;

// refs: 1 - tags: input, named, interface
/** Sets up the human review workflow the document will be sent to if one of the conditions is met. */
export interface HumanLoopConfig {
  /** The name of the human workflow used for this image. */
  HumanLoopName: string;
  /** The Amazon Resource Name (ARN) of the flow definition. */
  FlowDefinitionArn: string;
  /** Sets attributes of the input data. */
  DataAttributes?: HumanLoopDataAttributes | null;
}
function fromHumanLoopConfig(input?: HumanLoopConfig | null): jsonP.JSONValue {
  if (!input) return input;
  return {
    HumanLoopName: input["HumanLoopName"],
    FlowDefinitionArn: input["FlowDefinitionArn"],
    DataAttributes: fromHumanLoopDataAttributes(input["DataAttributes"]),
  }
}

// refs: 1 - tags: input, named, interface
/** Allows you to set attributes of the image. */
export interface HumanLoopDataAttributes {
  /** Sets whether the input image is free of personally identifiable information or adult content. */
  ContentClassifiers?: ContentClassifier[] | null;
}
function fromHumanLoopDataAttributes(input?: HumanLoopDataAttributes | null): jsonP.JSONValue {
  if (!input) return input;
  return {
    ContentClassifiers: input["ContentClassifiers"],
  }
}

// refs: 1 - tags: input, named, enum
export type ContentClassifier =
| "FreeOfPersonallyIdentifiableInformation"
| "FreeOfAdultContent"
| cmnP.UnexpectedEnumValue;

// refs: 3 - tags: input, named, interface
/** The Amazon S3 bucket that contains the document to be processed. */
export interface DocumentLocation {
  /** The Amazon S3 bucket that contains the input document. */
  S3Object?: S3Object | null;
}
function fromDocumentLocation(input?: DocumentLocation | null): jsonP.JSONValue {
  if (!input) return input;
  return {
    S3Object: fromS3Object(input["S3Object"]),
  }
}

// refs: 3 - tags: input, named, interface
/** The Amazon Simple Notification Service (Amazon SNS) topic to which Amazon Textract publishes the completion status of an asynchronous document operation, such as "StartDocumentTextDetection". */
export interface NotificationChannel {
  /** The Amazon SNS topic that Amazon Textract posts the completion status to. */
  SNSTopicArn: string;
  /** The Amazon Resource Name (ARN) of an IAM role that gives Amazon Textract publishing permissions to the Amazon SNS topic. */
  RoleArn: string;
}
function fromNotificationChannel(input?: NotificationChannel | null): jsonP.JSONValue {
  if (!input) return input;
  return {
    SNSTopicArn: input["SNSTopicArn"],
    RoleArn: input["RoleArn"],
  }
}

// refs: 3 - tags: input, named, interface
/** Sets whether or not your output will go to a user created bucket. */
export interface OutputConfig {
  /** The name of the bucket your output will go to. */
  S3Bucket: string;
  /** The prefix of the object key that the output will be saved to. */
  S3Prefix?: string | null;
}
function fromOutputConfig(input?: OutputConfig | null): jsonP.JSONValue {
  if (!input) return input;
  return {
    S3Bucket: input["S3Bucket"],
    S3Prefix: input["S3Prefix"],
  }
}

// refs: 7 - tags: output, named, interface
/** Information about the input document. */
export interface DocumentMetadata {
  /** The number of pages that are detected in the document. */
  Pages?: number | null;
}
function toDocumentMetadata(root: jsonP.JSONValue): DocumentMetadata {
  return jsonP.readObj({
    required: {},
    optional: {
      "Pages": "n",
    },
  }, root);
}

// refs: 4 - tags: output, named, interface
/** A `Block` represents items that are recognized in a document within a group of pixels close to each other. */
export interface Block {
  /** The type of text item that's recognized. */
  BlockType?: BlockType | null;
  /** The confidence score that Amazon Textract has in the accuracy of the recognized text and the accuracy of the geometry points around the recognized text. */
  Confidence?: number | null;
  /** The word or line of text that's recognized by Amazon Textract. */
  Text?: string | null;
  /** The kind of text that Amazon Textract has detected. */
  TextType?: TextType | null;
  /** The row in which a table cell is located. */
  RowIndex?: number | null;
  /** The column in which a table cell appears. */
  ColumnIndex?: number | null;
  /** The number of rows that a table cell spans. */
  RowSpan?: number | null;
  /** The number of columns that a table cell spans. */
  ColumnSpan?: number | null;
  /** The location of the recognized text on the image. */
  Geometry?: Geometry | null;
  /** The identifier for the recognized text. */
  Id?: string | null;
  /** A list of child blocks of the current block. */
  Relationships?: Relationship[] | null;
  /** The type of entity. */
  EntityTypes?: EntityType[] | null;
  /** The selection status of a selection element, such as an option button or check box. */
  SelectionStatus?: SelectionStatus | null;
  /** The page on which a block was detected. */
  Page?: number | null;
}
function toBlock(root: jsonP.JSONValue): Block {
  return jsonP.readObj({
    required: {},
    optional: {
      "BlockType": (x: jsonP.JSONValue) => cmnP.readEnum<BlockType>(x),
      "Confidence": "n",
      "Text": "s",
      "TextType": (x: jsonP.JSONValue) => cmnP.readEnum<TextType>(x),
      "RowIndex": "n",
      "ColumnIndex": "n",
      "RowSpan": "n",
      "ColumnSpan": "n",
      "Geometry": toGeometry,
      "Id": "s",
      "Relationships": [toRelationship],
      "EntityTypes": [(x: jsonP.JSONValue) => cmnP.readEnum<EntityType>(x)],
      "SelectionStatus": (x: jsonP.JSONValue) => cmnP.readEnum<SelectionStatus>(x),
      "Page": "n",
    },
  }, root);
}

// refs: 4 - tags: output, named, enum
export type BlockType =
| "KEY_VALUE_SET"
| "PAGE"
| "LINE"
| "WORD"
| "TABLE"
| "CELL"
| "SELECTION_ELEMENT"
| cmnP.UnexpectedEnumValue;

// refs: 4 - tags: output, named, enum
export type TextType =
| "HANDWRITING"
| "PRINTED"
| cmnP.UnexpectedEnumValue;

// refs: 12 - tags: output, named, interface
/** Information about where the following items are located on a document page: detected page, text, key-value pairs, tables, table cells, and selection elements. */
export interface Geometry {
  /** An axis-aligned coarse representation of the location of the recognized item on the document page. */
  BoundingBox?: BoundingBox | null;
  /** Within the bounding box, a fine-grained polygon around the recognized item. */
  Polygon?: Point[] | null;
}
function toGeometry(root: jsonP.JSONValue): Geometry {
  return jsonP.readObj({
    required: {},
    optional: {
      "BoundingBox": toBoundingBox,
      "Polygon": [toPoint],
    },
  }, root);
}

// refs: 12 - tags: output, named, interface
/** The bounding box around the detected page, text, key-value pair, table, table cell, or selection element on a document page. */
export interface BoundingBox {
  /** The width of the bounding box as a ratio of the overall document page width. */
  Width?: number | null;
  /** The height of the bounding box as a ratio of the overall document page height. */
  Height?: number | null;
  /** The left coordinate of the bounding box as a ratio of overall document page width. */
  Left?: number | null;
  /** The top coordinate of the bounding box as a ratio of overall document page height. */
  Top?: number | null;
}
function toBoundingBox(root: jsonP.JSONValue): BoundingBox {
  return jsonP.readObj({
    required: {},
    optional: {
      "Width": "n",
      "Height": "n",
      "Left": "n",
      "Top": "n",
    },
  }, root);
}

// refs: 12 - tags: output, named, interface
/** The X and Y coordinates of a point on a document page. */
export interface Point {
  /** The value of the X coordinate for a point on a `Polygon`. */
  X?: number | null;
  /** The value of the Y coordinate for a point on a `Polygon`. */
  Y?: number | null;
}
function toPoint(root: jsonP.JSONValue): Point {
  return jsonP.readObj({
    required: {},
    optional: {
      "X": "n",
      "Y": "n",
    },
  }, root);
}

// refs: 4 - tags: output, named, interface
/** Information about how blocks are related to each other. */
export interface Relationship {
  /** The type of relationship that the blocks in the IDs array have with the current block. */
  Type?: RelationshipType | null;
  /** An array of IDs for related blocks. */
  Ids?: string[] | null;
}
function toRelationship(root: jsonP.JSONValue): Relationship {
  return jsonP.readObj({
    required: {},
    optional: {
      "Type": (x: jsonP.JSONValue) => cmnP.readEnum<RelationshipType>(x),
      "Ids": ["s"],
    },
  }, root);
}

// refs: 4 - tags: output, named, enum
export type RelationshipType =
| "VALUE"
| "CHILD"
| "COMPLEX_FEATURES"
| cmnP.UnexpectedEnumValue;

// refs: 4 - tags: output, named, enum
export type EntityType =
| "KEY"
| "VALUE"
| cmnP.UnexpectedEnumValue;

// refs: 4 - tags: output, named, enum
export type SelectionStatus =
| "SELECTED"
| "NOT_SELECTED"
| cmnP.UnexpectedEnumValue;

// refs: 1 - tags: output, named, interface
/** Shows the results of the human in the loop evaluation. */
export interface HumanLoopActivationOutput {
  /** The Amazon Resource Name (ARN) of the HumanLoop created. */
  HumanLoopArn?: string | null;
  /** Shows if and why human review was needed. */
  HumanLoopActivationReasons?: string[] | null;
  /** Shows the result of condition evaluations, including those conditions which activated a human review. */
  HumanLoopActivationConditionsEvaluationResults?: jsonP.JSONValue | null;
}
function toHumanLoopActivationOutput(root: jsonP.JSONValue): HumanLoopActivationOutput {
  return jsonP.readObj({
    required: {},
    optional: {
      "HumanLoopArn": "s",
      "HumanLoopActivationReasons": ["s"],
      "HumanLoopActivationConditionsEvaluationResults": jsonP.readJsonValue,
    },
  }, root);
}

// refs: 2 - tags: output, named, interface
/** The structure holding all the information returned by AnalyzeExpense */
export interface ExpenseDocument {
  /** Denotes which invoice or receipt in the document the information is coming from. */
  ExpenseIndex?: number | null;
  /** Any information found outside of a table by Amazon Textract. */
  SummaryFields?: ExpenseField[] | null;
  /** Information detected on each table of a document, seperated into `LineItems`. */
  LineItemGroups?: LineItemGroup[] | null;
}
function toExpenseDocument(root: jsonP.JSONValue): ExpenseDocument {
  return jsonP.readObj({
    required: {},
    optional: {
      "ExpenseIndex": "n",
      "SummaryFields": [toExpenseField],
      "LineItemGroups": [toLineItemGroup],
    },
  }, root);
}

// refs: 4 - tags: output, named, interface
/** Breakdown of detected information, seperated into the catagories Type, LabelDetection, and ValueDetection */
export interface ExpenseField {
  /** The implied label of a detected element. */
  Type?: ExpenseType | null;
  /** The explicitly stated label of a detected element. */
  LabelDetection?: ExpenseDetection | null;
  /** The value of a detected element. */
  ValueDetection?: ExpenseDetection | null;
  /** The page number the value was detected on. */
  PageNumber?: number | null;
}
function toExpenseField(root: jsonP.JSONValue): ExpenseField {
  return jsonP.readObj({
    required: {},
    optional: {
      "Type": toExpenseType,
      "LabelDetection": toExpenseDetection,
      "ValueDetection": toExpenseDetection,
      "PageNumber": "n",
    },
  }, root);
}

// refs: 4 - tags: output, named, interface
/** An object used to store information about the Type detected by Amazon Textract. */
export interface ExpenseType {
  /** The word or line of text detected by Amazon Textract. */
  Text?: string | null;
  /** The confidence of accuracy, as a percentage. */
  Confidence?: number | null;
}
function toExpenseType(root: jsonP.JSONValue): ExpenseType {
  return jsonP.readObj({
    required: {},
    optional: {
      "Text": "s",
      "Confidence": "n",
    },
  }, root);
}

// refs: 8 - tags: output, named, interface
/** An object used to store information about the Value or Label detected by Amazon Textract. */
export interface ExpenseDetection {
  /** The word or line of text recognized by Amazon Textract */
  Text?: string | null;
  Geometry?: Geometry | null;
  /** The confidence in detection, as a percentage */
  Confidence?: number | null;
}
function toExpenseDetection(root: jsonP.JSONValue): ExpenseDetection {
  return jsonP.readObj({
    required: {},
    optional: {
      "Text": "s",
      "Geometry": toGeometry,
      "Confidence": "n",
    },
  }, root);
}

// refs: 2 - tags: output, named, interface
/** A grouping of tables which contain LineItems, with each table identified by the table's `LineItemGroupIndex`. */
export interface LineItemGroup {
  /** The number used to identify a specific table in a document. */
  LineItemGroupIndex?: number | null;
  /** The breakdown of information on a particular line of a table. */
  LineItems?: LineItemFields[] | null;
}
function toLineItemGroup(root: jsonP.JSONValue): LineItemGroup {
  return jsonP.readObj({
    required: {},
    optional: {
      "LineItemGroupIndex": "n",
      "LineItems": [toLineItemFields],
    },
  }, root);
}

// refs: 2 - tags: output, named, interface
/** A structure that holds information about the different lines found in a document's tables. */
export interface LineItemFields {
  /** ExpenseFields used to show information from detected lines on a table. */
  LineItemExpenseFields?: ExpenseField[] | null;
}
function toLineItemFields(root: jsonP.JSONValue): LineItemFields {
  return jsonP.readObj({
    required: {},
    optional: {
      "LineItemExpenseFields": [toExpenseField],
    },
  }, root);
}

// refs: 1 - tags: output, named, interface
/** The structure that lists each document processed in an AnalyzeID operation. */
export interface IdentityDocument {
  /** Denotes the placement of a document in the IdentityDocument list. */
  DocumentIndex?: number | null;
  /** The structure used to record information extracted from identity documents. */
  IdentityDocumentFields?: IdentityDocumentField[] | null;
}
function toIdentityDocument(root: jsonP.JSONValue): IdentityDocument {
  return jsonP.readObj({
    required: {},
    optional: {
      "DocumentIndex": "n",
      "IdentityDocumentFields": [toIdentityDocumentField],
    },
  }, root);
}

// refs: 1 - tags: output, named, interface
/** Structure containing both the normalized type of the extracted information and the text associated with it. */
export interface IdentityDocumentField {
  Type?: AnalyzeIDDetections | null;
  ValueDetection?: AnalyzeIDDetections | null;
}
function toIdentityDocumentField(root: jsonP.JSONValue): IdentityDocumentField {
  return jsonP.readObj({
    required: {},
    optional: {
      "Type": toAnalyzeIDDetections,
      "ValueDetection": toAnalyzeIDDetections,
    },
  }, root);
}

// refs: 2 - tags: output, named, interface
/** Used to contain the information detected by an AnalyzeID operation. */
export interface AnalyzeIDDetections {
  /** Text of either the normalized field or value associated with it. */
  Text: string;
  /** Only returned for dates, returns the type of value detected and the date written in a more machine readable way. */
  NormalizedValue?: NormalizedValue | null;
  /** The confidence score of the detected text. */
  Confidence?: number | null;
}
function toAnalyzeIDDetections(root: jsonP.JSONValue): AnalyzeIDDetections {
  return jsonP.readObj({
    required: {
      "Text": "s",
    },
    optional: {
      "NormalizedValue": toNormalizedValue,
      "Confidence": "n",
    },
  }, root);
}

// refs: 2 - tags: output, named, interface
/** Contains information relating to dates in a document, including the type of value, and the value. */
export interface NormalizedValue {
  /** The value of the date, written as Year-Month-DayTHour:Minute:Second. */
  Value?: string | null;
  /** The normalized type of the value detected. */
  ValueType?: ValueType | null;
}
function toNormalizedValue(root: jsonP.JSONValue): NormalizedValue {
  return jsonP.readObj({
    required: {},
    optional: {
      "Value": "s",
      "ValueType": (x: jsonP.JSONValue) => cmnP.readEnum<ValueType>(x),
    },
  }, root);
}

// refs: 2 - tags: output, named, enum
export type ValueType =
| "DATE"
| cmnP.UnexpectedEnumValue;

// refs: 3 - tags: output, named, enum
export type JobStatus =
| "IN_PROGRESS"
| "SUCCEEDED"
| "FAILED"
| "PARTIAL_SUCCESS"
| cmnP.UnexpectedEnumValue;

// refs: 3 - tags: output, named, interface
/** A warning about an issue that occurred during asynchronous text analysis ("StartDocumentAnalysis") or asynchronous document text detection ("StartDocumentTextDetection"). */
export interface Warning {
  /** The error code for the warning. */
  ErrorCode?: string | null;
  /** A list of the pages that the warning applies to. */
  Pages?: number[] | null;
}
function toWarning(root: jsonP.JSONValue): Warning {
  return jsonP.readObj({
    required: {},
    optional: {
      "ErrorCode": "s",
      "Pages": ["n"],
    },
  }, root);
}