Repository navigation
feat!: read Bastion's { data } envelope and domain codes (1.0.0) - #1
Merged
Merged
Conversation
Platform plan 03, W1: a client that works against both today's Bastion
and the 2.0 envelope, published before Bastion changes format.
- BastionHttp.call unwraps a body whose only key is `data`; pages,
arrays and other bodies pass through
- listMyEvents returns { data, meta }, normalising the pre-2.0 page
- Bastion's code is used when it is a BastionErrorCode and the message
is not itself one; new codes for the W0 domain errors (PROVIDER_TAKEN,
ALREADY_LINKED, AGE_*, CURRENT_PASSWORD_REQUIRED, ...)
- The plan's "code always wins" was wrong: an older Bastion sends
ALREADY_LINKED under code CONFLICT, so a code-as-message still wins
BREAKING CHANGE: `call` returns the inner value of a `{ data }`-only
body (e.g. GET /auth/me/tenants); listMyEvents moves the page fields
into `meta`; err.code is the domain code for the codes above.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- listMyEvents returns undefined on an empty body instead of throwing
- tests: double envelope, empty events page, two conflicting codes,
BastionHttpException forwarding a message-only domain code
- CHANGELOG names the three { data }-only routes and the code change
visible through BastionHttpException
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
@heyatom/bastion-client1.0.0: a client that works against both today's Bastion (1.11.x, bare bodies, domain codes in the errorcode) and Bastion 2.0 ({ data }/{ data, meta }envelope). It is meant to be published and rolled out to every consumer before Bastion changes format, so the Bastion cutover can be rolled back to 1.11 without breaking anyone.BastionHttp.callunwraps a success body whose only key isdata(unwrapData). Pages, arrays, other objects and empty bodies pass through. Single exit point, so it coversBastionApiClient,BastionService.call,ServiceTokenProviderandBastionHttpException.listMyEventsreturns{ data, meta }(newBastionPageMeta) and normalises the pre-2.0{ data, total, page, limit }.BastionErrorCodegainsPROVIDER_TAKEN,ALREADY_LINKED,OAUTH_EMAIL_TAKEN,OAUTH_USER_INACTIVE,OAUTH_UNDER_MINIMUM_AGE,AGE_ALREADY_VERIFIED,AGE_GATE_NOT_CONFIGURED,CURRENT_PASSWORD_REQUIRED,TWO_FACTOR_CODE_REQUIRED.messagestill wins, then Bastion'scodewhen it is aBastionErrorCode, thenVALIDATION_FAILED, then message classification as fallback.Reviewer notes
ALREADY_LINKEDundercode: CONFLICT, which is also aBastionErrorCode. The message-first order is kept and tested.{ data }alone today (GET /auth/me/tenants,GET/PUT /admin/apps/:slug/…/permissions): throughcallthey now return the inner array. Callers readArray.isArray(res) ? res : res.data. The Bastion 2.0 step must return the bare array on these routes, or they get enveloped twice. No consumer on its default branch calls the two admin routes throughcall, so bumping doesn't break any.listMyEventstype,err.codefor the nine codes, also forwarded byBastionHttpException) are listed in the CHANGELOG.^0.9.0consumers don't pick this up until bumped.73e30b1.Checks
pnpm lint✅,pnpm test56/56 ✅,pnpm build && pnpm test:di✅Publishing is a separate step: tag
v1.0.0after merge triggerspublish.yml.🤖 Generated with Claude Code