aparavi-client 1.0.2
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/LICENSE +21 -0
- package/README.md +523 -0
- package/dist/aparavi-client-typescript-1.0.0.tgz +0 -0
- package/dist/aparavi-client-typescript-1.0.1.tgz +0 -0
- package/dist/cjs/client.js +1002 -0
- package/dist/cjs/client.js.map +1 -0
- package/dist/cjs/constants.js +37 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/core/DAPBase.js +313 -0
- package/dist/cjs/core/DAPBase.js.map +1 -0
- package/dist/cjs/core/DAPClient.js +173 -0
- package/dist/cjs/core/DAPClient.js.map +1 -0
- package/dist/cjs/core/TransportBase.js +131 -0
- package/dist/cjs/core/TransportBase.js.map +1 -0
- package/dist/cjs/core/TransportWebSocket.js +492 -0
- package/dist/cjs/core/TransportWebSocket.js.map +1 -0
- package/dist/cjs/exceptions/index.js +109 -0
- package/dist/cjs/exceptions/index.js.map +1 -0
- package/dist/cjs/index.js +56 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/package.json +3 -0
- package/dist/cjs/schema/Doc.js +79 -0
- package/dist/cjs/schema/Doc.js.map +1 -0
- package/dist/cjs/schema/DocFilter.js +133 -0
- package/dist/cjs/schema/DocFilter.js.map +1 -0
- package/dist/cjs/schema/DocGroup.js +235 -0
- package/dist/cjs/schema/DocGroup.js.map +1 -0
- package/dist/cjs/schema/DocMetadata.js +57 -0
- package/dist/cjs/schema/DocMetadata.js.map +1 -0
- package/dist/cjs/schema/Question.js +414 -0
- package/dist/cjs/schema/Question.js.map +1 -0
- package/dist/cjs/schema/index.js +50 -0
- package/dist/cjs/schema/index.js.map +1 -0
- package/dist/cjs/types/client.js +26 -0
- package/dist/cjs/types/client.js.map +1 -0
- package/dist/cjs/types/data.js +26 -0
- package/dist/cjs/types/data.js.map +1 -0
- package/dist/cjs/types/events.js +119 -0
- package/dist/cjs/types/events.js.map +1 -0
- package/dist/cjs/types/index.js +50 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/pipeline.js +26 -0
- package/dist/cjs/types/pipeline.js.map +1 -0
- package/dist/cjs/types/task.js +115 -0
- package/dist/cjs/types/task.js.map +1 -0
- package/dist/cli/cli/aparavi.js +1401 -0
- package/dist/cli/cli/aparavi.js.map +1 -0
- package/dist/cli/src/client.js +1002 -0
- package/dist/cli/src/client.js.map +1 -0
- package/dist/cli/src/constants.js +37 -0
- package/dist/cli/src/constants.js.map +1 -0
- package/dist/cli/src/core/DAPBase.js +313 -0
- package/dist/cli/src/core/DAPBase.js.map +1 -0
- package/dist/cli/src/core/DAPClient.js +173 -0
- package/dist/cli/src/core/DAPClient.js.map +1 -0
- package/dist/cli/src/core/TransportBase.js +131 -0
- package/dist/cli/src/core/TransportBase.js.map +1 -0
- package/dist/cli/src/core/TransportWebSocket.js +492 -0
- package/dist/cli/src/core/TransportWebSocket.js.map +1 -0
- package/dist/cli/src/exceptions/index.js +109 -0
- package/dist/cli/src/exceptions/index.js.map +1 -0
- package/dist/cli/src/index.js +56 -0
- package/dist/cli/src/index.js.map +1 -0
- package/dist/cli/src/schema/Doc.js +79 -0
- package/dist/cli/src/schema/Doc.js.map +1 -0
- package/dist/cli/src/schema/DocFilter.js +133 -0
- package/dist/cli/src/schema/DocFilter.js.map +1 -0
- package/dist/cli/src/schema/DocGroup.js +235 -0
- package/dist/cli/src/schema/DocGroup.js.map +1 -0
- package/dist/cli/src/schema/DocMetadata.js +57 -0
- package/dist/cli/src/schema/DocMetadata.js.map +1 -0
- package/dist/cli/src/schema/Question.js +414 -0
- package/dist/cli/src/schema/Question.js.map +1 -0
- package/dist/cli/src/schema/index.js +50 -0
- package/dist/cli/src/schema/index.js.map +1 -0
- package/dist/cli/src/types/client.js +26 -0
- package/dist/cli/src/types/client.js.map +1 -0
- package/dist/cli/src/types/data.js +26 -0
- package/dist/cli/src/types/data.js.map +1 -0
- package/dist/cli/src/types/events.js +119 -0
- package/dist/cli/src/types/events.js.map +1 -0
- package/dist/cli/src/types/index.js +50 -0
- package/dist/cli/src/types/index.js.map +1 -0
- package/dist/cli/src/types/pipeline.js +26 -0
- package/dist/cli/src/types/pipeline.js.map +1 -0
- package/dist/cli/src/types/task.js +115 -0
- package/dist/cli/src/types/task.js.map +1 -0
- package/dist/esm/client.js +997 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/constants.js +34 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/core/DAPBase.js +309 -0
- package/dist/esm/core/DAPBase.js.map +1 -0
- package/dist/esm/core/DAPClient.js +169 -0
- package/dist/esm/core/DAPClient.js.map +1 -0
- package/dist/esm/core/TransportBase.js +127 -0
- package/dist/esm/core/TransportBase.js.map +1 -0
- package/dist/esm/core/TransportWebSocket.js +488 -0
- package/dist/esm/core/TransportWebSocket.js.map +1 -0
- package/dist/esm/exceptions/index.js +100 -0
- package/dist/esm/exceptions/index.js.map +1 -0
- package/dist/esm/index.js +40 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/schema/Doc.js +75 -0
- package/dist/esm/schema/Doc.js.map +1 -0
- package/dist/esm/schema/DocFilter.js +129 -0
- package/dist/esm/schema/DocFilter.js.map +1 -0
- package/dist/esm/schema/DocGroup.js +231 -0
- package/dist/esm/schema/DocGroup.js.map +1 -0
- package/dist/esm/schema/DocMetadata.js +53 -0
- package/dist/esm/schema/DocMetadata.js.map +1 -0
- package/dist/esm/schema/Question.js +409 -0
- package/dist/esm/schema/Question.js.map +1 -0
- package/dist/esm/schema/index.js +34 -0
- package/dist/esm/schema/index.js.map +1 -0
- package/dist/esm/types/client.js +25 -0
- package/dist/esm/types/client.js.map +1 -0
- package/dist/esm/types/data.js +25 -0
- package/dist/esm/types/data.js.map +1 -0
- package/dist/esm/types/events.js +116 -0
- package/dist/esm/types/events.js.map +1 -0
- package/dist/esm/types/index.js +34 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/pipeline.js +25 -0
- package/dist/esm/types/pipeline.js.map +1 -0
- package/dist/esm/types/task.js +112 -0
- package/dist/esm/types/task.js.map +1 -0
- package/dist/types/client.d.ts +395 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/constants.d.ts +34 -0
- package/dist/types/constants.d.ts.map +1 -0
- package/dist/types/core/DAPBase.d.ts +140 -0
- package/dist/types/core/DAPBase.d.ts.map +1 -0
- package/dist/types/core/DAPClient.d.ts +83 -0
- package/dist/types/core/DAPClient.d.ts.map +1 -0
- package/dist/types/core/TransportBase.d.ts +94 -0
- package/dist/types/core/TransportBase.d.ts.map +1 -0
- package/dist/types/core/TransportWebSocket.d.ts +78 -0
- package/dist/types/core/TransportWebSocket.d.ts.map +1 -0
- package/dist/types/exceptions/index.d.ts +81 -0
- package/dist/types/exceptions/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +36 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/schema/Doc.d.ts +69 -0
- package/dist/types/schema/Doc.d.ts.map +1 -0
- package/dist/types/schema/DocFilter.d.ts +101 -0
- package/dist/types/schema/DocFilter.d.ts.map +1 -0
- package/dist/types/schema/DocGroup.d.ts +113 -0
- package/dist/types/schema/DocGroup.d.ts.map +1 -0
- package/dist/types/schema/DocMetadata.d.ts +61 -0
- package/dist/types/schema/DocMetadata.d.ts.map +1 -0
- package/dist/types/schema/Question.d.ts +163 -0
- package/dist/types/schema/Question.d.ts.map +1 -0
- package/dist/types/schema/index.d.ts +34 -0
- package/dist/types/schema/index.d.ts.map +1 -0
- package/dist/types/types/client.d.ts +140 -0
- package/dist/types/types/client.d.ts.map +1 -0
- package/dist/types/types/data.d.ts +95 -0
- package/dist/types/types/data.d.ts.map +1 -0
- package/dist/types/types/events.d.ts +246 -0
- package/dist/types/types/events.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +34 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/pipeline.d.ts +61 -0
- package/dist/types/types/pipeline.d.ts.map +1 -0
- package/dist/types/types/task.d.ts +265 -0
- package/dist/types/types/task.d.ts.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.ValidationException = exports.ExecutionException = exports.PipeException = exports.ConnectionException = exports.AparaviException = exports.DAPException = void 0;
|
|
27
|
+
/**
|
|
28
|
+
* Base exception class for Debug Adapter Protocol (DAP) errors.
|
|
29
|
+
*
|
|
30
|
+
* This exception wraps DAP error responses to provide structured access to
|
|
31
|
+
* error information including file locations, line numbers, and other
|
|
32
|
+
* contextual data returned by Aparavi servers.
|
|
33
|
+
*/
|
|
34
|
+
class DAPException extends Error {
|
|
35
|
+
constructor(dapResult) {
|
|
36
|
+
const errorMessage = dapResult.message || 'Unknown DAP error';
|
|
37
|
+
super(errorMessage);
|
|
38
|
+
this.name = 'DAPException';
|
|
39
|
+
this.dapResult = dapResult || {};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.DAPException = DAPException;
|
|
43
|
+
/**
|
|
44
|
+
* Base exception for all Aparavi operations.
|
|
45
|
+
*
|
|
46
|
+
* This is the root exception class for all Aparavi-specific errors.
|
|
47
|
+
* Catch this exception type to handle any error that originates from
|
|
48
|
+
* Aparavi operations while still having access to detailed error context.
|
|
49
|
+
*/
|
|
50
|
+
class AparaviException extends DAPException {
|
|
51
|
+
constructor(dapResult) {
|
|
52
|
+
super(dapResult);
|
|
53
|
+
this.name = 'AparaviException';
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
exports.AparaviException = AparaviException;
|
|
57
|
+
/**
|
|
58
|
+
* Exception raised for connection-related issues.
|
|
59
|
+
*
|
|
60
|
+
* Raised when there are problems connecting to Aparavi servers,
|
|
61
|
+
* maintaining connections, or when connections are lost unexpectedly.
|
|
62
|
+
*/
|
|
63
|
+
class ConnectionException extends AparaviException {
|
|
64
|
+
constructor(dapResult) {
|
|
65
|
+
super(dapResult);
|
|
66
|
+
this.name = 'ConnectionException';
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.ConnectionException = ConnectionException;
|
|
70
|
+
/**
|
|
71
|
+
* Exception raised for data pipe operations.
|
|
72
|
+
*
|
|
73
|
+
* Raised when there are problems with data pipes used for sending
|
|
74
|
+
* data to pipelines, uploading files, or streaming operations.
|
|
75
|
+
*/
|
|
76
|
+
class PipeException extends AparaviException {
|
|
77
|
+
constructor(dapResult) {
|
|
78
|
+
super(dapResult);
|
|
79
|
+
this.name = 'PipeException';
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
exports.PipeException = PipeException;
|
|
83
|
+
/**
|
|
84
|
+
* Exception raised for pipeline execution issues.
|
|
85
|
+
*
|
|
86
|
+
* Raised when there are problems starting, running, or managing
|
|
87
|
+
* Aparavi pipelines and processing tasks.
|
|
88
|
+
*/
|
|
89
|
+
class ExecutionException extends AparaviException {
|
|
90
|
+
constructor(dapResult) {
|
|
91
|
+
super(dapResult);
|
|
92
|
+
this.name = 'ExecutionException';
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
exports.ExecutionException = ExecutionException;
|
|
96
|
+
/**
|
|
97
|
+
* Exception raised for input validation failures.
|
|
98
|
+
*
|
|
99
|
+
* Raised when input data, configurations, or parameters don't meet
|
|
100
|
+
* the requirements for Aparavi operations.
|
|
101
|
+
*/
|
|
102
|
+
class ValidationException extends AparaviException {
|
|
103
|
+
constructor(dapResult) {
|
|
104
|
+
super(dapResult);
|
|
105
|
+
this.name = 'ValidationException';
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.ValidationException = ValidationException;
|
|
109
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../aparavi-client/src/exceptions/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAEH;;;;;;GAMG;AACH,MAAa,YAAa,SAAQ,KAAK;IAGtC,YAAY,SAA8B;QACzC,MAAM,YAAY,GAAG,SAAS,CAAC,OAAO,IAAI,mBAAmB,CAAC;QAC9D,KAAK,CAAC,YAAY,CAAC,CAAC;QACpB,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,SAAS,GAAG,SAAS,IAAI,EAAE,CAAC;IAClC,CAAC;CACD;AATD,oCASC;AAED;;;;;;GAMG;AACH,MAAa,gBAAiB,SAAQ,YAAY;IACjD,YAAY,SAA8B;QACzC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IAChC,CAAC;CACD;AALD,4CAKC;AAED;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,gBAAgB;IACxD,YAAY,SAA8B;QACzC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,CAAC;CACD;AALD,kDAKC;AAED;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,gBAAgB;IAClD,YAAY,SAA8B;QACzC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC7B,CAAC;CACD;AALD,sCAKC;AAED;;;;;GAKG;AACH,MAAa,kBAAmB,SAAQ,gBAAgB;IACvD,YAAY,SAA8B;QACzC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IAClC,CAAC;CACD;AALD,gDAKC;AAED;;;;;GAKG;AACH,MAAa,mBAAoB,SAAQ,gBAAgB;IACxD,YAAY,SAA8B;QACzC,KAAK,CAAC,SAAS,CAAC,CAAC;QACjB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACnC,CAAC;CACD;AALD,kDAKC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
26
|
+
if (k2 === undefined) k2 = k;
|
|
27
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
28
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
29
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
30
|
+
}
|
|
31
|
+
Object.defineProperty(o, k2, desc);
|
|
32
|
+
}) : (function(o, m, k, k2) {
|
|
33
|
+
if (k2 === undefined) k2 = k;
|
|
34
|
+
o[k2] = m[k];
|
|
35
|
+
}));
|
|
36
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
37
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
38
|
+
};
|
|
39
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
/**
|
|
41
|
+
* Aparavi Client TypeScript SDK
|
|
42
|
+
*
|
|
43
|
+
* Main entry point for the Aparavi TypeScript client library.
|
|
44
|
+
* Exports all public APIs, types, exceptions, and schema definitions.
|
|
45
|
+
*
|
|
46
|
+
* @packageDocumentation
|
|
47
|
+
*/
|
|
48
|
+
// Export all exceptions
|
|
49
|
+
__exportStar(require("./exceptions"), exports);
|
|
50
|
+
// Export all schema classes
|
|
51
|
+
__exportStar(require("./schema"), exports);
|
|
52
|
+
// Export all type definitions
|
|
53
|
+
__exportStar(require("./types"), exports);
|
|
54
|
+
// Export the main client and utilities
|
|
55
|
+
__exportStar(require("./client"), exports);
|
|
56
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../aparavi-client/src/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;;;;;;;;;;;;;;AAEH;;;;;;;GAOG;AAEH,wBAAwB;AACxB,+CAA6B;AAE7B,4BAA4B;AAC5B,2CAAyB;AAEzB,8BAA8B;AAC9B,0CAAwB;AAExB,uCAAuC;AACvC,2CAAyB"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DocHelper = void 0;
|
|
27
|
+
class DocHelper {
|
|
28
|
+
/**
|
|
29
|
+
* Create a readable string representation showing the key identifiers and relevance score.
|
|
30
|
+
*/
|
|
31
|
+
static toString(doc) {
|
|
32
|
+
return `Document(${doc.metadata?.objectId}.${doc.metadata?.chunkId}=${doc.score})`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Convert this document to a dictionary for serialization or storage.
|
|
36
|
+
*/
|
|
37
|
+
static toDict(doc) {
|
|
38
|
+
const result = {};
|
|
39
|
+
for (const [key, value] of Object.entries(doc)) {
|
|
40
|
+
if (value !== undefined && value !== null) {
|
|
41
|
+
result[key] = value;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return result;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Create a Document from a dictionary (reverse of toDict).
|
|
48
|
+
*/
|
|
49
|
+
static fromDict(data) {
|
|
50
|
+
return {
|
|
51
|
+
type: data.type || 'Document',
|
|
52
|
+
page_content: data.page_content,
|
|
53
|
+
embedding_model: data.embedding_model,
|
|
54
|
+
embedding: data.embedding,
|
|
55
|
+
score: data.score,
|
|
56
|
+
highlight_score: data.highlight_score,
|
|
57
|
+
context: data.context,
|
|
58
|
+
tokens: data.tokens,
|
|
59
|
+
metadata: data.metadata,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Create a new document with default values.
|
|
64
|
+
*/
|
|
65
|
+
static create(content, metadata) {
|
|
66
|
+
return {
|
|
67
|
+
type: 'Document',
|
|
68
|
+
page_content: content,
|
|
69
|
+
score: 0,
|
|
70
|
+
metadata: {
|
|
71
|
+
objectId: '',
|
|
72
|
+
chunkId: 0,
|
|
73
|
+
...metadata,
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
exports.DocHelper = DocHelper;
|
|
79
|
+
//# sourceMappingURL=Doc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Doc.js","sourceRoot":"","sources":["../../../../aparavi-client/src/schema/Doc.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAuCH,MAAa,SAAS;IACrB;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,GAAQ;QACvB,OAAO,YAAY,GAAG,CAAC,QAAQ,EAAE,QAAQ,IAAI,GAAG,CAAC,QAAQ,EAAE,OAAO,IAAI,GAAG,CAAC,KAAK,GAAG,CAAC;IACpF,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,GAAQ;QACrB,MAAM,MAAM,GAAwB,EAAE,CAAC;QAEvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;YAChD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;gBAC3C,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACrB,CAAC;QACF,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAyB;QACxC,OAAO;YACN,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,UAAU;YAC7B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACvB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,MAAM,CAAC,OAAe,EAAE,QAA+B;QAC7D,OAAO;YACN,IAAI,EAAE,UAAU;YAChB,YAAY,EAAE,OAAO;YACrB,KAAK,EAAE,CAAC;YACR,QAAQ,EAAE;gBACT,QAAQ,EAAE,EAAE;gBACZ,OAAO,EAAE,CAAC;gBACV,GAAG,QAAQ;aACX;SACD,CAAC;IACH,CAAC;CACD;AAvDD,8BAuDC"}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DocFilterHelper = void 0;
|
|
27
|
+
class DocFilterHelper {
|
|
28
|
+
/**
|
|
29
|
+
* Create a default DocFilter with sensible defaults.
|
|
30
|
+
*/
|
|
31
|
+
static createDefault() {
|
|
32
|
+
return {
|
|
33
|
+
fullTables: false,
|
|
34
|
+
fullDocuments: false,
|
|
35
|
+
offset: 0,
|
|
36
|
+
limit: 25,
|
|
37
|
+
useQuickRank: false,
|
|
38
|
+
useGroupRank: false,
|
|
39
|
+
followUpQuestions: 5,
|
|
40
|
+
context: false,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Create a DocFilter for paginated table results.
|
|
45
|
+
*/
|
|
46
|
+
static forTables(limit = 20, offset = 0) {
|
|
47
|
+
return {
|
|
48
|
+
...DocFilterHelper.createDefault(),
|
|
49
|
+
isTable: true,
|
|
50
|
+
fullTables: true,
|
|
51
|
+
limit,
|
|
52
|
+
offset,
|
|
53
|
+
useQuickRank: true,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Create a DocFilter for complete documents.
|
|
58
|
+
*/
|
|
59
|
+
static forFullDocuments(limit = 10) {
|
|
60
|
+
return {
|
|
61
|
+
...DocFilterHelper.createDefault(),
|
|
62
|
+
fullDocuments: true,
|
|
63
|
+
limit,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Create a DocFilter with AI enhancements enabled.
|
|
68
|
+
*/
|
|
69
|
+
static withAIEnhancements() {
|
|
70
|
+
return {
|
|
71
|
+
...DocFilterHelper.createDefault(),
|
|
72
|
+
useQuickRank: true,
|
|
73
|
+
useGroupRank: true,
|
|
74
|
+
context: true,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate that a DocFilter has reasonable values.
|
|
79
|
+
*/
|
|
80
|
+
static validate(filter) {
|
|
81
|
+
const errors = [];
|
|
82
|
+
if (filter.limit !== undefined && (filter.limit < 1 || filter.limit > 1000)) {
|
|
83
|
+
errors.push('Limit must be between 1 and 1000');
|
|
84
|
+
}
|
|
85
|
+
if (filter.offset !== undefined && filter.offset < 0) {
|
|
86
|
+
errors.push('Offset must be non-negative');
|
|
87
|
+
}
|
|
88
|
+
if (filter.followUpQuestions !== undefined && filter.followUpQuestions < 0) {
|
|
89
|
+
errors.push('Follow-up questions count must be non-negative');
|
|
90
|
+
}
|
|
91
|
+
return errors;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Convert DocFilter to dictionary for serialization.
|
|
95
|
+
*/
|
|
96
|
+
static toDict(filter) {
|
|
97
|
+
const result = {};
|
|
98
|
+
for (const [key, value] of Object.entries(filter)) {
|
|
99
|
+
if (value !== undefined && value !== null) {
|
|
100
|
+
result[key] = value;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Create DocFilter from dictionary.
|
|
107
|
+
*/
|
|
108
|
+
static fromDict(data) {
|
|
109
|
+
return {
|
|
110
|
+
fullTables: data.fullTables,
|
|
111
|
+
fullDocuments: data.fullDocuments,
|
|
112
|
+
offset: data.offset,
|
|
113
|
+
limit: data.limit,
|
|
114
|
+
minChunkId: data.minChunkId,
|
|
115
|
+
maxChunkId: data.maxChunkId,
|
|
116
|
+
nodeId: data.nodeId,
|
|
117
|
+
parent: data.parent,
|
|
118
|
+
name: data.name,
|
|
119
|
+
permissions: data.permissions,
|
|
120
|
+
isDeleted: data.isDeleted,
|
|
121
|
+
objectIds: data.objectIds,
|
|
122
|
+
chunkIds: data.chunkIds,
|
|
123
|
+
isTable: data.isTable,
|
|
124
|
+
tableIds: data.tableIds,
|
|
125
|
+
useQuickRank: data.useQuickRank,
|
|
126
|
+
useGroupRank: data.useGroupRank,
|
|
127
|
+
followUpQuestions: data.followUpQuestions,
|
|
128
|
+
context: data.context,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
exports.DocFilterHelper = DocFilterHelper;
|
|
133
|
+
//# sourceMappingURL=DocFilter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocFilter.js","sourceRoot":"","sources":["../../../../aparavi-client/src/schema/DocFilter.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AAoEH,MAAa,eAAe;IAC3B;;OAEG;IACH,MAAM,CAAC,aAAa;QACnB,OAAO;YACN,UAAU,EAAE,KAAK;YACjB,aAAa,EAAE,KAAK;YACpB,MAAM,EAAE,CAAC;YACT,KAAK,EAAE,EAAE;YACT,YAAY,EAAE,KAAK;YACnB,YAAY,EAAE,KAAK;YACnB,iBAAiB,EAAE,CAAC;YACpB,OAAO,EAAE,KAAK;SACd,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,KAAK,GAAG,EAAE,EAAE,MAAM,GAAG,CAAC;QACtC,OAAO;YACN,GAAG,eAAe,CAAC,aAAa,EAAE;YAClC,OAAO,EAAE,IAAI;YACb,UAAU,EAAE,IAAI;YAChB,KAAK;YACL,MAAM;YACN,YAAY,EAAE,IAAI;SAClB,CAAC;IACH,CAAC;I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;gBAC3C,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;YACrB,CAAC;QACF,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAyB;QACxC,OAAO;YACN,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;YAC3B,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,YAAY,EAAE,IAAI,CAAC,YAAY;YAC/B,iBAAiB,EAAE,IAAI,CAAC,iBAAiB;YACzC,OAAO,EAAE,IAAI,CAAC,OAAO;SACrB,CAAC;IACH,CAAC;CACD;AApHD,0CAoHC"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* MIT License
|
|
4
|
+
*
|
|
5
|
+
* Copyright (c) 2024 Aparavi Development Team
|
|
6
|
+
*
|
|
7
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
* in the Software without restriction, including without limitation the rights
|
|
10
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
* furnished to do so, subject to the following conditions:
|
|
13
|
+
*
|
|
14
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
* copies or substantial portions of the Software.
|
|
16
|
+
*
|
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
* SOFTWARE.
|
|
24
|
+
*/
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
exports.DocGroupHelper = void 0;
|
|
27
|
+
class DocGroupHelper {
|
|
28
|
+
/**
|
|
29
|
+
* Create a readable string representation showing the filename and relevance score.
|
|
30
|
+
*/
|
|
31
|
+
static toString(group) {
|
|
32
|
+
const filename = group.parent.split('/').pop() || group.parent;
|
|
33
|
+
return `${filename}=${group.score}`;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a new DocGroup.
|
|
37
|
+
*/
|
|
38
|
+
static create(objectId, parent, documents = [], score = 0) {
|
|
39
|
+
return {
|
|
40
|
+
score,
|
|
41
|
+
objectId,
|
|
42
|
+
parent,
|
|
43
|
+
documents,
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Add a document to the group and update the score.
|
|
48
|
+
*/
|
|
49
|
+
static addDocument(group, doc) {
|
|
50
|
+
const newDocuments = [...group.documents, doc];
|
|
51
|
+
// Recalculate group score - use the maximum score from all documents
|
|
52
|
+
const newScore = Math.max(group.score, doc.score || 0);
|
|
53
|
+
return {
|
|
54
|
+
...group,
|
|
55
|
+
documents: newDocuments,
|
|
56
|
+
score: newScore,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Get the total content from all documents in the group.
|
|
61
|
+
*/
|
|
62
|
+
static getFullContent(group) {
|
|
63
|
+
return group.documents
|
|
64
|
+
.map(doc => doc.page_content || '')
|
|
65
|
+
.join('\n');
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Get the highest scoring document in the group.
|
|
69
|
+
*/
|
|
70
|
+
static getBestDocument(group) {
|
|
71
|
+
if (group.documents.length === 0) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
return group.documents.reduce((best, current) => {
|
|
75
|
+
const bestScore = best.score || 0;
|
|
76
|
+
const currentScore = current.score || 0;
|
|
77
|
+
return currentScore > bestScore ? current : best;
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Sort documents in the group by score (highest first) or chunk ID.
|
|
82
|
+
*/
|
|
83
|
+
static sortDocuments(group, sortBy = 'score') {
|
|
84
|
+
const sortedDocuments = [...group.documents].sort((a, b) => {
|
|
85
|
+
if (sortBy === 'score') {
|
|
86
|
+
const scoreA = a.score || 0;
|
|
87
|
+
const scoreB = b.score || 0;
|
|
88
|
+
return scoreB - scoreA; // Highest first
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
const chunkA = a.metadata?.chunkId || 0;
|
|
92
|
+
const chunkB = b.metadata?.chunkId || 0;
|
|
93
|
+
return chunkA - chunkB; // Lowest first
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
return {
|
|
97
|
+
...group,
|
|
98
|
+
documents: sortedDocuments,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Filter documents in the group by score threshold.
|
|
103
|
+
*/
|
|
104
|
+
static filterByScore(group, minScore) {
|
|
105
|
+
const filteredDocuments = group.documents.filter(doc => (doc.score || 0) >= minScore);
|
|
106
|
+
return {
|
|
107
|
+
...group,
|
|
108
|
+
documents: filteredDocuments,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get document count in the group.
|
|
113
|
+
*/
|
|
114
|
+
static getDocumentCount(group) {
|
|
115
|
+
return group.documents.length;
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Get total tokens count for all documents in the group.
|
|
119
|
+
*/
|
|
120
|
+
static getTotalTokens(group) {
|
|
121
|
+
return group.documents.reduce((total, doc) => total + (doc.tokens || 0), 0);
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Get average score of documents in the group.
|
|
125
|
+
*/
|
|
126
|
+
static getAverageScore(group) {
|
|
127
|
+
if (group.documents.length === 0) {
|
|
128
|
+
return 0;
|
|
129
|
+
}
|
|
130
|
+
const totalScore = group.documents.reduce((sum, doc) => sum + (doc.score || 0), 0);
|
|
131
|
+
return totalScore / group.documents.length;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Check if group contains table data.
|
|
135
|
+
*/
|
|
136
|
+
static hasTableData(group) {
|
|
137
|
+
return group.documents.some(doc => doc.metadata?.isTable === true);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Get only table documents from the group.
|
|
141
|
+
*/
|
|
142
|
+
static getTableDocuments(group) {
|
|
143
|
+
return group.documents.filter(doc => doc.metadata?.isTable === true);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Get only text documents from the group.
|
|
147
|
+
*/
|
|
148
|
+
static getTextDocuments(group) {
|
|
149
|
+
return group.documents.filter(doc => doc.metadata?.isTable !== true);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Convert DocGroup to dictionary for serialization.
|
|
153
|
+
*/
|
|
154
|
+
static toDict(group) {
|
|
155
|
+
return {
|
|
156
|
+
score: group.score,
|
|
157
|
+
objectId: group.objectId,
|
|
158
|
+
parent: group.parent,
|
|
159
|
+
documents: group.documents.map(doc => {
|
|
160
|
+
// Use Doc helper if available, otherwise convert directly
|
|
161
|
+
if (typeof doc.toDict === 'function') {
|
|
162
|
+
return doc.toDict();
|
|
163
|
+
}
|
|
164
|
+
return doc;
|
|
165
|
+
}),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Create DocGroup from dictionary.
|
|
170
|
+
*/
|
|
171
|
+
static fromDict(data) {
|
|
172
|
+
return {
|
|
173
|
+
score: data.score || 0,
|
|
174
|
+
objectId: data.objectId || '',
|
|
175
|
+
parent: data.parent || '',
|
|
176
|
+
documents: (data.documents || []).map((docData) => {
|
|
177
|
+
// Convert back to Doc if needed
|
|
178
|
+
if (typeof docData === 'object' && docData !== null) {
|
|
179
|
+
return docData;
|
|
180
|
+
}
|
|
181
|
+
return docData;
|
|
182
|
+
}),
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Merge multiple DocGroups from the same source document.
|
|
187
|
+
*/
|
|
188
|
+
static merge(groups) {
|
|
189
|
+
if (groups.length === 0) {
|
|
190
|
+
return undefined;
|
|
191
|
+
}
|
|
192
|
+
if (groups.length === 1) {
|
|
193
|
+
return groups[0];
|
|
194
|
+
}
|
|
195
|
+
// Ensure all groups are from the same document
|
|
196
|
+
const firstGroup = groups[0];
|
|
197
|
+
const sameSource = groups.every(group => group.objectId === firstGroup.objectId);
|
|
198
|
+
if (!sameSource) {
|
|
199
|
+
throw new Error('Cannot merge DocGroups from different source documents');
|
|
200
|
+
}
|
|
201
|
+
// Merge all documents
|
|
202
|
+
const allDocuments = groups.flatMap(group => group.documents);
|
|
203
|
+
// Use the highest score
|
|
204
|
+
const maxScore = Math.max(...groups.map(group => group.score));
|
|
205
|
+
return {
|
|
206
|
+
score: maxScore,
|
|
207
|
+
objectId: firstGroup.objectId,
|
|
208
|
+
parent: firstGroup.parent,
|
|
209
|
+
documents: allDocuments,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Split a DocGroup into smaller groups by chunk ranges.
|
|
214
|
+
*/
|
|
215
|
+
static splitByChunkRange(group, chunkSize) {
|
|
216
|
+
if (chunkSize <= 0) {
|
|
217
|
+
throw new Error('Chunk size must be positive');
|
|
218
|
+
}
|
|
219
|
+
const sortedGroup = DocGroupHelper.sortDocuments(group, 'chunkId');
|
|
220
|
+
const result = [];
|
|
221
|
+
for (let i = 0; i < sortedGroup.documents.length; i += chunkSize) {
|
|
222
|
+
const chunkDocuments = sortedGroup.documents.slice(i, i + chunkSize);
|
|
223
|
+
const chunkScore = Math.max(...chunkDocuments.map(doc => doc.score || 0));
|
|
224
|
+
result.push({
|
|
225
|
+
score: chunkScore,
|
|
226
|
+
objectId: group.objectId,
|
|
227
|
+
parent: group.parent,
|
|
228
|
+
documents: chunkDocuments,
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
return result;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
exports.DocGroupHelper = DocGroupHelper;
|
|
235
|
+
//# sourceMappingURL=DocGroup.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DocGroup.js","sourceRoot":"","sources":["../../../../aparavi-client/src/schema/DocGroup.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;;;AA0BH,MAAa,cAAc;IAC1B;;OAEG;IACH,MAAM,CAAC,QAAQ,CAAC,KAAe;QAC9B,MAAM,QAAQ,GAAG,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,IAAI,KAAK,CAAC,MAAM,CAAC;QAC/D,OAAO,GAAG,QAAQ,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;IACrC,CAAC;IAED;;OA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