import { RecordKey, RecordLocation, ResolvedType } from "soiac"; import { ClassName } from "./class_speller.js"; import { TsType } from "./ts_type.js"; import { TypeFlavor, TypeSpeller } from "./type_speller.js"; /** * A `RecordInfo` contains all the information required for generating * TypeScript classes for a given struct or enum. */ export type RecordInfo = StructInfo | EnumInfo; export interface StructInfo { readonly recordType: "struct"; readonly className: ClassName; readonly nestedRecords: readonly RecordKey[]; readonly removedNumbers: readonly number[]; /** Fields sorted by number. */ readonly fields: readonly StructField[]; /** * Subset of the fields which must should have a mutable getter generated in * the Mutable class. */ readonly fieldsWithMutableGetter: readonly StructField[]; /** Subset of the fields which are indexable. */ readonly indexableFields: readonly StructField[]; } export interface EnumInfo { readonly recordType: "enum"; readonly className: ClassName; readonly nestedRecords: readonly RecordKey[]; readonly removedNumbers: readonly number[]; /** True if all the fields of the enum are constant fields. */ readonly onlyConstants: boolean; readonly constantFields: readonly EnumConstantField[]; readonly wrapperFields: readonly EnumWrapperField[]; readonly kindType: TsType; /** Union of `undefined` and the frozen type of all the wrapper fields */ readonly valueType: TsType; readonly initializerType: TsType; readonly valueOnlyInitializerType: TsType; readonly unionViewType: TsType; } export interface StructField { /** * Name of the generated property for this field, in lowerCamel format. * Note that it might be a typescript keyword, because TypeScript allows * property names to be keywords. */ readonly property: string; /** * Name of the field as it appears in the `.soia` file, in lower_case format. * You probably meant to use `property`. */ readonly originalName: string; /** True if a mutable getter should be generated in the Mutable class. */ readonly hasMutableGetter: boolean; /** Name of the mutableX() generated method in the Mutable class. */ readonly mutableGetterName: string; /** Name of the search method generated in the frozen class. */ readonly searchMethodName: string; readonly number: number; /** Schema field type, e.g. `int32`. */ readonly type: ResolvedType; /** * True if the field type depends on the struct where the field is defined. */ readonly isRecursive: boolean; /** Matching TypeScript type for each type flavor. */ readonly tsTypes: Readonly>; /** Set if the field has keyed array type. */ readonly indexable?: Indexable; } export interface Indexable { readonly keyType: TsType; /** The key expression. References the value as `v`. */ keyExpression: string; /** * Transforms the key into a hashable value, meaning a value which can be * stored in a Set. References the key as `k`. */ hashableExpression: string; frozenValueType: TsType; /** Name of the only parameter of the search method. */ readonly searchMethodParamName: string; } export type EnumField = EnumConstantField | EnumWrapperField; export interface EnumConstantField { readonly isConstant: true; readonly name: string; readonly quotedName: string; readonly property: string; readonly number: number; } export interface EnumWrapperField { readonly isConstant: false; readonly name: string; readonly quotedName: string; readonly number: number; readonly type: ResolvedType; readonly isRecursive: boolean; readonly tsTypes: Readonly>; } export declare function createRecordInfo(record: RecordLocation, typeSpeller: TypeSpeller): RecordInfo; /** * Returns the name of the TypeScript property for the given struct field. * Expects a field name as it appears in the `.soia` file. */ export declare function structFieldNameToProperty(fieldName: string): string; //# sourceMappingURL=record_info.d.ts.map