import { SchemaBase } from './dsl.js'; // Dictionary definitions: vocabulary shared across the team — what a term // means and what it is called. /** Kind of a dictionary entry: which naming rule the phrase participates in. */ export enum DictionaryEntryType { Entity = 'entity', Business = 'business', } /** A vocabulary entry. */ export interface DictionaryEntry extends SchemaBase { /** * Entry kind. Entity phrases (abbreviation of an entity, e.g. mer) must be * the FIRST segment of a field name; business phrases (attribute of an * entity, e.g. rate) must be the LAST segment. */ type: DictionaryEntryType; /** Display label (Chinese) for the term. */ label?: string; } /** An entity phrase entry — type narrowed to Entity. */ export interface EntityPhrase extends DictionaryEntry { type: DictionaryEntryType.Entity; } /** * Explains an entity phrase — the returned entry IS the phrase. `name` is the * phrase itself (column-name stem, e.g. mer / bd), not a full entity name; * label/description explain what it means. Convention: short phrase, not long * name. Entity phrases appear as the first segment of a field name (mer_id). */ export function defineEntityPhrase(extra: Omit): EntityPhrase { return { type: DictionaryEntryType.Entity, ...extra }; } /** * Explains a business phrase (an attribute of an entity) — the returned entry * IS the phrase. `name` is the phrase itself (column-name stem, e.g. amt / * rate). Business phrases appear as the last segment of a field name (bd_rate). */ export function defineBusinessPhrase(extra: Omit): DictionaryEntry { return { type: DictionaryEntryType.Business, ...extra }; }