@solidxai/core 0.1.10-beta.25 → 0.1.10-beta.26
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/controllers/action-metadata.controller.d.ts +1 -20
- package/dist/controllers/action-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/agent-event.controller.d.ts +1 -20
- package/dist/controllers/agent-event.controller.d.ts.map +1 -1
- package/dist/controllers/agent-session.controller.d.ts +1 -20
- package/dist/controllers/agent-session.controller.d.ts.map +1 -1
- package/dist/controllers/ai-interaction.controller.d.ts +1 -20
- package/dist/controllers/ai-interaction.controller.d.ts.map +1 -1
- package/dist/controllers/chatter-message-details.controller.d.ts +1 -20
- package/dist/controllers/chatter-message-details.controller.d.ts.map +1 -1
- package/dist/controllers/chatter-message.controller.d.ts +1 -20
- package/dist/controllers/chatter-message.controller.d.ts.map +1 -1
- package/dist/controllers/dashboard-user-layout.controller.d.ts +1 -20
- package/dist/controllers/dashboard-user-layout.controller.d.ts.map +1 -1
- package/dist/controllers/email-template.controller.d.ts +1 -20
- package/dist/controllers/email-template.controller.d.ts.map +1 -1
- package/dist/controllers/export-template.controller.d.ts +1 -20
- package/dist/controllers/export-template.controller.d.ts.map +1 -1
- package/dist/controllers/export-transaction.controller.d.ts +1 -20
- package/dist/controllers/export-transaction.controller.d.ts.map +1 -1
- package/dist/controllers/import-transaction-error-log.controller.d.ts +1 -20
- package/dist/controllers/import-transaction-error-log.controller.d.ts.map +1 -1
- package/dist/controllers/import-transaction.controller.d.ts +1 -20
- package/dist/controllers/import-transaction.controller.d.ts.map +1 -1
- package/dist/controllers/list-of-values.controller.d.ts +1 -20
- package/dist/controllers/list-of-values.controller.d.ts.map +1 -1
- package/dist/controllers/locale.controller.d.ts +1 -20
- package/dist/controllers/locale.controller.d.ts.map +1 -1
- package/dist/controllers/mcp-audit-log.controller.d.ts +1 -20
- package/dist/controllers/mcp-audit-log.controller.d.ts.map +1 -1
- package/dist/controllers/media.controller.d.ts +1 -20
- package/dist/controllers/media.controller.d.ts.map +1 -1
- package/dist/controllers/menu-item-metadata.controller.d.ts +1 -20
- package/dist/controllers/menu-item-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/model-metadata.controller.d.ts +10 -30
- package/dist/controllers/model-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/model-metadata.controller.js +2 -2
- package/dist/controllers/model-sequence.controller.d.ts +1 -20
- package/dist/controllers/model-sequence.controller.d.ts.map +1 -1
- package/dist/controllers/module-metadata-explorer.controller.d.ts +171 -0
- package/dist/controllers/module-metadata-explorer.controller.d.ts.map +1 -0
- package/dist/controllers/module-metadata-explorer.controller.js +143 -0
- package/dist/controllers/module-metadata-explorer.controller.js.map +1 -0
- package/dist/controllers/module-metadata.controller.d.ts +5 -0
- package/dist/controllers/module-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/module-metadata.controller.js +12 -0
- package/dist/controllers/module-metadata.controller.js.map +1 -1
- package/dist/controllers/module-package.controller.d.ts +622 -0
- package/dist/controllers/module-package.controller.d.ts.map +1 -0
- package/dist/controllers/module-package.controller.js +150 -0
- package/dist/controllers/module-package.controller.js.map +1 -0
- package/dist/controllers/mq-message-queue.controller.d.ts +1 -20
- package/dist/controllers/mq-message-queue.controller.d.ts.map +1 -1
- package/dist/controllers/mq-message.controller.d.ts +1 -20
- package/dist/controllers/mq-message.controller.d.ts.map +1 -1
- package/dist/controllers/permission-metadata.controller.d.ts +1 -20
- package/dist/controllers/permission-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/role-metadata.controller.d.ts +1 -20
- package/dist/controllers/role-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/saved-filters.controller.d.ts +1 -20
- package/dist/controllers/saved-filters.controller.d.ts.map +1 -1
- package/dist/controllers/scheduled-job.controller.d.ts +1 -20
- package/dist/controllers/scheduled-job.controller.d.ts.map +1 -1
- package/dist/controllers/security-rule.controller.d.ts +1 -20
- package/dist/controllers/security-rule.controller.d.ts.map +1 -1
- package/dist/controllers/sms-template.controller.d.ts +1 -20
- package/dist/controllers/sms-template.controller.d.ts.map +1 -1
- package/dist/controllers/user-activity-history.controller.d.ts +1 -20
- package/dist/controllers/user-activity-history.controller.d.ts.map +1 -1
- package/dist/controllers/user-view-metadata.controller.d.ts +1 -20
- package/dist/controllers/user-view-metadata.controller.d.ts.map +1 -1
- package/dist/controllers/user.controller.d.ts +1 -20
- package/dist/controllers/user.controller.d.ts.map +1 -1
- package/dist/controllers/view-metadata.controller.d.ts +1 -20
- package/dist/controllers/view-metadata.controller.d.ts.map +1 -1
- package/dist/dtos/confirm-module-package-import.dto.d.ts +4 -0
- package/dist/dtos/confirm-module-package-import.dto.d.ts.map +1 -0
- package/dist/dtos/confirm-module-package-import.dto.js +34 -0
- package/dist/dtos/confirm-module-package-import.dto.js.map +1 -0
- package/dist/dtos/metadata-explorer-references-query.dto.d.ts +10 -0
- package/dist/dtos/metadata-explorer-references-query.dto.d.ts.map +1 -0
- package/dist/dtos/metadata-explorer-references-query.dto.js +69 -0
- package/dist/dtos/metadata-explorer-references-query.dto.js.map +1 -0
- package/dist/dtos/metadata-explorer-search-query.dto.d.ts +8 -0
- package/dist/dtos/metadata-explorer-search-query.dto.d.ts.map +1 -0
- package/dist/dtos/metadata-explorer-search-query.dto.js +55 -0
- package/dist/dtos/metadata-explorer-search-query.dto.js.map +1 -0
- package/dist/dtos/metadata-explorer-write.dto.d.ts +4 -0
- package/dist/dtos/metadata-explorer-write.dto.d.ts.map +1 -0
- package/dist/dtos/metadata-explorer-write.dto.js +30 -0
- package/dist/dtos/metadata-explorer-write.dto.js.map +1 -0
- package/dist/dtos/run-module-package-build.dto.d.ts +5 -0
- package/dist/dtos/run-module-package-build.dto.d.ts.map +1 -0
- package/dist/dtos/run-module-package-build.dto.js +38 -0
- package/dist/dtos/run-module-package-build.dto.js.map +1 -0
- package/dist/dtos/run-module-package-seed.dto.d.ts +4 -0
- package/dist/dtos/run-module-package-seed.dto.d.ts.map +1 -0
- package/dist/dtos/run-module-package-seed.dto.js +34 -0
- package/dist/dtos/run-module-package-seed.dto.js.map +1 -0
- package/dist/helpers/command.service.js +1 -1
- package/dist/helpers/command.service.js.map +1 -1
- package/dist/helpers/module-metadata-helper.service.d.ts +2 -0
- package/dist/helpers/module-metadata-helper.service.d.ts.map +1 -1
- package/dist/helpers/module-metadata-helper.service.js +14 -12
- package/dist/helpers/module-metadata-helper.service.js.map +1 -1
- package/dist/helpers/module.helper.d.ts.map +1 -1
- package/dist/helpers/module.helper.js +11 -6
- package/dist/helpers/module.helper.js.map +1 -1
- package/dist/helpers/typeorm-migration-helpers.d.ts +12 -0
- package/dist/helpers/typeorm-migration-helpers.d.ts.map +1 -0
- package/dist/helpers/typeorm-migration-helpers.js +119 -0
- package/dist/helpers/typeorm-migration-helpers.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.d.ts +1 -0
- package/dist/seeders/module-metadata-seeder.service.d.ts.map +1 -1
- package/dist/seeders/module-metadata-seeder.service.js +57 -38
- package/dist/seeders/module-metadata-seeder.service.js.map +1 -1
- package/dist/seeders/module-test-data.service.js +1 -1
- package/dist/seeders/module-test-data.service.js.map +1 -1
- package/dist/seeders/seed-data/solid-core-metadata.json +2364 -1106
- package/dist/services/crud-helper.service.d.ts +18 -0
- package/dist/services/crud-helper.service.d.ts.map +1 -1
- package/dist/services/crud-helper.service.js +59 -0
- package/dist/services/crud-helper.service.js.map +1 -1
- package/dist/services/crud.service.d.ts +1 -21
- package/dist/services/crud.service.d.ts.map +1 -1
- package/dist/services/crud.service.js +9 -75
- package/dist/services/crud.service.js.map +1 -1
- package/dist/services/genai/ingest-metadata.service.js +2 -2
- package/dist/services/genai/ingest-metadata.service.js.map +1 -1
- package/dist/services/media.service.d.ts +1 -20
- package/dist/services/media.service.d.ts.map +1 -1
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.d.ts.map +1 -1
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.js +31 -2
- package/dist/services/mediaStorageProviders/file-s3-storage-provider.js.map +1 -1
- package/dist/services/mediaStorageProviders/file-storage-provider.d.ts.map +1 -1
- package/dist/services/mediaStorageProviders/file-storage-provider.js +5 -1
- package/dist/services/mediaStorageProviders/file-storage-provider.js.map +1 -1
- package/dist/services/model-metadata.service.d.ts +15 -30
- package/dist/services/model-metadata.service.d.ts.map +1 -1
- package/dist/services/model-metadata.service.js +249 -29
- package/dist/services/model-metadata.service.js.map +1 -1
- package/dist/services/module-metadata-explorer.service.d.ts +161 -0
- package/dist/services/module-metadata-explorer.service.d.ts.map +1 -0
- package/dist/services/module-metadata-explorer.service.js +485 -0
- package/dist/services/module-metadata-explorer.service.js.map +1 -0
- package/dist/services/module-metadata.service.d.ts +7 -0
- package/dist/services/module-metadata.service.d.ts.map +1 -1
- package/dist/services/module-metadata.service.js +121 -2
- package/dist/services/module-metadata.service.js.map +1 -1
- package/dist/services/module-package.service.d.ts +266 -0
- package/dist/services/module-package.service.d.ts.map +1 -0
- package/dist/services/module-package.service.js +980 -0
- package/dist/services/module-package.service.js.map +1 -0
- package/dist/solid-core.module.d.ts.map +1 -1
- package/dist/solid-core.module.js +10 -2
- package/dist/solid-core.module.js.map +1 -1
- package/dist-tests/api/authenticate.spec.js +119 -0
- package/dist-tests/api/authenticate.spec.js.map +1 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js +97 -0
- package/dist-tests/api/crud-service.findOne.cityMaster.spec.js.map +1 -0
- package/dist-tests/api/ping.spec.js +21 -0
- package/dist-tests/api/ping.spec.js.map +1 -0
- package/dist-tests/helpers/auth.js +41 -0
- package/dist-tests/helpers/auth.js.map +1 -0
- package/dist-tests/helpers/env.js +11 -0
- package/dist-tests/helpers/env.js.map +1 -0
- package/docs/dashboards/AGENTIC_DASHBOARD_IMPLEMENTATION_PLAN.md +438 -0
- package/docs/dashboards/dashboard-curl-smoke-tests.txt +146 -0
- package/docs/dashboards/delete-legacy-dashboard-metadata.sql +172 -0
- package/docs/grouping-enhancements.md +89 -0
- package/docs/java-spring/README.md +3 -0
- package/docs/java-spring/solid-core-module-deep-dive-report.md +1317 -0
- package/docs/module-package-import-handoff.md +691 -0
- package/docs/seed-changes.md +65 -0
- package/docs/test-data-workflow.md +200 -0
- package/docs/type-declaration-import-issue.md +24 -0
- package/package.json +2 -1
- package/src/controllers/module-metadata-explorer.controller.ts +83 -0
- package/src/controllers/module-metadata.controller.ts +6 -0
- package/src/controllers/module-package.controller.ts +102 -0
- package/src/dtos/confirm-module-package-import.dto.ts +12 -0
- package/src/dtos/metadata-explorer-references-query.dto.ts +39 -0
- package/src/dtos/metadata-explorer-search-query.dto.ts +28 -0
- package/src/dtos/metadata-explorer-write.dto.ts +11 -0
- package/src/dtos/run-module-package-build.dto.ts +14 -0
- package/src/dtos/run-module-package-seed.dto.ts +12 -0
- package/src/helpers/command.service.ts +1 -1
- package/src/helpers/module-metadata-helper.service.ts +19 -21
- package/src/helpers/module.helper.ts +12 -9
- package/src/helpers/typeorm-migration-helpers.ts +163 -0
- package/src/index.ts +8 -0
- package/src/seeders/module-metadata-seeder.service.ts +63 -38
- package/src/seeders/module-test-data.service.ts +1 -1
- package/src/seeders/seed-data/solid-core-metadata.json +2365 -1107
- package/src/services/crud-helper.service.ts +72 -0
- package/src/services/crud.service.ts +11 -104
- package/src/services/dashboard-providers/README.md +1 -1
- package/src/services/genai/ingest-metadata.service.ts +3 -3
- package/src/services/mediaStorageProviders/file-s3-storage-provider.ts +37 -2
- package/src/services/mediaStorageProviders/file-storage-provider.ts +5 -1
- package/src/services/model-metadata.service.ts +302 -98
- package/src/services/module-metadata-explorer.service.ts +670 -0
- package/src/services/module-metadata.service.ts +136 -10
- package/src/services/module-package.service.ts +1171 -0
- package/src/solid-core.module.ts +10 -2
- package/.claude/settings.local.json +0 -15
- package/CLAUDE.md +0 -26
- package/dist/services/database/database-bootstrap.service.d.ts +0 -12
- package/dist/services/database/database-bootstrap.service.d.ts.map +0 -1
- package/dist/services/database/database-bootstrap.service.js +0 -115
- package/dist/services/database/database-bootstrap.service.js.map +0 -1
- package/sql/default/mariadb/proc_CleanupModelMetadata.sql +0 -153
- package/sql/default/mariadb/proc_CleanupModuleMetadata.sql +0 -56
- package/sql/default/mssql/proc_CleanupModuleMetadata.sql +0 -78
- package/sql/default/mysql/proc_CleanupModelMetadata.sql +0 -153
- package/sql/default/mysql/proc_CleanupModuleMetadata.sql +0 -56
- package/sql/default/postgres/proc_CleanupModelMetadata.sql +0 -148
- package/sql/default/postgres/proc_CleanupModuleMetadata.sql +0 -50
- package/sql/default/postgres/scratchpad.sql.txt +0 -12
- package/src/services/1.js +0 -6
- package/src/services/database/database-bootstrap.service.ts +0 -91
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { ModuleMetadataHelperService } from '../helpers/module-metadata-helper.service';
|
|
2
|
+
import { MetadataExplorerReferencesQueryDto } from '../dtos/metadata-explorer-references-query.dto';
|
|
3
|
+
import { MetadataExplorerSearchQueryDto } from '../dtos/metadata-explorer-search-query.dto';
|
|
4
|
+
import { MetadataExplorerWriteDto } from '../dtos/metadata-explorer-write.dto';
|
|
5
|
+
type MetadataExplorerSectionType = 'object' | 'array';
|
|
6
|
+
type MetadataValidationIssue = {
|
|
7
|
+
path: string;
|
|
8
|
+
message: string;
|
|
9
|
+
severity: 'error' | 'warning';
|
|
10
|
+
};
|
|
11
|
+
type MetadataSearchMatch = {
|
|
12
|
+
path: string;
|
|
13
|
+
sectionKey: string | null;
|
|
14
|
+
matchType: 'key' | 'value';
|
|
15
|
+
valueType: string;
|
|
16
|
+
preview: string;
|
|
17
|
+
};
|
|
18
|
+
export declare class ModuleMetadataExplorerService {
|
|
19
|
+
private readonly moduleMetadataHelperService;
|
|
20
|
+
private readonly logger;
|
|
21
|
+
constructor(moduleMetadataHelperService: ModuleMetadataHelperService);
|
|
22
|
+
getManifest(moduleName: string): Promise<{
|
|
23
|
+
moduleName: string;
|
|
24
|
+
filePath: string;
|
|
25
|
+
lastModifiedAt: string;
|
|
26
|
+
sections: {
|
|
27
|
+
exists: boolean;
|
|
28
|
+
itemCount: number;
|
|
29
|
+
nodeCount: number;
|
|
30
|
+
preview: string;
|
|
31
|
+
key: string;
|
|
32
|
+
title: string;
|
|
33
|
+
jsonPath: string;
|
|
34
|
+
type: MetadataExplorerSectionType;
|
|
35
|
+
description: string;
|
|
36
|
+
}[];
|
|
37
|
+
validation: {
|
|
38
|
+
valid: boolean;
|
|
39
|
+
issues: MetadataValidationIssue[];
|
|
40
|
+
};
|
|
41
|
+
}>;
|
|
42
|
+
getDocument(moduleName: string): Promise<{
|
|
43
|
+
moduleName: string;
|
|
44
|
+
filePath: string;
|
|
45
|
+
lastModifiedAt: string;
|
|
46
|
+
value: any;
|
|
47
|
+
validation: {
|
|
48
|
+
valid: boolean;
|
|
49
|
+
issues: MetadataValidationIssue[];
|
|
50
|
+
};
|
|
51
|
+
}>;
|
|
52
|
+
updateDocument(moduleName: string, dto: MetadataExplorerWriteDto): Promise<{
|
|
53
|
+
moduleName: string;
|
|
54
|
+
filePath: string;
|
|
55
|
+
lastModifiedAt: string;
|
|
56
|
+
value: any;
|
|
57
|
+
validation: {
|
|
58
|
+
valid: boolean;
|
|
59
|
+
issues: MetadataValidationIssue[];
|
|
60
|
+
};
|
|
61
|
+
}>;
|
|
62
|
+
validateDocument(moduleName: string, dto?: MetadataExplorerWriteDto): Promise<{
|
|
63
|
+
valid: boolean;
|
|
64
|
+
issues: MetadataValidationIssue[];
|
|
65
|
+
moduleName: string;
|
|
66
|
+
filePath: string;
|
|
67
|
+
}>;
|
|
68
|
+
getSection(moduleName: string, sectionKey: string): Promise<{
|
|
69
|
+
moduleName: string;
|
|
70
|
+
filePath: string;
|
|
71
|
+
lastModifiedAt: string;
|
|
72
|
+
section: {
|
|
73
|
+
key: string;
|
|
74
|
+
title: string;
|
|
75
|
+
jsonPath: string;
|
|
76
|
+
type: MetadataExplorerSectionType;
|
|
77
|
+
description: string;
|
|
78
|
+
exists: boolean;
|
|
79
|
+
itemCount: number;
|
|
80
|
+
nodeCount: number;
|
|
81
|
+
value: any;
|
|
82
|
+
};
|
|
83
|
+
validation: {
|
|
84
|
+
valid: boolean;
|
|
85
|
+
issues: MetadataValidationIssue[];
|
|
86
|
+
};
|
|
87
|
+
}>;
|
|
88
|
+
updateSection(moduleName: string, sectionKey: string, dto: MetadataExplorerWriteDto): Promise<{
|
|
89
|
+
moduleName: string;
|
|
90
|
+
filePath: string;
|
|
91
|
+
lastModifiedAt: string;
|
|
92
|
+
section: {
|
|
93
|
+
key: string;
|
|
94
|
+
title: string;
|
|
95
|
+
jsonPath: string;
|
|
96
|
+
type: MetadataExplorerSectionType;
|
|
97
|
+
description: string;
|
|
98
|
+
exists: boolean;
|
|
99
|
+
itemCount: number;
|
|
100
|
+
nodeCount: number;
|
|
101
|
+
value: any;
|
|
102
|
+
};
|
|
103
|
+
validation: {
|
|
104
|
+
valid: boolean;
|
|
105
|
+
issues: MetadataValidationIssue[];
|
|
106
|
+
};
|
|
107
|
+
}>;
|
|
108
|
+
validateSection(moduleName: string, sectionKey: string, dto?: MetadataExplorerWriteDto): Promise<{
|
|
109
|
+
valid: boolean;
|
|
110
|
+
issues: MetadataValidationIssue[];
|
|
111
|
+
moduleName: string;
|
|
112
|
+
sectionKey: string;
|
|
113
|
+
section: {
|
|
114
|
+
key: string;
|
|
115
|
+
title: string;
|
|
116
|
+
jsonPath: string;
|
|
117
|
+
type: MetadataExplorerSectionType;
|
|
118
|
+
};
|
|
119
|
+
}>;
|
|
120
|
+
search(moduleName: string, query: MetadataExplorerSearchQueryDto): Promise<{
|
|
121
|
+
moduleName: string;
|
|
122
|
+
query: string;
|
|
123
|
+
sectionKey: string;
|
|
124
|
+
meta: {
|
|
125
|
+
totalMatches: number;
|
|
126
|
+
returned: number;
|
|
127
|
+
limit: number;
|
|
128
|
+
offset: number;
|
|
129
|
+
};
|
|
130
|
+
matches: MetadataSearchMatch[];
|
|
131
|
+
}>;
|
|
132
|
+
findReferences(moduleName: string, query: MetadataExplorerReferencesQueryDto): Promise<{
|
|
133
|
+
moduleName: string;
|
|
134
|
+
needle: string;
|
|
135
|
+
sectionKey: string;
|
|
136
|
+
meta: {
|
|
137
|
+
totalMatches: number;
|
|
138
|
+
returned: number;
|
|
139
|
+
limit: number;
|
|
140
|
+
offset: number;
|
|
141
|
+
};
|
|
142
|
+
matches: MetadataSearchMatch[];
|
|
143
|
+
}>;
|
|
144
|
+
private loadMetadataDocument;
|
|
145
|
+
private writeMetadataDocument;
|
|
146
|
+
private getSectionDefinition;
|
|
147
|
+
private buildSectionResponse;
|
|
148
|
+
private validateDocumentValue;
|
|
149
|
+
private validateSectionValue;
|
|
150
|
+
private getValueAtPath;
|
|
151
|
+
private setValueAtPath;
|
|
152
|
+
private countNodes;
|
|
153
|
+
private buildPreview;
|
|
154
|
+
private collectMatches;
|
|
155
|
+
private matchesNeedle;
|
|
156
|
+
private resolveSectionKey;
|
|
157
|
+
private joinPath;
|
|
158
|
+
private assertValueProvided;
|
|
159
|
+
}
|
|
160
|
+
export {};
|
|
161
|
+
//# sourceMappingURL=module-metadata-explorer.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-metadata-explorer.service.d.ts","sourceRoot":"","sources":["../../src/services/module-metadata-explorer.service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AACzF,OAAO,EAAE,kCAAkC,EAAE,MAAM,gDAAgD,CAAC;AACpG,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAC;AAE/E,KAAK,2BAA2B,GAAG,QAAQ,GAAG,OAAO,CAAC;AAUtD,KAAK,uBAAuB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;CACjC,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,KAAK,GAAG,OAAO,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAuBF,qBACa,6BAA6B;IAIlC,OAAO,CAAC,QAAQ,CAAC,2BAA2B;IAHhD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAkD;gBAGpD,2BAA2B,EAAE,2BAA2B;IASvE,WAAW,CAAC,UAAU,EAAE,MAAM;;;;;;;;;iBAxD/B,MAAM;mBACJ,MAAM;sBACH,MAAM;kBACV,2BAA2B;yBACpB,MAAM;;;;;;;IAkFb,WAAW,CAAC,UAAU,EAAE,MAAM;;;;;;;;;;IAkB9B,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,wBAAwB;;;;;;;;;;IAkBhE,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,wBAAwB;;;;;;IAkBnE,UAAU,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;;;;;;;;;;;;;;;;;;;;IAqBjD,aAAa,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,EAAE,wBAAwB;;;;;;;;;;;;;;;;;;;;IA0BnF,eAAe,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,wBAAwB;;;;;;;;;;;;IA0BtF,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,8BAA8B;;;;;;;;;;;;IA2ChE,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,kCAAkC;;;;;;;;;;;;YA2CpE,oBAAoB;YAiCpB,qBAAqB;IAWnC,OAAO,CAAC,oBAAoB;IAc5B,OAAO,CAAC,oBAAoB;IAoB5B,OAAO,CAAC,qBAAqB;IA8C7B,OAAO,CAAC,oBAAoB;IAkD5B,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,cAAc;IAqBtB,OAAO,CAAC,UAAU;IAiBlB,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,cAAc;IAyEtB,OAAO,CAAC,aAAa;IAarB,OAAO,CAAC,iBAAiB;IAgBzB,OAAO,CAAC,QAAQ;IAWhB,OAAO,CAAC,mBAAmB;CAK9B"}
|
|
@@ -0,0 +1,485 @@
|
|
|
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 ModuleMetadataExplorerService_1;
|
|
45
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
46
|
+
exports.ModuleMetadataExplorerService = void 0;
|
|
47
|
+
const common_1 = require("@nestjs/common");
|
|
48
|
+
const fs = __importStar(require("fs/promises"));
|
|
49
|
+
const path = __importStar(require("path"));
|
|
50
|
+
const disallow_in_production_decorator_1 = require("../decorators/disallow-in-production.decorator");
|
|
51
|
+
const module_metadata_helper_service_1 = require("../helpers/module-metadata-helper.service");
|
|
52
|
+
const metadata_explorer_write_dto_1 = require("../dtos/metadata-explorer-write.dto");
|
|
53
|
+
const SECTION_DEFINITIONS = [
|
|
54
|
+
{ key: 'module', title: 'Module', jsonPath: 'moduleMetadata', type: 'object', description: 'Top-level module metadata excluding nested models.' },
|
|
55
|
+
{ key: 'models', title: 'Models', jsonPath: 'moduleMetadata.models', type: 'array', description: 'Model metadata definitions for the module.' },
|
|
56
|
+
{ key: 'roles', title: 'Roles', jsonPath: 'roles', type: 'array', description: 'Role metadata definitions.' },
|
|
57
|
+
{ key: 'users', title: 'Users', jsonPath: 'users', type: 'array', description: 'Seed users and user-role assignments.' },
|
|
58
|
+
{ key: 'permissions', title: 'Permissions', jsonPath: 'permissions', type: 'array', description: 'Permission declarations and explicit additions.' },
|
|
59
|
+
{ key: 'actions', title: 'Actions', jsonPath: 'actions', type: 'array', description: 'Action metadata definitions.' },
|
|
60
|
+
{ key: 'menus', title: 'Menus', jsonPath: 'menus', type: 'array', description: 'Menu item metadata definitions.' },
|
|
61
|
+
{ key: 'views', title: 'Views', jsonPath: 'views', type: 'array', description: 'List, form, kanban, tree, and related view metadata.' },
|
|
62
|
+
{ key: 'emailTemplates', title: 'Email Templates', jsonPath: 'emailTemplates', type: 'array', description: 'Email template metadata.' },
|
|
63
|
+
{ key: 'smsTemplates', title: 'SMS Templates', jsonPath: 'smsTemplates', type: 'array', description: 'SMS template metadata.' },
|
|
64
|
+
{ key: 'mediaStorageProviders', title: 'Media Storage Providers', jsonPath: 'mediaStorageProviders', type: 'array', description: 'Configured media storage providers.' },
|
|
65
|
+
{ key: 'savedFilters', title: 'Saved Filters', jsonPath: 'savedFilters', type: 'array', description: 'Saved filter definitions.' },
|
|
66
|
+
{ key: 'securityRules', title: 'Security Rules', jsonPath: 'securityRules', type: 'array', description: 'Security rule definitions.' },
|
|
67
|
+
{ key: 'listOfValues', title: 'List Of Values', jsonPath: 'listOfValues', type: 'array', description: 'List of values entries.' },
|
|
68
|
+
{ key: 'dashboards', title: 'Dashboards', jsonPath: 'dashboards', type: 'array', description: 'Dashboard metadata definitions.' },
|
|
69
|
+
{ key: 'testing', title: 'Testing', jsonPath: 'testing', type: 'object', description: 'Testing roles, users, specs, and scenarios.' },
|
|
70
|
+
{ key: 'scheduledJobs', title: 'Scheduled Jobs', jsonPath: 'scheduledJobs', type: 'array', description: 'Scheduled job metadata definitions.' },
|
|
71
|
+
{ key: 'modelSequences', title: 'Model Sequences', jsonPath: 'modelSequences', type: 'array', description: 'Model sequence definitions.' },
|
|
72
|
+
];
|
|
73
|
+
let ModuleMetadataExplorerService = ModuleMetadataExplorerService_1 = class ModuleMetadataExplorerService {
|
|
74
|
+
constructor(moduleMetadataHelperService) {
|
|
75
|
+
this.moduleMetadataHelperService = moduleMetadataHelperService;
|
|
76
|
+
this.logger = new common_1.Logger(ModuleMetadataExplorerService_1.name);
|
|
77
|
+
}
|
|
78
|
+
async getManifest(moduleName) {
|
|
79
|
+
const { document, filePath, stats } = await this.loadMetadataDocument(moduleName);
|
|
80
|
+
const validation = this.validateDocumentValue(document);
|
|
81
|
+
const sections = SECTION_DEFINITIONS.map((definition) => {
|
|
82
|
+
const value = this.getValueAtPath(document, definition.jsonPath);
|
|
83
|
+
return {
|
|
84
|
+
...definition,
|
|
85
|
+
exists: value !== undefined,
|
|
86
|
+
itemCount: Array.isArray(value) ? value.length : undefined,
|
|
87
|
+
nodeCount: this.countNodes(value),
|
|
88
|
+
preview: this.buildPreview(value, 96),
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
return {
|
|
92
|
+
moduleName,
|
|
93
|
+
filePath,
|
|
94
|
+
lastModifiedAt: stats.mtime.toISOString(),
|
|
95
|
+
sections,
|
|
96
|
+
validation,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async getDocument(moduleName) {
|
|
100
|
+
const { document, filePath, stats } = await this.loadMetadataDocument(moduleName);
|
|
101
|
+
return {
|
|
102
|
+
moduleName,
|
|
103
|
+
filePath,
|
|
104
|
+
lastModifiedAt: stats.mtime.toISOString(),
|
|
105
|
+
value: document,
|
|
106
|
+
validation: this.validateDocumentValue(document),
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
async updateDocument(moduleName, dto) {
|
|
110
|
+
this.assertValueProvided(dto?.value);
|
|
111
|
+
const validation = this.validateDocumentValue(dto.value);
|
|
112
|
+
if (!validation.valid) {
|
|
113
|
+
throw new common_1.BadRequestException(validation);
|
|
114
|
+
}
|
|
115
|
+
const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName);
|
|
116
|
+
await this.writeMetadataDocument(filePath, dto.value);
|
|
117
|
+
return this.getDocument(moduleName);
|
|
118
|
+
}
|
|
119
|
+
async validateDocument(moduleName, dto) {
|
|
120
|
+
const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName);
|
|
121
|
+
const value = dto && Object.prototype.hasOwnProperty.call(dto, 'value')
|
|
122
|
+
? dto.value
|
|
123
|
+
: (await this.loadMetadataDocument(moduleName)).document;
|
|
124
|
+
return {
|
|
125
|
+
moduleName,
|
|
126
|
+
filePath,
|
|
127
|
+
...this.validateDocumentValue(value),
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
async getSection(moduleName, sectionKey) {
|
|
131
|
+
const definition = this.getSectionDefinition(sectionKey);
|
|
132
|
+
const { document, filePath, stats } = await this.loadMetadataDocument(moduleName);
|
|
133
|
+
const value = this.getValueAtPath(document, definition.jsonPath);
|
|
134
|
+
return {
|
|
135
|
+
moduleName,
|
|
136
|
+
filePath,
|
|
137
|
+
lastModifiedAt: stats.mtime.toISOString(),
|
|
138
|
+
section: this.buildSectionResponse(definition, value),
|
|
139
|
+
validation: this.validateSectionValue(definition, value),
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
async updateSection(moduleName, sectionKey, dto) {
|
|
143
|
+
this.assertValueProvided(dto?.value);
|
|
144
|
+
const definition = this.getSectionDefinition(sectionKey);
|
|
145
|
+
const sectionValidation = this.validateSectionValue(definition, dto.value);
|
|
146
|
+
if (!sectionValidation.valid) {
|
|
147
|
+
throw new common_1.BadRequestException(sectionValidation);
|
|
148
|
+
}
|
|
149
|
+
const { document, filePath } = await this.loadMetadataDocument(moduleName);
|
|
150
|
+
this.setValueAtPath(document, definition.jsonPath, dto.value);
|
|
151
|
+
const documentValidation = this.validateDocumentValue(document);
|
|
152
|
+
if (!documentValidation.valid) {
|
|
153
|
+
throw new common_1.BadRequestException(documentValidation);
|
|
154
|
+
}
|
|
155
|
+
await this.writeMetadataDocument(filePath, document);
|
|
156
|
+
return this.getSection(moduleName, sectionKey);
|
|
157
|
+
}
|
|
158
|
+
async validateSection(moduleName, sectionKey, dto) {
|
|
159
|
+
const definition = this.getSectionDefinition(sectionKey);
|
|
160
|
+
const value = dto && Object.prototype.hasOwnProperty.call(dto, 'value')
|
|
161
|
+
? dto.value
|
|
162
|
+
: this.getValueAtPath((await this.loadMetadataDocument(moduleName)).document, definition.jsonPath);
|
|
163
|
+
return {
|
|
164
|
+
moduleName,
|
|
165
|
+
sectionKey,
|
|
166
|
+
section: {
|
|
167
|
+
key: definition.key,
|
|
168
|
+
title: definition.title,
|
|
169
|
+
jsonPath: definition.jsonPath,
|
|
170
|
+
type: definition.type,
|
|
171
|
+
},
|
|
172
|
+
...this.validateSectionValue(definition, value),
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
async search(moduleName, query) {
|
|
176
|
+
const needle = `${query?.query ?? ''}`.trim();
|
|
177
|
+
if (!needle) {
|
|
178
|
+
throw new common_1.BadRequestException('Search query is required.');
|
|
179
|
+
}
|
|
180
|
+
const { document } = await this.loadMetadataDocument(moduleName);
|
|
181
|
+
const targetSection = query?.sectionKey ? this.getSectionDefinition(query.sectionKey) : null;
|
|
182
|
+
const searchRoot = targetSection ? this.getValueAtPath(document, targetSection.jsonPath) : document;
|
|
183
|
+
const rootPath = targetSection ? targetSection.jsonPath : '';
|
|
184
|
+
const limit = query?.limit ?? 10;
|
|
185
|
+
const offset = query?.offset ?? 0;
|
|
186
|
+
const matches = this.collectMatches(searchRoot, rootPath, {
|
|
187
|
+
needle,
|
|
188
|
+
exact: query?.exact ?? false,
|
|
189
|
+
limit,
|
|
190
|
+
offset,
|
|
191
|
+
previewLength: query?.previewLength ?? 120,
|
|
192
|
+
matchKeys: true,
|
|
193
|
+
matchValues: true,
|
|
194
|
+
});
|
|
195
|
+
return {
|
|
196
|
+
moduleName,
|
|
197
|
+
query: needle,
|
|
198
|
+
sectionKey: targetSection?.key ?? null,
|
|
199
|
+
meta: {
|
|
200
|
+
totalMatches: matches.total,
|
|
201
|
+
returned: matches.items.length,
|
|
202
|
+
limit,
|
|
203
|
+
offset,
|
|
204
|
+
},
|
|
205
|
+
matches: matches.items,
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
async findReferences(moduleName, query) {
|
|
209
|
+
const needle = `${query?.needle ?? ''}`.trim();
|
|
210
|
+
if (!needle) {
|
|
211
|
+
throw new common_1.BadRequestException('Reference needle is required.');
|
|
212
|
+
}
|
|
213
|
+
const { document } = await this.loadMetadataDocument(moduleName);
|
|
214
|
+
const targetSection = query?.sectionKey ? this.getSectionDefinition(query.sectionKey) : null;
|
|
215
|
+
const searchRoot = targetSection ? this.getValueAtPath(document, targetSection.jsonPath) : document;
|
|
216
|
+
const rootPath = targetSection ? targetSection.jsonPath : '';
|
|
217
|
+
const limit = query?.limit ?? 10;
|
|
218
|
+
const offset = query?.offset ?? 0;
|
|
219
|
+
const matches = this.collectMatches(searchRoot, rootPath, {
|
|
220
|
+
needle,
|
|
221
|
+
exact: query?.exact ?? true,
|
|
222
|
+
limit,
|
|
223
|
+
offset,
|
|
224
|
+
previewLength: 140,
|
|
225
|
+
matchKeys: query?.matchKeys ?? true,
|
|
226
|
+
matchValues: query?.matchValues ?? true,
|
|
227
|
+
excludePath: query?.excludePath,
|
|
228
|
+
});
|
|
229
|
+
return {
|
|
230
|
+
moduleName,
|
|
231
|
+
needle,
|
|
232
|
+
sectionKey: targetSection?.key ?? null,
|
|
233
|
+
meta: {
|
|
234
|
+
totalMatches: matches.total,
|
|
235
|
+
returned: matches.items.length,
|
|
236
|
+
limit,
|
|
237
|
+
offset,
|
|
238
|
+
},
|
|
239
|
+
matches: matches.items,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
async loadMetadataDocument(moduleName) {
|
|
243
|
+
const filePath = await this.moduleMetadataHelperService.getModuleMetadataFilePath(moduleName);
|
|
244
|
+
if (!filePath) {
|
|
245
|
+
throw new common_1.NotFoundException(`Unable to resolve metadata file for module: ${moduleName}`);
|
|
246
|
+
}
|
|
247
|
+
try {
|
|
248
|
+
const [raw, stats] = await Promise.all([
|
|
249
|
+
fs.readFile(filePath, 'utf-8'),
|
|
250
|
+
fs.stat(filePath),
|
|
251
|
+
]);
|
|
252
|
+
const document = JSON.parse(raw);
|
|
253
|
+
return { document, filePath, stats };
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
if (error?.code === 'ENOENT') {
|
|
257
|
+
throw new common_1.NotFoundException(`Metadata file not found for module: ${moduleName}`);
|
|
258
|
+
}
|
|
259
|
+
if (error instanceof SyntaxError) {
|
|
260
|
+
throw new common_1.BadRequestException(`Metadata file for module ${moduleName} contains invalid JSON.`);
|
|
261
|
+
}
|
|
262
|
+
this.logger.error(`Failed to load metadata for module ${moduleName}`, error);
|
|
263
|
+
throw error;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
async writeMetadataDocument(filePath, document) {
|
|
267
|
+
await fs.mkdir(path.dirname(filePath), { recursive: true });
|
|
268
|
+
await fs.writeFile(filePath, `${JSON.stringify(document, null, 2)}\n`, 'utf-8');
|
|
269
|
+
}
|
|
270
|
+
getSectionDefinition(sectionKey) {
|
|
271
|
+
const definition = SECTION_DEFINITIONS.find((item) => item.key === sectionKey);
|
|
272
|
+
if (!definition) {
|
|
273
|
+
throw new common_1.NotFoundException(`Metadata explorer section not found: ${sectionKey}`);
|
|
274
|
+
}
|
|
275
|
+
return definition;
|
|
276
|
+
}
|
|
277
|
+
buildSectionResponse(definition, value) {
|
|
278
|
+
return {
|
|
279
|
+
key: definition.key,
|
|
280
|
+
title: definition.title,
|
|
281
|
+
jsonPath: definition.jsonPath,
|
|
282
|
+
type: definition.type,
|
|
283
|
+
description: definition.description,
|
|
284
|
+
exists: value !== undefined,
|
|
285
|
+
itemCount: Array.isArray(value) ? value.length : undefined,
|
|
286
|
+
nodeCount: this.countNodes(value),
|
|
287
|
+
value,
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
validateDocumentValue(document) {
|
|
291
|
+
const issues = [];
|
|
292
|
+
if (!document || typeof document !== 'object' || Array.isArray(document)) {
|
|
293
|
+
issues.push({
|
|
294
|
+
path: '',
|
|
295
|
+
message: 'Metadata document must be a JSON object.',
|
|
296
|
+
severity: 'error',
|
|
297
|
+
});
|
|
298
|
+
}
|
|
299
|
+
const moduleMetadata = document?.moduleMetadata;
|
|
300
|
+
if (!moduleMetadata || typeof moduleMetadata !== 'object' || Array.isArray(moduleMetadata)) {
|
|
301
|
+
issues.push({
|
|
302
|
+
path: 'moduleMetadata',
|
|
303
|
+
message: 'moduleMetadata must be present as an object.',
|
|
304
|
+
severity: 'error',
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
if (moduleMetadata && !Array.isArray(moduleMetadata.models)) {
|
|
308
|
+
issues.push({
|
|
309
|
+
path: 'moduleMetadata.models',
|
|
310
|
+
message: 'moduleMetadata.models must be an array.',
|
|
311
|
+
severity: 'error',
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
for (const definition of SECTION_DEFINITIONS) {
|
|
315
|
+
const sectionValue = this.getValueAtPath(document, definition.jsonPath);
|
|
316
|
+
const sectionValidation = this.validateSectionValue(definition, sectionValue, true);
|
|
317
|
+
issues.push(...sectionValidation.issues);
|
|
318
|
+
}
|
|
319
|
+
return {
|
|
320
|
+
valid: issues.every((issue) => issue.severity !== 'error'),
|
|
321
|
+
issues,
|
|
322
|
+
};
|
|
323
|
+
}
|
|
324
|
+
validateSectionValue(definition, value, allowUndefined = false) {
|
|
325
|
+
const issues = [];
|
|
326
|
+
if (value === undefined) {
|
|
327
|
+
if (!allowUndefined) {
|
|
328
|
+
issues.push({
|
|
329
|
+
path: definition.jsonPath,
|
|
330
|
+
message: `${definition.title} is missing from the metadata document.`,
|
|
331
|
+
severity: 'error',
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
return {
|
|
335
|
+
valid: issues.every((issue) => issue.severity !== 'error'),
|
|
336
|
+
issues,
|
|
337
|
+
};
|
|
338
|
+
}
|
|
339
|
+
const isArray = Array.isArray(value);
|
|
340
|
+
if (definition.type === 'array' && !isArray) {
|
|
341
|
+
issues.push({
|
|
342
|
+
path: definition.jsonPath,
|
|
343
|
+
message: `${definition.title} must be an array.`,
|
|
344
|
+
severity: 'error',
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
if (definition.type === 'object' && (value === null || typeof value !== 'object' || isArray)) {
|
|
348
|
+
issues.push({
|
|
349
|
+
path: definition.jsonPath,
|
|
350
|
+
message: `${definition.title} must be an object.`,
|
|
351
|
+
severity: 'error',
|
|
352
|
+
});
|
|
353
|
+
}
|
|
354
|
+
return {
|
|
355
|
+
valid: issues.every((issue) => issue.severity !== 'error'),
|
|
356
|
+
issues,
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
getValueAtPath(source, jsonPath) {
|
|
360
|
+
if (!jsonPath)
|
|
361
|
+
return source;
|
|
362
|
+
return jsonPath.split('.').reduce((acc, key) => (acc == null ? undefined : acc[key]), source);
|
|
363
|
+
}
|
|
364
|
+
setValueAtPath(target, jsonPath, value) {
|
|
365
|
+
const parts = jsonPath.split('.');
|
|
366
|
+
let current = target;
|
|
367
|
+
for (let index = 0; index < parts.length - 1; index++) {
|
|
368
|
+
const part = parts[index];
|
|
369
|
+
if (!current[part] || typeof current[part] !== 'object' || Array.isArray(current[part])) {
|
|
370
|
+
current[part] = {};
|
|
371
|
+
}
|
|
372
|
+
current = current[part];
|
|
373
|
+
}
|
|
374
|
+
current[parts[parts.length - 1]] = value;
|
|
375
|
+
}
|
|
376
|
+
countNodes(value) {
|
|
377
|
+
if (value === undefined || value === null)
|
|
378
|
+
return 0;
|
|
379
|
+
if (Array.isArray(value)) {
|
|
380
|
+
return value.reduce((sum, item) => sum + this.countNodes(item), 1);
|
|
381
|
+
}
|
|
382
|
+
if (typeof value === 'object') {
|
|
383
|
+
return Object.values(value).reduce((sum, item) => sum + this.countNodes(item), 1);
|
|
384
|
+
}
|
|
385
|
+
return 1;
|
|
386
|
+
}
|
|
387
|
+
buildPreview(value, maxLength) {
|
|
388
|
+
if (value === undefined)
|
|
389
|
+
return '';
|
|
390
|
+
const normalized = typeof value === 'string'
|
|
391
|
+
? value
|
|
392
|
+
: JSON.stringify(value);
|
|
393
|
+
if (!normalized)
|
|
394
|
+
return '';
|
|
395
|
+
return normalized.length > maxLength ? `${normalized.slice(0, maxLength)}...` : normalized;
|
|
396
|
+
}
|
|
397
|
+
collectMatches(root, rootPath, opts) {
|
|
398
|
+
const results = [];
|
|
399
|
+
const normalizedNeedle = opts.exact ? opts.needle : opts.needle.toLowerCase();
|
|
400
|
+
const visit = (value, currentPath) => {
|
|
401
|
+
if (value === undefined)
|
|
402
|
+
return;
|
|
403
|
+
if (Array.isArray(value)) {
|
|
404
|
+
value.forEach((item, index) => {
|
|
405
|
+
visit(item, this.joinPath(currentPath, `${index}`));
|
|
406
|
+
});
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (value && typeof value === 'object') {
|
|
410
|
+
Object.entries(value).forEach(([key, child]) => {
|
|
411
|
+
const childPath = this.joinPath(currentPath, key);
|
|
412
|
+
if (opts.matchKeys && this.matchesNeedle(key, normalizedNeedle, opts.exact) && childPath !== opts.excludePath) {
|
|
413
|
+
results.push({
|
|
414
|
+
path: childPath,
|
|
415
|
+
sectionKey: this.resolveSectionKey(childPath),
|
|
416
|
+
matchType: 'key',
|
|
417
|
+
valueType: 'key',
|
|
418
|
+
preview: this.buildPreview(child, opts.previewLength),
|
|
419
|
+
});
|
|
420
|
+
}
|
|
421
|
+
visit(child, childPath);
|
|
422
|
+
});
|
|
423
|
+
return;
|
|
424
|
+
}
|
|
425
|
+
if (!opts.matchValues)
|
|
426
|
+
return;
|
|
427
|
+
const comparable = value == null ? '' : `${value}`;
|
|
428
|
+
if (this.matchesNeedle(comparable, normalizedNeedle, opts.exact) && currentPath !== opts.excludePath) {
|
|
429
|
+
results.push({
|
|
430
|
+
path: currentPath,
|
|
431
|
+
sectionKey: this.resolveSectionKey(currentPath),
|
|
432
|
+
matchType: 'value',
|
|
433
|
+
valueType: typeof value,
|
|
434
|
+
preview: this.buildPreview(value, opts.previewLength),
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
};
|
|
438
|
+
visit(root, rootPath);
|
|
439
|
+
return {
|
|
440
|
+
total: results.length,
|
|
441
|
+
items: results.slice(opts.offset, opts.offset + opts.limit),
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
matchesNeedle(value, normalizedNeedle, exact) {
|
|
445
|
+
if (exact) {
|
|
446
|
+
return value === normalizedNeedle;
|
|
447
|
+
}
|
|
448
|
+
return value.toLowerCase().includes(normalizedNeedle);
|
|
449
|
+
}
|
|
450
|
+
resolveSectionKey(jsonPath) {
|
|
451
|
+
const sorted = [...SECTION_DEFINITIONS].sort((a, b) => b.jsonPath.length - a.jsonPath.length);
|
|
452
|
+
const matched = sorted.find((section) => jsonPath === section.jsonPath
|
|
453
|
+
|| jsonPath.startsWith(`${section.jsonPath}.`)
|
|
454
|
+
|| jsonPath.startsWith(`${section.jsonPath}[`));
|
|
455
|
+
return matched?.key ?? null;
|
|
456
|
+
}
|
|
457
|
+
joinPath(base, next) {
|
|
458
|
+
if (!base)
|
|
459
|
+
return /^\d+$/.test(next) ? `[${next}]` : next;
|
|
460
|
+
return /^\d+$/.test(next) ? `${base}[${next}]` : `${base}.${next}`;
|
|
461
|
+
}
|
|
462
|
+
assertValueProvided(value) {
|
|
463
|
+
if (value === undefined) {
|
|
464
|
+
throw new common_1.BadRequestException('A JSON value payload is required.');
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
};
|
|
468
|
+
exports.ModuleMetadataExplorerService = ModuleMetadataExplorerService;
|
|
469
|
+
__decorate([
|
|
470
|
+
(0, disallow_in_production_decorator_1.DisallowInProduction)(),
|
|
471
|
+
__metadata("design:type", Function),
|
|
472
|
+
__metadata("design:paramtypes", [String, metadata_explorer_write_dto_1.MetadataExplorerWriteDto]),
|
|
473
|
+
__metadata("design:returntype", Promise)
|
|
474
|
+
], ModuleMetadataExplorerService.prototype, "updateDocument", null);
|
|
475
|
+
__decorate([
|
|
476
|
+
(0, disallow_in_production_decorator_1.DisallowInProduction)(),
|
|
477
|
+
__metadata("design:type", Function),
|
|
478
|
+
__metadata("design:paramtypes", [String, String, metadata_explorer_write_dto_1.MetadataExplorerWriteDto]),
|
|
479
|
+
__metadata("design:returntype", Promise)
|
|
480
|
+
], ModuleMetadataExplorerService.prototype, "updateSection", null);
|
|
481
|
+
exports.ModuleMetadataExplorerService = ModuleMetadataExplorerService = ModuleMetadataExplorerService_1 = __decorate([
|
|
482
|
+
(0, common_1.Injectable)(),
|
|
483
|
+
__metadata("design:paramtypes", [module_metadata_helper_service_1.ModuleMetadataHelperService])
|
|
484
|
+
], ModuleMetadataExplorerService);
|
|
485
|
+
//# sourceMappingURL=module-metadata-explorer.service.js.map
|