* update to eslint 6.8.0 and related packages * Fixes for no-prototype-builtins * Updates for explicit-function-return-type * Add ignores for no-explicit-any * update to eslint 6.8.0 and related packages * Fixes for no-prototype-builtins * Updates for explicit-function-return-type * Add ignores for no-explicit-any * package: activate eslint-config-standard * apply updated eslint configuration * lint: apply eslint feedback after rebase * Update lockfile * Update lockfile * Restore missing deps * Update lockfile * Re-add eslint-plugin-node * Add eslint-plugin-standard and eslint-plugin-react-hooks * Clean lint Co-authored-by: Paul Melnikow <github@paulmelnikow.com>
77 lines
1.5 KiB
TypeScript
77 lines
1.5 KiB
TypeScript
import groupBy from 'lodash.groupby'
|
|
// load using js-yaml-loader
|
|
import definitions from '../../../service-definitions.yml'
|
|
|
|
export interface Category {
|
|
id: string
|
|
name: string
|
|
keywords: string[]
|
|
}
|
|
|
|
export interface ExampleSignature {
|
|
pattern: string
|
|
namedParams: { [k: string]: string }
|
|
queryParams: { [k: string]: string }
|
|
}
|
|
|
|
export interface Preview {
|
|
label?: string
|
|
message: string
|
|
color: string
|
|
style?: string
|
|
namedLogo?: string
|
|
}
|
|
|
|
export interface Example {
|
|
title: string
|
|
example: ExampleSignature
|
|
preview: Preview
|
|
keywords: string[]
|
|
documentation?: {
|
|
__html: string
|
|
}
|
|
}
|
|
|
|
export interface Route {
|
|
pattern: string
|
|
queryParams: string[]
|
|
}
|
|
|
|
export interface LegacyRoute {
|
|
format: string
|
|
queryParams: string[]
|
|
}
|
|
|
|
export interface ServiceDefinition {
|
|
category: string
|
|
name: string
|
|
isDeprecated: boolean
|
|
route: Route | LegacyRoute
|
|
examples: Example[]
|
|
}
|
|
|
|
export const services = definitions.services as ServiceDefinition[]
|
|
export const categories = definitions.categories as Category[]
|
|
|
|
export function findCategory(category: string): Category | undefined {
|
|
return categories.find(({ id }) => id === category)
|
|
}
|
|
|
|
const byCategory = groupBy(services, 'category')
|
|
export function getDefinitionsForCategory(
|
|
category: string
|
|
): ServiceDefinition[] {
|
|
return byCategory[category] || []
|
|
}
|
|
|
|
export interface Suggestion {
|
|
title: string
|
|
link: string
|
|
example: ExampleSignature
|
|
preview: {
|
|
style?: string
|
|
}
|
|
}
|
|
|
|
export type RenderableExample = Example | Suggestion
|