proagents 1.6.17 → 1.6.18
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/.claude/settings.local.json +169 -0
- package/COMMANDS.md +595 -0
- package/README.md +13 -23
- package/package.json +2 -7
- package/.proagents/ai-models/README.md +0 -141
- package/.proagents/ai-models/cost-management.md +0 -362
- package/.proagents/ai-models/fallbacks.md +0 -342
- package/.proagents/ai-models/model-config.md +0 -318
- package/.proagents/ai-models/task-routing.md +0 -503
- package/.proagents/ai-training/README.md +0 -155
- package/.proagents/ai-training/continuous-learning.md +0 -413
- package/.proagents/ai-training/domain-knowledge.md +0 -378
- package/.proagents/ai-training/pattern-learning.md +0 -455
- package/.proagents/ai-training/training-data.md +0 -337
- package/.proagents/ai-training/user-preferences.md +0 -346
- package/.proagents/approval-workflows/README.md +0 -146
- package/.proagents/approval-workflows/approval-config.md +0 -332
- package/.proagents/approval-workflows/approval-stages.md +0 -503
- package/.proagents/approval-workflows/emergency-bypass.md +0 -351
- package/.proagents/approval-workflows/examples.md +0 -859
- package/.proagents/approval-workflows/notifications.md +0 -320
- package/.proagents/compliance/README.md +0 -206
- package/.proagents/compliance/access-control.md +0 -310
- package/.proagents/compliance/audit-logging.md +0 -444
- package/.proagents/compliance/compliance-frameworks.md +0 -429
- package/.proagents/compliance/reports.md +0 -491
- package/.proagents/compliance/retention-policies.md +0 -454
- package/.proagents/config-versioning/README.md +0 -120
- package/.proagents/config-versioning/changelog.md +0 -300
- package/.proagents/config-versioning/rollback.md +0 -283
- package/.proagents/config-versioning/versioning.md +0 -330
- package/.proagents/contract-testing/README.md +0 -223
- package/.proagents/contract-testing/contract-testing.md +0 -614
- package/.proagents/contract-testing/pact-integration.md +0 -507
- package/.proagents/contract-testing/schema-validation.md +0 -565
- package/.proagents/dependency-management/README.md +0 -140
- package/.proagents/dependency-management/automation.md +0 -363
- package/.proagents/dependency-management/compatibility.md +0 -319
- package/.proagents/dependency-management/security-scanning.md +0 -413
- package/.proagents/dependency-management/update-policies.md +0 -374
- package/.proagents/disaster-recovery/README.md +0 -247
- package/.proagents/disaster-recovery/automation.md +0 -366
- package/.proagents/disaster-recovery/backup-recovery.md +0 -571
- package/.proagents/disaster-recovery/incident-response.md +0 -565
- package/.proagents/disaster-recovery/rollback-procedures.md +0 -499
- package/.proagents/disaster-recovery/runbooks.md +0 -603
- package/.proagents/disaster-recovery/scenarios.md +0 -892
- package/.proagents/disaster-recovery/testing.md +0 -438
- package/.proagents/environments/README.md +0 -244
- package/.proagents/environments/configuration.md +0 -437
- package/.proagents/environments/promotion.md +0 -434
- package/.proagents/environments/setup.md +0 -420
- package/.proagents/examples/README.md +0 -55
- package/.proagents/examples/backend-nodejs/README.md +0 -188
- package/.proagents/examples/backend-nodejs/complete-conversation.md +0 -601
- package/.proagents/examples/backend-nodejs/proagents.config.yaml +0 -415
- package/.proagents/examples/backend-nodejs/workflow-example.md +0 -909
- package/.proagents/examples/fullstack-nextjs/README.md +0 -155
- package/.proagents/examples/fullstack-nextjs/complete-conversation.md +0 -604
- package/.proagents/examples/fullstack-nextjs/proagents.config.yaml +0 -287
- package/.proagents/examples/fullstack-nextjs/workflow-example.md +0 -553
- package/.proagents/examples/mobile-react-native/README.md +0 -171
- package/.proagents/examples/mobile-react-native/complete-conversation.md +0 -825
- package/.proagents/examples/mobile-react-native/proagents.config.yaml +0 -330
- package/.proagents/examples/mobile-react-native/workflow-example.md +0 -723
- package/.proagents/examples/web-frontend-react/README.md +0 -125
- package/.proagents/examples/web-frontend-react/complete-conversation.md +0 -556
- package/.proagents/examples/web-frontend-react/proagents.config.yaml +0 -183
- package/.proagents/examples/web-frontend-react/workflow-example.md +0 -603
- package/.proagents/existing-projects/README.md +0 -65
- package/.proagents/existing-projects/challenges.md +0 -861
- package/.proagents/existing-projects/coexistence-mode.md +0 -483
- package/.proagents/existing-projects/compatibility-assessment.md +0 -541
- package/.proagents/existing-projects/gradual-adoption.md +0 -515
- package/.proagents/existing-projects/migration-strategies.md +0 -788
- package/.proagents/existing-projects/pattern-reconciliation.md +0 -489
- package/.proagents/existing-projects/team-onboarding.md +0 -617
- package/.proagents/existing-projects/technical-debt-handling.md +0 -644
- package/.proagents/feature-flags/README.md +0 -263
- package/.proagents/feature-flags/ab-testing.md +0 -413
- package/.proagents/feature-flags/configuration.md +0 -420
- package/.proagents/feature-flags/kill-switches.md +0 -444
- package/.proagents/feature-flags/rollout-strategies.md +0 -392
- package/.proagents/history.log +0 -12
- package/.proagents/i18n/README.md +0 -133
- package/.proagents/i18n/extraction.md +0 -433
- package/.proagents/i18n/tms-integration.md +0 -332
- package/.proagents/i18n/translation-workflow.md +0 -413
- package/.proagents/i18n/validation.md +0 -355
- package/.proagents/logging/README.md +0 -276
- package/.proagents/logging/aggregation.md +0 -475
- package/.proagents/logging/log-levels.md +0 -376
- package/.proagents/logging/sensitive-data.md +0 -423
- package/.proagents/logging/structured-logging.md +0 -406
- package/.proagents/metrics/README.md +0 -69
- package/.proagents/metrics/code-quality-kpis.md +0 -461
- package/.proagents/metrics/deployment-metrics.md +0 -517
- package/.proagents/metrics/developer-productivity.md +0 -368
- package/.proagents/metrics/learning-effectiveness.md +0 -478
- package/.proagents/migrations/README.md +0 -77
- package/.proagents/migrations/from-claude-projects.md +0 -313
- package/.proagents/migrations/from-cursor-rules.md +0 -345
- package/.proagents/migrations/from-custom-workflows.md +0 -410
- package/.proagents/monitoring/README.md +0 -308
- package/.proagents/monitoring/alerting.md +0 -449
- package/.proagents/monitoring/dashboards.md +0 -454
- package/.proagents/monitoring/health-checks.md +0 -436
- package/.proagents/monitoring/metrics.md +0 -434
- package/.proagents/multi-project/README.md +0 -170
- package/.proagents/multi-project/coordinated-deploy.md +0 -510
- package/.proagents/multi-project/cross-project-deps.md +0 -395
- package/.proagents/multi-project/unified-changelog.md +0 -477
- package/.proagents/multi-project/walkthroughs/monorepo-setup.md +0 -787
- package/.proagents/multi-project/workspace-config.md +0 -408
- package/.proagents/notifications/README.md +0 -151
- package/.proagents/notifications/channels.md +0 -457
- package/.proagents/notifications/preferences.md +0 -415
- package/.proagents/notifications/routing.md +0 -449
- package/.proagents/notifications/scheduling.md +0 -425
- package/.proagents/notifications/templates.md +0 -446
- package/.proagents/offline-mode/README.md +0 -145
- package/.proagents/offline-mode/caching.md +0 -344
- package/.proagents/offline-mode/offline-operations.md +0 -312
- package/.proagents/offline-mode/queue-specifications.md +0 -679
- package/.proagents/offline-mode/sync.md +0 -475
- package/.proagents/parallel-features/README.md +0 -85
- package/.proagents/parallel-features/conflict-detection.md +0 -226
- package/.proagents/parallel-features/dependency-management.md +0 -392
- package/.proagents/parallel-features/merge-coordination.md +0 -506
- package/.proagents/parallel-features/tracking-system.md +0 -416
- package/.proagents/performance/README.md +0 -59
- package/.proagents/performance/bundle-analysis.md +0 -375
- package/.proagents/performance/load-testing.md +0 -563
- package/.proagents/performance/runtime-metrics.md +0 -489
- package/.proagents/performance/web-vitals.md +0 -425
- package/.proagents/plugins/README.md +0 -139
- package/.proagents/plugins/creating-plugins.md +0 -504
- package/.proagents/plugins/plugin-api.md +0 -467
- package/.proagents/plugins/plugin-registry.md +0 -276
- package/.proagents/reporting/README.md +0 -158
- package/.proagents/reporting/dashboards.md +0 -366
- package/.proagents/reporting/exports.md +0 -524
- package/.proagents/reporting/quality-metrics.md +0 -385
- package/.proagents/reporting/templates/README.md +0 -56
- package/.proagents/reporting/templates/dashboard-config.json +0 -187
- package/.proagents/reporting/templates/metrics-queries.md +0 -427
- package/.proagents/reporting/templates/react-dashboard.tsx +0 -544
- package/.proagents/reporting/templates/widgets.md +0 -451
- package/.proagents/reporting/velocity-metrics.md +0 -340
- package/.proagents/reverse-engineering/README.md +0 -151
- package/.proagents/reverse-engineering/architecture-extraction.md +0 -325
- package/.proagents/reverse-engineering/code-analysis.md +0 -377
- package/.proagents/reverse-engineering/dependency-mapping.md +0 -567
- package/.proagents/reverse-engineering/diagram-generation.md +0 -586
- package/.proagents/reverse-engineering/documentation-generation.md +0 -468
- package/.proagents/reverse-engineering/pattern-detection.md +0 -569
- package/.proagents/reverse-engineering/quality-assessment.md +0 -733
- package/.proagents/secrets/README.md +0 -278
- package/.proagents/secrets/access-control.md +0 -443
- package/.proagents/secrets/rotation.md +0 -403
- package/.proagents/secrets/scanning.md +0 -487
- package/.proagents/secrets/storage.md +0 -394
- package/.proagents/webhooks/README.md +0 -126
- package/.proagents/webhooks/endpoints.md +0 -298
- package/.proagents/webhooks/events.md +0 -316
- package/.proagents/webhooks/payloads.md +0 -325
- package/.proagents/webhooks/reliability.md +0 -363
- package/.proagents/webhooks/security.md +0 -380
|
@@ -1,565 +0,0 @@
|
|
|
1
|
-
# Schema Validation
|
|
2
|
-
|
|
3
|
-
Validate API contracts using JSON Schema and OpenAPI specifications.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
Schema validation ensures API requests and responses conform to defined schemas, providing contract assurance without full contract testing infrastructure.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## JSON Schema Validation
|
|
14
|
-
|
|
15
|
-
### Define Schema
|
|
16
|
-
|
|
17
|
-
```json
|
|
18
|
-
{
|
|
19
|
-
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
20
|
-
"$id": "https://api.example.com/schemas/user.json",
|
|
21
|
-
"title": "User",
|
|
22
|
-
"type": "object",
|
|
23
|
-
"required": ["id", "name", "email"],
|
|
24
|
-
"properties": {
|
|
25
|
-
"id": {
|
|
26
|
-
"type": "string",
|
|
27
|
-
"format": "uuid",
|
|
28
|
-
"description": "Unique user identifier"
|
|
29
|
-
},
|
|
30
|
-
"name": {
|
|
31
|
-
"type": "string",
|
|
32
|
-
"minLength": 1,
|
|
33
|
-
"maxLength": 100
|
|
34
|
-
},
|
|
35
|
-
"email": {
|
|
36
|
-
"type": "string",
|
|
37
|
-
"format": "email"
|
|
38
|
-
},
|
|
39
|
-
"role": {
|
|
40
|
-
"type": "string",
|
|
41
|
-
"enum": ["admin", "user", "guest"],
|
|
42
|
-
"default": "user"
|
|
43
|
-
},
|
|
44
|
-
"createdAt": {
|
|
45
|
-
"type": "string",
|
|
46
|
-
"format": "date-time"
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"additionalProperties": false
|
|
50
|
-
}
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Validate in Tests
|
|
54
|
-
|
|
55
|
-
```typescript
|
|
56
|
-
import Ajv from 'ajv';
|
|
57
|
-
import addFormats from 'ajv-formats';
|
|
58
|
-
import userSchema from './schemas/user.json';
|
|
59
|
-
|
|
60
|
-
const ajv = new Ajv({ allErrors: true });
|
|
61
|
-
addFormats(ajv);
|
|
62
|
-
|
|
63
|
-
const validate = ajv.compile(userSchema);
|
|
64
|
-
|
|
65
|
-
describe('User API', () => {
|
|
66
|
-
it('returns valid user schema', async () => {
|
|
67
|
-
const response = await fetch('/api/users/123');
|
|
68
|
-
const user = await response.json();
|
|
69
|
-
|
|
70
|
-
const valid = validate(user);
|
|
71
|
-
|
|
72
|
-
if (!valid) {
|
|
73
|
-
console.error('Validation errors:', validate.errors);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
expect(valid).toBe(true);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Runtime Validation
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
import Ajv from 'ajv';
|
|
85
|
-
import addFormats from 'ajv-formats';
|
|
86
|
-
|
|
87
|
-
const ajv = new Ajv({ allErrors: true, removeAdditional: true });
|
|
88
|
-
addFormats(ajv);
|
|
89
|
-
|
|
90
|
-
// Compile schemas
|
|
91
|
-
const schemas = {
|
|
92
|
-
user: ajv.compile(require('./schemas/user.json')),
|
|
93
|
-
createUser: ajv.compile(require('./schemas/create-user.json')),
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// Validation middleware
|
|
97
|
-
function validateBody(schemaName: string) {
|
|
98
|
-
return (req: Request, res: Response, next: NextFunction) => {
|
|
99
|
-
const validate = schemas[schemaName];
|
|
100
|
-
|
|
101
|
-
if (!validate) {
|
|
102
|
-
return res.status(500).json({ error: 'Unknown schema' });
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (!validate(req.body)) {
|
|
106
|
-
return res.status(400).json({
|
|
107
|
-
error: 'Validation failed',
|
|
108
|
-
details: validate.errors,
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
next();
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// Usage
|
|
117
|
-
app.post('/api/users', validateBody('createUser'), createUser);
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
---
|
|
121
|
-
|
|
122
|
-
## OpenAPI Validation
|
|
123
|
-
|
|
124
|
-
### Define OpenAPI Spec
|
|
125
|
-
|
|
126
|
-
```yaml
|
|
127
|
-
# openapi.yaml
|
|
128
|
-
openapi: 3.0.3
|
|
129
|
-
info:
|
|
130
|
-
title: User API
|
|
131
|
-
version: 1.0.0
|
|
132
|
-
|
|
133
|
-
paths:
|
|
134
|
-
/users/{id}:
|
|
135
|
-
get:
|
|
136
|
-
summary: Get user by ID
|
|
137
|
-
parameters:
|
|
138
|
-
- name: id
|
|
139
|
-
in: path
|
|
140
|
-
required: true
|
|
141
|
-
schema:
|
|
142
|
-
type: string
|
|
143
|
-
format: uuid
|
|
144
|
-
responses:
|
|
145
|
-
'200':
|
|
146
|
-
description: User found
|
|
147
|
-
content:
|
|
148
|
-
application/json:
|
|
149
|
-
schema:
|
|
150
|
-
$ref: '#/components/schemas/User'
|
|
151
|
-
'404':
|
|
152
|
-
description: User not found
|
|
153
|
-
content:
|
|
154
|
-
application/json:
|
|
155
|
-
schema:
|
|
156
|
-
$ref: '#/components/schemas/Error'
|
|
157
|
-
|
|
158
|
-
/users:
|
|
159
|
-
post:
|
|
160
|
-
summary: Create user
|
|
161
|
-
requestBody:
|
|
162
|
-
required: true
|
|
163
|
-
content:
|
|
164
|
-
application/json:
|
|
165
|
-
schema:
|
|
166
|
-
$ref: '#/components/schemas/CreateUser'
|
|
167
|
-
responses:
|
|
168
|
-
'201':
|
|
169
|
-
description: User created
|
|
170
|
-
content:
|
|
171
|
-
application/json:
|
|
172
|
-
schema:
|
|
173
|
-
$ref: '#/components/schemas/User'
|
|
174
|
-
|
|
175
|
-
components:
|
|
176
|
-
schemas:
|
|
177
|
-
User:
|
|
178
|
-
type: object
|
|
179
|
-
required:
|
|
180
|
-
- id
|
|
181
|
-
- name
|
|
182
|
-
- email
|
|
183
|
-
properties:
|
|
184
|
-
id:
|
|
185
|
-
type: string
|
|
186
|
-
format: uuid
|
|
187
|
-
name:
|
|
188
|
-
type: string
|
|
189
|
-
email:
|
|
190
|
-
type: string
|
|
191
|
-
format: email
|
|
192
|
-
role:
|
|
193
|
-
type: string
|
|
194
|
-
enum: [admin, user, guest]
|
|
195
|
-
createdAt:
|
|
196
|
-
type: string
|
|
197
|
-
format: date-time
|
|
198
|
-
|
|
199
|
-
CreateUser:
|
|
200
|
-
type: object
|
|
201
|
-
required:
|
|
202
|
-
- name
|
|
203
|
-
- email
|
|
204
|
-
properties:
|
|
205
|
-
name:
|
|
206
|
-
type: string
|
|
207
|
-
minLength: 1
|
|
208
|
-
maxLength: 100
|
|
209
|
-
email:
|
|
210
|
-
type: string
|
|
211
|
-
format: email
|
|
212
|
-
role:
|
|
213
|
-
type: string
|
|
214
|
-
enum: [admin, user, guest]
|
|
215
|
-
default: user
|
|
216
|
-
|
|
217
|
-
Error:
|
|
218
|
-
type: object
|
|
219
|
-
required:
|
|
220
|
-
- error
|
|
221
|
-
- code
|
|
222
|
-
properties:
|
|
223
|
-
error:
|
|
224
|
-
type: string
|
|
225
|
-
code:
|
|
226
|
-
type: string
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
### Validate with OpenAPI
|
|
230
|
-
|
|
231
|
-
```typescript
|
|
232
|
-
import OpenAPIValidator from 'express-openapi-validator';
|
|
233
|
-
|
|
234
|
-
// Add validation middleware
|
|
235
|
-
app.use(
|
|
236
|
-
OpenAPIValidator.middleware({
|
|
237
|
-
apiSpec: './openapi.yaml',
|
|
238
|
-
validateRequests: true,
|
|
239
|
-
validateResponses: true,
|
|
240
|
-
})
|
|
241
|
-
);
|
|
242
|
-
|
|
243
|
-
// Error handler for validation errors
|
|
244
|
-
app.use((err, req, res, next) => {
|
|
245
|
-
if (err.status === 400) {
|
|
246
|
-
return res.status(400).json({
|
|
247
|
-
error: 'Validation error',
|
|
248
|
-
details: err.errors,
|
|
249
|
-
});
|
|
250
|
-
}
|
|
251
|
-
next(err);
|
|
252
|
-
});
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
### Test Against OpenAPI
|
|
256
|
-
|
|
257
|
-
```typescript
|
|
258
|
-
import { OpenAPIV3 } from 'openapi-types';
|
|
259
|
-
import SwaggerParser from '@apidevtools/swagger-parser';
|
|
260
|
-
import { createClient } from 'openapi-fetch';
|
|
261
|
-
|
|
262
|
-
describe('API Contract Tests', () => {
|
|
263
|
-
let api: OpenAPIV3.Document;
|
|
264
|
-
|
|
265
|
-
beforeAll(async () => {
|
|
266
|
-
api = await SwaggerParser.validate('./openapi.yaml') as OpenAPIV3.Document;
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
it('GET /users/{id} matches spec', async () => {
|
|
270
|
-
const response = await fetch('/api/users/123');
|
|
271
|
-
const body = await response.json();
|
|
272
|
-
|
|
273
|
-
// Validate response matches schema
|
|
274
|
-
const schema = api.paths['/users/{id}']
|
|
275
|
-
.get
|
|
276
|
-
.responses['200']
|
|
277
|
-
.content['application/json']
|
|
278
|
-
.schema;
|
|
279
|
-
|
|
280
|
-
const ajv = new Ajv();
|
|
281
|
-
const validate = ajv.compile(schema);
|
|
282
|
-
|
|
283
|
-
expect(validate(body)).toBe(true);
|
|
284
|
-
});
|
|
285
|
-
});
|
|
286
|
-
```
|
|
287
|
-
|
|
288
|
-
---
|
|
289
|
-
|
|
290
|
-
## Schema Testing Strategies
|
|
291
|
-
|
|
292
|
-
### 1. Snapshot Testing
|
|
293
|
-
|
|
294
|
-
```typescript
|
|
295
|
-
describe('API Schemas', () => {
|
|
296
|
-
it('user schema matches snapshot', () => {
|
|
297
|
-
const userSchema = require('./schemas/user.json');
|
|
298
|
-
expect(userSchema).toMatchSnapshot();
|
|
299
|
-
});
|
|
300
|
-
|
|
301
|
-
it('openapi spec matches snapshot', async () => {
|
|
302
|
-
const spec = await SwaggerParser.parse('./openapi.yaml');
|
|
303
|
-
expect(spec).toMatchSnapshot();
|
|
304
|
-
});
|
|
305
|
-
});
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
### 2. Breaking Change Detection
|
|
309
|
-
|
|
310
|
-
```typescript
|
|
311
|
-
import { diff } from 'json-diff';
|
|
312
|
-
|
|
313
|
-
describe('Schema Backward Compatibility', () => {
|
|
314
|
-
it('new schema is backward compatible', () => {
|
|
315
|
-
const oldSchema = require('./schemas/v1/user.json');
|
|
316
|
-
const newSchema = require('./schemas/v2/user.json');
|
|
317
|
-
|
|
318
|
-
// Check required fields not removed
|
|
319
|
-
const oldRequired = new Set(oldSchema.required || []);
|
|
320
|
-
const newRequired = new Set(newSchema.required || []);
|
|
321
|
-
|
|
322
|
-
for (const field of oldRequired) {
|
|
323
|
-
expect(newRequired.has(field)).toBe(true);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
// Check no type changes in existing fields
|
|
327
|
-
for (const [field, oldDef] of Object.entries(oldSchema.properties || {})) {
|
|
328
|
-
if (newSchema.properties?.[field]) {
|
|
329
|
-
expect(newSchema.properties[field].type).toBe(oldDef.type);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
});
|
|
333
|
-
});
|
|
334
|
-
```
|
|
335
|
-
|
|
336
|
-
### 3. Schema Fuzzing
|
|
337
|
-
|
|
338
|
-
```typescript
|
|
339
|
-
import jsf from 'json-schema-faker';
|
|
340
|
-
|
|
341
|
-
describe('Schema Fuzzing', () => {
|
|
342
|
-
it('handles random valid inputs', async () => {
|
|
343
|
-
const createUserSchema = require('./schemas/create-user.json');
|
|
344
|
-
|
|
345
|
-
// Generate random valid input
|
|
346
|
-
const randomUser = jsf.generate(createUserSchema);
|
|
347
|
-
|
|
348
|
-
// Should not throw
|
|
349
|
-
const response = await fetch('/api/users', {
|
|
350
|
-
method: 'POST',
|
|
351
|
-
body: JSON.stringify(randomUser),
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
// Should accept valid input
|
|
355
|
-
expect(response.status).toBe(201);
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
---
|
|
361
|
-
|
|
362
|
-
## Schema Evolution
|
|
363
|
-
|
|
364
|
-
### Versioning Strategies
|
|
365
|
-
|
|
366
|
-
```yaml
|
|
367
|
-
# Option 1: Path versioning
|
|
368
|
-
paths:
|
|
369
|
-
/v1/users:
|
|
370
|
-
get:
|
|
371
|
-
responses:
|
|
372
|
-
'200':
|
|
373
|
-
content:
|
|
374
|
-
application/json:
|
|
375
|
-
schema:
|
|
376
|
-
$ref: '#/components/schemas/UserV1'
|
|
377
|
-
|
|
378
|
-
/v2/users:
|
|
379
|
-
get:
|
|
380
|
-
responses:
|
|
381
|
-
'200':
|
|
382
|
-
content:
|
|
383
|
-
application/json:
|
|
384
|
-
schema:
|
|
385
|
-
$ref: '#/components/schemas/UserV2'
|
|
386
|
-
|
|
387
|
-
# Option 2: Content negotiation
|
|
388
|
-
paths:
|
|
389
|
-
/users:
|
|
390
|
-
get:
|
|
391
|
-
responses:
|
|
392
|
-
'200':
|
|
393
|
-
content:
|
|
394
|
-
application/vnd.api.v1+json:
|
|
395
|
-
schema:
|
|
396
|
-
$ref: '#/components/schemas/UserV1'
|
|
397
|
-
application/vnd.api.v2+json:
|
|
398
|
-
schema:
|
|
399
|
-
$ref: '#/components/schemas/UserV2'
|
|
400
|
-
```
|
|
401
|
-
|
|
402
|
-
### Migration Guide Generation
|
|
403
|
-
|
|
404
|
-
```typescript
|
|
405
|
-
function generateMigrationGuide(oldSchema: Schema, newSchema: Schema): string {
|
|
406
|
-
const changes: string[] = [];
|
|
407
|
-
|
|
408
|
-
// Find new required fields
|
|
409
|
-
const newRequired = newSchema.required.filter(
|
|
410
|
-
f => !oldSchema.required.includes(f)
|
|
411
|
-
);
|
|
412
|
-
|
|
413
|
-
if (newRequired.length > 0) {
|
|
414
|
-
changes.push(`New required fields: ${newRequired.join(', ')}`);
|
|
415
|
-
}
|
|
416
|
-
|
|
417
|
-
// Find removed fields
|
|
418
|
-
const removedFields = Object.keys(oldSchema.properties).filter(
|
|
419
|
-
f => !(f in newSchema.properties)
|
|
420
|
-
);
|
|
421
|
-
|
|
422
|
-
if (removedFields.length > 0) {
|
|
423
|
-
changes.push(`Removed fields: ${removedFields.join(', ')}`);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
// Find type changes
|
|
427
|
-
for (const [field, def] of Object.entries(newSchema.properties)) {
|
|
428
|
-
if (oldSchema.properties[field]?.type !== def.type) {
|
|
429
|
-
changes.push(`Type change: ${field} (${oldSchema.properties[field]?.type} → ${def.type})`);
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
return changes.join('\n');
|
|
434
|
-
}
|
|
435
|
-
```
|
|
436
|
-
|
|
437
|
-
---
|
|
438
|
-
|
|
439
|
-
## Integration with Zod
|
|
440
|
-
|
|
441
|
-
### Define Schema with Zod
|
|
442
|
-
|
|
443
|
-
```typescript
|
|
444
|
-
import { z } from 'zod';
|
|
445
|
-
import { zodToJsonSchema } from 'zod-to-json-schema';
|
|
446
|
-
|
|
447
|
-
// Define schema with Zod
|
|
448
|
-
const UserSchema = z.object({
|
|
449
|
-
id: z.string().uuid(),
|
|
450
|
-
name: z.string().min(1).max(100),
|
|
451
|
-
email: z.string().email(),
|
|
452
|
-
role: z.enum(['admin', 'user', 'guest']).default('user'),
|
|
453
|
-
createdAt: z.string().datetime(),
|
|
454
|
-
});
|
|
455
|
-
|
|
456
|
-
const CreateUserSchema = UserSchema.omit({ id: true, createdAt: true });
|
|
457
|
-
|
|
458
|
-
// Type inference
|
|
459
|
-
type User = z.infer<typeof UserSchema>;
|
|
460
|
-
type CreateUser = z.infer<typeof CreateUserSchema>;
|
|
461
|
-
|
|
462
|
-
// Convert to JSON Schema
|
|
463
|
-
const userJsonSchema = zodToJsonSchema(UserSchema);
|
|
464
|
-
|
|
465
|
-
// Validation
|
|
466
|
-
function validateUser(data: unknown): User {
|
|
467
|
-
return UserSchema.parse(data);
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// Safe validation
|
|
471
|
-
function safeValidateUser(data: unknown): { success: boolean; data?: User; error?: z.ZodError } {
|
|
472
|
-
const result = UserSchema.safeParse(data);
|
|
473
|
-
return result;
|
|
474
|
-
}
|
|
475
|
-
```
|
|
476
|
-
|
|
477
|
-
### Express Middleware with Zod
|
|
478
|
-
|
|
479
|
-
```typescript
|
|
480
|
-
import { z, ZodSchema } from 'zod';
|
|
481
|
-
|
|
482
|
-
function validate<T extends ZodSchema>(schema: T) {
|
|
483
|
-
return (req: Request, res: Response, next: NextFunction) => {
|
|
484
|
-
const result = schema.safeParse(req.body);
|
|
485
|
-
|
|
486
|
-
if (!result.success) {
|
|
487
|
-
return res.status(400).json({
|
|
488
|
-
error: 'Validation failed',
|
|
489
|
-
details: result.error.issues,
|
|
490
|
-
});
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
req.body = result.data;
|
|
494
|
-
next();
|
|
495
|
-
};
|
|
496
|
-
}
|
|
497
|
-
|
|
498
|
-
// Usage
|
|
499
|
-
app.post('/api/users', validate(CreateUserSchema), createUser);
|
|
500
|
-
```
|
|
501
|
-
|
|
502
|
-
---
|
|
503
|
-
|
|
504
|
-
## Commands
|
|
505
|
-
|
|
506
|
-
```bash
|
|
507
|
-
# Validate schema files
|
|
508
|
-
pa:schema validate ./schemas/
|
|
509
|
-
|
|
510
|
-
# Generate JSON Schema from TypeScript
|
|
511
|
-
pa:schema generate --from types.ts --out schemas/
|
|
512
|
-
|
|
513
|
-
# Compare schemas for breaking changes
|
|
514
|
-
pa:schema diff ./old-schema.json ./new-schema.json
|
|
515
|
-
|
|
516
|
-
# Generate TypeScript from JSON Schema
|
|
517
|
-
pa:schema to-typescript ./schemas/user.json
|
|
518
|
-
|
|
519
|
-
# Validate OpenAPI spec
|
|
520
|
-
pa:schema openapi validate ./openapi.yaml
|
|
521
|
-
|
|
522
|
-
# Generate mock data from schema
|
|
523
|
-
pa:schema mock ./schemas/user.json
|
|
524
|
-
```
|
|
525
|
-
|
|
526
|
-
---
|
|
527
|
-
|
|
528
|
-
## Configuration
|
|
529
|
-
|
|
530
|
-
```yaml
|
|
531
|
-
# proagents.config.yaml
|
|
532
|
-
schema_validation:
|
|
533
|
-
enabled: true
|
|
534
|
-
|
|
535
|
-
json_schema:
|
|
536
|
-
draft: "2020-12"
|
|
537
|
-
strict: true
|
|
538
|
-
additional_properties: false
|
|
539
|
-
|
|
540
|
-
openapi:
|
|
541
|
-
validate_requests: true
|
|
542
|
-
validate_responses: true
|
|
543
|
-
spec_path: "./openapi.yaml"
|
|
544
|
-
|
|
545
|
-
zod:
|
|
546
|
-
strict: true
|
|
547
|
-
coerce: false
|
|
548
|
-
|
|
549
|
-
ci:
|
|
550
|
-
check_breaking_changes: true
|
|
551
|
-
fail_on_breaking: true
|
|
552
|
-
generate_migration_guide: true
|
|
553
|
-
```
|
|
554
|
-
|
|
555
|
-
---
|
|
556
|
-
|
|
557
|
-
## Best Practices
|
|
558
|
-
|
|
559
|
-
1. **Single source of truth**: Define schemas once, generate others
|
|
560
|
-
2. **Version schemas**: Track schema changes in git
|
|
561
|
-
3. **Detect breaking changes**: Fail CI on incompatible changes
|
|
562
|
-
4. **Generate types**: Create TypeScript types from schemas
|
|
563
|
-
5. **Validate early**: Validate at API boundaries
|
|
564
|
-
6. **Document schemas**: Include descriptions and examples
|
|
565
|
-
7. **Use strict mode**: Disallow additional properties by default
|
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
# Dependency Auto-Update System
|
|
2
|
-
|
|
3
|
-
Automated dependency updates with testing and safety checks.
|
|
4
|
-
|
|
5
|
-
---
|
|
6
|
-
|
|
7
|
-
## Overview
|
|
8
|
-
|
|
9
|
-
Keep dependencies up-to-date automatically while ensuring stability and security.
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
┌─────────────────────────────────────────────────────────────┐
|
|
13
|
-
│ Dependency Update Pipeline │
|
|
14
|
-
├─────────────────────────────────────────────────────────────┤
|
|
15
|
-
│ │
|
|
16
|
-
│ ┌─────────┐ ┌─────────┐ ┌─────────┐ ┌─────────┐ │
|
|
17
|
-
│ │ Scan │──►│ Analyze │──►│ Test │──►│ Apply │ │
|
|
18
|
-
│ └─────────┘ └─────────┘ └─────────┘ └─────────┘ │
|
|
19
|
-
│ │ │ │ │ │
|
|
20
|
-
│ ▼ ▼ ▼ ▼ │
|
|
21
|
-
│ Find updates Check risk Run tests Merge/PR │
|
|
22
|
-
│ Check vulns Compatibility Verify Notify │
|
|
23
|
-
│ │
|
|
24
|
-
│ Auto-merge: Patches with passing tests │
|
|
25
|
-
│ PR Review: Minor/Major updates │
|
|
26
|
-
│ Block: Security vulnerabilities │
|
|
27
|
-
│ │
|
|
28
|
-
└─────────────────────────────────────────────────────────────┘
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
---
|
|
32
|
-
|
|
33
|
-
## Quick Start
|
|
34
|
-
|
|
35
|
-
### Enable Auto-Updates
|
|
36
|
-
|
|
37
|
-
```yaml
|
|
38
|
-
# proagents.config.yaml
|
|
39
|
-
|
|
40
|
-
dependencies:
|
|
41
|
-
auto_update:
|
|
42
|
-
enabled: true
|
|
43
|
-
schedule: "weekly" # daily, weekly, monthly
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
### Run Manual Check
|
|
47
|
-
|
|
48
|
-
```bash
|
|
49
|
-
# Check for updates
|
|
50
|
-
proagents deps check
|
|
51
|
-
|
|
52
|
-
# Update all dependencies
|
|
53
|
-
proagents deps update
|
|
54
|
-
|
|
55
|
-
# Update specific package
|
|
56
|
-
proagents deps update lodash
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
---
|
|
60
|
-
|
|
61
|
-
## Features
|
|
62
|
-
|
|
63
|
-
| Feature | Description |
|
|
64
|
-
|---------|-------------|
|
|
65
|
-
| **Auto-Detection** | Detects package managers automatically |
|
|
66
|
-
| **Security Scanning** | Checks for vulnerabilities |
|
|
67
|
-
| **Compatibility Check** | Analyzes breaking changes |
|
|
68
|
-
| **Test Verification** | Runs tests before applying |
|
|
69
|
-
| **Rollback Support** | Easy rollback if issues occur |
|
|
70
|
-
| **PR Creation** | Creates PRs for review |
|
|
71
|
-
|
|
72
|
-
---
|
|
73
|
-
|
|
74
|
-
## Documentation Files
|
|
75
|
-
|
|
76
|
-
| File | Description |
|
|
77
|
-
|------|-------------|
|
|
78
|
-
| [update-policies.md](./update-policies.md) | Update policies and rules |
|
|
79
|
-
| [security-scanning.md](./security-scanning.md) | Vulnerability scanning |
|
|
80
|
-
| [compatibility.md](./compatibility.md) | Breaking change detection |
|
|
81
|
-
| [automation.md](./automation.md) | CI/CD integration |
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## Configuration
|
|
86
|
-
|
|
87
|
-
```yaml
|
|
88
|
-
# proagents.config.yaml
|
|
89
|
-
|
|
90
|
-
dependencies:
|
|
91
|
-
auto_update:
|
|
92
|
-
enabled: true
|
|
93
|
-
schedule: "weekly"
|
|
94
|
-
|
|
95
|
-
# Update policies by type
|
|
96
|
-
policies:
|
|
97
|
-
patch:
|
|
98
|
-
auto_merge: true
|
|
99
|
-
require_tests: true
|
|
100
|
-
|
|
101
|
-
minor:
|
|
102
|
-
auto_merge: false
|
|
103
|
-
require_review: true
|
|
104
|
-
require_tests: true
|
|
105
|
-
|
|
106
|
-
major:
|
|
107
|
-
auto_merge: false
|
|
108
|
-
require_review: true
|
|
109
|
-
require_manual_testing: true
|
|
110
|
-
|
|
111
|
-
# Security updates
|
|
112
|
-
security:
|
|
113
|
-
auto_merge: true
|
|
114
|
-
priority: "immediate"
|
|
115
|
-
notify: ["security-team"]
|
|
116
|
-
|
|
117
|
-
# Packages to ignore
|
|
118
|
-
ignore:
|
|
119
|
-
- "legacy-package"
|
|
120
|
-
- "@internal/*"
|
|
121
|
-
|
|
122
|
-
# Group updates
|
|
123
|
-
groups:
|
|
124
|
-
- name: "react"
|
|
125
|
-
packages: ["react", "react-dom"]
|
|
126
|
-
update_together: true
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
---
|
|
130
|
-
|
|
131
|
-
## Commands
|
|
132
|
-
|
|
133
|
-
| Command | Description |
|
|
134
|
-
|---------|-------------|
|
|
135
|
-
| `proagents deps check` | Check for available updates |
|
|
136
|
-
| `proagents deps update` | Update dependencies |
|
|
137
|
-
| `proagents deps audit` | Security audit |
|
|
138
|
-
| `proagents deps outdated` | List outdated packages |
|
|
139
|
-
| `proagents deps rollback` | Rollback recent update |
|
|
140
|
-
| `proagents deps lock` | Lock specific versions |
|