@semiont/backend 0.4.9 → 0.4.12
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/dist/index.js +21 -73
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -10005,49 +10005,48 @@ rootRouter.get("/", (c) => {
|
|
|
10005
10005
|
<title>Semiont</title>
|
|
10006
10006
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
10007
10007
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10008
|
-
<link href="https://fonts.googleapis.com/css2?family=
|
|
10008
|
+
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500&family=Orbitron:wght@700&display=swap" rel="stylesheet">
|
|
10009
10009
|
<style>
|
|
10010
10010
|
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
10011
10011
|
body {
|
|
10012
|
-
background: #
|
|
10013
|
-
color: #
|
|
10014
|
-
font-family: '
|
|
10012
|
+
background: #ffffff;
|
|
10013
|
+
color: #111827;
|
|
10014
|
+
font-family: 'Inter', -apple-system, sans-serif;
|
|
10015
10015
|
min-height: 100vh;
|
|
10016
10016
|
display: flex;
|
|
10017
10017
|
flex-direction: column;
|
|
10018
10018
|
align-items: center;
|
|
10019
10019
|
justify-content: center;
|
|
10020
|
-
gap:
|
|
10020
|
+
gap: 0.75rem;
|
|
10021
10021
|
}
|
|
10022
10022
|
h1 {
|
|
10023
|
-
font-
|
|
10023
|
+
font-family: 'Orbitron', sans-serif;
|
|
10024
|
+
font-size: 3rem;
|
|
10024
10025
|
font-weight: 700;
|
|
10025
|
-
letter-spacing: 0.
|
|
10026
|
-
color: #
|
|
10027
|
-
text-transform: uppercase;
|
|
10026
|
+
letter-spacing: 0.15em;
|
|
10027
|
+
color: #0066cc;
|
|
10028
10028
|
}
|
|
10029
10029
|
h2 {
|
|
10030
|
-
font-
|
|
10031
|
-
font-
|
|
10032
|
-
|
|
10033
|
-
|
|
10030
|
+
font-family: 'Inter', sans-serif;
|
|
10031
|
+
font-size: 0.9rem;
|
|
10032
|
+
font-weight: 500;
|
|
10033
|
+
letter-spacing: 0.3em;
|
|
10034
|
+
color: #6b7280;
|
|
10034
10035
|
text-transform: uppercase;
|
|
10035
10036
|
}
|
|
10036
10037
|
.meta {
|
|
10037
|
-
margin-top:
|
|
10038
|
-
font-size: 0.
|
|
10039
|
-
|
|
10040
|
-
color: #555;
|
|
10038
|
+
margin-top: 1.5rem;
|
|
10039
|
+
font-size: 0.8rem;
|
|
10040
|
+
color: #9ca3af;
|
|
10041
10041
|
display: flex;
|
|
10042
10042
|
flex-direction: column;
|
|
10043
10043
|
align-items: center;
|
|
10044
|
-
gap: 0.
|
|
10044
|
+
gap: 0.25rem;
|
|
10045
10045
|
}
|
|
10046
10046
|
a {
|
|
10047
|
-
color: #
|
|
10047
|
+
color: #0066cc;
|
|
10048
10048
|
text-decoration: none;
|
|
10049
|
-
|
|
10050
|
-
font-size: 0.75rem;
|
|
10049
|
+
font-size: 0.8rem;
|
|
10051
10050
|
}
|
|
10052
10051
|
a:hover { text-decoration: underline; }
|
|
10053
10052
|
</style>
|
|
@@ -10057,7 +10056,7 @@ rootRouter.get("/", (c) => {
|
|
|
10057
10056
|
<h2>knowledge base</h2>
|
|
10058
10057
|
<div class="meta">
|
|
10059
10058
|
${siteName ? `<span>${siteName}</span>` : ""}
|
|
10060
|
-
${projectName ? `<span
|
|
10059
|
+
${projectName ? `<span>${projectName}${projectVersion ? " v" + projectVersion : ""}</span>` : ""}
|
|
10061
10060
|
<a href="/api/health">/api/health</a>
|
|
10062
10061
|
</div>
|
|
10063
10062
|
</body>
|
|
@@ -14964,44 +14963,6 @@ function registerCreateResource(router) {
|
|
|
14964
14963
|
return c.json({ resourceId: resourceId21 }, 202);
|
|
14965
14964
|
});
|
|
14966
14965
|
}
|
|
14967
|
-
|
|
14968
|
-
// src/middleware/content-negotiation.ts
|
|
14969
|
-
function prefersHtml(c) {
|
|
14970
|
-
const acceptHeader = c.req.header("Accept") || "";
|
|
14971
|
-
const userAgent = c.req.header("User-Agent") || "";
|
|
14972
|
-
const acceptsHtml = acceptHeader.includes("text/html");
|
|
14973
|
-
const acceptsJson = acceptHeader.includes("application/json") || acceptHeader.includes("application/ld+json");
|
|
14974
|
-
if (acceptsJson && !acceptsHtml) {
|
|
14975
|
-
return false;
|
|
14976
|
-
}
|
|
14977
|
-
if (acceptsHtml && acceptsJson) {
|
|
14978
|
-
const htmlIndex = acceptHeader.indexOf("text/html");
|
|
14979
|
-
const jsonIndex = Math.min(
|
|
14980
|
-
acceptHeader.indexOf("application/json") >= 0 ? acceptHeader.indexOf("application/json") : Infinity,
|
|
14981
|
-
acceptHeader.indexOf("application/ld+json") >= 0 ? acceptHeader.indexOf("application/ld+json") : Infinity
|
|
14982
|
-
);
|
|
14983
|
-
if (htmlIndex < jsonIndex) {
|
|
14984
|
-
return true;
|
|
14985
|
-
} else {
|
|
14986
|
-
return false;
|
|
14987
|
-
}
|
|
14988
|
-
}
|
|
14989
|
-
const isBrowser = /Mozilla|Chrome|Safari|Edge|Firefox|Opera/.test(userAgent);
|
|
14990
|
-
if (isBrowser && !acceptHeader && !userAgent.includes("curl")) {
|
|
14991
|
-
return true;
|
|
14992
|
-
}
|
|
14993
|
-
if (isBrowser && acceptsHtml && !userAgent.includes("curl")) {
|
|
14994
|
-
return true;
|
|
14995
|
-
}
|
|
14996
|
-
return acceptsHtml && !acceptsJson;
|
|
14997
|
-
}
|
|
14998
|
-
function getFrontendUrl() {
|
|
14999
|
-
const frontendUrl = process.env.FRONTEND_URL;
|
|
15000
|
-
if (!frontendUrl) {
|
|
15001
|
-
throw new Error("FRONTEND_URL environment variable is required for content negotiation");
|
|
15002
|
-
}
|
|
15003
|
-
return frontendUrl;
|
|
15004
|
-
}
|
|
15005
14966
|
var SSE_STREAM_CONNECTED = "stream-connected";
|
|
15006
14967
|
function getBodySource(body) {
|
|
15007
14968
|
if (Array.isArray(body)) {
|
|
@@ -15161,13 +15122,6 @@ function registerGetResourceUri(router) {
|
|
|
15161
15122
|
});
|
|
15162
15123
|
router.get("/resources/:id", async (c) => {
|
|
15163
15124
|
const { id } = c.req.param();
|
|
15164
|
-
const view = c.req.query("view");
|
|
15165
|
-
if (view === "semiont") {
|
|
15166
|
-
const frontendUrl = getFrontendUrl();
|
|
15167
|
-
const normalizedBase = frontendUrl.endsWith("/") ? frontendUrl.slice(0, -1) : frontendUrl;
|
|
15168
|
-
const redirectUrl = `${normalizedBase}/know/resource/${id}`;
|
|
15169
|
-
return c.redirect(redirectUrl, 302);
|
|
15170
|
-
}
|
|
15171
15125
|
const acceptHeader = c.req.header("Accept") || "application/ld+json";
|
|
15172
15126
|
if (acceptHeader.includes("text/") || acceptHeader.includes("image/") || acceptHeader.includes("application/pdf")) {
|
|
15173
15127
|
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
@@ -17393,12 +17347,6 @@ function registerGetAnnotationUri(router) {
|
|
|
17393
17347
|
if (!resourceIdParam) {
|
|
17394
17348
|
throw new HTTPException(400, { message: "resourceId query parameter is required" });
|
|
17395
17349
|
}
|
|
17396
|
-
if (prefersHtml(c)) {
|
|
17397
|
-
const frontendUrl = getFrontendUrl();
|
|
17398
|
-
const normalizedBase = frontendUrl.endsWith("/") ? frontendUrl.slice(0, -1) : frontendUrl;
|
|
17399
|
-
const redirectUrl = `${normalizedBase}/annotations/${id}?resourceId=${resourceIdParam}`;
|
|
17400
|
-
return c.redirect(redirectUrl, 302);
|
|
17401
|
-
}
|
|
17402
17350
|
const projection = await AnnotationContext.getResourceAnnotations(resourceId(resourceIdParam), kb);
|
|
17403
17351
|
const annotation = projection.annotations.find((a) => a.id === id);
|
|
17404
17352
|
if (!annotation) {
|