UNPKG

@fibery/ai-utils

Version:

Utilities for Fibery AI

96 lines (95 loc) 2.45 kB
import { TypeObject, FieldObject, Schema } from '@fibery/schema'; export type FormulaField = { expression?: any; params?: Record<string, any>; [key: string]: any; }; export type ProcessedField = { relation?: 'many-to-many' | 'many-to-one'; type: string; field?: string; formulaText?: string; values?: string[]; defaultValue?: string | null; getFinalStateNames?: () => any[]; }; export type ProcessedType = { color: string; fields: Record<string, string | ProcessedField>; description: string; }; export type ProcessedApp = { [typeName: string]: ProcessedType; }; export type DataTypeMap = { [typeName: string]: { type: TypeObject; fields: { [fieldName: string]: { type: TypeObject; fieldType: string | ProcessedField; field: FieldObject; }; }; }; }; export type EnumValues = string[] & { getDefaultValue: () => string | null; getFinalStateNames: () => any[]; }; export type Enums = { [typeName: string]: EnumValues; }; export type EnumFetcher = (type: TypeObject) => Promise<{ id: string; name: string; rank: string; color: string; }[]>; export type TemplateField = { name: string; type: string | ProcessedField; isManyToMany?: boolean; values?: string[] | null; formulaText?: string; defaultValue?: string | null; }; export type TemplateType = { name: string; description: string; fields: TemplateField[]; }; export type TemplateData = { schema: ProcessedApp; types: TemplateType[]; compact?: boolean; nonExistentTypes?: string[]; dataTypeMap?: DataTypeMap; }; export type OverrideFieldNameFunc = (params: { type: TypeObject; field: FieldObject; typeName: string; fieldType: string | ProcessedField; fieldName: string; }) => { name?: string; type?: string | ProcessedField; } | undefined; export type ProcessSchemaParams = { typeObjects: TypeObject[]; compact?: boolean; fiberySchema: Schema; overrideFieldNameType?: OverrideFieldNameFunc; includeEnumId?: boolean; fetchEnums?: EnumFetcher; }; export type GetSchemaStringParams = { typeObjects: TypeObject[]; schema: Schema; nonExistentTypes?: string[]; compact?: boolean; overrideFieldNameType?: OverrideFieldNameFunc; includeEnumId?: boolean; fetchEnums?: EnumFetcher; };