Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TRP.js v0.4.2(?) release draft #180

Merged
merged 15 commits into from
Jun 28, 2024
Merged

Conversation

athewsey
Copy link
Contributor

@athewsey athewsey commented Jun 5, 2024

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 .html() function to support skipping certain blocks #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.

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.

athewsey added 5 commits June 8, 2024 15:16
Extend list/iterContent() methods to support run-time filtering by
chosen block types. Unit tests now fully cover content.ts!
Enable filtering top-level and nested layout items by block type, as
a pre-requisite for filtering specific layout block types out of HTML
representations. To facilitate this, also added support for
`iter/listRelatedItemsByRelType()` to `Page`.
Add initial draft includeBlockTypes & skipBlockTypes support to
html() rendering: Only for layout items (+page, document) and only
supporting filtering on LAYOUT_* API block types.
athewsey added 10 commits June 13, 2024 16:54
Extend block type filtering to cover all `IRenderable.html()`
interfaces, and build more sensible render filtering for non-Layout
block types. By convention, html() and other rendering methods now
check for the *component's own* block type, whereas accessors like
listContent() only consider the children they're scanning through.
Make page.layout stateless: Traversing PAGE child relationships from
constructor rather than receiving a list of blocks. Move `_parse`
into body of Page constructor to facilitate this (can't create Layout
until other Page child blocks have parsed).
{iter/list}RelatedItemsByRelType now go via Blocks first, providing
a route to more standardised+configurable missing block handling
behaviour (currently at `error`).
Add initial SelectionElement.isSelected, and Field+FieldValue
properties isSelection & isSelected - to help navigate selection
element (checkbox/radio) based K-V results.
While `isSelection` was more semantically representative of the
underlying API, `isCheckbox` is more discoverable to users with the
primary intended use-case.
from rename of `isSelection` to `isCheckbox`.
@athewsey athewsey marked this pull request as ready for review June 28, 2024 11:39
@athewsey athewsey merged commit a87148d into aws-samples:master Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant