@semiont/backend 0.4.3 → 0.4.5
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 +426 -233
- package/dist/index.js.map +1 -1
- package/dist/openapi.json +6226 -0
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import winston from 'winston';
|
|
3
3
|
import { z } from 'zod';
|
|
4
4
|
import jwt from 'jsonwebtoken';
|
|
5
|
-
import { email, userId, accessToken, googleCredential, annotationId, resourceId, EventBus, jobId, entityType, assembleAnnotation, userToAgent } from '@semiont/core';
|
|
5
|
+
import { email, userId, accessToken, googleCredential, annotationId, resourceId, userToDid, EventBus, jobId, entityType, assembleAnnotation, userToAgent } from '@semiont/core';
|
|
6
6
|
import { cors } from 'hono/cors';
|
|
7
7
|
import { serve } from '@hono/node-server';
|
|
8
8
|
import { Hono } from 'hono';
|
|
@@ -11,6 +11,7 @@ import { SemiontProject, loadEnvironmentConfig } from '@semiont/core/node';
|
|
|
11
11
|
import { exportBackup, importBackup, readEntityTypesProjection, exportLinkedData, importLinkedData, AnnotationContext, startMakeMeaning, ResourceContext, ResourceOperations } from '@semiont/make-meaning';
|
|
12
12
|
import { PrismaClient } from '@prisma/client';
|
|
13
13
|
import { PrismaPg } from '@prisma/adapter-pg';
|
|
14
|
+
import { setCookie, deleteCookie, getCookie } from 'hono/cookie';
|
|
14
15
|
import { HTTPException } from 'hono/http-exception';
|
|
15
16
|
import Ajv from 'ajv';
|
|
16
17
|
import addFormats from 'ajv-formats';
|
|
@@ -613,7 +614,7 @@ var require_timeoutProvider = __commonJS({
|
|
|
613
614
|
});
|
|
614
615
|
exports$1.timeoutProvider = void 0;
|
|
615
616
|
exports$1.timeoutProvider = {
|
|
616
|
-
setTimeout: /* @__PURE__ */ __name(function(handler,
|
|
617
|
+
setTimeout: /* @__PURE__ */ __name(function(handler, timeout2) {
|
|
617
618
|
var args = [];
|
|
618
619
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
619
620
|
args[_i - 2] = arguments[_i];
|
|
@@ -622,12 +623,12 @@ var require_timeoutProvider = __commonJS({
|
|
|
622
623
|
if (delegate === null || delegate === void 0 ? void 0 : delegate.setTimeout) {
|
|
623
624
|
return delegate.setTimeout.apply(delegate, __spreadArray([
|
|
624
625
|
handler,
|
|
625
|
-
|
|
626
|
+
timeout2
|
|
626
627
|
], __read(args)));
|
|
627
628
|
}
|
|
628
629
|
return setTimeout.apply(void 0, __spreadArray([
|
|
629
630
|
handler,
|
|
630
|
-
|
|
631
|
+
timeout2
|
|
631
632
|
], __read(args)));
|
|
632
633
|
}, "setTimeout"),
|
|
633
634
|
clearTimeout: /* @__PURE__ */ __name(function(handle) {
|
|
@@ -2061,7 +2062,7 @@ var require_intervalProvider = __commonJS({
|
|
|
2061
2062
|
});
|
|
2062
2063
|
exports$1.intervalProvider = void 0;
|
|
2063
2064
|
exports$1.intervalProvider = {
|
|
2064
|
-
setInterval: /* @__PURE__ */ __name(function(handler,
|
|
2065
|
+
setInterval: /* @__PURE__ */ __name(function(handler, timeout2) {
|
|
2065
2066
|
var args = [];
|
|
2066
2067
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
2067
2068
|
args[_i - 2] = arguments[_i];
|
|
@@ -2070,12 +2071,12 @@ var require_intervalProvider = __commonJS({
|
|
|
2070
2071
|
if (delegate === null || delegate === void 0 ? void 0 : delegate.setInterval) {
|
|
2071
2072
|
return delegate.setInterval.apply(delegate, __spreadArray([
|
|
2072
2073
|
handler,
|
|
2073
|
-
|
|
2074
|
+
timeout2
|
|
2074
2075
|
], __read(args)));
|
|
2075
2076
|
}
|
|
2076
2077
|
return setInterval.apply(void 0, __spreadArray([
|
|
2077
2078
|
handler,
|
|
2078
|
-
|
|
2079
|
+
timeout2
|
|
2079
2080
|
], __read(args)));
|
|
2080
2081
|
}, "setInterval"),
|
|
2081
2082
|
clearInterval: /* @__PURE__ */ __name(function(handle) {
|
|
@@ -4283,7 +4284,7 @@ var require_firstValueFrom = __commonJS({
|
|
|
4283
4284
|
exports$1.firstValueFrom = void 0;
|
|
4284
4285
|
var EmptyError_1 = require_EmptyError();
|
|
4285
4286
|
var Subscriber_1 = require_Subscriber();
|
|
4286
|
-
function
|
|
4287
|
+
function firstValueFrom2(source, config2) {
|
|
4287
4288
|
var hasConfig = typeof config2 === "object";
|
|
4288
4289
|
return new Promise(function(resolve, reject) {
|
|
4289
4290
|
var subscriber = new Subscriber_1.SafeSubscriber({
|
|
@@ -4303,8 +4304,8 @@ var require_firstValueFrom = __commonJS({
|
|
|
4303
4304
|
source.subscribe(subscriber);
|
|
4304
4305
|
});
|
|
4305
4306
|
}
|
|
4306
|
-
__name(
|
|
4307
|
-
exports$1.firstValueFrom =
|
|
4307
|
+
__name(firstValueFrom2, "firstValueFrom");
|
|
4308
|
+
exports$1.firstValueFrom = firstValueFrom2;
|
|
4308
4309
|
}
|
|
4309
4310
|
});
|
|
4310
4311
|
|
|
@@ -4402,7 +4403,7 @@ var require_timeout = __commonJS({
|
|
|
4402
4403
|
this.info = info;
|
|
4403
4404
|
}, "TimeoutErrorImpl");
|
|
4404
4405
|
});
|
|
4405
|
-
function
|
|
4406
|
+
function timeout2(config2, schedulerArg) {
|
|
4406
4407
|
var _a = isDate_1.isValidDate(config2) ? {
|
|
4407
4408
|
first: config2
|
|
4408
4409
|
} : typeof config2 === "number" ? {
|
|
@@ -4444,8 +4445,8 @@ var require_timeout = __commonJS({
|
|
|
4444
4445
|
!seen && startTimer(first != null ? typeof first === "number" ? first : +first - scheduler.now() : each);
|
|
4445
4446
|
});
|
|
4446
4447
|
}
|
|
4447
|
-
__name(
|
|
4448
|
-
exports$1.timeout =
|
|
4448
|
+
__name(timeout2, "timeout");
|
|
4449
|
+
exports$1.timeout = timeout2;
|
|
4449
4450
|
function timeoutErrorFactory(info) {
|
|
4450
4451
|
throw new exports$1.TimeoutError(info);
|
|
4451
4452
|
}
|
|
@@ -4462,7 +4463,7 @@ var require_map = __commonJS({
|
|
|
4462
4463
|
exports$1.map = void 0;
|
|
4463
4464
|
var lift_1 = require_lift();
|
|
4464
4465
|
var OperatorSubscriber_1 = require_OperatorSubscriber();
|
|
4465
|
-
function
|
|
4466
|
+
function map2(project, thisArg) {
|
|
4466
4467
|
return lift_1.operate(function(source, subscriber) {
|
|
4467
4468
|
var index = 0;
|
|
4468
4469
|
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
|
|
@@ -4470,8 +4471,8 @@ var require_map = __commonJS({
|
|
|
4470
4471
|
}));
|
|
4471
4472
|
});
|
|
4472
4473
|
}
|
|
4473
|
-
__name(
|
|
4474
|
-
exports$1.map =
|
|
4474
|
+
__name(map2, "map");
|
|
4475
|
+
exports$1.map = map2;
|
|
4475
4476
|
}
|
|
4476
4477
|
});
|
|
4477
4478
|
|
|
@@ -5501,7 +5502,7 @@ var require_merge = __commonJS({
|
|
|
5501
5502
|
var empty_1 = require_empty();
|
|
5502
5503
|
var args_1 = require_args();
|
|
5503
5504
|
var from_1 = require_from();
|
|
5504
|
-
function
|
|
5505
|
+
function merge2() {
|
|
5505
5506
|
var args = [];
|
|
5506
5507
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
5507
5508
|
args[_i] = arguments[_i];
|
|
@@ -5511,8 +5512,8 @@ var require_merge = __commonJS({
|
|
|
5511
5512
|
var sources = args;
|
|
5512
5513
|
return !sources.length ? empty_1.EMPTY : sources.length === 1 ? innerFrom_1.innerFrom(sources[0]) : mergeAll_1.mergeAll(concurrent)(from_1.from(sources, scheduler));
|
|
5513
5514
|
}
|
|
5514
|
-
__name(
|
|
5515
|
-
exports$1.merge =
|
|
5515
|
+
__name(merge2, "merge");
|
|
5516
|
+
exports$1.merge = merge2;
|
|
5516
5517
|
}
|
|
5517
5518
|
});
|
|
5518
5519
|
|
|
@@ -5636,7 +5637,7 @@ var require_filter = __commonJS({
|
|
|
5636
5637
|
exports$1.filter = void 0;
|
|
5637
5638
|
var lift_1 = require_lift();
|
|
5638
5639
|
var OperatorSubscriber_1 = require_OperatorSubscriber();
|
|
5639
|
-
function
|
|
5640
|
+
function filter2(predicate, thisArg) {
|
|
5640
5641
|
return lift_1.operate(function(source, subscriber) {
|
|
5641
5642
|
var index = 0;
|
|
5642
5643
|
source.subscribe(OperatorSubscriber_1.createOperatorSubscriber(subscriber, function(value) {
|
|
@@ -5644,8 +5645,8 @@ var require_filter = __commonJS({
|
|
|
5644
5645
|
}));
|
|
5645
5646
|
});
|
|
5646
5647
|
}
|
|
5647
|
-
__name(
|
|
5648
|
-
exports$1.filter =
|
|
5648
|
+
__name(filter2, "filter");
|
|
5649
|
+
exports$1.filter = filter2;
|
|
5649
5650
|
}
|
|
5650
5651
|
});
|
|
5651
5652
|
|
|
@@ -6901,7 +6902,7 @@ var require_take = __commonJS({
|
|
|
6901
6902
|
var empty_1 = require_empty();
|
|
6902
6903
|
var lift_1 = require_lift();
|
|
6903
6904
|
var OperatorSubscriber_1 = require_OperatorSubscriber();
|
|
6904
|
-
function
|
|
6905
|
+
function take2(count) {
|
|
6905
6906
|
return count <= 0 ? function() {
|
|
6906
6907
|
return empty_1.EMPTY;
|
|
6907
6908
|
} : lift_1.operate(function(source, subscriber) {
|
|
@@ -6916,8 +6917,8 @@ var require_take = __commonJS({
|
|
|
6916
6917
|
}));
|
|
6917
6918
|
});
|
|
6918
6919
|
}
|
|
6919
|
-
__name(
|
|
6920
|
-
exports$1.take =
|
|
6920
|
+
__name(take2, "take");
|
|
6921
|
+
exports$1.take = take2;
|
|
6921
6922
|
}
|
|
6922
6923
|
});
|
|
6923
6924
|
|
|
@@ -7807,7 +7808,7 @@ var require_merge2 = __commonJS({
|
|
|
7807
7808
|
var mergeAll_1 = require_mergeAll();
|
|
7808
7809
|
var args_1 = require_args();
|
|
7809
7810
|
var from_1 = require_from();
|
|
7810
|
-
function
|
|
7811
|
+
function merge2() {
|
|
7811
7812
|
var args = [];
|
|
7812
7813
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
7813
7814
|
args[_i] = arguments[_i];
|
|
@@ -7820,8 +7821,8 @@ var require_merge2 = __commonJS({
|
|
|
7820
7821
|
], __read(args)), scheduler)).subscribe(subscriber);
|
|
7821
7822
|
});
|
|
7822
7823
|
}
|
|
7823
|
-
__name(
|
|
7824
|
-
exports$1.merge =
|
|
7824
|
+
__name(merge2, "merge");
|
|
7825
|
+
exports$1.merge = merge2;
|
|
7825
7826
|
}
|
|
7826
7827
|
});
|
|
7827
7828
|
|
|
@@ -12760,6 +12761,127 @@ var openapi_default = {
|
|
|
12760
12761
|
"isNewUser"
|
|
12761
12762
|
]
|
|
12762
12763
|
},
|
|
12764
|
+
BrowseFilesResponse: {
|
|
12765
|
+
type: "object",
|
|
12766
|
+
required: [
|
|
12767
|
+
"path",
|
|
12768
|
+
"entries"
|
|
12769
|
+
],
|
|
12770
|
+
properties: {
|
|
12771
|
+
path: {
|
|
12772
|
+
type: "string",
|
|
12773
|
+
description: "The directory path that was listed, relative to project root"
|
|
12774
|
+
},
|
|
12775
|
+
entries: {
|
|
12776
|
+
type: "array",
|
|
12777
|
+
items: {
|
|
12778
|
+
$ref: "#/components/schemas/DirectoryEntry"
|
|
12779
|
+
}
|
|
12780
|
+
}
|
|
12781
|
+
},
|
|
12782
|
+
additionalProperties: false
|
|
12783
|
+
},
|
|
12784
|
+
DirectoryEntry: {
|
|
12785
|
+
oneOf: [
|
|
12786
|
+
{
|
|
12787
|
+
$ref: "#/components/schemas/FileEntry"
|
|
12788
|
+
},
|
|
12789
|
+
{
|
|
12790
|
+
$ref: "#/components/schemas/DirEntry"
|
|
12791
|
+
}
|
|
12792
|
+
]
|
|
12793
|
+
},
|
|
12794
|
+
FileEntry: {
|
|
12795
|
+
type: "object",
|
|
12796
|
+
required: [
|
|
12797
|
+
"type",
|
|
12798
|
+
"name",
|
|
12799
|
+
"path",
|
|
12800
|
+
"size",
|
|
12801
|
+
"mtime",
|
|
12802
|
+
"tracked"
|
|
12803
|
+
],
|
|
12804
|
+
properties: {
|
|
12805
|
+
type: {
|
|
12806
|
+
type: "string",
|
|
12807
|
+
enum: [
|
|
12808
|
+
"file"
|
|
12809
|
+
]
|
|
12810
|
+
},
|
|
12811
|
+
name: {
|
|
12812
|
+
type: "string",
|
|
12813
|
+
description: "Entry name (basename)"
|
|
12814
|
+
},
|
|
12815
|
+
path: {
|
|
12816
|
+
type: "string",
|
|
12817
|
+
description: "Path relative to project root"
|
|
12818
|
+
},
|
|
12819
|
+
size: {
|
|
12820
|
+
type: "integer",
|
|
12821
|
+
description: "File size in bytes"
|
|
12822
|
+
},
|
|
12823
|
+
mtime: {
|
|
12824
|
+
type: "string",
|
|
12825
|
+
format: "date-time",
|
|
12826
|
+
description: "Last modified time (ISO 8601)"
|
|
12827
|
+
},
|
|
12828
|
+
tracked: {
|
|
12829
|
+
type: "boolean",
|
|
12830
|
+
description: "True if this file is a tracked resource in the Knowledge Base"
|
|
12831
|
+
},
|
|
12832
|
+
resourceId: {
|
|
12833
|
+
type: "string",
|
|
12834
|
+
description: "Resource ID (only when tracked is true)"
|
|
12835
|
+
},
|
|
12836
|
+
entityTypes: {
|
|
12837
|
+
type: "array",
|
|
12838
|
+
items: {
|
|
12839
|
+
type: "string"
|
|
12840
|
+
},
|
|
12841
|
+
description: "Entity types assigned to this resource (only when tracked is true)"
|
|
12842
|
+
},
|
|
12843
|
+
annotationCount: {
|
|
12844
|
+
type: "integer",
|
|
12845
|
+
description: "Number of annotations on this resource (only when tracked is true)"
|
|
12846
|
+
},
|
|
12847
|
+
creator: {
|
|
12848
|
+
type: "string",
|
|
12849
|
+
description: "DID of the user who created the resource (only when tracked is true)"
|
|
12850
|
+
}
|
|
12851
|
+
},
|
|
12852
|
+
additionalProperties: false
|
|
12853
|
+
},
|
|
12854
|
+
DirEntry: {
|
|
12855
|
+
type: "object",
|
|
12856
|
+
required: [
|
|
12857
|
+
"type",
|
|
12858
|
+
"name",
|
|
12859
|
+
"path",
|
|
12860
|
+
"mtime"
|
|
12861
|
+
],
|
|
12862
|
+
properties: {
|
|
12863
|
+
type: {
|
|
12864
|
+
type: "string",
|
|
12865
|
+
enum: [
|
|
12866
|
+
"dir"
|
|
12867
|
+
]
|
|
12868
|
+
},
|
|
12869
|
+
name: {
|
|
12870
|
+
type: "string",
|
|
12871
|
+
description: "Entry name (basename)"
|
|
12872
|
+
},
|
|
12873
|
+
path: {
|
|
12874
|
+
type: "string",
|
|
12875
|
+
description: "Path relative to project root"
|
|
12876
|
+
},
|
|
12877
|
+
mtime: {
|
|
12878
|
+
type: "string",
|
|
12879
|
+
format: "date-time",
|
|
12880
|
+
description: "Last modified time (ISO 8601)"
|
|
12881
|
+
}
|
|
12882
|
+
},
|
|
12883
|
+
additionalProperties: false
|
|
12884
|
+
},
|
|
12763
12885
|
BodyOperationAdd: {
|
|
12764
12886
|
type: "object",
|
|
12765
12887
|
properties: {
|
|
@@ -13479,6 +13601,10 @@ var openapi_default = {
|
|
|
13479
13601
|
minimum: 1,
|
|
13480
13602
|
maximum: 10,
|
|
13481
13603
|
description: "Optional density: desired number of assessments per 2000 words of text (1-10)"
|
|
13604
|
+
},
|
|
13605
|
+
language: {
|
|
13606
|
+
type: "string",
|
|
13607
|
+
description: 'BCP 47 language tag for the generated assessment text (e.g. "en", "fr", "de")'
|
|
13482
13608
|
}
|
|
13483
13609
|
}
|
|
13484
13610
|
},
|
|
@@ -13504,6 +13630,10 @@ var openapi_default = {
|
|
|
13504
13630
|
minimum: 2,
|
|
13505
13631
|
maximum: 12,
|
|
13506
13632
|
description: "Optional density: desired number of comments per 2000 words of text (2-12)"
|
|
13633
|
+
},
|
|
13634
|
+
language: {
|
|
13635
|
+
type: "string",
|
|
13636
|
+
description: "BCP 47 language tag for the generated comment text (e.g. 'en', 'fr', 'de')"
|
|
13507
13637
|
}
|
|
13508
13638
|
}
|
|
13509
13639
|
},
|
|
@@ -14694,6 +14824,20 @@ var openapi_default = {
|
|
|
14694
14824
|
}
|
|
14695
14825
|
]
|
|
14696
14826
|
},
|
|
14827
|
+
generator: {
|
|
14828
|
+
description: "Software agent that produced or processed this resource (W3C Web Annotation model)",
|
|
14829
|
+
oneOf: [
|
|
14830
|
+
{
|
|
14831
|
+
$ref: "#/components/schemas/Agent"
|
|
14832
|
+
},
|
|
14833
|
+
{
|
|
14834
|
+
type: "array",
|
|
14835
|
+
items: {
|
|
14836
|
+
$ref: "#/components/schemas/Agent"
|
|
14837
|
+
}
|
|
14838
|
+
}
|
|
14839
|
+
]
|
|
14840
|
+
},
|
|
14697
14841
|
conformsTo: {
|
|
14698
14842
|
description: "Profile/shape URI this resource description conforms to.",
|
|
14699
14843
|
oneOf: [
|
|
@@ -15219,6 +15363,10 @@ var openapi_default = {
|
|
|
15219
15363
|
},
|
|
15220
15364
|
created: {
|
|
15221
15365
|
type: "string"
|
|
15366
|
+
},
|
|
15367
|
+
token: {
|
|
15368
|
+
type: "string",
|
|
15369
|
+
description: "The validated JWT token string for the current session"
|
|
15222
15370
|
}
|
|
15223
15371
|
},
|
|
15224
15372
|
required: [
|
|
@@ -15232,7 +15380,8 @@ var openapi_default = {
|
|
|
15232
15380
|
"isActive",
|
|
15233
15381
|
"termsAcceptedAt",
|
|
15234
15382
|
"lastLogin",
|
|
15235
|
-
"created"
|
|
15383
|
+
"created",
|
|
15384
|
+
"token"
|
|
15236
15385
|
]
|
|
15237
15386
|
},
|
|
15238
15387
|
SvgSelector: {
|
|
@@ -15703,22 +15852,16 @@ var OAuthService = class {
|
|
|
15703
15852
|
var authMiddleware = /* @__PURE__ */ __name(async (c, next) => {
|
|
15704
15853
|
const logger2 = c.get("logger");
|
|
15705
15854
|
const authHeader = c.req.header("Authorization");
|
|
15706
|
-
|
|
15707
|
-
|
|
15708
|
-
|
|
15709
|
-
|
|
15710
|
-
|
|
15711
|
-
method: c.req.method
|
|
15712
|
-
});
|
|
15713
|
-
return c.json({
|
|
15714
|
-
error: "Unauthorized"
|
|
15715
|
-
}, 401);
|
|
15855
|
+
let tokenStr;
|
|
15856
|
+
if (authHeader?.startsWith("Bearer ")) {
|
|
15857
|
+
tokenStr = authHeader.substring(7).trim();
|
|
15858
|
+
} else {
|
|
15859
|
+
tokenStr = getCookie(c, "semiont-token");
|
|
15716
15860
|
}
|
|
15717
|
-
const tokenStr = authHeader.substring(7).trim();
|
|
15718
15861
|
if (!tokenStr) {
|
|
15719
|
-
logger2.warn("Authentication failed:
|
|
15862
|
+
logger2.warn("Authentication failed: No token", {
|
|
15720
15863
|
type: "auth_failed",
|
|
15721
|
-
reason: "
|
|
15864
|
+
reason: "missing_token",
|
|
15722
15865
|
path: c.req.path,
|
|
15723
15866
|
method: c.req.method
|
|
15724
15867
|
});
|
|
@@ -15729,6 +15872,7 @@ var authMiddleware = /* @__PURE__ */ __name(async (c, next) => {
|
|
|
15729
15872
|
try {
|
|
15730
15873
|
const user = await OAuthService.getUserFromToken(accessToken(tokenStr));
|
|
15731
15874
|
c.set("user", user);
|
|
15875
|
+
c.set("token", tokenStr);
|
|
15732
15876
|
logger2.debug("Authentication successful", {
|
|
15733
15877
|
type: "auth_success",
|
|
15734
15878
|
userId: user.id,
|
|
@@ -15920,6 +16064,13 @@ authRouter.post("/api/tokens/password", validateRequestBody("PasswordAuthRequest
|
|
|
15920
16064
|
lastLogin: /* @__PURE__ */ new Date()
|
|
15921
16065
|
}
|
|
15922
16066
|
});
|
|
16067
|
+
setCookie(c, "semiont-token", token, {
|
|
16068
|
+
httpOnly: true,
|
|
16069
|
+
secure: process.env.NODE_ENV === "production",
|
|
16070
|
+
sameSite: "Lax",
|
|
16071
|
+
path: "/",
|
|
16072
|
+
maxAge: 7 * 24 * 60 * 60
|
|
16073
|
+
});
|
|
15923
16074
|
const response = {
|
|
15924
16075
|
success: true,
|
|
15925
16076
|
user: {
|
|
@@ -15955,6 +16106,13 @@ authRouter.post("/api/tokens/google", validateRequestBody("GoogleAuthRequest"),
|
|
|
15955
16106
|
}
|
|
15956
16107
|
const googleUser = await OAuthService.verifyGoogleToken(googleCredential(access_token));
|
|
15957
16108
|
const { user, token, isNewUser } = await OAuthService.createOrUpdateUser(googleUser);
|
|
16109
|
+
setCookie(c, "semiont-token", token, {
|
|
16110
|
+
httpOnly: true,
|
|
16111
|
+
secure: process.env.NODE_ENV === "production",
|
|
16112
|
+
sameSite: "Lax",
|
|
16113
|
+
path: "/",
|
|
16114
|
+
maxAge: 7 * 24 * 60 * 60
|
|
16115
|
+
});
|
|
15958
16116
|
const response = {
|
|
15959
16117
|
success: true,
|
|
15960
16118
|
user: {
|
|
@@ -16051,6 +16209,7 @@ authRouter.post("/api/tokens/refresh", validateRequestBody("TokenRefreshRequest"
|
|
|
16051
16209
|
});
|
|
16052
16210
|
authRouter.get("/api/users/me", authMiddleware, async (c) => {
|
|
16053
16211
|
const user = c.get("user");
|
|
16212
|
+
const token = c.get("token");
|
|
16054
16213
|
const response = {
|
|
16055
16214
|
id: user.id,
|
|
16056
16215
|
email: user.email,
|
|
@@ -16062,7 +16221,8 @@ authRouter.get("/api/users/me", authMiddleware, async (c) => {
|
|
|
16062
16221
|
isActive: user.isActive,
|
|
16063
16222
|
termsAcceptedAt: user.termsAcceptedAt?.toISOString() || null,
|
|
16064
16223
|
lastLogin: user.lastLogin?.toISOString() || null,
|
|
16065
|
-
created: user.createdAt.toISOString()
|
|
16224
|
+
created: user.createdAt.toISOString(),
|
|
16225
|
+
token
|
|
16066
16226
|
};
|
|
16067
16227
|
return c.json(response, 200);
|
|
16068
16228
|
});
|
|
@@ -16104,6 +16264,9 @@ authRouter.post("/api/users/accept-terms", authMiddleware, async (c) => {
|
|
|
16104
16264
|
return c.json(response, 200);
|
|
16105
16265
|
});
|
|
16106
16266
|
authRouter.post("/api/users/logout", authMiddleware, async (c) => {
|
|
16267
|
+
deleteCookie(c, "semiont-token", {
|
|
16268
|
+
path: "/"
|
|
16269
|
+
});
|
|
16107
16270
|
return c.json({
|
|
16108
16271
|
success: true,
|
|
16109
16272
|
message: "Logged out successfully"
|
|
@@ -16375,8 +16538,8 @@ exchangeRouter.post("/api/admin/exchange/backup", async (c) => {
|
|
|
16375
16538
|
(async () => {
|
|
16376
16539
|
try {
|
|
16377
16540
|
await exportBackup({
|
|
16378
|
-
eventStore: mm.kb.eventStore,
|
|
16379
|
-
content: mm.kb.content,
|
|
16541
|
+
eventStore: mm.knowledgeSystem.kb.eventStore,
|
|
16542
|
+
content: mm.knowledgeSystem.kb.content,
|
|
16380
16543
|
sourceUrl
|
|
16381
16544
|
}, nodeWritable);
|
|
16382
16545
|
} catch (err) {
|
|
@@ -16475,8 +16638,8 @@ exchangeRouter.post("/api/moderate/exchange/export", async (c) => {
|
|
|
16475
16638
|
(async () => {
|
|
16476
16639
|
try {
|
|
16477
16640
|
await exportLinkedData({
|
|
16478
|
-
views: mm.kb.views,
|
|
16479
|
-
content: mm.kb.content,
|
|
16641
|
+
views: mm.knowledgeSystem.kb.views,
|
|
16642
|
+
content: mm.knowledgeSystem.kb.content,
|
|
16480
16643
|
sourceUrl,
|
|
16481
16644
|
entityTypes,
|
|
16482
16645
|
includeArchived
|
|
@@ -16587,7 +16750,7 @@ function registerCreateResource(router) {
|
|
|
16587
16750
|
const arrayBuffer = await file.arrayBuffer();
|
|
16588
16751
|
const contentBuffer = Buffer.from(arrayBuffer);
|
|
16589
16752
|
const eventBus2 = c.get("eventBus");
|
|
16590
|
-
const
|
|
16753
|
+
const resourceId20 = await ResourceOperations.createResource({
|
|
16591
16754
|
name,
|
|
16592
16755
|
content: contentBuffer,
|
|
16593
16756
|
format,
|
|
@@ -16595,9 +16758,9 @@ function registerCreateResource(router) {
|
|
|
16595
16758
|
entityTypes,
|
|
16596
16759
|
creationMethod: creationMethod || void 0,
|
|
16597
16760
|
storageUri: storageUri || void 0
|
|
16598
|
-
}, userId(user
|
|
16761
|
+
}, userId(userToDid(user)), eventBus2);
|
|
16599
16762
|
return c.json({
|
|
16600
|
-
resourceId:
|
|
16763
|
+
resourceId: resourceId20
|
|
16601
16764
|
}, 202);
|
|
16602
16765
|
});
|
|
16603
16766
|
}
|
|
@@ -16912,7 +17075,7 @@ function registerGetResourceUri(router) {
|
|
|
16912
17075
|
}
|
|
16913
17076
|
const acceptHeader = c.req.header("Accept") || "application/ld+json";
|
|
16914
17077
|
if (acceptHeader.includes("text/") || acceptHeader.includes("image/") || acceptHeader.includes("application/pdf")) {
|
|
16915
|
-
const { kb } = c.get("makeMeaning");
|
|
17078
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
16916
17079
|
let resource;
|
|
16917
17080
|
try {
|
|
16918
17081
|
resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
|
|
@@ -17026,7 +17189,7 @@ function registerUpdateResource(router) {
|
|
|
17026
17189
|
const body = c.get("validatedBody");
|
|
17027
17190
|
const user = c.get("user");
|
|
17028
17191
|
const eventBus2 = c.get("eventBus");
|
|
17029
|
-
const { kb } = c.get("makeMeaning");
|
|
17192
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
17030
17193
|
const doc = await ResourceContext.getResourceMetadata(resourceId(id), kb);
|
|
17031
17194
|
if (!doc) {
|
|
17032
17195
|
throw new HTTPException(404, {
|
|
@@ -17035,7 +17198,7 @@ function registerUpdateResource(router) {
|
|
|
17035
17198
|
}
|
|
17036
17199
|
await ResourceOperations.updateResource({
|
|
17037
17200
|
resourceId: resourceId(id),
|
|
17038
|
-
userId: userId(user
|
|
17201
|
+
userId: userId(userToDid(user)),
|
|
17039
17202
|
currentArchived: doc.archived,
|
|
17040
17203
|
updatedArchived: body.archived,
|
|
17041
17204
|
currentEntityTypes: doc.entityTypes,
|
|
@@ -17105,7 +17268,7 @@ function registerAnnotateReferencesStream(router, jobQueue) {
|
|
|
17105
17268
|
});
|
|
17106
17269
|
}
|
|
17107
17270
|
const eventBus2 = c.get("eventBus");
|
|
17108
|
-
const { kb } = c.get("makeMeaning");
|
|
17271
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
17109
17272
|
const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
|
|
17110
17273
|
if (!resource) {
|
|
17111
17274
|
throw new HTTPException(404, {
|
|
@@ -17117,7 +17280,7 @@ function registerAnnotateReferencesStream(router, jobQueue) {
|
|
|
17117
17280
|
metadata: {
|
|
17118
17281
|
id: jobId(`job-${nanoid()}`),
|
|
17119
17282
|
type: "reference-annotation",
|
|
17120
|
-
userId: userId(user
|
|
17283
|
+
userId: userId(userToDid(user)),
|
|
17121
17284
|
userName: user.name || user.email,
|
|
17122
17285
|
userEmail: user.email,
|
|
17123
17286
|
userDomain: user.domain,
|
|
@@ -17307,7 +17470,7 @@ function registerAnnotateHighlightsStream(router, jobQueue) {
|
|
|
17307
17470
|
});
|
|
17308
17471
|
}
|
|
17309
17472
|
const eventBus2 = c.get("eventBus");
|
|
17310
|
-
const { kb } = c.get("makeMeaning");
|
|
17473
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
17311
17474
|
const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
|
|
17312
17475
|
if (!resource) {
|
|
17313
17476
|
throw new HTTPException(404, {
|
|
@@ -17319,7 +17482,7 @@ function registerAnnotateHighlightsStream(router, jobQueue) {
|
|
|
17319
17482
|
metadata: {
|
|
17320
17483
|
id: jobId(`job-${nanoid()}`),
|
|
17321
17484
|
type: "highlight-annotation",
|
|
17322
|
-
userId: userId(user
|
|
17485
|
+
userId: userId(userToDid(user)),
|
|
17323
17486
|
userName: user.name || user.email,
|
|
17324
17487
|
userEmail: user.email,
|
|
17325
17488
|
userDomain: user.domain,
|
|
@@ -17495,7 +17658,7 @@ function registerAnnotateAssessmentsStream(router, jobQueue) {
|
|
|
17495
17658
|
router.post("/resources/:id/annotate-assessments-stream", validateRequestBody("AnnotateAssessmentsStreamRequest"), async (c) => {
|
|
17496
17659
|
const { id } = c.req.param();
|
|
17497
17660
|
const body = c.get("validatedBody");
|
|
17498
|
-
const { instructions, tone, density } = body;
|
|
17661
|
+
const { instructions, tone, density, language } = body;
|
|
17499
17662
|
if (density !== void 0 && (typeof density !== "number" || density < 1 || density > 10)) {
|
|
17500
17663
|
throw new HTTPException(400, {
|
|
17501
17664
|
message: "Invalid density. Must be a number between 1 and 10."
|
|
@@ -17517,7 +17680,7 @@ function registerAnnotateAssessmentsStream(router, jobQueue) {
|
|
|
17517
17680
|
});
|
|
17518
17681
|
}
|
|
17519
17682
|
const eventBus2 = c.get("eventBus");
|
|
17520
|
-
const { kb } = c.get("makeMeaning");
|
|
17683
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
17521
17684
|
const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
|
|
17522
17685
|
if (!resource) {
|
|
17523
17686
|
throw new HTTPException(404, {
|
|
@@ -17529,7 +17692,7 @@ function registerAnnotateAssessmentsStream(router, jobQueue) {
|
|
|
17529
17692
|
metadata: {
|
|
17530
17693
|
id: jobId(`job-${nanoid()}`),
|
|
17531
17694
|
type: "assessment-annotation",
|
|
17532
|
-
userId: userId(user
|
|
17695
|
+
userId: userId(userToDid(user)),
|
|
17533
17696
|
userName: user.name || user.email,
|
|
17534
17697
|
userEmail: user.email,
|
|
17535
17698
|
userDomain: user.domain,
|
|
@@ -17541,7 +17704,8 @@ function registerAnnotateAssessmentsStream(router, jobQueue) {
|
|
|
17541
17704
|
resourceId: resourceId(id),
|
|
17542
17705
|
instructions,
|
|
17543
17706
|
tone,
|
|
17544
|
-
density
|
|
17707
|
+
density,
|
|
17708
|
+
language
|
|
17545
17709
|
}
|
|
17546
17710
|
};
|
|
17547
17711
|
await jobQueue.createJob(job);
|
|
@@ -17716,7 +17880,7 @@ function registerAnnotateCommentsStream(router, jobQueue) {
|
|
|
17716
17880
|
router.post("/resources/:id/annotate-comments-stream", validateRequestBody("AnnotateCommentsStreamRequest"), async (c) => {
|
|
17717
17881
|
const { id } = c.req.param();
|
|
17718
17882
|
const body = c.get("validatedBody");
|
|
17719
|
-
const { instructions, tone, density } = body;
|
|
17883
|
+
const { instructions, tone, density, language } = body;
|
|
17720
17884
|
if (density !== void 0 && (typeof density !== "number" || density < 2 || density > 12)) {
|
|
17721
17885
|
throw new HTTPException(400, {
|
|
17722
17886
|
message: "Invalid density. Must be a number between 2 and 12."
|
|
@@ -17738,7 +17902,7 @@ function registerAnnotateCommentsStream(router, jobQueue) {
|
|
|
17738
17902
|
});
|
|
17739
17903
|
}
|
|
17740
17904
|
const eventBus2 = c.get("eventBus");
|
|
17741
|
-
const { kb } = c.get("makeMeaning");
|
|
17905
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
17742
17906
|
const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
|
|
17743
17907
|
if (!resource) {
|
|
17744
17908
|
throw new HTTPException(404, {
|
|
@@ -17750,7 +17914,7 @@ function registerAnnotateCommentsStream(router, jobQueue) {
|
|
|
17750
17914
|
metadata: {
|
|
17751
17915
|
id: jobId(`job-${nanoid()}`),
|
|
17752
17916
|
type: "comment-annotation",
|
|
17753
|
-
userId: userId(user
|
|
17917
|
+
userId: userId(userToDid(user)),
|
|
17754
17918
|
userName: user.name || user.email,
|
|
17755
17919
|
userEmail: user.email,
|
|
17756
17920
|
userDomain: user.domain,
|
|
@@ -17762,7 +17926,8 @@ function registerAnnotateCommentsStream(router, jobQueue) {
|
|
|
17762
17926
|
resourceId: resourceId(id),
|
|
17763
17927
|
instructions,
|
|
17764
17928
|
tone,
|
|
17765
|
-
density
|
|
17929
|
+
density,
|
|
17930
|
+
language
|
|
17766
17931
|
}
|
|
17767
17932
|
};
|
|
17768
17933
|
await jobQueue.createJob(job);
|
|
@@ -18130,7 +18295,7 @@ function registerAnnotateTagsStream(router, jobQueue) {
|
|
|
18130
18295
|
});
|
|
18131
18296
|
}
|
|
18132
18297
|
const eventBus2 = c.get("eventBus");
|
|
18133
|
-
const { kb } = c.get("makeMeaning");
|
|
18298
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
18134
18299
|
const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
|
|
18135
18300
|
if (!resource) {
|
|
18136
18301
|
throw new HTTPException(404, {
|
|
@@ -18142,7 +18307,7 @@ function registerAnnotateTagsStream(router, jobQueue) {
|
|
|
18142
18307
|
metadata: {
|
|
18143
18308
|
id: jobId(`job-${nanoid()}`),
|
|
18144
18309
|
type: "tag-annotation",
|
|
18145
|
-
userId: userId(user
|
|
18310
|
+
userId: userId(userToDid(user)),
|
|
18146
18311
|
userName: user.name || user.email,
|
|
18147
18312
|
userEmail: user.email,
|
|
18148
18313
|
userDomain: user.domain,
|
|
@@ -18318,134 +18483,6 @@ function registerAnnotateTagsStream(router, jobQueue) {
|
|
|
18318
18483
|
});
|
|
18319
18484
|
}
|
|
18320
18485
|
__name(registerAnnotateTagsStream, "registerAnnotateTagsStream");
|
|
18321
|
-
|
|
18322
|
-
// src/routes/resources/routes/llm-context.ts
|
|
18323
|
-
var import_rxjs2 = __toESM(require_cjs());
|
|
18324
|
-
var import_operators2 = __toESM(require_operators());
|
|
18325
|
-
function registerGetResourceLLMContext(router) {
|
|
18326
|
-
router.get("/resources/:id/llm-context", async (c) => {
|
|
18327
|
-
const { id } = c.req.param();
|
|
18328
|
-
const query = c.req.query();
|
|
18329
|
-
const eventBus2 = c.get("eventBus");
|
|
18330
|
-
const depth = query.depth ? Number(query.depth) : 2;
|
|
18331
|
-
const maxResources = query.maxResources ? Number(query.maxResources) : 10;
|
|
18332
|
-
const includeContent = query.includeContent === "false" ? false : true;
|
|
18333
|
-
const includeSummary = query.includeSummary === "true" ? true : false;
|
|
18334
|
-
if (depth < 1 || depth > 3) {
|
|
18335
|
-
throw new HTTPException(400, {
|
|
18336
|
-
message: 'Query parameter "depth" must be between 1 and 3'
|
|
18337
|
-
});
|
|
18338
|
-
}
|
|
18339
|
-
if (maxResources < 1 || maxResources > 20) {
|
|
18340
|
-
throw new HTTPException(400, {
|
|
18341
|
-
message: 'Query parameter "maxResources" must be between 1 and 20'
|
|
18342
|
-
});
|
|
18343
|
-
}
|
|
18344
|
-
eventBus2.get("gather:resource-requested").next({
|
|
18345
|
-
resourceId: resourceId(id),
|
|
18346
|
-
options: {
|
|
18347
|
-
depth,
|
|
18348
|
-
maxResources,
|
|
18349
|
-
includeContent,
|
|
18350
|
-
includeSummary
|
|
18351
|
-
}
|
|
18352
|
-
});
|
|
18353
|
-
try {
|
|
18354
|
-
const result = await (0, import_rxjs2.firstValueFrom)((0, import_rxjs2.merge)(eventBus2.get("gather:resource-complete").pipe((0, import_operators2.filter)((e) => e.resourceId === id), (0, import_operators2.map)((e) => ({
|
|
18355
|
-
ok: true,
|
|
18356
|
-
context: e.context
|
|
18357
|
-
}))), eventBus2.get("gather:resource-failed").pipe((0, import_operators2.filter)((e) => e.resourceId === id), (0, import_operators2.map)((e) => ({
|
|
18358
|
-
ok: false,
|
|
18359
|
-
error: e.error
|
|
18360
|
-
})))).pipe((0, import_operators2.take)(1), (0, import_operators2.timeout)(3e4)));
|
|
18361
|
-
if (!result.ok) {
|
|
18362
|
-
throw result.error;
|
|
18363
|
-
}
|
|
18364
|
-
return c.json(result.context);
|
|
18365
|
-
} catch (error) {
|
|
18366
|
-
if (error instanceof Error) {
|
|
18367
|
-
if (error.message === "Resource not found") {
|
|
18368
|
-
throw new HTTPException(404, {
|
|
18369
|
-
message: "Resource not found"
|
|
18370
|
-
});
|
|
18371
|
-
}
|
|
18372
|
-
if (error.name === "TimeoutError") {
|
|
18373
|
-
throw new HTTPException(504, {
|
|
18374
|
-
message: "Context gathering timed out"
|
|
18375
|
-
});
|
|
18376
|
-
}
|
|
18377
|
-
}
|
|
18378
|
-
throw error;
|
|
18379
|
-
}
|
|
18380
|
-
});
|
|
18381
|
-
}
|
|
18382
|
-
__name(registerGetResourceLLMContext, "registerGetResourceLLMContext");
|
|
18383
|
-
|
|
18384
|
-
// src/routes/resources/routes/annotation-llm-context.ts
|
|
18385
|
-
var import_rxjs3 = __toESM(require_cjs());
|
|
18386
|
-
var import_operators3 = __toESM(require_operators());
|
|
18387
|
-
function registerGetAnnotationLLMContext(router) {
|
|
18388
|
-
router.get("/resources/:resourceId/annotations/:annotationId/llm-context", async (c) => {
|
|
18389
|
-
const { resourceId: resourceIdParam, annotationId: annotationIdParam } = c.req.param();
|
|
18390
|
-
const query = c.req.query();
|
|
18391
|
-
const eventBus2 = c.get("eventBus");
|
|
18392
|
-
const includeSourceContext = query.includeSourceContext === "false" ? false : true;
|
|
18393
|
-
const includeTargetContext = query.includeTargetContext === "false" ? false : true;
|
|
18394
|
-
const contextWindow = query.contextWindow ? Number(query.contextWindow) : 1e3;
|
|
18395
|
-
if (contextWindow < 100 || contextWindow > 5e3) {
|
|
18396
|
-
throw new HTTPException(400, {
|
|
18397
|
-
message: 'Query parameter "contextWindow" must be between 100 and 5000'
|
|
18398
|
-
});
|
|
18399
|
-
}
|
|
18400
|
-
eventBus2.get("gather:requested").next({
|
|
18401
|
-
annotationId: annotationId(annotationIdParam),
|
|
18402
|
-
resourceId: resourceId(resourceIdParam),
|
|
18403
|
-
options: {
|
|
18404
|
-
includeSourceContext,
|
|
18405
|
-
includeTargetContext,
|
|
18406
|
-
contextWindow
|
|
18407
|
-
}
|
|
18408
|
-
});
|
|
18409
|
-
try {
|
|
18410
|
-
const result = await (0, import_rxjs3.firstValueFrom)((0, import_rxjs3.merge)(eventBus2.get("gather:complete").pipe((0, import_operators3.filter)((e) => e.annotationId === annotationIdParam), (0, import_operators3.map)((e) => ({
|
|
18411
|
-
ok: true,
|
|
18412
|
-
response: e.response
|
|
18413
|
-
}))), eventBus2.get("gather:failed").pipe((0, import_operators3.filter)((e) => e.annotationId === annotationIdParam), (0, import_operators3.map)((e) => ({
|
|
18414
|
-
ok: false,
|
|
18415
|
-
error: e.error
|
|
18416
|
-
})))).pipe((0, import_operators3.take)(1), (0, import_operators3.timeout)(3e4)));
|
|
18417
|
-
if (!result.ok) {
|
|
18418
|
-
throw result.error;
|
|
18419
|
-
}
|
|
18420
|
-
return c.json(result.response);
|
|
18421
|
-
} catch (error) {
|
|
18422
|
-
if (error instanceof Error) {
|
|
18423
|
-
if (error.message === "Annotation not found") {
|
|
18424
|
-
throw new HTTPException(404, {
|
|
18425
|
-
message: "Annotation not found"
|
|
18426
|
-
});
|
|
18427
|
-
}
|
|
18428
|
-
if (error.message === "Source resource not found") {
|
|
18429
|
-
throw new HTTPException(404, {
|
|
18430
|
-
message: "Source resource not found"
|
|
18431
|
-
});
|
|
18432
|
-
}
|
|
18433
|
-
if (error.message === "Source content not found") {
|
|
18434
|
-
throw new HTTPException(404, {
|
|
18435
|
-
message: "Source content not found"
|
|
18436
|
-
});
|
|
18437
|
-
}
|
|
18438
|
-
if (error.name === "TimeoutError") {
|
|
18439
|
-
throw new HTTPException(504, {
|
|
18440
|
-
message: "Context gathering timed out"
|
|
18441
|
-
});
|
|
18442
|
-
}
|
|
18443
|
-
}
|
|
18444
|
-
throw error;
|
|
18445
|
-
}
|
|
18446
|
-
});
|
|
18447
|
-
}
|
|
18448
|
-
__name(registerGetAnnotationLLMContext, "registerGetAnnotationLLMContext");
|
|
18449
18486
|
function registerGetReferencedBy(router) {
|
|
18450
18487
|
router.get("/resources/:id/referenced-by", async (c) => {
|
|
18451
18488
|
const { id } = c.req.param();
|
|
@@ -18453,11 +18490,11 @@ function registerGetReferencedBy(router) {
|
|
|
18453
18490
|
const eventBus2 = c.get("eventBus");
|
|
18454
18491
|
const correlationId = crypto.randomUUID();
|
|
18455
18492
|
try {
|
|
18456
|
-
const response = await eventBusRequest(eventBus2, "
|
|
18493
|
+
const response = await eventBusRequest(eventBus2, "browse:referenced-by-requested", {
|
|
18457
18494
|
correlationId,
|
|
18458
18495
|
resourceId: resourceId(id),
|
|
18459
18496
|
motivation
|
|
18460
|
-
}, "
|
|
18497
|
+
}, "browse:referenced-by-result", "browse:referenced-by-failed");
|
|
18461
18498
|
return c.json(response);
|
|
18462
18499
|
} catch (error) {
|
|
18463
18500
|
if (error instanceof Error && error.name === "TimeoutError") {
|
|
@@ -18492,7 +18529,7 @@ function registerBindSearchStream(router) {
|
|
|
18492
18529
|
});
|
|
18493
18530
|
}
|
|
18494
18531
|
const eventBus2 = c.get("eventBus");
|
|
18495
|
-
const { kb } = c.get("makeMeaning");
|
|
18532
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
18496
18533
|
const resource = await ResourceContext.getResourceMetadata(resourceId(id), kb);
|
|
18497
18534
|
if (!resource) {
|
|
18498
18535
|
throw new HTTPException(404, {
|
|
@@ -18520,7 +18557,7 @@ function registerBindSearchStream(router) {
|
|
|
18520
18557
|
if (closeStreamCallback) closeStreamCallback();
|
|
18521
18558
|
}, "cleanup");
|
|
18522
18559
|
try {
|
|
18523
|
-
subscriptions.push(eventBus2.get("
|
|
18560
|
+
subscriptions.push(eventBus2.get("match:search-results").subscribe(async (event) => {
|
|
18524
18561
|
if (event.correlationId !== correlationId) return;
|
|
18525
18562
|
if (isStreamClosed) return;
|
|
18526
18563
|
logger2.info("Bind search completed", {
|
|
@@ -18533,7 +18570,7 @@ function registerBindSearchStream(router) {
|
|
|
18533
18570
|
referenceId: event.referenceId,
|
|
18534
18571
|
results: event.results
|
|
18535
18572
|
}),
|
|
18536
|
-
event: "
|
|
18573
|
+
event: "match:search-results",
|
|
18537
18574
|
id: String(Date.now())
|
|
18538
18575
|
});
|
|
18539
18576
|
} catch (error) {
|
|
@@ -18541,7 +18578,7 @@ function registerBindSearchStream(router) {
|
|
|
18541
18578
|
}
|
|
18542
18579
|
cleanup();
|
|
18543
18580
|
}));
|
|
18544
|
-
subscriptions.push(eventBus2.get("
|
|
18581
|
+
subscriptions.push(eventBus2.get("match:search-failed").subscribe(async (event) => {
|
|
18545
18582
|
if (event.correlationId !== correlationId) return;
|
|
18546
18583
|
if (isStreamClosed) return;
|
|
18547
18584
|
logger2.error("Bind search failed", {
|
|
@@ -18554,7 +18591,7 @@ function registerBindSearchStream(router) {
|
|
|
18554
18591
|
referenceId: event.referenceId,
|
|
18555
18592
|
error: event.error.message
|
|
18556
18593
|
}),
|
|
18557
|
-
event: "
|
|
18594
|
+
event: "match:search-failed",
|
|
18558
18595
|
id: String(Date.now())
|
|
18559
18596
|
});
|
|
18560
18597
|
} catch (error) {
|
|
@@ -18562,7 +18599,7 @@ function registerBindSearchStream(router) {
|
|
|
18562
18599
|
}
|
|
18563
18600
|
cleanup();
|
|
18564
18601
|
}));
|
|
18565
|
-
eventBus2.get("
|
|
18602
|
+
eventBus2.get("match:search-requested").next({
|
|
18566
18603
|
correlationId,
|
|
18567
18604
|
referenceId,
|
|
18568
18605
|
context,
|
|
@@ -18580,7 +18617,7 @@ function registerBindSearchStream(router) {
|
|
|
18580
18617
|
referenceId,
|
|
18581
18618
|
error: error instanceof Error ? error.message : "Search failed"
|
|
18582
18619
|
}),
|
|
18583
|
-
event: "
|
|
18620
|
+
event: "match:search-failed",
|
|
18584
18621
|
id: String(Date.now())
|
|
18585
18622
|
});
|
|
18586
18623
|
} catch (sseError) {
|
|
@@ -18636,7 +18673,7 @@ function registerTokenRoutes(router) {
|
|
|
18636
18673
|
token: body.token,
|
|
18637
18674
|
name: body.name,
|
|
18638
18675
|
content: body.content,
|
|
18639
|
-
userId: userId(user
|
|
18676
|
+
userId: userId(userToDid(user)),
|
|
18640
18677
|
archiveOriginal: body.archiveOriginal
|
|
18641
18678
|
}, "yield:clone-created", "yield:clone-create-failed");
|
|
18642
18679
|
return c.json({
|
|
@@ -18779,7 +18816,7 @@ function registerGetEventStream(router) {
|
|
|
18779
18816
|
logger2.info("Client connecting to resource events stream", {
|
|
18780
18817
|
resourceId: rId
|
|
18781
18818
|
});
|
|
18782
|
-
const { eventStore } = c.get("makeMeaning");
|
|
18819
|
+
const { knowledgeSystem: { kb: { eventStore } } } = c.get("makeMeaning");
|
|
18783
18820
|
const query = new EventQuery(eventStore.log.storage);
|
|
18784
18821
|
const events = await query.getResourceEvents(rId);
|
|
18785
18822
|
if (events.length === 0) {
|
|
@@ -18928,7 +18965,7 @@ function registerCreateAnnotation(router) {
|
|
|
18928
18965
|
const eventBus2 = c.get("eventBus");
|
|
18929
18966
|
eventBus2.get("mark:create").next({
|
|
18930
18967
|
annotation,
|
|
18931
|
-
userId: userId(user
|
|
18968
|
+
userId: userId(userToDid(user)),
|
|
18932
18969
|
resourceId: resourceId(id)
|
|
18933
18970
|
});
|
|
18934
18971
|
return c.json({
|
|
@@ -18974,7 +19011,7 @@ function registerDeleteAnnotation(router) {
|
|
|
18974
19011
|
const eventBus2 = c.get("eventBus");
|
|
18975
19012
|
eventBus2.get("mark:delete").next({
|
|
18976
19013
|
annotationId: annotationId(annotationIdParam),
|
|
18977
|
-
userId: userId(user
|
|
19014
|
+
userId: userId(userToDid(user)),
|
|
18978
19015
|
resourceId: resourceId(resourceIdParam)
|
|
18979
19016
|
});
|
|
18980
19017
|
return c.body(null, 202);
|
|
@@ -18990,7 +19027,7 @@ function registerUpdateAnnotationBody(router) {
|
|
|
18990
19027
|
eventBus2.get("mark:update-body").next({
|
|
18991
19028
|
annotationId: annotationId(annotationIdParam),
|
|
18992
19029
|
resourceId: resourceId(resourceIdParam),
|
|
18993
|
-
userId: userId(user
|
|
19030
|
+
userId: userId(userToDid(user)),
|
|
18994
19031
|
operations: request.operations
|
|
18995
19032
|
});
|
|
18996
19033
|
return c.body(null, 202);
|
|
@@ -19017,7 +19054,7 @@ function registerYieldResourceStream(router, jobQueue) {
|
|
|
19017
19054
|
});
|
|
19018
19055
|
}
|
|
19019
19056
|
const eventBus2 = c.get("eventBus");
|
|
19020
|
-
const { kb } = c.get("makeMeaning");
|
|
19057
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
19021
19058
|
logger2.info("Starting resource generation", {
|
|
19022
19059
|
language: body.language
|
|
19023
19060
|
});
|
|
@@ -19053,7 +19090,7 @@ function registerYieldResourceStream(router, jobQueue) {
|
|
|
19053
19090
|
metadata: {
|
|
19054
19091
|
id: jobId(`job-${nanoid()}`),
|
|
19055
19092
|
type: "generation",
|
|
19056
|
-
userId: userId(user
|
|
19093
|
+
userId: userId(userToDid(user)),
|
|
19057
19094
|
userName: user.name || user.email,
|
|
19058
19095
|
userEmail: user.email,
|
|
19059
19096
|
userDomain: user.domain,
|
|
@@ -19214,15 +19251,130 @@ function registerYieldResourceStream(router, jobQueue) {
|
|
|
19214
19251
|
});
|
|
19215
19252
|
}
|
|
19216
19253
|
__name(registerYieldResourceStream, "registerYieldResourceStream");
|
|
19254
|
+
init_logger();
|
|
19255
|
+
function registerGatherAnnotationStream(router) {
|
|
19256
|
+
router.post("/resources/:resourceId/annotations/:annotationId/gather-annotation-stream", validateRequestBody("GatherAnnotationStreamRequest"), async (c) => {
|
|
19257
|
+
const { resourceId: resourceIdParam, annotationId: annotationIdParam } = c.req.param();
|
|
19258
|
+
const body = c.get("validatedBody");
|
|
19259
|
+
const contextWindow = body.contextWindow ?? 1e3;
|
|
19260
|
+
const eventBus2 = c.get("eventBus");
|
|
19261
|
+
const logger2 = getLogger().child({
|
|
19262
|
+
component: "gather-annotation-stream",
|
|
19263
|
+
resourceId: resourceIdParam,
|
|
19264
|
+
annotationId: annotationIdParam
|
|
19265
|
+
});
|
|
19266
|
+
const user = c.get("user");
|
|
19267
|
+
if (!user) {
|
|
19268
|
+
throw new HTTPException(401, {
|
|
19269
|
+
message: "Authentication required"
|
|
19270
|
+
});
|
|
19271
|
+
}
|
|
19272
|
+
eventBus2.get("gather:requested").next({
|
|
19273
|
+
annotationId: annotationId(annotationIdParam),
|
|
19274
|
+
resourceId: resourceId(resourceIdParam),
|
|
19275
|
+
options: {
|
|
19276
|
+
includeSourceContext: true,
|
|
19277
|
+
includeTargetContext: true,
|
|
19278
|
+
contextWindow
|
|
19279
|
+
}
|
|
19280
|
+
});
|
|
19281
|
+
logger2.info("Emitted gather:requested", {
|
|
19282
|
+
annotationId: annotationIdParam,
|
|
19283
|
+
contextWindow
|
|
19284
|
+
});
|
|
19285
|
+
c.header("X-Accel-Buffering", "no");
|
|
19286
|
+
c.header("Cache-Control", "no-cache, no-transform");
|
|
19287
|
+
return streamSSE(c, async (stream) => {
|
|
19288
|
+
let isStreamClosed = false;
|
|
19289
|
+
const subscriptions = [];
|
|
19290
|
+
let keepAliveInterval = null;
|
|
19291
|
+
const streamPromise = new Promise((resolve) => {
|
|
19292
|
+
const cleanup = /* @__PURE__ */ __name(() => {
|
|
19293
|
+
if (isStreamClosed) return;
|
|
19294
|
+
isStreamClosed = true;
|
|
19295
|
+
if (keepAliveInterval) clearInterval(keepAliveInterval);
|
|
19296
|
+
subscriptions.forEach((sub) => sub.unsubscribe());
|
|
19297
|
+
resolve();
|
|
19298
|
+
}, "cleanup");
|
|
19299
|
+
subscriptions.push(eventBus2.get("gather:annotation-progress").subscribe(async (event) => {
|
|
19300
|
+
if (isStreamClosed) return;
|
|
19301
|
+
try {
|
|
19302
|
+
await writeTypedSSE(stream, {
|
|
19303
|
+
data: JSON.stringify({
|
|
19304
|
+
message: event.message,
|
|
19305
|
+
percentage: event.percentage
|
|
19306
|
+
}),
|
|
19307
|
+
event: "gather:annotation-progress",
|
|
19308
|
+
id: String(Date.now())
|
|
19309
|
+
});
|
|
19310
|
+
} catch {
|
|
19311
|
+
cleanup();
|
|
19312
|
+
}
|
|
19313
|
+
}));
|
|
19314
|
+
subscriptions.push(eventBus2.get("gather:complete").subscribe(async (event) => {
|
|
19315
|
+
if (event.annotationId !== annotationIdParam) return;
|
|
19316
|
+
if (isStreamClosed) return;
|
|
19317
|
+
try {
|
|
19318
|
+
await writeTypedSSE(stream, {
|
|
19319
|
+
data: JSON.stringify({
|
|
19320
|
+
annotationId: event.annotationId,
|
|
19321
|
+
response: event.response
|
|
19322
|
+
}),
|
|
19323
|
+
event: "gather:annotation-finished",
|
|
19324
|
+
id: String(Date.now())
|
|
19325
|
+
});
|
|
19326
|
+
} catch {
|
|
19327
|
+
}
|
|
19328
|
+
cleanup();
|
|
19329
|
+
}));
|
|
19330
|
+
subscriptions.push(eventBus2.get("gather:failed").subscribe(async (event) => {
|
|
19331
|
+
if (event.annotationId !== annotationIdParam) return;
|
|
19332
|
+
if (isStreamClosed) return;
|
|
19333
|
+
try {
|
|
19334
|
+
await writeTypedSSE(stream, {
|
|
19335
|
+
data: JSON.stringify({
|
|
19336
|
+
annotationId: event.annotationId,
|
|
19337
|
+
error: event.error
|
|
19338
|
+
}),
|
|
19339
|
+
event: "gather:failed",
|
|
19340
|
+
id: String(Date.now())
|
|
19341
|
+
});
|
|
19342
|
+
} catch {
|
|
19343
|
+
}
|
|
19344
|
+
cleanup();
|
|
19345
|
+
}));
|
|
19346
|
+
keepAliveInterval = setInterval(async () => {
|
|
19347
|
+
if (isStreamClosed) {
|
|
19348
|
+
clearInterval(keepAliveInterval);
|
|
19349
|
+
return;
|
|
19350
|
+
}
|
|
19351
|
+
try {
|
|
19352
|
+
await stream.writeSSE({
|
|
19353
|
+
data: ":keep-alive"
|
|
19354
|
+
});
|
|
19355
|
+
} catch {
|
|
19356
|
+
cleanup();
|
|
19357
|
+
}
|
|
19358
|
+
}, 3e4);
|
|
19359
|
+
c.req.raw.signal.addEventListener("abort", () => {
|
|
19360
|
+
logger2.info("Client disconnected from gather stream");
|
|
19361
|
+
cleanup();
|
|
19362
|
+
});
|
|
19363
|
+
});
|
|
19364
|
+
return streamPromise;
|
|
19365
|
+
});
|
|
19366
|
+
});
|
|
19367
|
+
}
|
|
19368
|
+
__name(registerGatherAnnotationStream, "registerGatherAnnotationStream");
|
|
19217
19369
|
function registerGetAnnotationHistory(router) {
|
|
19218
19370
|
router.get("/resources/:resourceId/annotations/:annotationId/history", async (c) => {
|
|
19219
|
-
const { resourceId:
|
|
19371
|
+
const { resourceId: resourceId20, annotationId: annotationId6 } = c.req.param();
|
|
19220
19372
|
const eventBus2 = c.get("eventBus");
|
|
19221
19373
|
const correlationId = crypto.randomUUID();
|
|
19222
19374
|
try {
|
|
19223
19375
|
const response = await eventBusRequest(eventBus2, "browse:annotation-history-requested", {
|
|
19224
19376
|
correlationId,
|
|
19225
|
-
resourceId: resourceId(
|
|
19377
|
+
resourceId: resourceId(resourceId20),
|
|
19226
19378
|
annotationId: annotationId(annotationId6)
|
|
19227
19379
|
}, "browse:annotation-history-result", "browse:annotation-history-failed");
|
|
19228
19380
|
return c.json(response);
|
|
@@ -19261,8 +19413,6 @@ function createResourcesRouter(jobQueue) {
|
|
|
19261
19413
|
registerAnnotateAssessmentsStream(resourcesRouter2, jobQueue);
|
|
19262
19414
|
registerAnnotateCommentsStream(resourcesRouter2, jobQueue);
|
|
19263
19415
|
registerAnnotateTagsStream(resourcesRouter2, jobQueue);
|
|
19264
|
-
registerGetResourceLLMContext(resourcesRouter2);
|
|
19265
|
-
registerGetAnnotationLLMContext(resourcesRouter2);
|
|
19266
19416
|
registerGetReferencedBy(resourcesRouter2);
|
|
19267
19417
|
registerBindSearchStream(resourcesRouter2);
|
|
19268
19418
|
registerGetResourceAnnotations(resourcesRouter2);
|
|
@@ -19270,6 +19420,7 @@ function createResourcesRouter(jobQueue) {
|
|
|
19270
19420
|
registerGetAnnotation(resourcesRouter2);
|
|
19271
19421
|
registerUpdateAnnotationBody(resourcesRouter2);
|
|
19272
19422
|
registerYieldResourceStream(resourcesRouter2, jobQueue);
|
|
19423
|
+
registerGatherAnnotationStream(resourcesRouter2);
|
|
19273
19424
|
registerGetAnnotationHistory(resourcesRouter2);
|
|
19274
19425
|
registerDeleteAnnotation(resourcesRouter2);
|
|
19275
19426
|
registerGetEvents(resourcesRouter2);
|
|
@@ -19290,7 +19441,7 @@ function registerGetAnnotationUri(router) {
|
|
|
19290
19441
|
router.get("/annotations/:id", async (c) => {
|
|
19291
19442
|
const { id } = c.req.param();
|
|
19292
19443
|
const query = c.req.query();
|
|
19293
|
-
const { kb } = c.get("makeMeaning");
|
|
19444
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
19294
19445
|
const resourceIdParam = query.resourceId;
|
|
19295
19446
|
if (!resourceIdParam) {
|
|
19296
19447
|
throw new HTTPException(400, {
|
|
@@ -19330,9 +19481,9 @@ var operationsRouter = createAnnotationRouter();
|
|
|
19330
19481
|
operationsRouter.get("/api/annotations/:id/context", async (c) => {
|
|
19331
19482
|
const { id } = c.req.param();
|
|
19332
19483
|
const query = c.req.query();
|
|
19333
|
-
const { kb } = c.get("makeMeaning");
|
|
19334
|
-
const
|
|
19335
|
-
if (!
|
|
19484
|
+
const { knowledgeSystem: { kb } } = c.get("makeMeaning");
|
|
19485
|
+
const resourceId20 = query.resourceId;
|
|
19486
|
+
if (!resourceId20) {
|
|
19336
19487
|
throw new HTTPException(400, {
|
|
19337
19488
|
message: "resourceId query parameter is required"
|
|
19338
19489
|
});
|
|
@@ -19350,7 +19501,7 @@ operationsRouter.get("/api/annotations/:id/context", async (c) => {
|
|
|
19350
19501
|
});
|
|
19351
19502
|
}
|
|
19352
19503
|
try {
|
|
19353
|
-
const response = await AnnotationContext.getAnnotationContext(annotationId(id), resourceId(
|
|
19504
|
+
const response = await AnnotationContext.getAnnotationContext(annotationId(id), resourceId(resourceId20), contextBefore, contextAfter, kb);
|
|
19354
19505
|
return c.json(response);
|
|
19355
19506
|
} catch (error) {
|
|
19356
19507
|
if (error instanceof Error && error.message === "Annotation not found") {
|
|
@@ -19379,15 +19530,15 @@ operationsRouter.get("/api/annotations/:id/context", async (c) => {
|
|
|
19379
19530
|
operationsRouter.get("/api/annotations/:id/summary", async (c) => {
|
|
19380
19531
|
const { id } = c.req.param();
|
|
19381
19532
|
const query = c.req.query();
|
|
19382
|
-
const {
|
|
19383
|
-
const
|
|
19384
|
-
if (!
|
|
19533
|
+
const { knowledgeSystem: { gatherer } } = c.get("makeMeaning");
|
|
19534
|
+
const resourceId20 = query.resourceId;
|
|
19535
|
+
if (!resourceId20) {
|
|
19385
19536
|
throw new HTTPException(400, {
|
|
19386
19537
|
message: "resourceId query parameter is required"
|
|
19387
19538
|
});
|
|
19388
19539
|
}
|
|
19389
19540
|
try {
|
|
19390
|
-
const response = await
|
|
19541
|
+
const response = await gatherer.generateAnnotationSummary(annotationId(id), resourceId(resourceId20));
|
|
19391
19542
|
return c.json(response);
|
|
19392
19543
|
} catch (error) {
|
|
19393
19544
|
if (error instanceof Error && error.message === "Annotation not found") {
|
|
@@ -19420,9 +19571,9 @@ entityTypesRouter.use("/api/entity-types/*", authMiddleware);
|
|
|
19420
19571
|
entityTypesRouter.get("/api/entity-types", async (c) => {
|
|
19421
19572
|
const eventBus2 = c.get("eventBus");
|
|
19422
19573
|
const correlationId = crypto.randomUUID();
|
|
19423
|
-
const response = await eventBusRequest(eventBus2, "
|
|
19574
|
+
const response = await eventBusRequest(eventBus2, "browse:entity-types-requested", {
|
|
19424
19575
|
correlationId
|
|
19425
|
-
}, "
|
|
19576
|
+
}, "browse:entity-types-result", "browse:entity-types-failed");
|
|
19426
19577
|
return c.json(response, 200);
|
|
19427
19578
|
});
|
|
19428
19579
|
entityTypesRouter.post("/api/entity-types", validateRequestBody("AddEntityTypeRequest"), async (c) => {
|
|
@@ -19436,7 +19587,7 @@ entityTypesRouter.post("/api/entity-types", validateRequestBody("AddEntityTypeRe
|
|
|
19436
19587
|
const eventBus2 = c.get("eventBus");
|
|
19437
19588
|
eventBus2.get("mark:add-entity-type").next({
|
|
19438
19589
|
tag: body.tag,
|
|
19439
|
-
userId: userId(user
|
|
19590
|
+
userId: userId(userToDid(user))
|
|
19440
19591
|
});
|
|
19441
19592
|
return c.body(null, 202);
|
|
19442
19593
|
});
|
|
@@ -19452,7 +19603,7 @@ entityTypesRouter.post("/api/entity-types/bulk", validateRequestBody("BulkAddEnt
|
|
|
19452
19603
|
for (const tag of body.tags) {
|
|
19453
19604
|
eventBus2.get("mark:add-entity-type").next({
|
|
19454
19605
|
tag,
|
|
19455
|
-
userId: userId(user
|
|
19606
|
+
userId: userId(userToDid(user))
|
|
19456
19607
|
});
|
|
19457
19608
|
}
|
|
19458
19609
|
return c.body(null, 202);
|
|
@@ -19466,7 +19617,7 @@ globalEventsRouter.use("/api/events/stream", authMiddleware);
|
|
|
19466
19617
|
globalEventsRouter.get("/api/events/stream", async (c) => {
|
|
19467
19618
|
const logger2 = getRouteLogger4();
|
|
19468
19619
|
logger2.info("Client connecting to global events stream");
|
|
19469
|
-
const { eventStore } = c.get("makeMeaning");
|
|
19620
|
+
const { knowledgeSystem: { kb: { eventStore } } } = c.get("makeMeaning");
|
|
19470
19621
|
return streamSSE(c, async (stream) => {
|
|
19471
19622
|
await stream.writeSSE({
|
|
19472
19623
|
data: JSON.stringify({
|
|
@@ -19593,11 +19744,11 @@ function createJobsRouter(_jobQueue, authMiddleware2) {
|
|
|
19593
19744
|
__name(createJobsRouter, "createJobsRouter");
|
|
19594
19745
|
|
|
19595
19746
|
// src/routes/participants/attention-channels.ts
|
|
19596
|
-
var
|
|
19747
|
+
var import_rxjs2 = __toESM(require_cjs());
|
|
19597
19748
|
var channels = /* @__PURE__ */ new Map();
|
|
19598
19749
|
function getOrCreateChannel(participantId) {
|
|
19599
19750
|
if (!channels.has(participantId)) {
|
|
19600
|
-
channels.set(participantId, new
|
|
19751
|
+
channels.set(participantId, new import_rxjs2.Subject());
|
|
19601
19752
|
}
|
|
19602
19753
|
return channels.get(participantId);
|
|
19603
19754
|
}
|
|
@@ -19707,6 +19858,46 @@ var participantsRouter = new Hono();
|
|
|
19707
19858
|
participantsRouter.use("/api/participants/*", authMiddleware);
|
|
19708
19859
|
registerBeckon(participantsRouter);
|
|
19709
19860
|
registerAttentionStream(participantsRouter);
|
|
19861
|
+
var browseRouter = new Hono();
|
|
19862
|
+
browseRouter.use("/api/browse/*", authMiddleware);
|
|
19863
|
+
browseRouter.get("/api/browse/files", async (c) => {
|
|
19864
|
+
const reqPath = c.req.query("path") ?? "";
|
|
19865
|
+
const sort = c.req.query("sort");
|
|
19866
|
+
if (sort !== void 0 && sort !== "name" && sort !== "mtime" && sort !== "annotationCount") {
|
|
19867
|
+
throw new HTTPException(400, {
|
|
19868
|
+
message: 'Invalid sort value. Must be "name", "mtime", or "annotationCount".'
|
|
19869
|
+
});
|
|
19870
|
+
}
|
|
19871
|
+
const eventBus2 = c.get("eventBus");
|
|
19872
|
+
const correlationId = crypto.randomUUID();
|
|
19873
|
+
try {
|
|
19874
|
+
const response = await eventBusRequest(eventBus2, "browse:directory-requested", {
|
|
19875
|
+
correlationId,
|
|
19876
|
+
path: reqPath,
|
|
19877
|
+
sort
|
|
19878
|
+
}, "browse:directory-result", "browse:directory-failed");
|
|
19879
|
+
return c.json(response);
|
|
19880
|
+
} catch (error) {
|
|
19881
|
+
if (error instanceof Error) {
|
|
19882
|
+
if (error.name === "TimeoutError") {
|
|
19883
|
+
throw new HTTPException(504, {
|
|
19884
|
+
message: "Request timed out"
|
|
19885
|
+
});
|
|
19886
|
+
}
|
|
19887
|
+
if (error.message === "path not found") {
|
|
19888
|
+
throw new HTTPException(404, {
|
|
19889
|
+
message: error.message
|
|
19890
|
+
});
|
|
19891
|
+
}
|
|
19892
|
+
if (error.message === "path escapes project root") {
|
|
19893
|
+
throw new HTTPException(400, {
|
|
19894
|
+
message: error.message
|
|
19895
|
+
});
|
|
19896
|
+
}
|
|
19897
|
+
}
|
|
19898
|
+
throw error;
|
|
19899
|
+
}
|
|
19900
|
+
});
|
|
19710
19901
|
|
|
19711
19902
|
// src/middleware/security-headers.ts
|
|
19712
19903
|
var securityHeaders = /* @__PURE__ */ __name(() => {
|
|
@@ -19873,6 +20064,7 @@ app.route("/", globalEventsRouter);
|
|
|
19873
20064
|
var jobsRouter = createJobsRouter(makeMeaning.jobQueue, authMiddleware);
|
|
19874
20065
|
app.route("/", jobsRouter);
|
|
19875
20066
|
app.route("/", participantsRouter);
|
|
20067
|
+
app.route("/", browseRouter);
|
|
19876
20068
|
app.get("/api", (c) => {
|
|
19877
20069
|
const acceptHeader = c.req.header("Accept") || "";
|
|
19878
20070
|
const userAgent = c.req.header("User-Agent") || "";
|
|
@@ -19885,7 +20077,8 @@ app.get("/api", (c) => {
|
|
|
19885
20077
|
return c.redirect(redirectUrl);
|
|
19886
20078
|
});
|
|
19887
20079
|
app.get("/api/openapi.json", (c) => {
|
|
19888
|
-
const
|
|
20080
|
+
const distPath = path.join(__dirname$1, "openapi.json");
|
|
20081
|
+
const openApiPath = fs.existsSync(distPath) ? distPath : path.join(__dirname$1, "../../../specs/openapi.json");
|
|
19889
20082
|
const openApiContent = fs.readFileSync(openApiPath, "utf-8");
|
|
19890
20083
|
const openApiSpec = JSON.parse(openApiContent);
|
|
19891
20084
|
const port2 = backendService.port || 4e3;
|
|
@@ -19952,7 +20145,7 @@ if (config.env?.NODE_ENV !== "test") {
|
|
|
19952
20145
|
});
|
|
19953
20146
|
}
|
|
19954
20147
|
try {
|
|
19955
|
-
const entityTypes = await makeMeaning.
|
|
20148
|
+
const entityTypes = await makeMeaning.knowledgeSystem.kb.graph.getEntityTypes();
|
|
19956
20149
|
logger.info("Loaded entity types from graph database", {
|
|
19957
20150
|
count: entityTypes.length
|
|
19958
20151
|
});
|