UNPKG

@kontent-ai/model-generator

Version:

This utility generates strongly-typed models for Delivery JS SDK, Migration toolkit or just general scripting to improve the experience when referencing Kontent.ai related objects.

45 lines 1.49 kB
import { sdkInfo } from "../sdk-info.js"; export function wrapComment(comment, options) { if (options.disableComments) { return ""; } const nonEmptyLines = options.lines?.filter((m) => m.value) ?? []; if (!nonEmptyLines.length) { return `/*\n* ${toSafeCommentText(comment)}\n*/`; } return `/* * ${toSafeCommentText(comment)} * ${nonEmptyLines.map((m) => `* ${m.name}: ${m.value}`).join("\n")} */`; } export function toSafeCommentText(text) { const replaceContent = ""; return text.replace(/\/\*/g, replaceContent).replace(/\*\//g, replaceContent); } export function formatGuidelinesComment(guidelines) { return removeLineEndings(guidelines); } export function getEnvironmentInfoComment(data) { if (data.disableComments) { return ""; } return ` /* * This file has been auto-generated by '${sdkInfo.name}@${sdkInfo.version}'. * * (c) Kontent.ai * * ------------------------------------------------------------------------------- * * Project: ${toSafeCommentText(data.environmentInfo.name)} * Environment: ${toSafeCommentText(data.environmentInfo.environment)} * Id: ${data.environmentInfo.id}${data.timestampDate ? `\n* Generated: ${data.timestampDate.toLocaleString()}` : ""} * * ------------------------------------------------------------------------------- */`; } function removeLineEndings(value) { return value.replace(/(\r\n|\n|\r)/g, " "); } //# sourceMappingURL=comment.utils.js.map