From b7ce5da5f70503bccc08a8d8051afff521749fd0 Mon Sep 17 00:00:00 2001 From: "gcf-owl-bot[bot]" <78513119+gcf-owl-bot[bot]@users.noreply.github.com> Date: Tue, 23 Apr 2024 12:46:56 -0700 Subject: [PATCH] feat: [documentai] Support Chunk header and footer in Doc AI external proto (#5275) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat: Support Chunk header and footer in Doc AI external proto docs: Keep the API doc up-to-date with recent changes PiperOrigin-RevId: 627100297 Source-Link: https://github.com/googleapis/googleapis/commit/caad330c676f351a209667840165cc2f136ccf3d Source-Link: https://github.com/googleapis/googleapis-gen/commit/b20a664c8db22dd6c03c78f1fb4ea65788f40e3a Copy-Tag: eyJwIjoicGFja2FnZXMvZ29vZ2xlLWNsb3VkLWRvY3VtZW50YWkvLk93bEJvdC55YW1sIiwiaCI6ImIyMGE2NjRjOGRiMjJkZDZjMDNjNzhmMWZiNGVhNjU3ODhmNDBlM2EifQ== * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: Owl Bot --- .../cloud/documentai/v1beta3/document.proto | 33 +- .../protos/protos.d.ts | 218 +++++++ .../google-cloud-documentai/protos/protos.js | 555 +++++++++++++++++- .../protos/protos.json | 34 ++ 4 files changed, 835 insertions(+), 5 deletions(-) diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document.proto index d93aafa98c5..e26e7c4181c 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1beta3/document.proto @@ -286,16 +286,16 @@ message Document { // Whether the text is underlined. bool underlined = 7; - // Whether the text is strikethrough. + // Whether the text is strikethrough. This feature is not supported yet. bool strikeout = 8; - // Whether the text is a subscript. + // Whether the text is a subscript. This feature is not supported yet. bool subscript = 9; - // Whether the text is a superscript. + // Whether the text is a superscript. This feature is not supported yet. bool superscript = 10; - // Whether the text is in small caps. + // Whether the text is in small caps. This feature is not supported yet. bool smallcaps = 11; // TrueType weight on a scale `100` (thin) to `1000` (ultra-heavy). @@ -1010,9 +1010,28 @@ message Document { int32 page_end = 2; } + // Represents the page header associated with the chunk. + message ChunkPageHeader { + // Header in text format. + string text = 1; + + // Page span of the header. + ChunkPageSpan page_span = 2; + } + + // Represents the page footer associated with the chunk. + message ChunkPageFooter { + // Footer in text format. + string text = 1; + + // Page span of the footer. + ChunkPageSpan page_span = 2; + } + // ID of the chunk. string chunk_id = 1; + // DO NOT USE. // List of all parsed documents layout source blocks used to generate the // chunk. repeated string source_block_ids = 2; @@ -1022,6 +1041,12 @@ message Document { // Page span of the chunk. ChunkPageSpan page_span = 4; + + // Page headers associated with the chunk. + repeated ChunkPageHeader page_headers = 5; + + // Page footers associated with the chunk. + repeated ChunkPageFooter page_footers = 6; } // List of chunks. diff --git a/packages/google-cloud-documentai/protos/protos.d.ts b/packages/google-cloud-documentai/protos/protos.d.ts index 0ffda8f2a51..b280905e920 100644 --- a/packages/google-cloud-documentai/protos/protos.d.ts +++ b/packages/google-cloud-documentai/protos/protos.d.ts @@ -32766,6 +32766,12 @@ export namespace google { /** Chunk pageSpan */ pageSpan?: (google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null); + + /** Chunk pageHeaders */ + pageHeaders?: (google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader[]|null); + + /** Chunk pageFooters */ + pageFooters?: (google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter[]|null); } /** Represents a Chunk. */ @@ -32789,6 +32795,12 @@ export namespace google { /** Chunk pageSpan. */ public pageSpan?: (google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null); + /** Chunk pageHeaders. */ + public pageHeaders: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader[]; + + /** Chunk pageFooters. */ + public pageFooters: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter[]; + /** * Creates a new Chunk instance using the specified properties. * @param [properties] Properties to set @@ -32971,6 +32983,212 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a ChunkPageHeader. */ + interface IChunkPageHeader { + + /** ChunkPageHeader text */ + text?: (string|null); + + /** ChunkPageHeader pageSpan */ + pageSpan?: (google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null); + } + + /** Represents a ChunkPageHeader. */ + class ChunkPageHeader implements IChunkPageHeader { + + /** + * Constructs a new ChunkPageHeader. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader); + + /** ChunkPageHeader text. */ + public text: string; + + /** ChunkPageHeader pageSpan. */ + public pageSpan?: (google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null); + + /** + * Creates a new ChunkPageHeader instance using the specified properties. + * @param [properties] Properties to set + * @returns ChunkPageHeader instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader): google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader; + + /** + * Encodes the specified ChunkPageHeader message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.verify|verify} messages. + * @param message ChunkPageHeader message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ChunkPageHeader message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.verify|verify} messages. + * @param message ChunkPageHeader message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ChunkPageHeader message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ChunkPageHeader + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader; + + /** + * Decodes a ChunkPageHeader message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ChunkPageHeader + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader; + + /** + * Verifies a ChunkPageHeader message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ChunkPageHeader message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ChunkPageHeader + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader; + + /** + * Creates a plain object from a ChunkPageHeader message. Also converts values to other types if specified. + * @param message ChunkPageHeader + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ChunkPageHeader to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ChunkPageHeader + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a ChunkPageFooter. */ + interface IChunkPageFooter { + + /** ChunkPageFooter text */ + text?: (string|null); + + /** ChunkPageFooter pageSpan */ + pageSpan?: (google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null); + } + + /** Represents a ChunkPageFooter. */ + class ChunkPageFooter implements IChunkPageFooter { + + /** + * Constructs a new ChunkPageFooter. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter); + + /** ChunkPageFooter text. */ + public text: string; + + /** ChunkPageFooter pageSpan. */ + public pageSpan?: (google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null); + + /** + * Creates a new ChunkPageFooter instance using the specified properties. + * @param [properties] Properties to set + * @returns ChunkPageFooter instance + */ + public static create(properties?: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter): google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter; + + /** + * Encodes the specified ChunkPageFooter message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.verify|verify} messages. + * @param message ChunkPageFooter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified ChunkPageFooter message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.verify|verify} messages. + * @param message ChunkPageFooter message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a ChunkPageFooter message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns ChunkPageFooter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter; + + /** + * Decodes a ChunkPageFooter message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns ChunkPageFooter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter; + + /** + * Verifies a ChunkPageFooter message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a ChunkPageFooter message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns ChunkPageFooter + */ + public static fromObject(object: { [k: string]: any }): google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter; + + /** + * Creates a plain object from a ChunkPageFooter message. Also converts values to other types if specified. + * @param message ChunkPageFooter + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this ChunkPageFooter to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for ChunkPageFooter + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } } } } diff --git a/packages/google-cloud-documentai/protos/protos.js b/packages/google-cloud-documentai/protos/protos.js index 2a9b0be676d..b8da3116c0f 100644 --- a/packages/google-cloud-documentai/protos/protos.js +++ b/packages/google-cloud-documentai/protos/protos.js @@ -82648,6 +82648,8 @@ * @property {Array.|null} [sourceBlockIds] Chunk sourceBlockIds * @property {string|null} [content] Chunk content * @property {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null} [pageSpan] Chunk pageSpan + * @property {Array.|null} [pageHeaders] Chunk pageHeaders + * @property {Array.|null} [pageFooters] Chunk pageFooters */ /** @@ -82660,6 +82662,8 @@ */ function Chunk(properties) { this.sourceBlockIds = []; + this.pageHeaders = []; + this.pageFooters = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -82698,6 +82702,22 @@ */ Chunk.prototype.pageSpan = null; + /** + * Chunk pageHeaders. + * @member {Array.} pageHeaders + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk + * @instance + */ + Chunk.prototype.pageHeaders = $util.emptyArray; + + /** + * Chunk pageFooters. + * @member {Array.} pageFooters + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk + * @instance + */ + Chunk.prototype.pageFooters = $util.emptyArray; + /** * Creates a new Chunk instance using the specified properties. * @function create @@ -82731,6 +82751,12 @@ writer.uint32(/* id 3, wireType 2 =*/26).string(message.content); if (message.pageSpan != null && Object.hasOwnProperty.call(message, "pageSpan")) $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.encode(message.pageSpan, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.pageHeaders != null && message.pageHeaders.length) + for (var i = 0; i < message.pageHeaders.length; ++i) + $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.encode(message.pageHeaders[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); + if (message.pageFooters != null && message.pageFooters.length) + for (var i = 0; i < message.pageFooters.length; ++i) + $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.encode(message.pageFooters[i], writer.uint32(/* id 6, wireType 2 =*/50).fork()).ldelim(); return writer; }; @@ -82783,6 +82809,18 @@ message.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.decode(reader, reader.uint32()); break; } + case 5: { + if (!(message.pageHeaders && message.pageHeaders.length)) + message.pageHeaders = []; + message.pageHeaders.push($root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.decode(reader, reader.uint32())); + break; + } + case 6: { + if (!(message.pageFooters && message.pageFooters.length)) + message.pageFooters = []; + message.pageFooters.push($root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -82836,6 +82874,24 @@ if (error) return "pageSpan." + error; } + if (message.pageHeaders != null && message.hasOwnProperty("pageHeaders")) { + if (!Array.isArray(message.pageHeaders)) + return "pageHeaders: array expected"; + for (var i = 0; i < message.pageHeaders.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.verify(message.pageHeaders[i]); + if (error) + return "pageHeaders." + error; + } + } + if (message.pageFooters != null && message.hasOwnProperty("pageFooters")) { + if (!Array.isArray(message.pageFooters)) + return "pageFooters: array expected"; + for (var i = 0; i < message.pageFooters.length; ++i) { + var error = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.verify(message.pageFooters[i]); + if (error) + return "pageFooters." + error; + } + } return null; }; @@ -82867,6 +82923,26 @@ throw TypeError(".google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.pageSpan: object expected"); message.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.fromObject(object.pageSpan); } + if (object.pageHeaders) { + if (!Array.isArray(object.pageHeaders)) + throw TypeError(".google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.pageHeaders: array expected"); + message.pageHeaders = []; + for (var i = 0; i < object.pageHeaders.length; ++i) { + if (typeof object.pageHeaders[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.pageHeaders: object expected"); + message.pageHeaders[i] = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.fromObject(object.pageHeaders[i]); + } + } + if (object.pageFooters) { + if (!Array.isArray(object.pageFooters)) + throw TypeError(".google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.pageFooters: array expected"); + message.pageFooters = []; + for (var i = 0; i < object.pageFooters.length; ++i) { + if (typeof object.pageFooters[i] !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.pageFooters: object expected"); + message.pageFooters[i] = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.fromObject(object.pageFooters[i]); + } + } return message; }; @@ -82883,8 +82959,11 @@ if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) + if (options.arrays || options.defaults) { object.sourceBlockIds = []; + object.pageHeaders = []; + object.pageFooters = []; + } if (options.defaults) { object.chunkId = ""; object.content = ""; @@ -82901,6 +82980,16 @@ object.content = message.content; if (message.pageSpan != null && message.hasOwnProperty("pageSpan")) object.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.toObject(message.pageSpan, options); + if (message.pageHeaders && message.pageHeaders.length) { + object.pageHeaders = []; + for (var j = 0; j < message.pageHeaders.length; ++j) + object.pageHeaders[j] = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.toObject(message.pageHeaders[j], options); + } + if (message.pageFooters && message.pageFooters.length) { + object.pageFooters = []; + for (var j = 0; j < message.pageFooters.length; ++j) + object.pageFooters[j] = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.toObject(message.pageFooters[j], options); + } return object; }; @@ -83157,6 +83246,470 @@ return ChunkPageSpan; })(); + Chunk.ChunkPageHeader = (function() { + + /** + * Properties of a ChunkPageHeader. + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk + * @interface IChunkPageHeader + * @property {string|null} [text] ChunkPageHeader text + * @property {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null} [pageSpan] ChunkPageHeader pageSpan + */ + + /** + * Constructs a new ChunkPageHeader. + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk + * @classdesc Represents a ChunkPageHeader. + * @implements IChunkPageHeader + * @constructor + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader=} [properties] Properties to set + */ + function ChunkPageHeader(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ChunkPageHeader text. + * @member {string} text + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @instance + */ + ChunkPageHeader.prototype.text = ""; + + /** + * ChunkPageHeader pageSpan. + * @member {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null|undefined} pageSpan + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @instance + */ + ChunkPageHeader.prototype.pageSpan = null; + + /** + * Creates a new ChunkPageHeader instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader} ChunkPageHeader instance + */ + ChunkPageHeader.create = function create(properties) { + return new ChunkPageHeader(properties); + }; + + /** + * Encodes the specified ChunkPageHeader message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader} message ChunkPageHeader message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ChunkPageHeader.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.text != null && Object.hasOwnProperty.call(message, "text")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.text); + if (message.pageSpan != null && Object.hasOwnProperty.call(message, "pageSpan")) + $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.encode(message.pageSpan, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ChunkPageHeader message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageHeader} message ChunkPageHeader message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ChunkPageHeader.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ChunkPageHeader message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader} ChunkPageHeader + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ChunkPageHeader.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.text = reader.string(); + break; + } + case 2: { + message.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ChunkPageHeader message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader} ChunkPageHeader + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ChunkPageHeader.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ChunkPageHeader message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ChunkPageHeader.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.text != null && message.hasOwnProperty("text")) + if (!$util.isString(message.text)) + return "text: string expected"; + if (message.pageSpan != null && message.hasOwnProperty("pageSpan")) { + var error = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.verify(message.pageSpan); + if (error) + return "pageSpan." + error; + } + return null; + }; + + /** + * Creates a ChunkPageHeader message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader} ChunkPageHeader + */ + ChunkPageHeader.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader) + return object; + var message = new $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader(); + if (object.text != null) + message.text = String(object.text); + if (object.pageSpan != null) { + if (typeof object.pageSpan !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader.pageSpan: object expected"); + message.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.fromObject(object.pageSpan); + } + return message; + }; + + /** + * Creates a plain object from a ChunkPageHeader message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader} message ChunkPageHeader + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ChunkPageHeader.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.text = ""; + object.pageSpan = null; + } + if (message.text != null && message.hasOwnProperty("text")) + object.text = message.text; + if (message.pageSpan != null && message.hasOwnProperty("pageSpan")) + object.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.toObject(message.pageSpan, options); + return object; + }; + + /** + * Converts this ChunkPageHeader to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @instance + * @returns {Object.} JSON object + */ + ChunkPageHeader.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ChunkPageHeader + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ChunkPageHeader.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageHeader"; + }; + + return ChunkPageHeader; + })(); + + Chunk.ChunkPageFooter = (function() { + + /** + * Properties of a ChunkPageFooter. + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk + * @interface IChunkPageFooter + * @property {string|null} [text] ChunkPageFooter text + * @property {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null} [pageSpan] ChunkPageFooter pageSpan + */ + + /** + * Constructs a new ChunkPageFooter. + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk + * @classdesc Represents a ChunkPageFooter. + * @implements IChunkPageFooter + * @constructor + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter=} [properties] Properties to set + */ + function ChunkPageFooter(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * ChunkPageFooter text. + * @member {string} text + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @instance + */ + ChunkPageFooter.prototype.text = ""; + + /** + * ChunkPageFooter pageSpan. + * @member {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageSpan|null|undefined} pageSpan + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @instance + */ + ChunkPageFooter.prototype.pageSpan = null; + + /** + * Creates a new ChunkPageFooter instance using the specified properties. + * @function create + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter=} [properties] Properties to set + * @returns {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter} ChunkPageFooter instance + */ + ChunkPageFooter.create = function create(properties) { + return new ChunkPageFooter(properties); + }; + + /** + * Encodes the specified ChunkPageFooter message. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.verify|verify} messages. + * @function encode + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter} message ChunkPageFooter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ChunkPageFooter.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.text != null && Object.hasOwnProperty.call(message, "text")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.text); + if (message.pageSpan != null && Object.hasOwnProperty.call(message, "pageSpan")) + $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.encode(message.pageSpan, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified ChunkPageFooter message, length delimited. Does not implicitly {@link google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.IChunkPageFooter} message ChunkPageFooter message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + ChunkPageFooter.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a ChunkPageFooter message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter} ChunkPageFooter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ChunkPageFooter.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.text = reader.string(); + break; + } + case 2: { + message.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a ChunkPageFooter message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter} ChunkPageFooter + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + ChunkPageFooter.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a ChunkPageFooter message. + * @function verify + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + ChunkPageFooter.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.text != null && message.hasOwnProperty("text")) + if (!$util.isString(message.text)) + return "text: string expected"; + if (message.pageSpan != null && message.hasOwnProperty("pageSpan")) { + var error = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.verify(message.pageSpan); + if (error) + return "pageSpan." + error; + } + return null; + }; + + /** + * Creates a ChunkPageFooter message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter} ChunkPageFooter + */ + ChunkPageFooter.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter) + return object; + var message = new $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter(); + if (object.text != null) + message.text = String(object.text); + if (object.pageSpan != null) { + if (typeof object.pageSpan !== "object") + throw TypeError(".google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter.pageSpan: object expected"); + message.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.fromObject(object.pageSpan); + } + return message; + }; + + /** + * Creates a plain object from a ChunkPageFooter message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter} message ChunkPageFooter + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + ChunkPageFooter.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.text = ""; + object.pageSpan = null; + } + if (message.text != null && message.hasOwnProperty("text")) + object.text = message.text; + if (message.pageSpan != null && message.hasOwnProperty("pageSpan")) + object.pageSpan = $root.google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageSpan.toObject(message.pageSpan, options); + return object; + }; + + /** + * Converts this ChunkPageFooter to JSON. + * @function toJSON + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @instance + * @returns {Object.} JSON object + */ + ChunkPageFooter.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for ChunkPageFooter + * @function getTypeUrl + * @memberof google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + ChunkPageFooter.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.documentai.v1beta3.Document.ChunkedDocument.Chunk.ChunkPageFooter"; + }; + + return ChunkPageFooter; + })(); + return Chunk; })(); diff --git a/packages/google-cloud-documentai/protos/protos.json b/packages/google-cloud-documentai/protos/protos.json index 2666744e650..088da7f25c8 100644 --- a/packages/google-cloud-documentai/protos/protos.json +++ b/packages/google-cloud-documentai/protos/protos.json @@ -7120,6 +7120,16 @@ "pageSpan": { "type": "ChunkPageSpan", "id": 4 + }, + "pageHeaders": { + "rule": "repeated", + "type": "ChunkPageHeader", + "id": 5 + }, + "pageFooters": { + "rule": "repeated", + "type": "ChunkPageFooter", + "id": 6 } }, "nested": { @@ -7134,6 +7144,30 @@ "id": 2 } } + }, + "ChunkPageHeader": { + "fields": { + "text": { + "type": "string", + "id": 1 + }, + "pageSpan": { + "type": "ChunkPageSpan", + "id": 2 + } + } + }, + "ChunkPageFooter": { + "fields": { + "text": { + "type": "string", + "id": 1 + }, + "pageSpan": { + "type": "ChunkPageSpan", + "id": 2 + } + } } } }