feat(kyc): expose submission completeness on personal and financial data - #195
feat(kyc): expose submission completeness on personal and financial data#195joshuakrueger-dfx wants to merge 4 commits into
Conversation
The API returns whether a submission was complete and which required fields are still missing. Type the two submit calls accordingly so consumers can surface the information, and model the previously anonymous question conditions as a named interface.
Consumers pin this library independently and can run against an API deployment that does not report submission completeness yet. With both fields required, a consumer reading `result.complete` gets undefined and treats a submission that in fact succeeded as incomplete - the inverse of the symptom this contract is meant to remove. Both fields are now optional with a documented absence case, following ApiException.switchToCode. The test restated what the type system already enforces: three guard helpers plus the same fact asserted up to six times per case. Reverting the return type flags the plain field access before it reaches any of the helpers, so they detected nothing. What remains follows bank-api.test.ts - the exact call shape per endpoint, the response passing through unchanged, and one case for a response without the two fields, which only compiles while they are optional.
|
Converted to draft. The API counterpart (DFXswiss/api#4426) was closed without merging, so no deployment returns Both fields are optional, so this is technically safe to merge — which is exactly the risk. Two things came out of reviewing the API side that are worth recording here:
The reported symptom is still undiagnosed. Both frontends evaluate the submit response through |
Status
This PR was written against DFXswiss/api#4426, which has since been closed without merging. The
API does not send
completeormissingFieldson either submit endpoint, and there is currently noopen API PR that would add them.
Both fields are optional, so merging this would not break anything at runtime — but it would ship an
SDK type promising fields that no deployment returns.
completewould arrive asundefinedfromevery real response, and a consumer writing
if (!result.complete)would treat every submit asincomplete. That is why this stays a draft rather than being merged on the grounds of being additive.
What the API side did land instead:
KycStep.updateno longer clears omitted fields, so the submit responsecarries
statusandsequenceNumberagain, asKycStepBasealready declared.conditionsin the Swagger contract. That field was already sent atruntime and already typed here, so it changes nothing for this library.
What is in this PR
KycStepSubmitextendingKycStepBasewith optionalcompleteandmissingFields, and thematching return types on
KycApi.setPersonalData/setFinancialDataand the hook. Held untilan API change actually emits the fields.
KycFinancialQuestion.conditionsis a namedKycFinancialConditioninterface instead of ananonymous inline object. The field was already typed and readable; consumers can now import the
type instead of restating the shape. This part is independent of the API and would be safe on its
own, but it is cosmetic and does not carry a PR by itself.
Purely additive — existing consumers reading only
KycStepBasefields are unaffected.Tests
kyc-api.test.tsfollows the pattern ofbank-api.test.ts: it pins the exact call shape of eachendpoint (URL, method, body,
token: false,x-kyc-codeheader) and asserts that the responsepasses through the client unchanged. One case covers a response without the two fields, which only
compiles while they are optional.
@dfx.swiss/core: 7 suites, 74 tests, 5 of them new (69 ondevelop).Counter-proofs, each run on this revision. In all three type cases the file's tests are not counted
at all, so the suite line is the signal, not the test line:
KycStepBaseTest Suites: 1 failed, 6 passed(TS2339 onresult.complete)complete?back to requiredTest Suites: 1 failed, 6 passed(TS2741 at the response literal)missingFields?back to requiredTest Suites: 1 failed, 6 passed(TS2741 at the response literal)missingFieldsat runtimeTests: 1 failed, 73 passedGates:
lerna run lintandlerna run format:checkclean across all 4 projects;coreandreactbuild. No version bump or changelog per CONTRIBUTING; versioning happens through the publish
workflow.
What has to happen before this can go ready
attributed to a cause instead of a plausible one.
endpoint at least. On the personal endpoint the field would be constant: the global
ValidationPiperejects any incomplete body with 400, so after a successful call the onlyrequired field that can still be unset is
mail, which is owned by the ContactData step.