nestjs-apcore 0.1.0
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/README.md +304 -0
- package/dist/bridge/binding-loader.d.ts +33 -0
- package/dist/bridge/binding-loader.d.ts.map +1 -0
- package/dist/bridge/binding-loader.js +118 -0
- package/dist/bridge/binding-loader.js.map +1 -0
- package/dist/bridge/index.d.ts +3 -0
- package/dist/bridge/index.d.ts.map +1 -0
- package/dist/bridge/index.js +2 -0
- package/dist/bridge/index.js.map +1 -0
- package/dist/constants.d.ts +6 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +8 -0
- package/dist/constants.js.map +1 -0
- package/dist/core/apcore-executor.service.d.ts +42 -0
- package/dist/core/apcore-executor.service.d.ts.map +1 -0
- package/dist/core/apcore-executor.service.js +68 -0
- package/dist/core/apcore-executor.service.js.map +1 -0
- package/dist/core/apcore-registry.service.d.ts +52 -0
- package/dist/core/apcore-registry.service.d.ts.map +1 -0
- package/dist/core/apcore-registry.service.js +181 -0
- package/dist/core/apcore-registry.service.js.map +1 -0
- package/dist/core/apcore.module.d.ts +27 -0
- package/dist/core/apcore.module.d.ts.map +1 -0
- package/dist/core/apcore.module.js +105 -0
- package/dist/core/apcore.module.js.map +1 -0
- package/dist/decorators/ap-context.decorator.d.ts +2 -0
- package/dist/decorators/ap-context.decorator.d.ts.map +1 -0
- package/dist/decorators/ap-context.decorator.js +9 -0
- package/dist/decorators/ap-context.decorator.js.map +1 -0
- package/dist/decorators/ap-module.decorator.d.ts +3 -0
- package/dist/decorators/ap-module.decorator.d.ts.map +1 -0
- package/dist/decorators/ap-module.decorator.js +7 -0
- package/dist/decorators/ap-module.decorator.js.map +1 -0
- package/dist/decorators/ap-tool-scanner.service.d.ts +28 -0
- package/dist/decorators/ap-tool-scanner.service.d.ts.map +1 -0
- package/dist/decorators/ap-tool-scanner.service.js +166 -0
- package/dist/decorators/ap-tool-scanner.service.js.map +1 -0
- package/dist/decorators/ap-tool.decorator.d.ts +3 -0
- package/dist/decorators/ap-tool.decorator.d.ts.map +1 -0
- package/dist/decorators/ap-tool.decorator.js +7 -0
- package/dist/decorators/ap-tool.decorator.js.map +1 -0
- package/dist/decorators/index.d.ts +4 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +4 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/apcore-mcp.module.d.ts +28 -0
- package/dist/mcp/apcore-mcp.module.d.ts.map +1 -0
- package/dist/mcp/apcore-mcp.module.js +77 -0
- package/dist/mcp/apcore-mcp.module.js.map +1 -0
- package/dist/mcp/apcore-mcp.service.d.ts +53 -0
- package/dist/mcp/apcore-mcp.service.d.ts.map +1 -0
- package/dist/mcp/apcore-mcp.service.js +148 -0
- package/dist/mcp/apcore-mcp.service.js.map +1 -0
- package/dist/schema/adapters/dto.adapter.d.ts +44 -0
- package/dist/schema/adapters/dto.adapter.d.ts.map +1 -0
- package/dist/schema/adapters/dto.adapter.js +191 -0
- package/dist/schema/adapters/dto.adapter.js.map +1 -0
- package/dist/schema/adapters/json-schema.adapter.d.ts +30 -0
- package/dist/schema/adapters/json-schema.adapter.d.ts.map +1 -0
- package/dist/schema/adapters/json-schema.adapter.js +48 -0
- package/dist/schema/adapters/json-schema.adapter.js.map +1 -0
- package/dist/schema/adapters/schema-adapter.interface.d.ts +21 -0
- package/dist/schema/adapters/schema-adapter.interface.d.ts.map +1 -0
- package/dist/schema/adapters/schema-adapter.interface.js +2 -0
- package/dist/schema/adapters/schema-adapter.interface.js.map +1 -0
- package/dist/schema/adapters/typebox.adapter.d.ts +32 -0
- package/dist/schema/adapters/typebox.adapter.d.ts.map +1 -0
- package/dist/schema/adapters/typebox.adapter.js +46 -0
- package/dist/schema/adapters/typebox.adapter.js.map +1 -0
- package/dist/schema/adapters/zod.adapter.d.ts +16 -0
- package/dist/schema/adapters/zod.adapter.d.ts.map +1 -0
- package/dist/schema/adapters/zod.adapter.js +184 -0
- package/dist/schema/adapters/zod.adapter.js.map +1 -0
- package/dist/schema/schema-extractor.service.d.ts +58 -0
- package/dist/schema/schema-extractor.service.d.ts.map +1 -0
- package/dist/schema/schema-extractor.service.js +100 -0
- package/dist/schema/schema-extractor.service.js.map +1 -0
- package/dist/types.d.ts +106 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/id-generator.d.ts +41 -0
- package/dist/utils/id-generator.d.ts.map +1 -0
- package/dist/utils/id-generator.js +87 -0
- package/dist/utils/id-generator.js.map +1 -0
- package/package.json +100 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { AP_TOOL_METADATA_KEY } from '../constants.js';
|
|
2
|
+
export function ApTool(options) {
|
|
3
|
+
return (target, propertyKey, _descriptor) => {
|
|
4
|
+
Reflect.defineMetadata(AP_TOOL_METADATA_KEY, options, target, propertyKey);
|
|
5
|
+
};
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=ap-tool.decorator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ap-tool.decorator.js","sourceRoot":"","sources":["../../src/decorators/ap-tool.decorator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAGvD,MAAM,UAAU,MAAM,CAAC,OAAsB;IAC3C,OAAO,CAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAE,EAAE;QAC1C,OAAO,CAAC,cAAc,CAAC,oBAAoB,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;IAC7E,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AACpD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export { ApcoreModule } from './core/apcore.module.js';
|
|
2
|
+
export { ApcoreRegistryService } from './core/apcore-registry.service.js';
|
|
3
|
+
export { ApcoreExecutorService } from './core/apcore-executor.service.js';
|
|
4
|
+
export { ApcoreMcpModule } from './mcp/apcore-mcp.module.js';
|
|
5
|
+
export { ApcoreMcpService } from './mcp/apcore-mcp.service.js';
|
|
6
|
+
export { reportProgress, elicit, createBridgeContext } from 'apcore-mcp';
|
|
7
|
+
export type { BridgeContext, OpenAIToolDef, ServeOptions, MetricsExporter, ElicitResult } from 'apcore-mcp';
|
|
8
|
+
export { JWTAuthenticator, getCurrentIdentity, identityStorage } from 'apcore-mcp';
|
|
9
|
+
export type { Authenticator, ClaimMapping, JWTAuthenticatorOptions } from 'apcore-mcp';
|
|
10
|
+
export { ApTool, ApModule, ApContext } from './decorators/index.js';
|
|
11
|
+
export { ApToolScannerService } from './decorators/ap-tool-scanner.service.js';
|
|
12
|
+
export { SchemaExtractor, SchemaExtractionError } from './schema/schema-extractor.service.js';
|
|
13
|
+
export type { SchemaAdapter } from './schema/adapters/schema-adapter.interface.js';
|
|
14
|
+
export { TypeBoxAdapter } from './schema/adapters/typebox.adapter.js';
|
|
15
|
+
export { ZodAdapter } from './schema/adapters/zod.adapter.js';
|
|
16
|
+
export { DtoAdapter } from './schema/adapters/dto.adapter.js';
|
|
17
|
+
export { JsonSchemaAdapter } from './schema/adapters/json-schema.adapter.js';
|
|
18
|
+
export { ApBindingLoader } from './bridge/index.js';
|
|
19
|
+
export type { InstanceProvider } from './bridge/index.js';
|
|
20
|
+
export { normalizeClassName, normalizeMethodName, generateModuleId, } from './utils/id-generator.js';
|
|
21
|
+
export { APCORE_MODULE_OPTIONS, APCORE_MCP_MODULE_OPTIONS, AP_TOOL_METADATA_KEY, AP_MODULE_METADATA_KEY, AP_CONTEXT_METADATA_KEY, } from './constants.js';
|
|
22
|
+
export type { ModuleAnnotations, ModuleExample, Module, Context, Identity, ModuleDescriptor, ApToolAnnotations, ApToolExample, ApToolOptions, ApModuleOptions, ApcoreModuleOptions, ApcoreModuleAsyncOptions, ApcoreMcpModuleOptions, ApcoreMcpModuleAsyncOptions, RegisterMethodOptions, RegisterServiceOptions, } from './types.js';
|
|
23
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAK1E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAG/D,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACzE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAG5G,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACnF,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAC;AAKvF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAK/E,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC9F,YAAY,EAAE,aAAa,EAAE,MAAM,+CAA+C,CAAC;AACnF,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAK7E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAK1D,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC;AAKxB,YAAY,EAEV,iBAAiB,EACjB,aAAa,EACb,MAAM,EACN,OAAO,EACP,QAAQ,EACR,gBAAgB,EAEhB,iBAAiB,EACjB,aAAa,EACb,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,wBAAwB,EACxB,sBAAsB,EACtB,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,YAAY,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// ---------------------------------------------------------------------------
|
|
2
|
+
// Core
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
export { ApcoreModule } from './core/apcore.module.js';
|
|
5
|
+
export { ApcoreRegistryService } from './core/apcore-registry.service.js';
|
|
6
|
+
export { ApcoreExecutorService } from './core/apcore-executor.service.js';
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
// MCP
|
|
9
|
+
// ---------------------------------------------------------------------------
|
|
10
|
+
export { ApcoreMcpModule } from './mcp/apcore-mcp.module.js';
|
|
11
|
+
export { ApcoreMcpService } from './mcp/apcore-mcp.service.js';
|
|
12
|
+
// Re-export apcore-mcp helpers and types for convenience
|
|
13
|
+
export { reportProgress, elicit, createBridgeContext } from 'apcore-mcp';
|
|
14
|
+
// Re-export apcore-mcp auth utilities
|
|
15
|
+
export { JWTAuthenticator, getCurrentIdentity, identityStorage } from 'apcore-mcp';
|
|
16
|
+
// ---------------------------------------------------------------------------
|
|
17
|
+
// Decorators
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
export { ApTool, ApModule, ApContext } from './decorators/index.js';
|
|
20
|
+
export { ApToolScannerService } from './decorators/ap-tool-scanner.service.js';
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Schema
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
export { SchemaExtractor, SchemaExtractionError } from './schema/schema-extractor.service.js';
|
|
25
|
+
export { TypeBoxAdapter } from './schema/adapters/typebox.adapter.js';
|
|
26
|
+
export { ZodAdapter } from './schema/adapters/zod.adapter.js';
|
|
27
|
+
export { DtoAdapter } from './schema/adapters/dto.adapter.js';
|
|
28
|
+
export { JsonSchemaAdapter } from './schema/adapters/json-schema.adapter.js';
|
|
29
|
+
// ---------------------------------------------------------------------------
|
|
30
|
+
// Bridge
|
|
31
|
+
// ---------------------------------------------------------------------------
|
|
32
|
+
export { ApBindingLoader } from './bridge/index.js';
|
|
33
|
+
// ---------------------------------------------------------------------------
|
|
34
|
+
// Utilities
|
|
35
|
+
// ---------------------------------------------------------------------------
|
|
36
|
+
export { normalizeClassName, normalizeMethodName, generateModuleId, } from './utils/id-generator.js';
|
|
37
|
+
// ---------------------------------------------------------------------------
|
|
38
|
+
// Constants
|
|
39
|
+
// ---------------------------------------------------------------------------
|
|
40
|
+
export { APCORE_MODULE_OPTIONS, APCORE_MCP_MODULE_OPTIONS, AP_TOOL_METADATA_KEY, AP_MODULE_METADATA_KEY, AP_CONTEXT_METADATA_KEY, } from './constants.js';
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,OAAO;AACP,8EAA8E;AAC9E,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAC1E,OAAO,EAAE,qBAAqB,EAAE,MAAM,mCAAmC,CAAC;AAE1E,8EAA8E;AAC9E,MAAM;AACN,8EAA8E;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE/D,yDAAyD;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGzE,sCAAsC;AACtC,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAGnF,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAC9E,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,yCAAyC,CAAC;AAE/E,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAC9E,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAE9F,OAAO,EAAE,cAAc,EAAE,MAAM,sCAAsC,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0CAA0C,CAAC;AAE7E,8EAA8E;AAC9E,SAAS;AACT,8EAA8E;AAC9E,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGpD,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAC9E,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,yBAAyB,CAAC;AAEjC,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAC9E,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,EACpB,sBAAsB,EACtB,uBAAuB,GACxB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { DynamicModule } from '@nestjs/common';
|
|
2
|
+
import type { ApcoreMcpModuleOptions, ApcoreMcpModuleAsyncOptions } from '../types.js';
|
|
3
|
+
/**
|
|
4
|
+
* NestJS dynamic module for the MCP (Model Context Protocol) server.
|
|
5
|
+
*
|
|
6
|
+
* Provides {@link ApcoreMcpService} and the {@link APCORE_MCP_MODULE_OPTIONS}
|
|
7
|
+
* token. Requires that {@link ApcoreRegistryService} and
|
|
8
|
+
* {@link ApcoreExecutorService} are available in the injection context
|
|
9
|
+
* (typically via importing `ApcoreModule`).
|
|
10
|
+
*/
|
|
11
|
+
export declare class ApcoreMcpModule {
|
|
12
|
+
/**
|
|
13
|
+
* Synchronous configuration.
|
|
14
|
+
*
|
|
15
|
+
* Creates the {@link ApcoreMcpService} via a factory that injects
|
|
16
|
+
* {@link ApcoreRegistryService} and {@link ApcoreExecutorService}
|
|
17
|
+
* from the parent context.
|
|
18
|
+
*/
|
|
19
|
+
static forRoot(options: ApcoreMcpModuleOptions): DynamicModule;
|
|
20
|
+
/**
|
|
21
|
+
* Asynchronous configuration using the `useFactory` / `inject` pattern.
|
|
22
|
+
*
|
|
23
|
+
* Supports an `imports` array so that injected dependencies (e.g. a
|
|
24
|
+
* ConfigService) are available to the factory function.
|
|
25
|
+
*/
|
|
26
|
+
static forRootAsync(options: ApcoreMcpModuleAsyncOptions): DynamicModule;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=apcore-mcp.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apcore-mcp.module.d.ts","sourceRoot":"","sources":["../../src/mcp/apcore-mcp.module.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAKpE,OAAO,KAAK,EACV,sBAAsB,EACtB,2BAA2B,EAC5B,MAAM,aAAa,CAAC;AAErB;;;;;;;GAOG;AACH,qBACa,eAAe;IAC1B;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,sBAAsB,GAAG,aAAa;IAkB9D;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,2BAA2B,GAAG,aAAa;CA2BzE"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var ApcoreMcpModule_1;
|
|
8
|
+
import { Module } from '@nestjs/common';
|
|
9
|
+
import { ApcoreRegistryService } from '../core/apcore-registry.service.js';
|
|
10
|
+
import { ApcoreExecutorService } from '../core/apcore-executor.service.js';
|
|
11
|
+
import { ApcoreMcpService } from './apcore-mcp.service.js';
|
|
12
|
+
import { APCORE_MCP_MODULE_OPTIONS } from '../constants.js';
|
|
13
|
+
/**
|
|
14
|
+
* NestJS dynamic module for the MCP (Model Context Protocol) server.
|
|
15
|
+
*
|
|
16
|
+
* Provides {@link ApcoreMcpService} and the {@link APCORE_MCP_MODULE_OPTIONS}
|
|
17
|
+
* token. Requires that {@link ApcoreRegistryService} and
|
|
18
|
+
* {@link ApcoreExecutorService} are available in the injection context
|
|
19
|
+
* (typically via importing `ApcoreModule`).
|
|
20
|
+
*/
|
|
21
|
+
let ApcoreMcpModule = ApcoreMcpModule_1 = class ApcoreMcpModule {
|
|
22
|
+
/**
|
|
23
|
+
* Synchronous configuration.
|
|
24
|
+
*
|
|
25
|
+
* Creates the {@link ApcoreMcpService} via a factory that injects
|
|
26
|
+
* {@link ApcoreRegistryService} and {@link ApcoreExecutorService}
|
|
27
|
+
* from the parent context.
|
|
28
|
+
*/
|
|
29
|
+
static forRoot(options) {
|
|
30
|
+
return {
|
|
31
|
+
module: ApcoreMcpModule_1,
|
|
32
|
+
providers: [
|
|
33
|
+
{ provide: APCORE_MCP_MODULE_OPTIONS, useValue: options },
|
|
34
|
+
{
|
|
35
|
+
provide: ApcoreMcpService,
|
|
36
|
+
useFactory: (registry, executor) => new ApcoreMcpService(registry, executor, options),
|
|
37
|
+
inject: [ApcoreRegistryService, ApcoreExecutorService],
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
exports: [ApcoreMcpService, APCORE_MCP_MODULE_OPTIONS],
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Asynchronous configuration using the `useFactory` / `inject` pattern.
|
|
45
|
+
*
|
|
46
|
+
* Supports an `imports` array so that injected dependencies (e.g. a
|
|
47
|
+
* ConfigService) are available to the factory function.
|
|
48
|
+
*/
|
|
49
|
+
static forRootAsync(options) {
|
|
50
|
+
return {
|
|
51
|
+
module: ApcoreMcpModule_1,
|
|
52
|
+
imports: (options.imports ?? []),
|
|
53
|
+
providers: [
|
|
54
|
+
{
|
|
55
|
+
provide: APCORE_MCP_MODULE_OPTIONS,
|
|
56
|
+
useFactory: options.useFactory,
|
|
57
|
+
inject: (options.inject ?? []),
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
provide: ApcoreMcpService,
|
|
61
|
+
useFactory: (opts, registry, executor) => new ApcoreMcpService(registry, executor, opts),
|
|
62
|
+
inject: [
|
|
63
|
+
APCORE_MCP_MODULE_OPTIONS,
|
|
64
|
+
ApcoreRegistryService,
|
|
65
|
+
ApcoreExecutorService,
|
|
66
|
+
],
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
exports: [ApcoreMcpService, APCORE_MCP_MODULE_OPTIONS],
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
ApcoreMcpModule = ApcoreMcpModule_1 = __decorate([
|
|
74
|
+
Module({})
|
|
75
|
+
], ApcoreMcpModule);
|
|
76
|
+
export { ApcoreMcpModule };
|
|
77
|
+
//# sourceMappingURL=apcore-mcp.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apcore-mcp.module.js","sourceRoot":"","sources":["../../src/mcp/apcore-mcp.module.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAExC,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAM5D;;;;;;;GAOG;AAEI,IAAM,eAAe,uBAArB,MAAM,eAAe;IAC1B;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,OAA+B;QAC5C,OAAO;YACL,MAAM,EA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
|
3
|
+
import { ApcoreRegistryService } from '../core/apcore-registry.service.js';
|
|
4
|
+
import { ApcoreExecutorService } from '../core/apcore-executor.service.js';
|
|
5
|
+
import type { ApcoreMcpModuleOptions } from '../types.js';
|
|
6
|
+
/**
|
|
7
|
+
* NestJS service that manages the MCP (Model Context Protocol) server lifecycle.
|
|
8
|
+
*
|
|
9
|
+
* Wraps the `serve()` and `toOpenaiTools()` functions from `apcore-mcp`,
|
|
10
|
+
* integrating them with NestJS lifecycle hooks for automatic startup/shutdown.
|
|
11
|
+
*/
|
|
12
|
+
export declare class ApcoreMcpService implements OnApplicationBootstrap, OnModuleDestroy {
|
|
13
|
+
private readonly registry;
|
|
14
|
+
private readonly executor;
|
|
15
|
+
private readonly options;
|
|
16
|
+
private _isRunning;
|
|
17
|
+
constructor(registry: ApcoreRegistryService, executor: ApcoreExecutorService, options: ApcoreMcpModuleOptions);
|
|
18
|
+
/** Whether the MCP server is currently running. */
|
|
19
|
+
get isRunning(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Number of tools available in the registry, filtered by the module-level
|
|
22
|
+
* `tags` and `prefix` options when provided.
|
|
23
|
+
*/
|
|
24
|
+
get toolCount(): number;
|
|
25
|
+
/** Starts the MCP server using the configured transport and options. */
|
|
26
|
+
start(): Promise<void>;
|
|
27
|
+
/** Stops the MCP server. */
|
|
28
|
+
stop(): Promise<void>;
|
|
29
|
+
/** Restarts the MCP server (stop, then start). */
|
|
30
|
+
restart(): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Convert the registered tools to OpenAI-compatible tool definitions.
|
|
33
|
+
*
|
|
34
|
+
* Delegates to `toOpenaiTools()` from `apcore-mcp`.
|
|
35
|
+
*/
|
|
36
|
+
toOpenaiTools(options?: {
|
|
37
|
+
embedAnnotations?: boolean;
|
|
38
|
+
strict?: boolean;
|
|
39
|
+
tags?: string[];
|
|
40
|
+
prefix?: string;
|
|
41
|
+
}): OpenAIToolDef[];
|
|
42
|
+
/**
|
|
43
|
+
* Auto-starts the MCP server when a transport is configured.
|
|
44
|
+
*
|
|
45
|
+
* Uses `OnApplicationBootstrap` (not `OnModuleInit`) so that all
|
|
46
|
+
* tools registered via decorators, programmatic calls, or YAML
|
|
47
|
+
* bindings during `onModuleInit` are available before the server starts.
|
|
48
|
+
*/
|
|
49
|
+
onApplicationBootstrap(): Promise<void>;
|
|
50
|
+
/** Auto-stops the MCP server on module destruction. */
|
|
51
|
+
onModuleDestroy(): Promise<void>;
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=apcore-mcp.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apcore-mcp.service.d.ts","sourceRoot":"","sources":["../../src/mcp/apcore-mcp.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAE9E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAE3E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,aAAa,CAAC;AAE1D;;;;;GAKG;AACH,qBACa,gBAAiB,YAAW,sBAAsB,EAAE,eAAe;IAK5E,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAEzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IAEzB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAR1B,OAAO,CAAC,UAAU,CAAS;gBAIR,QAAQ,EAAE,qBAAqB,EAE/B,QAAQ,EAAE,qBAAqB,EAE/B,OAAO,EAAE,sBAAsB;IAOlD,mDAAmD;IACnD,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;OAGG;IACH,IAAI,SAAS,IAAI,MAAM,CAKtB;IAMD,wEAAwE;IAClE,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IA4B5B,4BAA4B;IACtB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B,kDAAkD;IAC5C,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAS9B;;;;OAIG;IACH,aAAa,CAAC,OAAO,CAAC,EAAE;QACtB,gBAAgB,CAAC,EAAE,OAAO,CAAC;QAC3B,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;QAChB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,GAAG,aAAa,EAAE;IAQnB;;;;;;OAMG;IACG,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC;IAM7C,uDAAuD;IACjD,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;CAKvC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { Injectable, Inject } from '@nestjs/common';
|
|
14
|
+
import { serve, toOpenaiTools } from 'apcore-mcp';
|
|
15
|
+
import { ApcoreRegistryService } from '../core/apcore-registry.service.js';
|
|
16
|
+
import { ApcoreExecutorService } from '../core/apcore-executor.service.js';
|
|
17
|
+
import { APCORE_MCP_MODULE_OPTIONS } from '../constants.js';
|
|
18
|
+
/**
|
|
19
|
+
* NestJS service that manages the MCP (Model Context Protocol) server lifecycle.
|
|
20
|
+
*
|
|
21
|
+
* Wraps the `serve()` and `toOpenaiTools()` functions from `apcore-mcp`,
|
|
22
|
+
* integrating them with NestJS lifecycle hooks for automatic startup/shutdown.
|
|
23
|
+
*/
|
|
24
|
+
let ApcoreMcpService = class ApcoreMcpService {
|
|
25
|
+
registry;
|
|
26
|
+
executor;
|
|
27
|
+
options;
|
|
28
|
+
_isRunning = false;
|
|
29
|
+
constructor(registry, executor, options) {
|
|
30
|
+
this.registry = registry;
|
|
31
|
+
this.executor = executor;
|
|
32
|
+
this.options = options;
|
|
33
|
+
}
|
|
34
|
+
// -----------------------------------------------------------------------
|
|
35
|
+
// Properties
|
|
36
|
+
// -----------------------------------------------------------------------
|
|
37
|
+
/** Whether the MCP server is currently running. */
|
|
38
|
+
get isRunning() {
|
|
39
|
+
return this._isRunning;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Number of tools available in the registry, filtered by the module-level
|
|
43
|
+
* `tags` and `prefix` options when provided.
|
|
44
|
+
*/
|
|
45
|
+
get toolCount() {
|
|
46
|
+
return this.registry.list({
|
|
47
|
+
tags: this.options.tags ?? undefined,
|
|
48
|
+
prefix: this.options.prefix ?? undefined,
|
|
49
|
+
}).length;
|
|
50
|
+
}
|
|
51
|
+
// -----------------------------------------------------------------------
|
|
52
|
+
// Lifecycle
|
|
53
|
+
// -----------------------------------------------------------------------
|
|
54
|
+
/** Starts the MCP server using the configured transport and options. */
|
|
55
|
+
async start() {
|
|
56
|
+
this._isRunning = true;
|
|
57
|
+
const serveOptions = {};
|
|
58
|
+
// Forward all relevant options to serve()
|
|
59
|
+
if (this.options.transport !== undefined)
|
|
60
|
+
serveOptions.transport = this.options.transport;
|
|
61
|
+
if (this.options.host !== undefined)
|
|
62
|
+
serveOptions.host = this.options.host;
|
|
63
|
+
if (this.options.port !== undefined)
|
|
64
|
+
serveOptions.port = this.options.port;
|
|
65
|
+
if (this.options.name !== undefined)
|
|
66
|
+
serveOptions.name = this.options.name;
|
|
67
|
+
if (this.options.version !== undefined)
|
|
68
|
+
serveOptions.version = this.options.version;
|
|
69
|
+
if (this.options.tags !== undefined)
|
|
70
|
+
serveOptions.tags = this.options.tags;
|
|
71
|
+
if (this.options.prefix !== undefined)
|
|
72
|
+
serveOptions.prefix = this.options.prefix;
|
|
73
|
+
if (this.options.explorer !== undefined)
|
|
74
|
+
serveOptions.explorer = this.options.explorer;
|
|
75
|
+
if (this.options.explorerPrefix !== undefined)
|
|
76
|
+
serveOptions.explorerPrefix = this.options.explorerPrefix;
|
|
77
|
+
if (this.options.allowExecute !== undefined)
|
|
78
|
+
serveOptions.allowExecute = this.options.allowExecute;
|
|
79
|
+
if (this.options.dynamic !== undefined)
|
|
80
|
+
serveOptions.dynamic = this.options.dynamic;
|
|
81
|
+
if (this.options.validateInputs !== undefined)
|
|
82
|
+
serveOptions.validateInputs = this.options.validateInputs;
|
|
83
|
+
if (this.options.logLevel !== undefined)
|
|
84
|
+
serveOptions.logLevel = this.options.logLevel;
|
|
85
|
+
if (this.options.onStartup !== undefined)
|
|
86
|
+
serveOptions.onStartup = this.options.onStartup;
|
|
87
|
+
if (this.options.onShutdown !== undefined)
|
|
88
|
+
serveOptions.onShutdown = this.options.onShutdown;
|
|
89
|
+
if (this.options.metricsCollector !== undefined)
|
|
90
|
+
serveOptions.metricsCollector = this.options.metricsCollector;
|
|
91
|
+
if (this.options.authenticator !== undefined)
|
|
92
|
+
serveOptions.authenticator = this.options.authenticator;
|
|
93
|
+
if (this.options.exemptPaths !== undefined)
|
|
94
|
+
serveOptions.exemptPaths = this.options.exemptPaths;
|
|
95
|
+
await serve(this.executor.raw, serveOptions);
|
|
96
|
+
}
|
|
97
|
+
/** Stops the MCP server. */
|
|
98
|
+
async stop() {
|
|
99
|
+
this._isRunning = false;
|
|
100
|
+
}
|
|
101
|
+
/** Restarts the MCP server (stop, then start). */
|
|
102
|
+
async restart() {
|
|
103
|
+
await this.stop();
|
|
104
|
+
await this.start();
|
|
105
|
+
}
|
|
106
|
+
// -----------------------------------------------------------------------
|
|
107
|
+
// Tool conversion
|
|
108
|
+
// -----------------------------------------------------------------------
|
|
109
|
+
/**
|
|
110
|
+
* Convert the registered tools to OpenAI-compatible tool definitions.
|
|
111
|
+
*
|
|
112
|
+
* Delegates to `toOpenaiTools()` from `apcore-mcp`.
|
|
113
|
+
*/
|
|
114
|
+
toOpenaiTools(options) {
|
|
115
|
+
return toOpenaiTools(this.executor.raw, options);
|
|
116
|
+
}
|
|
117
|
+
// -----------------------------------------------------------------------
|
|
118
|
+
// NestJS lifecycle hooks
|
|
119
|
+
// -----------------------------------------------------------------------
|
|
120
|
+
/**
|
|
121
|
+
* Auto-starts the MCP server when a transport is configured.
|
|
122
|
+
*
|
|
123
|
+
* Uses `OnApplicationBootstrap` (not `OnModuleInit`) so that all
|
|
124
|
+
* tools registered via decorators, programmatic calls, or YAML
|
|
125
|
+
* bindings during `onModuleInit` are available before the server starts.
|
|
126
|
+
*/
|
|
127
|
+
async onApplicationBootstrap() {
|
|
128
|
+
if (this.options.transport) {
|
|
129
|
+
await this.start();
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
/** Auto-stops the MCP server on module destruction. */
|
|
133
|
+
async onModuleDestroy() {
|
|
134
|
+
if (this._isRunning) {
|
|
135
|
+
await this.stop();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
ApcoreMcpService = __decorate([
|
|
140
|
+
Injectable(),
|
|
141
|
+
__param(0, Inject(ApcoreRegistryService)),
|
|
142
|
+
__param(1, Inject(ApcoreExecutorService)),
|
|
143
|
+
__param(2, Inject(APCORE_MCP_MODULE_OPTIONS)),
|
|
144
|
+
__metadata("design:paramtypes", [ApcoreRegistryService,
|
|
145
|
+
ApcoreExecutorService, Object])
|
|
146
|
+
], ApcoreMcpService);
|
|
147
|
+
export { ApcoreMcpService };
|
|
148
|
+
//# sourceMappingURL=apcore-mcp.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apcore-mcp.service.js","sourceRoot":"","sources":["../../src/mcp/apcore-mcp.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAElD,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAG5D;;;;;GAKG;AAEI,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IAKR;IAEA;IAEA;IARX,UAAU,GAAG,KAAK,CAAC;IAE3B,YAEmB,QAA+B,EAE/B,QAA+B,EAE/B,OAA+B;QAJ/B,aAAQ,GAAR,QAAQ,CAAuB;QAE/B,aAAQ,GAAR,QAAQ,CAAuB;QAE/B,YAAO,GAAP,OAAO,CAAwB;IAC/C,CAAC;IAEJ,0EAA0E;IAC1E,aAAa;IACb,0EAA0E;IAE1E,mDAAmD;IACnD,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAED;;;OAGG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC;YACxB,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,SAAS;YACpC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,SAAS;SACzC,CAAC,CAAC,MAAM,CAAC;IACZ,CAAC;IAED,0EAA0E;IAC1E,YAAY;IACZ,0EAA0E;IAE1E,wEAAwE;IACxE,KAAK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K,CAAC;IAC1B,CAAC;IAED,kDAAkD;IAClD,KAAK,CAAC,OAAO;QACX,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;IACrB,CAAC;IAED,0EAA0E;IAC1E,kBAAkB;IAClB,0EAA0E;IAE1E;;;;OAIG;IACH,aAAa,CAAC,OAKb;QACC,OAAO,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IACnD,CAAC;IAED,0EAA0E;IAC1E,yBAAyB;IACzB,0EAA0E;IAE1E;;;;;;OAMG;IACH,KAAK,CAAC,sBAAsB;QAC1B,IAAI,IAAI,CAAC,OAAO,CAAC,SAAS,EAAE,CAAC;YAC3B,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACrB,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,KAAK,CAAC,eAAe;QACnB,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACpB,MAAM,IAAI,CAAC,IAAI,EAAE,CAAC;QACpB,CAAC;IACH,CAAC;CACF,CAAA;AArHY,gBAAgB;IAD5B,UAAU,EAAE;IAKR,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAE7B,WAAA,MAAM,CAAC,qBAAqB,CAAC,CAAA;IAE7B,WAAA,MAAM,CAAC,yBAAyB,CAAC,CAAA;qCAHP,qBAAqB;QAErB,qBAAqB;GAPvC,gBAAgB,CAqH5B"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { TSchema } from '@sinclair/typebox';
|
|
2
|
+
import type { SchemaAdapter } from './schema-adapter.interface.js';
|
|
3
|
+
/**
|
|
4
|
+
* SchemaAdapter that converts class-validator decorated DTO classes into
|
|
5
|
+
* JSON Schema / TSchema objects.
|
|
6
|
+
*
|
|
7
|
+
* Detection relies on querying class-validator's global MetadataStorage for
|
|
8
|
+
* validation metadata associated with the target constructor.
|
|
9
|
+
*/
|
|
10
|
+
export declare class DtoAdapter implements SchemaAdapter {
|
|
11
|
+
readonly name: "dto";
|
|
12
|
+
readonly priority = 20;
|
|
13
|
+
/**
|
|
14
|
+
* Returns `true` when `input` is a class constructor that has at least one
|
|
15
|
+
* class-validator decorator registered in the global MetadataStorage.
|
|
16
|
+
*/
|
|
17
|
+
detect(input: unknown): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Converts a class-validator DTO into a TSchema-compatible JSON Schema
|
|
20
|
+
* object (type: 'object' with properties and required).
|
|
21
|
+
*/
|
|
22
|
+
extract(input: unknown): TSchema;
|
|
23
|
+
/**
|
|
24
|
+
* Reads class-validator metadata from the global MetadataStorage and builds
|
|
25
|
+
* a JSON Schema object.
|
|
26
|
+
*
|
|
27
|
+
* Mapping rules:
|
|
28
|
+
* - isString -> type: 'string'
|
|
29
|
+
* - isNumber -> type: 'number'
|
|
30
|
+
* - isInt -> type: 'integer'
|
|
31
|
+
* - isBoolean -> type: 'boolean'
|
|
32
|
+
* - isEmail -> type: 'string', format: 'email'
|
|
33
|
+
* - isUrl / isURL -> type: 'string', format: 'uri'
|
|
34
|
+
* - isEnum -> type: 'string', enum: Object.values(constraints[0])
|
|
35
|
+
* - isOptional -> not included in required[]
|
|
36
|
+
* - minLength -> minLength constraint
|
|
37
|
+
* - maxLength -> maxLength constraint
|
|
38
|
+
* - min -> minimum
|
|
39
|
+
* - max -> maximum
|
|
40
|
+
* - isArray -> type: 'array'
|
|
41
|
+
*/
|
|
42
|
+
extractJsonSchema(input: unknown): Record<string, unknown>;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=dto.adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dto.adapter.d.ts","sourceRoot":"","sources":["../../../src/schema/adapters/dto.adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAwDnE;;;;;;GAMG;AACH,qBAAa,UAAW,YAAW,aAAa;IAC9C,QAAQ,CAAC,IAAI,EAAG,KAAK,CAAU;IAC/B,QAAQ,CAAC,QAAQ,MAAM;IAEvB;;;OAGG;IACH,MAAM,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAmB/B;;;OAGG;IACH,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO;IAIhC;;;;;;;;;;;;;;;;;;OAkBG;IACH,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAiI3D"}
|