Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
remains lazy (cold-start only) via `ensureApp()` / `ensureKernel()` in `_kernel.ts`.

### Fixed
- **SvelteKit adapter test failures** — Updated test mock to include `dispatch()` method and
aligned Metadata, Data, Error handling, and toResponse test assertions with the unified
catch-all dispatch pattern used by the implementation and all other adapters (e.g. Hono).
Removed obsolete `handleMetadata`/`handleData` references from the mock.
- **Vercel serverless 404 fix** — The previous `api/[...path].ts` path-normalisation fix is now
superseded by the Hono adapter migration above. The new `api/index.ts` entrypoint combined with
Vercel rewrites (`/api/*` → `/api`) eliminates the routing ambiguity that caused 404s.
Expand Down
3 changes: 1 addition & 2 deletions packages/adapters/express/src/express.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ const mockDispatcher = {
getDiscoveryInfo: vi.fn().mockReturnValue({ version: '1.0', endpoints: [] }),
handleAuth: vi.fn().mockResolvedValue({ handled: true, response: { body: { ok: true }, status: 200 } }),
handleGraphQL: vi.fn().mockResolvedValue({ data: {} }),
handleMetadata: vi.fn().mockResolvedValue({ handled: true, response: { body: { objects: [] }, status: 200 } }),
handleData: vi.fn().mockResolvedValue({ handled: true, response: { body: { records: [] }, status: 200 } }),
handleStorage: vi.fn().mockResolvedValue({ handled: true, response: { body: {}, status: 200 } }),
dispatch: vi.fn().mockResolvedValue({ handled: true, response: { body: { success: true }, status: 200 } }),
};

vi.mock('@objectstack/runtime', () => {
Expand Down
22 changes: 9 additions & 13 deletions packages/adapters/fastify/src/fastify.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@ const mockDispatcher = {
getDiscoveryInfo: vi.fn().mockReturnValue({ version: '1.0', endpoints: [] }),
handleAuth: vi.fn().mockResolvedValue({ handled: true, response: { body: { ok: true }, status: 200 } }),
handleGraphQL: vi.fn().mockResolvedValue({ data: {} }),
handleMetadata: vi.fn().mockResolvedValue({ handled: true, response: { body: { objects: [] }, status: 200 } }),
handleData: vi.fn().mockResolvedValue({ handled: true, response: { body: { records: [] }, status: 200 } }),
handleStorage: vi.fn().mockResolvedValue({ handled: true, response: { body: {}, status: 200 } }),
dispatch: vi.fn().mockResolvedValue({ handled: true, response: { body: { success: true }, status: 200 } }),
};

vi.mock('@objectstack/runtime', () => {
Expand Down Expand Up @@ -91,13 +90,12 @@ describe('objectStackPlugin', () => {

const res = await app.inject({ method: 'GET', url: '/api/meta/objects' });
expect(res.statusCode).toBe(200);
const json = JSON.parse(res.payload);
expect(json.objects).toBeDefined();
expect(mockDispatcher.handleMetadata).toHaveBeenCalledWith(
'/objects',
expect.objectContaining({ request: expect.anything() }),
expect(mockDispatcher.dispatch).toHaveBeenCalledWith(
'GET',
'/meta/objects',
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
);
});

Expand All @@ -108,12 +106,10 @@ describe('objectStackPlugin', () => {

const res = await app.inject({ method: 'GET', url: '/api/data/account' });
expect(res.statusCode).toBe(200);
const json = JSON.parse(res.payload);
expect(json.records).toBeDefined();
expect(mockDispatcher.handleData).toHaveBeenCalledWith(
'/account',
expect(mockDispatcher.dispatch).toHaveBeenCalledWith(
'GET',
{},
'/data/account',
undefined,
expect.any(Object),
expect.objectContaining({ request: expect.anything() }),
);
Expand Down Expand Up @@ -148,7 +144,7 @@ describe('objectStackPlugin', () => {
});

it('returns error on exception', async () => {
mockDispatcher.handleData.mockRejectedValueOnce(
mockDispatcher.dispatch.mockRejectedValueOnce(
Object.assign(new Error('Forbidden'), { statusCode: 403 }),
);
const app = Fastify();
Expand Down
1 change: 1 addition & 0 deletions packages/adapters/nestjs/src/__mocks__/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export class HttpDispatcher {
handleMetadata = vi.fn().mockResolvedValue({ handled: true, response: { status: 200, body: [] } });
handleData = vi.fn().mockResolvedValue({ handled: true, response: { status: 200, body: [] } });
handleStorage = vi.fn().mockResolvedValue({ handled: true, response: { status: 200, body: {} } });
dispatch = vi.fn().mockResolvedValue({ handled: true, response: { status: 200, body: { success: true } } });

constructor(_kernel: any) {}
}
Expand Down
Loading
Loading