Skip to content

Commit 7914b5e

Browse files
Copilothotlong
andcommitted
fix: Address code review feedback — JSDoc formatting, PURL encoding, schema detection
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 0999704 commit 7914b5e

4 files changed

Lines changed: 8 additions & 6 deletions

File tree

packages/cli/src/commands/generate.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,9 @@ function generateTypesFromConfig(config: Record<string, unknown>): string {
290290
const fType = String(fieldDef.type || 'text');
291291
const tsType = fieldTypeToTs(fType, !!fieldDef.multiple);
292292
const required = fieldDef.required ? '' : '?';
293-
const desc = fieldDef.label ? ` /** ${fieldDef.label} */` : '';
294-
lines.push(`${desc}`);
293+
if (fieldDef.label) {
294+
lines.push(` /** ${fieldDef.label} */`);
295+
}
295296
lines.push(` ${fieldName}${required}: ${tsType};`);
296297
}
297298

packages/spec/scripts/build-openapi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,9 @@ function generateComponentSchemas(): Record<string, Record<string, unknown>> {
252252
};
253253

254254
for (const [name, schema] of Object.entries(contractSchemas)) {
255-
if (schema instanceof z.ZodType) {
255+
if (schema && typeof schema === 'object' && '_zod' in schema) {
256256
try {
257-
schemas[name] = z.toJSONSchema(schema, { target: 'draft-2020-12' });
257+
schemas[name] = z.toJSONSchema(schema as z.ZodType, { target: 'draft-2020-12' });
258258
} catch {
259259
schemas[name] = { type: 'object', description: `${name} (schema too complex for auto-generation)` };
260260
}

packages/spec/scripts/generate-sbom.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ for (const [name, info] of deps) {
156156
type: 'library',
157157
name,
158158
version: info.version,
159-
purl: `pkg:npm/${name.replace('/', '%2F')}@${info.version}`,
159+
purl: `pkg:npm/${encodeURIComponent(name)}@${info.version}`,
160160
licenses: license !== 'UNKNOWN' ? [{ license: { id: license } }] : [],
161161
description: undefined,
162162
});

packages/spec/src/benchmark.bench.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@
88
*/
99

1010
import { bench, describe } from 'vitest';
11+
// Benchmark uses `as any` for schema access since schemas use Object.assign
12+
// patterns that complicate direct typing. This is acceptable for benchmarks.
1113
import * as Data from './data';
1214
import * as UI from './ui';
13-
import * as System from './system';
1415
import * as Kernel from './kernel';
1516
import * as API from './api';
1617
import * as AI from './ai';

0 commit comments

Comments
 (0)