graphql-codegen-flutter-freezed
Version:
A stand-alone package to generate Freezed models from GraphQL schema based on the flutter-freezed plugin for GraphQL Code Generator
91 lines (90 loc) • 4.51 kB
TypeScript
import { EnumTypeDefinitionNode, FieldDefinitionNode, InputObjectTypeDefinitionNode, InputValueDefinitionNode, ObjectTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
import { ApplyDecoratorOn, CustomDecorator, FreezedConfig, FreezedPluginConfig, TypeSpecificFreezedConfig } from './config';
import { FreezedDeclarationBlock, FreezedFactoryBlock } from './freezed-declaration-blocks';
export declare type FieldType = FieldDefinitionNode | InputValueDefinitionNode;
export declare type NodeType = ObjectTypeDefinitionNode | InputObjectTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode;
export declare type OptionName = 'alwaysUseJsonKeyName' | 'copyWith' | 'customDecorators' | 'defaultUnionConstructor' | 'equal' | 'fromJsonToJson' | 'immutable' | 'makeCollectionsUnmodifiable' | 'mergeInputs' | 'mutableInputs' | 'privateEmptyConstructor' | 'unionKey' | 'unionValueCase';
export declare function transformDefinition(config: FreezedPluginConfig, freezedFactoryBlockRepository: FreezedFactoryBlockRepository, node: NodeType): "" | FreezedDeclarationBlock;
/**
* returns the value of the FreezedConfig option
* for a specific type if given typeName
* or else fallback to the global FreezedConfig value
*/
export declare function getFreezedConfigValue(option: OptionName, config: FreezedPluginConfig, typeName?: string | undefined): any;
/**
* @description filters the customDirectives to return those that are applied on a list of blocks
*/
export declare function getCustomDecorators(config: FreezedPluginConfig, appliesOn: ApplyDecoratorOn[], nodeName?: string | undefined, fieldName?: string | undefined): CustomDecorator;
export declare function transformCustomDecorators(customDecorators: CustomDecorator, node?: NodeType | undefined, field?: FieldType | undefined): string[];
/** a class variant of the getFreezedConfigValue helper function
*
* returns the value of the FreezedConfig option
* for a specific type if given typeName
* or else fallback to the global FreezedConfig value
*/
export declare class FreezedConfigValue {
private _config;
private _typeName;
constructor(_config: FreezedPluginConfig, _typeName: string | undefined);
/**
* returns the value of the FreezedConfig option
* for a specific type if given typeName
* or else fallback to the global FreezedConfig value
*/
get(option: OptionName): any;
}
export declare class FreezedImportBlock {
private _config;
private _fileName?;
_importFreezedAnnotation?: boolean;
_importFoundation?: boolean;
_jsonSerializable?: boolean;
constructor(_config: FreezedPluginConfig, _fileName?: string | undefined);
string(): string;
/** TODO: Work on the modularization
* returns the fileName without the extension.
* if modular is set to, returns the value of fileName from the config
*/
getFileName(fileName?: string): string | undefined;
}
/**
* stores an instance of FreezedFactoryBlock using the node names as the key
* and returns that instance when replacing tokens
* */
export declare class FreezedFactoryBlockRepository {
_store: Record<string, FreezedFactoryBlock>;
register(key: string, value: FreezedFactoryBlock): FreezedFactoryBlock;
retrieve(key: string, appliesOn: string, name: string, typeName: string | undefined): FreezedFactoryBlock;
}
/** initializes a FreezedPluginConfig with the defaults values */
export declare class DefaultFreezedPluginConfig implements FreezedPluginConfig {
customScalars?: {
[name: string]: string;
};
fileName?: string;
globalFreezedConfig?: FreezedConfig;
typeSpecificFreezedConfig?: Record<string, TypeSpecificFreezedConfig>;
ignoreTypes?: string[];
interfaceNamePrefix?: string;
interfaceNameSuffix?: string;
lowercaseEnums?: boolean;
modular?: boolean;
constructor(config?: FreezedPluginConfig);
}
/** initializes a FreezedConfig with the defaults values */
export declare class DefaultFreezedConfig implements FreezedConfig {
alwaysUseJsonKeyName?: boolean;
copyWith?: boolean;
customDecorators?: CustomDecorator;
defaultUnionConstructor?: boolean;
equal?: boolean;
fromJsonToJson?: boolean;
immutable?: boolean;
makeCollectionsUnmodifiable?: boolean;
mergeInputs?: string[];
mutableInputs?: boolean;
privateEmptyConstructor?: boolean;
unionKey?: string;
unionValueCase?: 'FreezedUnionCase.camel' | 'FreezedUnionCase.pascal';
constructor();
}