@ontrails/hono 1.0.0-beta.15 → 1.0.0-beta.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,77 +0,0 @@
1
- import { describe, expect, test } from 'bun:test';
2
-
3
- import { Result, trail, topo } from '@ontrails/core';
4
- import { z } from 'zod';
5
-
6
- import { createApp, surface } from '../surface.js';
7
-
8
- const echoTrail = trail('echo', {
9
- blaze: (input) => Result.ok({ reply: input.message }),
10
- input: z.object({ message: z.string() }),
11
- intent: 'read',
12
- output: z.object({ reply: z.string() }),
13
- });
14
-
15
- const tagsTrail = trail('tags', {
16
- blaze: (input) => Result.ok({ tags: input.tags }),
17
- input: z.object({ tags: z.array(z.string()) }),
18
- intent: 'read',
19
- output: z.object({ tags: z.array(z.string()) }),
20
- });
21
-
22
- describe('surface API (Hono connector)', () => {
23
- test('createApp materializes the Hono surface without serving', async () => {
24
- const graph = topo('surface-api', { echoTrail });
25
- const app = createApp(graph);
26
-
27
- const response = await app.request('/echo?message=hello', {
28
- method: 'GET',
29
- });
30
-
31
- expect(response.status).toBe(200);
32
- expect(await response.json()).toEqual({ data: { reply: 'hello' } });
33
- });
34
-
35
- test('surface starts a Bun server and returns a close handle', async () => {
36
- const graph = topo('surface-api', { echoTrail });
37
- const handle = await surface(graph, { port: 0 });
38
-
39
- try {
40
- const response = await fetch(new URL('/echo?message=hello', handle.url));
41
- expect(response.status).toBe(200);
42
- expect(await response.json()).toEqual({ data: { reply: 'hello' } });
43
- } finally {
44
- await handle.close();
45
- }
46
- });
47
-
48
- test('repeated query keys arrive as arrays for GET routes', async () => {
49
- const graph = topo('surface-api', { tagsTrail });
50
- const app = createApp(graph);
51
-
52
- const response = await app.request('/tags?tags=red&tags=blue', {
53
- method: 'GET',
54
- });
55
-
56
- expect(response.status).toBe(200);
57
- expect(await response.json()).toEqual({
58
- data: { tags: ['red', 'blue'] },
59
- });
60
- });
61
-
62
- test('single query values stay scalar even when the schema expects an array', async () => {
63
- const graph = topo('surface-api', { tagsTrail });
64
- const app = createApp(graph);
65
-
66
- const response = await app.request('/tags?tags=solo', {
67
- method: 'GET',
68
- });
69
-
70
- expect(response.status).toBe(400);
71
- expect(await response.json()).toMatchObject({
72
- error: {
73
- category: 'validation',
74
- },
75
- });
76
- });
77
- });
package/tsconfig.json DELETED
@@ -1,9 +0,0 @@
1
- {
2
- "extends": "../../tsconfig.json",
3
- "compilerOptions": {
4
- "outDir": "dist",
5
- "rootDir": "src"
6
- },
7
- "include": ["src"],
8
- "exclude": ["**/__tests__/**", "**/*.test.ts", "dist"]
9
- }
@@ -1,10 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "noEmit": true,
5
- "rootDir": "./src",
6
- "types": ["bun"]
7
- },
8
- "include": ["src/**/*.test.ts", "src/__tests__/**/*.ts"],
9
- "exclude": []
10
- }
@@ -1 +0,0 @@
1
- {"root":["./src/index.ts","./src/surface.ts"],"version":"5.9.3"}