@hamak/smart-data-dico 1.0.3 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/backend/dist/server.mjs +82212 -0
- package/bin/cli.js +28 -17
- package/frontend/dist/assets/index-1b53cffe.js +431 -0
- package/frontend/dist/assets/index-fa72a51a.css +1 -0
- package/frontend/dist/index.html +15 -0
- package/package.json +28 -27
- package/backend/package.json +0 -51
- package/backend/src/__tests__/integration/api.test.ts +0 -149
- package/backend/src/__tests__/setup.ts +0 -24
- package/backend/src/__tests__/utils/testUtils.ts +0 -76
- package/backend/src/adapters/EntityFileAdapter.ts +0 -154
- package/backend/src/adapters/YamlFileInfoEnricher.ts +0 -52
- package/backend/src/controllers/authController.ts +0 -131
- package/backend/src/controllers/diagramController.ts +0 -143
- package/backend/src/controllers/dictionaryController.ts +0 -306
- package/backend/src/controllers/importExportController.ts +0 -64
- package/backend/src/controllers/perspectiveController.ts +0 -90
- package/backend/src/controllers/serviceController.ts +0 -418
- package/backend/src/controllers/stereotypeController.ts +0 -59
- package/backend/src/controllers/versionController.ts +0 -226
- package/backend/src/kernel/config.ts +0 -43
- package/backend/src/middleware/auth.ts +0 -128
- package/backend/src/middleware/jwtAuth.ts +0 -100
- package/backend/src/models/Dictionary.ts +0 -38
- package/backend/src/models/EntitySchema.ts +0 -393
- package/backend/src/models/__tests__/Dictionary.test.ts +0 -92
- package/backend/src/models/__tests__/EntitySchema.test.ts +0 -119
- package/backend/src/routes/index.ts +0 -120
- package/backend/src/scripts/migrate-to-uuid.ts +0 -24
- package/backend/src/server.ts +0 -158
- package/backend/src/services/__mocks__/entityService.ts +0 -38
- package/backend/src/services/__mocks__/serviceService.ts +0 -88
- package/backend/src/services/__mocks__/versionService.ts +0 -38
- package/backend/src/services/__tests__/dictionaryService.test.ts +0 -74
- package/backend/src/services/diagramService.ts +0 -165
- package/backend/src/services/dictionaryService.ts +0 -582
- package/backend/src/services/entityService.ts +0 -102
- package/backend/src/services/exportService.ts +0 -172
- package/backend/src/services/importService.ts +0 -208
- package/backend/src/services/perspectiveService.ts +0 -276
- package/backend/src/services/qualityService.ts +0 -121
- package/backend/src/services/serviceService.ts +0 -763
- package/backend/src/services/stereotypeService.ts +0 -98
- package/backend/src/services/versionService.ts +0 -135
- package/backend/src/setupTests.ts +0 -12
- package/backend/src/utils/__mocks__/fileOperations.ts +0 -116
- package/backend/src/utils/fileOperations.ts +0 -602
- package/backend/src/utils/logger.ts +0 -38
- package/backend/src/utils/migration.ts +0 -254
- package/backend/src/utils/swagger.ts +0 -358
- package/backend/src/utils/uuid.ts +0 -41
- package/backend/tsconfig.json +0 -20
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
|
|
3
|
-
import { Dictionary } from '../models/Dictionary.js';
|
|
4
|
-
import { Entity } from '../models/EntitySchema.js';
|
|
5
|
-
import { dictionaryService } from '../services/dictionaryService.js';
|
|
6
|
-
import { entityService } from '../services/entityService.js';
|
|
7
|
-
import { logger } from '../utils/logger.js';
|
|
8
|
-
|
|
9
|
-
// Dictionary controller methods
|
|
10
|
-
export const getDictionaries = async (req: Request, res: Response) => {
|
|
11
|
-
try {
|
|
12
|
-
const dictionaries = await dictionaryService.getAllDictionaries();
|
|
13
|
-
res.json({
|
|
14
|
-
message: 'Success',
|
|
15
|
-
data: dictionaries
|
|
16
|
-
});
|
|
17
|
-
} catch (error) {
|
|
18
|
-
logger.error('Error fetching dictionaries', error);
|
|
19
|
-
res.status(500).json({ message: 'Error fetching dictionaries', error });
|
|
20
|
-
}
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
export const getDictionaryById = async (req: Request, res: Response) => {
|
|
24
|
-
try {
|
|
25
|
-
const { id } = req.params;
|
|
26
|
-
const dictionary = await dictionaryService.getDictionaryById(id);
|
|
27
|
-
|
|
28
|
-
if (!dictionary) {
|
|
29
|
-
return res.status(404).json({ message: 'Dictionary not found' });
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
res.json({
|
|
33
|
-
message: 'Success',
|
|
34
|
-
data: dictionary
|
|
35
|
-
});
|
|
36
|
-
} catch (error) {
|
|
37
|
-
logger.error(`Error fetching dictionary with ID: ${req.params.id}`, error);
|
|
38
|
-
res.status(500).json({ message: 'Error fetching dictionary', error });
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const getDictionaryEntries = async (req: Request, res: Response) => {
|
|
43
|
-
try {
|
|
44
|
-
const { id } = req.params;
|
|
45
|
-
const entries = await dictionaryService.getDictionaryEntries(id);
|
|
46
|
-
|
|
47
|
-
res.json({
|
|
48
|
-
message: 'Success',
|
|
49
|
-
data: entries
|
|
50
|
-
});
|
|
51
|
-
} catch (error) {
|
|
52
|
-
logger.error(`Error in getDictionaryEntries: ${error}`);
|
|
53
|
-
res.status(500).json({ message: 'Error fetching dictionary entries', error });
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
export const getEntityAttributes = async (req: Request, res: Response) => {
|
|
58
|
-
try {
|
|
59
|
-
const { microservice, entityName } = req.params;
|
|
60
|
-
const attributes = await dictionaryService.getEntityAttributes(microservice, entityName);
|
|
61
|
-
|
|
62
|
-
if (attributes.length === 0) {
|
|
63
|
-
return res.status(404).json({ message: 'Entity not found' });
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
res.json({
|
|
67
|
-
message: 'Success',
|
|
68
|
-
data: attributes
|
|
69
|
-
});
|
|
70
|
-
} catch (error) {
|
|
71
|
-
logger.error(`Error in getEntityAttributes: ${error}`);
|
|
72
|
-
res.status(500).json({ message: 'Error fetching entity attributes', error });
|
|
73
|
-
}
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
export const saveEntity = async (req: Request, res: Response) => {
|
|
77
|
-
try {
|
|
78
|
-
const entity = req.body as Entity;
|
|
79
|
-
const packageName = req.body.packageName || req.query.packageName as string;
|
|
80
|
-
|
|
81
|
-
if (!entity) {
|
|
82
|
-
return res.status(400).json({ message: 'Invalid entity data' });
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
if (!packageName) {
|
|
86
|
-
return res.status(400).json({ message: 'packageName is required' });
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
const result = await entityService.saveEntity(entity, packageName);
|
|
90
|
-
|
|
91
|
-
if (!result.success) {
|
|
92
|
-
return res.status(400).json({
|
|
93
|
-
message: 'Failed to save entity',
|
|
94
|
-
errors: result.errors
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
res.status(200).json({
|
|
99
|
-
message: 'Entity saved successfully',
|
|
100
|
-
data: entity
|
|
101
|
-
});
|
|
102
|
-
} catch (error) {
|
|
103
|
-
logger.error(`Error in saveEntity: ${error}`);
|
|
104
|
-
res.status(500).json({ message: 'Error saving entity', error });
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
|
|
108
|
-
export const getRelatedEntities = async (req: Request, res: Response) => {
|
|
109
|
-
try {
|
|
110
|
-
const { microservice, entityName } = req.params;
|
|
111
|
-
const relatedEntities = await entityService.getRelatedEntities(microservice, entityName);
|
|
112
|
-
|
|
113
|
-
res.json({
|
|
114
|
-
message: 'Success',
|
|
115
|
-
data: relatedEntities
|
|
116
|
-
});
|
|
117
|
-
} catch (error) {
|
|
118
|
-
logger.error(`Error in getRelatedEntities: ${error}`);
|
|
119
|
-
res.status(500).json({ message: 'Error fetching related entities', error });
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
|
|
123
|
-
export const createDictionary = async (req: Request, res: Response) => {
|
|
124
|
-
try {
|
|
125
|
-
const dictionaryData = req.body as Dictionary;
|
|
126
|
-
|
|
127
|
-
if (!dictionaryData || !dictionaryData.name) {
|
|
128
|
-
return res.status(400).json({ message: 'Dictionary name is required' });
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const result = await dictionaryService.createDictionary(dictionaryData);
|
|
132
|
-
|
|
133
|
-
if (result && 'error' in result) {
|
|
134
|
-
if (result.code === 'DUPLICATE_NAME') {
|
|
135
|
-
logger.warn(`Attempted to create dictionary with duplicate name: ${dictionaryData.name}`);
|
|
136
|
-
return res.status(409).json({
|
|
137
|
-
message: result.error,
|
|
138
|
-
code: result.code
|
|
139
|
-
});
|
|
140
|
-
} else if (result.code === 'MISSING_NAME') {
|
|
141
|
-
return res.status(400).json({
|
|
142
|
-
message: result.error,
|
|
143
|
-
code: result.code
|
|
144
|
-
});
|
|
145
|
-
} else {
|
|
146
|
-
return res.status(400).json({
|
|
147
|
-
message: result.error,
|
|
148
|
-
code: result.code
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
if (!result) {
|
|
154
|
-
return res.status(500).json({ message: 'Failed to create dictionary due to an unknown error' });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
res.status(201).json({
|
|
158
|
-
message: 'Dictionary created successfully',
|
|
159
|
-
data: result
|
|
160
|
-
});
|
|
161
|
-
} catch (error) {
|
|
162
|
-
logger.error(`Error in createDictionary: ${error}`);
|
|
163
|
-
res.status(500).json({ message: 'Error creating dictionary', error });
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
|
|
167
|
-
export const getPackageHierarchy = async (req: Request, res: Response) => {
|
|
168
|
-
try {
|
|
169
|
-
const { rootPackage } = req.params;
|
|
170
|
-
const hierarchy = await dictionaryService.getPackageHierarchy(rootPackage);
|
|
171
|
-
res.json({ message: 'Success', data: hierarchy });
|
|
172
|
-
} catch (error) {
|
|
173
|
-
logger.error('Error fetching package hierarchy', error);
|
|
174
|
-
res.status(500).json({ message: 'Error fetching package hierarchy', error });
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export const getTabularData = async (req: Request, res: Response) => {
|
|
179
|
-
try {
|
|
180
|
-
const { rootPackage } = req.params;
|
|
181
|
-
const tabularData = await dictionaryService.getTabularData(rootPackage);
|
|
182
|
-
res.json({ message: 'Success', data: tabularData });
|
|
183
|
-
} catch (error) {
|
|
184
|
-
logger.error('Error fetching tabular data', error);
|
|
185
|
-
res.status(500).json({ message: 'Error fetching tabular data', error });
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
export const getPackageByPath = async (req: Request, res: Response) => {
|
|
190
|
-
try {
|
|
191
|
-
const { rootPackage } = req.params;
|
|
192
|
-
const packagePath = req.params[0]?.split('/').filter(Boolean) || [];
|
|
193
|
-
const pkg = await dictionaryService.getPackageByPath(rootPackage, packagePath);
|
|
194
|
-
if (!pkg) {
|
|
195
|
-
return res.status(404).json({ message: 'Package not found' });
|
|
196
|
-
}
|
|
197
|
-
res.json({ message: 'Success', data: pkg });
|
|
198
|
-
} catch (error) {
|
|
199
|
-
logger.error('Error fetching package by path', error);
|
|
200
|
-
res.status(500).json({ message: 'Error fetching package by path', error });
|
|
201
|
-
}
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
export const listAllPackagesAndEntities = async (req: Request, res: Response) => {
|
|
205
|
-
try {
|
|
206
|
-
const result = await dictionaryService.listAllPackagesAndEntities();
|
|
207
|
-
res.json({ message: 'Success', data: result });
|
|
208
|
-
} catch (error) {
|
|
209
|
-
logger.error('Error listing all packages and entities', error);
|
|
210
|
-
res.status(500).json({ message: 'Error listing all packages and entities', error });
|
|
211
|
-
}
|
|
212
|
-
};
|
|
213
|
-
|
|
214
|
-
export const createPackageAtPath = async (req: Request, res: Response) => {
|
|
215
|
-
try {
|
|
216
|
-
const { rootPackage } = req.params;
|
|
217
|
-
const packagePath = req.params[0]?.split('/').filter(Boolean) || [];
|
|
218
|
-
const packageData = req.body;
|
|
219
|
-
const result = await dictionaryService.createPackageAtPath(rootPackage, packagePath, packageData);
|
|
220
|
-
if (!result.success) {
|
|
221
|
-
return res.status(400).json({ message: 'Failed to create package', errors: result.errors });
|
|
222
|
-
}
|
|
223
|
-
res.status(201).json({ message: 'Package created successfully', data: result.package });
|
|
224
|
-
} catch (error) {
|
|
225
|
-
logger.error('Error creating package', error);
|
|
226
|
-
res.status(500).json({ message: 'Error creating package', error });
|
|
227
|
-
}
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export const updatePackageAtPath = async (req: Request, res: Response) => {
|
|
231
|
-
try {
|
|
232
|
-
const { rootPackage } = req.params;
|
|
233
|
-
const packagePath = req.params[0]?.split('/').filter(Boolean) || [];
|
|
234
|
-
const packageData = req.body;
|
|
235
|
-
const result = await dictionaryService.updatePackageAtPath(rootPackage, packagePath, packageData);
|
|
236
|
-
if (!result.success) {
|
|
237
|
-
return res.status(400).json({ message: 'Failed to update package', errors: result.errors });
|
|
238
|
-
}
|
|
239
|
-
res.status(200).json({ message: 'Package updated successfully', data: result.package });
|
|
240
|
-
} catch (error) {
|
|
241
|
-
logger.error('Error updating package', error);
|
|
242
|
-
res.status(500).json({ message: 'Error updating package', error });
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
export const createRootPackage = async (req: Request, res: Response) => {
|
|
247
|
-
try {
|
|
248
|
-
const { name, description, type, metadata } = req.body;
|
|
249
|
-
if (!name) {
|
|
250
|
-
return res.status(400).json({ message: 'Package name is required' });
|
|
251
|
-
}
|
|
252
|
-
const result = await dictionaryService.createPackageAtPath(name, [], { name, description, type, metadata });
|
|
253
|
-
if (!result.success) {
|
|
254
|
-
return res.status(400).json({ message: 'Failed to create package', errors: result.errors });
|
|
255
|
-
}
|
|
256
|
-
res.status(201).json({ message: 'Package created successfully', data: result.package });
|
|
257
|
-
} catch (error) {
|
|
258
|
-
logger.error('Error creating root package', error);
|
|
259
|
-
res.status(500).json({ message: 'Error creating package', error });
|
|
260
|
-
}
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
export const deletePackageAtPath = async (req: Request, res: Response) => {
|
|
264
|
-
try {
|
|
265
|
-
const { rootPackage } = req.params;
|
|
266
|
-
const packagePath = req.params[0]?.split('/').filter(Boolean) || [];
|
|
267
|
-
const force = req.query.force === 'true';
|
|
268
|
-
const result = await dictionaryService.deletePackageAtPath(rootPackage, packagePath, force);
|
|
269
|
-
if (!result.success) {
|
|
270
|
-
return res.status(400).json({ message: 'Failed to delete package', errors: result.errors });
|
|
271
|
-
}
|
|
272
|
-
res.status(200).json({ message: 'Package deleted successfully' });
|
|
273
|
-
} catch (error) {
|
|
274
|
-
logger.error('Error deleting package', error);
|
|
275
|
-
res.status(500).json({ message: 'Error deleting package', error });
|
|
276
|
-
}
|
|
277
|
-
};
|
|
278
|
-
|
|
279
|
-
export const getFlatEntitiesAndAttributes = async (req: Request, res: Response) => {
|
|
280
|
-
try {
|
|
281
|
-
const { name, type, package: pkg } = req.query;
|
|
282
|
-
const filters: any = {};
|
|
283
|
-
if (name) filters.name = String(name);
|
|
284
|
-
if (type) filters.type = String(type);
|
|
285
|
-
if (pkg) filters.package = String(pkg);
|
|
286
|
-
const result = await dictionaryService.getFlatEntitiesAndAttributes(filters);
|
|
287
|
-
res.json({ message: 'Success', data: result });
|
|
288
|
-
} catch (error) {
|
|
289
|
-
logger.error('Error getting flat entities/attributes', error);
|
|
290
|
-
res.status(500).json({ message: 'Error getting flat entities/attributes', error });
|
|
291
|
-
}
|
|
292
|
-
};
|
|
293
|
-
|
|
294
|
-
export const getEntityHierarchy = async (req: Request, res: Response) => {
|
|
295
|
-
try {
|
|
296
|
-
const { microservice, entityName } = req.params;
|
|
297
|
-
const result = await dictionaryService.getEntityHierarchy(microservice, entityName);
|
|
298
|
-
if (!result) {
|
|
299
|
-
return res.status(404).json({ message: 'Entity not found' });
|
|
300
|
-
}
|
|
301
|
-
res.json({ message: 'Success', data: result });
|
|
302
|
-
} catch (error) {
|
|
303
|
-
logger.error('Error getting entity hierarchy', error);
|
|
304
|
-
res.status(500).json({ message: 'Error getting entity hierarchy', error });
|
|
305
|
-
}
|
|
306
|
-
};
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
import { importService } from '../services/importService.js';
|
|
3
|
-
import { exportService } from '../services/exportService.js';
|
|
4
|
-
import { qualityService } from '../services/qualityService.js';
|
|
5
|
-
import { logger } from '../utils/logger.js';
|
|
6
|
-
|
|
7
|
-
export const importJsonSchema = async (req: Request, res: Response) => {
|
|
8
|
-
try {
|
|
9
|
-
const { schema, service } = req.body;
|
|
10
|
-
if (!schema || !service) return res.status(400).json({ message: 'schema and service are required' });
|
|
11
|
-
const result = await importService.importFromJsonSchema(schema, service);
|
|
12
|
-
res.json({ message: `Imported ${result.entities.length} entities`, data: result });
|
|
13
|
-
} catch (error) {
|
|
14
|
-
logger.error('Error importing JSON Schema', error);
|
|
15
|
-
res.status(500).json({ message: 'Error importing JSON Schema', error });
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const importSqlDdl = async (req: Request, res: Response) => {
|
|
20
|
-
try {
|
|
21
|
-
const { sql, service } = req.body;
|
|
22
|
-
if (!sql || !service) return res.status(400).json({ message: 'sql and service are required' });
|
|
23
|
-
const result = await importService.importFromSqlDdl(sql, service);
|
|
24
|
-
res.json({ message: `Imported ${result.entities.length} entities`, data: result });
|
|
25
|
-
} catch (error) {
|
|
26
|
-
logger.error('Error importing SQL DDL', error);
|
|
27
|
-
res.status(500).json({ message: 'Error importing SQL DDL', error });
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export const exportJsonSchema = async (req: Request, res: Response) => {
|
|
32
|
-
try {
|
|
33
|
-
const { service } = req.params;
|
|
34
|
-
const schema = await exportService.exportToJsonSchema(service);
|
|
35
|
-
res.json(schema);
|
|
36
|
-
} catch (error) {
|
|
37
|
-
logger.error('Error exporting JSON Schema', error);
|
|
38
|
-
res.status(500).json({ message: 'Error exporting JSON Schema', error });
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
export const exportMarkdown = async (req: Request, res: Response) => {
|
|
43
|
-
try {
|
|
44
|
-
const { service } = req.params;
|
|
45
|
-
const markdown = await exportService.exportToMarkdown(service);
|
|
46
|
-
res.setHeader('Content-Type', 'text/markdown');
|
|
47
|
-
res.setHeader('Content-Disposition', `attachment; filename="${service}-data-dictionary.md"`);
|
|
48
|
-
res.send(markdown);
|
|
49
|
-
} catch (error) {
|
|
50
|
-
logger.error('Error exporting Markdown', error);
|
|
51
|
-
res.status(500).json({ message: 'Error exporting Markdown', error });
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export const getQualityReport = async (req: Request, res: Response) => {
|
|
56
|
-
try {
|
|
57
|
-
const service = req.query.service as string | undefined;
|
|
58
|
-
const report = await qualityService.getQualityReport(service);
|
|
59
|
-
res.json({ message: 'Success', data: report });
|
|
60
|
-
} catch (error) {
|
|
61
|
-
logger.error('Error getting quality report', error);
|
|
62
|
-
res.status(500).json({ message: 'Error getting quality report', error });
|
|
63
|
-
}
|
|
64
|
-
};
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import { Request, Response } from 'express';
|
|
2
|
-
import { perspectiveService } from '../services/perspectiveService.js';
|
|
3
|
-
import { logger } from '../utils/logger.js';
|
|
4
|
-
|
|
5
|
-
export const getAllPerspectives = async (_req: Request, res: Response) => {
|
|
6
|
-
try {
|
|
7
|
-
const perspectives = await perspectiveService.getAll();
|
|
8
|
-
res.json({ message: 'Success', data: perspectives });
|
|
9
|
-
} catch (error) {
|
|
10
|
-
logger.error('Error fetching perspectives', error);
|
|
11
|
-
res.status(500).json({ message: 'Error fetching perspectives', error });
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export const getPerspective = async (req: Request, res: Response) => {
|
|
16
|
-
try {
|
|
17
|
-
const perspective = await perspectiveService.getById(req.params.id);
|
|
18
|
-
if (!perspective) return res.status(404).json({ message: 'Perspective not found' });
|
|
19
|
-
res.json({ message: 'Success', data: perspective });
|
|
20
|
-
} catch (error) {
|
|
21
|
-
logger.error('Error fetching perspective', error);
|
|
22
|
-
res.status(500).json({ message: 'Error fetching perspective', error });
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
export const createPerspective = async (req: Request, res: Response) => {
|
|
27
|
-
try {
|
|
28
|
-
const result = await perspectiveService.create(req.body);
|
|
29
|
-
if (!result.success) return res.status(400).json({ message: 'Failed to create perspective', errors: result.errors });
|
|
30
|
-
res.status(201).json({ message: 'Perspective created successfully', data: result.perspective });
|
|
31
|
-
} catch (error) {
|
|
32
|
-
logger.error('Error creating perspective', error);
|
|
33
|
-
res.status(500).json({ message: 'Error creating perspective', error });
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export const updatePerspective = async (req: Request, res: Response) => {
|
|
38
|
-
try {
|
|
39
|
-
const result = await perspectiveService.update(req.params.id, req.body);
|
|
40
|
-
if (!result.success) return res.status(400).json({ message: 'Failed to update perspective', errors: result.errors });
|
|
41
|
-
res.json({ message: 'Perspective updated successfully', data: result.perspective });
|
|
42
|
-
} catch (error) {
|
|
43
|
-
logger.error('Error updating perspective', error);
|
|
44
|
-
res.status(500).json({ message: 'Error updating perspective', error });
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const deletePerspective = async (req: Request, res: Response) => {
|
|
49
|
-
try {
|
|
50
|
-
const result = await perspectiveService.delete(req.params.id);
|
|
51
|
-
if (!result.success) return res.status(400).json({ message: 'Failed to delete perspective', errors: result.errors });
|
|
52
|
-
res.json({ message: 'Perspective deleted successfully' });
|
|
53
|
-
} catch (error) {
|
|
54
|
-
logger.error('Error deleting perspective', error);
|
|
55
|
-
res.status(500).json({ message: 'Error deleting perspective', error });
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const resolvePerspective = async (req: Request, res: Response) => {
|
|
60
|
-
try {
|
|
61
|
-
const resolved = await perspectiveService.resolve(req.params.id);
|
|
62
|
-
if (!resolved) return res.status(404).json({ message: 'Perspective not found' });
|
|
63
|
-
res.json({ message: 'Success', data: resolved });
|
|
64
|
-
} catch (error) {
|
|
65
|
-
logger.error('Error resolving perspective', error);
|
|
66
|
-
res.status(500).json({ message: 'Error resolving perspective', error });
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
|
|
70
|
-
export const getPerspectiveGraph = async (req: Request, res: Response) => {
|
|
71
|
-
try {
|
|
72
|
-
const graph = await perspectiveService.getGraphData(req.params.id);
|
|
73
|
-
if (!graph) return res.status(404).json({ message: 'Perspective not found' });
|
|
74
|
-
res.json({ message: 'Success', data: graph });
|
|
75
|
-
} catch (error) {
|
|
76
|
-
logger.error('Error getting perspective graph', error);
|
|
77
|
-
res.status(500).json({ message: 'Error getting perspective graph', error });
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
|
|
81
|
-
export const upsertPerspectiveNode = async (req: Request, res: Response) => {
|
|
82
|
-
try {
|
|
83
|
-
const result = await perspectiveService.upsertNode(req.params.id, req.body);
|
|
84
|
-
if (!result.success) return res.status(400).json({ message: 'Failed to update node', errors: result.errors });
|
|
85
|
-
res.json({ message: 'Node updated successfully' });
|
|
86
|
-
} catch (error) {
|
|
87
|
-
logger.error('Error updating perspective node', error);
|
|
88
|
-
res.status(500).json({ message: 'Error updating perspective node', error });
|
|
89
|
-
}
|
|
90
|
-
};
|