vovk-cli 0.0.1-draft.276 → 0.0.1-draft.277
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/utils/compileTs.mjs +12 -4
- package/package.json +1 -1
package/dist/utils/compileTs.mjs
CHANGED
|
@@ -18,8 +18,8 @@ export function compileTs(options) {
|
|
|
18
18
|
.map(([, typeDecl]) => typeDecl)
|
|
19
19
|
.join('\n\n');
|
|
20
20
|
return compiledRefs
|
|
21
|
-
? `${compiledRefs}\n\n${options.schema.description ? `/** ${options.schema.description} */\n` : ''}export type ${mainTypeName} = ${mainType};`
|
|
22
|
-
: `${options.schema.description ? `/** ${options.schema.description} */\n` : ''}export type ${mainTypeName} = ${mainType};`;
|
|
21
|
+
? `${compiledRefs}\n\n${options.schema.description ? `/** ${escapeJSDocComment(options.schema.description)} */\n` : ''}export type ${mainTypeName} = ${mainType};`
|
|
22
|
+
: `${options.schema.description ? `/** ${escapeJSDocComment(options.schema.description)} */\n` : ''}export type ${mainTypeName} = ${mainType};`;
|
|
23
23
|
}
|
|
24
24
|
function collectDefinitions(schema, refs) {
|
|
25
25
|
// Collect from $defs
|
|
@@ -153,7 +153,9 @@ function handleRef(ref, context) {
|
|
|
153
153
|
context.refsInProgress.add(ref);
|
|
154
154
|
// Compile the referenced schema
|
|
155
155
|
const compiledType = compileSchema(referencedSchema, typeName, context);
|
|
156
|
-
const description = referencedSchema.description
|
|
156
|
+
const description = referencedSchema.description
|
|
157
|
+
? `/** ${escapeJSDocComment(referencedSchema.description)} */\n`
|
|
158
|
+
: '';
|
|
157
159
|
context.compiledRefs.set(ref, `${description}export type ${typeName} = ${compiledType};`);
|
|
158
160
|
// Mark as completed
|
|
159
161
|
context.refsInProgress.delete(ref);
|
|
@@ -212,7 +214,7 @@ function handleObject(schema, name, context) {
|
|
|
212
214
|
const propType = compileSchema(propSchema, nestedTypeName, context);
|
|
213
215
|
const safePropName = /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(propName) ? propName : `"${propName}"`;
|
|
214
216
|
// Add JSDoc comment if description is present
|
|
215
|
-
const comment = propSchema.description ? `\n/** ${propSchema.description} */\n` : '';
|
|
217
|
+
const comment = propSchema.description ? `\n/** ${escapeJSDocComment(propSchema.description)} */\n` : '';
|
|
216
218
|
props.push(`${comment}${safePropName}${isRequired ? '' : '?'}: ${propType}`);
|
|
217
219
|
}
|
|
218
220
|
}
|
|
@@ -251,3 +253,9 @@ function wrapUnionType(type) {
|
|
|
251
253
|
function sanitizeTypeName(name) {
|
|
252
254
|
return upperFirst(camelCase(name));
|
|
253
255
|
}
|
|
256
|
+
// Utility function to escape JSDoc comment terminators in descriptions
|
|
257
|
+
function escapeJSDocComment(description) {
|
|
258
|
+
if (!description)
|
|
259
|
+
return '';
|
|
260
|
+
return description.replace(/\*\//g, '*\\/');
|
|
261
|
+
}
|