@tstdl/base 0.93.123 → 0.93.126
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/ai/genkit/tests/multi-region.test.js +6 -6
- package/ai/index.d.ts +2 -6
- package/ai/index.js +2 -6
- package/ai/parser/index.d.ts +1 -0
- package/ai/parser/index.js +1 -0
- package/ai/parser/parser.d.ts +12 -0
- package/ai/parser/parser.js +28 -0
- package/ai/prompts/build.d.ts +21 -0
- package/ai/prompts/build.js +25 -0
- package/ai/prompts/index.d.ts +2 -0
- package/ai/prompts/index.js +2 -0
- package/ai/prompts/instructions-formatter.d.ts +9 -22
- package/ai/prompts/instructions-formatter.js +20 -7
- package/ai/prompts/instructions.js +1 -1
- package/ai/prompts/steering.d.ts +27 -0
- package/ai/prompts/steering.js +54 -0
- package/ai/tests/instructions-formatter.test.js +115 -0
- package/ai/tests/steering.test.js +37 -0
- package/application/application.d.ts +2 -1
- package/application/application.js +3 -0
- package/authentication/client/module.d.ts +1 -1
- package/authentication/client/module.js +4 -5
- package/authentication/tests/authentication-ancillary.service.test.js +1 -1
- package/authentication/tests/authentication.api-controller.test.js +3 -1
- package/authentication/tests/authentication.api-request-token.provider.test.js +1 -1
- package/authentication/tests/authentication.client-service.test.js +1 -1
- package/authentication/tests/authentication.service.test.js +1 -1
- package/authentication/tests/subject.service.test.js +1 -1
- package/circuit-breaker/tests/circuit-breaker.test.js +1 -1
- package/document-management/api/document-management.api.d.ts +16 -16
- package/document-management/api/document-management.api.js +12 -12
- package/document-management/models/ai-configuration.d.ts +59 -0
- package/document-management/models/ai-configuration.js +1 -0
- package/document-management/models/document-assignment-scope.model.js +2 -4
- package/document-management/models/document-assignment-task.model.js +2 -4
- package/document-management/models/document-collection-assignment.model.js +2 -4
- package/document-management/models/document-collection.model.js +2 -3
- package/document-management/models/document-content.model.d.ts +6 -0
- package/document-management/models/document-content.model.js +32 -0
- package/document-management/models/document-property-value.model.js +1 -2
- package/document-management/models/document-request-collection-assignment.model.js +2 -4
- package/document-management/models/document-request.model.js +2 -4
- package/document-management/models/document-tag-assignment.model.js +2 -3
- package/document-management/models/document-validation-execution-related-document.model.js +2 -4
- package/document-management/models/document-validation-execution.model.js +2 -5
- package/document-management/models/document-workflow.model.d.ts +2 -1
- package/document-management/models/document-workflow.model.js +4 -5
- package/document-management/models/document.model.js +2 -3
- package/document-management/models/index.d.ts +2 -0
- package/document-management/models/index.js +2 -0
- package/document-management/server/api/document-management.api.d.ts +7 -7
- package/document-management/server/api/document-management.api.js +9 -9
- package/document-management/server/configure.d.ts +4 -1
- package/document-management/server/configure.js +9 -4
- package/document-management/server/drizzle/{0000_silly_chimera.sql → 0000_curious_nighthawk.sql} +8 -28
- package/document-management/server/drizzle/meta/0000_snapshot.json +14 -286
- package/document-management/server/drizzle/meta/_journal.json +2 -2
- package/document-management/server/module.d.ts +2 -0
- package/document-management/server/module.js +1 -0
- package/document-management/server/schemas.d.ts +2 -1
- package/document-management/server/services/document-file.service.d.ts +6 -6
- package/document-management/server/services/document-file.service.js +7 -81
- package/document-management/server/services/document-management-ai-provider.service.d.ts +66 -0
- package/document-management/server/services/document-management-ai-provider.service.js +2 -0
- package/document-management/server/services/document-management-ai.service.d.ts +44 -7
- package/document-management/server/services/document-management-ai.service.js +332 -329
- package/document-management/server/services/document-validation.service.d.ts +1 -1
- package/document-management/server/services/document-workflow.service.d.ts +4 -3
- package/document-management/server/services/document-workflow.service.js +26 -9
- package/document-management/server/services/document.service.d.ts +7 -3
- package/document-management/server/services/document.service.js +13 -4
- package/document-management/server/services/index.d.ts +1 -0
- package/document-management/server/services/index.js +1 -0
- package/document-management/server/validators/ai-validation-executor.d.ts +419 -12
- package/document-management/server/validators/ai-validation-executor.js +51 -46
- package/document-management/server/validators/single-document-validation-executor.d.ts +1 -3
- package/document-management/server/validators/single-document-validation-executor.js +2 -4
- package/document-management/service-models/document.service-model.d.ts +3 -3
- package/document-management/service-models/document.service-model.js +1 -1
- package/document-management/tests/ai-config-hierarchy.test.d.ts +1 -0
- package/document-management/tests/ai-config-hierarchy.test.js +64 -0
- package/document-management/tests/ai-config-integration.test.d.ts +1 -0
- package/document-management/tests/ai-config-integration.test.js +125 -0
- package/document-management/tests/ai-config-merge.test.d.ts +1 -0
- package/document-management/tests/ai-config-merge.test.js +38 -0
- package/document-management/tests/document-management-ai-overrides.test.d.ts +1 -0
- package/document-management/tests/document-management-ai-overrides.test.js +64 -0
- package/document-management/tests/document-management-core.test.js +6 -6
- package/document-management/tests/document-management.api.test.js +5 -5
- package/document-management/tests/document-statistics.service.test.js +10 -6
- package/document-management/tests/document-validation-ai-overrides.test.d.ts +1 -0
- package/document-management/tests/document-validation-ai-overrides.test.js +85 -0
- package/document-management/tests/document.service.test.js +15 -11
- package/document-management/tests/enum-helpers.test.js +5 -5
- package/examples/document-management/ai-provider.d.ts +20 -0
- package/examples/document-management/ai-provider.js +74 -0
- package/examples/document-management/main.js +9 -6
- package/examples/injector/graph-example.d.ts +1 -0
- package/examples/injector/graph-example.js +340 -0
- package/injector/decorators.d.ts +4 -4
- package/injector/decorators.js +5 -6
- package/injector/forward-ref.d.ts +15 -0
- package/injector/forward-ref.js +20 -0
- package/injector/graph.d.ts +113 -0
- package/injector/graph.js +631 -0
- package/injector/index.d.ts +2 -0
- package/injector/index.js +2 -0
- package/injector/inject.d.ts +15 -15
- package/injector/injector.d.ts +101 -13
- package/injector/injector.js +103 -59
- package/injector/resolve-chain.d.ts +20 -6
- package/injector/resolve-chain.js +39 -14
- package/injector/tests/advanced.test.d.ts +1 -0
- package/injector/tests/advanced.test.js +116 -0
- package/injector/tests/async-init.test.d.ts +1 -0
- package/injector/tests/async-init.test.js +77 -0
- package/injector/tests/basic.test.d.ts +1 -0
- package/injector/tests/basic.test.js +114 -0
- package/injector/tests/hierarchical.test.d.ts +1 -0
- package/injector/tests/hierarchical.test.js +59 -0
- package/injector/tests/lifecycles.test.d.ts +1 -0
- package/injector/tests/lifecycles.test.js +109 -0
- package/injector/token.d.ts +2 -1
- package/injector/token.js +4 -1
- package/injector/type-info.d.ts +1 -5
- package/injector/types.d.ts +4 -10
- package/logger/tests/pretty-print.test.d.ts +1 -0
- package/logger/{formatters → tests}/pretty-print.test.js +1 -1
- package/logger/transports/console.d.ts +3 -2
- package/logger/transports/console.js +4 -3
- package/notification/api/notification.api.d.ts +26 -6
- package/notification/api/notification.api.js +15 -4
- package/notification/client/notification-client.d.ts +6 -0
- package/notification/client/notification-client.js +13 -3
- package/notification/models/in-app-notification.model.d.ts +9 -3
- package/notification/models/in-app-notification.model.js +32 -11
- package/notification/models/notification-log.model.js +2 -3
- package/notification/server/api/notification.api-controller.d.ts +1 -0
- package/notification/server/api/notification.api-controller.js +7 -1
- package/notification/server/drizzle/{0000_oval_rage.sql → 0000_wise_pyro.sql} +22 -4
- package/notification/server/drizzle/meta/0000_snapshot.json +249 -37
- package/notification/server/drizzle/meta/_journal.json +2 -2
- package/notification/server/module.d.ts +5 -0
- package/notification/server/module.js +6 -1
- package/notification/server/providers/in-app-channel-provider.js +1 -0
- package/notification/server/schemas.d.ts +3 -2
- package/notification/server/schemas.js +3 -2
- package/notification/server/services/notification.service.d.ts +11 -6
- package/notification/server/services/notification.service.js +138 -42
- package/notification/tests/notification-api.test.js +16 -6
- package/notification/tests/notification-client.test.d.ts +1 -0
- package/notification/tests/{unit/notification-client.test.js → notification-client.test.js} +5 -5
- package/notification/tests/notification-flow.test.js +45 -7
- package/notification/tests/notification-sse.service.test.js +1 -1
- package/notification/tests/notification-type.service.test.js +1 -1
- package/object-storage/s3/s3.object-storage.js +3 -0
- package/object-storage/s3/tests/s3.object-storage.integration.test.js +1 -1
- package/orm/server/drizzle/schema-converter.js +5 -3
- package/orm/tests/repository-attributes.test.js +10 -17
- package/orm/tests/repository-cti-mapping.test.js +2 -2
- package/orm/tests/repository-cti-soft-delete.test.js +1 -1
- package/orm/tests/repository-cti.test.js +19 -33
- package/orm/tests/repository-extra-coverage.test.js +1 -1
- package/orm/tests/repository-search.test.js +5 -2
- package/orm/tests/schema-converter.test.js +1 -0
- package/orm/tests/transaction-safety.test.js +1 -1
- package/package.json +7 -9
- package/rate-limit/tests/postgres-rate-limiter.test.js +6 -16
- package/renderer/d2.d.ts +77 -0
- package/renderer/d2.js +68 -0
- package/renderer/graphviz.d.ts +47 -0
- package/renderer/graphviz.js +58 -0
- package/renderer/index.d.ts +4 -0
- package/renderer/index.js +4 -0
- package/renderer/typst.d.ts +57 -0
- package/renderer/typst.js +62 -0
- package/rpc/adapters/readable-stream.adapter.d.ts +3 -0
- package/rpc/adapters/readable-stream.adapter.js +5 -1
- package/rpc/rpc.js +28 -3
- package/rpc/tests/rpc.integration.test.js +3 -1
- package/schema/schemas/nullable.js +1 -1
- package/task-queue/task-queue.d.ts +2 -0
- package/task-queue/task-queue.js +6 -2
- package/task-queue/tests/complex.test.js +1 -1
- package/task-queue/tests/dependencies.test.js +3 -3
- package/task-queue/tests/extensive-dependencies.test.js +1 -1
- package/task-queue/tests/queue.test.js +1 -1
- package/task-queue/tests/worker.test.js +4 -7
- package/test5.js +52 -8
- package/{unit-test → testing}/integration-setup.d.ts +1 -0
- package/{unit-test → testing}/integration-setup.js +13 -0
- package/utils/base64.d.ts +7 -0
- package/utils/base64.js +10 -1
- package/utils/noop.d.ts +7 -1
- package/utils/noop.js +7 -1
- package/ai/ai-file.service.d.ts +0 -57
- package/ai/ai-file.service.js +0 -233
- package/ai/ai-session.d.ts +0 -38
- package/ai/ai-session.js +0 -50
- package/ai/ai.service.d.ts +0 -126
- package/ai/ai.service.js +0 -481
- package/ai/functions.d.ts +0 -9
- package/ai/functions.js +0 -38
- package/ai/module.d.ts +0 -26
- package/ai/module.js +0 -25
- package/ai/types.d.ts +0 -229
- package/ai/types.js +0 -33
- package/latex/index.d.ts +0 -1
- package/latex/index.js +0 -1
- package/typst/index.d.ts +0 -1
- package/typst/index.js +0 -1
- package/typst/render.d.ts +0 -23
- package/typst/render.js +0 -32
- /package/{logger/formatters/pretty-print.test.d.ts → ai/tests/instructions-formatter.test.d.ts} +0 -0
- /package/{notification/tests/unit/notification-client.test.d.ts → ai/tests/steering.test.d.ts} +0 -0
- /package/{latex/render.d.ts → renderer/latex.d.ts} +0 -0
- /package/{latex/render.js → renderer/latex.js} +0 -0
- /package/{unit-test → testing}/index.d.ts +0 -0
- /package/{unit-test → testing}/index.js +0 -0
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
import { injectModel } from '../../ai/genkit/index.js';
|
|
8
|
+
import { fewShotPrompt, stylePrompt } from '../../ai/prompts/index.js';
|
|
9
|
+
import { DocumentManagementAiProviderService } from '../../document-management/server/index.js';
|
|
10
|
+
import { Singleton } from '../../injector/index.js';
|
|
11
|
+
let ExampleAiProviderService = class ExampleAiProviderService extends DocumentManagementAiProviderService {
|
|
12
|
+
/**
|
|
13
|
+
* Providing global defaults for the entire Document Management module.
|
|
14
|
+
*/
|
|
15
|
+
getGlobalConfiguration() {
|
|
16
|
+
return {
|
|
17
|
+
defaults: {
|
|
18
|
+
language: 'German', // Steer all AI outputs to German
|
|
19
|
+
model: injectModel('gemini-2.5-flash'),
|
|
20
|
+
prompt: {
|
|
21
|
+
systemAddition: 'Additional global instructions for all AI steps.',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
getContentExtractionConfiguration() {
|
|
27
|
+
return {};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Providing specific overrides for the Classification step.
|
|
31
|
+
*/
|
|
32
|
+
getClassificationConfiguration() {
|
|
33
|
+
return {
|
|
34
|
+
// Use a faster/cheaper model for classification
|
|
35
|
+
model: injectModel('gemini-2.5-flash-lite'),
|
|
36
|
+
prompt: {
|
|
37
|
+
systemAddition: 'For classification, focus strictly on the layout.',
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Providing specific overrides for the Data Extraction step,
|
|
43
|
+
* potentially specific to a Document Type Key.
|
|
44
|
+
*/
|
|
45
|
+
getDataExtractionConfiguration(_tenantId, data) {
|
|
46
|
+
if (data.type.key == 'invoice') {
|
|
47
|
+
return {
|
|
48
|
+
prompt: {
|
|
49
|
+
// Use prompt factories for standardized steering
|
|
50
|
+
systemAddition: [
|
|
51
|
+
stylePrompt('Titles must always start with "INV-" followed by the invoice number.'),
|
|
52
|
+
fewShotPrompt([
|
|
53
|
+
{
|
|
54
|
+
input: 'Invoice from 2023-10-05, No. 12345',
|
|
55
|
+
output: 'INV-12345',
|
|
56
|
+
},
|
|
57
|
+
]),
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
getAssignmentConfiguration() {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
getValidationConfiguration() {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
ExampleAiProviderService = __decorate([
|
|
72
|
+
Singleton()
|
|
73
|
+
], ExampleAiProviderService);
|
|
74
|
+
export { ExampleAiProviderService };
|
|
@@ -6,7 +6,6 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
6
|
};
|
|
7
7
|
import '../../polyfills.js';
|
|
8
8
|
import { configureGenkit } from '../../ai/genkit/module.js';
|
|
9
|
-
import { configureAiService } from '../../ai/index.js';
|
|
10
9
|
import { MockApiRequestTokenProvider } from '../../api/server/api-request-token.provider.js';
|
|
11
10
|
import { configureApiServer } from '../../api/server/module.js';
|
|
12
11
|
import { Application } from '../../application/application.js';
|
|
@@ -28,6 +27,7 @@ import { configureOrm } from '../../orm/server/index.js';
|
|
|
28
27
|
import { configureDefaultSignalsImplementation } from '../../signals/implementation/configure.js';
|
|
29
28
|
import { configurePostgresTaskQueue, migratePostgresTaskQueueSchema } from '../../task-queue/postgres/index.js';
|
|
30
29
|
import { boolean, positiveInteger, string } from '../../utils/config-parser.js';
|
|
30
|
+
import { ExampleAiProviderService } from './ai-provider.js';
|
|
31
31
|
import { TstdlCategoryParents, TstdlDocumentCategoryLabels, TstdlDocumentPropertyConfiguration, TstdlDocumentTypeCategories, TstdlDocumentTypeLabels, TstdlDocumentTypeProperties } from './categories-and-types.js';
|
|
32
32
|
const config = {
|
|
33
33
|
database: {
|
|
@@ -42,8 +42,8 @@ const config = {
|
|
|
42
42
|
apiKey: string('AI_API_KEY', undefined),
|
|
43
43
|
keyFile: string('AI_API_KEY_FILE', undefined),
|
|
44
44
|
vertex: {
|
|
45
|
-
project: string('AI_VERTEX_PROJECT',
|
|
46
|
-
location: string('AI_VERTEX_LOCATION',
|
|
45
|
+
project: string('AI_VERTEX_PROJECT', 'tstdl-dev'),
|
|
46
|
+
location: string('AI_VERTEX_LOCATION', 'tstdl-dev'),
|
|
47
47
|
},
|
|
48
48
|
},
|
|
49
49
|
s3: {
|
|
@@ -108,6 +108,7 @@ async function bootstrap() {
|
|
|
108
108
|
configureDocumentManagement({
|
|
109
109
|
ancillaryService: ExampleDocumentManagementAncillaryService,
|
|
110
110
|
authorizationService: AllowAllDocumentManagementAuthorizationService,
|
|
111
|
+
aiProvider: ExampleAiProviderService,
|
|
111
112
|
fileObjectStorageModule: 'documents',
|
|
112
113
|
fileUploadObjectStorageModule: 'document-uploads',
|
|
113
114
|
filePreviewObjectStorageModule: 'document-previews',
|
|
@@ -132,9 +133,11 @@ async function bootstrap() {
|
|
|
132
133
|
},
|
|
133
134
|
},
|
|
134
135
|
});
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
136
|
+
configureGenkit({
|
|
137
|
+
vertex: {
|
|
138
|
+
projectId: config.ai.vertex.project,
|
|
139
|
+
location: config.ai.vertex.location,
|
|
140
|
+
},
|
|
138
141
|
});
|
|
139
142
|
await runInInjectionContext(injector, migrateDocumentManagementSchema);
|
|
140
143
|
await runInInjectionContext(injector, migratePostgresCircuitBreaker);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '../../polyfills.js';
|
|
@@ -0,0 +1,340 @@
|
|
|
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
|
+
import '../../polyfills.js';
|
|
11
|
+
import { Application, provideModule } from '../../application/index.js';
|
|
12
|
+
import { Injectable, Injector, ReplaceClass, Scoped, Singleton, afterResolve, forwardRef, generateApplicationDependencyGraph, generateApplicationDependencyGraphD2, inject, injectAll, injectArgument, injectManyAsync, injectionToken, provide, resolveArgumentType, runInInjectionContext, } from '../../injector/index.js';
|
|
13
|
+
import { LogLevel, Logger, PrettyPrintLogFormatter, provideConsoleLogTransport } from '../../logger/index.js';
|
|
14
|
+
import { Module } from '../../module/index.js';
|
|
15
|
+
// --- 1. System Tokens & Interfaces ---
|
|
16
|
+
const APP_NAME = injectionToken('APP_NAME');
|
|
17
|
+
const API_URL = injectionToken('API_URL');
|
|
18
|
+
const PLUGIN = injectionToken('PLUGIN');
|
|
19
|
+
const FEATURE_FLAGS = injectionToken('FEATURE_FLAGS');
|
|
20
|
+
const CONFIG = injectionToken('CONFIG');
|
|
21
|
+
const LOCAL_SECRET = injectionToken('LOCAL_SECRET');
|
|
22
|
+
const BASE_TOKEN = injectionToken('BASE_TOKEN');
|
|
23
|
+
// --- 2. Shared Infrastructure ---
|
|
24
|
+
let Metrics = class Metrics {
|
|
25
|
+
logger = inject(Logger);
|
|
26
|
+
track(event) { this.logger.info(`Metric: ${event}`); }
|
|
27
|
+
};
|
|
28
|
+
Metrics = __decorate([
|
|
29
|
+
Singleton()
|
|
30
|
+
], Metrics);
|
|
31
|
+
// --- 3. Factory & Manual Providers ---
|
|
32
|
+
let ConfigService = class ConfigService {
|
|
33
|
+
data;
|
|
34
|
+
constructor(data) {
|
|
35
|
+
this.data = data;
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
ConfigService = __decorate([
|
|
39
|
+
Singleton(),
|
|
40
|
+
__metadata("design:paramtypes", [Object])
|
|
41
|
+
], ConfigService);
|
|
42
|
+
// --- 4. Async & Resource Management ---
|
|
43
|
+
let ConnectionPool = class ConnectionPool {
|
|
44
|
+
logger = inject(Logger);
|
|
45
|
+
active = false;
|
|
46
|
+
async [afterResolve](_arg, { addDisposeHandler }) {
|
|
47
|
+
this.logger.info('Pool connecting...');
|
|
48
|
+
await new Promise(r => setTimeout(r, 10));
|
|
49
|
+
this.active = true;
|
|
50
|
+
addDisposeHandler(async () => this.logger.info('Pool disconnected.'));
|
|
51
|
+
}
|
|
52
|
+
async [Symbol.asyncDispose]() { }
|
|
53
|
+
};
|
|
54
|
+
ConnectionPool = __decorate([
|
|
55
|
+
Singleton()
|
|
56
|
+
], ConnectionPool);
|
|
57
|
+
// --- 5. Scoped Resources ---
|
|
58
|
+
let ModuleCache = class ModuleCache {
|
|
59
|
+
id = Math.random().toString(36).substring(7);
|
|
60
|
+
};
|
|
61
|
+
ModuleCache = __decorate([
|
|
62
|
+
Scoped('injector')
|
|
63
|
+
], ModuleCache);
|
|
64
|
+
let RequestContext = class RequestContext {
|
|
65
|
+
requestId = Math.random().toString(36).substring(7);
|
|
66
|
+
};
|
|
67
|
+
RequestContext = __decorate([
|
|
68
|
+
Scoped('resolution')
|
|
69
|
+
], RequestContext);
|
|
70
|
+
let TransientTask = class TransientTask {
|
|
71
|
+
id = Math.random().toString(36).substring(7);
|
|
72
|
+
};
|
|
73
|
+
TransientTask = __decorate([
|
|
74
|
+
Injectable() // Defaults to transient
|
|
75
|
+
], TransientTask);
|
|
76
|
+
// --- 6. Argument Handling & Advanced Forwarding ---
|
|
77
|
+
let Validator = class Validator {
|
|
78
|
+
// Map partial argument from parent resolve
|
|
79
|
+
userRole = injectArgument(this, { optional: true })?.role;
|
|
80
|
+
logger = inject(Logger);
|
|
81
|
+
validate() {
|
|
82
|
+
this.logger.info(`Validating role: ${this.userRole}`);
|
|
83
|
+
return this.userRole === 'ADMIN';
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
Validator = __decorate([
|
|
87
|
+
Injectable({
|
|
88
|
+
// Default argument provider if none provided during resolve
|
|
89
|
+
defaultArgumentProvider: () => ({ id: 'GUEST-' + Math.random().toString(36).substring(7), role: 'GUEST' }),
|
|
90
|
+
// Custom identity provider for resolution/singleton scoping
|
|
91
|
+
argumentIdentityProvider: (arg) => arg.id,
|
|
92
|
+
})
|
|
93
|
+
], Validator);
|
|
94
|
+
let ActionWorker = class ActionWorker {
|
|
95
|
+
logger = inject(Logger);
|
|
96
|
+
user = injectArgument(this, { optional: true });
|
|
97
|
+
subValidator = inject(Validator, { ...this.user, role: 'SUB-' + (this.user?.role ?? 'NONE') }, { optional: true });
|
|
98
|
+
// Forward our argument to validator manually
|
|
99
|
+
validator = inject(Validator, injectArgument(this, { optional: true }));
|
|
100
|
+
execute(action) {
|
|
101
|
+
const u = this.user ? `${this.user.role}:${this.user.id}` : 'anon';
|
|
102
|
+
this.subValidator?.validate();
|
|
103
|
+
if (this.validator.validate()) {
|
|
104
|
+
this.logger.info(`Action "${action}" by ${u} (AUTHORIZED)`);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
ActionWorker = __decorate([
|
|
109
|
+
Injectable()
|
|
110
|
+
], ActionWorker);
|
|
111
|
+
// --- 7. Hierarchy Control (skipSelf / onlySelf) ---
|
|
112
|
+
let HierarchyDemo = class HierarchyDemo {
|
|
113
|
+
// Specifically want the logger from the parent, ignoring any local overrides
|
|
114
|
+
parentLogger = inject(Logger, undefined, { skipSelf: true });
|
|
115
|
+
// Only want local metrics, fail if not found locally
|
|
116
|
+
localMetrics = inject(Metrics, undefined, { onlySelf: true, optional: true });
|
|
117
|
+
};
|
|
118
|
+
HierarchyDemo = __decorate([
|
|
119
|
+
Singleton()
|
|
120
|
+
], HierarchyDemo);
|
|
121
|
+
// --- 8. Diamond Dependency Shape ---
|
|
122
|
+
let DiamondTop = class DiamondTop {
|
|
123
|
+
l = inject(Logger);
|
|
124
|
+
};
|
|
125
|
+
DiamondTop = __decorate([
|
|
126
|
+
Singleton()
|
|
127
|
+
], DiamondTop);
|
|
128
|
+
let DiamondLeft = class DiamondLeft {
|
|
129
|
+
t = inject(DiamondTop);
|
|
130
|
+
};
|
|
131
|
+
DiamondLeft = __decorate([
|
|
132
|
+
Singleton()
|
|
133
|
+
], DiamondLeft);
|
|
134
|
+
let DiamondRight = class DiamondRight {
|
|
135
|
+
t = inject(DiamondTop);
|
|
136
|
+
};
|
|
137
|
+
DiamondRight = __decorate([
|
|
138
|
+
Singleton()
|
|
139
|
+
], DiamondRight);
|
|
140
|
+
let DiamondBottom = class DiamondBottom {
|
|
141
|
+
l = inject(DiamondLeft);
|
|
142
|
+
r = inject(DiamondRight);
|
|
143
|
+
m = inject(Metrics);
|
|
144
|
+
};
|
|
145
|
+
DiamondBottom = __decorate([
|
|
146
|
+
Singleton()
|
|
147
|
+
], DiamondBottom);
|
|
148
|
+
// --- 9. Circular Hub ---
|
|
149
|
+
let ServiceAlpha = class ServiceAlpha {
|
|
150
|
+
beta = inject(forwardRef(() => ServiceBeta));
|
|
151
|
+
name = 'Alpha';
|
|
152
|
+
};
|
|
153
|
+
ServiceAlpha = __decorate([
|
|
154
|
+
Singleton()
|
|
155
|
+
], ServiceAlpha);
|
|
156
|
+
let ServiceBeta = class ServiceBeta {
|
|
157
|
+
gamma = inject(forwardRef(() => ServiceGamma));
|
|
158
|
+
name = 'Beta';
|
|
159
|
+
};
|
|
160
|
+
ServiceBeta = __decorate([
|
|
161
|
+
Singleton()
|
|
162
|
+
], ServiceBeta);
|
|
163
|
+
let ServiceGamma = class ServiceGamma {
|
|
164
|
+
alpha = inject(ServiceAlpha);
|
|
165
|
+
metrics = inject(Metrics);
|
|
166
|
+
name = 'Gamma';
|
|
167
|
+
};
|
|
168
|
+
ServiceGamma = __decorate([
|
|
169
|
+
Singleton()
|
|
170
|
+
], ServiceGamma);
|
|
171
|
+
// --- 10. Multi-providers & Bridge ---
|
|
172
|
+
const ADAPTER = injectionToken('ADAPTER');
|
|
173
|
+
let MyAdapter = class MyAdapter {
|
|
174
|
+
name = 'Postgres';
|
|
175
|
+
};
|
|
176
|
+
MyAdapter = __decorate([
|
|
177
|
+
Singleton({ alias: ADAPTER })
|
|
178
|
+
], MyAdapter);
|
|
179
|
+
let Plugin1 = class Plugin1 {
|
|
180
|
+
name = 'P1';
|
|
181
|
+
run() { }
|
|
182
|
+
};
|
|
183
|
+
Plugin1 = __decorate([
|
|
184
|
+
Singleton({ alias: PLUGIN, multi: true })
|
|
185
|
+
], Plugin1);
|
|
186
|
+
let Plugin2 = class Plugin2 {
|
|
187
|
+
name = 'P2';
|
|
188
|
+
run() { }
|
|
189
|
+
};
|
|
190
|
+
Plugin2 = __decorate([
|
|
191
|
+
Singleton({ alias: PLUGIN, multi: true })
|
|
192
|
+
], Plugin2);
|
|
193
|
+
// --- 11. Class Local Providers ---
|
|
194
|
+
// This feature allows a class to define providers that are only available to its own dependencies
|
|
195
|
+
let SecureVault = class SecureVault {
|
|
196
|
+
secret = inject(LOCAL_SECRET);
|
|
197
|
+
logger = inject(Logger);
|
|
198
|
+
open() {
|
|
199
|
+
this.logger.info(`Vault opened with secret: ${this.secret}`);
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
SecureVault = __decorate([
|
|
203
|
+
Singleton({
|
|
204
|
+
providers: [
|
|
205
|
+
provide(LOCAL_SECRET, { useValue: 'SuperSecret42' }),
|
|
206
|
+
],
|
|
207
|
+
})
|
|
208
|
+
], SecureVault);
|
|
209
|
+
// --- 12. Decorator Inheritance ---
|
|
210
|
+
let BaseService = class BaseService {
|
|
211
|
+
logger = inject(Logger);
|
|
212
|
+
};
|
|
213
|
+
BaseService = __decorate([
|
|
214
|
+
Singleton({ alias: BASE_TOKEN })
|
|
215
|
+
], BaseService);
|
|
216
|
+
// Inherits 'singleton' lifecycle and 'BASE_TOKEN' alias from BaseService
|
|
217
|
+
let ExtendedService = class ExtendedService extends BaseService {
|
|
218
|
+
doWork() { this.logger.info('Work done in ExtendedService'); }
|
|
219
|
+
};
|
|
220
|
+
ExtendedService = __decorate([
|
|
221
|
+
Injectable()
|
|
222
|
+
], ExtendedService);
|
|
223
|
+
// --- 13. ReplaceClass ---
|
|
224
|
+
// Used to wrap or type external classes
|
|
225
|
+
let ExternalService = class ExternalService {
|
|
226
|
+
};
|
|
227
|
+
ExternalService = __decorate([
|
|
228
|
+
Injectable()
|
|
229
|
+
], ExternalService);
|
|
230
|
+
let TypedExternalService = class TypedExternalService {
|
|
231
|
+
};
|
|
232
|
+
TypedExternalService = __decorate([
|
|
233
|
+
ReplaceClass(ExternalService)
|
|
234
|
+
], TypedExternalService);
|
|
235
|
+
// --- 14. Delayed Injection Demo ---
|
|
236
|
+
let LateService = class LateService {
|
|
237
|
+
id = Math.random().toString(36).substring(7);
|
|
238
|
+
};
|
|
239
|
+
LateService = __decorate([
|
|
240
|
+
Singleton()
|
|
241
|
+
], LateService);
|
|
242
|
+
let AnotherLateService = class AnotherLateService {
|
|
243
|
+
id = Math.random().toString(36).substring(7);
|
|
244
|
+
};
|
|
245
|
+
AnotherLateService = __decorate([
|
|
246
|
+
Singleton()
|
|
247
|
+
], AnotherLateService);
|
|
248
|
+
let LateConsumer = class LateConsumer {
|
|
249
|
+
injector = inject(Injector);
|
|
250
|
+
logger = inject(Logger);
|
|
251
|
+
async doLateResolve() {
|
|
252
|
+
this.logger.info('Performing late resolve...');
|
|
253
|
+
// This resolve happens AFTER the initial app startup graph is captured
|
|
254
|
+
// But since we are in dev mode, the injector will record it!
|
|
255
|
+
// And because we capture the ownerToken in the child injector,
|
|
256
|
+
// this will be linked to LateConsumer in the graph!
|
|
257
|
+
const late = this.injector.resolve(LateService);
|
|
258
|
+
const another = this.injector.resolve(AnotherLateService);
|
|
259
|
+
this.logger.info(`Late resolve finished: ${late.id}, ${another.id}`);
|
|
260
|
+
}
|
|
261
|
+
};
|
|
262
|
+
LateConsumer = __decorate([
|
|
263
|
+
Singleton()
|
|
264
|
+
], LateConsumer);
|
|
265
|
+
let DynamicService = class DynamicService {
|
|
266
|
+
id = Math.random().toString(36).substring(7);
|
|
267
|
+
};
|
|
268
|
+
DynamicService = __decorate([
|
|
269
|
+
Singleton()
|
|
270
|
+
], DynamicService);
|
|
271
|
+
// --- 15. The Ultimate Orchestrator (as a Module) ---
|
|
272
|
+
let UltimateApp = class UltimateApp extends Module {
|
|
273
|
+
injector = inject(Injector);
|
|
274
|
+
logger = inject(Logger);
|
|
275
|
+
diamond = inject(DiamondBottom);
|
|
276
|
+
circ = inject(ServiceAlpha);
|
|
277
|
+
workflow = inject(ActionWorker);
|
|
278
|
+
pool = inject(ConnectionPool);
|
|
279
|
+
cache = inject(ModuleCache);
|
|
280
|
+
ctx = inject(RequestContext);
|
|
281
|
+
adapter = inject(ADAPTER);
|
|
282
|
+
config = inject(ConfigService);
|
|
283
|
+
hierarchy = inject(HierarchyDemo);
|
|
284
|
+
vault = inject(SecureVault);
|
|
285
|
+
task1 = inject(TransientTask);
|
|
286
|
+
task2 = inject(TransientTask);
|
|
287
|
+
extended = inject(ExtendedService);
|
|
288
|
+
baseViaAlias = inject(BASE_TOKEN);
|
|
289
|
+
typedExternal = inject(TypedExternalService);
|
|
290
|
+
lateConsumer = inject(LateConsumer);
|
|
291
|
+
dynamic = this.injector.resolve(DynamicService);
|
|
292
|
+
constructor() {
|
|
293
|
+
super('UltimateApp');
|
|
294
|
+
}
|
|
295
|
+
async _run() {
|
|
296
|
+
this.logger.info(`UltimateApp starting. Cache: ${this.cache.id}, Request: ${this.ctx.requestId}`);
|
|
297
|
+
this.vault.open();
|
|
298
|
+
// Showcase synchronous and asynchronous multiple injection
|
|
299
|
+
const [adapter] = this.injector.resolveMany(ADAPTER);
|
|
300
|
+
this.logger.info(`Resolved via resolveMany: ${adapter.name}`);
|
|
301
|
+
await runInInjectionContext(this.injector, async () => {
|
|
302
|
+
const logger = inject(Logger);
|
|
303
|
+
const plugins = injectAll(PLUGIN);
|
|
304
|
+
logger.info(`Plugins via injectAll: ${plugins.map(p => p.name).join(', ')}`);
|
|
305
|
+
const [name, url] = await injectManyAsync(APP_NAME, API_URL);
|
|
306
|
+
this.logger.info(`Resolved via injectManyAsync: ${name} @ ${url}`);
|
|
307
|
+
this.workflow.execute('STARTUP');
|
|
308
|
+
});
|
|
309
|
+
await this.lateConsumer.doLateResolve();
|
|
310
|
+
}
|
|
311
|
+
};
|
|
312
|
+
UltimateApp = __decorate([
|
|
313
|
+
Singleton(),
|
|
314
|
+
__metadata("design:paramtypes", [])
|
|
315
|
+
], UltimateApp);
|
|
316
|
+
// --- 16. Execution & Visualization ---
|
|
317
|
+
const app = Application.create('TheEnterpriseSystem', [
|
|
318
|
+
provideModule(UltimateApp),
|
|
319
|
+
provideConsoleLogTransport(PrettyPrintLogFormatter, { level: LogLevel.Trace, stderrOnly: true }),
|
|
320
|
+
{ provide: ExternalService, useClass: ExternalService },
|
|
321
|
+
{ provide: APP_NAME, useValue: 'TheEnterpriseSystem' },
|
|
322
|
+
{ provide: API_URL, useValue: 'https://api.enterprise.tld' },
|
|
323
|
+
{ provide: FEATURE_FLAGS, useValue: { debug: true } },
|
|
324
|
+
{ provide: CONFIG, useValue: { timeout: 5000 } },
|
|
325
|
+
{ provide: PLUGIN, useValue: { name: 'P3', run: () => { } }, multi: true },
|
|
326
|
+
{
|
|
327
|
+
provide: ConfigService,
|
|
328
|
+
useFactory: (_arg, ctx) => new ConfigService(ctx.resolve(CONFIG)),
|
|
329
|
+
},
|
|
330
|
+
]);
|
|
331
|
+
// Register formatters needed by logger
|
|
332
|
+
app.injector.registerSingleton(PrettyPrintLogFormatter, { useClass: PrettyPrintLogFormatter });
|
|
333
|
+
// Resolve some things before run to show they are captured
|
|
334
|
+
app.injector.resolve(Metrics).track('PRE-RUN');
|
|
335
|
+
await app.runAndWait();
|
|
336
|
+
const useD2 = process.argv.includes('--d2');
|
|
337
|
+
const output = useD2
|
|
338
|
+
? generateApplicationDependencyGraphD2(app)
|
|
339
|
+
: generateApplicationDependencyGraph(app);
|
|
340
|
+
console.log(output);
|
package/injector/decorators.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { type Decorator } from '../reflection/index.js';
|
|
2
2
|
import type { Constructor, OneOrMany, Record, Simplify, TypedOmit } from '../types/index.js';
|
|
3
|
+
import { type ForwardRefToken } from './forward-ref.js';
|
|
3
4
|
import type { Provider } from './provider.js';
|
|
4
5
|
import type { InjectionToken } from './token.js';
|
|
5
|
-
import type {
|
|
6
|
-
import type { ArgumentProvider, ForwardRefInjectionToken, Mapper, RegistrationOptions } from './types.js';
|
|
6
|
+
import type { ArgumentProvider, Mapper, RegistrationOptions } from './types.js';
|
|
7
7
|
export type InjectDecorator = Decorator<'accessor' | 'constructorParameter'>;
|
|
8
8
|
export type InjectableOptions<T, A, C extends Record = Record> = RegistrationOptions<T, A, C> & {
|
|
9
9
|
/** Aliases (tokens) for the class. Useful for example for circular dependencies when you can't use the class itself as a token */
|
|
@@ -84,7 +84,7 @@ export declare function ForwardArg<T, U>(mapper: Mapper<T, U>): InjectDecorator;
|
|
|
84
84
|
export declare function Optional(): InjectDecorator;
|
|
85
85
|
/**
|
|
86
86
|
* Resolve using ForwardRef to handle circular dependencies. Resolve logic derefs all ForwardRefs which are direct properties of resolved instances automatically
|
|
87
|
-
* @param
|
|
87
|
+
* @param tokenFactory factory function that returns the token
|
|
88
88
|
* @param argument resolve argument
|
|
89
89
|
*/
|
|
90
|
-
export declare function ForwardRef<T extends object, A>(
|
|
90
|
+
export declare function ForwardRef<T extends object, A>(tokenFactory: () => InjectionToken<T, A>, argument?: A, options?: Pick<ForwardRefToken, 'typeHint'>): InjectDecorator;
|
package/injector/decorators.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/naming-convention */
|
|
2
1
|
import { createClassDecorator, createDecorator, reflectionRegistry } from '../reflection/index.js';
|
|
3
2
|
import { toArray } from '../utils/array/array.js';
|
|
4
3
|
import { filterObject } from '../utils/object/object.js';
|
|
5
4
|
import { isArray, isDefined, isFunction, isNotNull, isPromise } from '../utils/type-guards.js';
|
|
5
|
+
import { forwardRef } from './forward-ref.js';
|
|
6
6
|
import { Injector } from './injector.js';
|
|
7
7
|
import { injectMetadataSymbol, injectableMetadataSymbol, injectableOptionsSymbol } from './symbols.js';
|
|
8
8
|
/**
|
|
@@ -63,7 +63,7 @@ export function Injectable(options = {}) {
|
|
|
63
63
|
Injector.register(token, targetProvider, mergedRegistationOptions);
|
|
64
64
|
if (isDefined(aliases)) {
|
|
65
65
|
for (const alias of toArray(aliases)) {
|
|
66
|
-
Injector.register(alias, { useToken: token });
|
|
66
|
+
Injector.register(alias, { useToken: token }, { multi: mergedRegistationOptions.multi });
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
},
|
|
@@ -161,13 +161,12 @@ export function Optional() {
|
|
|
161
161
|
}
|
|
162
162
|
/**
|
|
163
163
|
* Resolve using ForwardRef to handle circular dependencies. Resolve logic derefs all ForwardRefs which are direct properties of resolved instances automatically
|
|
164
|
-
* @param
|
|
164
|
+
* @param tokenFactory factory function that returns the token
|
|
165
165
|
* @param argument resolve argument
|
|
166
166
|
*/
|
|
167
|
-
export function ForwardRef(
|
|
167
|
+
export function ForwardRef(tokenFactory, argument, options) {
|
|
168
168
|
const injectMetadata = {
|
|
169
|
-
|
|
170
|
-
forwardRefTypeHint: options?.forwardRefTypeHint,
|
|
169
|
+
injectToken: forwardRef(tokenFactory, options?.typeHint),
|
|
171
170
|
};
|
|
172
171
|
if (isDefined(argument)) {
|
|
173
172
|
injectMetadata.resolveArgumentProvider = () => argument;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ForwardRefTypeHint } from '../utils/object/forward-ref.js';
|
|
2
|
+
import type { InjectionToken } from './token.js';
|
|
3
|
+
export declare class ForwardRefToken<T = any, A = any> {
|
|
4
|
+
readonly tokenFactory: () => InjectionToken<T, A>;
|
|
5
|
+
readonly typeHint?: ForwardRefTypeHint;
|
|
6
|
+
constructor(tokenFactory: () => InjectionToken<T, A>, typeHint?: ForwardRefTypeHint);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Creates a forward reference to a token. Useful for circular dependencies.
|
|
10
|
+
* @param tokenFactory factory function that returns the token
|
|
11
|
+
* @param typeHint optional type hint for the forward reference proxy
|
|
12
|
+
* @returns a ForwardRefToken
|
|
13
|
+
*/
|
|
14
|
+
export declare function forwardRef<T, A>(tokenFactory: () => InjectionToken<T, A>, typeHint?: ForwardRefTypeHint): ForwardRefToken<T, A>;
|
|
15
|
+
export declare function isForwardRefToken(value: any): value is ForwardRefToken;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export class ForwardRefToken {
|
|
2
|
+
tokenFactory;
|
|
3
|
+
typeHint;
|
|
4
|
+
constructor(tokenFactory, typeHint) {
|
|
5
|
+
this.tokenFactory = tokenFactory;
|
|
6
|
+
this.typeHint = typeHint;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Creates a forward reference to a token. Useful for circular dependencies.
|
|
11
|
+
* @param tokenFactory factory function that returns the token
|
|
12
|
+
* @param typeHint optional type hint for the forward reference proxy
|
|
13
|
+
* @returns a ForwardRefToken
|
|
14
|
+
*/
|
|
15
|
+
export function forwardRef(tokenFactory, typeHint) {
|
|
16
|
+
return new ForwardRefToken(tokenFactory, typeHint);
|
|
17
|
+
}
|
|
18
|
+
export function isForwardRefToken(value) {
|
|
19
|
+
return value instanceof ForwardRefToken;
|
|
20
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import type { Application } from '../application/application.js';
|
|
2
|
+
import { Injector } from './injector.js';
|
|
3
|
+
import type { ResolveChain } from './resolve-chain.js';
|
|
4
|
+
import { type InjectionToken } from './token.js';
|
|
5
|
+
export type GenerateDependencyGraphOptions = {
|
|
6
|
+
/** Accesses captured during resolution. Used to show real dependency links. */
|
|
7
|
+
accesses?: {
|
|
8
|
+
chain: ResolveChain;
|
|
9
|
+
}[];
|
|
10
|
+
/** Whether to group nodes by their injector. Defaults to false. */
|
|
11
|
+
groupByInjector?: boolean;
|
|
12
|
+
/** Whether to highlight circular dependencies. Defaults to true. */
|
|
13
|
+
highlightCycles?: boolean;
|
|
14
|
+
/** Whether to show a legend. Defaults to true. */
|
|
15
|
+
showLegend?: boolean;
|
|
16
|
+
/** Whether to show metadata like lifecycle and provider type. Defaults to true. */
|
|
17
|
+
showMetadata?: boolean;
|
|
18
|
+
/** Orientation of the graph. Defaults to 'LR'. */
|
|
19
|
+
rankdir?: 'LR' | 'TB' | 'BT' | 'RL';
|
|
20
|
+
/** Background color of the graph. */
|
|
21
|
+
bgcolor?: string;
|
|
22
|
+
/** Vertical distance between nodes. */
|
|
23
|
+
nodesep?: number;
|
|
24
|
+
/** Horizontal distance between ranks. */
|
|
25
|
+
ranksep?: number;
|
|
26
|
+
/** Font name for nodes and edges. Defaults to 'Helvetica'. */
|
|
27
|
+
fontname?: string;
|
|
28
|
+
/** Font size for nodes. Defaults to 11. */
|
|
29
|
+
fontsize?: number;
|
|
30
|
+
/** Tokens to include. If provided, only these tokens and their dependencies are shown. */
|
|
31
|
+
includeTokens?: InjectionToken[];
|
|
32
|
+
/** Tokens to exclude from the graph. */
|
|
33
|
+
excludeTokens?: InjectionToken[];
|
|
34
|
+
/** Max depth to traverse for dependencies. Only used if includeTokens is specified. */
|
|
35
|
+
maxDepth?: number;
|
|
36
|
+
/** Whether to exclude tokens named 'Logger' or 'LogManager' by default. Defaults to true. */
|
|
37
|
+
excludeLoggers?: boolean;
|
|
38
|
+
};
|
|
39
|
+
export type DependencyGraphNodeMetadata = {
|
|
40
|
+
lifecycle: string;
|
|
41
|
+
type: string;
|
|
42
|
+
hasAfterResolve: boolean;
|
|
43
|
+
};
|
|
44
|
+
export type DependencyGraphEdge = {
|
|
45
|
+
from: InjectionToken;
|
|
46
|
+
to: InjectionToken;
|
|
47
|
+
label: string;
|
|
48
|
+
isCycle: boolean;
|
|
49
|
+
color?: string;
|
|
50
|
+
style?: string;
|
|
51
|
+
penwidth?: number;
|
|
52
|
+
};
|
|
53
|
+
export type DependencyGraphNode = {
|
|
54
|
+
token: InjectionToken;
|
|
55
|
+
name: string;
|
|
56
|
+
injectorId: number;
|
|
57
|
+
metadata: DependencyGraphNodeMetadata;
|
|
58
|
+
};
|
|
59
|
+
export type DependencyGraph = {
|
|
60
|
+
nodes: Map<InjectionToken, DependencyGraphNode>;
|
|
61
|
+
edges: DependencyGraphEdge[];
|
|
62
|
+
injectorNames: Map<number, string>;
|
|
63
|
+
dynamicResolutions: Map<number, Map<InjectionToken, Set<InjectionToken>>>;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Extracts the dependency graph structure from an injector and optional resolution accesses.
|
|
67
|
+
* @param injector The injector to analyze.
|
|
68
|
+
* @param options Options for graph extraction.
|
|
69
|
+
* @returns A structured representation of the dependency graph.
|
|
70
|
+
*/
|
|
71
|
+
export declare function getDependencyGraph(injector: Injector, options?: GenerateDependencyGraphOptions): DependencyGraph;
|
|
72
|
+
/**
|
|
73
|
+
* Renders a dependency graph structure into a Graphviz DOT representation.
|
|
74
|
+
* @param graph The dependency graph to render.
|
|
75
|
+
* @param options Rendering options.
|
|
76
|
+
* @returns A string in DOT format.
|
|
77
|
+
*/
|
|
78
|
+
export declare function renderDependencyGraphToDot(graph: DependencyGraph, options?: GenerateDependencyGraphOptions): string;
|
|
79
|
+
/**
|
|
80
|
+
* Renders a dependency graph structure into a D2 representation.
|
|
81
|
+
* @param graph The dependency graph to render.
|
|
82
|
+
* @param options Rendering options.
|
|
83
|
+
* @returns A string in D2 format.
|
|
84
|
+
*/
|
|
85
|
+
export declare function renderDependencyGraphToD2(graph: DependencyGraph, options?: GenerateDependencyGraphOptions): string;
|
|
86
|
+
/**
|
|
87
|
+
* Generates a Graphviz DOT representation of the dependency injection graph.
|
|
88
|
+
* @param injector The injector to analyze.
|
|
89
|
+
* @param options Options for graph generation.
|
|
90
|
+
* @returns A string in DOT format.
|
|
91
|
+
*/
|
|
92
|
+
export declare function generateDependencyGraph(injector: Injector, options?: GenerateDependencyGraphOptions): string;
|
|
93
|
+
/**
|
|
94
|
+
* Generates a D2 representation of the dependency injection graph.
|
|
95
|
+
* @param injector The injector to analyze.
|
|
96
|
+
* @param options Options for graph generation.
|
|
97
|
+
* @returns A string in D2 format.
|
|
98
|
+
*/
|
|
99
|
+
export declare function generateDependencyGraphD2(injector: Injector, options?: GenerateDependencyGraphOptions): string;
|
|
100
|
+
/**
|
|
101
|
+
* Generates a Graphviz DOT representation of the application's dependency injection graph.
|
|
102
|
+
* @param application The application to analyze.
|
|
103
|
+
* @param options Options for graph generation.
|
|
104
|
+
* @returns A string in DOT format.
|
|
105
|
+
*/
|
|
106
|
+
export declare function generateApplicationDependencyGraph(application: Application, options?: GenerateDependencyGraphOptions): string;
|
|
107
|
+
/**
|
|
108
|
+
* Generates a D2 representation of the application's dependency injection graph.
|
|
109
|
+
* @param application The application to analyze.
|
|
110
|
+
* @param options Options for graph generation.
|
|
111
|
+
* @returns A string in D2 format.
|
|
112
|
+
*/
|
|
113
|
+
export declare function generateApplicationDependencyGraphD2(application: Application, options?: GenerateDependencyGraphOptions): string;
|