Issue #, if available: #179, a little pre-work for #183
Description of changes:
(Detailed also in the draft CHANGELOG.md)
Filter content by block type in .html({...}) rendering as requested by #179, with includeBlockTypes (allow-list) and skipBlockTypes (deny-list) options. The main expected use-case for this is to filter on the Layout* types... Other block types kinda work but can yield counter-intuitive results because of the nature of the Textract API.
More generally, iter/listContent(), Layout.iter/listItems(), and LayoutItem.iter/ListLayoutChildren() methods now support full Block type filtering with includeBlockTypes (allow-list) and/or skipBlockTypes (deny-list) options, and control over what happens when unexpected block types (not in either include or skip) are encountered.
New accessor on SelectionElement.isSelected, in convenient boolean format (versus the 2-member .selectionStatus enumeration)
Added Form Field.isCheckbox and FieldValue.isCheckbox, to check if a K->V field corresponds to a (label)->(selectionElement) pair. Also added {Field/FieldValue}.isSelected and .selectionStatus, which return null for non-'checkbox' fields. (Pre-work for #183)
Low-level relationship traversal via iter/listRelatedItemsByRelType() is now supported from Pages (PAGE blocks)
Refactors including:
WithContent mixin options refactored to more closely mirror IBlockTypeFilterOpts, because WithContent now aligns to iter/listRelatedItemsByRelType() under the hood. This will give us more fine-grained but standardised control of unexpected non-content child block type handling, per item class. ⚠️ But means some warning/error behaviour when parsing Textract JSON might have shifted a little (hopefully for the better).
A page's Layout no longer keeps any internal list-of-items state, instead referring to the parent PAGE block's child relationships directly.
Issue #, if available: #179, a little pre-work for #183
Description of changes:
(Detailed also in the draft
CHANGELOG.md
).html({...})
rendering as requested by #179, withincludeBlockTypes
(allow-list) andskipBlockTypes
(deny-list) options. The main expected use-case for this is to filter on the Layout* types... Other block types kinda work but can yield counter-intuitive results because of the nature of the Textract API.iter/listContent()
,Layout.iter/listItems()
, andLayoutItem.iter/ListLayoutChildren()
methods now support full Block type filtering withincludeBlockTypes
(allow-list) and/orskipBlockTypes
(deny-list) options, and control over what happens when unexpected block types (not in either include or skip) are encountered.SelectionElement.isSelected
, in convenient boolean format (versus the 2-member.selectionStatus
enumeration)Field.isCheckbox
andFieldValue.isCheckbox
, to check if a K->V field corresponds to a (label)->(selectionElement) pair. Also added{Field/FieldValue}.isSelected
and.selectionStatus
, which returnnull
for non-'checkbox' fields. (Pre-work for #183)iter/listRelatedItemsByRelType()
is now supported fromPage
s (PAGE blocks)WithContent
mixin options refactored to more closely mirrorIBlockTypeFilterOpts
, because WithContent now aligns toiter/listRelatedItemsByRelType()
under the hood. This will give us more fine-grained but standardised control of unexpected non-content child block type handling, per item class. ⚠️ But means some warning/error behaviour when parsing Textract JSON might have shifted a little (hopefully for the better).Layout
no longer keeps any internal list-of-items state, instead referring to the parentPAGE
block's child relationships directly.Initial alpha release available at amazon-textract-response-parser v0.4.2-alpha.3 on NPM - please share your feedback!
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.