@redocly/openapi-core
Advanced tools
Comparing version 1.0.0-beta.63 to 1.0.0-beta.64
@@ -22,2 +22,5 @@ "use strict"; | ||
} | ||
if (root.openapi && typeof root.openapi !== 'string') { | ||
throw new Error(`Invalid OpenAPI version: should be a string but got "${typeof root.openapi}"`); | ||
} | ||
if (root.openapi && root.openapi.startsWith('3.0')) { | ||
@@ -24,0 +27,0 @@ return OasVersion.Version3_0; |
@@ -5,2 +5,3 @@ "use strict"; | ||
const _1 = require("."); | ||
const utils_1 = require("../utils"); | ||
const ConfigRoot = { | ||
@@ -11,3 +12,3 @@ properties: { | ||
properties: {}, | ||
additionalProperties: { properties: { type: 'string' } } | ||
additionalProperties: { properties: { type: 'string' } }, | ||
}, | ||
@@ -92,17 +93,283 @@ lint: 'ConfigLint', | ||
}; | ||
const CommonThemeColors = { | ||
properties: { | ||
main: { type: 'string' }, | ||
light: { type: 'string' }, | ||
dark: { type: 'string' }, | ||
contrastText: { type: 'string' }, | ||
}, | ||
}; | ||
const CommonColorProps = { | ||
properties: { | ||
backgroundColor: { type: 'string' }, | ||
borderColor: { type: 'string' }, | ||
color: { type: 'string' }, | ||
tabTextColor: { type: 'string' }, | ||
}, | ||
}; | ||
const BorderThemeColors = { | ||
properties: utils_1.pickObjectProps(CommonThemeColors.properties, ['light', 'dark']), | ||
}; | ||
const HttpColors = { | ||
properties: { | ||
basic: { type: 'string' }, | ||
delete: { type: 'string' }, | ||
get: { type: 'string' }, | ||
head: { type: 'string' }, | ||
link: { type: 'string' }, | ||
options: { type: 'string' }, | ||
patch: { type: 'string' }, | ||
post: { type: 'string' }, | ||
put: { type: 'string' }, | ||
}, | ||
}; | ||
const ResponseColors = { | ||
properties: { | ||
errors: 'CommonColorProps', | ||
info: 'CommonColorProps', | ||
redirect: 'CommonColorProps', | ||
success: 'CommonColorProps', | ||
}, | ||
}; | ||
const SecondaryColors = { | ||
properties: utils_1.omitObjectProps(CommonThemeColors.properties, ['dark']), | ||
}; | ||
const TextThemeColors = { | ||
properties: { | ||
primary: { type: 'string' }, | ||
secondary: { type: 'string' }, | ||
light: { type: 'string' }, | ||
}, | ||
}; | ||
const ThemeColors = { | ||
properties: { | ||
accent: 'CommonThemeColors', | ||
border: 'BorderThemeColors', | ||
error: 'CommonThemeColors', | ||
http: 'HttpColors', | ||
primary: 'CommonThemeColors', | ||
responses: 'ResponseColors', | ||
secondary: 'SecondaryColors', | ||
success: 'CommonThemeColors', | ||
text: 'TextThemeColors', | ||
tonalOffset: { type: 'number' }, | ||
warning: 'CommonThemeColors', | ||
}, | ||
}; | ||
const SizeProps = { | ||
properties: { | ||
fontSize: { type: 'string' }, | ||
padding: { type: 'string' }, | ||
minWidth: { type: 'string' }, | ||
}, | ||
}; | ||
const Sizes = { | ||
properties: { | ||
small: 'SizeProps', | ||
medium: 'SizeProps', | ||
large: 'SizeProps', | ||
xlarge: 'SizeProps', | ||
}, | ||
}; | ||
const FontConfig = { | ||
properties: { | ||
fontFamily: { type: 'string' }, | ||
fontSize: { type: 'string' }, | ||
fontWeight: { type: 'string' }, | ||
lineHeight: { type: 'string' }, | ||
}, | ||
}; | ||
const ButtonsConfig = { | ||
properties: Object.assign(Object.assign({}, utils_1.omitObjectProps(FontConfig.properties, ['fontSize', 'lineHeight'])), { borderRadius: { type: 'string' }, hoverStyle: { type: 'string' }, boxShadow: { type: 'string' }, hoverBoxShadow: { type: 'string' }, sizes: 'Sizes' }), | ||
}; | ||
const BadgeFontConfig = { | ||
properties: utils_1.pickObjectProps(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
}; | ||
const BadgeSizes = { | ||
properties: { | ||
medium: 'BadgeFontConfig', | ||
small: 'BadgeFontConfig', | ||
}, | ||
}; | ||
const HttpBadgesConfig = { | ||
properties: Object.assign(Object.assign({}, utils_1.omitObjectProps(FontConfig.properties, ['fontSize', 'lineHeight'])), { borderRadius: { type: 'string' }, color: { type: 'string' }, sizes: 'BadgeSizes' }), | ||
}; | ||
const LabelControls = { | ||
properties: { | ||
top: { type: 'string' }, | ||
}, | ||
}; | ||
const Panels = { | ||
properties: { | ||
borderRadius: { type: 'string' }, | ||
}, | ||
}; | ||
const TryItButton = { | ||
properties: { | ||
fullWidth: { type: 'boolean' }, | ||
}, | ||
}; | ||
const Components = { | ||
properties: { | ||
buttons: 'ButtonsConfig', | ||
httpBadges: 'HttpBadgesConfig', | ||
layoutControls: 'LabelControls', | ||
panels: 'Panels', | ||
tryItButton: 'TryItButton', | ||
tryItSendButton: 'TryItButton', | ||
}, | ||
}; | ||
const Breakpoints = { | ||
properties: { | ||
small: { type: 'string' }, | ||
medium: { type: 'string' }, | ||
large: { type: 'string' }, | ||
}, | ||
}; | ||
const StackedConfig = { | ||
properties: { | ||
maxWidth: 'Breakpoints', | ||
}, | ||
}; | ||
const ThreePanelConfig = { | ||
properties: { | ||
maxWidth: 'Breakpoints', | ||
}, | ||
}; | ||
const Layout = { | ||
properties: { | ||
showDarkRightPanel: { type: 'boolean' }, | ||
stacked: 'StackedConfig', | ||
'three-panel': 'ThreePanelConfig', | ||
}, | ||
}; | ||
const SchemaColorsConfig = { | ||
properties: { | ||
backgroundColor: { type: 'string' }, | ||
border: { type: 'string' }, | ||
}, | ||
}; | ||
const Schema = { | ||
properties: { | ||
breakFieldNames: { type: 'boolean' }, | ||
caretColor: { type: 'string' }, | ||
caretSize: { type: 'string' }, | ||
constraints: 'SchemaColorsConfig', | ||
defaultDetailsWidth: { type: 'string' }, | ||
examples: 'SchemaColorsConfig', | ||
labelsTextSize: { type: 'string' }, | ||
linesColor: { type: 'string' }, | ||
nestedBackground: { type: 'string' }, | ||
nestingSpacing: { type: 'string' }, | ||
requireLabelColor: { type: 'string' }, | ||
typeNameColor: { type: 'string' }, | ||
typeTitleColor: { type: 'string' }, | ||
}, | ||
}; | ||
const GroupItemsConfig = { | ||
properties: { | ||
subItemsColor: { type: 'string' }, | ||
textTransform: { type: 'string' }, | ||
fontWeight: { type: 'string' }, | ||
}, | ||
}; | ||
const Level1Items = { | ||
properties: utils_1.pickObjectProps(GroupItemsConfig.properties, ['textTransform']), | ||
}; | ||
const SpacingConfig = { | ||
properties: { | ||
unit: { type: 'number' }, | ||
paddingHorizontal: { type: 'string' }, | ||
paddingVertical: { type: 'string' }, | ||
offsetTop: { type: 'string' }, | ||
offsetLeft: { type: 'string' }, | ||
offsetNesting: { type: 'string' }, | ||
}, | ||
}; | ||
const Sidebar = { | ||
properties: Object.assign(Object.assign({}, utils_1.omitObjectProps(FontConfig.properties, ['fontWeight', 'lineHeight'])), { activeBgColor: { type: 'string' }, activeTextColor: { type: 'string' }, backgroundColor: { type: 'string' }, borderRadius: { type: 'string' }, breakPath: { type: 'boolean' }, caretColor: { type: 'string' }, caretSize: { type: 'string' }, groupItems: 'GroupItemsConfig', level1items: 'Level1Items', rightLineColor: { type: 'string' }, separatorLabelColor: { type: 'string' }, showAtBreakpoint: { type: 'string' }, spacing: 'SpacingConfig', textColor: { type: 'string' }, width: { type: 'string' } }), | ||
}; | ||
const Heading = { | ||
properties: Object.assign(Object.assign({}, FontConfig.properties), { color: { type: 'string' }, transform: { type: 'string' } }), | ||
}; | ||
const CodeConfig = { | ||
properties: Object.assign(Object.assign({}, FontConfig.properties), { backgroundColor: { type: 'string' }, color: { type: 'string' }, wordBreak: { type: 'string' }, wrap: { type: 'boolean' } }), | ||
}; | ||
const HeadingsConfig = { | ||
properties: utils_1.omitObjectProps(FontConfig.properties, ['fontSize']), | ||
}; | ||
const LinksConfig = { | ||
properties: { | ||
color: { type: 'string' }, | ||
hover: { type: 'string' }, | ||
textDecoration: { type: 'string' }, | ||
visited: { type: 'string' }, | ||
}, | ||
}; | ||
const Typography = { | ||
properties: Object.assign(Object.assign({ code: 'CodeConfig', fieldName: 'FontConfig' }, utils_1.pickObjectProps(FontConfig.properties, ['fontSize', 'fontFamily'])), { fontWeightBold: { type: 'string' }, fontWeightLight: { type: 'string' }, fontWeightRegular: { type: 'string' }, heading1: 'Heading', heading2: 'Heading', heading3: 'Heading', headings: 'HeadingsConfig', lineHeight: { type: 'string' }, links: 'LinksConfig', optimizeSpeed: { type: 'boolean' }, rightPanelHeading: 'Heading', smoothing: { type: 'string' } }), | ||
}; | ||
const TokenProps = { | ||
properties: Object.assign({ color: { type: 'string' } }, utils_1.omitObjectProps(FontConfig.properties, ['fontWeight'])), | ||
}; | ||
const CodeBlock = { | ||
properties: { | ||
backgroundColor: { type: 'string' }, | ||
borderRadius: { type: 'string' }, | ||
tokens: 'TokenProps', | ||
}, | ||
}; | ||
const Logo = { | ||
properties: { | ||
gutter: { type: 'string' }, | ||
maxHeight: { type: 'string' }, | ||
maxWidth: { type: 'string' }, | ||
}, | ||
}; | ||
const ButtonOverrides = { | ||
properties: { | ||
custom: { type: 'string' }, | ||
}, | ||
}; | ||
const Overrides = { | ||
properties: { | ||
DownloadButton: 'ButtonOverrides', | ||
NextSectionButton: 'ButtonOverrides', | ||
}, | ||
}; | ||
const RightPanel = { | ||
properties: { | ||
backgroundColor: { type: 'string' }, | ||
panelBackgroundColor: { type: 'string' }, | ||
panelControlsBackgroundColor: { type: 'string' }, | ||
showAtBreakpoint: { type: 'string' }, | ||
textColor: { type: 'string' }, | ||
width: { type: 'string' }, | ||
}, | ||
}; | ||
const Shape = { | ||
properties: { borderRadius: { type: 'string' } }, | ||
}; | ||
const ThemeSpacing = { | ||
properties: { | ||
sectionHorizontal: { type: 'number' }, | ||
sectionVertical: { type: 'number' }, | ||
unit: { type: 'number' }, | ||
}, | ||
}; | ||
const ConfigTheme = { | ||
properties: { | ||
breakpoints: { type: 'object', additionalProperties: { type: 'string' } }, | ||
codeBlock: { type: 'object', additionalProperties: { type: 'string' } }, | ||
colors: { type: 'object', additionalProperties: { type: 'string' } }, | ||
components: { type: 'object', additionalProperties: { type: 'string' } }, | ||
layout: { type: 'object', additionalProperties: { type: 'string' } }, | ||
logo: { type: 'object', additionalProperties: { type: 'string' } }, | ||
overrides: { type: 'object', additionalProperties: { type: 'string' } }, | ||
rightPanel: { type: 'object', additionalProperties: { type: 'string' } }, | ||
schema: { type: 'object', additionalProperties: { type: 'string' } }, | ||
shape: { type: 'object', additionalProperties: { type: 'string' } }, | ||
sidebar: { type: 'object', additionalProperties: { type: 'string' } }, | ||
spacing: { type: 'object', additionalProperties: { type: 'string' } }, | ||
typography: { type: 'object', additionalProperties: { type: 'string' } }, | ||
breakpoints: 'Breakpoints', | ||
codeBlock: 'CodeBlock', | ||
colors: 'ThemeColors', | ||
components: 'Components', | ||
layout: 'Layout', | ||
logo: 'Logo', | ||
overrides: 'Overrides', | ||
rightPanel: 'RightPanel', | ||
schema: 'Schema', | ||
shape: 'Shape', | ||
sidebar: 'Sidebar', | ||
spacing: 'ThemeSpacing', | ||
typography: 'Typography', | ||
links: { properties: { color: { type: 'string' } } }, | ||
@@ -112,2 +379,8 @@ codeSample: { properties: { backgroundColor: { type: 'string' } } }, | ||
}; | ||
const GenerateCodeSamples = { | ||
properties: { | ||
skipOptionalParameters: { type: 'boolean' }, | ||
languages: _1.listOf('ConfigLanguage'), | ||
}, | ||
}; | ||
const ConfigReferenceDocs = { | ||
@@ -126,8 +399,3 @@ properties: { | ||
expandSingleSchemaField: { type: 'boolean' }, | ||
generateCodeSamples: { | ||
properties: { | ||
skipOptionalParameters: { type: 'boolean' }, | ||
languages: _1.listOf('ConfigLanguage'), | ||
}, | ||
}, | ||
generateCodeSamples: 'GenerateCodeSamples', | ||
generatedPayloadSamplesMaxDepth: { type: 'number' }, | ||
@@ -146,3 +414,3 @@ hideDownloadButton: { type: 'boolean' }, | ||
labels: 'ConfigLabels', | ||
layout: { type: 'object' }, | ||
layout: { type: 'string' }, | ||
maxDisplayedEnumValues: { type: 'number' }, | ||
@@ -195,2 +463,45 @@ menuToggle: { type: 'boolean' }, | ||
ConfigTheme, | ||
ThemeColors, | ||
CommonThemeColors, | ||
BorderThemeColors, | ||
HttpColors, | ||
ResponseColors, | ||
SecondaryColors, | ||
TextThemeColors, | ||
Sizes, | ||
ButtonsConfig, | ||
CommonColorProps, | ||
BadgeFontConfig, | ||
BadgeSizes, | ||
HttpBadgesConfig, | ||
LabelControls, | ||
Panels, | ||
TryItButton, | ||
Breakpoints, | ||
StackedConfig, | ||
ThreePanelConfig, | ||
SchemaColorsConfig, | ||
SizeProps, | ||
Level1Items, | ||
SpacingConfig, | ||
FontConfig, | ||
CodeConfig, | ||
HeadingsConfig, | ||
LinksConfig, | ||
TokenProps, | ||
CodeBlock, | ||
Logo, | ||
ButtonOverrides, | ||
Overrides, | ||
RightPanel, | ||
Shape, | ||
ThemeSpacing, | ||
GenerateCodeSamples, | ||
GroupItemsConfig, | ||
Components, | ||
Layout, | ||
Schema, | ||
Sidebar, | ||
Heading, | ||
Typography, | ||
}; |
@@ -23,1 +23,3 @@ import { HttpResolveConfig } from './config/config'; | ||
export declare function match(url: string, pattern: string): boolean; | ||
export declare function pickObjectProps<T extends Record<string, unknown>>(object: T, keys: Array<string>): T; | ||
export declare function omitObjectProps<T extends Record<string, unknown>>(object: T, keys: Array<string>): T; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.match = exports.readFileFromUrl = exports.isPlainObject = exports.notUndefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0; | ||
exports.omitObjectProps = exports.pickObjectProps = exports.match = exports.readFileFromUrl = exports.isPlainObject = exports.notUndefined = exports.loadYaml = exports.popStack = exports.pushStack = exports.stringifyYaml = exports.parseYaml = void 0; | ||
const fs = require("fs"); | ||
@@ -72,1 +72,9 @@ const minimatch = require("minimatch"); | ||
exports.match = match; | ||
function pickObjectProps(object, keys) { | ||
return Object.fromEntries(keys.filter((key) => key in object).map((key) => [key, object[key]])); | ||
} | ||
exports.pickObjectProps = pickObjectProps; | ||
function omitObjectProps(object, keys) { | ||
return Object.fromEntries(Object.entries(object).filter(([key]) => !keys.includes(key))); | ||
} | ||
exports.omitObjectProps = omitObjectProps; |
{ | ||
"name": "@redocly/openapi-core", | ||
"version": "1.0.0-beta.63", | ||
"version": "1.0.0-beta.64", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -90,2 +90,15 @@ import { outdent } from 'outdent'; | ||
}, | ||
Object { | ||
"location": Array [ | ||
Object { | ||
"pointer": "#/referenceDocs/layout", | ||
"reportOnKey": false, | ||
"source": "", | ||
}, | ||
], | ||
"message": "Expected type \`string\` but got \`object\`.", | ||
"ruleId": "spec", | ||
"severity": "error", | ||
"suggest": Array [], | ||
}, | ||
] | ||
@@ -92,0 +105,0 @@ `); |
@@ -37,2 +37,6 @@ import { | ||
if (root.openapi && typeof root.openapi !== 'string') { | ||
throw new Error(`Invalid OpenAPI version: should be a string but got "${typeof root.openapi}"`); | ||
} | ||
if (root.openapi && root.openapi.startsWith('3.0')) { | ||
@@ -39,0 +43,0 @@ return OasVersion.Version3_0; |
import { NodeType, listOf } from '.'; | ||
import { omitObjectProps, pickObjectProps } from '../utils'; | ||
@@ -8,3 +9,3 @@ const ConfigRoot: NodeType = { | ||
properties: {}, | ||
additionalProperties: { properties: { type: 'string' } } | ||
additionalProperties: { properties: { type: 'string' } }, | ||
}, | ||
@@ -95,22 +96,395 @@ lint: 'ConfigLint', | ||
const CommonThemeColors: NodeType = { | ||
properties: { | ||
main: { type: 'string' }, | ||
light: { type: 'string' }, | ||
dark: { type: 'string' }, | ||
contrastText: { type: 'string' }, | ||
}, | ||
}; | ||
const CommonColorProps: NodeType = { | ||
properties: { | ||
backgroundColor: { type: 'string' }, | ||
borderColor: { type: 'string' }, | ||
color: { type: 'string' }, | ||
tabTextColor: { type: 'string' }, | ||
}, | ||
}; | ||
const BorderThemeColors: NodeType = { | ||
properties: pickObjectProps(CommonThemeColors.properties, ['light', 'dark']), | ||
}; | ||
const HttpColors: NodeType = { | ||
properties: { | ||
basic: { type: 'string' }, | ||
delete: { type: 'string' }, | ||
get: { type: 'string' }, | ||
head: { type: 'string' }, | ||
link: { type: 'string' }, | ||
options: { type: 'string' }, | ||
patch: { type: 'string' }, | ||
post: { type: 'string' }, | ||
put: { type: 'string' }, | ||
}, | ||
}; | ||
const ResponseColors: NodeType = { | ||
properties: { | ||
errors: 'CommonColorProps', | ||
info: 'CommonColorProps', | ||
redirect: 'CommonColorProps', | ||
success: 'CommonColorProps', | ||
}, | ||
}; | ||
const SecondaryColors: NodeType = { | ||
properties: omitObjectProps(CommonThemeColors.properties, ['dark']), | ||
}; | ||
const TextThemeColors: NodeType = { | ||
properties: { | ||
primary: { type: 'string' }, | ||
secondary: { type: 'string' }, | ||
light: { type: 'string' }, | ||
}, | ||
}; | ||
const ThemeColors: NodeType = { | ||
properties: { | ||
accent: 'CommonThemeColors', | ||
border: 'BorderThemeColors', | ||
error: 'CommonThemeColors', | ||
http: 'HttpColors', | ||
primary: 'CommonThemeColors', | ||
responses: 'ResponseColors', | ||
secondary: 'SecondaryColors', | ||
success: 'CommonThemeColors', | ||
text: 'TextThemeColors', | ||
tonalOffset: { type: 'number' }, | ||
warning: 'CommonThemeColors', | ||
}, | ||
}; | ||
const SizeProps: NodeType = { | ||
properties: { | ||
fontSize: { type: 'string' }, | ||
padding: { type: 'string' }, | ||
minWidth: { type: 'string' }, | ||
}, | ||
}; | ||
const Sizes: NodeType = { | ||
properties: { | ||
small: 'SizeProps', | ||
medium: 'SizeProps', | ||
large: 'SizeProps', | ||
xlarge: 'SizeProps', | ||
}, | ||
}; | ||
const FontConfig: NodeType = { | ||
properties: { | ||
fontFamily: { type: 'string' }, | ||
fontSize: { type: 'string' }, | ||
fontWeight: { type: 'string' }, | ||
lineHeight: { type: 'string' }, | ||
}, | ||
}; | ||
const ButtonsConfig: NodeType = { | ||
properties: { | ||
...omitObjectProps(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
borderRadius: { type: 'string' }, | ||
hoverStyle: { type: 'string' }, | ||
boxShadow: { type: 'string' }, | ||
hoverBoxShadow: { type: 'string' }, | ||
sizes: 'Sizes', | ||
}, | ||
}; | ||
const BadgeFontConfig: NodeType = { | ||
properties: pickObjectProps(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
}; | ||
const BadgeSizes: NodeType = { | ||
properties: { | ||
medium: 'BadgeFontConfig', | ||
small: 'BadgeFontConfig', | ||
}, | ||
}; | ||
const HttpBadgesConfig: NodeType = { | ||
properties: { | ||
...omitObjectProps(FontConfig.properties, ['fontSize', 'lineHeight']), | ||
borderRadius: { type: 'string' }, | ||
color: { type: 'string' }, | ||
sizes: 'BadgeSizes', | ||
}, | ||
}; | ||
const LabelControls: NodeType = { | ||
properties: { | ||
top: { type: 'string' }, | ||
}, | ||
}; | ||
const Panels: NodeType = { | ||
properties: { | ||
borderRadius: { type: 'string' }, | ||
}, | ||
}; | ||
const TryItButton: NodeType = { | ||
properties: { | ||
fullWidth: { type: 'boolean' }, | ||
}, | ||
}; | ||
const Components: NodeType = { | ||
properties: { | ||
buttons: 'ButtonsConfig', | ||
httpBadges: 'HttpBadgesConfig', | ||
layoutControls: 'LabelControls', | ||
panels: 'Panels', | ||
tryItButton: 'TryItButton', | ||
tryItSendButton: 'TryItButton', | ||
}, | ||
}; | ||
const Breakpoints: NodeType = { | ||
properties: { | ||
small: { type: 'string' }, | ||
medium: { type: 'string' }, | ||
large: { type: 'string' }, | ||
}, | ||
}; | ||
const StackedConfig: NodeType = { | ||
properties: { | ||
maxWidth: 'Breakpoints', | ||
}, | ||
}; | ||
const ThreePanelConfig: NodeType = { | ||
properties: { | ||
maxWidth: 'Breakpoints', | ||
}, | ||
}; | ||
const Layout: NodeType = { | ||
properties: { | ||
showDarkRightPanel: { type: 'boolean' }, | ||
stacked: 'StackedConfig', | ||
'three-panel': 'ThreePanelConfig', | ||
}, | ||
}; | ||
const SchemaColorsConfig: NodeType = { | ||
properties: { | ||
backgroundColor: { type: 'string' }, | ||
border: { type: 'string' }, | ||
}, | ||
}; | ||
const Schema: NodeType = { | ||
properties: { | ||
breakFieldNames: { type: 'boolean' }, | ||
caretColor: { type: 'string' }, | ||
caretSize: { type: 'string' }, | ||
constraints: 'SchemaColorsConfig', | ||
defaultDetailsWidth: { type: 'string' }, | ||
examples: 'SchemaColorsConfig', | ||
labelsTextSize: { type: 'string' }, | ||
linesColor: { type: 'string' }, | ||
nestedBackground: { type: 'string' }, | ||
nestingSpacing: { type: 'string' }, | ||
requireLabelColor: { type: 'string' }, | ||
typeNameColor: { type: 'string' }, | ||
typeTitleColor: { type: 'string' }, | ||
}, | ||
}; | ||
const GroupItemsConfig: NodeType = { | ||
properties: { | ||
subItemsColor: { type: 'string' }, | ||
textTransform: { type: 'string' }, | ||
fontWeight: { type: 'string' }, | ||
}, | ||
}; | ||
const Level1Items: NodeType = { | ||
properties: pickObjectProps(GroupItemsConfig.properties, ['textTransform']), | ||
}; | ||
const SpacingConfig: NodeType = { | ||
properties: { | ||
unit: { type: 'number' }, | ||
paddingHorizontal: { type: 'string' }, | ||
paddingVertical: { type: 'string' }, | ||
offsetTop: { type: 'string' }, | ||
offsetLeft: { type: 'string' }, | ||
offsetNesting: { type: 'string' }, | ||
}, | ||
}; | ||
const Sidebar: NodeType = { | ||
properties: { | ||
...omitObjectProps(FontConfig.properties, ['fontWeight', 'lineHeight']), | ||
activeBgColor: { type: 'string' }, | ||
activeTextColor: { type: 'string' }, | ||
backgroundColor: { type: 'string' }, | ||
borderRadius: { type: 'string' }, | ||
breakPath: { type: 'boolean' }, | ||
caretColor: { type: 'string' }, | ||
caretSize: { type: 'string' }, | ||
groupItems: 'GroupItemsConfig', | ||
level1items: 'Level1Items', | ||
rightLineColor: { type: 'string' }, | ||
separatorLabelColor: { type: 'string' }, | ||
showAtBreakpoint: { type: 'string' }, | ||
spacing: 'SpacingConfig', | ||
textColor: { type: 'string' }, | ||
width: { type: 'string' }, | ||
}, | ||
}; | ||
const Heading: NodeType = { | ||
properties: { | ||
...FontConfig.properties, | ||
color: { type: 'string' }, | ||
transform: { type: 'string' }, | ||
}, | ||
}; | ||
const CodeConfig: NodeType = { | ||
properties: { | ||
...FontConfig.properties, | ||
backgroundColor: { type: 'string' }, | ||
color: { type: 'string' }, | ||
wordBreak: { type: 'string' }, | ||
wrap: { type: 'boolean' }, | ||
}, | ||
}; | ||
const HeadingsConfig: NodeType = { | ||
properties: omitObjectProps(FontConfig.properties, ['fontSize']), | ||
}; | ||
const LinksConfig: NodeType = { | ||
properties: { | ||
color: { type: 'string' }, | ||
hover: { type: 'string' }, | ||
textDecoration: { type: 'string' }, | ||
visited: { type: 'string' }, | ||
}, | ||
}; | ||
const Typography: NodeType = { | ||
properties: { | ||
code: 'CodeConfig', | ||
fieldName: 'FontConfig', | ||
...pickObjectProps(FontConfig.properties, ['fontSize', 'fontFamily']), | ||
fontWeightBold: { type: 'string' }, | ||
fontWeightLight: { type: 'string' }, | ||
fontWeightRegular: { type: 'string' }, | ||
heading1: 'Heading', | ||
heading2: 'Heading', | ||
heading3: 'Heading', | ||
headings: 'HeadingsConfig', | ||
lineHeight: { type: 'string' }, | ||
links: 'LinksConfig', | ||
optimizeSpeed: { type: 'boolean' }, | ||
rightPanelHeading: 'Heading', | ||
smoothing: { type: 'string' }, | ||
}, | ||
}; | ||
const TokenProps: NodeType = { | ||
properties: { | ||
color: { type: 'string' }, | ||
...omitObjectProps(FontConfig.properties, ['fontWeight']), | ||
}, | ||
}; | ||
const CodeBlock: NodeType = { | ||
properties: { | ||
backgroundColor: { type: 'string' }, | ||
borderRadius: { type: 'string' }, | ||
tokens: 'TokenProps', | ||
}, | ||
}; | ||
const Logo: NodeType = { | ||
properties: { | ||
gutter: { type: 'string' }, | ||
maxHeight: { type: 'string' }, | ||
maxWidth: { type: 'string' }, | ||
}, | ||
}; | ||
const ButtonOverrides: NodeType = { | ||
properties: { | ||
custom: { type: 'string' }, | ||
}, | ||
}; | ||
const Overrides: NodeType = { | ||
properties: { | ||
DownloadButton: 'ButtonOverrides', | ||
NextSectionButton: 'ButtonOverrides', | ||
}, | ||
}; | ||
const RightPanel: NodeType = { | ||
properties: { | ||
backgroundColor: { type: 'string' }, | ||
panelBackgroundColor: { type: 'string' }, | ||
panelControlsBackgroundColor: { type: 'string' }, | ||
showAtBreakpoint: { type: 'string' }, | ||
textColor: { type: 'string' }, | ||
width: { type: 'string' }, | ||
}, | ||
}; | ||
const Shape: NodeType = { | ||
properties: { borderRadius: { type: 'string' } }, | ||
}; | ||
const ThemeSpacing: NodeType = { | ||
properties: { | ||
sectionHorizontal: { type: 'number' }, | ||
sectionVertical: { type: 'number' }, | ||
unit: { type: 'number' }, | ||
}, | ||
}; | ||
const ConfigTheme: NodeType = { | ||
properties: { | ||
breakpoints: { type: 'object', additionalProperties: { type: 'string' } }, | ||
codeBlock: { type: 'object', additionalProperties: { type: 'string' } }, | ||
colors: { type: 'object', additionalProperties: { type: 'string' } }, | ||
components: { type: 'object', additionalProperties: { type: 'string' } }, | ||
layout: { type: 'object', additionalProperties: { type: 'string' } }, | ||
logo: { type: 'object', additionalProperties: { type: 'string' } }, | ||
overrides: { type: 'object', additionalProperties: { type: 'string' } }, | ||
rightPanel: { type: 'object', additionalProperties: { type: 'string' } }, | ||
schema: { type: 'object', additionalProperties: { type: 'string' } }, | ||
shape: { type: 'object', additionalProperties: { type: 'string' } }, | ||
sidebar: { type: 'object', additionalProperties: { type: 'string' } }, | ||
spacing: { type: 'object', additionalProperties: { type: 'string' } }, | ||
typography: { type: 'object', additionalProperties: { type: 'string' } }, | ||
breakpoints: 'Breakpoints', | ||
codeBlock: 'CodeBlock', | ||
colors: 'ThemeColors', | ||
components: 'Components', | ||
layout: 'Layout', | ||
logo: 'Logo', | ||
overrides: 'Overrides', | ||
rightPanel: 'RightPanel', | ||
schema: 'Schema', | ||
shape: 'Shape', | ||
sidebar: 'Sidebar', | ||
spacing: 'ThemeSpacing', | ||
typography: 'Typography', | ||
links: { properties: { color: { type: 'string' } } }, | ||
codeSample: { properties: { backgroundColor: { type: 'string' } } }, | ||
}, | ||
} | ||
}; | ||
const GenerateCodeSamples: NodeType = { | ||
properties: { | ||
skipOptionalParameters: { type: 'boolean' }, | ||
languages: listOf('ConfigLanguage'), | ||
}, | ||
}; | ||
const ConfigReferenceDocs: NodeType = { | ||
@@ -129,8 +503,3 @@ properties: { | ||
expandSingleSchemaField: { type: 'boolean' }, | ||
generateCodeSamples: { | ||
properties: { | ||
skipOptionalParameters: { type: 'boolean' }, | ||
languages: listOf('ConfigLanguage'), | ||
}, | ||
}, | ||
generateCodeSamples: 'GenerateCodeSamples', | ||
generatedPayloadSamplesMaxDepth: { type: 'number' }, | ||
@@ -149,3 +518,3 @@ hideDownloadButton: { type: 'boolean' }, | ||
labels: 'ConfigLabels', | ||
layout: { type: 'object' }, | ||
layout: { type: 'string' }, | ||
maxDisplayedEnumValues: { type: 'number' }, | ||
@@ -199,2 +568,45 @@ menuToggle: { type: 'boolean' }, | ||
ConfigTheme, | ||
ThemeColors, | ||
CommonThemeColors, | ||
BorderThemeColors, | ||
HttpColors, | ||
ResponseColors, | ||
SecondaryColors, | ||
TextThemeColors, | ||
Sizes, | ||
ButtonsConfig, | ||
CommonColorProps, | ||
BadgeFontConfig, | ||
BadgeSizes, | ||
HttpBadgesConfig, | ||
LabelControls, | ||
Panels, | ||
TryItButton, | ||
Breakpoints, | ||
StackedConfig, | ||
ThreePanelConfig, | ||
SchemaColorsConfig, | ||
SizeProps, | ||
Level1Items, | ||
SpacingConfig, | ||
FontConfig, | ||
CodeConfig, | ||
HeadingsConfig, | ||
LinksConfig, | ||
TokenProps, | ||
CodeBlock, | ||
Logo, | ||
ButtonOverrides, | ||
Overrides, | ||
RightPanel, | ||
Shape, | ||
ThemeSpacing, | ||
GenerateCodeSamples, | ||
GroupItemsConfig, | ||
Components, | ||
Layout, | ||
Schema, | ||
Sidebar, | ||
Heading, | ||
Typography, | ||
}; |
@@ -68,1 +68,17 @@ import * as fs from 'fs'; | ||
} | ||
export function pickObjectProps<T extends Record<string, unknown>>( | ||
object: T, | ||
keys: Array<string>, | ||
): T { | ||
return Object.fromEntries( | ||
keys.filter((key: string) => key in object).map((key: string) => [key, object[key]]), | ||
) as T; | ||
} | ||
export function omitObjectProps<T extends Record<string, unknown>>( | ||
object: T, | ||
keys: Array<string>, | ||
): T { | ||
return Object.fromEntries(Object.entries(object).filter(([key]) => !keys.includes(key))) as T; | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1874974
337
23009