Changelog - 2026-10-23
The HTTP connector
Feature Enhancement Bug Fix Bug Fix Behavior ChangeIn one line. @venizia/ignis-connectors/http now reads and writes through the CRUD and search routes of another IGNIS server, follows the session in a browser app, and throws the error the server threw.
typescript
const products = new HttpRepository<TProduct>({ dataSource, resource: 'products' });
const { data: product } = await products.create({ data: { name: 'Lamp' } });
await products.updateById({ id: product.id, data: { name: 'Desk lamp' } });
await products.updateBy({ where: { status: 'draft' }, data: { status: 'published' } });
await products.deleteAll({ where: { id: { inq: staleIds } } });
// A route the verbs do not cover:
await dataSource.write({ paths: ['products', product.id], method: 'PUT', body: replacement });What changed
- Writes.
HttpRepositoryis no longer read-only.create({ data })isPOST /<resource>;updateById({ id, data })isPATCH /<resource>/:id;updateAll/updateBy({ where, data })isPATCH /<resource>withwherein the body;deleteById({ id })isDELETE /<resource>/:id;deleteAll/deleteBy({ where })isDELETE /<resource>withwherein the body. HttpDataSource.request()takesbodyand per-requestheaderson any method. A plain object or array goes out as JSON; a string,FormData,Blob,URLSearchParams,ArrayBufferor typed array goes as it is. The 401 retry resends the same body.HttpDataSource.write()answers{ data, count }.- The session.
settings.headersis read once, when the datasource is built.headersResolverruns on every send, the 401 retry included.authTokenResolverandonUnauthorizedreceive the request they serve ({ paths, method, url, signal }), so a public route can send no token and skip the refresh. A throw from a resolver fails that request. - One call. Every repository verb,
read(),write()andrequest()takeheadersandsignalin their options. A call aborted whileonUnauthorizedruns is not retried. - Errors are the server's. A failed read or write throws an
ApplicationErrorwithstatusCode(the response status),normalized.code,normalized.argsandnormalized.text(a response with no text reads asHTTP 502),extra(the server's, withrequestIdadded; the ids of relayed upstream requests are kept inupstreamRequestIds),cause(the server'sdetails.cause, such as a 422's per-field issues), and amessageof the server's text prefixed with the verb, status and path. The host and query are left out of the message. Before, the connector droppednormalized.args, so a UI that translates by code showed placeholders unfilled. errorRootKey. A server witherror.rootKeywraps its envelope. SeterrorRootKeyto the same key, or every error reads ascore.system_error.- Requests that named the wrong route are refused. An empty,
.or..id throws 400 before any request (deleteById({ id: '.' })used to sendDELETE /users/, the bulk route). AbaseUrlis absolute or starts with/; anything else throws at construction (this also covers'api'and'localhost:3000'). AFormDatabody always carries the multipart content-typefetchwrites. An empty list body, a non-JSON answer or a bigint in a query throws anApplicationError(500, 502, 400) instead of a bareSyntaxErrororTypeError. HttpResponseReaderis exported from@venizia/ignis-kernel/repository, besidebuildDataRange, so a client that reads an IGNIS server without the connector does not copy the parsing.@venizia/ignis-connectors/httpstill exports the same class. ItsparseContentRange,readErrorEnvelope,readError,isPlainObjectandtoTextare public, andtoApplicationError({ response, context, rootKey? })turns a failed response into the sameApplicationErrorthe connector throws. A missingContent-Rangenow names the likely cross-origin cause: the server must list it inAccess-Control-Expose-Headers.- Reads.
find,findOne,findById,countandexistsWithtakequery: { merchantId: 'm1', q: 'abc' }and send it next to the filter; the filter andwherewin over a key of the same name. A subclass can override the protectedbuildQuery({ method, query, params })to reshape one verb. defaultLimit.new HttpRepository({ dataSource, resource, defaultLimit: 50 })makesfindask for 50 rows when its filter names nolimit. A filter's own limit wins.findOne,countandexistsWithkeep their limit of 1. A value that is not a positive integer throws at construction.search({ input, query?, options? })POSTsinputto<resource>/searchand returns{ found, isFoundExact, hits }.foundis the total;isFoundExactisfalsewhen the engine estimates it. A body that is not that envelope throws instead of reading as no match.searchPathrenames the segment after the resource; a subclass overridesgetSearchPaths()to move the whole route.findOnePath. Opt in withfindOnePath: 'find-one'andfindOnereadsGET /<resource>/find-one, the routedefineCrudControllergenerates. A missing row answers HTTP 200 andfindOnereturnsnull. Off by default,findOneasks the list route for one row, as before; a backend that is not an IGNIS controller may not have the route.
typescript
super({ dataSource, resource: 'products', findOnePath: 'find-one' });
const product = await productRepository.findOne({ filter: { where: { sku: 'LAMP-1' } } });
// GET /products/find-one?filter=... -> the row, or nulltypescript
new HttpDataSource({
baseUrl: '/api',
errorRootKey: 'error',
headersResolver: () => ({ 'x-locale': session.locale }),
authTokenResolver: ({ paths }) => (paths[0] === 'auth' ? undefined : session.token),
onUnauthorized: ({ paths }) => (paths[0] === 'auth' ? false : session.refresh()),
});
await products.find({ filter, options: { headers: { 'x-trace': id }, signal } });Who is affected
- Code that wrote with bare
fetchbeside the connector. Move to the repository verbs orwrite(); the auth token, the 401 retry and the error mapping come with them. - An app with run-time session headers or public routes. Move them into
headersResolverandauthTokenResolver. - A server with
error.rootKey. SeterrorRootKey. - An app with a path-relative
baseUrl. Changeapito/api. - Code that read
error.extra, or parsed the URL out oferror.message.extranow holds the server'sextrabesiderequestId, and the message names the path only. Code that matched a read error message exactly sees the server's message after the path. - Code that wrote
whereinto afindByIdfilter literal. It no longer type-checks: the server always replaced it with the id. - A subclass that overrides
resolveAuthToken(). It now receives{ context }. - A subclass that overrides
request()to wrap every call.read()andwrite()no longer go through it; overridesendRequest(), which every call reaches. - A client that copied the Content-Range or error-envelope parsing. Import
HttpResponseReaderfrom@venizia/ignis-kernel/repository. - Everyone else. No action needed; every new argument and setting is optional, and the read verbs are otherwise unchanged.
Details
- The id in
/:idis URL-encoded, for reads and writes alike. - A bulk
wheretravels in the body, so a longinqdoes not hit the URL limit. An empty bulkwhereis refused before any request, andforcecannot cross HTTP. shouldReturn: falseanswers{ count, data: null }.- There is no
createAll: the IGNIS REST contract has no bulk-create route. - A per-request
x-request-countis refused; the connector owns it. HttpRepository<E, P = Partial<E>>: the second type parameter is what a write sends; the server fills ids and defaults.- IGNIS generates
POST <resource>/searchandPOST <resource>/multi-search, and nosearch/countroute; the total of a search isfound. A route of any other shape stays a call todataSource.read.