Files
klz-cables.com/.pnpm-store/v10/files/03/6ab7f2bc12cd52652ea139dd922bf45ce0c1586d0b7997d3df82df87c4cc79bb48d351dc664abcda3a71adbc48ae05e675c846e61833c34e237c73d13939c6
Marc Mintel 5397309103
Some checks failed
Build & Deploy / 🔍 Prepare (push) Successful in 20s
Build & Deploy / 🧪 QA (push) Failing after 34s
Build & Deploy / 🏗️ Build (push) Has started running
Build & Deploy / 🚀 Deploy (push) Has been cancelled
Build & Deploy / 🧪 Smoke Test (push) Has been cancelled
Build & Deploy / ⚡ Lighthouse (push) Has been cancelled
Build & Deploy / 🔔 Notify (push) Has been cancelled
fix(products): fix breadcrumbs and product filtering (backport from main)
2026-02-24 16:04:21 +01:00

172 lines
3.3 KiB
Plaintext

import {JSONSchema4Type} from 'json-schema'
export type AST_TYPE = AST['type']
export type AST =
| TAny
| TArray
| TBoolean
| TEnum
| TInterface
| TNamedInterface
| TIntersection
| TLiteral
| TNever
| TNumber
| TNull
| TObject
| TReference
| TString
| TTuple
| TUnion
| TUnknown
| TCustomType
export interface AbstractAST {
comment?: string
keyName?: string
standaloneName?: string
type: AST_TYPE
deprecated?: boolean
}
export type ASTWithComment = AST & {comment: string}
export type ASTWithName = AST & {keyName: string}
export type ASTWithStandaloneName = AST & {standaloneName: string}
export function hasComment(ast: AST): ast is ASTWithComment {
return (
('comment' in ast && ast.comment != null && ast.comment !== '') ||
// Compare to true because ast.deprecated might be undefined
('deprecated' in ast && ast.deprecated === true)
)
}
export function hasStandaloneName(ast: AST): ast is ASTWithStandaloneName {
return 'standaloneName' in ast && ast.standaloneName != null && ast.standaloneName !== ''
}
//////////////////////////////////////////// types
export interface TAny extends AbstractAST {
type: 'ANY'
}
export interface TArray extends AbstractAST {
type: 'ARRAY'
params: AST
}
export interface TBoolean extends AbstractAST {
type: 'BOOLEAN'
}
export interface TEnum extends AbstractAST {
standaloneName: string
type: 'ENUM'
params: TEnumParam[]
}
export interface TEnumParam {
ast: AST
keyName: string
}
export interface TInterface extends AbstractAST {
type: 'INTERFACE'
params: TInterfaceParam[]
superTypes: TNamedInterface[]
}
export interface TNamedInterface extends AbstractAST {
standaloneName: string
type: 'INTERFACE'
params: TInterfaceParam[]
superTypes: TNamedInterface[]
}
export interface TNever extends AbstractAST {
type: 'NEVER'
}
export interface TInterfaceParam {
ast: AST
keyName: string
isRequired: boolean
isPatternProperty: boolean
isUnreachableDefinition: boolean
}
export interface TIntersection extends AbstractAST {
type: 'INTERSECTION'
params: AST[]
}
export interface TLiteral extends AbstractAST {
params: JSONSchema4Type
type: 'LITERAL'
}
export interface TNumber extends AbstractAST {
type: 'NUMBER'
}
export interface TNull extends AbstractAST {
type: 'NULL'
}
export interface TObject extends AbstractAST {
type: 'OBJECT'
}
export interface TReference extends AbstractAST {
type: 'REFERENCE'
params: string
}
export interface TString extends AbstractAST {
type: 'STRING'
}
export interface TTuple extends AbstractAST {
type: 'TUPLE'
params: AST[]
spreadParam?: AST
minItems: number
maxItems?: number
}
export interface TUnion extends AbstractAST {
type: 'UNION'
params: AST[]
}
export interface TUnknown extends AbstractAST {
type: 'UNKNOWN'
}
export interface TCustomType extends AbstractAST {
type: 'CUSTOM_TYPE'
params: string
}
//////////////////////////////////////////// literals
export const T_ANY: TAny = {
type: 'ANY',
}
export const T_ANY_ADDITIONAL_PROPERTIES: TAny & ASTWithName = {
keyName: '[k: string]',
type: 'ANY',
}
export const T_UNKNOWN: TUnknown = {
type: 'UNKNOWN',
}
export const T_UNKNOWN_ADDITIONAL_PROPERTIES: TUnknown & ASTWithName = {
keyName: '[k: string]',
type: 'UNKNOWN',
}