@graphql-codegen/flutter-freezed 2.11.2-alpha-20221101110911-a036e7a25 → 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 +6 -6
- 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
package/typings/utils.d.ts
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.js';
|
|
3
|
+
import { AppliesOn, DartIdentifierCasing, FlutterFreezedPluginConfig } from './config/plugin-config.js';
|
|
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 {};
|
package/cjs/config.js
DELETED
package/esm/config.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/typings/config.d.cts
DELETED
|
@@ -1,479 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @name ApplyDecoratorOn
|
|
3
|
-
* @description Values that are passed to the `DecoratorToFreezed.applyOn` field that specifies where the custom decorator should be applied
|
|
4
|
-
*/
|
|
5
|
-
export declare type ApplyDecoratorOn = 'enum' | 'enum_field' | 'class' | 'class_factory' | 'union_factory' | 'merged_input_factory' | 'class_factory_parameter' | 'union_factory_parameter' | 'merged_input_parameter';
|
|
6
|
-
/**
|
|
7
|
-
* @name DecoratorToFreezed
|
|
8
|
-
* @description the value of a `CustomDecorator`. This value specifies how the the decorator should be handled by Freezed
|
|
9
|
-
*/
|
|
10
|
-
export declare type DecoratorToFreezed = {
|
|
11
|
-
/**
|
|
12
|
-
* @name arguments
|
|
13
|
-
* @description Arguments to be applied on the decorator. if the `mapsToFreezedAs === 'directive'`, use template string such `['$0', '$2', '$3']` to select/order the arguments of the directive to be used($0 is the first argument, $1 is the second).
|
|
14
|
-
* @default undefined
|
|
15
|
-
* @exampleMarkdown
|
|
16
|
-
* ```yaml
|
|
17
|
-
* arguments: [$0] # $0 is the first argument, $1 is the 2nd ...
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
arguments?: string[];
|
|
21
|
-
/**
|
|
22
|
-
* @name applyOn
|
|
23
|
-
* @description Specify where the decorator should be applied
|
|
24
|
-
* @exampleMarkdown
|
|
25
|
-
* ```yaml
|
|
26
|
-
* applyOn: ['class_factory','union_factory'], # applies this decorator on both class and union factory blocks
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
applyOn: ApplyDecoratorOn[];
|
|
30
|
-
/**
|
|
31
|
-
* @name mapsToFreezedAs
|
|
32
|
-
* @description maps to a Freezed decorator or use `custom` to use a custom decorator.If `mapsToFreezedAs === 'directive'` don't include the `@` prefix in the key of the customDecorator. If `mapsToFreezedAs === 'custom'` value, whatever you use as the key of the customDecorator is used just as it is, and the arguments spread into a parenthesis () */
|
|
33
|
-
mapsToFreezedAs: '@Default' | '@deprecated' | 'final' | 'directive' | 'custom';
|
|
34
|
-
};
|
|
35
|
-
/**
|
|
36
|
-
* @name CustomDecorator
|
|
37
|
-
* @description
|
|
38
|
-
* use this option to add annotations/decorators for the the generated output. Also use this to add @Assert decorators to validate the properties of the model
|
|
39
|
-
*/
|
|
40
|
-
export declare type CustomDecorator = Record<string, DecoratorToFreezed>;
|
|
41
|
-
/**
|
|
42
|
-
* @name FreezedConfig
|
|
43
|
-
* @description configure what Freeze should generate
|
|
44
|
-
* @default DefaultFreezedConfig
|
|
45
|
-
*/
|
|
46
|
-
export interface FreezedConfig {
|
|
47
|
-
/**
|
|
48
|
-
* @name alwaysUseJsonKeyName
|
|
49
|
-
* @description Use @JsonKey(name: 'name') even if the name is already camelCased
|
|
50
|
-
* @default false
|
|
51
|
-
*
|
|
52
|
-
* @exampleMarkdown
|
|
53
|
-
* ```yaml
|
|
54
|
-
* generates:
|
|
55
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
56
|
-
* plugins:
|
|
57
|
-
* - flutter-freezed
|
|
58
|
-
* config:
|
|
59
|
-
* alwaysUseJsonKeyName: true
|
|
60
|
-
*
|
|
61
|
-
* ```
|
|
62
|
-
*/
|
|
63
|
-
alwaysUseJsonKeyName?: boolean;
|
|
64
|
-
/**
|
|
65
|
-
* @name copyWith
|
|
66
|
-
* @description set to false to disable Freezed copyWith method helper
|
|
67
|
-
* @default undefined
|
|
68
|
-
*
|
|
69
|
-
* @exampleMarkdown
|
|
70
|
-
* ```yaml
|
|
71
|
-
* generates:
|
|
72
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
73
|
-
* plugins:
|
|
74
|
-
* - flutter-freezed
|
|
75
|
-
* config:
|
|
76
|
-
* copyWith: false
|
|
77
|
-
* ```
|
|
78
|
-
*/
|
|
79
|
-
copyWith?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* @name customDecorators
|
|
82
|
-
* @description annotate/decorate the generated output. Also use this option to map GraphQL directives to freezed decorators.
|
|
83
|
-
* @default {}
|
|
84
|
-
*
|
|
85
|
-
* @exampleMarkdown
|
|
86
|
-
* ```yaml
|
|
87
|
-
* generates:
|
|
88
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
89
|
-
* plugins:
|
|
90
|
-
* - flutter-freezed
|
|
91
|
-
* config:
|
|
92
|
-
* customDecorators: {
|
|
93
|
-
* 'default' : {
|
|
94
|
-
* mapsToFreezedAs: '@Default',
|
|
95
|
-
* arguments: ['$0'],
|
|
96
|
-
* },
|
|
97
|
-
* 'deprecated' : {
|
|
98
|
-
* mapsToFreezedAs: '@deprecated',
|
|
99
|
-
* },
|
|
100
|
-
* 'readonly' : {
|
|
101
|
-
* mapsToFreezedAs: 'final',
|
|
102
|
-
* },
|
|
103
|
-
* '@Assert' : {
|
|
104
|
-
* mapsToFreezedAs: 'custom',
|
|
105
|
-
* applyOn: ['class_factory','union_factory'], # @Assert should ONLY be used on factories
|
|
106
|
-
* arguments: [
|
|
107
|
-
* '(email != null && email != "") || (phoneNumber != null && phoneNumber != "")',
|
|
108
|
-
* 'provide either an email or a phoneNumber',
|
|
109
|
-
* ],
|
|
110
|
-
* }, # custom are used just as it given
|
|
111
|
-
* }
|
|
112
|
-
*
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
customDecorators?: CustomDecorator;
|
|
116
|
-
/**
|
|
117
|
-
* @name defaultUnionConstructor
|
|
118
|
-
* @description generate empty constructors for Union Types and mergedInputs
|
|
119
|
-
* @default true
|
|
120
|
-
*
|
|
121
|
-
* @exampleMarkdown
|
|
122
|
-
* ```yaml
|
|
123
|
-
* generates:
|
|
124
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
125
|
-
* plugins:
|
|
126
|
-
* - flutter-freezed
|
|
127
|
-
* config:
|
|
128
|
-
* defaultUnionConstructor: true
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
defaultUnionConstructor?: boolean;
|
|
132
|
-
/**
|
|
133
|
-
* @name equal
|
|
134
|
-
* @description set to false to disable Freezed equal method helper
|
|
135
|
-
* @default undefined
|
|
136
|
-
*
|
|
137
|
-
* @exampleMarkdown
|
|
138
|
-
* ```yaml
|
|
139
|
-
* generates:
|
|
140
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
141
|
-
* plugins:
|
|
142
|
-
* - flutter-freezed
|
|
143
|
-
* config:
|
|
144
|
-
* equal: false
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
equal?: boolean;
|
|
148
|
-
/**
|
|
149
|
-
* @name fromJsonToJson
|
|
150
|
-
* @description generate fromJson toJson methods on the classes with json_serialization. Requires the [json_serializable](https://pub.dev/packages/json_serializable) to be installed in your Flutter app
|
|
151
|
-
* @default true
|
|
152
|
-
*
|
|
153
|
-
* @exampleMarkdown
|
|
154
|
-
* ```yaml
|
|
155
|
-
* generates:
|
|
156
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
157
|
-
* plugins:
|
|
158
|
-
* - flutter-freezed
|
|
159
|
-
* config:
|
|
160
|
-
* fromJsonToJson: true
|
|
161
|
-
*
|
|
162
|
-
* ```
|
|
163
|
-
*/
|
|
164
|
-
fromJsonToJson?: boolean;
|
|
165
|
-
/**
|
|
166
|
-
* @name immutable
|
|
167
|
-
* @description set to true to use the `@freezed` decorator or false to use the `@unfreezed` decorator
|
|
168
|
-
* @default true
|
|
169
|
-
*
|
|
170
|
-
* @exampleMarkdown
|
|
171
|
-
* ```yaml
|
|
172
|
-
* generates:
|
|
173
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
174
|
-
* plugins:
|
|
175
|
-
* - flutter-freezed
|
|
176
|
-
* config:
|
|
177
|
-
* immutable: true
|
|
178
|
-
*
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
immutable?: boolean;
|
|
182
|
-
/**
|
|
183
|
-
* @name makeCollectionsUnmodifiable
|
|
184
|
-
* @description allows collections(lists/maps) to be modified even if class is immutable
|
|
185
|
-
* @default undefined
|
|
186
|
-
*
|
|
187
|
-
* @exampleMarkdown
|
|
188
|
-
* ```yaml
|
|
189
|
-
* generates:
|
|
190
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
191
|
-
* plugins:
|
|
192
|
-
* - flutter-freezed
|
|
193
|
-
* config:
|
|
194
|
-
* makeCollectionsUnmodifiable: true
|
|
195
|
-
*
|
|
196
|
-
* ```
|
|
197
|
-
*/
|
|
198
|
-
makeCollectionsUnmodifiable?: boolean;
|
|
199
|
-
/**
|
|
200
|
-
* @name mergeInputs
|
|
201
|
-
* @description merge InputTypes as a union of an ObjectType where ObjectType is denoted by a $ in the pattern.
|
|
202
|
-
* @default []
|
|
203
|
-
*
|
|
204
|
-
* @exampleMarkdown
|
|
205
|
-
* ```yaml
|
|
206
|
-
* generates:
|
|
207
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
208
|
-
* plugins:
|
|
209
|
-
* - flutter-freezed
|
|
210
|
-
* config:
|
|
211
|
-
* mergeInputs: ["Create$Input", "Update$Input", "Delete$Input"]
|
|
212
|
-
* ```
|
|
213
|
-
*/
|
|
214
|
-
mergeInputs?: string[];
|
|
215
|
-
/**
|
|
216
|
-
* @name mutableInputs
|
|
217
|
-
* @description since inputs will be used to collect data, it makes sense to make them mutable with Freezed's `@unfreezed` decorator. This overrides(in order words: has a higher precedence than) the `immutable` config value `ONLY` for GraphQL `input types`.
|
|
218
|
-
* @default true
|
|
219
|
-
*
|
|
220
|
-
* @exampleMarkdown
|
|
221
|
-
* ```yaml
|
|
222
|
-
* generates:
|
|
223
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
224
|
-
* plugins:
|
|
225
|
-
* - flutter-freezed
|
|
226
|
-
* config:
|
|
227
|
-
* mutableInputs: true
|
|
228
|
-
*
|
|
229
|
-
* ```
|
|
230
|
-
*/
|
|
231
|
-
mutableInputs?: boolean;
|
|
232
|
-
/**
|
|
233
|
-
* @name privateEmptyConstructor
|
|
234
|
-
* @description if true, defines a private empty constructor to allow getter and methods to work on the class
|
|
235
|
-
* @default true
|
|
236
|
-
*
|
|
237
|
-
* @exampleMarkdown
|
|
238
|
-
* ```yaml
|
|
239
|
-
* generates:
|
|
240
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
241
|
-
* plugins:
|
|
242
|
-
* - flutter-freezed
|
|
243
|
-
* config:
|
|
244
|
-
* privateEmptyConstructor: true
|
|
245
|
-
*
|
|
246
|
-
* ```
|
|
247
|
-
*/
|
|
248
|
-
privateEmptyConstructor?: boolean;
|
|
249
|
-
/**
|
|
250
|
-
* @name unionKey
|
|
251
|
-
* @description specify the key to be used for Freezed union/sealed classes
|
|
252
|
-
* @default undefined
|
|
253
|
-
*
|
|
254
|
-
* @exampleMarkdown
|
|
255
|
-
* ```yaml
|
|
256
|
-
* generates:
|
|
257
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
258
|
-
* plugins:
|
|
259
|
-
* - flutter-freezed
|
|
260
|
-
* config:
|
|
261
|
-
* unionKey: 'type'
|
|
262
|
-
*
|
|
263
|
-
* ```
|
|
264
|
-
*/
|
|
265
|
-
unionKey?: string;
|
|
266
|
-
/**
|
|
267
|
-
* @name unionValueCase
|
|
268
|
-
* @description specify the casing style to be used for Freezed union/sealed classes
|
|
269
|
-
* @default undefined
|
|
270
|
-
*
|
|
271
|
-
* @exampleMarkdown
|
|
272
|
-
* ```yaml
|
|
273
|
-
* generates:
|
|
274
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
275
|
-
* plugins:
|
|
276
|
-
* - flutter-freezed
|
|
277
|
-
* config:
|
|
278
|
-
* unionValueCase: 'FreezedUnionCase.pascal'
|
|
279
|
-
*
|
|
280
|
-
* ```
|
|
281
|
-
*/
|
|
282
|
-
unionValueCase?: 'FreezedUnionCase.camel' | 'FreezedUnionCase.pascal';
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* @name FieldConfig
|
|
286
|
-
* @description configuration for the field
|
|
287
|
-
*/
|
|
288
|
-
export interface FieldConfig {
|
|
289
|
-
/**
|
|
290
|
-
* @name final
|
|
291
|
-
* @description marks a field as final
|
|
292
|
-
* @default undefined
|
|
293
|
-
*/
|
|
294
|
-
final?: boolean;
|
|
295
|
-
/**
|
|
296
|
-
* @name deprecated
|
|
297
|
-
* @description marks a field as deprecated
|
|
298
|
-
* @default undefined
|
|
299
|
-
*/
|
|
300
|
-
deprecated?: boolean;
|
|
301
|
-
/**
|
|
302
|
-
* @name defaultValue
|
|
303
|
-
* @description annotate a field with a @Default(value: defaultValue) decorator
|
|
304
|
-
* @default undefined
|
|
305
|
-
*/
|
|
306
|
-
defaultValue?: any;
|
|
307
|
-
/**
|
|
308
|
-
* @name customDecorators
|
|
309
|
-
* @description specific directives to apply to the field. All `mapsToFreezedAs` values except `custom` are parsed so use the name of the directive without the `@` symbol as the key of the customDecorators. With the `custom` value, whatever you use as the key of the custom directive is used just as it is, and the arguments spread into a parenthesis ()
|
|
310
|
-
* @default undefined
|
|
311
|
-
* @exampleMarkdown
|
|
312
|
-
* ```yaml
|
|
313
|
-
* customDecorators: {
|
|
314
|
-
* 'default' : {
|
|
315
|
-
* mapsToFreezedAs: '@Default',
|
|
316
|
-
* applyOn: ['class_factory_parameter],
|
|
317
|
-
* arguments: ['$0'],
|
|
318
|
-
* },
|
|
319
|
-
* 'deprecated' : {
|
|
320
|
-
* mapsToFreezedAs: '@deprecated',
|
|
321
|
-
* applyOn: ['union_factory_parameter],
|
|
322
|
-
* },
|
|
323
|
-
* 'readonly' : {
|
|
324
|
-
* mapsToFreezedAs: 'final',
|
|
325
|
-
* applyOn: ['class_factory_parameter','union_factory_parameter'],
|
|
326
|
-
* },
|
|
327
|
-
* '@HiveField' : {
|
|
328
|
-
* mapsToFreezedAs: 'custom',
|
|
329
|
-
* applyOn: ['class_factory_parameter'],
|
|
330
|
-
* arguments: ['1'],
|
|
331
|
-
* }, # custom are used just as it given
|
|
332
|
-
* }
|
|
333
|
-
* ```
|
|
334
|
-
*/
|
|
335
|
-
customDecorators?: CustomDecorator;
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* @name TypeSpecificFreezedConfig
|
|
339
|
-
* @description override the `FlutterFreezedPluginConfig.globalFreezedConfig` option for a specific type
|
|
340
|
-
*/
|
|
341
|
-
export interface TypeSpecificFreezedConfig {
|
|
342
|
-
/** marks a type as deprecated */
|
|
343
|
-
deprecated?: boolean;
|
|
344
|
-
/** overrides the `globalFreezedConfig` for this type */
|
|
345
|
-
config?: FreezedConfig;
|
|
346
|
-
/** configure fields for this type. The GraphQL field name is the key */
|
|
347
|
-
fields?: Record<string, FieldConfig>;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* @name FlutterFreezedPluginConfig
|
|
351
|
-
* @description configure the `flutter-freezed` plugin
|
|
352
|
-
*/
|
|
353
|
-
export interface FlutterFreezedPluginConfig {
|
|
354
|
-
/**
|
|
355
|
-
* @name camelCasedEnums
|
|
356
|
-
* @description Dart's recommended lint uses camelCase for enum fields. Set this option to `false` to use the same case as used in the GraphQL Schema but note this can cause lint issues.
|
|
357
|
-
* @default true
|
|
358
|
-
*
|
|
359
|
-
* @exampleMarkdown
|
|
360
|
-
* ```yaml
|
|
361
|
-
* generates:
|
|
362
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
363
|
-
* plugins:
|
|
364
|
-
* - flutter-freezed
|
|
365
|
-
* config:
|
|
366
|
-
* camelCasedEnums: true
|
|
367
|
-
* ```
|
|
368
|
-
*/
|
|
369
|
-
camelCasedEnums?: boolean;
|
|
370
|
-
/**
|
|
371
|
-
* @name customScalars
|
|
372
|
-
* @description map custom Scalars to Dart built-in types
|
|
373
|
-
* @default {}
|
|
374
|
-
*
|
|
375
|
-
* @exampleMarkdown
|
|
376
|
-
* ```yaml
|
|
377
|
-
* generates:
|
|
378
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
379
|
-
* plugins:
|
|
380
|
-
* - flutter-freezed
|
|
381
|
-
* config:
|
|
382
|
-
* customScalars:
|
|
383
|
-
* {
|
|
384
|
-
* "jsonb": "Map<String, dynamic>",
|
|
385
|
-
* "timestamptz": "DateTime",
|
|
386
|
-
* "UUID": "String",
|
|
387
|
-
* }
|
|
388
|
-
* ```
|
|
389
|
-
*/
|
|
390
|
-
customScalars?: {
|
|
391
|
-
[name: string]: string;
|
|
392
|
-
};
|
|
393
|
-
/**
|
|
394
|
-
* @name fileName
|
|
395
|
-
* @description this fileName will be used for the generated output file
|
|
396
|
-
* @default "app_models"
|
|
397
|
-
*
|
|
398
|
-
* @exampleMarkdown
|
|
399
|
-
* ```yaml
|
|
400
|
-
* generates:
|
|
401
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
402
|
-
* plugins:
|
|
403
|
-
* - flutter-freezed
|
|
404
|
-
* config:
|
|
405
|
-
* fileName: app_models
|
|
406
|
-
*
|
|
407
|
-
* ```
|
|
408
|
-
*/
|
|
409
|
-
fileName?: string;
|
|
410
|
-
/**
|
|
411
|
-
* @name globalFreezedConfig
|
|
412
|
-
* @description use the same Freezed configuration for every generated output
|
|
413
|
-
* @default DefaultFreezedConfig
|
|
414
|
-
*
|
|
415
|
-
* @exampleMarkdown
|
|
416
|
-
* ```yaml
|
|
417
|
-
* generates:
|
|
418
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
419
|
-
* plugins:
|
|
420
|
-
* - flutter-freezed
|
|
421
|
-
* config:
|
|
422
|
-
* globalFreezedConfig:
|
|
423
|
-
* {
|
|
424
|
-
* immutable: false,
|
|
425
|
-
* unionValueCase: FreezedUnionCase.pascal,
|
|
426
|
-
* }
|
|
427
|
-
*
|
|
428
|
-
* ```
|
|
429
|
-
*/
|
|
430
|
-
globalFreezedConfig?: FreezedConfig;
|
|
431
|
-
/**
|
|
432
|
-
* @name typeSpecificFreezedConfig
|
|
433
|
-
* @description override the `globalFreezedConfig` for specific types. The GraphQL Type name is the key
|
|
434
|
-
* @default undefined
|
|
435
|
-
*
|
|
436
|
-
* @exampleMarkdown
|
|
437
|
-
* ```yaml
|
|
438
|
-
* generates:
|
|
439
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
440
|
-
* plugins:
|
|
441
|
-
* - flutter-freezed
|
|
442
|
-
* config:
|
|
443
|
-
* typeSpecificFreezedConfig:
|
|
444
|
-
* {
|
|
445
|
-
* 'Starship':{
|
|
446
|
-
* config: {
|
|
447
|
-
* immutable: false,
|
|
448
|
-
* unionValueCase: FreezedUnionCase.pascal,
|
|
449
|
-
* },
|
|
450
|
-
* fields: {
|
|
451
|
-
* 'id': {
|
|
452
|
-
* final: true,
|
|
453
|
-
* defaultValue: NanoId.id(),
|
|
454
|
-
* },
|
|
455
|
-
* },
|
|
456
|
-
* },
|
|
457
|
-
* },
|
|
458
|
-
*
|
|
459
|
-
* ```
|
|
460
|
-
*/
|
|
461
|
-
typeSpecificFreezedConfig?: Record<string, TypeSpecificFreezedConfig>;
|
|
462
|
-
/**
|
|
463
|
-
* @name ignoreTypes
|
|
464
|
-
* @description names of GraphQL types to ignore when generating Freezed classes
|
|
465
|
-
* @default []
|
|
466
|
-
*
|
|
467
|
-
* @exampleMarkdown
|
|
468
|
-
* ```yaml
|
|
469
|
-
* generates:
|
|
470
|
-
* flutter_app/lib/data/models/app_models.dart
|
|
471
|
-
* plugins:
|
|
472
|
-
* - flutter-freezed
|
|
473
|
-
* config:
|
|
474
|
-
* ignoreTypes: ["PaginatorInfo"]
|
|
475
|
-
*
|
|
476
|
-
* ```
|
|
477
|
-
*/
|
|
478
|
-
ignoreTypes?: string[];
|
|
479
|
-
}
|