@graphql-codegen/flutter-freezed 2.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. package/cjs/config.js +2 -0
  2. package/cjs/freezed-declaration-blocks/class-block.js +221 -0
  3. package/cjs/freezed-declaration-blocks/factory-block.js +121 -0
  4. package/cjs/freezed-declaration-blocks/index.js +6 -0
  5. package/cjs/freezed-declaration-blocks/parameter-block.js +150 -0
  6. package/cjs/index.js +27 -0
  7. package/cjs/package.json +1 -0
  8. package/cjs/schema-visitor.js +15 -0
  9. package/cjs/utils.js +221 -0
  10. package/esm/config.js +1 -0
  11. package/esm/freezed-declaration-blocks/class-block.js +217 -0
  12. package/esm/freezed-declaration-blocks/factory-block.js +117 -0
  13. package/esm/freezed-declaration-blocks/index.js +3 -0
  14. package/esm/freezed-declaration-blocks/parameter-block.js +146 -0
  15. package/esm/index.js +23 -0
  16. package/esm/schema-visitor.js +11 -0
  17. package/esm/utils.js +209 -0
  18. package/package.json +46 -0
  19. package/typings/config.d.cts +453 -0
  20. package/typings/config.d.ts +453 -0
  21. package/typings/freezed-declaration-blocks/class-block.d.cts +36 -0
  22. package/typings/freezed-declaration-blocks/class-block.d.ts +36 -0
  23. package/typings/freezed-declaration-blocks/factory-block.d.cts +38 -0
  24. package/typings/freezed-declaration-blocks/factory-block.d.ts +38 -0
  25. package/typings/freezed-declaration-blocks/index.d.cts +3 -0
  26. package/typings/freezed-declaration-blocks/index.d.ts +3 -0
  27. package/typings/freezed-declaration-blocks/parameter-block.d.cts +45 -0
  28. package/typings/freezed-declaration-blocks/parameter-block.d.ts +45 -0
  29. package/typings/index.d.cts +3 -0
  30. package/typings/index.d.ts +3 -0
  31. package/typings/schema-visitor.d.cts +10 -0
  32. package/typings/schema-visitor.d.ts +10 -0
  33. package/typings/utils.d.cts +78 -0
  34. package/typings/utils.d.ts +78 -0
@@ -0,0 +1,45 @@
1
+ import { ApplyDecoratorOn, FlutterFreezedPluginConfig } from '../config.js';
2
+ import { FieldType, NodeType } from '../utils.js';
3
+ /**
4
+ * maps GraphQL scalar types to Dart's scalar types
5
+ */
6
+ export declare const DART_SCALARS: Record<string, string>;
7
+ export declare class FreezedParameterBlock {
8
+ private _config;
9
+ private _appliesOn;
10
+ private _node;
11
+ private _field;
12
+ /** document the property */
13
+ _comment: string;
14
+ /** a list of decorators to copy paste to the generator */
15
+ _decorators: string[];
16
+ /** mark the property as required */
17
+ _required: boolean | undefined;
18
+ /** mark the property as required */
19
+ _type: string | undefined;
20
+ /** the name of the property */
21
+ _name: string | undefined;
22
+ /** the shape is the content of the block */
23
+ _shape: string | undefined;
24
+ /** the block is the final structure that is generated */
25
+ _block: string | undefined;
26
+ private _freezedConfigValue;
27
+ constructor(_config: FlutterFreezedPluginConfig, _appliesOn: ApplyDecoratorOn[], _node: NodeType, _field: FieldType);
28
+ init(): FreezedParameterBlock;
29
+ private setComment;
30
+ private setDecorators;
31
+ private setRequired;
32
+ private setType;
33
+ private setName;
34
+ /** compose the freezed constructor property */
35
+ private setShape;
36
+ /** composes the full block */
37
+ private setBlock;
38
+ private propertyType;
39
+ private isListType;
40
+ private isNonNullType;
41
+ private isNamedType;
42
+ private scalar;
43
+ /** returns the block */
44
+ toString(): string;
45
+ }
@@ -0,0 +1,3 @@
1
+ import { PluginFunction } from '@graphql-codegen/plugin-helpers';
2
+ import { FlutterFreezedPluginConfig } from './config.cjs';
3
+ export declare const plugin: PluginFunction<FlutterFreezedPluginConfig>;
@@ -0,0 +1,3 @@
1
+ import { PluginFunction } from '@graphql-codegen/plugin-helpers';
2
+ import { FlutterFreezedPluginConfig } from './config.js';
3
+ export declare const plugin: PluginFunction<FlutterFreezedPluginConfig>;
@@ -0,0 +1,10 @@
1
+ import { EnumTypeDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, ObjectTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
2
+ import { FlutterFreezedPluginConfig } from './config.cjs';
3
+ import { FreezedFactoryBlockRepository } from './utils.cjs';
4
+ export declare const schemaVisitor: (_schema: GraphQLSchema, config: FlutterFreezedPluginConfig) => {
5
+ freezedFactoryBlockRepository: FreezedFactoryBlockRepository;
6
+ EnumTypeDefinition: (node: EnumTypeDefinitionNode) => "" | import("./freezed-declaration-blocks/class-block.js").FreezedDeclarationBlock;
7
+ UnionTypeDefinition: (node: UnionTypeDefinitionNode) => "" | import("./freezed-declaration-blocks/class-block.js").FreezedDeclarationBlock;
8
+ ObjectTypeDefinition: (node: ObjectTypeDefinitionNode) => "" | import("./freezed-declaration-blocks/class-block.js").FreezedDeclarationBlock;
9
+ InputObjectTypeDefinition: (node: InputObjectTypeDefinitionNode) => "" | import("./freezed-declaration-blocks/class-block.js").FreezedDeclarationBlock;
10
+ };
@@ -0,0 +1,10 @@
1
+ import { EnumTypeDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, ObjectTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
2
+ import { FlutterFreezedPluginConfig } from './config.js';
3
+ import { FreezedFactoryBlockRepository } from './utils.js';
4
+ export declare const schemaVisitor: (_schema: GraphQLSchema, config: FlutterFreezedPluginConfig) => {
5
+ freezedFactoryBlockRepository: FreezedFactoryBlockRepository;
6
+ EnumTypeDefinition: (node: EnumTypeDefinitionNode) => "" | import("./freezed-declaration-blocks/class-block.js").FreezedDeclarationBlock;
7
+ UnionTypeDefinition: (node: UnionTypeDefinitionNode) => "" | import("./freezed-declaration-blocks/class-block.js").FreezedDeclarationBlock;
8
+ ObjectTypeDefinition: (node: ObjectTypeDefinitionNode) => "" | import("./freezed-declaration-blocks/class-block.js").FreezedDeclarationBlock;
9
+ InputObjectTypeDefinition: (node: InputObjectTypeDefinitionNode) => "" | import("./freezed-declaration-blocks/class-block.js").FreezedDeclarationBlock;
10
+ };
@@ -0,0 +1,78 @@
1
+ import { EnumTypeDefinitionNode, FieldDefinitionNode, InputObjectTypeDefinitionNode, InputValueDefinitionNode, ObjectTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
2
+ import { ApplyDecoratorOn, CustomDecorator, FreezedConfig, FlutterFreezedPluginConfig, TypeSpecificFreezedConfig } from './config.cjs';
3
+ import { FreezedDeclarationBlock, FreezedFactoryBlock } from './freezed-declaration-blocks/index.cjs';
4
+ export declare type FieldType = FieldDefinitionNode | InputValueDefinitionNode;
5
+ export declare type NodeType = ObjectTypeDefinitionNode | InputObjectTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode;
6
+ export declare type OptionName = 'alwaysUseJsonKeyName' | 'copyWith' | 'customDecorators' | 'defaultUnionConstructor' | 'equal' | 'fromJsonToJson' | 'immutable' | 'makeCollectionsUnmodifiable' | 'mergeInputs' | 'mutableInputs' | 'privateEmptyConstructor' | 'unionKey' | 'unionValueCase';
7
+ export declare function transformDefinition(config: FlutterFreezedPluginConfig, freezedFactoryBlockRepository: FreezedFactoryBlockRepository, node: NodeType): "" | FreezedDeclarationBlock;
8
+ /**
9
+ * returns the value of the FreezedConfig option
10
+ * for a specific type if given typeName
11
+ * or else fallback to the global FreezedConfig value
12
+ */
13
+ export declare function getFreezedConfigValue(option: OptionName, config: FlutterFreezedPluginConfig, typeName?: string | undefined): any;
14
+ /**
15
+ * @description filters the customDirectives to return those that are applied on a list of blocks
16
+ */
17
+ export declare function getCustomDecorators(config: FlutterFreezedPluginConfig, appliesOn: ApplyDecoratorOn[], nodeName?: string | undefined, fieldName?: string | undefined): CustomDecorator;
18
+ export declare function transformCustomDecorators(customDecorators: CustomDecorator, node?: NodeType | undefined, field?: FieldType | undefined): string[];
19
+ /** returns freezed import statements */
20
+ export declare function addFreezedImportStatements(fileName: string): string;
21
+ /** a class variant of the getFreezedConfigValue helper function
22
+ *
23
+ * returns the value of the FreezedConfig option
24
+ * for a specific type if given typeName
25
+ * or else fallback to the global FreezedConfig value
26
+ */
27
+ export declare class FreezedConfigValue {
28
+ private _config;
29
+ private _typeName;
30
+ constructor(_config: FlutterFreezedPluginConfig, _typeName: string | undefined);
31
+ /**
32
+ * returns the value of the FreezedConfig option
33
+ * for a specific type if given typeName
34
+ * or else fallback to the global FreezedConfig value
35
+ */
36
+ get(option: OptionName): any;
37
+ }
38
+ /**
39
+ * stores an instance of FreezedFactoryBlock using the node names as the key
40
+ * and returns that instance when replacing tokens
41
+ * */
42
+ export declare class FreezedFactoryBlockRepository {
43
+ _store: Record<string, FreezedFactoryBlock>;
44
+ register(key: string, value: FreezedFactoryBlock): FreezedFactoryBlock;
45
+ retrieve(key: string, appliesOn: string, name: string, typeName: string | undefined): FreezedFactoryBlock;
46
+ }
47
+ /** initializes a FreezedPluginConfig with the defaults values */
48
+ export declare class DefaultFreezedPluginConfig implements FlutterFreezedPluginConfig {
49
+ customScalars?: {
50
+ [name: string]: string;
51
+ };
52
+ fileName?: string;
53
+ globalFreezedConfig?: FreezedConfig;
54
+ typeSpecificFreezedConfig?: Record<string, TypeSpecificFreezedConfig>;
55
+ ignoreTypes?: string[];
56
+ interfaceNamePrefix?: string;
57
+ interfaceNameSuffix?: string;
58
+ lowercaseEnums?: boolean;
59
+ modular?: boolean;
60
+ constructor(config?: FlutterFreezedPluginConfig);
61
+ }
62
+ /** initializes a FreezedConfig with the defaults values */
63
+ export declare class DefaultFreezedConfig implements FreezedConfig {
64
+ alwaysUseJsonKeyName?: boolean;
65
+ copyWith?: boolean;
66
+ customDecorators?: CustomDecorator;
67
+ defaultUnionConstructor?: boolean;
68
+ equal?: boolean;
69
+ fromJsonToJson?: boolean;
70
+ immutable?: boolean;
71
+ makeCollectionsUnmodifiable?: boolean;
72
+ mergeInputs?: string[];
73
+ mutableInputs?: boolean;
74
+ privateEmptyConstructor?: boolean;
75
+ unionKey?: string;
76
+ unionValueCase?: 'FreezedUnionCase.camel' | 'FreezedUnionCase.pascal';
77
+ constructor();
78
+ }
@@ -0,0 +1,78 @@
1
+ import { EnumTypeDefinitionNode, FieldDefinitionNode, InputObjectTypeDefinitionNode, InputValueDefinitionNode, ObjectTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
2
+ import { ApplyDecoratorOn, CustomDecorator, FreezedConfig, FlutterFreezedPluginConfig, TypeSpecificFreezedConfig } from './config.js';
3
+ import { FreezedDeclarationBlock, FreezedFactoryBlock } from './freezed-declaration-blocks/index.js';
4
+ export declare type FieldType = FieldDefinitionNode | InputValueDefinitionNode;
5
+ export declare type NodeType = ObjectTypeDefinitionNode | InputObjectTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode;
6
+ export declare type OptionName = 'alwaysUseJsonKeyName' | 'copyWith' | 'customDecorators' | 'defaultUnionConstructor' | 'equal' | 'fromJsonToJson' | 'immutable' | 'makeCollectionsUnmodifiable' | 'mergeInputs' | 'mutableInputs' | 'privateEmptyConstructor' | 'unionKey' | 'unionValueCase';
7
+ export declare function transformDefinition(config: FlutterFreezedPluginConfig, freezedFactoryBlockRepository: FreezedFactoryBlockRepository, node: NodeType): "" | FreezedDeclarationBlock;
8
+ /**
9
+ * returns the value of the FreezedConfig option
10
+ * for a specific type if given typeName
11
+ * or else fallback to the global FreezedConfig value
12
+ */
13
+ export declare function getFreezedConfigValue(option: OptionName, config: FlutterFreezedPluginConfig, typeName?: string | undefined): any;
14
+ /**
15
+ * @description filters the customDirectives to return those that are applied on a list of blocks
16
+ */
17
+ export declare function getCustomDecorators(config: FlutterFreezedPluginConfig, appliesOn: ApplyDecoratorOn[], nodeName?: string | undefined, fieldName?: string | undefined): CustomDecorator;
18
+ export declare function transformCustomDecorators(customDecorators: CustomDecorator, node?: NodeType | undefined, field?: FieldType | undefined): string[];
19
+ /** returns freezed import statements */
20
+ export declare function addFreezedImportStatements(fileName: string): string;
21
+ /** a class variant of the getFreezedConfigValue helper function
22
+ *
23
+ * returns the value of the FreezedConfig option
24
+ * for a specific type if given typeName
25
+ * or else fallback to the global FreezedConfig value
26
+ */
27
+ export declare class FreezedConfigValue {
28
+ private _config;
29
+ private _typeName;
30
+ constructor(_config: FlutterFreezedPluginConfig, _typeName: string | undefined);
31
+ /**
32
+ * returns the value of the FreezedConfig option
33
+ * for a specific type if given typeName
34
+ * or else fallback to the global FreezedConfig value
35
+ */
36
+ get(option: OptionName): any;
37
+ }
38
+ /**
39
+ * stores an instance of FreezedFactoryBlock using the node names as the key
40
+ * and returns that instance when replacing tokens
41
+ * */
42
+ export declare class FreezedFactoryBlockRepository {
43
+ _store: Record<string, FreezedFactoryBlock>;
44
+ register(key: string, value: FreezedFactoryBlock): FreezedFactoryBlock;
45
+ retrieve(key: string, appliesOn: string, name: string, typeName: string | undefined): FreezedFactoryBlock;
46
+ }
47
+ /** initializes a FreezedPluginConfig with the defaults values */
48
+ export declare class DefaultFreezedPluginConfig implements FlutterFreezedPluginConfig {
49
+ customScalars?: {
50
+ [name: string]: string;
51
+ };
52
+ fileName?: string;
53
+ globalFreezedConfig?: FreezedConfig;
54
+ typeSpecificFreezedConfig?: Record<string, TypeSpecificFreezedConfig>;
55
+ ignoreTypes?: string[];
56
+ interfaceNamePrefix?: string;
57
+ interfaceNameSuffix?: string;
58
+ lowercaseEnums?: boolean;
59
+ modular?: boolean;
60
+ constructor(config?: FlutterFreezedPluginConfig);
61
+ }
62
+ /** initializes a FreezedConfig with the defaults values */
63
+ export declare class DefaultFreezedConfig implements FreezedConfig {
64
+ alwaysUseJsonKeyName?: boolean;
65
+ copyWith?: boolean;
66
+ customDecorators?: CustomDecorator;
67
+ defaultUnionConstructor?: boolean;
68
+ equal?: boolean;
69
+ fromJsonToJson?: boolean;
70
+ immutable?: boolean;
71
+ makeCollectionsUnmodifiable?: boolean;
72
+ mergeInputs?: string[];
73
+ mutableInputs?: boolean;
74
+ privateEmptyConstructor?: boolean;
75
+ unionKey?: string;
76
+ unionValueCase?: 'FreezedUnionCase.camel' | 'FreezedUnionCase.pascal';
77
+ constructor();
78
+ }