@graphql-codegen/flutter-freezed 2.11.2 → 3.0.0

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 (53) hide show
  1. package/cjs/config/config-value.js +132 -0
  2. package/cjs/config/pattern.js +731 -0
  3. package/cjs/config/plugin-config.js +140 -0
  4. package/cjs/freezed-declaration-blocks/class-block.js +87 -224
  5. package/cjs/freezed-declaration-blocks/enum-block.js +54 -0
  6. package/cjs/freezed-declaration-blocks/factory-block.js +81 -113
  7. package/cjs/freezed-declaration-blocks/index.js +91 -4
  8. package/cjs/freezed-declaration-blocks/node-repository.js +26 -0
  9. package/cjs/freezed-declaration-blocks/parameter-block.js +55 -143
  10. package/cjs/index.js +10 -14
  11. package/cjs/schema-visitor.js +8 -7
  12. package/cjs/utils.js +64 -219
  13. package/esm/config/config-value.js +128 -0
  14. package/esm/config/pattern.js +723 -0
  15. package/esm/config/plugin-config.js +137 -0
  16. package/esm/freezed-declaration-blocks/class-block.js +86 -223
  17. package/esm/freezed-declaration-blocks/enum-block.js +50 -0
  18. package/esm/freezed-declaration-blocks/factory-block.js +81 -113
  19. package/esm/freezed-declaration-blocks/index.js +89 -3
  20. package/esm/freezed-declaration-blocks/node-repository.js +22 -0
  21. package/esm/freezed-declaration-blocks/parameter-block.js +53 -141
  22. package/esm/index.js +11 -15
  23. package/esm/schema-visitor.js +8 -7
  24. package/esm/utils.js +56 -212
  25. package/package.json +5 -5
  26. package/typings/config/config-value.d.cts +24 -0
  27. package/typings/config/config-value.d.ts +24 -0
  28. package/typings/config/pattern.d.cts +252 -0
  29. package/typings/config/pattern.d.ts +252 -0
  30. package/typings/config/plugin-config.d.cts +683 -0
  31. package/typings/config/plugin-config.d.ts +683 -0
  32. package/typings/freezed-declaration-blocks/class-block.d.cts +11 -35
  33. package/typings/freezed-declaration-blocks/class-block.d.ts +11 -35
  34. package/typings/freezed-declaration-blocks/enum-block.d.cts +10 -0
  35. package/typings/freezed-declaration-blocks/enum-block.d.ts +10 -0
  36. package/typings/freezed-declaration-blocks/factory-block.d.cts +16 -37
  37. package/typings/freezed-declaration-blocks/factory-block.d.ts +16 -37
  38. package/typings/freezed-declaration-blocks/index.d.cts +27 -3
  39. package/typings/freezed-declaration-blocks/index.d.ts +27 -3
  40. package/typings/freezed-declaration-blocks/node-repository.d.cts +10 -0
  41. package/typings/freezed-declaration-blocks/node-repository.d.ts +10 -0
  42. package/typings/freezed-declaration-blocks/parameter-block.d.cts +11 -44
  43. package/typings/freezed-declaration-blocks/parameter-block.d.ts +11 -44
  44. package/typings/index.d.cts +1 -1
  45. package/typings/index.d.ts +1 -1
  46. package/typings/schema-visitor.d.cts +7 -7
  47. package/typings/schema-visitor.d.ts +7 -7
  48. package/typings/utils.d.cts +33 -72
  49. package/typings/utils.d.ts +33 -72
  50. package/cjs/config.js +0 -2
  51. package/esm/config.js +0 -1
  52. package/typings/config.d.cts +0 -479
  53. package/typings/config.d.ts +0 -479
@@ -1,36 +1,12 @@
1
- import { FlutterFreezedPluginConfig } from '../config.cjs';
2
- import { FreezedFactoryBlockRepository, NodeType } from '../utils.cjs';
3
- import { FreezedFactoryBlock } from './factory-block.cjs';
4
- export declare class FreezedDeclarationBlock {
5
- private _config;
6
- private _freezedFactoryBlockRepository;
7
- private _node;
8
- /** document the class */
9
- _comment: string;
10
- /** a list of decorators to copy paste to the generator */
11
- _decorators: string[];
12
- /** the name of the class */
13
- _name: string | undefined;
14
- /** a list of default constructor and named Constructors used create a Freezed union/sealed class */
15
- _factoryBlocks: FreezedFactoryBlock[];
16
- /** the shape is the content of the block */
17
- _shape: string | undefined;
18
- /** the block is the final structure that is generated */
19
- _block: string | undefined;
20
- private _freezedConfigValue;
21
- constructor(_config: FlutterFreezedPluginConfig, _freezedFactoryBlockRepository: FreezedFactoryBlockRepository, _node: NodeType);
22
- init(): FreezedDeclarationBlock;
23
- private setComment;
24
- private getEnumComment;
25
- private setDecorators;
26
- private getFreezedDecorator;
27
- private setName;
28
- private setFactoryBlocks;
29
- private setShape;
30
- /**
31
- * returns the string output of the block
32
- */
33
- private setBlock;
34
- /** returns the block */
35
- toString(): string;
1
+ import { FlutterFreezedPluginConfig, NodeType } from '../config/plugin-config.cjs';
2
+ import { TypeName } from '../config/pattern.cjs';
3
+ export declare class ClassBlock {
4
+ static build(config: FlutterFreezedPluginConfig, node: NodeType): string;
5
+ static buildDecorators: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
6
+ static buildFreezedDecorator: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
7
+ static decorateAsFreezed: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
8
+ static decorateAsUnfreezed: (config: FlutterFreezedPluginConfig, node: NodeType) => "@unfreezed\n" | "@freezed\n";
9
+ static buildHeader: (config: FlutterFreezedPluginConfig, typeName: TypeName, _className: string) => string;
10
+ static buildBody: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
11
+ static buildFooter: (config: FlutterFreezedPluginConfig, typeName: TypeName, _className: string) => string;
36
12
  }
@@ -1,36 +1,12 @@
1
- import { FlutterFreezedPluginConfig } from '../config.js';
2
- import { FreezedFactoryBlockRepository, NodeType } from '../utils.js';
3
- import { FreezedFactoryBlock } from './factory-block.js';
4
- export declare class FreezedDeclarationBlock {
5
- private _config;
6
- private _freezedFactoryBlockRepository;
7
- private _node;
8
- /** document the class */
9
- _comment: string;
10
- /** a list of decorators to copy paste to the generator */
11
- _decorators: string[];
12
- /** the name of the class */
13
- _name: string | undefined;
14
- /** a list of default constructor and named Constructors used create a Freezed union/sealed class */
15
- _factoryBlocks: FreezedFactoryBlock[];
16
- /** the shape is the content of the block */
17
- _shape: string | undefined;
18
- /** the block is the final structure that is generated */
19
- _block: string | undefined;
20
- private _freezedConfigValue;
21
- constructor(_config: FlutterFreezedPluginConfig, _freezedFactoryBlockRepository: FreezedFactoryBlockRepository, _node: NodeType);
22
- init(): FreezedDeclarationBlock;
23
- private setComment;
24
- private getEnumComment;
25
- private setDecorators;
26
- private getFreezedDecorator;
27
- private setName;
28
- private setFactoryBlocks;
29
- private setShape;
30
- /**
31
- * returns the string output of the block
32
- */
33
- private setBlock;
34
- /** returns the block */
35
- toString(): string;
1
+ import { FlutterFreezedPluginConfig, NodeType } from '../config/plugin-config.js';
2
+ import { TypeName } from '../config/pattern.js';
3
+ export declare class ClassBlock {
4
+ static build(config: FlutterFreezedPluginConfig, node: NodeType): string;
5
+ static buildDecorators: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
6
+ static buildFreezedDecorator: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
7
+ static decorateAsFreezed: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
8
+ static decorateAsUnfreezed: (config: FlutterFreezedPluginConfig, node: NodeType) => "@unfreezed\n" | "@freezed\n";
9
+ static buildHeader: (config: FlutterFreezedPluginConfig, typeName: TypeName, _className: string) => string;
10
+ static buildBody: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
11
+ static buildFooter: (config: FlutterFreezedPluginConfig, typeName: TypeName, _className: string) => string;
36
12
  }
@@ -0,0 +1,10 @@
1
+ import { EnumTypeDefinitionNode } from 'graphql';
2
+ import { TypeName } from '../config/pattern.cjs';
3
+ import { FlutterFreezedPluginConfig } from '../config/plugin-config.cjs';
4
+ export declare class EnumBlock {
5
+ static build(config: FlutterFreezedPluginConfig, node: EnumTypeDefinitionNode): string;
6
+ static buildDecorators: () => string;
7
+ static buildHeader: (config: FlutterFreezedPluginConfig, typeName: TypeName) => string;
8
+ static buildBody: (config: FlutterFreezedPluginConfig, node: EnumTypeDefinitionNode) => string;
9
+ static buildFooter: () => string;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { EnumTypeDefinitionNode } from 'graphql';
2
+ import { TypeName } from '../config/pattern.js';
3
+ import { FlutterFreezedPluginConfig } from '../config/plugin-config.js';
4
+ export declare class EnumBlock {
5
+ static build(config: FlutterFreezedPluginConfig, node: EnumTypeDefinitionNode): string;
6
+ static buildDecorators: () => string;
7
+ static buildHeader: (config: FlutterFreezedPluginConfig, typeName: TypeName) => string;
8
+ static buildBody: (config: FlutterFreezedPluginConfig, node: EnumTypeDefinitionNode) => string;
9
+ static buildFooter: () => string;
10
+ }
@@ -1,38 +1,17 @@
1
- import { FreezedParameterBlock } from './parameter-block.cjs';
2
- import { FlutterFreezedPluginConfig } from '../config.cjs';
3
- import { NodeType } from '../utils.cjs';
4
- export declare class FreezedFactoryBlock {
5
- private _config;
6
- private _node;
7
- /** document the constructor */
8
- _comment: string;
9
- /** a list of decorators to copy paste to the generator */
10
- _decorators: string[];
11
- /** the key of the original type name */
12
- _key: string | undefined;
13
- /** the name of the class */
14
- _name: string | undefined;
15
- /** the namedConstructor is used for GraphQL Union types or if mergeInput is true */
16
- _namedConstructor: string | undefined;
17
- /** a list of interfaces to implements */
18
- /** a list of class to mixin with */
19
- /** the parameters of this factory constructor */
20
- _parameters: FreezedParameterBlock[];
21
- /** the shape is the content of the block */
22
- _shape: string | undefined;
23
- /** the block is the final structure that is generated */
24
- _block: string | undefined;
25
- private _freezedConfigValue;
26
- constructor(_config: FlutterFreezedPluginConfig, _node: NodeType);
27
- init(): FreezedFactoryBlock;
28
- private setComment;
29
- setDecorators(appliesOn: string, nodeName: string): FreezedFactoryBlock;
30
- setKey(key: string): FreezedFactoryBlock;
31
- setName(name: string): FreezedFactoryBlock;
32
- setNamedConstructor(namedConstructor: string | undefined): FreezedFactoryBlock;
33
- private setParameters;
34
- private setShape;
35
- private setBlock;
36
- /** returns the block */
37
- toString(): string;
1
+ import { TypeName } from '../config/pattern.cjs';
2
+ import { FlutterFreezedPluginConfig, ObjectType, AppliesOnFactory, AppliesOnDefaultFactory, AppliesOnNamedFactory } from '../config/plugin-config.cjs';
3
+ import { NodeRepository } from './node-repository.cjs';
4
+ export declare class FactoryBlock {
5
+ static build(config: FlutterFreezedPluginConfig, node: ObjectType, blockAppliesOn: readonly AppliesOnFactory[], className: TypeName, factoryName?: TypeName): string;
6
+ static buildDecorators: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOnFactory[], className: TypeName, factoryName?: TypeName) => string;
7
+ static buildHeader: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOnFactory[], className: TypeName, factoryName?: TypeName) => string;
8
+ static buildBody: (config: FlutterFreezedPluginConfig, node: ObjectType, appliesOn: readonly AppliesOnFactory[]) => string;
9
+ static buildFooter: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOnFactory[], factoryName: TypeName) => string;
10
+ static serializeDefaultFactory: (className: TypeName) => string;
11
+ static serializeUnionFactory: (className: TypeName, factoryName: TypeName) => string;
12
+ static serializeMergedFactory: (className: TypeName, factoryName: TypeName) => string;
13
+ static deserializeFactory: (config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, blockAppliesOn: readonly AppliesOnDefaultFactory[], className: TypeName) => string;
14
+ static deserializeNamedFactory: (config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, blockAppliesOn: readonly AppliesOnNamedFactory[], className: TypeName, factoryName: TypeName) => string;
15
+ static buildFromFactory: (config: FlutterFreezedPluginConfig, node: ObjectType, blockAppliesOn: readonly AppliesOnDefaultFactory[], className: TypeName) => string;
16
+ static buildFromNamedFactory: (config: FlutterFreezedPluginConfig, node: ObjectType, blockAppliesOn: readonly AppliesOnNamedFactory[], className: TypeName, factoryName: TypeName) => string;
38
17
  }
@@ -1,38 +1,17 @@
1
- import { FreezedParameterBlock } from './parameter-block.js';
2
- import { FlutterFreezedPluginConfig } from '../config.js';
3
- import { NodeType } from '../utils.js';
4
- export declare class FreezedFactoryBlock {
5
- private _config;
6
- private _node;
7
- /** document the constructor */
8
- _comment: string;
9
- /** a list of decorators to copy paste to the generator */
10
- _decorators: string[];
11
- /** the key of the original type name */
12
- _key: string | undefined;
13
- /** the name of the class */
14
- _name: string | undefined;
15
- /** the namedConstructor is used for GraphQL Union types or if mergeInput is true */
16
- _namedConstructor: string | undefined;
17
- /** a list of interfaces to implements */
18
- /** a list of class to mixin with */
19
- /** the parameters of this factory constructor */
20
- _parameters: FreezedParameterBlock[];
21
- /** the shape is the content of the block */
22
- _shape: string | undefined;
23
- /** the block is the final structure that is generated */
24
- _block: string | undefined;
25
- private _freezedConfigValue;
26
- constructor(_config: FlutterFreezedPluginConfig, _node: NodeType);
27
- init(): FreezedFactoryBlock;
28
- private setComment;
29
- setDecorators(appliesOn: string, nodeName: string): FreezedFactoryBlock;
30
- setKey(key: string): FreezedFactoryBlock;
31
- setName(name: string): FreezedFactoryBlock;
32
- setNamedConstructor(namedConstructor: string | undefined): FreezedFactoryBlock;
33
- private setParameters;
34
- private setShape;
35
- private setBlock;
36
- /** returns the block */
37
- toString(): string;
1
+ import { TypeName } from '../config/pattern.js';
2
+ import { FlutterFreezedPluginConfig, ObjectType, AppliesOnFactory, AppliesOnDefaultFactory, AppliesOnNamedFactory } from '../config/plugin-config.js';
3
+ import { NodeRepository } from './node-repository.js';
4
+ export declare class FactoryBlock {
5
+ static build(config: FlutterFreezedPluginConfig, node: ObjectType, blockAppliesOn: readonly AppliesOnFactory[], className: TypeName, factoryName?: TypeName): string;
6
+ static buildDecorators: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOnFactory[], className: TypeName, factoryName?: TypeName) => string;
7
+ static buildHeader: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOnFactory[], className: TypeName, factoryName?: TypeName) => string;
8
+ static buildBody: (config: FlutterFreezedPluginConfig, node: ObjectType, appliesOn: readonly AppliesOnFactory[]) => string;
9
+ static buildFooter: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOnFactory[], factoryName: TypeName) => string;
10
+ static serializeDefaultFactory: (className: TypeName) => string;
11
+ static serializeUnionFactory: (className: TypeName, factoryName: TypeName) => string;
12
+ static serializeMergedFactory: (className: TypeName, factoryName: TypeName) => string;
13
+ static deserializeFactory: (config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, blockAppliesOn: readonly AppliesOnDefaultFactory[], className: TypeName) => string;
14
+ static deserializeNamedFactory: (config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, blockAppliesOn: readonly AppliesOnNamedFactory[], className: TypeName, factoryName: TypeName) => string;
15
+ static buildFromFactory: (config: FlutterFreezedPluginConfig, node: ObjectType, blockAppliesOn: readonly AppliesOnDefaultFactory[], className: TypeName) => string;
16
+ static buildFromNamedFactory: (config: FlutterFreezedPluginConfig, node: ObjectType, blockAppliesOn: readonly AppliesOnNamedFactory[], className: TypeName, factoryName: TypeName) => string;
38
17
  }
@@ -1,3 +1,27 @@
1
- export * from './parameter-block.cjs';
2
- export * from './factory-block.cjs';
3
- export * from './class-block.cjs';
1
+ import { EnumValueDefinitionNode } from 'graphql';
2
+ import { FieldName, TypeName } from '../config/pattern.cjs';
3
+ import { AppliesOn, DartIdentifierCasing, FieldType, FlutterFreezedPluginConfig, NodeType } from '../config/plugin-config.cjs';
4
+ import { NodeRepository } from './node-repository.cjs';
5
+ export declare class Block {
6
+ static buildImportStatements: (fileName: string) => string;
7
+ /**
8
+ * Transforms the AST nodes into Freezed classes/models
9
+ * @param config The plugin configuration object
10
+ * @param node the AST node passed by the schema visitor
11
+ * @param nodeRepository A map that stores the name of the Graphql Type as the key and it AST node as the value. Used to build FactoryBlocks from placeholders for mergedInputs and Union Types
12
+ * @returns a string output of a `FreezedDeclarationBlock` which represents a Freezed class/model in Dart
13
+ */
14
+ static build: (config: FlutterFreezedPluginConfig, node: NodeType, nodeRepository: NodeRepository) => string;
15
+ static buildComment: (node?: NodeType | FieldType | EnumValueDefinitionNode) => string;
16
+ static buildBlockName: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOn[], identifier: string, typeName: TypeName, fieldName?: FieldName, blockCasing?: DartIdentifierCasing) => string;
17
+ static tokens: {
18
+ defaultFactory: string;
19
+ unionFactory: string;
20
+ mergedFactory: string;
21
+ fromJsonToJson: string;
22
+ };
23
+ static regexpForToken: (tokenName: 'defaultFactory' | 'unionFactory' | 'mergedFactory' | 'fromJsonToJson') => RegExp;
24
+ static replaceTokens: (config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, generatedBlocks: string[]) => string;
25
+ static replaceDefaultFactoryToken: (block: string, config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository) => string;
26
+ static replaceNamedFactoryToken: (block: string, config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, blockType: 'unionFactory' | 'mergedFactory') => string;
27
+ }
@@ -1,3 +1,27 @@
1
- export * from './parameter-block.js';
2
- export * from './factory-block.js';
3
- export * from './class-block.js';
1
+ import { EnumValueDefinitionNode } from 'graphql';
2
+ import { FieldName, TypeName } from '../config/pattern.js';
3
+ import { AppliesOn, DartIdentifierCasing, FieldType, FlutterFreezedPluginConfig, NodeType } from '../config/plugin-config.js';
4
+ import { NodeRepository } from './node-repository.js';
5
+ export declare class Block {
6
+ static buildImportStatements: (fileName: string) => string;
7
+ /**
8
+ * Transforms the AST nodes into Freezed classes/models
9
+ * @param config The plugin configuration object
10
+ * @param node the AST node passed by the schema visitor
11
+ * @param nodeRepository A map that stores the name of the Graphql Type as the key and it AST node as the value. Used to build FactoryBlocks from placeholders for mergedInputs and Union Types
12
+ * @returns a string output of a `FreezedDeclarationBlock` which represents a Freezed class/model in Dart
13
+ */
14
+ static build: (config: FlutterFreezedPluginConfig, node: NodeType, nodeRepository: NodeRepository) => string;
15
+ static buildComment: (node?: NodeType | FieldType | EnumValueDefinitionNode) => string;
16
+ static buildBlockName: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOn[], identifier: string, typeName: TypeName, fieldName?: FieldName, blockCasing?: DartIdentifierCasing) => string;
17
+ static tokens: {
18
+ defaultFactory: string;
19
+ unionFactory: string;
20
+ mergedFactory: string;
21
+ fromJsonToJson: string;
22
+ };
23
+ static regexpForToken: (tokenName: 'defaultFactory' | 'unionFactory' | 'mergedFactory' | 'fromJsonToJson') => RegExp;
24
+ static replaceTokens: (config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, generatedBlocks: string[]) => string;
25
+ static replaceDefaultFactoryToken: (block: string, config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository) => string;
26
+ static replaceNamedFactoryToken: (block: string, config: FlutterFreezedPluginConfig, nodeRepository: NodeRepository, blockType: 'unionFactory' | 'mergedFactory') => string;
27
+ }
@@ -0,0 +1,10 @@
1
+ import { ObjectType } from '../config/plugin-config.cjs';
2
+ /**
3
+ * stores an instance of `ObjectTypeDefinitionNode` or `InputObjectTypeDefinitionNode` using the node name as the key
4
+ * and returns that node when replacing placeholders
5
+ * */
6
+ export declare class NodeRepository {
7
+ private _store;
8
+ get(key: string): ObjectType | undefined;
9
+ register(node: ObjectType): ObjectType;
10
+ }
@@ -0,0 +1,10 @@
1
+ import { ObjectType } from '../config/plugin-config.js';
2
+ /**
3
+ * stores an instance of `ObjectTypeDefinitionNode` or `InputObjectTypeDefinitionNode` using the node name as the key
4
+ * and returns that node when replacing placeholders
5
+ * */
6
+ export declare class NodeRepository {
7
+ private _store;
8
+ get(key: string): ObjectType | undefined;
9
+ register(node: ObjectType): ObjectType;
10
+ }
@@ -1,45 +1,12 @@
1
- import { ApplyDecoratorOn, FlutterFreezedPluginConfig } from '../config.cjs';
2
- import { FieldType, NodeType } from '../utils.cjs';
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;
1
+ import { ListTypeNode, NamedTypeNode, NonNullTypeNode, TypeNode } from 'graphql';
2
+ import { FieldName, TypeName } from '../config/pattern.cjs';
3
+ import { AppliesOnParameters, FieldType, FlutterFreezedPluginConfig, NodeType } from '../config/plugin-config.cjs';
4
+ export declare class ParameterBlock {
5
+ static build(config: FlutterFreezedPluginConfig, node: NodeType, field: FieldType, blockAppliesOn: readonly AppliesOnParameters[]): string;
6
+ static buildDecorators: (config: FlutterFreezedPluginConfig, typeName: TypeName, fieldName: FieldName, parameterName: string, blockAppliesOn: readonly AppliesOnParameters[]) => string;
7
+ static buildBody: (config: FlutterFreezedPluginConfig, field: FieldType, typeName: TypeName, fieldName: FieldName, parameterName: string, blockAppliesOn: readonly AppliesOnParameters[]) => string;
8
+ static parameterType: (config: FlutterFreezedPluginConfig, type: TypeNode, parentType?: TypeNode) => string;
9
+ static isListType: (type?: TypeNode) => type is ListTypeNode;
10
+ static isNonNullType: (type?: TypeNode) => type is NonNullTypeNode;
11
+ static isNamedType: (type?: TypeNode) => type is NamedTypeNode;
45
12
  }
@@ -1,45 +1,12 @@
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;
1
+ import { ListTypeNode, NamedTypeNode, NonNullTypeNode, TypeNode } from 'graphql';
2
+ import { FieldName, TypeName } from '../config/pattern.js';
3
+ import { AppliesOnParameters, FieldType, FlutterFreezedPluginConfig, NodeType } from '../config/plugin-config.js';
4
+ export declare class ParameterBlock {
5
+ static build(config: FlutterFreezedPluginConfig, node: NodeType, field: FieldType, blockAppliesOn: readonly AppliesOnParameters[]): string;
6
+ static buildDecorators: (config: FlutterFreezedPluginConfig, typeName: TypeName, fieldName: FieldName, parameterName: string, blockAppliesOn: readonly AppliesOnParameters[]) => string;
7
+ static buildBody: (config: FlutterFreezedPluginConfig, field: FieldType, typeName: TypeName, fieldName: FieldName, parameterName: string, blockAppliesOn: readonly AppliesOnParameters[]) => string;
8
+ static parameterType: (config: FlutterFreezedPluginConfig, type: TypeNode, parentType?: TypeNode) => string;
9
+ static isListType: (type?: TypeNode) => type is ListTypeNode;
10
+ static isNonNullType: (type?: TypeNode) => type is NonNullTypeNode;
11
+ static isNamedType: (type?: TypeNode) => type is NamedTypeNode;
45
12
  }
@@ -1,3 +1,3 @@
1
1
  import { PluginFunction } from '@graphql-codegen/plugin-helpers';
2
- import { FlutterFreezedPluginConfig } from './config.cjs';
2
+ import { FlutterFreezedPluginConfig } from './config/plugin-config.cjs';
3
3
  export declare const plugin: PluginFunction<FlutterFreezedPluginConfig>;
@@ -1,3 +1,3 @@
1
1
  import { PluginFunction } from '@graphql-codegen/plugin-helpers';
2
- import { FlutterFreezedPluginConfig } from './config.js';
2
+ import { FlutterFreezedPluginConfig } from './config/plugin-config.js';
3
3
  export declare const plugin: PluginFunction<FlutterFreezedPluginConfig>;
@@ -1,10 +1,10 @@
1
1
  import { EnumTypeDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, ObjectTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
2
- import { FlutterFreezedPluginConfig } from './config.cjs';
3
- import { FreezedFactoryBlockRepository } from './utils.cjs';
2
+ import { FlutterFreezedPluginConfig } from './config/plugin-config.cjs';
3
+ import { NodeRepository } from './freezed-declaration-blocks/node-repository.cjs';
4
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;
5
+ nodeRepository: NodeRepository;
6
+ EnumTypeDefinition: (node: EnumTypeDefinitionNode) => string;
7
+ UnionTypeDefinition: (node: UnionTypeDefinitionNode) => string;
8
+ ObjectTypeDefinition: (node: ObjectTypeDefinitionNode) => string;
9
+ InputObjectTypeDefinition: (node: InputObjectTypeDefinitionNode) => string;
10
10
  };
@@ -1,10 +1,10 @@
1
1
  import { EnumTypeDefinitionNode, GraphQLSchema, InputObjectTypeDefinitionNode, ObjectTypeDefinitionNode, UnionTypeDefinitionNode } from 'graphql';
2
- import { FlutterFreezedPluginConfig } from './config.js';
3
- import { FreezedFactoryBlockRepository } from './utils.js';
2
+ import { FlutterFreezedPluginConfig } from './config/plugin-config.js';
3
+ import { NodeRepository } from './freezed-declaration-blocks/node-repository.js';
4
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;
5
+ nodeRepository: NodeRepository;
6
+ EnumTypeDefinition: (node: EnumTypeDefinitionNode) => string;
7
+ UnionTypeDefinition: (node: UnionTypeDefinitionNode) => string;
8
+ ObjectTypeDefinition: (node: ObjectTypeDefinitionNode) => string;
9
+ InputObjectTypeDefinition: (node: InputObjectTypeDefinitionNode) => string;
10
10
  };
@@ -1,76 +1,37 @@
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;
1
+ import { DefinitionNode, ObjectTypeDefinitionNode, InputObjectTypeDefinitionNode } from 'graphql';
2
+ import { FieldName, TypeName } from './config/pattern.cjs';
3
+ import { AppliesOn, DartIdentifierCasing, FlutterFreezedPluginConfig } from './config/plugin-config.cjs';
4
+ export declare const strToList: (str: string) => string[];
5
+ export declare const arrayWrap: <T>(value: T | T[]) => T[];
6
+ export declare const resetIndex: (regexp: RegExp) => number;
7
+ export declare const nodeIsObjectType: (node: DefinitionNode) => node is ObjectTypeDefinitionNode | InputObjectTypeDefinitionNode;
8
+ export declare const appliesOnBlock: <T extends AppliesOn>(configAppliesOn: T[], blockAppliesOn: readonly T[]) => boolean;
9
+ export declare const dartCasing: (name: string, casing?: DartIdentifierCasing) => string;
8
10
  /**
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
11
+ * checks whether name is a Dart Language keyword
12
+ * @param identifier The name or identifier to be checked
13
+ * @returns `true` if name is a Dart Language keyword, otherwise `false`
12
14
  */
13
- export declare function getFreezedConfigValue(option: OptionName, config: FlutterFreezedPluginConfig, typeName?: string | undefined): any;
15
+ export declare const isDartKeyword: (identifier: string) => boolean;
14
16
  /**
15
- * @description filters the customDirectives to return those that are applied on a list of blocks
17
+ * Ensures that the blockName isn't a valid Dart language reserved keyword.
18
+ * It wraps the identifier with the prefix and suffix then transforms the casing as specified in the config
19
+ * @param config
20
+ * @param name
21
+ * @param typeName
22
+ * @returns
16
23
  */
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<T>(option: OptionName): T;
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
- get(key: string): FreezedFactoryBlock | undefined;
45
- register(key: string, value: FreezedFactoryBlock): FreezedFactoryBlock;
46
- retrieve(key: string, appliesOn: string, name: string, typeName: string | undefined): string;
47
- }
48
- /** initializes a FreezedPluginConfig with the defaults values */
49
- export declare class DefaultFreezedPluginConfig implements FlutterFreezedPluginConfig {
50
- camelCasedEnums?: boolean;
51
- customScalars?: {
52
- [name: string]: string;
53
- };
54
- fileName?: string;
55
- globalFreezedConfig?: FreezedConfig;
56
- typeSpecificFreezedConfig?: Record<string, TypeSpecificFreezedConfig>;
57
- ignoreTypes?: string[];
58
- constructor(config?: FlutterFreezedPluginConfig);
59
- }
60
- /** initializes a FreezedConfig with the defaults values */
61
- export declare class DefaultFreezedConfig implements FreezedConfig {
62
- alwaysUseJsonKeyName?: boolean;
63
- copyWith?: boolean;
64
- customDecorators?: CustomDecorator;
65
- defaultUnionConstructor?: boolean;
66
- equal?: boolean;
67
- fromJsonToJson?: boolean;
68
- immutable?: boolean;
69
- makeCollectionsUnmodifiable?: boolean;
70
- mergeInputs?: string[];
71
- mutableInputs?: boolean;
72
- privateEmptyConstructor?: boolean;
73
- unionKey?: string;
74
- unionValueCase?: 'FreezedUnionCase.camel' | 'FreezedUnionCase.pascal';
75
- constructor();
76
- }
24
+ export declare const escapeDartKeyword: (config: FlutterFreezedPluginConfig, blockAppliesOn: readonly AppliesOn[], identifier: string, typeName?: TypeName, fieldName?: FieldName) => string;
25
+ declare type JsonKeyOptions = {
26
+ defaultValue?: string;
27
+ disallowNullValue?: boolean;
28
+ fromJson?: string;
29
+ ignore?: boolean;
30
+ includeIfNull?: boolean;
31
+ name?: string;
32
+ required?: boolean;
33
+ toJson?: string;
34
+ };
35
+ export declare const atJsonKeyDecorator: ({ defaultValue, disallowNullValue, fromJson, ignore, includeIfNull, name, required, toJson, }: JsonKeyOptions) => string;
36
+ export declare const stringIsNotEmpty: (str: string) => boolean;
37
+ export {};