@dataparade/cli 0.0.21 → 0.0.23
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/package.json +1 -1
- package/dist/src/ai-enrichment/agent-orchestrator.d.ts +8 -2
- package/dist/src/ai-enrichment/agent-orchestrator.js +140 -70
- package/dist/src/ai-enrichment/provider-prompt.js +36 -2
- package/dist/src/core/pipeline/omit-internal-implementation.d.ts +34 -0
- package/dist/src/core/pipeline/omit-internal-implementation.js +146 -0
- package/dist/src/core/pipeline/scan-pipeline.js +21 -0
- package/dist/tests/unit/ai-enrichment/agent-orchestrator.spec.js +227 -147
- package/dist/tests/unit/ai-enrichment/provider-prompt.spec.js +35 -0
- package/dist/tests/unit/core/omit-internal-implementation.spec.d.ts +1 -0
- package/dist/tests/unit/core/omit-internal-implementation.spec.js +125 -0
- package/package.json +1 -1
|
@@ -37,6 +37,41 @@ describe('provider-prompt', () => {
|
|
|
37
37
|
expect(slim.sparsePropertyKeys).not.toContain('inference_status');
|
|
38
38
|
expect(slim.sparsePropertyKeys[0]).toBe('encrypt_at_rest');
|
|
39
39
|
});
|
|
40
|
+
it('slimComponentForLlm drops scanner evidence and caps oversized set values', () => {
|
|
41
|
+
const evidence = Array.from({ length: 2_000 }, (_, i) => ({
|
|
42
|
+
filePath: `backend/src/entities/e${i}.ts`,
|
|
43
|
+
startLine: i,
|
|
44
|
+
endLine: i,
|
|
45
|
+
reason: 'property.patterns.yaml:database_connection',
|
|
46
|
+
}));
|
|
47
|
+
const c = {
|
|
48
|
+
id: 'cmp_orm',
|
|
49
|
+
name: 'Typeorm',
|
|
50
|
+
type: 'asset',
|
|
51
|
+
confidence: 0.9,
|
|
52
|
+
detectedFrom: [],
|
|
53
|
+
sourceLocations: [],
|
|
54
|
+
properties: {
|
|
55
|
+
propertyEvidence: { audit_logging_enabled: evidence },
|
|
56
|
+
dataActions: [
|
|
57
|
+
{ action: 'store', source: 'deterministic', evidence },
|
|
58
|
+
{ action: 'combine', source: 'deterministic', evidence },
|
|
59
|
+
{ action: 'store', source: 'deterministic', evidence },
|
|
60
|
+
],
|
|
61
|
+
data_categories: Array.from({ length: 2_000 }, (_, i) => `cat_${i}`),
|
|
62
|
+
vendor: null,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const slim = (0, provider_prompt_1.slimComponentForLlm)(c);
|
|
66
|
+
const propertiesSet = slim.propertiesSet;
|
|
67
|
+
expect(propertiesSet.propertyEvidence).toBeUndefined();
|
|
68
|
+
expect(slim.sparsePropertyKeys).not.toContain('propertyEvidence');
|
|
69
|
+
expect(propertiesSet.dataActions).toEqual(['store', 'combine']);
|
|
70
|
+
const categories = propertiesSet.data_categories;
|
|
71
|
+
expect(categories.length).toBeGreaterThan(0);
|
|
72
|
+
expect(categories.length).toBeLessThan(2_000);
|
|
73
|
+
expect(JSON.stringify(slim).length).toBeLessThan(10_000);
|
|
74
|
+
});
|
|
40
75
|
it('buildProviderPromptPayload includes componentContext for queued componentIds', () => {
|
|
41
76
|
const components = [
|
|
42
77
|
{
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const omit_internal_implementation_1 = require("../../../src/core/pipeline/omit-internal-implementation");
|
|
4
|
+
const nestSource = `
|
|
5
|
+
import { Injectable } from "@nestjs/common";
|
|
6
|
+
|
|
7
|
+
@Injectable()
|
|
8
|
+
export class AssetContextService {
|
|
9
|
+
findAll() {}
|
|
10
|
+
}
|
|
11
|
+
`;
|
|
12
|
+
const directusSource = `
|
|
13
|
+
export class UsersService extends ItemsService {
|
|
14
|
+
constructor() {
|
|
15
|
+
super("directus_users", {});
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
`;
|
|
19
|
+
describe('omitInternalImplementationNodes', () => {
|
|
20
|
+
const readSource = (filePath) => {
|
|
21
|
+
if (filePath.endsWith('asset-context.service.ts'))
|
|
22
|
+
return nestSource;
|
|
23
|
+
if (filePath.endsWith('users.ts'))
|
|
24
|
+
return directusSource;
|
|
25
|
+
return undefined;
|
|
26
|
+
};
|
|
27
|
+
it('drops NestJS service classes and bare HTTP clients, and keeps named services', () => {
|
|
28
|
+
const result = (0, omit_internal_implementation_1.omitInternalImplementationNodes)([
|
|
29
|
+
{
|
|
30
|
+
id: 'hub',
|
|
31
|
+
name: 'backend',
|
|
32
|
+
type: 'asset',
|
|
33
|
+
subType: 'application',
|
|
34
|
+
properties: { isMainApplication: true, section_id: 'backend' },
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
id: 'asset-context',
|
|
38
|
+
name: 'Assetcontext',
|
|
39
|
+
type: 'asset',
|
|
40
|
+
subType: 'service',
|
|
41
|
+
detectedFrom: [{ pattern: 'auth_middleware' }],
|
|
42
|
+
sourceLocations: [
|
|
43
|
+
{
|
|
44
|
+
filePath: 'backend/src/diagrams/services/asset-context.service.ts',
|
|
45
|
+
startLine: 5,
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
properties: { section_id: 'backend' },
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
id: 'users',
|
|
52
|
+
name: 'Users',
|
|
53
|
+
type: 'asset',
|
|
54
|
+
subType: 'service',
|
|
55
|
+
detectedFrom: [{ pattern: 'auth_middleware' }],
|
|
56
|
+
sourceLocations: [
|
|
57
|
+
{ filePath: 'api/src/services/users.ts', startLine: 2 },
|
|
58
|
+
],
|
|
59
|
+
properties: { section_id: 'backend' },
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
id: 'axios',
|
|
63
|
+
name: 'Axios Call',
|
|
64
|
+
type: 'asset',
|
|
65
|
+
subType: 'api',
|
|
66
|
+
properties: { client: 'axios', section_id: 'backend' },
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: 'sendgrid',
|
|
70
|
+
name: 'Sendgrid',
|
|
71
|
+
type: 'third_party',
|
|
72
|
+
properties: { serviceName: 'sendgrid', client: 'axios', section_id: 'backend' },
|
|
73
|
+
},
|
|
74
|
+
], [
|
|
75
|
+
{
|
|
76
|
+
id: 'flow-service',
|
|
77
|
+
sourceComponentId: 'hub',
|
|
78
|
+
targetComponentId: 'asset-context',
|
|
79
|
+
type: 'api_call',
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
id: 'flow-users',
|
|
83
|
+
sourceComponentId: 'hub',
|
|
84
|
+
targetComponentId: 'users',
|
|
85
|
+
type: 'api_call',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'flow-axios',
|
|
89
|
+
sourceComponentId: 'hub',
|
|
90
|
+
targetComponentId: 'axios',
|
|
91
|
+
type: 'api_call',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
id: 'flow-sendgrid',
|
|
95
|
+
sourceComponentId: 'axios',
|
|
96
|
+
targetComponentId: 'sendgrid',
|
|
97
|
+
type: 'api_call',
|
|
98
|
+
},
|
|
99
|
+
], { readSource });
|
|
100
|
+
expect(result.components.map((component) => component.name).sort()).toEqual([
|
|
101
|
+
'Sendgrid',
|
|
102
|
+
'Users',
|
|
103
|
+
'backend',
|
|
104
|
+
]);
|
|
105
|
+
expect(result.dataFlows.map((flow) => [flow.sourceComponentId, flow.targetComponentId])).toEqual([
|
|
106
|
+
['hub', 'users'],
|
|
107
|
+
['hub', 'sendgrid'],
|
|
108
|
+
]);
|
|
109
|
+
});
|
|
110
|
+
it('keeps a service class when its source file cannot be read', () => {
|
|
111
|
+
const result = (0, omit_internal_implementation_1.omitInternalImplementationNodes)([
|
|
112
|
+
{
|
|
113
|
+
id: 'svc',
|
|
114
|
+
name: 'Assetcontext',
|
|
115
|
+
type: 'asset',
|
|
116
|
+
subType: 'service',
|
|
117
|
+
detectedFrom: [{ pattern: 'auth_middleware' }],
|
|
118
|
+
sourceLocations: [
|
|
119
|
+
{ filePath: 'src/services/asset-context.service.ts', startLine: 1 },
|
|
120
|
+
],
|
|
121
|
+
},
|
|
122
|
+
], [], { readSource: () => undefined });
|
|
123
|
+
expect(result.components).toHaveLength(1);
|
|
124
|
+
});
|
|
125
|
+
});
|