@struktur/http 2.6.0 → 2.6.1
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.
- package/package.json +2 -2
- package/src/index.test.ts +2 -1
- package/src/routes/info.ts +2 -1
- package/src/utils/serialize.ts +18 -20
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@struktur/http",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.1",
|
|
4
4
|
"license": "FSL-1.1-MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"hono": "^4.6.0",
|
|
17
17
|
"hono-openapi": "^1.3.0",
|
|
18
18
|
"zod": "^4.3.6",
|
|
19
|
-
"@struktur/sdk": "2.6.
|
|
19
|
+
"@struktur/sdk": "2.6.1"
|
|
20
20
|
},
|
|
21
21
|
"devDependencies": {
|
|
22
22
|
"@types/bun": "latest",
|
package/src/index.test.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { test, expect, describe, beforeAll, afterAll } from "bun:test";
|
|
2
2
|
import { spawn, type Subprocess } from "bun";
|
|
3
|
+
import packageJson from "../package.json" with { type: "json" };
|
|
3
4
|
|
|
4
5
|
async function startServer(port: string, apiKey = ""): Promise<Subprocess> {
|
|
5
6
|
const server = spawn({
|
|
@@ -64,7 +65,7 @@ describe("HTTP API - OpenAPI Documentation", () => {
|
|
|
64
65
|
const data = await response.json();
|
|
65
66
|
|
|
66
67
|
expect(data.info.title).toBe("Struktur HTTP API");
|
|
67
|
-
expect(data.info.version).toBe(
|
|
68
|
+
expect(data.info.version).toBe(packageJson.version);
|
|
68
69
|
expect(data.info.description).toContain("Struktur");
|
|
69
70
|
});
|
|
70
71
|
|
package/src/routes/info.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Hono } from "hono";
|
|
2
2
|
import { describeRoute, resolver } from "hono-openapi";
|
|
3
|
+
import packageJson from "../../package.json" with { type: "json" };
|
|
3
4
|
import { APIInfoSchema } from "../schemas";
|
|
4
5
|
|
|
5
6
|
const app = new Hono();
|
|
@@ -26,7 +27,7 @@ app.get(
|
|
|
26
27
|
return c.json(
|
|
27
28
|
{
|
|
28
29
|
name: "struktur-http",
|
|
29
|
-
version:
|
|
30
|
+
version: packageJson.version,
|
|
30
31
|
endpoints: {
|
|
31
32
|
"POST /parse": "Parse uploaded files into artifact JSON",
|
|
32
33
|
"POST /extract": "Extract structured data from documents or artifact JSON",
|
package/src/utils/serialize.ts
CHANGED
|
@@ -4,26 +4,24 @@ export function serializeArtifacts(artifacts: Artifact[]): SerializedArtifact[]
|
|
|
4
4
|
return artifacts.map((a) => ({
|
|
5
5
|
id: a.id,
|
|
6
6
|
type: a.type,
|
|
7
|
-
contents: a.contents.map(
|
|
8
|
-
(c
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}),
|
|
26
|
-
),
|
|
7
|
+
contents: a.contents.map((c): SerializedArtifactContent => ({
|
|
8
|
+
...(c.page !== undefined ? { page: c.page } : {}),
|
|
9
|
+
...(c.text !== undefined ? { text: c.text } : {}),
|
|
10
|
+
...(c.media
|
|
11
|
+
? {
|
|
12
|
+
media: c.media.map((m) => ({
|
|
13
|
+
type: "image" as const,
|
|
14
|
+
...(m.url ? { url: m.url } : {}),
|
|
15
|
+
...(m.base64 ? { base64: m.base64 } : {}),
|
|
16
|
+
...(m.contents ? { base64: m.contents.toString("base64") } : {}),
|
|
17
|
+
...(m.text ? { text: m.text } : {}),
|
|
18
|
+
...(m.width !== undefined ? { width: m.width } : {}),
|
|
19
|
+
...(m.height !== undefined ? { height: m.height } : {}),
|
|
20
|
+
...(m.imageType ? { imageType: m.imageType } : {}),
|
|
21
|
+
})),
|
|
22
|
+
}
|
|
23
|
+
: {}),
|
|
24
|
+
})),
|
|
27
25
|
...(a.metadata ? { metadata: a.metadata } : {}),
|
|
28
26
|
}));
|
|
29
27
|
}
|