@carlonicora/nestjs-neo4jsonapi 1.80.0 → 1.82.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/dist/config/base.config.d.ts.map +1 -1
- package/dist/config/base.config.js +2 -0
- package/dist/config/base.config.js.map +1 -1
- package/dist/config/interfaces/config.ai.interface.d.ts +14 -0
- package/dist/config/interfaces/config.ai.interface.d.ts.map +1 -1
- package/dist/core/index.d.ts +4 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +12 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/llm/services/audio/ffmpeg-transcode.d.ts +6 -0
- package/dist/core/llm/services/audio/ffmpeg-transcode.d.ts.map +1 -1
- package/dist/core/llm/services/audio/ffmpeg-transcode.js +4 -5
- package/dist/core/llm/services/audio/ffmpeg-transcode.js.map +1 -1
- package/dist/core/llm/services/audio.llm.service.d.ts.map +1 -1
- package/dist/core/llm/services/audio.llm.service.js +42 -17
- package/dist/core/llm/services/audio.llm.service.js.map +1 -1
- package/dist/core/model-manager/index.d.ts +8 -0
- package/dist/core/model-manager/index.d.ts.map +1 -0
- package/dist/core/model-manager/index.js +26 -0
- package/dist/core/model-manager/index.js.map +1 -0
- package/dist/core/model-manager/model-loader.d.ts +22 -0
- package/dist/core/model-manager/model-loader.d.ts.map +1 -0
- package/dist/core/model-manager/model-loader.js +213 -0
- package/dist/core/model-manager/model-loader.js.map +1 -0
- package/dist/core/model-manager/model-manager.config.d.ts +81 -0
- package/dist/core/model-manager/model-manager.config.d.ts.map +1 -0
- package/dist/core/model-manager/model-manager.config.js +8 -0
- package/dist/core/model-manager/model-manager.config.js.map +1 -0
- package/dist/core/model-manager/model-manager.module.d.ts +12 -0
- package/dist/core/model-manager/model-manager.module.d.ts.map +1 -0
- package/dist/core/model-manager/model-manager.module.js +31 -0
- package/dist/core/model-manager/model-manager.module.js.map +1 -0
- package/dist/core/model-manager/model-manager.service.d.ts +65 -0
- package/dist/core/model-manager/model-manager.service.d.ts.map +1 -0
- package/dist/core/model-manager/model-manager.service.js +428 -0
- package/dist/core/model-manager/model-manager.service.js.map +1 -0
- package/dist/core/onnx-runtime/index.d.ts +5 -0
- package/dist/core/onnx-runtime/index.d.ts.map +1 -0
- package/dist/core/onnx-runtime/index.js +10 -0
- package/dist/core/onnx-runtime/index.js.map +1 -0
- package/dist/core/onnx-runtime/onnx-runtime.config.d.ts +72 -0
- package/dist/core/onnx-runtime/onnx-runtime.config.d.ts.map +1 -0
- package/dist/core/onnx-runtime/onnx-runtime.config.js +12 -0
- package/dist/core/onnx-runtime/onnx-runtime.config.js.map +1 -0
- package/dist/core/onnx-runtime/onnx-runtime.constants.d.ts +5 -0
- package/dist/core/onnx-runtime/onnx-runtime.constants.d.ts.map +1 -0
- package/dist/core/onnx-runtime/onnx-runtime.constants.js +8 -0
- package/dist/core/onnx-runtime/onnx-runtime.constants.js.map +1 -0
- package/dist/core/onnx-runtime/onnx-runtime.module.d.ts +67 -0
- package/dist/core/onnx-runtime/onnx-runtime.module.d.ts.map +1 -0
- package/dist/core/onnx-runtime/onnx-runtime.module.js +103 -0
- package/dist/core/onnx-runtime/onnx-runtime.module.js.map +1 -0
- package/dist/core/onnx-runtime/onnx-runtime.service.d.ts +58 -0
- package/dist/core/onnx-runtime/onnx-runtime.service.d.ts.map +1 -0
- package/dist/core/onnx-runtime/onnx-runtime.service.js +149 -0
- package/dist/core/onnx-runtime/onnx-runtime.service.js.map +1 -0
- package/dist/scripts/generate-module/__tests__/entity.spec.d.ts +2 -0
- package/dist/scripts/generate-module/__tests__/entity.spec.d.ts.map +1 -0
- package/dist/scripts/generate-module/__tests__/entity.spec.js +58 -0
- package/dist/scripts/generate-module/__tests__/entity.spec.js.map +1 -0
- package/dist/scripts/generate-module/__tests__/fixtures.d.ts +3 -0
- package/dist/scripts/generate-module/__tests__/fixtures.d.ts.map +1 -0
- package/dist/scripts/generate-module/__tests__/fixtures.js +31 -0
- package/dist/scripts/generate-module/__tests__/fixtures.js.map +1 -0
- package/dist/scripts/generate-module/__tests__/plumbing.spec.d.ts +2 -0
- package/dist/scripts/generate-module/__tests__/plumbing.spec.d.ts.map +1 -0
- package/dist/scripts/generate-module/__tests__/plumbing.spec.js +19 -0
- package/dist/scripts/generate-module/__tests__/plumbing.spec.js.map +1 -0
- package/dist/scripts/generate-module/__tests__/service-module.spec.d.ts +2 -0
- package/dist/scripts/generate-module/__tests__/service-module.spec.d.ts.map +1 -0
- package/dist/scripts/generate-module/__tests__/service-module.spec.js +33 -0
- package/dist/scripts/generate-module/__tests__/service-module.spec.js.map +1 -0
- package/dist/scripts/generate-module/generator.d.ts.map +1 -1
- package/dist/scripts/generate-module/generator.js +8 -0
- package/dist/scripts/generate-module/generator.js.map +1 -1
- package/dist/scripts/generate-module/templates/entity.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/entity.template.js +26 -8
- package/dist/scripts/generate-module/templates/entity.template.js.map +1 -1
- package/dist/scripts/generate-module/templates/module.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/module.template.js +14 -10
- package/dist/scripts/generate-module/templates/module.template.js.map +1 -1
- package/dist/scripts/generate-module/templates/service.spec.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/service.spec.template.js +16 -1
- package/dist/scripts/generate-module/templates/service.spec.template.js.map +1 -1
- package/dist/scripts/generate-module/templates/service.template.d.ts.map +1 -1
- package/dist/scripts/generate-module/templates/service.template.js +3 -1
- package/dist/scripts/generate-module/templates/service.template.js.map +1 -1
- package/dist/scripts/generate-module/transformers/relationship-mapper.d.ts.map +1 -1
- package/dist/scripts/generate-module/transformers/relationship-mapper.js +5 -0
- package/dist/scripts/generate-module/transformers/relationship-mapper.js.map +1 -1
- package/dist/scripts/generate-module/types/json-schema.interface.d.ts +18 -0
- package/dist/scripts/generate-module/types/json-schema.interface.d.ts.map +1 -1
- package/dist/scripts/generate-module/types/template-data.interface.d.ts +14 -0
- package/dist/scripts/generate-module/types/template-data.interface.d.ts.map +1 -1
- package/package.json +6 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { DynamicModule } from "@nestjs/common";
|
|
2
|
+
import { OnnxRuntimeModuleOptions } from "./onnx-runtime.config";
|
|
3
|
+
interface OnnxRuntimeAsyncOptions {
|
|
4
|
+
imports?: any[];
|
|
5
|
+
inject?: any[];
|
|
6
|
+
useFactory: (...args: any[]) => Promise<OnnxRuntimeModuleOptions> | OnnxRuntimeModuleOptions;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Global NestJS module for ONNX Runtime session management.
|
|
10
|
+
*
|
|
11
|
+
* This module provides centralized ONNX model loading and session management.
|
|
12
|
+
* It uses OnApplicationBootstrap to load models AFTER @huggingface/transformers
|
|
13
|
+
* services (which use OnModuleInit), avoiding potential conflicts.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* // In your root module (e.g., FeaturesModules)
|
|
18
|
+
* import { OnnxRuntimeModule } from 'src/common/onnx-runtime';
|
|
19
|
+
*
|
|
20
|
+
* const ONNX_MODELS: OnnxModelConfig[] = [
|
|
21
|
+
* { name: 'yolo-pose', path: 'models/yolo11l-pose.onnx', priority: 1, optional: false },
|
|
22
|
+
* { name: 'arcface', path: 'models/arcface.onnx', priority: 2, optional: false },
|
|
23
|
+
* ];
|
|
24
|
+
*
|
|
25
|
+
* @Module({
|
|
26
|
+
* imports: [
|
|
27
|
+
* OnnxRuntimeModule.forRoot({ models: ONNX_MODELS }),
|
|
28
|
+
* ],
|
|
29
|
+
* })
|
|
30
|
+
* export class FeaturesModules {}
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* // In your service
|
|
36
|
+
* import { OnnxRuntimeService } from 'src/common/onnx-runtime';
|
|
37
|
+
*
|
|
38
|
+
* @Injectable()
|
|
39
|
+
* export class MyDetectionService {
|
|
40
|
+
* constructor(private readonly onnxService: OnnxRuntimeService) {}
|
|
41
|
+
*
|
|
42
|
+
* async detect(buffer: Buffer) {
|
|
43
|
+
* const session = this.onnxService.getSession('yolo-pose');
|
|
44
|
+
* if (!session) throw new Error('Model not loaded');
|
|
45
|
+
* // ... run inference
|
|
46
|
+
* }
|
|
47
|
+
* }
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare class OnnxRuntimeModule {
|
|
51
|
+
/**
|
|
52
|
+
* Configure the ONNX Runtime module with model definitions.
|
|
53
|
+
*
|
|
54
|
+
* @param options - Configuration including models to load
|
|
55
|
+
* @returns Dynamic module configuration
|
|
56
|
+
*/
|
|
57
|
+
static forRoot(options: OnnxRuntimeModuleOptions): DynamicModule;
|
|
58
|
+
/**
|
|
59
|
+
* Configure the ONNX Runtime module asynchronously with ConfigService.
|
|
60
|
+
*
|
|
61
|
+
* @param options - Async configuration including factory function
|
|
62
|
+
* @returns Dynamic module configuration
|
|
63
|
+
*/
|
|
64
|
+
static forRootAsync(options: OnnxRuntimeAsyncOptions): DynamicModule;
|
|
65
|
+
}
|
|
66
|
+
export {};
|
|
67
|
+
//# sourceMappingURL=onnx-runtime.module.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onnx-runtime.module.d.ts","sourceRoot":"","sources":["../../../src/core/onnx-runtime/onnx-runtime.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAkB,MAAM,gBAAgB,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AAKjE,UAAU,uBAAuB;IAC/B,OAAO,CAAC,EAAE,GAAG,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,GAAG,EAAE,CAAC;IACf,UAAU,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,OAAO,CAAC,wBAAwB,CAAC,GAAG,wBAAwB,CAAC;CAC9F;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AACH,qBAEa,iBAAiB;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAO,EAAE,wBAAwB,GAAG,aAAa;IAchE;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,uBAAuB,GAAG,aAAa;CAerE"}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var OnnxRuntimeModule_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.OnnxRuntimeModule = void 0;
|
|
11
|
+
const common_1 = require("@nestjs/common");
|
|
12
|
+
const onnx_runtime_service_1 = require("./onnx-runtime.service");
|
|
13
|
+
const onnx_runtime_constants_1 = require("./onnx-runtime.constants");
|
|
14
|
+
/**
|
|
15
|
+
* Global NestJS module for ONNX Runtime session management.
|
|
16
|
+
*
|
|
17
|
+
* This module provides centralized ONNX model loading and session management.
|
|
18
|
+
* It uses OnApplicationBootstrap to load models AFTER @huggingface/transformers
|
|
19
|
+
* services (which use OnModuleInit), avoiding potential conflicts.
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // In your root module (e.g., FeaturesModules)
|
|
24
|
+
* import { OnnxRuntimeModule } from 'src/common/onnx-runtime';
|
|
25
|
+
*
|
|
26
|
+
* const ONNX_MODELS: OnnxModelConfig[] = [
|
|
27
|
+
* { name: 'yolo-pose', path: 'models/yolo11l-pose.onnx', priority: 1, optional: false },
|
|
28
|
+
* { name: 'arcface', path: 'models/arcface.onnx', priority: 2, optional: false },
|
|
29
|
+
* ];
|
|
30
|
+
*
|
|
31
|
+
* @Module({
|
|
32
|
+
* imports: [
|
|
33
|
+
* OnnxRuntimeModule.forRoot({ models: ONNX_MODELS }),
|
|
34
|
+
* ],
|
|
35
|
+
* })
|
|
36
|
+
* export class FeaturesModules {}
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* // In your service
|
|
42
|
+
* import { OnnxRuntimeService } from 'src/common/onnx-runtime';
|
|
43
|
+
*
|
|
44
|
+
* @Injectable()
|
|
45
|
+
* export class MyDetectionService {
|
|
46
|
+
* constructor(private readonly onnxService: OnnxRuntimeService) {}
|
|
47
|
+
*
|
|
48
|
+
* async detect(buffer: Buffer) {
|
|
49
|
+
* const session = this.onnxService.getSession('yolo-pose');
|
|
50
|
+
* if (!session) throw new Error('Model not loaded');
|
|
51
|
+
* // ... run inference
|
|
52
|
+
* }
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
let OnnxRuntimeModule = OnnxRuntimeModule_1 = class OnnxRuntimeModule {
|
|
57
|
+
/**
|
|
58
|
+
* Configure the ONNX Runtime module with model definitions.
|
|
59
|
+
*
|
|
60
|
+
* @param options - Configuration including models to load
|
|
61
|
+
* @returns Dynamic module configuration
|
|
62
|
+
*/
|
|
63
|
+
static forRoot(options) {
|
|
64
|
+
return {
|
|
65
|
+
module: OnnxRuntimeModule_1,
|
|
66
|
+
providers: [
|
|
67
|
+
{
|
|
68
|
+
provide: onnx_runtime_constants_1.ONNX_RUNTIME_OPTIONS,
|
|
69
|
+
useValue: options,
|
|
70
|
+
},
|
|
71
|
+
onnx_runtime_service_1.OnnxRuntimeService,
|
|
72
|
+
],
|
|
73
|
+
exports: [onnx_runtime_service_1.OnnxRuntimeService],
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Configure the ONNX Runtime module asynchronously with ConfigService.
|
|
78
|
+
*
|
|
79
|
+
* @param options - Async configuration including factory function
|
|
80
|
+
* @returns Dynamic module configuration
|
|
81
|
+
*/
|
|
82
|
+
static forRootAsync(options) {
|
|
83
|
+
return {
|
|
84
|
+
module: OnnxRuntimeModule_1,
|
|
85
|
+
imports: options.imports || [],
|
|
86
|
+
providers: [
|
|
87
|
+
{
|
|
88
|
+
provide: onnx_runtime_constants_1.ONNX_RUNTIME_OPTIONS,
|
|
89
|
+
useFactory: options.useFactory,
|
|
90
|
+
inject: options.inject || [],
|
|
91
|
+
},
|
|
92
|
+
onnx_runtime_service_1.OnnxRuntimeService,
|
|
93
|
+
],
|
|
94
|
+
exports: [onnx_runtime_service_1.OnnxRuntimeService],
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
exports.OnnxRuntimeModule = OnnxRuntimeModule;
|
|
99
|
+
exports.OnnxRuntimeModule = OnnxRuntimeModule = OnnxRuntimeModule_1 = __decorate([
|
|
100
|
+
(0, common_1.Global)(),
|
|
101
|
+
(0, common_1.Module)({})
|
|
102
|
+
], OnnxRuntimeModule);
|
|
103
|
+
//# sourceMappingURL=onnx-runtime.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onnx-runtime.module.js","sourceRoot":"","sources":["../../../src/core/onnx-runtime/onnx-runtime.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,2CAA+D;AAE/D,iEAA4D;AAC5D,qEAAgE;AAShE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyCG;AAGI,IAAM,iBAAiB,yBAAvB,MAAM,iBAAiB;IAC5B;;;;;OAKG;IACH,MAAM,CAAC,OAAO,CAAC,OAAiC;QAC9C,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,6CAAoB;oBAC7B,QAAQ,EAAE,OAAO;iBAClB;gBACD,yCAAkB;aACnB;YACD,OAAO,EAAE,CAAC,yCAAkB,CAAC;SAC9B,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAC,OAAgC;QAClD,OAAO;YACL,MAAM,EAAE,mBAAiB;YACzB,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,EAAE;YAC9B,SAAS,EAAE;gBACT;oBACE,OAAO,EAAE,6CAAoB;oBAC7B,UAAU,EAAE,OAAO,CAAC,UAAU;oBAC9B,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,EAAE;iBAC7B;gBACD,yCAAkB;aACnB;YACD,OAAO,EAAE,CAAC,yCAAkB,CAAC;SAC9B,CAAC;IACJ,CAAC;CACF,CAAA;AA1CY,8CAAiB;4BAAjB,iBAAiB;IAF7B,IAAA,eAAM,GAAE;IACR,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,iBAAiB,CA0C7B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as ort from "onnxruntime-node";
|
|
2
|
+
import { OnnxRuntimeModuleOptions } from "./onnx-runtime.config";
|
|
3
|
+
import { ModelManagerService } from "../model-manager/model-manager.service";
|
|
4
|
+
/**
|
|
5
|
+
* ONNX Runtime service for session configuration and access.
|
|
6
|
+
*
|
|
7
|
+
* This service now delegates to ModelManagerService for model loading.
|
|
8
|
+
* It maintains backward compatibility by providing session access methods.
|
|
9
|
+
*
|
|
10
|
+
* The service uses OnApplicationBootstrap instead of OnModuleInit to ensure
|
|
11
|
+
* @huggingface/transformers services (which use OnModuleInit) load their models first,
|
|
12
|
+
* avoiding potential conflicts with the shared native ONNX Runtime.
|
|
13
|
+
*/
|
|
14
|
+
export declare class OnnxRuntimeService {
|
|
15
|
+
private readonly modelManager;
|
|
16
|
+
private readonly logger;
|
|
17
|
+
private readonly sessionOptions;
|
|
18
|
+
private readonly options;
|
|
19
|
+
constructor(options: OnnxRuntimeModuleOptions, modelManager: ModelManagerService);
|
|
20
|
+
/**
|
|
21
|
+
* Configure the ONNX Runtime global environment.
|
|
22
|
+
* Called once during service construction.
|
|
23
|
+
*/
|
|
24
|
+
private configureRuntime;
|
|
25
|
+
/**
|
|
26
|
+
* Build session options from configuration.
|
|
27
|
+
* Note: These options are no longer used directly for loading
|
|
28
|
+
* (ModelManagerService handles that), but kept for backward compatibility.
|
|
29
|
+
*/
|
|
30
|
+
private buildSessionOptions;
|
|
31
|
+
/**
|
|
32
|
+
* Get a loaded session by name.
|
|
33
|
+
* Delegates to ModelManagerService.
|
|
34
|
+
*
|
|
35
|
+
* @param name - The model name as configured in models.config.yaml
|
|
36
|
+
* @returns The InferenceSession, or null if not loaded
|
|
37
|
+
*/
|
|
38
|
+
getSession(name: string): ort.InferenceSession | null;
|
|
39
|
+
/**
|
|
40
|
+
* Check if a model is loaded and ready.
|
|
41
|
+
* Delegates to ModelManagerService.
|
|
42
|
+
*
|
|
43
|
+
* @param name - The model name
|
|
44
|
+
* @returns true if the model is loaded
|
|
45
|
+
*/
|
|
46
|
+
isModelLoaded(name: string): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Wait for all models to be loaded.
|
|
49
|
+
* Services that depend on ONNX models should call this before accessing them.
|
|
50
|
+
*/
|
|
51
|
+
waitForReady(): Promise<void>;
|
|
52
|
+
/**
|
|
53
|
+
* Get all loaded ONNX model names.
|
|
54
|
+
* Delegates to ModelManagerService.
|
|
55
|
+
*/
|
|
56
|
+
getLoadedModels(): string[];
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=onnx-runtime.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onnx-runtime.service.d.ts","sourceRoot":"","sources":["../../../src/core/onnx-runtime/onnx-runtime.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,GAAG,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,wBAAwB,EAAgC,MAAM,uBAAuB,CAAC;AAE/F,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAE7E;;;;;;;;;GASG;AACH,qBACa,kBAAkB;IAQ3B,OAAO,CAAC,QAAQ,CAAC,YAAY;IAP/B,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;IAC9D,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAsC;IACrE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;gBAI3D,OAAO,EAAE,wBAAwB,EAChB,YAAY,EAAE,mBAAmB;IAepD;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IAcxB;;;;OAIG;IACH,OAAO,CAAC,mBAAmB;IAW3B;;;;;;OAMG;IACH,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,gBAAgB,GAAG,IAAI;IAIrD;;;;;;OAMG;IACH,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIpC;;;OAGG;IACG,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAInC;;;OAGG;IACH,eAAe,IAAI,MAAM,EAAE;CAI5B"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
|
+
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;
|
|
22
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
|
+
};
|
|
24
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
25
|
+
var ownKeys = function(o) {
|
|
26
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
27
|
+
var ar = [];
|
|
28
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
29
|
+
return ar;
|
|
30
|
+
};
|
|
31
|
+
return ownKeys(o);
|
|
32
|
+
};
|
|
33
|
+
return function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
})();
|
|
41
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
42
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
43
|
+
};
|
|
44
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
45
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
46
|
+
};
|
|
47
|
+
var OnnxRuntimeService_1;
|
|
48
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
49
|
+
exports.OnnxRuntimeService = void 0;
|
|
50
|
+
const common_1 = require("@nestjs/common");
|
|
51
|
+
const ort = __importStar(require("onnxruntime-node"));
|
|
52
|
+
const onnx_runtime_config_1 = require("./onnx-runtime.config");
|
|
53
|
+
const onnx_runtime_constants_1 = require("./onnx-runtime.constants");
|
|
54
|
+
const model_manager_service_1 = require("../model-manager/model-manager.service");
|
|
55
|
+
/**
|
|
56
|
+
* ONNX Runtime service for session configuration and access.
|
|
57
|
+
*
|
|
58
|
+
* This service now delegates to ModelManagerService for model loading.
|
|
59
|
+
* It maintains backward compatibility by providing session access methods.
|
|
60
|
+
*
|
|
61
|
+
* The service uses OnApplicationBootstrap instead of OnModuleInit to ensure
|
|
62
|
+
* @huggingface/transformers services (which use OnModuleInit) load their models first,
|
|
63
|
+
* avoiding potential conflicts with the shared native ONNX Runtime.
|
|
64
|
+
*/
|
|
65
|
+
let OnnxRuntimeService = OnnxRuntimeService_1 = class OnnxRuntimeService {
|
|
66
|
+
constructor(options, modelManager) {
|
|
67
|
+
this.modelManager = modelManager;
|
|
68
|
+
this.logger = new common_1.Logger(OnnxRuntimeService_1.name);
|
|
69
|
+
// Merge with defaults
|
|
70
|
+
this.options = {
|
|
71
|
+
...onnx_runtime_config_1.DEFAULT_ONNX_RUNTIME_OPTIONS,
|
|
72
|
+
...options,
|
|
73
|
+
};
|
|
74
|
+
// Configure ONNX Runtime environment ONCE at construction
|
|
75
|
+
this.configureRuntime();
|
|
76
|
+
// Build session options for backward compatibility
|
|
77
|
+
this.sessionOptions = this.buildSessionOptions();
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Configure the ONNX Runtime global environment.
|
|
81
|
+
* Called once during service construction.
|
|
82
|
+
*/
|
|
83
|
+
configureRuntime() {
|
|
84
|
+
// Disable telemetry
|
|
85
|
+
ort.env.telemetry = false;
|
|
86
|
+
// Set log level to 'fatal' to silence verbose BFCArena/memory allocation logs
|
|
87
|
+
// Only critical errors will be shown
|
|
88
|
+
ort.env.logLevel = "fatal";
|
|
89
|
+
this.logger.log(`ONNX Runtime configured: threads=${this.options.intraOpNumThreads}/${this.options.interOpNumThreads}, ` +
|
|
90
|
+
`optimization=${this.options.graphOptimizationLevel}`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* Build session options from configuration.
|
|
94
|
+
* Note: These options are no longer used directly for loading
|
|
95
|
+
* (ModelManagerService handles that), but kept for backward compatibility.
|
|
96
|
+
*/
|
|
97
|
+
buildSessionOptions() {
|
|
98
|
+
return {
|
|
99
|
+
executionProviders: ["cpu"],
|
|
100
|
+
graphOptimizationLevel: this.options.graphOptimizationLevel,
|
|
101
|
+
intraOpNumThreads: this.options.intraOpNumThreads,
|
|
102
|
+
interOpNumThreads: this.options.interOpNumThreads,
|
|
103
|
+
enableCpuMemArena: true,
|
|
104
|
+
enableMemPattern: true,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Get a loaded session by name.
|
|
109
|
+
* Delegates to ModelManagerService.
|
|
110
|
+
*
|
|
111
|
+
* @param name - The model name as configured in models.config.yaml
|
|
112
|
+
* @returns The InferenceSession, or null if not loaded
|
|
113
|
+
*/
|
|
114
|
+
getSession(name) {
|
|
115
|
+
return this.modelManager.getOnnxSession(name);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Check if a model is loaded and ready.
|
|
119
|
+
* Delegates to ModelManagerService.
|
|
120
|
+
*
|
|
121
|
+
* @param name - The model name
|
|
122
|
+
* @returns true if the model is loaded
|
|
123
|
+
*/
|
|
124
|
+
isModelLoaded(name) {
|
|
125
|
+
return this.modelManager.isModelLoaded(name, "onnx");
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Wait for all models to be loaded.
|
|
129
|
+
* Services that depend on ONNX models should call this before accessing them.
|
|
130
|
+
*/
|
|
131
|
+
async waitForReady() {
|
|
132
|
+
return this.modelManager.waitForReady();
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Get all loaded ONNX model names.
|
|
136
|
+
* Delegates to ModelManagerService.
|
|
137
|
+
*/
|
|
138
|
+
getLoadedModels() {
|
|
139
|
+
const loaded = this.modelManager.getLoadedModels();
|
|
140
|
+
return loaded.onnx;
|
|
141
|
+
}
|
|
142
|
+
};
|
|
143
|
+
exports.OnnxRuntimeService = OnnxRuntimeService;
|
|
144
|
+
exports.OnnxRuntimeService = OnnxRuntimeService = OnnxRuntimeService_1 = __decorate([
|
|
145
|
+
(0, common_1.Injectable)(),
|
|
146
|
+
__param(0, (0, common_1.Inject)(onnx_runtime_constants_1.ONNX_RUNTIME_OPTIONS)),
|
|
147
|
+
__metadata("design:paramtypes", [Object, model_manager_service_1.ModelManagerService])
|
|
148
|
+
], OnnxRuntimeService);
|
|
149
|
+
//# sourceMappingURL=onnx-runtime.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"onnx-runtime.service.js","sourceRoot":"","sources":["../../../src/core/onnx-runtime/onnx-runtime.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4D;AAC5D,sDAAwC;AACxC,+DAA+F;AAC/F,qEAAgE;AAChE,kFAA6E;AAE7E;;;;;;;;;GASG;AAEI,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAK7B,YAEE,OAAiC,EAChB,YAAiC;QAAjC,iBAAY,GAAZ,YAAY,CAAqB;QAPnC,WAAM,GAAG,IAAI,eAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;QAS5D,sBAAsB;QACtB,IAAI,CAAC,OAAO,GAAG;YACb,GAAG,kDAA4B;YAC/B,GAAG,OAAO;SAC2B,CAAC;QAExC,0DAA0D;QAC1D,IAAI,CAAC,gBAAgB,EAAE,CAAC;QAExB,mDAAmD;QACnD,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,mBA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/FY,gDAAkB;6BAAlB,kBAAkB;IAD9B,IAAA,mBAAU,GAAE;IAOR,WAAA,IAAA,eAAM,EAAC,6CAAoB,CAAC,CAAA;6CAEE,2CAAmB;GARzC,kBAAkB,CA+F9B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.spec.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/__tests__/entity.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const fixtures_1 = require("./fixtures");
|
|
5
|
+
const entity_template_1 = require("../templates/entity.template");
|
|
6
|
+
(0, vitest_1.describe)("backend entity template", () => {
|
|
7
|
+
(0, vitest_1.it)("emits entity-level description and chat", () => {
|
|
8
|
+
const out = (0, entity_template_1.generateEntityFile)((0, fixtures_1.makeTemplateData)({
|
|
9
|
+
description: "A demo widget.",
|
|
10
|
+
chat: { summary: "data.name ?? data.id", textSearchFields: ["name"] },
|
|
11
|
+
}));
|
|
12
|
+
(0, vitest_1.expect)(out).toContain('"A demo widget."');
|
|
13
|
+
(0, vitest_1.expect)(out).toContain("chat:");
|
|
14
|
+
(0, vitest_1.expect)(out).toContain("summary: (data) => data.name ?? data.id");
|
|
15
|
+
(0, vitest_1.expect)(out).toContain('textSearchFields: ["name"]');
|
|
16
|
+
});
|
|
17
|
+
(0, vitest_1.it)("emits field description and kind", () => {
|
|
18
|
+
const out = (0, entity_template_1.generateEntityFile)((0, fixtures_1.makeTemplateData)({
|
|
19
|
+
fields: [{ name: "value", type: "number", required: false, tsType: "number", description: "Money.", kind: { type: "money" } }],
|
|
20
|
+
}));
|
|
21
|
+
(0, vitest_1.expect)(out).toContain('value: { type: "number", description: "Money.", kind: { type: "money" } }');
|
|
22
|
+
});
|
|
23
|
+
(0, vitest_1.it)("moves readOnly+computed fields into computed{} and out of fields{}", () => {
|
|
24
|
+
const out = (0, entity_template_1.generateEntityFile)((0, fixtures_1.makeTemplateData)({
|
|
25
|
+
fields: [
|
|
26
|
+
{ name: "name", type: "string", required: true, tsType: "string" },
|
|
27
|
+
{ name: "effective_value", type: "number", required: false, tsType: "number", readOnly: true, computed: "p.record?.get('effective_value') ?? undefined" },
|
|
28
|
+
],
|
|
29
|
+
}));
|
|
30
|
+
(0, vitest_1.expect)(out).toContain("effective_value?: number;"); // present in entity TS type
|
|
31
|
+
(0, vitest_1.expect)(out).toContain("computed: {"); // computed block present
|
|
32
|
+
(0, vitest_1.expect)(out).toContain("effective_value: {");
|
|
33
|
+
(0, vitest_1.expect)(out).toContain("compute: (p) => p.record?.get('effective_value') ?? undefined");
|
|
34
|
+
(0, vitest_1.expect)(out).not.toMatch(/effective_value:\s*\{\s*type:/); // absent from fields{} block
|
|
35
|
+
});
|
|
36
|
+
(0, vitest_1.it)("excludes a computed field from fields{} even when not readOnly", () => {
|
|
37
|
+
const out = (0, entity_template_1.generateEntityFile)((0, fixtures_1.makeTemplateData)({
|
|
38
|
+
fields: [
|
|
39
|
+
{ name: "name", type: "string", required: true, tsType: "string" },
|
|
40
|
+
{ name: "score", type: "number", required: false, tsType: "number", computed: "p.record?.get('score') ?? 0" },
|
|
41
|
+
],
|
|
42
|
+
}));
|
|
43
|
+
(0, vitest_1.expect)(out).not.toMatch(/score:\s*\{\s*type:/); // not in fields{}
|
|
44
|
+
(0, vitest_1.expect)(out).toContain("compute: (p) => p.record?.get('score') ?? 0"); // in computed{}
|
|
45
|
+
});
|
|
46
|
+
(0, vitest_1.it)("emits relationship description", () => {
|
|
47
|
+
const out = (0, entity_template_1.generateEntityFile)((0, fixtures_1.makeTemplateData)({
|
|
48
|
+
relationships: [{
|
|
49
|
+
key: "account", model: "accountMeta", direction: "out", relationship: "FOR",
|
|
50
|
+
cardinality: "one", required: true, dtoKey: "account", description: "The owning account.",
|
|
51
|
+
relatedEntity: { name: "Account", directory: "crm", pascalCase: "Account", camelCase: "account", kebabCase: "account" },
|
|
52
|
+
isNewStructure: false,
|
|
53
|
+
}],
|
|
54
|
+
}));
|
|
55
|
+
(0, vitest_1.expect)(out).toContain('description: "The owning account."');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=entity.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entity.spec.js","sourceRoot":"","sources":["../../../../scripts/generate-module/__tests__/entity.spec.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,yCAA8C;AAC9C,kEAAkE;AAElE,IAAA,iBAAQ,EAAC,yBAAyB,EAAE,GAAG,EAAE;IACvC,IAAA,WAAE,EAAC,yCAAyC,EAAE,GAAG,EAAE;QACjD,MAAM,GAAG,GAAG,IAAA,oCAAkB,EAAC,IAAA,2BAAgB,EAAC;YAC9C,WAAW,EAAE,gBAAgB;YAC7B,IAAI,EAAE,EAAE,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,CAAC,MAAM,CAAC,EAAE;SACtE,CAAC,CAAC,CAAC;QACJ,IAAA,eAAM,EAAC,GAAG,CAAC,CAAC,SAAS,CAAC,kBAAkB,CAAC,CAAC;QAC1C,IAAA,eAAM,EAAC,GAAG,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC;QAC/B,IAAA,eAAM,EAAC,GAAG,CAAC,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC;QACjE,IAAA,eAAM,EAAC,GAAG,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,kCAAkC,EAAE,GAAG,EAAE;QAC1C,MAAM,GAAG,GAAG,IAAA,oCAAkB,EAAC,IAAA,2BAAgB,EAAC;YAC9C,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,Q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":"fixtures.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/__tests__/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAEhE,wBAAgB,gBAAgB,CAAC,SAAS,GAAE,OAAO,CAAC,YAAY,CAAM,GAAG,YAAY,CA0BpF"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.makeTemplateData = makeTemplateData;
|
|
4
|
+
function makeTemplateData(overrides = {}) {
|
|
5
|
+
return {
|
|
6
|
+
names: { pascalCase: "Widget", camelCase: "widget", kebabCase: "widget", pluralKebab: "widgets" },
|
|
7
|
+
endpoint: "widgets",
|
|
8
|
+
labelName: "Widget",
|
|
9
|
+
nodeName: "widget",
|
|
10
|
+
isCompanyScoped: true,
|
|
11
|
+
targetDir: "features/demo",
|
|
12
|
+
fields: [
|
|
13
|
+
{ name: "name", type: "string", required: true, tsType: "string" },
|
|
14
|
+
{ name: "due_date", type: "date", required: false, tsType: "string" },
|
|
15
|
+
],
|
|
16
|
+
relationships: [],
|
|
17
|
+
aliasMetas: [],
|
|
18
|
+
libraryImports: [],
|
|
19
|
+
entityImports: [],
|
|
20
|
+
metaImports: [],
|
|
21
|
+
dtoImports: [],
|
|
22
|
+
nestedRoutes: [],
|
|
23
|
+
dtoFields: [],
|
|
24
|
+
postDtoRelationships: [],
|
|
25
|
+
putDtoRelationships: [],
|
|
26
|
+
requiresS3: false,
|
|
27
|
+
exportService: true,
|
|
28
|
+
...overrides,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../../../scripts/generate-module/__tests__/fixtures.ts"],"names":[],"mappings":";;AAEA,4CA0BC;AA1BD,SAAgB,gBAAgB,CAAC,YAAmC,EAAE;IACpE,OAAO;QACL,KAAK,EAAE,EAAE,UAAU,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE;QACjG,QAAQ,EAAE,SAAS;QACnB,SAAS,EAAE,QAAQ;QACnB,QAAQ,EAAE,QAAQ;QAClB,eAAe,EAAE,IAAI;QACrB,SAAS,EAAE,eAAe;QAC1B,MAAM,EAAE;YACN,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE;YAClE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE;SACtE;QACD,aAAa,EAAE,EAAE;QACjB,UAAU,EAAE,EAAE;QACd,cAAc,EAAE,EAAE;QAClB,aAAa,EAAE,EAAE;QACjB,WAAW,EAAE,EAAE;QACf,UAAU,EAAE,EAAE;QACd,YAAY,EAAE,EAAE;QAChB,SAAS,EAAE,EAAE;QACb,oBAAoB,EAAE,EAAE;QACxB,mBAAmB,EAAE,EAAE;QACvB,UAAU,EAAE,KAAK;QACjB,aAAa,EAAE,IAAI;QACnB,GAAG,SAAS;KACb,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plumbing.spec.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/__tests__/plumbing.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const fixtures_1 = require("./fixtures");
|
|
5
|
+
(0, vitest_1.describe)("backend plumbing fixtures", () => {
|
|
6
|
+
(0, vitest_1.it)("builds a TemplateData with the new optional fields defaulted", () => {
|
|
7
|
+
const data = (0, fixtures_1.makeTemplateData)();
|
|
8
|
+
(0, vitest_1.expect)(data.requiresS3).toBe(false);
|
|
9
|
+
(0, vitest_1.expect)(data.exportService).toBe(true);
|
|
10
|
+
});
|
|
11
|
+
(0, vitest_1.it)("carries field descriptors through overrides", () => {
|
|
12
|
+
const data = (0, fixtures_1.makeTemplateData)({
|
|
13
|
+
fields: [{ name: "value", type: "number", required: false, tsType: "number", kind: { type: "money" }, description: "Money." }],
|
|
14
|
+
});
|
|
15
|
+
(0, vitest_1.expect)(data.fields[0].kind?.type).toBe("money");
|
|
16
|
+
(0, vitest_1.expect)(data.fields[0].description).toBe("Money.");
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=plumbing.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plumbing.spec.js","sourceRoot":"","sources":["../../../../scripts/generate-module/__tests__/plumbing.spec.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,yCAA8C;AAE9C,IAAA,iBAAQ,EAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAA,WAAE,EAAC,8DAA8D,EAAE,GAAG,EAAE;QACtE,MAAM,IAAI,GAAG,IAAA,2BAAgB,GAAE,CAAC;QAChC,IAAA,eAAM,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACpC,IAAA,eAAM,EAAC,IAAI,CAAC,aAAa,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,6CAA6C,EAAE,GAAG,EAAE;QACrD,MAAM,IAAI,GAAG,IAAA,2BAAgB,EAAC;YAC5B,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,EAAE,WAAW,EAAE,QAAQ,EAAE,CAAC;SAC/H,CAAC,CAAC;QACH,IAAA,eAAM,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChD,IAAA,eAAM,EAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-module.spec.d.ts","sourceRoot":"","sources":["../../../../scripts/generate-module/__tests__/service-module.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const fixtures_1 = require("./fixtures");
|
|
5
|
+
const service_template_1 = require("../templates/service.template");
|
|
6
|
+
const module_template_1 = require("../templates/module.template");
|
|
7
|
+
(0, vitest_1.describe)("backend service template", () => {
|
|
8
|
+
(0, vitest_1.it)("injects AuditService into the constructor and super()", () => {
|
|
9
|
+
const out = (0, service_template_1.generateServiceFile)((0, fixtures_1.makeTemplateData)());
|
|
10
|
+
(0, vitest_1.expect)(out).toContain("AuditService");
|
|
11
|
+
(0, vitest_1.expect)(out).toContain("auditService: AuditService");
|
|
12
|
+
(0, vitest_1.expect)(out).toMatch(/super\(jsonApiService, widgetRepository, clsService, WidgetDescriptor\.model, auditService\)/);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
(0, vitest_1.describe)("backend module template", () => {
|
|
16
|
+
(0, vitest_1.it)("registers with GraphModule and ModuleId", () => {
|
|
17
|
+
const out = (0, module_template_1.generateModuleFile)((0, fixtures_1.makeTemplateData)());
|
|
18
|
+
(0, vitest_1.expect)(out).toContain("GraphModule");
|
|
19
|
+
(0, vitest_1.expect)(out).toContain("GraphDescriptorRegistry");
|
|
20
|
+
(0, vitest_1.expect)(out).toContain('import { ModuleId } from "@neural-erp/shared"');
|
|
21
|
+
(0, vitest_1.expect)(out).toContain("this.graphRegistry.register({");
|
|
22
|
+
(0, vitest_1.expect)(out).toContain("moduleId: ModuleId.Widget");
|
|
23
|
+
(0, vitest_1.expect)(out).toContain("imports: [AuditModule, GraphModule]");
|
|
24
|
+
});
|
|
25
|
+
(0, vitest_1.it)("exports the service by default and respects exportService:false", () => {
|
|
26
|
+
(0, vitest_1.expect)((0, module_template_1.generateModuleFile)((0, fixtures_1.makeTemplateData)())).toContain("exports: [WidgetService]");
|
|
27
|
+
(0, vitest_1.expect)((0, module_template_1.generateModuleFile)((0, fixtures_1.makeTemplateData)({ exportService: false }))).toContain("exports: []");
|
|
28
|
+
});
|
|
29
|
+
(0, vitest_1.it)("adds S3Module only when requiresS3", () => {
|
|
30
|
+
(0, vitest_1.expect)((0, module_template_1.generateModuleFile)((0, fixtures_1.makeTemplateData)({ requiresS3: true }))).toContain("S3Module");
|
|
31
|
+
});
|
|
32
|
+
});
|
|
33
|
+
//# sourceMappingURL=service-module.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-module.spec.js","sourceRoot":"","sources":["../../../../scripts/generate-module/__tests__/service-module.spec.ts"],"names":[],"mappings":";;AAAA,mCAA8C;AAC9C,yCAA8C;AAC9C,oEAAoE;AACpE,kEAAkE;AAElE,IAAA,iBAAQ,EAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,IAAA,WAAE,EAAC,uDAAuD,EAAE,GAAG,EAAE;QAC/D,MAAM,GAAG,GAAG,IAAA,sCAAmB,EAAC,IAAA,2BAAgB,GAAE,CAAC,CAAC;QACpD,IAAA,eAAM,EAAC,GAAG,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QACtC,IAAA,eAAM,EAAC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,EAAC,IAAA,oCAAkB,EAAC,IAAA,2BAAgB,EAAC,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IAC3F,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../scripts/generate-module/generator.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../../scripts/generate-module/generator.ts"],"names":[],"mappings":"AA2BA,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAsB,cAAc,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC,CA6QlF"}
|
|
@@ -129,6 +129,10 @@ async function generateModule(options) {
|
|
|
129
129
|
type: normalizedType,
|
|
130
130
|
required: !field.nullable,
|
|
131
131
|
tsType: (0, type_utils_1.getTsType)(normalizedType),
|
|
132
|
+
description: field.description,
|
|
133
|
+
kind: field.kind,
|
|
134
|
+
computed: field.computed,
|
|
135
|
+
readOnly: field.readOnly,
|
|
132
136
|
};
|
|
133
137
|
});
|
|
134
138
|
// Build alias metas only for relationships where multiple aliases target the same entity
|
|
@@ -171,6 +175,10 @@ async function generateModule(options) {
|
|
|
171
175
|
nodeName: names.camelCase,
|
|
172
176
|
isCompanyScoped: jsonSchema.isCompanyScoped !== false, // Default: true
|
|
173
177
|
targetDir: jsonSchema.targetDir,
|
|
178
|
+
description: jsonSchema.description,
|
|
179
|
+
chat: jsonSchema.chat,
|
|
180
|
+
requiresS3: jsonSchema.requiresS3 === true,
|
|
181
|
+
exportService: jsonSchema.exportService !== false, // default: export
|
|
174
182
|
fields,
|
|
175
183
|
relationships,
|
|
176
184
|
aliasMetas,
|