From 5d0d08f2a6d50d76b56ee38b13474e421c90ac95 Mon Sep 17 00:00:00 2001 From: vanilla-wave Date: Mon, 14 Apr 2025 18:27:28 +0200 Subject: [PATCH] prototype: structure typings --- src/lib/config/models.ts | 22 ++++++++++++++++++++++ src/lib/domain/models.ts | 13 +++++++++++++ src/lib/yaml/models.ts | 1 + 3 files changed, 36 insertions(+) diff --git a/src/lib/config/models.ts b/src/lib/config/models.ts index 9cae73d..718bb71 100644 --- a/src/lib/config/models.ts +++ b/src/lib/config/models.ts @@ -33,8 +33,29 @@ export const treeDecoder = d.struct({ export const metaDecoder = d.partial({ attributes: d.array(attributeDecoder), trees: d.array(treeDecoder), + structures: d.array(treeDecoder), }); +interface DirType { + title: string; + id: string; + dirs: Array; +} + +const dirDecoder: d.Decoder = d.lazy('dirDecoder', () => + d.struct({ + title: d.string, + id: d.string, + dirs: d.array(dirDecoder), + }), +); + +export const structureDecoder = d.struct({ + title: d.string, + id: d.string, + dirs: d.array(dirDecoder), +}) + // config export const apiConfigDecoder = d.struct({ host: d.string, @@ -125,5 +146,6 @@ export type ValidationSeverity = d.TypeOf; export type Meta = d.TypeOf; export type Tree = d.TypeOf; +export type Structure = d.TypeOf; export type Attribute = d.TypeOf; export type AttributeValue = d.TypeOf; diff --git a/src/lib/domain/models.ts b/src/lib/domain/models.ts index f143ea8..d9c2a69 100644 --- a/src/lib/domain/models.ts +++ b/src/lib/domain/models.ts @@ -45,10 +45,23 @@ export interface Tree { attributes: string[]; } +interface StructureDir { + title: string; + id: string; + dirs: StructureDir[]; +} + +export type Structure = { + title: string; + id: string; + dirs: StructureDir[]; +} + export interface ProjectData { features: Feature[]; attributes?: Attribute[]; trees?: Tree[]; + structure?: Structure; metaFilePath: string; } diff --git a/src/lib/yaml/models.ts b/src/lib/yaml/models.ts index 850a314..98a07de 100644 --- a/src/lib/yaml/models.ts +++ b/src/lib/yaml/models.ts @@ -19,6 +19,7 @@ export const entityDecoder = d.intersect( }), )( d.partial({ + path: d.string, type: featureTypeDecoder, 'specs-unit': d.record(d.array(assertionDecoder)), definitions: d.record(d.array(d.string)),