In-Process Integration
A module installed in the same host as Dignite Vault Extract can keep its own data derived from Extract's documents — Vault Index keeps chunks and vectors, for example. It needs two things the other egress channels do not give it: a way to read documents from a background job, where there is no user, and a way to show a user only the documents Extract would let that user read. Extract provides one contract for each. Both are plain .NET calls inside the host; neither is an HTTP endpoint or an MCP tool.
| Contract | Called from | Identity | Returns |
|---|---|---|---|
IDocumentIntegrationService |
The module's event handlers and background jobs (ingestion) | None | Ready documents and their ids |
IDocumentAppService.GetReadScopeAsync |
The module's own query path, on behalf of a signed-in user | The caller's | What that user may read |
IDocumentAppService.GetIdsByFieldsAsync |
The same query path, when the user filters by extracted fields | The caller's | The documents whose fields match |
Both live in the Dignite.Vault.Extract.Application.Contracts package. Keep each on its own side: a query path that reads documents through the integration service skips Extract's read rule.
Ingestion: IDocumentIntegrationService
Namespace Dignite.Vault.Extract.Documents.Integration. It is an ABP integration service: ABP does not expose it over HTTP unless a host sets AbpAspNetCoreMvcOptions.ExposeIntegrationServices, and Vault Extract's own controllers do not implement it.
| Method | Returns |
|---|---|
FindReadyAsync(Guid id) |
The document if it is Ready under the current tenant, otherwise null |
GetReadyIdsAsync(GetReadyDocumentIdsInput input) |
One page of the ids of the current tenant's Ready documents |
GetFieldDefinitionsAsync(Guid documentTypeId) |
The field definitions of a document type in the current tenant's layer, archived fields included |
"Ready" means what DocumentReadyEto announces: the document passed the Ready gate, has a confirmed type and is not a container. Nothing outside that set is returned, which is why the service needs no user and performs no authorization check. Every method reads under the ambient tenant, so switch to the event's TenantId first (using (CurrentTenant.Change(eto.TenantId))).
FindReadyAsync returns a DocumentIntegrationDto:
| Property | Type | Description |
|---|---|---|
Id |
Guid |
The document |
TenantId |
Guid? |
null for a Host document |
DocumentTypeId |
Guid |
The confirmed type. Key derived data by this id, not by the type code, which can be renamed |
OwnerId |
Guid? |
The uploader; the owner the read scope's OwnerId is compared with. null for a row created with no user |
Title |
string? |
Display title |
Language |
string? |
ISO 639-1 / IETF tag; null when not detected |
Markdown |
string |
The whole text. Apply your own ceiling before sending it to an LLM |
ExtractedFields |
Dictionary<string, JsonElement>? |
Field values by name, in the same shape as the REST API's extractedFields |
Pages |
List<DocumentPageSpansDto>? |
The ranges of Markdown read from each page of the file (PageNumber, Spans of Offset and Length), the shape of Azure Document Intelligence's pages[].spans. null when the document has no current layout: a file without pages, a parse from before layouts were kept, or Markdown corrected after the parse |
Regions |
List<DocumentPageRegionDto>? |
Where on its page each element of Markdown (paragraph, heading, list item, table cell, figure) was read: its range (Offset, Length), PageNumber, and a box from the page's top-left corner in fractions of the page (Left, Top, Width, Height), the shape of Amazon Textract's BoundingBox. Only elements whose engine reported a region with the page's frame are listed: the PDF engine does, a page read by a vision model names only its page. null when Pages is or no element could be placed |
null from FindReadyAsync means there is nothing to apply now: the id is unknown, the document is in the recycle bin, or it was Ready when its event was published and has since gone back to review. Keep what you derived from its last Ready version; a deletion reaches you separately as DocumentDeletedEto.
GetReadyIdsAsync pages by a keyset cursor, for a first backfill or a rebuild. Pass the last id of the previous page as AfterId (null for the first page) and MaxResultCount as the page size (1 to 1000), and stop at an empty page. A cursor rather than an offset keeps the walk from skipping a document when an earlier one leaves the Ready set while you are walking it.
Guid? afterId = null;
while (true)
{
var page = await _documentIntegrationService.GetReadyIdsAsync(
new GetReadyDocumentIdsInput { AfterId = afterId, MaxResultCount = 200 });
if (page.Items.Count == 0)
{
break;
}
foreach (var id in page.Items)
{
// enqueue an ingestion job for id
}
afterId = page.Items[^1];
}
Field definitions
ExtractedFields gives each value by field name in its type's JSON shape, nothing more. A consumer that turns the values into something of its own (text for a prompt, columns of a table, labels for a Select) reads the definitions with GetFieldDefinitionsAsync(documentTypeId), as stored, as FieldDefinitionDtos: Name (the key in ExtractedFields), DisplayName, FieldTypeName and its Configuration (Select options, DateTime input mode, CKEditor content format, Table columns), DisplayOrder and the flags. Extract renders nothing for the consumer; what each field type writes into ExtractedFields is under Reading a Document, the field types themselves in Document Types and Fields.
- Archived fields are included. A document keeps the values of a field archived after it was extracted, and
FindReadyAsyncstill hands them out. A name is unique within a type, archived fields included, so the list can be keyed byName. - One layer. The definitions are those of the current tenant's layer, which is the document's: switch to the event's
TenantIdas for the document. A Host type and a tenant type with the same code are two types with two lists. - Ordered by
DisplayOrder, thenName. Empty for an unknown type. - Definitions change rarely, so a consumer that reads them for every document may cache them per type; an administrator's change does not re-fire the documents' events.
The integration service is not behind the VaultExtract.Enable feature, because it is called with no user. It tells you nothing by itself: learn what to pull from the integration events, and treat a repeated DocumentReadyEto as "pull it again".
Serving a user: GetReadScopeAsync
IDocumentAppService.GetReadScopeAsync() returns the calling user's read scope over the current tenant's documents, as a DocumentReadScopeDto:
| Property | Type | Description |
|---|---|---|
Version |
int |
The rule version; 1 today |
IsUnrestricted |
bool |
The user reads every document of the tenant (Documents.ReadAll) |
DocumentTypeIds |
List<Guid> |
The types the user reads through a per-type grant |
OwnerId |
Guid? |
The user's id when they read their own uploads; null otherwise |
Under version 1, a document is readable when IsUnrestricted is true, or its type id is in DocumentTypeIds, or its owner equals OwnerId. An empty list with a null owner reaches nothing. Store each derived row's DocumentTypeId and OwnerId (from DocumentIntegrationDto) and filter by that expression on every query.
- Accept only the versions you know.
Versionchanges whenever that reading changes. Refuse any other version rather than guess: an older module reading a newer rule could show a user more than Extract would. - Resolve it on every query. It reflects grants as they are now, so a revoked grant takes effect on the next query.
- It throws
AbpAuthorizationExceptionwhen the user lacksDocuments.Default. Such a user reaches nothing through your module either. The method also sits behind theVaultExtract.Enablefeature, like the rest of Extract's application services. - Answer "not found", not "forbidden", for a row outside the scope, as Extract's own read paths do.
The rule itself is described in Document Type Permissions.
Filtering by extracted fields: GetIdsByFieldsAsync
Keep no copy of field values in your module. When a user narrows your query by extracted fields, ask Extract which documents match and filter your rows by document id:
var matched = await _documentAppService.GetIdsByFieldsAsync(new GetDocumentIdsByFieldsInput
{
DocumentTypeCode = "lease",
FieldFilters = [new DocumentFieldFilter { Name = "monthly_rent", Min = "150000" }],
MaxResultCount = 10_000
});
DocumentTypeCode is required, and FieldFilters takes 1 to 10 conditions with the same rules as the document list's (REST API). Ids holds the matching documents in ascending id order, only those of that type the calling user may read, never a container; HasMore says more matched than MaxResultCount (1 to 10,000, default 10,000).
The lifecycle status is not a condition. Your rows hold what was released, and a document sent back to review or being re-parsed after its release keeps its rows at the released version, so it must keep matching; its current field values are the ones tested. A document never released is matched too and finds no rows of yours, but it counts toward MaxResultCount.
- Refuse, do not truncate, when
HasMoreistrue. Searching the first 10,000 ids silently drops the rest. Vault Index refuses withVaultIndex:FieldFilterTooBroad. - It throws like the document list:
AbpAuthorizationExceptionwithoutDocuments.Default, and aBusinessException(Extract:UnknownExtractedField) for a type code or field the current layer does not define. - Still apply the read scope to your own rows. The ids are already within it; filtering by both costs nothing and keeps your rows safe if the two calls see different grants.
See Also
- Integration Events — the events that tell you when to pull
- Document Type Permissions — the read rule the scope expresses
- ABP Integration Services