@xpert-ai/plugin-sdk 0.0.3-0 → 3.6.0-beta.6
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.js +211 -193
- package/index.esm.js +211 -194
- package/package.json +2 -2
- package/src/lib/core/i18n.d.ts +2 -0
- package/src/lib/core/index.d.ts +1 -0
- package/src/lib/core/schema.d.ts +2 -2
- package/src/lib/integration/strategy.interface.d.ts +1 -0
- package/src/lib/rag/source/strategy.interface.d.ts +10 -0
- package/src/lib/rag/transformer/strategy.interface.d.ts +2 -17
- package/src/lib/types.d.ts +8 -8
package/package.json
CHANGED
package/src/lib/core/index.d.ts
CHANGED
package/src/lib/core/schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* Common UI Schema field definitions
|
|
3
3
|
*/
|
|
4
4
|
export interface ISchemaUIBase {
|
|
5
5
|
component: string;
|
|
@@ -12,7 +12,7 @@ export interface ISchemaUIBase {
|
|
|
12
12
|
enabledWhen?: Record<string, any>;
|
|
13
13
|
}
|
|
14
14
|
/**
|
|
15
|
-
* Secret
|
|
15
|
+
* Secret field extensions
|
|
16
16
|
*/
|
|
17
17
|
export interface ISchemaSecretField extends ISchemaUIBase {
|
|
18
18
|
component: 'secretInput';
|
|
@@ -23,4 +23,14 @@ export interface IDocumentSourceStrategy<TConfig = any> {
|
|
|
23
23
|
loadDocuments(config: TConfig, context?: {
|
|
24
24
|
integration?: IIntegration;
|
|
25
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>;
|
|
26
36
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _TFile, IDocumentProcessorProvider, IIntegration } from '@metad/contracts';
|
|
1
|
+
import { IDocumentProcessorProvider, IIntegration, IKnowledgeDocument } from '@metad/contracts';
|
|
3
2
|
import { Permissions, XpFileSystem } from '../../core/index';
|
|
4
|
-
import { ChunkMetadata, TDocumentAsset } from '../types';
|
|
5
3
|
export type TDocumentTransformerConfig = {
|
|
6
4
|
stage: 'test' | 'prod';
|
|
7
5
|
tempDir?: string;
|
|
@@ -10,19 +8,6 @@ export type TDocumentTransformerConfig = {
|
|
|
10
8
|
integration?: IIntegration;
|
|
11
9
|
};
|
|
12
10
|
};
|
|
13
|
-
export type TDocumentTransformerFile = _TFile & {
|
|
14
|
-
id?: string;
|
|
15
|
-
filename: string;
|
|
16
|
-
extension: string | undefined;
|
|
17
|
-
};
|
|
18
|
-
export type TDocumentTransformerInput = TDocumentTransformerFile[] | string | string[];
|
|
19
|
-
export type TDocumentTransformerResult = {
|
|
20
|
-
id?: string;
|
|
21
|
-
chunks: DocumentInterface<ChunkMetadata>[];
|
|
22
|
-
metadata: {
|
|
23
|
-
assets?: TDocumentAsset[];
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
11
|
export interface IDocumentTransformerStrategy<TConfig extends TDocumentTransformerConfig = TDocumentTransformerConfig> {
|
|
27
12
|
/**
|
|
28
13
|
* Metadata about this transformer
|
|
@@ -36,5 +21,5 @@ export interface IDocumentTransformerStrategy<TConfig extends TDocumentTransform
|
|
|
36
21
|
/**
|
|
37
22
|
* Transform documents (e.g., extract, OCR, normalize, enrich metadata)
|
|
38
23
|
*/
|
|
39
|
-
transformDocuments(files:
|
|
24
|
+
transformDocuments(files: Partial<IKnowledgeDocument>[], config: TConfig): Promise<Partial<IKnowledgeDocument>[]>;
|
|
40
25
|
}
|
package/src/lib/types.d.ts
CHANGED
|
@@ -2,15 +2,15 @@ import { PluginMeta } from '@metad/contracts';
|
|
|
2
2
|
import type { DynamicModule, INestApplicationContext } from '@nestjs/common';
|
|
3
3
|
import type { ZodSchema } from 'zod';
|
|
4
4
|
export interface PluginLifecycle {
|
|
5
|
-
/**
|
|
5
|
+
/** Called after module registration but before application startup */
|
|
6
6
|
onInit?(ctx: PluginContext): Promise<void> | void;
|
|
7
|
-
/**
|
|
7
|
+
/** Called after application startup (can start serving externally) */
|
|
8
8
|
onStart?(ctx: PluginContext): Promise<void> | void;
|
|
9
|
-
/**
|
|
9
|
+
/** Called during graceful shutdown */
|
|
10
10
|
onStop?(ctx: PluginContext): Promise<void> | void;
|
|
11
11
|
}
|
|
12
12
|
export interface PluginHealth {
|
|
13
|
-
/**
|
|
13
|
+
/** Returns health status and optional dependency check details */
|
|
14
14
|
checkHealth?(ctx: PluginContext): Promise<{
|
|
15
15
|
status: 'up' | 'down';
|
|
16
16
|
details?: any;
|
|
@@ -20,22 +20,22 @@ export interface PluginHealth {
|
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
export interface PluginConfigSpec<T extends object = any> {
|
|
23
|
-
/**
|
|
23
|
+
/** Zod validation schema for plugin-level config (optional) */
|
|
24
24
|
schema?: ZodSchema<T>;
|
|
25
|
-
/**
|
|
25
|
+
/** Default configuration */
|
|
26
26
|
defaults?: Partial<T>;
|
|
27
27
|
}
|
|
28
28
|
export interface XpertPlugin<TConfig extends object = any> extends PluginLifecycle, PluginHealth {
|
|
29
29
|
meta: PluginMeta;
|
|
30
30
|
config?: PluginConfigSpec<TConfig>;
|
|
31
|
-
/**
|
|
31
|
+
/** Returns the DynamicModule to be mounted to the main application (can be set as global) */
|
|
32
32
|
register(ctx: PluginContext<TConfig>): DynamicModule;
|
|
33
33
|
}
|
|
34
34
|
export interface PluginContext<TConfig extends object = any> {
|
|
35
35
|
app: INestApplicationContext;
|
|
36
36
|
logger: PluginLogger;
|
|
37
37
|
config: TConfig;
|
|
38
|
-
/**
|
|
38
|
+
/** Helper method to access other Providers in the container */
|
|
39
39
|
resolve<TInput = any, TResult = TInput>(token: any): TResult;
|
|
40
40
|
}
|
|
41
41
|
export interface PluginLogger {
|