@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.
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 +6 -6
  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
@@ -0,0 +1,683 @@
1
+ import { ObjectTypeDefinitionNode, InputObjectTypeDefinitionNode, UnionTypeDefinitionNode, EnumTypeDefinitionNode, FieldDefinitionNode, InputValueDefinitionNode } from 'graphql';
2
+ import { TypeNamePattern, TypeName, FieldNamePattern, Pattern } from './pattern.js';
3
+ /**
4
+ * @name FlutterFreezedPluginConfig
5
+ * @description configure the `flutter-freezed` plugin
6
+ */
7
+ export declare type FlutterFreezedPluginConfig = {
8
+ /**
9
+ * @name camelCasedEnums
10
+ * @type {(boolean | DartIdentifierCasing)}
11
+ * @default true
12
+ * @summary Specify how Enum values should be cased.
13
+ * @description Setting this option to `true` will camelCase enum values as required by Dart's recommended linter.
14
+ *
15
+ * If set to false, the original casing as specified in the Graphql Schema is used
16
+ *
17
+ * You can also transform the casing by specifying your preferred casing for Enum values.
18
+ *
19
+ * Available options are: `'snake_case'`, `'camelCase'` and `'PascalCase'`
20
+ *
21
+ * For consistency, this option applies the same configuration to all Enum Types in the GraphQL Schema
22
+ * @exampleMarkdown
23
+ * ## Usage:
24
+ * ```ts filename='codegen.ts'
25
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
26
+ *
27
+ * const config: CodegenConfig = {
28
+ * // ...
29
+ * generates: {
30
+ * 'lib/data/models/app_models.dart': {
31
+ * plugins: {
32
+ * 'flutter-freezed': {
33
+ * // ...
34
+ * camelCasedEnums: true, // or false
35
+ * // OR: specify a DartIdentifierCasing
36
+ * camelCasedEnums: 'snake_case',
37
+ * },
38
+ * },
39
+ * },
40
+ * },
41
+ * };
42
+ * export default config;
43
+ * ```
44
+ */
45
+ camelCasedEnums?: boolean | DartIdentifierCasing;
46
+ /**
47
+ * @name copyWith
48
+ * @type {(boolean | TypeNamePattern)}
49
+ * @default undefined
50
+ * @see {@link https://pub.dev/packages/freezed#how-copywith-works How copyWith works}
51
+ * @see {@link https://pub.dev/documentation/freezed_annotation/latest/freezed_annotation/Freezed/copyWith.html Freezed annotation copyWith property}
52
+ * @summary enables Freezed copyWith helper method
53
+ * @description The [`freezed`](https://pub.dev/packages/freezed) library has this option enabled by default.
54
+ * Use this option to enable/disable this option completely.
55
+ *
56
+ * The plugin by default generates immutable Freezed models using the `@freezed` decorator.
57
+ *
58
+ * If this option is configured, the plugin will generate immutable Freezed models using the `@Freezed(copyWith: value)` instead.
59
+ *
60
+ * Setting a boolean value will enable/disable this option globally for every GraphQL Type
61
+ * but you can also set this option to `true` for one or more GraphQL Types using a `TypeNamePattern`.
62
+ * @exampleMarkdown
63
+ * ## Usage:
64
+ * ```ts filename='codegen.ts'
65
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
66
+ *
67
+ * const config: CodegenConfig = {
68
+ * // ...
69
+ * generates: {
70
+ * 'lib/data/models/app_models.dart': {
71
+ * plugins: {
72
+ * 'flutter-freezed': {
73
+ * // ...
74
+ * copyWith: true,
75
+ * // OR: enable it for only Droid and Starship GraphQL types
76
+ * copyWith: TypeNamePattern.forTypeNames([Droid, Starship]),
77
+ * },
78
+ * },
79
+ * },
80
+ * },
81
+ * };
82
+ * export default config;
83
+ * ```
84
+ */
85
+ copyWith?: boolean | TypeNamePattern;
86
+ /**
87
+ * @name customScalars
88
+ * @type {(Record<string, string>)}
89
+ * @default {}
90
+ * @summary Maps GraphQL Scalar Types to Dart built-in types
91
+ * @description The `key` is the GraphQL Scalar Type and the `value` is the equivalent Dart Type
92
+ *
93
+ * The plugin automatically handles built-in GraphQL Scalar Types so only specify the custom Scalars in your Graphql Schema.
94
+ * @exampleMarkdown
95
+ * ## Usage
96
+ * ```ts filename='codegen.ts'
97
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
98
+ *
99
+ * const config: CodegenConfig = {
100
+ * // ...
101
+ * generates: {
102
+ * 'lib/data/models/app_models.dart': {
103
+ * plugins: {
104
+ * 'flutter-freezed': {
105
+ * // ...
106
+ * customScalars: {
107
+ * jsonb: 'Map<String, dynamic>',
108
+ * timestamp: 'DateTime',
109
+ * UUID: 'String',
110
+ * },
111
+ * },
112
+ * },
113
+ * },
114
+ * },
115
+ * };
116
+ * export default config;
117
+ * ```
118
+ */
119
+ customScalars?: Record<string, string>;
120
+ /**
121
+ * @name defaultValues
122
+ * @type {([pattern: FieldNamePattern, value: string, appliesOn: AppliesOnParameters[], directiveName?: string, directiveArgName?: string][])}
123
+ * @default undefined
124
+ * @see {@link https://pub.dev/packages/freezed#default-values Default values}
125
+ * @see {@link https://pub.dev/documentation/freezed_annotation/latest/freezed_annotation/Default-class.html Default class}
126
+ * @summary set the default value for a field.
127
+ * @description This will annotate the generated parameter with a `@Default(value: defaultValue)` decorator.
128
+ *
129
+ * The default value will be interpolated into the `@Default(value: ${value})` decorator so
130
+ * Use backticks for the value element so that you can use quotation marks for string values.
131
+ * E.g: `"I'm a string default value"` but `Episode.jedi` is not a string value.
132
+ *
133
+ * Use the `appliesOn` to specify where this option should be applied on
134
+ *
135
+ * If the `directiveName` and `directiveArgName` are passed, the value of the argument of the given directive specified in the Graphql Schema will be used as the defaultValue
136
+ * @exampleMarkdown
137
+ * ## Usage:
138
+ * ```ts filename='codegen.ts'
139
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
140
+ *
141
+ * const config: CodegenConfig = {
142
+ * // ...
143
+ * generates: {
144
+ * 'lib/data/models/app_models.dart': {
145
+ * plugins: {
146
+ * 'flutter-freezed': {
147
+ * // ...
148
+ * defaultValues: [
149
+ * [FieldNamePattern.forFieldNamesOfTypeName(MovieCharacter, appearsIn), `Episode.jedi`, ['default_factory_parameter']],
150
+ * ],
151
+ * },
152
+ * },
153
+ * },
154
+ * },
155
+ * };
156
+ * export default config;
157
+ * ```
158
+ */
159
+ defaultValues?: [
160
+ pattern: FieldNamePattern,
161
+ value: string,
162
+ appliesOn: AppliesOnParameters[]
163
+ ][];
164
+ /**
165
+ * @name deprecated
166
+ * @type {([pattern: Pattern, appliesOn: (AppliesOnFactory | AppliesOnParameters)[]][])}
167
+ * @default undefined
168
+ * @see {@link https://pub.dev/packages/freezed#decorators-and-comments Decorators and comments}
169
+ * @summary a list of Graphql Types(factory constructors) or fields(parameters) to be marked as deprecated.
170
+ * @description Using a TypeNamePattern, you can mark an entire factory constructor for one or more GraphQL types as deprecated.
171
+ *
172
+ * Likewise, using a FieldNamePattern, you can mark one or more fields as deprecated
173
+ *
174
+ * Since the first element in the tuple has a type signature of `Pattern`,
175
+ * you can use either TypeNamePattern or FieldNamePattern or use both
176
+ * by composing them with `Pattern.compose(...)`
177
+ *
178
+ * Use the `appliesOn` to specify which block this option should be applied on
179
+ * @exampleMarkdown
180
+ * ## Usage:
181
+ *
182
+ * ```ts filename='codegen.ts'
183
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
184
+ *
185
+ * const config: CodegenConfig = {
186
+ * // ...
187
+ * generates: {
188
+ * 'lib/data/models/app_models.dart': {
189
+ * plugins: {
190
+ * 'flutter-freezed': {
191
+ * // ...
192
+ * deprecated: [
193
+ * // using FieldNamePattern
194
+ * [FieldNamePattern.forFieldNamesOfTypeName(MovieCharacter, [appearsIn, name]), ['default_factory_parameter']],
195
+ * // using TypeNamePattern
196
+ * [TypeNamePattern.forTypeNames([Starship,Droid,Human]), ['union_factory']],
197
+ * ],
198
+ * },
199
+ * },
200
+ * },
201
+ * },
202
+ * };
203
+ * export default config;
204
+ * ```
205
+ */
206
+ deprecated?: [pattern: Pattern, appliesOn: (AppliesOnFactory | AppliesOnParameters)[]][];
207
+ /**
208
+ * @name equal
209
+ * @type {(boolean | TypeNamePattern)}
210
+ * @default undefined
211
+ * @see {@link url Freezed equal helper method usage}
212
+ * @see {@link https://pub.dev/documentation/freezed_annotation/latest/freezed_annotation/Freezed/equal.html Freezed annotation equal property}
213
+ * @summary enables Freezed equal helper method
214
+ * @description The [`freezed`](https://pub.dev/packages/freezed) library has this option enabled by default.
215
+ * Use this option to enable/disable this option completely.
216
+ *
217
+ * The plugin by default generates immutable Freezed models using the `@freezed` decorator.
218
+ *
219
+ * If this option is configured, the plugin will generate immutable Freezed models using the `@Freezed(equal: value)` instead.
220
+ *
221
+ * Setting a boolean value will enable/disable this option globally for every GraphQL Type
222
+ * but you can also set this option to `true` for one or more GraphQL Types using a `TypeNamePattern`.
223
+ * @exampleMarkdown
224
+ * ## Usage:
225
+ * ```ts filename='codegen.ts'
226
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
227
+ *
228
+ * const config: CodegenConfig = {
229
+ * // ...
230
+ * generates: {
231
+ * 'lib/data/models/app_models.dart': {
232
+ * plugins: {
233
+ * 'flutter-freezed': {
234
+ * // ...
235
+ * equal: true,
236
+ * // OR: enable it for only Droid and Starship GraphQL types
237
+ * equal: TypeNamePattern.forTypeNames([Droid, Starship]),
238
+ * },
239
+ * },
240
+ * },
241
+ * },
242
+ * };
243
+ * export default config;
244
+ * ```
245
+ */
246
+ equal?: boolean | TypeNamePattern;
247
+ /**
248
+ * @name escapeDartKeywords
249
+ * @default true
250
+ * @see_also [dartKeywordEscapePrefix,dartKeywordEscapeSuffix]
251
+ * @summary ensures that the generated Freezed models doesn't use any of Dart's reserved keywords as identifiers
252
+ * @description Wraps the fields names that are valid Dart keywords with the prefix and suffix given and allows you to specify your preferred casing: "snake_case" | "camelCase" | "PascalCase"
253
+ *
254
+ *
255
+ * @exampleMarkdown
256
+ * ## Usage:
257
+ *
258
+ * ```ts filename='codegen.ts'
259
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
260
+ *
261
+ * const config: CodegenConfig = {
262
+ * // ...
263
+ * generates: {
264
+ * 'lib/data/models/app_models.dart': {
265
+ * plugins: {
266
+ * 'flutter-freezed': {
267
+ * // ...
268
+ * // WARNING: Setting this option to `false` might generate output that contains Dart keywords as identifiers. Defaults to `true`
269
+ * escapeDartKeywords: false,
270
+ * // OR configure how Dart keywords are handled for each type
271
+ * escapeDartKeywords: [
272
+ * [
273
+ * 'Episode.@*FieldNames',
274
+ * // `prefix`: defaults to an empty string `''` if undefined.
275
+ * // Note that using a underscore `_` as a prefix will make the field as private
276
+ * undefined,
277
+ * // `suffix`: defaults to an underscore `_` if undefined
278
+ * undefined,
279
+ * // `casing`: maintains the original casing if undefined.
280
+ * // Available options: `snake_cased`, `camelCase` or `PascalCase`
281
+ * undefined,
282
+ * // `appliesOn`: defaults to an ['enum', 'enum_value', 'class', 'factory', 'parameter'] if undefined.
283
+ * undefined,
284
+ * ],
285
+ * ],
286
+ * },
287
+ * },
288
+ * },
289
+ * },
290
+ * };
291
+ * export default config;
292
+ * ```
293
+ */
294
+ escapeDartKeywords?: boolean | [pattern: Pattern, prefix?: string, suffix?: string, appliesOn?: AppliesOn[]][];
295
+ /**
296
+ * @name final
297
+ * @summary marks fields as final
298
+ * @description This will mark the specified parameters as final
299
+ *
300
+ * Requires a an array of tuples with the type signature below:
301
+ *
302
+ * ` [typeFieldName: TypeFieldName, appliesOn: AppliesOnParameters[]]`
303
+ * @default undefined
304
+ * @exampleMarkdown
305
+ * ## Usage:
306
+ * ```ts filename='codegen.ts'
307
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
308
+ *
309
+ * const config: CodegenConfig = {
310
+ * // ...
311
+ * generates: {
312
+ * 'lib/data/models/app_models.dart': {
313
+ * plugins: {
314
+ * 'flutter-freezed': {
315
+ * // ...
316
+ * final: [
317
+ * ['Human.[name]', ['parameter']],
318
+ * ['Starship.[id],Droid.[id],Human.[id]', ['default_factory_parameter']],
319
+ * ],
320
+ * },
321
+ * },
322
+ * },
323
+ * },
324
+ * };
325
+ * export default config;
326
+ * ```
327
+ */
328
+ final?: [pattern: FieldNamePattern, appliesOn: AppliesOnParameters[]][];
329
+ /**
330
+ * @name ignoreTypes
331
+ * @type {(TypeNamePattern)}
332
+ * @default undefined
333
+ * @description names of GraphQL types to ignore when generating Freezed classes
334
+ *
335
+ * @exampleMarkdown
336
+ * ## Usage:
337
+ * ```ts filename='codegen.ts'
338
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
339
+ *
340
+ * const config: CodegenConfig = {
341
+ * // ...
342
+ * generates: {
343
+ * 'lib/data/models/app_models.dart': {
344
+ * plugins: {
345
+ * 'flutter-freezed': {
346
+ * // ...
347
+ * ignoreTypes: ['PaginatorInfo'],
348
+ * },
349
+ * },
350
+ * },
351
+ * },
352
+ * };
353
+ * export default config;
354
+ * ```
355
+ */
356
+ ignoreTypes?: TypeNamePattern;
357
+ /**
358
+ * @name immutable
359
+ * @type {(boolean | TypeNamePattern)}
360
+ * @default undefined
361
+ * @see {@link https://pub.dev/packages/freezed#creating-a-model-using-freezed Creating a Model using Freezed}
362
+ * @summary enables Freezed immutable helper method
363
+ * @description set to true to use the `@freezed` decorator or false to use the `@unfreezed` decorator
364
+ * @description The [`freezed`](https://pub.dev/packages/freezed) library by default generates immutable models decorated with the `@freezed` decorator.
365
+ * This option if set to `false` the plugin will generate mutable Freezed models using the `@unfreezed` decorator instead.
366
+ *
367
+ * Setting a boolean value will enable/disable this option globally for every GraphQL Type
368
+ * but you can also set this option to `true` for one or more GraphQL Types using a `TypeNamePattern`.
369
+ * @exampleMarkdown
370
+ * ## Usage:
371
+ * ```ts filename='codegen.ts'
372
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
373
+ *
374
+ * const config: CodegenConfig = {
375
+ * // ...
376
+ * generates: {
377
+ * 'lib/data/models/app_models.dart': {
378
+ * plugins: {
379
+ * 'flutter-freezed': {
380
+ * // ...
381
+ * immutable: true,
382
+ * // OR: enable it for all GraphQL types except Droid and Starship types
383
+ * immutable: TypeNamePattern.forTypeNamesExcludeTypeNames([Droid, Starship]),
384
+ * },
385
+ * },
386
+ * },
387
+ * },
388
+ * };
389
+ * export default config;
390
+ * ```
391
+ */
392
+ immutable?: boolean | TypeNamePattern;
393
+ /**
394
+ * @name makeCollectionsUnmodifiable
395
+ * @description allows collections(lists/maps) to be modified even if class is immutable
396
+ * @default undefined
397
+ *
398
+ * @exampleMarkdown
399
+ * ## Usage:
400
+ * ```ts filename='codegen.ts'
401
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
402
+ *
403
+ * const config: CodegenConfig = {
404
+ * // ...
405
+ * generates: {
406
+ * 'lib/data/models/app_models.dart': {
407
+ * plugins: {
408
+ * 'flutter-freezed': {
409
+ * // ...
410
+ * makeCollectionsUnmodifiable: true,
411
+ * // OR: a comma-separated string
412
+ * makeCollectionsUnmodifiable: 'Droid,Starship',
413
+ * // OR: a list of GRaphQL Type names
414
+ * makeCollectionsUnmodifiable: ['Droid', 'Starship'],
415
+ * },
416
+ * },
417
+ * },
418
+ * },
419
+ * };
420
+ * export default config;
421
+ * ```
422
+ */
423
+ makeCollectionsUnmodifiable?: boolean | TypeNamePattern;
424
+ /**
425
+ * @name mergeTypes
426
+ * @default undefined
427
+ * @description merges other GraphQL Types as a named factory constructor inside a class generated for the target GraphQL ObjectType.
428
+ * This option takes an array of strings that are expected to be valid typeNames of GraphQL Types to be merged with the GraphQL Type used as the key.
429
+ * The array is mapped and each string is converted into a TypeName so please ensure that the strings are valid GraphQL TypeNames
430
+ * A string that contains any invalid characters will throw an exception.
431
+ * @exampleMarkdown
432
+ * ```yaml
433
+ * generates:
434
+ * flutter_app/lib/data/models/app_models.dart
435
+ * plugins:
436
+ * - flutter-freezed
437
+ * config:
438
+ * mergeTypes: ["Create$Input", "Update$Input", "Delete$Input"]
439
+ * ```
440
+ */
441
+ mergeTypes?: Record<string, string[]>;
442
+ /**
443
+ * @name mutableInputs
444
+ * @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`.
445
+ * @default true
446
+ *
447
+ * @exampleMarkdown
448
+ * ## Usage:
449
+ * ```ts filename='codegen.ts'
450
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
451
+ *
452
+ * const config: CodegenConfig = {
453
+ * // ...
454
+ * generates: {
455
+ * 'lib/data/models/app_models.dart': {
456
+ * plugins: {
457
+ * 'flutter-freezed': {
458
+ * // ...
459
+ * mutableInputs: true,
460
+ * // OR: a comma-separated string
461
+ * mutableInputs: 'Droid,Starship',
462
+ * // OR: a list of GRaphQL Type names
463
+ * mutableInputs: ['Droid', 'Starship'],
464
+ * },
465
+ * },
466
+ * },
467
+ * },
468
+ * };
469
+ * export default config;
470
+ * ```
471
+ */
472
+ mutableInputs?: boolean | TypeNamePattern;
473
+ /**
474
+ * @name privateEmptyConstructor
475
+ * @description if true, defines a private empty constructor to allow getter and methods to work on the class
476
+ * @default true
477
+ *
478
+ * @exampleMarkdown
479
+ * ## Usage:
480
+ * ```ts filename='codegen.ts'
481
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
482
+ *
483
+ * const config: CodegenConfig = {
484
+ * // ...
485
+ * generates: {
486
+ * 'lib/data/models/app_models.dart': {
487
+ * plugins: {
488
+ * 'flutter-freezed': {
489
+ * // ...
490
+ * privateEmptyConstructor: true,
491
+ * // OR: a comma-separated string
492
+ * privateEmptyConstructor: 'Droid,Starship',
493
+ * // OR: a list of GRaphQL Type names
494
+ * privateEmptyConstructor: ['Droid', 'Starship'],
495
+ * },
496
+ * },
497
+ * },
498
+ * },
499
+ * };
500
+ * export default config;
501
+ * ```
502
+ */
503
+ privateEmptyConstructor?: boolean | TypeNamePattern;
504
+ /**
505
+ * @name unionClass
506
+ * @description customize the key to be used for fromJson with multiple constructors
507
+ * @see {@link https://pub.dev/packages/freezed#fromjson---classes-with-multiple-constructors fromJSON - classes with multiple constructors}
508
+ * @default undefined
509
+ * @exampleMarkdown
510
+ * ## Usage:
511
+ * ```ts filename='codegen.ts'
512
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
513
+ *
514
+ * const config: CodegenConfig = {
515
+ * // ...
516
+ * generates: {
517
+ * 'lib/data/models/app_models.dart': {
518
+ * plugins: {
519
+ * 'flutter-freezed': {
520
+ * // ...
521
+ * unionClass: [
522
+ * [
523
+ * 'SearchResult', // <-- unionTypeName
524
+ * 'namedConstructor', // <-- unionKey
525
+ * 'FreezedUnionCase.pascal', // <-- unionValueCase
526
+ * [ // <-- unionValuesNameMap
527
+ * [ Droid, 'special droid'],
528
+ * [ Human, 'astronaut'],
529
+ * [ Starship, 'space_Shuttle'],
530
+ * ],
531
+ * ],
532
+ * ],
533
+ * },
534
+ * },
535
+ * },
536
+ * },
537
+ * };
538
+ * export default config;
539
+ * ```
540
+ */
541
+ unionClass?: [
542
+ /**
543
+ * The name of the Graphql Union Type (or in the case of merged types, the base type on which other types are merged with)
544
+ */
545
+ unionTypeName: TypeNamePattern,
546
+ /**
547
+ * in a fromJSON/toJson encoding a response/object({key:value}), you can specify what name should be used as the key ?
548
+ */
549
+ unionKey?: string,
550
+ /**
551
+ * normally in camelCase but you can change that to PascalCase
552
+ */
553
+ unionValueCase?: UnionValueCase,
554
+ /**
555
+ * just as the unionKey changes the key used, this changes the value for each union/sealed factories
556
+ */
557
+ unionValuesNameMap?: [typeName: TypeName, unionValueKey: string][]
558
+ ][];
559
+ };
560
+ /**
561
+ * @name ApplyDecoratorOn
562
+ * @description Values that are passed to the `DecoratorToFreezed.applyOn` field that specifies where the custom decorator should be applied
563
+ */
564
+ export declare type AppliesOn = 'enum' | 'enum_value' | 'class' | 'factory' | 'default_factory' | 'named_factory' | 'union_factory' | 'merged_factory' | 'parameter' | 'default_factory_parameter' | 'named_factory_parameter' | 'union_factory_parameter' | 'merged_factory_parameter';
565
+ export declare const APPLIES_ON_ENUM: readonly ["enum"];
566
+ export declare type AppliesOnEnum = (typeof APPLIES_ON_ENUM)[number];
567
+ export declare const APPLIES_ON_ENUM_VALUE: readonly ["enum_value"];
568
+ export declare type AppliesOnEnumValue = (typeof APPLIES_ON_ENUM_VALUE)[number];
569
+ export declare const APPLIES_ON_CLASS: readonly ["class"];
570
+ export declare type AppliesOnClass = (typeof APPLIES_ON_CLASS)[number];
571
+ export declare const APPLIES_ON_DEFAULT_FACTORY: readonly ["factory", "default_factory"];
572
+ export declare type AppliesOnDefaultFactory = (typeof APPLIES_ON_DEFAULT_FACTORY)[number];
573
+ export declare const APPLIES_ON_UNION_FACTORY: readonly ["factory", "named_factory", "union_factory"];
574
+ export declare type AppliesOnUnionFactory = (typeof APPLIES_ON_UNION_FACTORY)[number];
575
+ export declare const APPLIES_ON_MERGED_FACTORY: readonly ["factory", "named_factory", "merged_factory"];
576
+ export declare type AppliesOnMergedFactory = (typeof APPLIES_ON_MERGED_FACTORY)[number];
577
+ export declare type AppliesOnNamedFactory = AppliesOnUnionFactory | AppliesOnMergedFactory;
578
+ export declare const APPLIES_ON_FACTORY: string[];
579
+ export declare type AppliesOnFactory = AppliesOnDefaultFactory | AppliesOnNamedFactory;
580
+ export declare const APPLIES_ON_DEFAULT_FACTORY_PARAMETERS: readonly ["parameter", "default_factory_parameter"];
581
+ export declare type AppliesOnDefaultFactoryParameters = (typeof APPLIES_ON_DEFAULT_FACTORY_PARAMETERS)[number];
582
+ export declare const APPLIES_ON_UNION_FACTORY_PARAMETERS: readonly ["parameter", "named_factory_parameter", "union_factory_parameter"];
583
+ export declare type AppliesOnUnionFactoryParameters = (typeof APPLIES_ON_UNION_FACTORY_PARAMETERS)[number];
584
+ export declare const APPLIES_ON_MERGED_FACTORY_PARAMETERS: readonly ["parameter", "named_factory_parameter", "merged_factory_parameter"];
585
+ export declare type AppliesOnMergedFactoryParameters = (typeof APPLIES_ON_MERGED_FACTORY_PARAMETERS)[number];
586
+ export declare type AppliesOnNamedParameters = AppliesOnUnionFactoryParameters | AppliesOnMergedFactoryParameters;
587
+ export declare const APPLIES_ON_PARAMETERS: readonly ["parameter", "default_factory_parameter", "named_factory_parameter", "union_factory_parameter", "merged_factory_parameter"];
588
+ export declare type AppliesOnParameters = AppliesOnDefaultFactoryParameters | AppliesOnNamedParameters;
589
+ export declare type DartIdentifierCasing = 'snake_case' | 'camelCase' | 'PascalCase';
590
+ export declare type NodeType = ObjectTypeDefinitionNode | InputObjectTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode;
591
+ export declare type FieldType = FieldDefinitionNode | InputValueDefinitionNode;
592
+ export declare type ObjectType = ObjectTypeDefinitionNode | InputObjectTypeDefinitionNode;
593
+ export declare type ConfigOption = keyof FlutterFreezedPluginConfig;
594
+ export declare type FreezedOption = Extract<ConfigOption, 'copyWith' | 'equal' | 'immutable' | 'makeCollectionsUnmodifiable' | 'mutableInputs' | 'privateEmptyConstructor'>;
595
+ export declare type TypeFieldNameOption = Extract<ConfigOption, 'defaultValues' | 'deprecated' | 'escapeDartKeywords' | 'final' | 'fromJsonToJson'>;
596
+ export declare type MultiConstructorOption = FlutterFreezedPluginConfig['unionClass'];
597
+ export declare type UnionValueCase = 'FreezedUnionCase.camel' | 'FreezedUnionCase.pascal';
598
+ /**
599
+ * maps GraphQL scalar types to Dart's scalar types
600
+ */
601
+ export declare const DART_SCALARS: Record<string, string>;
602
+ export declare const DART_KEYWORDS: {
603
+ abstract: string;
604
+ else: string;
605
+ import: string;
606
+ show: string;
607
+ as: string;
608
+ enum: string;
609
+ in: string;
610
+ static: string;
611
+ assert: string;
612
+ export: string;
613
+ interface: string;
614
+ super: string;
615
+ async: string;
616
+ extends: string;
617
+ is: string;
618
+ switch: string;
619
+ await: string;
620
+ extension: string;
621
+ late: string;
622
+ sync: string;
623
+ break: string;
624
+ external: string;
625
+ library: string;
626
+ this: string;
627
+ case: string;
628
+ factory: string;
629
+ mixin: string;
630
+ throw: string;
631
+ catch: string;
632
+ false: string;
633
+ new: string;
634
+ true: string;
635
+ class: string;
636
+ final: string;
637
+ null: string;
638
+ try: string;
639
+ const: string;
640
+ finally: string;
641
+ on: string;
642
+ typedef: string;
643
+ continue: string;
644
+ for: string;
645
+ operator: string;
646
+ var: string;
647
+ covariant: string;
648
+ Function: string;
649
+ part: string;
650
+ void: string;
651
+ default: string;
652
+ get: string;
653
+ required: string;
654
+ while: string;
655
+ deferred: string;
656
+ hide: string;
657
+ rethrow: string;
658
+ with: string;
659
+ do: string;
660
+ if: string;
661
+ return: string;
662
+ yield: string;
663
+ dynamic: string;
664
+ implements: string;
665
+ set: string;
666
+ int: string;
667
+ double: string;
668
+ String: string;
669
+ bool: string;
670
+ List: string;
671
+ Set: string;
672
+ Map: string;
673
+ Runes: string;
674
+ Symbol: string;
675
+ Object: string;
676
+ Null: string;
677
+ Never: string;
678
+ Enum: string;
679
+ Future: string;
680
+ Iterable: string;
681
+ };
682
+ /** initializes a FreezedPluginConfig with the defaults values */
683
+ export declare const defaultFreezedPluginConfig: FlutterFreezedPluginConfig;