@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.
- package/cjs/config/config-value.js +132 -0
- package/cjs/config/pattern.js +731 -0
- package/cjs/config/plugin-config.js +140 -0
- package/cjs/freezed-declaration-blocks/class-block.js +87 -224
- package/cjs/freezed-declaration-blocks/enum-block.js +54 -0
- package/cjs/freezed-declaration-blocks/factory-block.js +81 -113
- package/cjs/freezed-declaration-blocks/index.js +91 -4
- package/cjs/freezed-declaration-blocks/node-repository.js +26 -0
- package/cjs/freezed-declaration-blocks/parameter-block.js +55 -143
- package/cjs/index.js +10 -14
- package/cjs/schema-visitor.js +8 -7
- package/cjs/utils.js +64 -219
- package/esm/config/config-value.js +128 -0
- package/esm/config/pattern.js +723 -0
- package/esm/config/plugin-config.js +137 -0
- package/esm/freezed-declaration-blocks/class-block.js +86 -223
- package/esm/freezed-declaration-blocks/enum-block.js +50 -0
- package/esm/freezed-declaration-blocks/factory-block.js +81 -113
- package/esm/freezed-declaration-blocks/index.js +89 -3
- package/esm/freezed-declaration-blocks/node-repository.js +22 -0
- package/esm/freezed-declaration-blocks/parameter-block.js +53 -141
- package/esm/index.js +11 -15
- package/esm/schema-visitor.js +8 -7
- package/esm/utils.js +56 -212
- package/package.json +5 -5
- package/typings/config/config-value.d.cts +24 -0
- package/typings/config/config-value.d.ts +24 -0
- package/typings/config/pattern.d.cts +252 -0
- package/typings/config/pattern.d.ts +252 -0
- package/typings/config/plugin-config.d.cts +683 -0
- package/typings/config/plugin-config.d.ts +683 -0
- package/typings/freezed-declaration-blocks/class-block.d.cts +11 -35
- package/typings/freezed-declaration-blocks/class-block.d.ts +11 -35
- package/typings/freezed-declaration-blocks/enum-block.d.cts +10 -0
- package/typings/freezed-declaration-blocks/enum-block.d.ts +10 -0
- package/typings/freezed-declaration-blocks/factory-block.d.cts +16 -37
- package/typings/freezed-declaration-blocks/factory-block.d.ts +16 -37
- package/typings/freezed-declaration-blocks/index.d.cts +27 -3
- package/typings/freezed-declaration-blocks/index.d.ts +27 -3
- package/typings/freezed-declaration-blocks/node-repository.d.cts +10 -0
- package/typings/freezed-declaration-blocks/node-repository.d.ts +10 -0
- package/typings/freezed-declaration-blocks/parameter-block.d.cts +11 -44
- package/typings/freezed-declaration-blocks/parameter-block.d.ts +11 -44
- package/typings/index.d.cts +1 -1
- package/typings/index.d.ts +1 -1
- package/typings/schema-visitor.d.cts +7 -7
- package/typings/schema-visitor.d.ts +7 -7
- package/typings/utils.d.cts +33 -72
- package/typings/utils.d.ts +33 -72
- package/cjs/config.js +0 -2
- package/esm/config.js +0 -1
- package/typings/config.d.cts +0 -479
- package/typings/config.d.ts +0 -479
|
@@ -1,36 +1,12 @@
|
|
|
1
|
-
import { FlutterFreezedPluginConfig } from '../config.cjs';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 {
|
|
2
|
-
import { FlutterFreezedPluginConfig } from '../config.cjs';
|
|
3
|
-
import {
|
|
4
|
-
export declare class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 {
|
|
2
|
-
import { FlutterFreezedPluginConfig } from '../config.js';
|
|
3
|
-
import {
|
|
4
|
-
export declare class
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
|
}
|
package/typings/index.d.cts
CHANGED
|
@@ -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>;
|
package/typings/index.d.ts
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
6
|
-
EnumTypeDefinition: (node: EnumTypeDefinitionNode) =>
|
|
7
|
-
UnionTypeDefinition: (node: UnionTypeDefinitionNode) =>
|
|
8
|
-
ObjectTypeDefinition: (node: ObjectTypeDefinitionNode) =>
|
|
9
|
-
InputObjectTypeDefinition: (node: InputObjectTypeDefinitionNode) =>
|
|
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 {
|
|
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
|
-
|
|
6
|
-
EnumTypeDefinition: (node: EnumTypeDefinitionNode) =>
|
|
7
|
-
UnionTypeDefinition: (node: UnionTypeDefinitionNode) =>
|
|
8
|
-
ObjectTypeDefinition: (node: ObjectTypeDefinitionNode) =>
|
|
9
|
-
InputObjectTypeDefinition: (node: InputObjectTypeDefinitionNode) =>
|
|
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
|
};
|
package/typings/utils.d.cts
CHANGED
|
@@ -1,76 +1,37 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
export declare
|
|
5
|
-
export declare
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
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
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
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
|
|
15
|
+
export declare const isDartKeyword: (identifier: string) => boolean;
|
|
14
16
|
/**
|
|
15
|
-
*
|
|
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
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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 {};
|