diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1/document.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1/document.proto index eb4615c1845..467a44921a6 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1/document.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1/document.proto @@ -324,6 +324,9 @@ message Document { // - "unfilled_checkbox" // - "filled_checkbox" string value_type = 5; + + // The history of this annotation. + Provenance provenance = 8; } // Detected language for a structural component. @@ -385,6 +388,9 @@ message Document { // A list of visually detected form fields on the page. repeated FormField form_fields = 11; + + // The history of this page. + Provenance provenance = 16; } // A phrase in the text that is a known entity type, such as a person, an @@ -536,6 +542,8 @@ message Document { // Required. Index into the [Document.pages][google.cloud.documentai.v1.Document.pages] element, for example using // [Document.pages][page_refs.page] to locate the related page element. + // This field is skipped when its value is the default 0. See + // https://developers.google.com/protocol-buffers/docs/proto3#json. int64 page = 1 [(google.api.field_behavior) = REQUIRED]; // Optional. The type of the layout element that is being referenced if any. @@ -568,8 +576,12 @@ message Document { // The index of the [Document.revisions] identifying the parent revision. int32 revision = 1; + // The index of the parent revisions corresponding collection of items + // (eg. list of entities, properties within entities, etc.) + int32 index = 3; + // The id of the parent provenance. - int32 id = 2; + int32 id = 2 [deprecated = true]; } // If a processor or agent does an explicit operation on existing elements. @@ -602,7 +614,7 @@ message Document { // The Id of this operation. Needs to be unique within the scope of the // revision. - int32 id = 2; + int32 id = 2 [deprecated = true]; // References to the original elements that are replaced. repeated Parent parents = 3; diff --git a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1/document_processor_service.proto b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1/document_processor_service.proto index 9f0b11a74de..65f0e6d967c 100644 --- a/packages/google-cloud-documentai/protos/google/cloud/documentai/v1/document_processor_service.proto +++ b/packages/google-cloud-documentai/protos/google/cloud/documentai/v1/document_processor_service.proto @@ -254,6 +254,18 @@ message BatchProcessMetadata { // Request message for review document method. message ReviewDocumentRequest { + reserved 2; + + // The priority level of the human review task. + enum Priority { + // The default priority level. + DEFAULT = 0; + + // The urgent priority level. The labeling manager should allocate labeler + // resource to the urgent task queue to respect this priority level. + URGENT = 1; + } + // The document payload. oneof source { // An inline document proto. @@ -268,6 +280,12 @@ message ReviewDocumentRequest { type: "documentai.googleapis.com/HumanReviewConfig" } ]; + + // Whether the validation should be performed on the ad-hoc review request. + bool enable_schema_validation = 3; + + // The priority of the human review task. + Priority priority = 5; } // Response message for review document method. diff --git a/packages/google-cloud-documentai/protos/protos.d.ts b/packages/google-cloud-documentai/protos/protos.d.ts index 9c5d7578c3f..5504882a531 100644 --- a/packages/google-cloud-documentai/protos/protos.d.ts +++ b/packages/google-cloud-documentai/protos/protos.d.ts @@ -555,6 +555,9 @@ export namespace google { /** Page formFields */ formFields?: (google.cloud.documentai.v1.Document.Page.IFormField[]|null); + + /** Page provenance */ + provenance?: (google.cloud.documentai.v1.Document.IProvenance|null); } /** Represents a Page. */ @@ -605,6 +608,9 @@ export namespace google { /** Page formFields. */ public formFields: google.cloud.documentai.v1.Document.Page.IFormField[]; + /** Page provenance. */ + public provenance?: (google.cloud.documentai.v1.Document.IProvenance|null); + /** * Creates a new Page instance using the specified properties. * @param [properties] Properties to set @@ -2062,6 +2068,9 @@ export namespace google { /** FormField valueType */ valueType?: (string|null); + + /** FormField provenance */ + provenance?: (google.cloud.documentai.v1.Document.IProvenance|null); } /** Represents a FormField. */ @@ -2088,6 +2097,9 @@ export namespace google { /** FormField valueType. */ public valueType: string; + /** FormField provenance. */ + public provenance?: (google.cloud.documentai.v1.Document.IProvenance|null); + /** * Creates a new FormField instance using the specified properties. * @param [properties] Properties to set @@ -3167,6 +3179,9 @@ export namespace google { /** Parent revision */ revision?: (number|null); + /** Parent index */ + index?: (number|null); + /** Parent id */ id?: (number|null); } @@ -3183,6 +3198,9 @@ export namespace google { /** Parent revision. */ public revision: number; + /** Parent index. */ + public index: number; + /** Parent id. */ public id: number; @@ -5383,6 +5401,12 @@ export namespace google { /** ReviewDocumentRequest humanReviewConfig */ humanReviewConfig?: (string|null); + + /** ReviewDocumentRequest enableSchemaValidation */ + enableSchemaValidation?: (boolean|null); + + /** ReviewDocumentRequest priority */ + priority?: (google.cloud.documentai.v1.ReviewDocumentRequest.Priority|keyof typeof google.cloud.documentai.v1.ReviewDocumentRequest.Priority|null); } /** Represents a ReviewDocumentRequest. */ @@ -5400,6 +5424,12 @@ export namespace google { /** ReviewDocumentRequest humanReviewConfig. */ public humanReviewConfig: string; + /** ReviewDocumentRequest enableSchemaValidation. */ + public enableSchemaValidation: boolean; + + /** ReviewDocumentRequest priority. */ + public priority: (google.cloud.documentai.v1.ReviewDocumentRequest.Priority|keyof typeof google.cloud.documentai.v1.ReviewDocumentRequest.Priority); + /** ReviewDocumentRequest source. */ public source?: "inlineDocument"; @@ -5474,6 +5504,15 @@ export namespace google { public toJSON(): { [k: string]: any }; } + namespace ReviewDocumentRequest { + + /** Priority enum. */ + enum Priority { + DEFAULT = 0, + URGENT = 1 + } + } + /** Properties of a ReviewDocumentResponse. */ interface IReviewDocumentResponse { diff --git a/packages/google-cloud-documentai/protos/protos.js b/packages/google-cloud-documentai/protos/protos.js index b8d0a78350a..3bdbfbb41e9 100644 --- a/packages/google-cloud-documentai/protos/protos.js +++ b/packages/google-cloud-documentai/protos/protos.js @@ -1502,6 +1502,7 @@ * @property {Array.|null} [visualElements] Page visualElements * @property {Array.|null} [tables] Page tables * @property {Array.|null} [formFields] Page formFields + * @property {google.cloud.documentai.v1.Document.IProvenance|null} [provenance] Page provenance */ /** @@ -1632,6 +1633,14 @@ */ Page.prototype.formFields = $util.emptyArray; + /** + * Page provenance. + * @member {google.cloud.documentai.v1.Document.IProvenance|null|undefined} provenance + * @memberof google.cloud.documentai.v1.Document.Page + * @instance + */ + Page.prototype.provenance = null; + /** * Creates a new Page instance using the specified properties. * @function create @@ -1691,6 +1700,8 @@ if (message.transforms != null && message.transforms.length) for (var i = 0; i < message.transforms.length; ++i) $root.google.cloud.documentai.v1.Document.Page.Matrix.encode(message.transforms[i], writer.uint32(/* id 14, wireType 2 =*/114).fork()).ldelim(); + if (message.provenance != null && Object.hasOwnProperty.call(message, "provenance")) + $root.google.cloud.documentai.v1.Document.Provenance.encode(message.provenance, writer.uint32(/* id 16, wireType 2 =*/130).fork()).ldelim(); return writer; }; @@ -1782,6 +1793,9 @@ message.formFields = []; message.formFields.push($root.google.cloud.documentai.v1.Document.Page.FormField.decode(reader, reader.uint32())); break; + case 16: + message.provenance = $root.google.cloud.documentai.v1.Document.Provenance.decode(reader, reader.uint32()); + break; default: reader.skipType(tag & 7); break; @@ -1916,6 +1930,11 @@ return "formFields." + error; } } + if (message.provenance != null && message.hasOwnProperty("provenance")) { + var error = $root.google.cloud.documentai.v1.Document.Provenance.verify(message.provenance); + if (error) + return "provenance." + error; + } return null; }; @@ -2038,6 +2057,11 @@ message.formFields[i] = $root.google.cloud.documentai.v1.Document.Page.FormField.fromObject(object.formFields[i]); } } + if (object.provenance != null) { + if (typeof object.provenance !== "object") + throw TypeError(".google.cloud.documentai.v1.Document.Page.provenance: object expected"); + message.provenance = $root.google.cloud.documentai.v1.Document.Provenance.fromObject(object.provenance); + } return message; }; @@ -2070,6 +2094,7 @@ object.dimension = null; object.layout = null; object.image = null; + object.provenance = null; } if (message.pageNumber != null && message.hasOwnProperty("pageNumber")) object.pageNumber = message.pageNumber; @@ -2124,6 +2149,8 @@ for (var j = 0; j < message.transforms.length; ++j) object.transforms[j] = $root.google.cloud.documentai.v1.Document.Page.Matrix.toObject(message.transforms[j], options); } + if (message.provenance != null && message.hasOwnProperty("provenance")) + object.provenance = $root.google.cloud.documentai.v1.Document.Provenance.toObject(message.provenance, options); return object; }; @@ -5601,6 +5628,7 @@ * @property {Array.|null} [nameDetectedLanguages] FormField nameDetectedLanguages * @property {Array.|null} [valueDetectedLanguages] FormField valueDetectedLanguages * @property {string|null} [valueType] FormField valueType + * @property {google.cloud.documentai.v1.Document.IProvenance|null} [provenance] FormField provenance */ /** @@ -5660,6 +5688,14 @@ */ FormField.prototype.valueType = ""; + /** + * FormField provenance. + * @member {google.cloud.documentai.v1.Document.IProvenance|null|undefined} provenance + * @memberof google.cloud.documentai.v1.Document.Page.FormField + * @instance + */ + FormField.prototype.provenance = null; + /** * Creates a new FormField instance using the specified properties. * @function create @@ -5696,6 +5732,8 @@ $root.google.cloud.documentai.v1.Document.Page.DetectedLanguage.encode(message.valueDetectedLanguages[i], writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); if (message.valueType != null && Object.hasOwnProperty.call(message, "valueType")) writer.uint32(/* id 5, wireType 2 =*/42).string(message.valueType); + if (message.provenance != null && Object.hasOwnProperty.call(message, "provenance")) + $root.google.cloud.documentai.v1.Document.Provenance.encode(message.provenance, writer.uint32(/* id 8, wireType 2 =*/66).fork()).ldelim(); return writer; }; @@ -5749,6 +5787,9 @@ case 5: message.valueType = reader.string(); break; + case 8: + message.provenance = $root.google.cloud.documentai.v1.Document.Provenance.decode(reader, reader.uint32()); + break; default: reader.skipType(tag & 7); break; @@ -5815,6 +5856,11 @@ if (message.valueType != null && message.hasOwnProperty("valueType")) if (!$util.isString(message.valueType)) return "valueType: string expected"; + if (message.provenance != null && message.hasOwnProperty("provenance")) { + var error = $root.google.cloud.documentai.v1.Document.Provenance.verify(message.provenance); + if (error) + return "provenance." + error; + } return null; }; @@ -5862,6 +5908,11 @@ } if (object.valueType != null) message.valueType = String(object.valueType); + if (object.provenance != null) { + if (typeof object.provenance !== "object") + throw TypeError(".google.cloud.documentai.v1.Document.Page.FormField.provenance: object expected"); + message.provenance = $root.google.cloud.documentai.v1.Document.Provenance.fromObject(object.provenance); + } return message; }; @@ -5886,6 +5937,7 @@ object.fieldName = null; object.fieldValue = null; object.valueType = ""; + object.provenance = null; } if (message.fieldName != null && message.hasOwnProperty("fieldName")) object.fieldName = $root.google.cloud.documentai.v1.Document.Page.Layout.toObject(message.fieldName, options); @@ -5903,6 +5955,8 @@ } if (message.valueType != null && message.hasOwnProperty("valueType")) object.valueType = message.valueType; + if (message.provenance != null && message.hasOwnProperty("provenance")) + object.provenance = $root.google.cloud.documentai.v1.Document.Provenance.toObject(message.provenance, options); return object; }; @@ -8538,6 +8592,7 @@ * @memberof google.cloud.documentai.v1.Document.Provenance * @interface IParent * @property {number|null} [revision] Parent revision + * @property {number|null} [index] Parent index * @property {number|null} [id] Parent id */ @@ -8564,6 +8619,14 @@ */ Parent.prototype.revision = 0; + /** + * Parent index. + * @member {number} index + * @memberof google.cloud.documentai.v1.Document.Provenance.Parent + * @instance + */ + Parent.prototype.index = 0; + /** * Parent id. * @member {number} id @@ -8600,6 +8663,8 @@ writer.uint32(/* id 1, wireType 0 =*/8).int32(message.revision); if (message.id != null && Object.hasOwnProperty.call(message, "id")) writer.uint32(/* id 2, wireType 0 =*/16).int32(message.id); + if (message.index != null && Object.hasOwnProperty.call(message, "index")) + writer.uint32(/* id 3, wireType 0 =*/24).int32(message.index); return writer; }; @@ -8637,6 +8702,9 @@ case 1: message.revision = reader.int32(); break; + case 3: + message.index = reader.int32(); + break; case 2: message.id = reader.int32(); break; @@ -8678,6 +8746,9 @@ if (message.revision != null && message.hasOwnProperty("revision")) if (!$util.isInteger(message.revision)) return "revision: integer expected"; + if (message.index != null && message.hasOwnProperty("index")) + if (!$util.isInteger(message.index)) + return "index: integer expected"; if (message.id != null && message.hasOwnProperty("id")) if (!$util.isInteger(message.id)) return "id: integer expected"; @@ -8698,6 +8769,8 @@ var message = new $root.google.cloud.documentai.v1.Document.Provenance.Parent(); if (object.revision != null) message.revision = object.revision | 0; + if (object.index != null) + message.index = object.index | 0; if (object.id != null) message.id = object.id | 0; return message; @@ -8719,11 +8792,14 @@ if (options.defaults) { object.revision = 0; object.id = 0; + object.index = 0; } if (message.revision != null && message.hasOwnProperty("revision")) object.revision = message.revision; if (message.id != null && message.hasOwnProperty("id")) object.id = message.id; + if (message.index != null && message.hasOwnProperty("index")) + object.index = message.index; return object; }; @@ -13728,6 +13804,8 @@ * @interface IReviewDocumentRequest * @property {google.cloud.documentai.v1.IDocument|null} [inlineDocument] ReviewDocumentRequest inlineDocument * @property {string|null} [humanReviewConfig] ReviewDocumentRequest humanReviewConfig + * @property {boolean|null} [enableSchemaValidation] ReviewDocumentRequest enableSchemaValidation + * @property {google.cloud.documentai.v1.ReviewDocumentRequest.Priority|null} [priority] ReviewDocumentRequest priority */ /** @@ -13761,6 +13839,22 @@ */ ReviewDocumentRequest.prototype.humanReviewConfig = ""; + /** + * ReviewDocumentRequest enableSchemaValidation. + * @member {boolean} enableSchemaValidation + * @memberof google.cloud.documentai.v1.ReviewDocumentRequest + * @instance + */ + ReviewDocumentRequest.prototype.enableSchemaValidation = false; + + /** + * ReviewDocumentRequest priority. + * @member {google.cloud.documentai.v1.ReviewDocumentRequest.Priority} priority + * @memberof google.cloud.documentai.v1.ReviewDocumentRequest + * @instance + */ + ReviewDocumentRequest.prototype.priority = 0; + // OneOf field names bound to virtual getters and setters var $oneOfFields; @@ -13801,8 +13895,12 @@ writer = $Writer.create(); if (message.humanReviewConfig != null && Object.hasOwnProperty.call(message, "humanReviewConfig")) writer.uint32(/* id 1, wireType 2 =*/10).string(message.humanReviewConfig); + if (message.enableSchemaValidation != null && Object.hasOwnProperty.call(message, "enableSchemaValidation")) + writer.uint32(/* id 3, wireType 0 =*/24).bool(message.enableSchemaValidation); if (message.inlineDocument != null && Object.hasOwnProperty.call(message, "inlineDocument")) $root.google.cloud.documentai.v1.Document.encode(message.inlineDocument, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + if (message.priority != null && Object.hasOwnProperty.call(message, "priority")) + writer.uint32(/* id 5, wireType 0 =*/40).int32(message.priority); return writer; }; @@ -13843,6 +13941,12 @@ case 1: message.humanReviewConfig = reader.string(); break; + case 3: + message.enableSchemaValidation = reader.bool(); + break; + case 5: + message.priority = reader.int32(); + break; default: reader.skipType(tag & 7); break; @@ -13890,6 +13994,17 @@ if (message.humanReviewConfig != null && message.hasOwnProperty("humanReviewConfig")) if (!$util.isString(message.humanReviewConfig)) return "humanReviewConfig: string expected"; + if (message.enableSchemaValidation != null && message.hasOwnProperty("enableSchemaValidation")) + if (typeof message.enableSchemaValidation !== "boolean") + return "enableSchemaValidation: boolean expected"; + if (message.priority != null && message.hasOwnProperty("priority")) + switch (message.priority) { + default: + return "priority: enum value expected"; + case 0: + case 1: + break; + } return null; }; @@ -13912,6 +14027,18 @@ } if (object.humanReviewConfig != null) message.humanReviewConfig = String(object.humanReviewConfig); + if (object.enableSchemaValidation != null) + message.enableSchemaValidation = Boolean(object.enableSchemaValidation); + switch (object.priority) { + case "DEFAULT": + case 0: + message.priority = 0; + break; + case "URGENT": + case 1: + message.priority = 1; + break; + } return message; }; @@ -13928,15 +14055,22 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.humanReviewConfig = ""; + object.enableSchemaValidation = false; + object.priority = options.enums === String ? "DEFAULT" : 0; + } if (message.humanReviewConfig != null && message.hasOwnProperty("humanReviewConfig")) object.humanReviewConfig = message.humanReviewConfig; + if (message.enableSchemaValidation != null && message.hasOwnProperty("enableSchemaValidation")) + object.enableSchemaValidation = message.enableSchemaValidation; if (message.inlineDocument != null && message.hasOwnProperty("inlineDocument")) { object.inlineDocument = $root.google.cloud.documentai.v1.Document.toObject(message.inlineDocument, options); if (options.oneofs) object.source = "inlineDocument"; } + if (message.priority != null && message.hasOwnProperty("priority")) + object.priority = options.enums === String ? $root.google.cloud.documentai.v1.ReviewDocumentRequest.Priority[message.priority] : message.priority; return object; }; @@ -13951,6 +14085,20 @@ return this.constructor.toObject(this, $protobuf.util.toJSONOptions); }; + /** + * Priority enum. + * @name google.cloud.documentai.v1.ReviewDocumentRequest.Priority + * @enum {number} + * @property {number} DEFAULT=0 DEFAULT value + * @property {number} URGENT=1 URGENT value + */ + ReviewDocumentRequest.Priority = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "DEFAULT"] = 0; + values[valuesById[1] = "URGENT"] = 1; + return values; + })(); + return ReviewDocumentRequest; })(); diff --git a/packages/google-cloud-documentai/protos/protos.json b/packages/google-cloud-documentai/protos/protos.json index 0210786328c..b7abceda7ac 100644 --- a/packages/google-cloud-documentai/protos/protos.json +++ b/packages/google-cloud-documentai/protos/protos.json @@ -218,6 +218,10 @@ "rule": "repeated", "type": "FormField", "id": 11 + }, + "provenance": { + "type": "Provenance", + "id": 16 } }, "nested": { @@ -495,6 +499,10 @@ "valueType": { "type": "string", "id": 5 + }, + "provenance": { + "type": "Provenance", + "id": 8 } } }, @@ -751,7 +759,10 @@ }, "id": { "type": "int32", - "id": 2 + "id": 2, + "options": { + "deprecated": true + } }, "parents": { "rule": "repeated", @@ -770,9 +781,16 @@ "type": "int32", "id": 1 }, + "index": { + "type": "int32", + "id": 3 + }, "id": { "type": "int32", - "id": 2 + "id": 2, + "options": { + "deprecated": true + } } } }, @@ -1243,6 +1261,28 @@ "(google.api.field_behavior)": "REQUIRED", "(google.api.resource_reference).type": "documentai.googleapis.com/HumanReviewConfig" } + }, + "enableSchemaValidation": { + "type": "bool", + "id": 3 + }, + "priority": { + "type": "Priority", + "id": 5 + } + }, + "reserved": [ + [ + 2, + 2 + ] + ], + "nested": { + "Priority": { + "values": { + "DEFAULT": 0, + "URGENT": 1 + } } } }, diff --git a/packages/google-cloud-documentai/src/v1/document_processor_service_client.ts b/packages/google-cloud-documentai/src/v1/document_processor_service_client.ts index 8f7d6e99eff..dff16ac1453 100644 --- a/packages/google-cloud-documentai/src/v1/document_processor_service_client.ts +++ b/packages/google-cloud-documentai/src/v1/document_processor_service_client.ts @@ -617,6 +617,10 @@ export class DocumentProcessorServiceClient { * @param {string} request.humanReviewConfig * Required. The resource name of the HumanReviewConfig that the document will be * reviewed with. + * @param {boolean} request.enableSchemaValidation + * Whether the validation should be performed on the ad-hoc review request. + * @param {google.cloud.documentai.v1.ReviewDocumentRequest.Priority} request.priority + * The priority of the human review task. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array.