@tracelens/shared 0.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/dist/__tests__/validation.test.d.ts +2 -0
- package/dist/__tests__/validation.test.d.ts.map +1 -0
- package/dist/__tests__/validation.test.js +16 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/schemas/dependency.schema.d.ts +177 -0
- package/dist/schemas/dependency.schema.d.ts.map +1 -0
- package/dist/schemas/dependency.schema.js +187 -0
- package/dist/schemas/error.schema.d.ts +170 -0
- package/dist/schemas/error.schema.d.ts.map +1 -0
- package/dist/schemas/error.schema.js +176 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.d.ts.map +1 -0
- package/dist/schemas/index.js +5 -0
- package/dist/schemas/performance.schema.d.ts +333 -0
- package/dist/schemas/performance.schema.d.ts.map +1 -0
- package/dist/schemas/performance.schema.js +200 -0
- package/dist/schemas/trace.schema.d.ts +325 -0
- package/dist/schemas/trace.schema.d.ts.map +1 -0
- package/dist/schemas/trace.schema.js +145 -0
- package/dist/types/dependency.types.d.ts +109 -0
- package/dist/types/dependency.types.d.ts.map +1 -0
- package/dist/types/dependency.types.js +8 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/performance.types.d.ts +95 -0
- package/dist/types/performance.types.d.ts.map +1 -0
- package/dist/types/performance.types.js +1 -0
- package/dist/types/security.types.d.ts +154 -0
- package/dist/types/security.types.d.ts.map +1 -0
- package/dist/types/security.types.js +8 -0
- package/dist/types/trace.types.d.ts +57 -0
- package/dist/types/trace.types.d.ts.map +1 -0
- package/dist/types/trace.types.js +20 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/validation.d.ts +21 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +157 -0
- package/jest.config.js +14 -0
- package/package.json +22 -0
- package/src/__tests__/validation.test.ts +19 -0
- package/src/index.d.ts.map +1 -0
- package/src/index.ts +4 -0
- package/src/schemas/dependency.schema.ts +187 -0
- package/src/schemas/error.schema.ts +176 -0
- package/src/schemas/index.ts +5 -0
- package/src/schemas/performance.schema.ts +200 -0
- package/src/schemas/trace.schema.ts +146 -0
- package/src/types/dependency.types.ts +120 -0
- package/src/types/index.d.ts.map +1 -0
- package/src/types/index.ts +11 -0
- package/src/types/performance.types.ts +108 -0
- package/src/types/security.types.ts +172 -0
- package/src/types/trace.types.ts +62 -0
- package/src/utils/index.d.ts.map +1 -0
- package/src/utils/index.ts +6 -0
- package/src/utils/validation.ts +209 -0
- package/tsconfig.json +9 -0
- package/tsconfig.tsbuildinfo +1 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
// Performance timing event schema for TraceLens
|
|
2
|
+
export const PerformanceEventSchema = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
required: ['id', 'timestamp', 'type', 'data', 'url', 'userAgent'],
|
|
5
|
+
properties: {
|
|
6
|
+
id: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
pattern: '^[a-zA-Z0-9_-]+$',
|
|
9
|
+
minLength: 1,
|
|
10
|
+
maxLength: 100
|
|
11
|
+
},
|
|
12
|
+
timestamp: {
|
|
13
|
+
type: 'number',
|
|
14
|
+
minimum: 1577836800000, // 2020-01-01
|
|
15
|
+
maximum: 2524608000000 // 2050-01-01
|
|
16
|
+
},
|
|
17
|
+
type: {
|
|
18
|
+
type: 'string',
|
|
19
|
+
enum: ['web-vitals', 'resource-timing', 'navigation-timing', 'long-task']
|
|
20
|
+
},
|
|
21
|
+
data: {
|
|
22
|
+
oneOf: [
|
|
23
|
+
{ $ref: '#/definitions/WebVitalsData' },
|
|
24
|
+
{ $ref: '#/definitions/ResourceTimingData' },
|
|
25
|
+
{ $ref: '#/definitions/NavigationTimingData' },
|
|
26
|
+
{ $ref: '#/definitions/LongTaskData' }
|
|
27
|
+
]
|
|
28
|
+
},
|
|
29
|
+
url: {
|
|
30
|
+
type: 'string',
|
|
31
|
+
format: 'uri',
|
|
32
|
+
maxLength: 2048
|
|
33
|
+
},
|
|
34
|
+
userAgent: {
|
|
35
|
+
type: 'string',
|
|
36
|
+
maxLength: 512
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
definitions: {
|
|
40
|
+
WebVitalsData: {
|
|
41
|
+
type: 'object',
|
|
42
|
+
properties: {
|
|
43
|
+
cls: { $ref: '#/definitions/CLSMetric' },
|
|
44
|
+
fid: { $ref: '#/definitions/FIDMetric' },
|
|
45
|
+
lcp: { $ref: '#/definitions/LCPMetric' },
|
|
46
|
+
fcp: { $ref: '#/definitions/FCPMetric' },
|
|
47
|
+
ttfb: { $ref: '#/definitions/TTFBMetric' },
|
|
48
|
+
inp: { $ref: '#/definitions/INPMetric' }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
BaseMetric: {
|
|
52
|
+
type: 'object',
|
|
53
|
+
required: ['name', 'value', 'rating', 'delta', 'id', 'navigationType'],
|
|
54
|
+
properties: {
|
|
55
|
+
name: { type: 'string' },
|
|
56
|
+
value: { type: 'number', minimum: 0 },
|
|
57
|
+
rating: {
|
|
58
|
+
type: 'string',
|
|
59
|
+
enum: ['good', 'needs-improvement', 'poor']
|
|
60
|
+
},
|
|
61
|
+
delta: { type: 'number' },
|
|
62
|
+
id: { type: 'string' },
|
|
63
|
+
navigationType: {
|
|
64
|
+
type: 'string',
|
|
65
|
+
enum: ['navigate', 'reload', 'back-forward', 'prerender']
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
CLSMetric: {
|
|
70
|
+
allOf: [
|
|
71
|
+
{ $ref: '#/definitions/BaseMetric' },
|
|
72
|
+
{
|
|
73
|
+
properties: {
|
|
74
|
+
name: { const: 'CLS' },
|
|
75
|
+
value: { maximum: 1 }
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
FIDMetric: {
|
|
81
|
+
allOf: [
|
|
82
|
+
{ $ref: '#/definitions/BaseMetric' },
|
|
83
|
+
{
|
|
84
|
+
properties: {
|
|
85
|
+
name: { const: 'FID' },
|
|
86
|
+
value: { maximum: 10000 }
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
]
|
|
90
|
+
},
|
|
91
|
+
LCPMetric: {
|
|
92
|
+
allOf: [
|
|
93
|
+
{ $ref: '#/definitions/BaseMetric' },
|
|
94
|
+
{
|
|
95
|
+
properties: {
|
|
96
|
+
name: { const: 'LCP' },
|
|
97
|
+
value: { maximum: 30000 }
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
]
|
|
101
|
+
},
|
|
102
|
+
FCPMetric: {
|
|
103
|
+
allOf: [
|
|
104
|
+
{ $ref: '#/definitions/BaseMetric' },
|
|
105
|
+
{
|
|
106
|
+
properties: {
|
|
107
|
+
name: { const: 'FCP' },
|
|
108
|
+
value: { maximum: 10000 }
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
]
|
|
112
|
+
},
|
|
113
|
+
TTFBMetric: {
|
|
114
|
+
allOf: [
|
|
115
|
+
{ $ref: '#/definitions/BaseMetric' },
|
|
116
|
+
{
|
|
117
|
+
properties: {
|
|
118
|
+
name: { const: 'TTFB' },
|
|
119
|
+
value: { maximum: 5000 }
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
INPMetric: {
|
|
125
|
+
allOf: [
|
|
126
|
+
{ $ref: '#/definitions/BaseMetric' },
|
|
127
|
+
{
|
|
128
|
+
properties: {
|
|
129
|
+
name: { const: 'INP' },
|
|
130
|
+
value: { maximum: 1000 }
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
]
|
|
134
|
+
},
|
|
135
|
+
ResourceTimingData: {
|
|
136
|
+
type: 'object',
|
|
137
|
+
required: ['name', 'entryType', 'startTime', 'duration'],
|
|
138
|
+
properties: {
|
|
139
|
+
name: { type: 'string', maxLength: 2048 },
|
|
140
|
+
entryType: { const: 'resource' },
|
|
141
|
+
startTime: { type: 'number', minimum: 0 },
|
|
142
|
+
duration: { type: 'number', minimum: 0 },
|
|
143
|
+
initiatorType: { type: 'string' },
|
|
144
|
+
nextHopProtocol: { type: 'string' },
|
|
145
|
+
renderBlockingStatus: { type: 'string' },
|
|
146
|
+
responseStatus: { type: 'number', minimum: 100, maximum: 599 },
|
|
147
|
+
transferSize: { type: 'number', minimum: 0 },
|
|
148
|
+
encodedBodySize: { type: 'number', minimum: 0 },
|
|
149
|
+
decodedBodySize: { type: 'number', minimum: 0 },
|
|
150
|
+
responseStart: { type: 'number', minimum: 0 },
|
|
151
|
+
responseEnd: { type: 'number', minimum: 0 }
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
NavigationTimingData: {
|
|
155
|
+
type: 'object',
|
|
156
|
+
required: ['type'],
|
|
157
|
+
properties: {
|
|
158
|
+
domComplete: { type: 'number', minimum: 0 },
|
|
159
|
+
domContentLoadedEventEnd: { type: 'number', minimum: 0 },
|
|
160
|
+
domContentLoadedEventStart: { type: 'number', minimum: 0 },
|
|
161
|
+
domInteractive: { type: 'number', minimum: 0 },
|
|
162
|
+
loadEventEnd: { type: 'number', minimum: 0 },
|
|
163
|
+
loadEventStart: { type: 'number', minimum: 0 },
|
|
164
|
+
redirectCount: { type: 'number', minimum: 0 },
|
|
165
|
+
type: {
|
|
166
|
+
type: 'string',
|
|
167
|
+
enum: ['navigate', 'reload', 'back-forward', 'prerender']
|
|
168
|
+
},
|
|
169
|
+
unloadEventEnd: { type: 'number', minimum: 0 },
|
|
170
|
+
unloadEventStart: { type: 'number', minimum: 0 }
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
LongTaskData: {
|
|
174
|
+
type: 'object',
|
|
175
|
+
required: ['name', 'entryType', 'startTime', 'duration'],
|
|
176
|
+
properties: {
|
|
177
|
+
name: { const: 'longtask' },
|
|
178
|
+
entryType: { const: 'longtask' },
|
|
179
|
+
startTime: { type: 'number', minimum: 0 },
|
|
180
|
+
duration: { type: 'number', minimum: 50 }, // Long tasks are >= 50ms
|
|
181
|
+
attribution: {
|
|
182
|
+
type: 'array',
|
|
183
|
+
items: {
|
|
184
|
+
type: 'object',
|
|
185
|
+
properties: {
|
|
186
|
+
name: { type: 'string' },
|
|
187
|
+
entryType: { const: 'taskattribution' },
|
|
188
|
+
startTime: { type: 'number', minimum: 0 },
|
|
189
|
+
duration: { type: 'number', minimum: 0 },
|
|
190
|
+
containerType: { type: 'string' },
|
|
191
|
+
containerSrc: { type: 'string' },
|
|
192
|
+
containerId: { type: 'string' },
|
|
193
|
+
containerName: { type: 'string' }
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
} as const;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// Trace span event schema for TraceLens
|
|
2
|
+
export const TraceSpanSchema = {
|
|
3
|
+
type: 'object',
|
|
4
|
+
required: ['traceId', 'spanId', 'operationName', 'startTime', 'tags', 'status'],
|
|
5
|
+
properties: {
|
|
6
|
+
traceId: {
|
|
7
|
+
type: 'string',
|
|
8
|
+
pattern: '^[a-f0-9]{32}$',
|
|
9
|
+
description: 'Hexadecimal trace ID (32 characters)'
|
|
10
|
+
},
|
|
11
|
+
spanId: {
|
|
12
|
+
type: 'string',
|
|
13
|
+
pattern: '^[a-f0-9]{16}$',
|
|
14
|
+
description: 'Hexadecimal span ID (16 characters)'
|
|
15
|
+
},
|
|
16
|
+
parentSpanId: {
|
|
17
|
+
type: 'string',
|
|
18
|
+
pattern: '^[a-f0-9]{16}$',
|
|
19
|
+
description: 'Hexadecimal parent span ID (16 characters)'
|
|
20
|
+
},
|
|
21
|
+
operationName: {
|
|
22
|
+
type: 'string',
|
|
23
|
+
minLength: 1,
|
|
24
|
+
maxLength: 256,
|
|
25
|
+
description: 'Name of the operation being traced'
|
|
26
|
+
},
|
|
27
|
+
startTime: {
|
|
28
|
+
type: 'number',
|
|
29
|
+
minimum: 0,
|
|
30
|
+
description: 'Start time in microseconds since epoch'
|
|
31
|
+
},
|
|
32
|
+
endTime: {
|
|
33
|
+
type: 'number',
|
|
34
|
+
minimum: 0,
|
|
35
|
+
description: 'End time in microseconds since epoch'
|
|
36
|
+
},
|
|
37
|
+
duration: {
|
|
38
|
+
type: 'number',
|
|
39
|
+
minimum: 0,
|
|
40
|
+
description: 'Duration in microseconds'
|
|
41
|
+
},
|
|
42
|
+
tags: {
|
|
43
|
+
type: 'object',
|
|
44
|
+
patternProperties: {
|
|
45
|
+
'^[a-zA-Z][a-zA-Z0-9._-]*$': {
|
|
46
|
+
oneOf: [
|
|
47
|
+
{ type: 'string', maxLength: 1024 },
|
|
48
|
+
{ type: 'number' },
|
|
49
|
+
{ type: 'boolean' }
|
|
50
|
+
]
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
additionalProperties: false,
|
|
54
|
+
description: 'Key-value pairs providing additional context'
|
|
55
|
+
},
|
|
56
|
+
logs: {
|
|
57
|
+
type: 'array',
|
|
58
|
+
items: {
|
|
59
|
+
type: 'object',
|
|
60
|
+
required: ['timestamp', 'fields'],
|
|
61
|
+
properties: {
|
|
62
|
+
timestamp: {
|
|
63
|
+
type: 'number',
|
|
64
|
+
minimum: 0,
|
|
65
|
+
description: 'Log timestamp in microseconds since epoch'
|
|
66
|
+
},
|
|
67
|
+
fields: {
|
|
68
|
+
type: 'object',
|
|
69
|
+
patternProperties: {
|
|
70
|
+
'^[a-zA-Z][a-zA-Z0-9._-]*$': {
|
|
71
|
+
oneOf: [
|
|
72
|
+
{ type: 'string', maxLength: 1024 },
|
|
73
|
+
{ type: 'number' },
|
|
74
|
+
{ type: 'boolean' }
|
|
75
|
+
]
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
additionalProperties: false
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
maxItems: 100,
|
|
83
|
+
description: 'Structured log events within the span'
|
|
84
|
+
},
|
|
85
|
+
status: {
|
|
86
|
+
type: 'string',
|
|
87
|
+
enum: [
|
|
88
|
+
'OK',
|
|
89
|
+
'CANCELLED',
|
|
90
|
+
'UNKNOWN',
|
|
91
|
+
'INVALID_ARGUMENT',
|
|
92
|
+
'DEADLINE_EXCEEDED',
|
|
93
|
+
'NOT_FOUND',
|
|
94
|
+
'ALREADY_EXISTS',
|
|
95
|
+
'PERMISSION_DENIED',
|
|
96
|
+
'RESOURCE_EXHAUSTED',
|
|
97
|
+
'FAILED_PRECONDITION',
|
|
98
|
+
'ABORTED',
|
|
99
|
+
'OUT_OF_RANGE',
|
|
100
|
+
'UNIMPLEMENTED',
|
|
101
|
+
'INTERNAL',
|
|
102
|
+
'UNAVAILABLE',
|
|
103
|
+
'DATA_LOSS',
|
|
104
|
+
'UNAUTHENTICATED'
|
|
105
|
+
],
|
|
106
|
+
description: 'Span status indicating success or failure'
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
additionalProperties: false
|
|
110
|
+
} as const;
|
|
111
|
+
|
|
112
|
+
export const TraceSchema = {
|
|
113
|
+
type: 'object',
|
|
114
|
+
required: ['traceId', 'spans', 'startTime'],
|
|
115
|
+
properties: {
|
|
116
|
+
traceId: {
|
|
117
|
+
type: 'string',
|
|
118
|
+
pattern: '^[a-f0-9]{32}$',
|
|
119
|
+
description: 'Hexadecimal trace ID (32 characters)'
|
|
120
|
+
},
|
|
121
|
+
spans: {
|
|
122
|
+
type: 'array',
|
|
123
|
+
items: TraceSpanSchema,
|
|
124
|
+
minItems: 1,
|
|
125
|
+
maxItems: 1000,
|
|
126
|
+
description: 'Array of spans that make up this trace'
|
|
127
|
+
},
|
|
128
|
+
startTime: {
|
|
129
|
+
type: 'number',
|
|
130
|
+
minimum: 0,
|
|
131
|
+
description: 'Trace start time in microseconds since epoch'
|
|
132
|
+
},
|
|
133
|
+
endTime: {
|
|
134
|
+
type: 'number',
|
|
135
|
+
minimum: 0,
|
|
136
|
+
description: 'Trace end time in microseconds since epoch'
|
|
137
|
+
},
|
|
138
|
+
duration: {
|
|
139
|
+
type: 'number',
|
|
140
|
+
minimum: 0,
|
|
141
|
+
description: 'Total trace duration in microseconds'
|
|
142
|
+
},
|
|
143
|
+
rootSpan: TraceSpanSchema
|
|
144
|
+
},
|
|
145
|
+
additionalProperties: false
|
|
146
|
+
} as const;
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// Package dependency structures for TraceLens
|
|
2
|
+
export interface PackageDependency {
|
|
3
|
+
name: string;
|
|
4
|
+
version: string;
|
|
5
|
+
type: DependencyType;
|
|
6
|
+
resolved?: string;
|
|
7
|
+
integrity?: string;
|
|
8
|
+
dev?: boolean;
|
|
9
|
+
optional?: boolean;
|
|
10
|
+
bundled?: boolean;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export enum DependencyType {
|
|
14
|
+
PRODUCTION = 'production',
|
|
15
|
+
DEVELOPMENT = 'development',
|
|
16
|
+
PEER = 'peer',
|
|
17
|
+
OPTIONAL = 'optional',
|
|
18
|
+
BUNDLED = 'bundled'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface DependencyGraph {
|
|
22
|
+
projectId: string;
|
|
23
|
+
timestamp: number;
|
|
24
|
+
rootPackage: PackageInfo;
|
|
25
|
+
dependencies: Map<string, PackageDependency>;
|
|
26
|
+
dependencyTree: DependencyNode;
|
|
27
|
+
lockfileHash?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface PackageInfo {
|
|
31
|
+
name: string;
|
|
32
|
+
version: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
main?: string;
|
|
35
|
+
scripts?: Record<string, string>;
|
|
36
|
+
dependencies?: Record<string, string>;
|
|
37
|
+
devDependencies?: Record<string, string>;
|
|
38
|
+
peerDependencies?: Record<string, string>;
|
|
39
|
+
optionalDependencies?: Record<string, string>;
|
|
40
|
+
bundledDependencies?: string[];
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface DependencyNode {
|
|
44
|
+
name: string;
|
|
45
|
+
version: string;
|
|
46
|
+
path: string;
|
|
47
|
+
children: DependencyNode[];
|
|
48
|
+
parent?: DependencyNode;
|
|
49
|
+
depth: number;
|
|
50
|
+
circular?: boolean;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RuntimeDependency {
|
|
54
|
+
name: string;
|
|
55
|
+
version: string;
|
|
56
|
+
loadTime: number;
|
|
57
|
+
executionTime: number;
|
|
58
|
+
memoryUsage: number;
|
|
59
|
+
importPath: string;
|
|
60
|
+
isEsm: boolean;
|
|
61
|
+
exports: string[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export interface DependencySnapshot {
|
|
65
|
+
id: string;
|
|
66
|
+
projectId: string;
|
|
67
|
+
timestamp: number;
|
|
68
|
+
environment: 'development' | 'production' | 'test';
|
|
69
|
+
nodeVersion: string;
|
|
70
|
+
npmVersion?: string;
|
|
71
|
+
yarnVersion?: string;
|
|
72
|
+
packageManager: 'npm' | 'yarn' | 'pnpm';
|
|
73
|
+
dependencies: PackageDependency[];
|
|
74
|
+
runtimeDependencies: RuntimeDependency[];
|
|
75
|
+
totalSize: number;
|
|
76
|
+
bundleSize?: number;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export interface DependencyChange {
|
|
80
|
+
type: 'added' | 'removed' | 'updated';
|
|
81
|
+
package: string;
|
|
82
|
+
oldVersion?: string;
|
|
83
|
+
newVersion?: string;
|
|
84
|
+
timestamp: number;
|
|
85
|
+
reason?: string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface DependencyAnalysis {
|
|
89
|
+
snapshotId: string;
|
|
90
|
+
criticalPath: string[];
|
|
91
|
+
bottlenecks: DependencyBottleneck[];
|
|
92
|
+
unusedDependencies: string[];
|
|
93
|
+
duplicateDependencies: DuplicateDependency[];
|
|
94
|
+
securityIssues: string[];
|
|
95
|
+
performanceImpact: PerformanceImpact;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface DependencyBottleneck {
|
|
99
|
+
package: string;
|
|
100
|
+
version: string;
|
|
101
|
+
impact: 'high' | 'medium' | 'low';
|
|
102
|
+
reason: 'load-time' | 'execution-time' | 'memory-usage' | 'bundle-size';
|
|
103
|
+
value: number;
|
|
104
|
+
threshold: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface DuplicateDependency {
|
|
108
|
+
package: string;
|
|
109
|
+
versions: string[];
|
|
110
|
+
paths: string[];
|
|
111
|
+
wastedSize: number;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface PerformanceImpact {
|
|
115
|
+
totalLoadTime: number;
|
|
116
|
+
totalExecutionTime: number;
|
|
117
|
+
totalMemoryUsage: number;
|
|
118
|
+
criticalPathTime: number;
|
|
119
|
+
parallelizableTime: number;
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AACA,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// Shared type definitions
|
|
2
|
+
export * from './trace.types';
|
|
3
|
+
export * from './performance.types';
|
|
4
|
+
export * from './dependency.types';
|
|
5
|
+
export * from './security.types';
|
|
6
|
+
|
|
7
|
+
export interface BaseEvent {
|
|
8
|
+
id: string;
|
|
9
|
+
timestamp: number;
|
|
10
|
+
projectId: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Web Vitals and performance timing types for TraceLens
|
|
2
|
+
export interface WebVitalsMetrics {
|
|
3
|
+
cls?: CLSMetric;
|
|
4
|
+
fid?: FIDMetric;
|
|
5
|
+
lcp?: LCPMetric;
|
|
6
|
+
fcp?: FCPMetric;
|
|
7
|
+
ttfb?: TTFBMetric;
|
|
8
|
+
inp?: INPMetric;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export interface BaseMetric {
|
|
12
|
+
name: string;
|
|
13
|
+
value: number;
|
|
14
|
+
rating: 'good' | 'needs-improvement' | 'poor';
|
|
15
|
+
delta: number;
|
|
16
|
+
entries: unknown[]; // Generic entries array
|
|
17
|
+
id: string;
|
|
18
|
+
navigationType: NavigationType;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface CLSMetric extends BaseMetric {
|
|
22
|
+
name: 'CLS';
|
|
23
|
+
entries: unknown[]; // Layout shift entries
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface FIDMetric extends BaseMetric {
|
|
27
|
+
name: 'FID';
|
|
28
|
+
entries: unknown[]; // Performance event timing entries
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface LCPMetric extends BaseMetric {
|
|
32
|
+
name: 'LCP';
|
|
33
|
+
entries: unknown[]; // Largest contentful paint entries
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface FCPMetric extends BaseMetric {
|
|
37
|
+
name: 'FCP';
|
|
38
|
+
entries: unknown[]; // Performance paint timing entries
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TTFBMetric extends BaseMetric {
|
|
42
|
+
name: 'TTFB';
|
|
43
|
+
entries: unknown[]; // Performance navigation timing entries
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface INPMetric extends BaseMetric {
|
|
47
|
+
name: 'INP';
|
|
48
|
+
entries: unknown[]; // Performance event timing entries
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export type NavigationType = 'navigate' | 'reload' | 'back-forward' | 'prerender';
|
|
52
|
+
|
|
53
|
+
export interface ResourceTiming {
|
|
54
|
+
name: string;
|
|
55
|
+
entryType: string;
|
|
56
|
+
startTime: number;
|
|
57
|
+
duration: number;
|
|
58
|
+
initiatorType: string;
|
|
59
|
+
nextHopProtocol: string;
|
|
60
|
+
renderBlockingStatus: string;
|
|
61
|
+
responseStatus: number;
|
|
62
|
+
transferSize: number;
|
|
63
|
+
encodedBodySize: number;
|
|
64
|
+
decodedBodySize: number;
|
|
65
|
+
responseStart: number;
|
|
66
|
+
responseEnd: number;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface NavigationTiming {
|
|
70
|
+
domComplete: number;
|
|
71
|
+
domContentLoadedEventEnd: number;
|
|
72
|
+
domContentLoadedEventStart: number;
|
|
73
|
+
domInteractive: number;
|
|
74
|
+
loadEventEnd: number;
|
|
75
|
+
loadEventStart: number;
|
|
76
|
+
redirectCount: number;
|
|
77
|
+
type: NavigationType;
|
|
78
|
+
unloadEventEnd: number;
|
|
79
|
+
unloadEventStart: number;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface LongTask {
|
|
83
|
+
name: string;
|
|
84
|
+
entryType: 'longtask';
|
|
85
|
+
startTime: number;
|
|
86
|
+
duration: number;
|
|
87
|
+
attribution: TaskAttributionTiming[];
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface TaskAttributionTiming {
|
|
91
|
+
name: string;
|
|
92
|
+
entryType: 'taskattribution';
|
|
93
|
+
startTime: number;
|
|
94
|
+
duration: number;
|
|
95
|
+
containerType: string;
|
|
96
|
+
containerSrc: string;
|
|
97
|
+
containerId: string;
|
|
98
|
+
containerName: string;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export interface PerformanceEvent {
|
|
102
|
+
id: string;
|
|
103
|
+
timestamp: number;
|
|
104
|
+
type: 'web-vitals' | 'resource-timing' | 'navigation-timing' | 'long-task';
|
|
105
|
+
data: WebVitalsMetrics | ResourceTiming | NavigationTiming | LongTask;
|
|
106
|
+
url: string;
|
|
107
|
+
userAgent: string;
|
|
108
|
+
}
|