Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

test(external-rest): r7-l12 assert NDJSON resync contract

Josué077cd96f5d8e
diff --git a/external-rest-api/package-lock.json b/external-rest-api/package-lock.json
index c7b44265d..b43708bc3 100644
--- a/external-rest-api/package-lock.json
+++ b/external-rest-api/package-lock.json
@@ -1,12 +1,12 @@
{
"name": "clerum-external-rest-api",
- "version": "0.1.89",
+ "version": "0.1.90",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "clerum-external-rest-api",
- "version": "0.1.89",
+ "version": "0.1.90",
"dependencies": {
"cors": "^2.8.5",
"express": "^4.21.2",
diff --git a/external-rest-api/package.json b/external-rest-api/package.json
index df9e20b56..19a45ca29 100644
--- a/external-rest-api/package.json
+++ b/external-rest-api/package.json
@@ -1,6 +1,6 @@
{
"name": "clerum-external-rest-api",
- "version": "0.1.89",
+ "version": "0.1.90",
"description": "External REST API for profile, team management, and RPC token brokerage",
"main": "dist/main.js",
"engines": {
diff --git a/external-rest-api/src/releaseManifest.ts b/external-rest-api/src/releaseManifest.ts
index 64596d83a..133770789 100644
--- a/external-rest-api/src/releaseManifest.ts
+++ b/external-rest-api/src/releaseManifest.ts
@@ -8,7 +8,7 @@ export type ReleaseManifest = {
export const releaseManifest: ReleaseManifest = {
releaseId: 'v0.10.0',
- externalRestApiVersion: '0.1.89',
+ externalRestApiVersion: '0.1.90',
rpcProxyVersion: '0.1.94',
desktopVersion: '0.10.0',
minimumDesktopVersion: '0.1.252',
diff --git a/external-rest-api/test/routes.entityChanges.test.ts b/external-rest-api/test/routes.entityChanges.test.ts
index da85d8797..7e87ee339 100644
--- a/external-rest-api/test/routes.entityChanges.test.ts
+++ b/external-rest-api/test/routes.entityChanges.test.ts
@@ -89,29 +89,29 @@ describe('routes/entityChanges', () => {
)
})
- it('propagates authorization and cursor errors from control-api', async () => {
+ it('passes an expired-cursor resync instruction as an NDJSON frame', async () => {
authTokenMock.verifyToken.mockReturnValueOnce(claims)
- const error = new controlApiClientMock.ControlApiError(
- 'expired cursor',
- 410,
- { error: 'resync_required' },
- { 'retry-after': '1' }
- )
- controlApiClientMock.controlApiStreamRequest.mockRejectedValueOnce(error)
- const app = makeApp()
- app.use(
- (err: unknown, _req: express.Request, res: express.Response, _next: express.NextFunction) => {
- const status = (err as { status?: number }).status ?? 500
- res.status(status).json({ error: 'unexpected' })
- }
- )
+ const frame = JSON.stringify({
+ schemaVersion: 1,
+ type: 'resync_required',
+ cursor: 'd119f895-1ef8-4e73-8f08-f9754919682a',
+ scopes: ['gfs', 'authorization'],
+ })
+ controlApiClientMock.controlApiStreamRequest.mockResolvedValueOnce({
+ status: 200,
+ headers: new Headers({ 'content-type': 'application/x-ndjson; charset=utf-8' }),
+ body: makeNdjsonStream(frame),
+ })
- const response = await request(app)
+ const response = await request(makeApp())
.get('/entity-changes/stream?cursor=d119f895-1ef8-4e73-8f08-f9754919682a')
.set('authorization', 'Bearer session-token')
- .expect(410)
- expect(response.body).toEqual({ error: 'resync_required' })
- expect(response.headers['retry-after']).toBe('1')
+ .expect(200)
+ expect(response.text.trim()).toBe(frame)
+ expect(JSON.parse(response.text.trim())).toMatchObject({
+ type: 'resync_required',
+ scopes: ['gfs', 'authorization'],
+ })
})
it('preserves upstream server error status without exposing internal response details', async () => {