docs(sdk): document Yivi attribute disjunctions#113
Conversation
|
Dobby has received the request! Routing to the right specialist now... |
There was a problem hiding this comment.
Code review
Docs-only PR; new AttrReq/AttrDiscon/AttrConItem types and the wire-format JSON match postguard-js buildStartRequestBody and the merged types in src/types.ts. One internal inconsistency: the wire-format JSON example drops an attribute that appears in the TS example above it. Companion PKG PR encryption4all/postguard#198 is still open, so no deployed PKG accepts the nested con shape yet.
Rule compliance
One style-budget violation against the postguard-docs/CLAUDE.md writing rules (target zero, hard max 1 per 1,000 words for both em dashes and bold). The new section is ~290 words and contains 3 em dashes in prose (lines 83×2, 144) and 2 bold spans (lines 83, 93) — both well over budget. PR title, cross-repo references, and docs: scope are all fine.
| [{ "t": "pbdf.pbdf.idcard.firstName" }, { "t": "pbdf.pbdf.idcard.lastName" }], | ||
| [{ "t": "pbdf.pbdf.drivinglicence.firstName" }, { "t": "pbdf.pbdf.drivinglicence.lastName" }] | ||
| ], | ||
| { "t": "pbdf.sidn-pbdf.mobilenumber.mobilenumber", "optional": true } |
There was a problem hiding this comment.
[Code review] The TS example above (lines 99-121) sets attributes to discon + mobilenumber + dateofbirth, but this wire-format JSON shows only email + discon + mobilenumber — dateofbirth is missing. Add the third entry so the JSON visibly matches the TS example, or shrink the TS example to two entries.
| ``` | ||
|
|
||
| ::: info PKG requirement | ||
| Attribute disjunctions require `@e4a/pg-js` ≥ 1.11.0 and a PKG running `postguard` with condiscon support. Earlier PKG versions only accept a flat `con` array. |
There was a problem hiding this comment.
[Code review] The companion PKG change encryption4all/postguard#198 is still open, so today no deployed PKG accepts the nested con shape. Consider holding this docs merge (or noting in-flight status) until the PKG side lands so users following the example don't hit serde errors.
|
|
||
| ### Attribute disjunctions | ||
|
|
||
| By default each entry in `attributes` is a single attribute object (`AttrReq`). When you need to accept the same piece of information from multiple credential types — for example, a name that can come from a municipality credential, a passport, an ID card, or a driving licence — you can pass an **`AttrDiscon`** instead: a nested array where each inner array is one acceptable conjunction of attributes (an AND), and the outer array is the list of alternatives (an OR). |
There was a problem hiding this comment.
[Rule: postguard writing style] Two em dashes and one bold span in a single paragraph. Hard max is 1 per 1,000 words for each; this section is ~290 words. Rewrite the em-dash-flanked clause with commas or parentheses and drop the bold around AttrDiscon (the backticked code already carries the emphasis).
|
|
||
| Narrow the union at runtime with `Array.isArray(item)`: `true` → `AttrDiscon`, `false` → `AttrReq`. | ||
|
|
||
| **Making a disjunction optional** follows the Yivi convention: add an empty array `[]` as the first alternative. Yivi treats an empty conjunction as always-satisfiable, making the whole discon skippable. |
There was a problem hiding this comment.
[Rule: postguard writing style + writing-rules #48] Bold-sentence-opener (**Making a disjunction optional** followed by a colon and prose) is exactly the "inline header + colon + sentence" anti-pattern, and pushes the bold count over budget. Make this an #### subheading or plain prose.
|
|
||
| #### How it maps to the PKG wire format | ||
|
|
||
| The `attributes` array is forwarded verbatim as the `con` field in the `POST /v2/request/start` body. Single `AttrReq` objects serialise as `{"t":"..."}` objects; `AttrDiscon` entries serialise as nested arrays — exactly the shape the PKG's `ConItem` untagged enum expects: |
There was a problem hiding this comment.
[Rule: postguard writing style] Third prose em dash in the section. Replace with a comma or a colon: …nested arrays, exactly the shape the PKG's ConItem untagged enum expects:
|
/dobby review |
|
Dobby has received the request! Routing to the right specialist now... |
There was a problem hiding this comment.
Code review
All five prior findings resolved in fix commit ecab3b2. Docs build passes; no new issues.
Rule compliance
One minor style note (inline). Writing-rules, AI-slop, typo, conventional-commit, and cross-repo-link checks all pass.
|
|
||
| To make a disjunction optional, add an empty array `[]` as the first alternative. Yivi treats an empty conjunction as always-satisfiable, making the whole discon skippable. | ||
|
|
||
| #### Example: optional name from any government ID |
There was a problem hiding this comment.
[Rule: postguard-docs writing-rules] Heading contains a colon; PostGuard style guide says to avoid colons in titles. Consider #### Optional name from any government ID (the surrounding text already establishes this is an example). Non-blocking.
|
/dobby if this is non blokcing, why did you not approve the PR? |
|
Dobby has received the request! Routing to the right specialist now... |
Summary
AttrReq/AttrDiscon/AttrConItemtype hierarchy introduced inencryption4all/postguard-js#78[]to make the group skippable)POST /v2/request/startattributesparameter table entry to reflect the newAttrConItemtypeDependencies
Depends on
encryption4all/postguard-js#78(condiscon support) andencryption4all/postguard#198(PKGConItemwire format). The feature requires@e4a/pg-js≥ 1.11.0.Test plan
npm run docs:buildpasses with no errors