@xpert-ai/plugin-sdk 3.6.0 → 3.6.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/index.cjs.d.ts +1 -0
- package/index.cjs.js +65517 -4
- package/index.esm.d.ts +1 -0
- package/index.esm.js +65419 -0
- package/package.json +4 -4
- package/src/index.d.ts +13 -0
- package/src/lib/ai-model/abstract-provider.d.ts +41 -0
- package/src/lib/ai-model/ai-model-provider.decorator.d.ts +2 -0
- package/src/lib/ai-model/ai-model-provider.interface.d.ts +42 -0
- package/src/lib/ai-model/ai-model-provider.registry.d.ts +6 -0
- package/src/lib/ai-model/ai-model.d.ts +33 -0
- package/src/lib/ai-model/entities/defaults.d.ts +3 -0
- package/src/lib/ai-model/entities/index.d.ts +2 -0
- package/src/lib/ai-model/entities/model_entities.d.ts +14 -0
- package/src/lib/ai-model/errors.d.ts +5 -0
- package/src/lib/ai-model/index.d.ts +8 -0
- package/src/lib/ai-model/llm.d.ts +49 -0
- package/src/lib/ai-model/openai-compatible/completions.d.ts +23 -0
- package/src/lib/ai-model/openai-compatible/index.d.ts +3 -0
- package/src/lib/ai-model/openai-compatible/rerank.d.ts +20 -0
- package/src/lib/ai-model/openai-compatible/speech2text.d.ts +17 -0
- package/src/lib/ai-model/types/index.d.ts +11 -0
- package/src/lib/ai-model/types/model.d.ts +43 -0
- package/src/lib/ai-model/types/rerank.d.ts +20 -0
- package/src/lib/ai-model/types/speech2text.d.ts +3 -0
- package/src/lib/ai-model/types/text-embedding-model.d.ts +7 -0
- package/src/lib/ai-model/types/tts.d.ts +5 -0
- package/src/lib/core/file-system.d.ts +55 -0
- package/src/lib/core/i18n.d.ts +2 -0
- package/src/lib/core/index.d.ts +5 -0
- package/src/lib/core/permissions.d.ts +74 -0
- package/src/lib/core/schema.d.ts +22 -0
- package/src/lib/core/utils.d.ts +12 -0
- package/src/lib/data/datasource/adapter.strategy.d.ts +20 -0
- package/src/lib/data/datasource/index.d.ts +5 -0
- package/src/lib/data/datasource/strategy.decorator.d.ts +2 -0
- package/src/lib/data/datasource/strategy.interface.d.ts +19 -0
- package/src/lib/data/datasource/strategy.registry.d.ts +7 -0
- package/src/lib/data/datasource/types.d.ts +255 -0
- package/src/lib/data/index.d.ts +1 -0
- package/src/lib/integration/index.d.ts +3 -0
- package/src/lib/integration/strategy.decorator.d.ts +2 -0
- package/src/lib/integration/strategy.interface.d.ts +9 -0
- package/src/lib/integration/strategy.registry.d.ts +6 -0
- package/src/lib/logger.d.ts +2 -0
- package/src/lib/plugin-metadata.d.ts +17 -0
- package/src/lib/plugin.d.ts +8 -0
- package/src/lib/{plugin.hook.ts → plugin.hook.d.ts} +0 -4
- package/src/lib/plugin.interface.d.ts +59 -0
- package/src/lib/rag/image/index.d.ts +3 -0
- package/src/lib/rag/image/strategy.decorator.d.ts +5 -0
- package/src/lib/rag/image/strategy.interface.d.ts +31 -0
- package/src/lib/rag/image/strategy.registry.d.ts +6 -0
- package/src/lib/rag/index.d.ts +7 -0
- package/src/lib/rag/knowledge/index.d.ts +3 -0
- package/src/lib/rag/knowledge/knowledge-strategy.decorator.d.ts +2 -0
- package/src/lib/rag/knowledge/knowledge-strategy.interface.d.ts +15 -0
- package/src/lib/rag/knowledge/knowledge-strategy.registry.d.ts +6 -0
- package/src/lib/rag/retriever/index.d.ts +3 -0
- package/src/lib/rag/retriever/strategy.decorator.d.ts +5 -0
- package/src/lib/rag/retriever/strategy.interface.d.ts +30 -0
- package/src/lib/rag/retriever/strategy.registry.d.ts +6 -0
- package/src/lib/rag/source/index.d.ts +3 -0
- package/src/lib/rag/source/strategy.decorator.d.ts +5 -0
- package/src/lib/rag/source/strategy.interface.d.ts +36 -0
- package/src/lib/rag/source/strategy.registry.d.ts +6 -0
- package/src/lib/rag/textsplitter/index.d.ts +3 -0
- package/src/lib/rag/textsplitter/strategy.decorator.d.ts +2 -0
- package/src/lib/rag/textsplitter/strategy.interface.d.ts +23 -0
- package/src/lib/rag/textsplitter/strategy.registry.d.ts +6 -0
- package/src/lib/rag/transformer/index.d.ts +3 -0
- package/src/lib/rag/transformer/strategy.decorator.d.ts +5 -0
- package/src/lib/rag/transformer/strategy.interface.d.ts +26 -0
- package/src/lib/rag/transformer/strategy.registry.d.ts +6 -0
- package/src/lib/rag/types.d.ts +18 -0
- package/src/lib/strategy.d.ts +12 -0
- package/src/lib/toolset/builtin.d.ts +54 -0
- package/src/lib/toolset/index.d.ts +5 -0
- package/src/lib/toolset/strategy.decorator.d.ts +5 -0
- package/src/lib/toolset/strategy.interface.d.ts +28 -0
- package/src/lib/toolset/strategy.registry.d.ts +6 -0
- package/src/lib/toolset/toolset.d.ts +53 -0
- package/src/lib/types.d.ts +47 -0
- package/src/lib/vectorstore/index.d.ts +3 -0
- package/src/lib/vectorstore/strategy.decorator.d.ts +2 -0
- package/src/lib/vectorstore/strategy.interface.d.ts +24 -0
- package/src/lib/vectorstore/strategy.registry.d.ts +6 -0
- package/src/lib/workflow/index.d.ts +2 -0
- package/src/lib/workflow/node/index.d.ts +3 -0
- package/src/lib/workflow/node/strategy.decorator.d.ts +5 -0
- package/src/lib/workflow/node/strategy.interface.d.ts +41 -0
- package/src/lib/workflow/node/strategy.registry.d.ts +9 -0
- package/src/lib/workflow/trigger/index.d.ts +3 -0
- package/src/lib/workflow/trigger/strategy.decorator.d.ts +2 -0
- package/src/lib/workflow/trigger/strategy.interface.d.ts +22 -0
- package/src/lib/workflow/trigger/strategy.registry.d.ts +6 -0
- package/.eslintrc.json +0 -30
- package/.swcrc +0 -29
- package/jest.config.ts +0 -28
- package/project.json +0 -59
- package/src/index.ts +0 -11
- package/src/lib/core/file-system.ts +0 -113
- package/src/lib/core/i18n.ts +0 -31
- package/src/lib/core/index.ts +0 -4
- package/src/lib/core/permissions.ts +0 -97
- package/src/lib/core/schema.ts +0 -23
- package/src/lib/integration/index.ts +0 -3
- package/src/lib/integration/strategy.decorator.ts +0 -6
- package/src/lib/integration/strategy.interface.ts +0 -11
- package/src/lib/integration/strategy.registry.ts +0 -12
- package/src/lib/logger.ts +0 -18
- package/src/lib/plugin-metadata.ts +0 -20
- package/src/lib/plugin.interface.ts +0 -67
- package/src/lib/plugin.ts +0 -32
- package/src/lib/rag/image/index.ts +0 -3
- package/src/lib/rag/image/strategy.decorator.ts +0 -9
- package/src/lib/rag/image/strategy.interface.ts +0 -37
- package/src/lib/rag/image/strategy.registry.ts +0 -17
- package/src/lib/rag/index.ts +0 -7
- package/src/lib/rag/knowledge/index.ts +0 -3
- package/src/lib/rag/knowledge/knowledge-strategy.decorator.ts +0 -6
- package/src/lib/rag/knowledge/knowledge-strategy.interface.ts +0 -15
- package/src/lib/rag/knowledge/knowledge-strategy.registry.ts +0 -12
- package/src/lib/rag/retriever/index.ts +0 -3
- package/src/lib/rag/retriever/strategy.decorator.ts +0 -9
- package/src/lib/rag/retriever/strategy.interface.ts +0 -32
- package/src/lib/rag/retriever/strategy.registry.ts +0 -12
- package/src/lib/rag/source/index.ts +0 -3
- package/src/lib/rag/source/strategy.decorator.ts +0 -9
- package/src/lib/rag/source/strategy.interface.ts +0 -36
- package/src/lib/rag/source/strategy.registry.ts +0 -17
- package/src/lib/rag/textsplitter/index.ts +0 -3
- package/src/lib/rag/textsplitter/strategy.decorator.ts +0 -6
- package/src/lib/rag/textsplitter/strategy.interface.ts +0 -28
- package/src/lib/rag/textsplitter/strategy.registry.ts +0 -17
- package/src/lib/rag/transformer/index.ts +0 -3
- package/src/lib/rag/transformer/strategy.decorator.ts +0 -9
- package/src/lib/rag/transformer/strategy.interface.ts +0 -34
- package/src/lib/rag/transformer/strategy.registry.ts +0 -14
- package/src/lib/rag/types.ts +0 -76
- package/src/lib/strategy.ts +0 -37
- package/src/lib/toolset/builtin.ts +0 -111
- package/src/lib/toolset/index.ts +0 -5
- package/src/lib/toolset/strategy.decorator.ts +0 -9
- package/src/lib/toolset/strategy.interface.ts +0 -32
- package/src/lib/toolset/strategy.registry.ts +0 -17
- package/src/lib/toolset/toolset.ts +0 -76
- package/src/lib/types.ts +0 -47
- package/src/lib/vectorstore/index.ts +0 -3
- package/src/lib/vectorstore/strategy.decorator.ts +0 -6
- package/src/lib/vectorstore/strategy.interface.ts +0 -25
- package/src/lib/vectorstore/strategy.registry.ts +0 -17
- package/src/lib/workflow/index.ts +0 -2
- package/src/lib/workflow/node/index.ts +0 -3
- package/src/lib/workflow/node/strategy.decorator.ts +0 -9
- package/src/lib/workflow/node/strategy.interface.ts +0 -51
- package/src/lib/workflow/node/strategy.registry.ts +0 -18
- package/src/lib/workflow/trigger/index.ts +0 -3
- package/src/lib/workflow/trigger/strategy.decorator.ts +0 -6
- package/src/lib/workflow/trigger/strategy.interface.ts +0 -27
- package/src/lib/workflow/trigger/strategy.registry.ts +0 -17
- package/tsconfig.json +0 -22
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -9
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AdapterBaseOptions, DBQueryRunner, DBQueryRunnerType } from "./types";
|
|
2
|
+
export interface IDataSourceStrategy<TOptions extends AdapterBaseOptions = AdapterBaseOptions> {
|
|
3
|
+
readonly type: string;
|
|
4
|
+
readonly name: string;
|
|
5
|
+
readonly description?: string;
|
|
6
|
+
/**
|
|
7
|
+
* Create a query runner for the given data source options.
|
|
8
|
+
*/
|
|
9
|
+
create(options: TOptions): Promise<DBQueryRunner> | DBQueryRunner;
|
|
10
|
+
/**
|
|
11
|
+
* Optional configuration schema description for UI generation.
|
|
12
|
+
*/
|
|
13
|
+
configurationSchema?(): Promise<Record<string, unknown>> | Record<string, unknown>;
|
|
14
|
+
/**
|
|
15
|
+
* Cleanup hook invoked when a runner is no longer needed.
|
|
16
|
+
*/
|
|
17
|
+
teardown?(runner: DBQueryRunner): Promise<void> | void;
|
|
18
|
+
getClassType(): DBQueryRunnerType;
|
|
19
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../../strategy';
|
|
3
|
+
import { IDataSourceStrategy } from './strategy.interface';
|
|
4
|
+
import { AdapterBaseOptions } from './types';
|
|
5
|
+
export declare class DataSourceStrategyRegistry<TOptions extends AdapterBaseOptions = any> extends BaseStrategyRegistry<IDataSourceStrategy<TOptions>> {
|
|
6
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
7
|
+
}
|
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
import * as _axios from 'axios';
|
|
5
|
+
import { Readable } from 'stream';
|
|
6
|
+
import { IColumnDef, IDSSchema, IDSTable } from '@metad/contracts';
|
|
7
|
+
export { IColumnDef, IDSSchema, IDSTable } from '@metad/contracts';
|
|
8
|
+
/**
|
|
9
|
+
* The base options for DB adapters
|
|
10
|
+
*/
|
|
11
|
+
export interface AdapterBaseOptions {
|
|
12
|
+
/**
|
|
13
|
+
* Ref to debug in `createConnection` of `mysql`
|
|
14
|
+
*/
|
|
15
|
+
debug?: boolean;
|
|
16
|
+
/**
|
|
17
|
+
* Ref to trace in `createConnection` of `mysql`
|
|
18
|
+
*/
|
|
19
|
+
trace?: boolean;
|
|
20
|
+
host: string;
|
|
21
|
+
port: number;
|
|
22
|
+
username: string;
|
|
23
|
+
password: string;
|
|
24
|
+
}
|
|
25
|
+
export declare enum DBSyntaxEnum {
|
|
26
|
+
SQL = "sql",
|
|
27
|
+
MDX = "mdx"
|
|
28
|
+
}
|
|
29
|
+
export declare enum DBProtocolEnum {
|
|
30
|
+
SQL = "sql",
|
|
31
|
+
XMLA = "xmla"
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Options of single query
|
|
35
|
+
*/
|
|
36
|
+
export interface QueryOptions {
|
|
37
|
+
catalog?: string;
|
|
38
|
+
headers?: Record<string, string>;
|
|
39
|
+
}
|
|
40
|
+
export interface QueryResult<T = unknown> {
|
|
41
|
+
status: 'OK' | 'ERROR';
|
|
42
|
+
data?: Array<T>;
|
|
43
|
+
columns?: Array<IColumnDef>;
|
|
44
|
+
stats?: any;
|
|
45
|
+
error?: string;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Duties:
|
|
49
|
+
* - Convert error messages into a unified format
|
|
50
|
+
* - Connect different types of data sources
|
|
51
|
+
*/
|
|
52
|
+
export interface DBQueryRunner {
|
|
53
|
+
type: string;
|
|
54
|
+
name: string;
|
|
55
|
+
syntax: DBSyntaxEnum;
|
|
56
|
+
protocol: DBProtocolEnum;
|
|
57
|
+
host: string;
|
|
58
|
+
port: number | string;
|
|
59
|
+
jdbcDriver: string;
|
|
60
|
+
configurationSchema: Record<string, unknown>;
|
|
61
|
+
jdbcUrl(schema?: string): string;
|
|
62
|
+
/**
|
|
63
|
+
* Execute a sql query
|
|
64
|
+
*
|
|
65
|
+
* @param sql
|
|
66
|
+
*/
|
|
67
|
+
run(sql: string): Promise<any>;
|
|
68
|
+
/**
|
|
69
|
+
* Execute a sql query with options
|
|
70
|
+
*
|
|
71
|
+
* @param query
|
|
72
|
+
* @param options
|
|
73
|
+
*/
|
|
74
|
+
runQuery(query: string, options?: QueryOptions): Promise<QueryResult | any>;
|
|
75
|
+
/**
|
|
76
|
+
* Get catalog (schema or database) list in data source
|
|
77
|
+
*/
|
|
78
|
+
getCatalogs(): Promise<IDSSchema[]>;
|
|
79
|
+
/**
|
|
80
|
+
* Get schema of table in catalog (schema or database)
|
|
81
|
+
*
|
|
82
|
+
* @param catalog
|
|
83
|
+
* @param tableName
|
|
84
|
+
*/
|
|
85
|
+
getSchema(catalog?: string, tableName?: string): Promise<IDSSchema[]>;
|
|
86
|
+
/**
|
|
87
|
+
* Describe a sql query result schema
|
|
88
|
+
*
|
|
89
|
+
* @param catalog
|
|
90
|
+
* @param statement
|
|
91
|
+
*/
|
|
92
|
+
describe(catalog: string, statement: string): Promise<{
|
|
93
|
+
columns?: IDSTable['columns'];
|
|
94
|
+
}>;
|
|
95
|
+
/**
|
|
96
|
+
* Ping the db
|
|
97
|
+
*/
|
|
98
|
+
ping(): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Create a new catalog (schema) in database
|
|
101
|
+
*
|
|
102
|
+
* @param catalog
|
|
103
|
+
*/
|
|
104
|
+
createCatalog?(catalog: string): Promise<void>;
|
|
105
|
+
/**
|
|
106
|
+
* Create or append table data
|
|
107
|
+
*
|
|
108
|
+
* @param params
|
|
109
|
+
* @param options
|
|
110
|
+
*/
|
|
111
|
+
import(params: CreationTable, options?: QueryOptions): Promise<any>;
|
|
112
|
+
/**
|
|
113
|
+
* Drop a table
|
|
114
|
+
*
|
|
115
|
+
* @param name Table name
|
|
116
|
+
* @param options
|
|
117
|
+
*/
|
|
118
|
+
dropTable(name: string, options?: QueryOptions): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Teardown all resources:
|
|
121
|
+
* - close connection
|
|
122
|
+
*
|
|
123
|
+
*/
|
|
124
|
+
teardown(): Promise<void>;
|
|
125
|
+
}
|
|
126
|
+
export type DBQueryRunnerType = new (options?: AdapterBaseOptions, ...args: unknown[]) => DBQueryRunner;
|
|
127
|
+
export interface ColumnDef {
|
|
128
|
+
/**
|
|
129
|
+
* Key of data object
|
|
130
|
+
*/
|
|
131
|
+
name: string;
|
|
132
|
+
/**
|
|
133
|
+
* Name of table column
|
|
134
|
+
*/
|
|
135
|
+
fieldName: string;
|
|
136
|
+
/**
|
|
137
|
+
* Object value type, convert to db type
|
|
138
|
+
*/
|
|
139
|
+
type: string;
|
|
140
|
+
/**
|
|
141
|
+
* Is primary key column
|
|
142
|
+
*/
|
|
143
|
+
isKey: boolean;
|
|
144
|
+
/**
|
|
145
|
+
* length of type for column: varchar, decimal ...
|
|
146
|
+
*/
|
|
147
|
+
length?: number;
|
|
148
|
+
/**
|
|
149
|
+
* fraction of type for decimal
|
|
150
|
+
*/
|
|
151
|
+
fraction?: number;
|
|
152
|
+
}
|
|
153
|
+
export interface CreationTable {
|
|
154
|
+
catalog?: string;
|
|
155
|
+
table?: string;
|
|
156
|
+
name: string;
|
|
157
|
+
columns: ColumnDef[];
|
|
158
|
+
data?: any[];
|
|
159
|
+
file?: File;
|
|
160
|
+
mergeType?: 'APPEND' | 'DELETE' | 'MERGE';
|
|
161
|
+
format?: 'csv' | 'json' | 'parquet' | 'orc' | 'data';
|
|
162
|
+
columnSeparator?: string;
|
|
163
|
+
withHeader?: number;
|
|
164
|
+
}
|
|
165
|
+
export declare abstract class BaseQueryRunner<T extends AdapterBaseOptions = AdapterBaseOptions> implements DBQueryRunner {
|
|
166
|
+
type: string;
|
|
167
|
+
name: string;
|
|
168
|
+
syntax: DBSyntaxEnum;
|
|
169
|
+
protocol: DBProtocolEnum;
|
|
170
|
+
jdbcDriver: string;
|
|
171
|
+
abstract get host(): string;
|
|
172
|
+
abstract get port(): number | string;
|
|
173
|
+
options: T;
|
|
174
|
+
jdbcUrl(schema?: string): string;
|
|
175
|
+
get configurationSchema(): any;
|
|
176
|
+
constructor(options?: T);
|
|
177
|
+
run(sql: string): Promise<any>;
|
|
178
|
+
abstract runQuery(query: string, options?: QueryOptions): Promise<QueryResult>;
|
|
179
|
+
abstract getCatalogs(): Promise<IDSSchema[]>;
|
|
180
|
+
abstract getSchema(catalog?: string, tableName?: string): Promise<IDSSchema[]>;
|
|
181
|
+
describe(catalog: string, statement: string): Promise<{
|
|
182
|
+
columns?: IDSTable['columns'];
|
|
183
|
+
}>;
|
|
184
|
+
abstract ping(): Promise<void>;
|
|
185
|
+
import({ name, columns, data }: {
|
|
186
|
+
name: any;
|
|
187
|
+
columns: any;
|
|
188
|
+
data: any;
|
|
189
|
+
}, options?: {
|
|
190
|
+
catalog?: string;
|
|
191
|
+
}): Promise<void>;
|
|
192
|
+
dropTable(name: string, options?: any): Promise<void>;
|
|
193
|
+
abstract teardown(): Promise<void>;
|
|
194
|
+
}
|
|
195
|
+
export interface HttpAdapterOptions extends AdapterBaseOptions {
|
|
196
|
+
url?: string;
|
|
197
|
+
}
|
|
198
|
+
export declare abstract class BaseHTTPQueryRunner<T extends HttpAdapterOptions = HttpAdapterOptions> extends BaseQueryRunner<T> {
|
|
199
|
+
get url(): string;
|
|
200
|
+
get host(): string;
|
|
201
|
+
get port(): number | string;
|
|
202
|
+
get configurationSchema(): {};
|
|
203
|
+
get(): Promise<_axios.AxiosResponse<any, any>>;
|
|
204
|
+
post(data: any, options?: any): Promise<_axios.AxiosResponse<any, any>>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Adapter options for sql db
|
|
208
|
+
*/
|
|
209
|
+
export interface SQLAdapterOptions extends AdapterBaseOptions {
|
|
210
|
+
url?: string;
|
|
211
|
+
/**
|
|
212
|
+
* Database name, used as catalog
|
|
213
|
+
*/
|
|
214
|
+
catalog?: string;
|
|
215
|
+
use_ssl?: boolean;
|
|
216
|
+
ssl_cacert?: string;
|
|
217
|
+
version?: number;
|
|
218
|
+
}
|
|
219
|
+
export declare abstract class BaseSQLQueryRunner<T extends SQLAdapterOptions = SQLAdapterOptions> extends BaseQueryRunner<T> {
|
|
220
|
+
syntax: DBSyntaxEnum;
|
|
221
|
+
protocol: DBProtocolEnum;
|
|
222
|
+
get host(): string;
|
|
223
|
+
get port(): string | number;
|
|
224
|
+
abstract createCatalog?(catalog: string): Promise<void>;
|
|
225
|
+
ping(): Promise<void>;
|
|
226
|
+
}
|
|
227
|
+
export interface File {
|
|
228
|
+
/** Name of the form field associated with this file. */
|
|
229
|
+
fieldname: string;
|
|
230
|
+
/** Name of the file on the uploader's computer. */
|
|
231
|
+
originalname: string;
|
|
232
|
+
/**
|
|
233
|
+
* Value of the `Content-Transfer-Encoding` header for this file.
|
|
234
|
+
* @deprecated since July 2015
|
|
235
|
+
* @see RFC 7578, Section 4.7
|
|
236
|
+
*/
|
|
237
|
+
encoding: string;
|
|
238
|
+
/** Value of the `Content-Type` header for this file. */
|
|
239
|
+
mimetype: string;
|
|
240
|
+
/** Size of the file in bytes. */
|
|
241
|
+
size: number;
|
|
242
|
+
/**
|
|
243
|
+
* A readable stream of this file. Only available to the `_handleFile`
|
|
244
|
+
* callback for custom `StorageEngine`s.
|
|
245
|
+
*/
|
|
246
|
+
stream: Readable;
|
|
247
|
+
/** `DiskStorage` only: Directory to which this file has been uploaded. */
|
|
248
|
+
destination: string;
|
|
249
|
+
/** `DiskStorage` only: Name of this file within `destination`. */
|
|
250
|
+
filename: string;
|
|
251
|
+
/** `DiskStorage` only: Full path to the uploaded file. */
|
|
252
|
+
path: string;
|
|
253
|
+
/** `MemoryStorage` only: A Buffer containing the entire file. */
|
|
254
|
+
buffer: Buffer;
|
|
255
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './datasource/index';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IIntegration, TIntegrationProvider } from '@metad/contracts';
|
|
2
|
+
export type TIntegrationStrategyParams = {
|
|
3
|
+
query: string;
|
|
4
|
+
};
|
|
5
|
+
export interface IntegrationStrategy<T = unknown> {
|
|
6
|
+
meta: TIntegrationProvider;
|
|
7
|
+
execute(integration: IIntegration<T>, payload: TIntegrationStrategyParams): Promise<any>;
|
|
8
|
+
validateConfig?(config: T): Promise<void>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../strategy';
|
|
3
|
+
import { IntegrationStrategy } from './strategy.interface';
|
|
4
|
+
export declare class IntegrationStrategyRegistry extends BaseStrategyRegistry<IntegrationStrategy> {
|
|
5
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Metadata keys used in plugins for defining various aspects like entities, subscribers, and configurations.
|
|
3
|
+
*/
|
|
4
|
+
export declare const PLUGIN_METADATA: {
|
|
5
|
+
/**
|
|
6
|
+
* Key representing the entities registered within the plugin.
|
|
7
|
+
*/
|
|
8
|
+
readonly ENTITIES: "entities";
|
|
9
|
+
/**
|
|
10
|
+
* Key representing event subscribers within the plugin.
|
|
11
|
+
*/
|
|
12
|
+
readonly SUBSCRIBERS: "subscribers";
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Type definition for valid plugin metadata keys.
|
|
16
|
+
*/
|
|
17
|
+
export type PluginMetadataKey = (typeof PLUGIN_METADATA)[keyof typeof PLUGIN_METADATA];
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { PluginMetadata } from './plugin.interface';
|
|
2
|
+
/**
|
|
3
|
+
* Decorator function for extending NestJS features with additional metadata.
|
|
4
|
+
*
|
|
5
|
+
* @param pluginMetadata Metadata to be applied to the target class.
|
|
6
|
+
* @returns Class decorator function.
|
|
7
|
+
*/
|
|
8
|
+
export declare function XpertServerPlugin(pluginMetadata: PluginMetadata): ClassDecorator;
|
|
@@ -8,7 +8,6 @@ export interface IOnPluginBootstrap {
|
|
|
8
8
|
*/
|
|
9
9
|
onPluginBootstrap(): void | Promise<void>;
|
|
10
10
|
}
|
|
11
|
-
|
|
12
11
|
/**
|
|
13
12
|
* Interface for plugins with a destroy lifecycle method.
|
|
14
13
|
*/
|
|
@@ -19,7 +18,6 @@ export interface IOnPluginDestroy {
|
|
|
19
18
|
*/
|
|
20
19
|
onPluginDestroy(): void | Promise<void>;
|
|
21
20
|
}
|
|
22
|
-
|
|
23
21
|
/**
|
|
24
22
|
* Interface for plugins supporting basic seed operations.
|
|
25
23
|
*/
|
|
@@ -30,7 +28,6 @@ export interface IOnPluginWithBasicSeed {
|
|
|
30
28
|
*/
|
|
31
29
|
onPluginBasicSeed(): void | Promise<void>;
|
|
32
30
|
}
|
|
33
|
-
|
|
34
31
|
/**
|
|
35
32
|
* Interface for plugins supporting default seed operations.
|
|
36
33
|
*/
|
|
@@ -41,7 +38,6 @@ export interface IOnPluginWithDefaultSeed {
|
|
|
41
38
|
*/
|
|
42
39
|
onPluginDefaultSeed(): void | Promise<void>;
|
|
43
40
|
}
|
|
44
|
-
|
|
45
41
|
/**
|
|
46
42
|
* Interface for plugins supporting random seed operations.
|
|
47
43
|
*/
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { ModuleMetadata, Type } from '@nestjs/common';
|
|
2
|
+
/**
|
|
3
|
+
* Metadata definition for a plugin in NestJS.
|
|
4
|
+
*/
|
|
5
|
+
export interface PluginMetadata extends ModuleMetadata {
|
|
6
|
+
/**
|
|
7
|
+
* List of entities injected by the plugin.
|
|
8
|
+
*/
|
|
9
|
+
entities?: Array<Type<any>> | (() => Array<Type<any>>);
|
|
10
|
+
/**
|
|
11
|
+
* List of subscribers injected by the plugin.
|
|
12
|
+
*/
|
|
13
|
+
subscribers?: Array<Type<any>> | (() => Array<Type<any>>);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Interface for plugins with a bootstrap lifecycle method.
|
|
17
|
+
*/
|
|
18
|
+
export interface IOnPluginBootstrap {
|
|
19
|
+
/**
|
|
20
|
+
* Called when the plugin is being initialized.
|
|
21
|
+
* @returns A void or a Promise representing the completion of the operation.
|
|
22
|
+
*/
|
|
23
|
+
onPluginBootstrap(): void | Promise<void>;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Interface for plugins with a destroy lifecycle method.
|
|
27
|
+
*/
|
|
28
|
+
export interface IOnPluginDestroy {
|
|
29
|
+
/**
|
|
30
|
+
* Called when the plugin is being destroyed.
|
|
31
|
+
* @returns A void or a Promise representing the completion of the operation.
|
|
32
|
+
*/
|
|
33
|
+
onPluginDestroy(): void | Promise<void>;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Interface for plugins supporting various seed operations.
|
|
37
|
+
*/
|
|
38
|
+
export interface IOnPluginSeedable {
|
|
39
|
+
/**
|
|
40
|
+
* Invoked when seeding basic plugin data.
|
|
41
|
+
* @returns A void or a Promise representing the completion of the operation.
|
|
42
|
+
*/
|
|
43
|
+
onPluginBasicSeed?(): void | Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Invoked when seeding default plugin data.
|
|
46
|
+
* @returns A void or a Promise representing the completion of the operation.
|
|
47
|
+
*/
|
|
48
|
+
onPluginDefaultSeed?(): void | Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Invoked when seeding random plugin data.
|
|
51
|
+
* @returns A void or a Promise representing the completion of the operation.
|
|
52
|
+
*/
|
|
53
|
+
onPluginRandomSeed?(): void | Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Represents the combined lifecycle methods for a plugin.
|
|
57
|
+
* This type combines interfaces for initializing and destroying a plugin.
|
|
58
|
+
*/
|
|
59
|
+
export type PluginLifecycleMethods = IOnPluginBootstrap & IOnPluginDestroy & IOnPluginSeedable;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const IMAGE_UNDERSTANDING_STRATEGY = "IMAGE_UNDERSTANDING_STRATEGY";
|
|
2
|
+
/**
|
|
3
|
+
* Decorator to mark a provider as an Image Understanding Strategy
|
|
4
|
+
*/
|
|
5
|
+
export declare const ImageUnderstandingStrategy: (provider: string) => import("@nestjs/common").CustomDecorator<string>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { DocumentInterface } from '@langchain/core/documents';
|
|
2
|
+
import { BaseChatModel } from '@langchain/core/language_models/chat_models';
|
|
3
|
+
import { IDocumentUnderstandingProvider, IKnowledgeDocument } from '@metad/contracts';
|
|
4
|
+
import { Permissions, XpFileSystem } from '../../core/index';
|
|
5
|
+
import { ChunkMetadata } from '../types';
|
|
6
|
+
export type TImageUnderstandingConfig = {
|
|
7
|
+
stage: 'test' | 'prod';
|
|
8
|
+
visionModel: BaseChatModel;
|
|
9
|
+
permissions?: {
|
|
10
|
+
fileSystem?: XpFileSystem;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export type TImageUnderstandingResult = {
|
|
14
|
+
chunks: DocumentInterface<Partial<ChunkMetadata>>[];
|
|
15
|
+
metadata: any;
|
|
16
|
+
};
|
|
17
|
+
export interface IImageUnderstandingStrategy<TConfig extends TImageUnderstandingConfig = TImageUnderstandingConfig> {
|
|
18
|
+
readonly permissions: Permissions;
|
|
19
|
+
/**
|
|
20
|
+
* Metadata about this strategy
|
|
21
|
+
*/
|
|
22
|
+
readonly meta: IDocumentUnderstandingProvider;
|
|
23
|
+
/**
|
|
24
|
+
* Validate the configuration
|
|
25
|
+
*/
|
|
26
|
+
validateConfig(config: TConfig): Promise<void>;
|
|
27
|
+
/**
|
|
28
|
+
* Understand image files (e.g., OCR, VLM, Chart Parsing)
|
|
29
|
+
*/
|
|
30
|
+
understandImages(doc: IKnowledgeDocument<ChunkMetadata>, config: TConfig): Promise<TImageUnderstandingResult>;
|
|
31
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../../strategy';
|
|
3
|
+
import { IImageUnderstandingStrategy, TImageUnderstandingConfig } from './strategy.interface';
|
|
4
|
+
export declare class ImageUnderstandingRegistry<TConfig extends TImageUnderstandingConfig = TImageUnderstandingConfig> extends BaseStrategyRegistry<IImageUnderstandingStrategy<TConfig>> {
|
|
5
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { IIntegration } from '@metad/contracts';
|
|
2
|
+
import { Document } from '@langchain/core/documents';
|
|
3
|
+
export type TKnowledgeStrategyParams = {
|
|
4
|
+
query: string;
|
|
5
|
+
k: number;
|
|
6
|
+
filter: Record<string, any>;
|
|
7
|
+
options: {
|
|
8
|
+
knowledgebaseId: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export interface KnowledgeStrategy {
|
|
12
|
+
execute(integration: IIntegration, payload: TKnowledgeStrategyParams): Promise<{
|
|
13
|
+
chunks: [Document, number][];
|
|
14
|
+
}>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../../strategy';
|
|
3
|
+
import { KnowledgeStrategy } from './knowledge-strategy.interface';
|
|
4
|
+
export declare class KnowledgeStrategyRegistry extends BaseStrategyRegistry<KnowledgeStrategy> {
|
|
5
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { VectorStore } from '@langchain/core/vectorstores';
|
|
2
|
+
import { I18nObject } from '@metad/contracts';
|
|
3
|
+
import { Document } from '@langchain/core/documents';
|
|
4
|
+
export type TRetrieverConfig = {
|
|
5
|
+
vectorStore: VectorStore;
|
|
6
|
+
};
|
|
7
|
+
export interface IRetrieverStrategy<TConfig extends TRetrieverConfig = TRetrieverConfig> {
|
|
8
|
+
/**
|
|
9
|
+
* Metadata about this retriever
|
|
10
|
+
*/
|
|
11
|
+
readonly meta: {
|
|
12
|
+
name: string;
|
|
13
|
+
label: I18nObject;
|
|
14
|
+
configSchema: any;
|
|
15
|
+
icon: {
|
|
16
|
+
svg?: string;
|
|
17
|
+
color?: string;
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Validate the configuration
|
|
22
|
+
*/
|
|
23
|
+
validateConfig(config: TConfig): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Retrieve relevant documents for a given query
|
|
26
|
+
*/
|
|
27
|
+
retrieve(query: string, options?: TConfig): Promise<{
|
|
28
|
+
documents: Document[];
|
|
29
|
+
}>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../../strategy';
|
|
3
|
+
import { IRetrieverStrategy } from './strategy.interface';
|
|
4
|
+
export declare class RetrieverRegistry extends BaseStrategyRegistry<IRetrieverStrategy> {
|
|
5
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IDocumentSourceProvider, IIntegration } from '@metad/contracts';
|
|
2
|
+
import { Document } from '@langchain/core/documents';
|
|
3
|
+
import { Permissions } from '../../core';
|
|
4
|
+
export interface IDocumentSourceStrategy<TConfig = any> {
|
|
5
|
+
readonly permissions: Permissions;
|
|
6
|
+
/**
|
|
7
|
+
* Metadata about this document source
|
|
8
|
+
*/
|
|
9
|
+
readonly meta: IDocumentSourceProvider;
|
|
10
|
+
/**
|
|
11
|
+
* Validate the configuration
|
|
12
|
+
*/
|
|
13
|
+
validateConfig(config: TConfig): Promise<void>;
|
|
14
|
+
/**
|
|
15
|
+
* Test the connection to the source
|
|
16
|
+
*
|
|
17
|
+
* @param config
|
|
18
|
+
*/
|
|
19
|
+
test(config: TConfig): Promise<any>;
|
|
20
|
+
/**
|
|
21
|
+
* Load documents from the source
|
|
22
|
+
*/
|
|
23
|
+
loadDocuments(config: TConfig, context?: {
|
|
24
|
+
integration?: IIntegration;
|
|
25
|
+
}): Promise<Document[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Load a single document by its ID
|
|
28
|
+
*
|
|
29
|
+
* @deprecated Planning
|
|
30
|
+
* @param documentId
|
|
31
|
+
* @param context
|
|
32
|
+
*/
|
|
33
|
+
loadDocument?(document: Document, context: {
|
|
34
|
+
integration?: IIntegration;
|
|
35
|
+
}): Promise<Document>;
|
|
36
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { DiscoveryService, Reflector } from '@nestjs/core';
|
|
2
|
+
import { BaseStrategyRegistry } from '../../strategy';
|
|
3
|
+
import { IDocumentSourceStrategy } from './strategy.interface';
|
|
4
|
+
export declare class DocumentSourceRegistry<TConfig = any> extends BaseStrategyRegistry<IDocumentSourceStrategy<TConfig>> {
|
|
5
|
+
constructor(discoveryService: DiscoveryService, reflector: Reflector);
|
|
6
|
+
}
|