@graphql-codegen/flutter-freezed
Version:
GraphQL Code Generator plugin to generate Freezed models from your GraphQL schema
77 lines (76 loc) • 4.12 kB
TypeScript
import { EnumTypeDefinitionNode, FieldDefinitionNode, InputObjectTypeDefinitionNode, InputValueDefinitionNode, ObjectTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
import { ApplyDecoratorOn, CustomDecorator, FreezedConfig, FlutterFreezedPluginConfig, TypeSpecificFreezedConfig } from './config.js';
import { FreezedDeclarationBlock, FreezedFactoryBlock } from './freezed-declaration-blocks/index.js';
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: FlutterFreezedPluginConfig, 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: FlutterFreezedPluginConfig, typeName?: string | undefined): any;
/**
* @description filters the customDirectives to return those that are applied on a list of blocks
*/
export declare function getCustomDecorators(config: FlutterFreezedPluginConfig, appliesOn: ApplyDecoratorOn[], nodeName?: string | undefined, fieldName?: string | undefined): CustomDecorator;
export declare function transformCustomDecorators(customDecorators: CustomDecorator, node?: NodeType | undefined, field?: FieldType | undefined): string[];
/** returns freezed import statements */
export declare function addFreezedImportStatements(fileName: string): 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: FlutterFreezedPluginConfig, _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<T>(option: OptionName): T;
}
/**
* 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>;
get(key: string): FreezedFactoryBlock | undefined;
register(key: string, value: FreezedFactoryBlock): FreezedFactoryBlock;
retrieve(key: string, appliesOn: string, name: string, typeName: string | undefined): string;
}
/** initializes a FreezedPluginConfig with the defaults values */
export declare class DefaultFreezedPluginConfig implements FlutterFreezedPluginConfig {
camelCasedEnums?: boolean;
customScalars?: {
[name: string]: string;
};
fileName?: string;
globalFreezedConfig?: FreezedConfig;
typeSpecificFreezedConfig?: Record<string, TypeSpecificFreezedConfig>;
ignoreTypes?: string[];
constructor(config?: FlutterFreezedPluginConfig);
}
/** 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();
}