@graphql-codegen/flutter-freezed 3.0.0 → 3.0.1-alpha-20230130180936-04996f117

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.
@@ -47,7 +47,7 @@ Config.escapeDartKeywords = (config, blockAppliesOn, typeName, fieldName) => {
47
47
  else if (typeName && Array.isArray(escapeDartKeywords) && escapeDartKeywords.length > 0) {
48
48
  const [, prefix, suffix] = escapeDartKeywords
49
49
  .filter(([pattern, , , configAppliesOn]) => pattern_js_1.Pattern.findLastConfiguration(pattern, typeName, fieldName) &&
50
- (0, utils_js_1.appliesOnBlock)(configAppliesOn, blockAppliesOn))
50
+ (0, utils_js_1.appliesOnBlock)(configAppliesOn !== null && configAppliesOn !== void 0 ? configAppliesOn : [...plugin_config_js_1.APPLIES_ON_ALL_BLOCKS], blockAppliesOn))
51
51
  .slice(-1)[0];
52
52
  return [prefix, suffix];
53
53
  }
@@ -115,7 +115,7 @@ Config.unionKey = ( /* config: FlutterFreezedPluginConfig, typeName: TypeName */
115
115
  Config.unionValueCase = ( /* config: FlutterFreezedPluginConfig, typeName: TypeName */) => {
116
116
  return undefined;
117
117
  };
118
- Config.unionValueDecorator = () => {
118
+ Config.unionValueFactoryDecorator = () => {
119
119
  return undefined;
120
120
  };
121
121
  Config.enableWithBooleanOrTypeFieldName = (value, typeName) => {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.defaultFreezedPluginConfig = exports.DART_KEYWORDS = exports.DART_SCALARS = exports.APPLIES_ON_PARAMETERS = exports.APPLIES_ON_MERGED_FACTORY_PARAMETERS = exports.APPLIES_ON_UNION_FACTORY_PARAMETERS = exports.APPLIES_ON_DEFAULT_FACTORY_PARAMETERS = exports.APPLIES_ON_FACTORY = exports.APPLIES_ON_MERGED_FACTORY = exports.APPLIES_ON_UNION_FACTORY = exports.APPLIES_ON_DEFAULT_FACTORY = exports.APPLIES_ON_CLASS = exports.APPLIES_ON_ENUM_VALUE = exports.APPLIES_ON_ENUM = void 0;
3
+ exports.defaultFreezedPluginConfig = exports.DART_KEYWORDS = exports.DART_SCALARS = exports.APPLIES_ON_ALL_BLOCKS = exports.APPLIES_ON_PARAMETERS = exports.APPLIES_ON_MERGED_FACTORY_PARAMETERS = exports.APPLIES_ON_UNION_FACTORY_PARAMETERS = exports.APPLIES_ON_DEFAULT_FACTORY_PARAMETERS = exports.APPLIES_ON_FACTORY = exports.APPLIES_ON_MERGED_FACTORY = exports.APPLIES_ON_UNION_FACTORY = exports.APPLIES_ON_DEFAULT_FACTORY = exports.APPLIES_ON_CLASS = exports.APPLIES_ON_ENUM_VALUE = exports.APPLIES_ON_ENUM = void 0;
4
4
  exports.APPLIES_ON_ENUM = ['enum'];
5
5
  exports.APPLIES_ON_ENUM_VALUE = ['enum_value'];
6
6
  exports.APPLIES_ON_CLASS = ['class'];
@@ -26,6 +26,7 @@ exports.APPLIES_ON_PARAMETERS = [
26
26
  'union_factory_parameter',
27
27
  'merged_factory_parameter',
28
28
  ];
29
+ exports.APPLIES_ON_ALL_BLOCKS = ['enum', 'enum_value', 'class', 'factory', 'parameter'];
29
30
  /**
30
31
  * maps GraphQL scalar types to Dart's scalar types
31
32
  */
@@ -19,7 +19,7 @@ class ClassBlock {
19
19
  block += this.buildDecorators(config, node);
20
20
  block += this.buildHeader(config, typeName, _className);
21
21
  block += this.buildBody(config, node);
22
- block += this.buildFooter(config, typeName, _className);
22
+ block += this.buildFooter(_className);
23
23
  return block;
24
24
  }
25
25
  }
@@ -83,13 +83,12 @@ ClassBlock.buildBody = (config, node) => {
83
83
  .join('');
84
84
  }
85
85
  body += config_value_js_1.Config.mergeTypes(config, className)
86
- .map(value => {
87
- const factoryName = pattern_js_1.TypeName.fromString(value);
86
+ .map(factoryName => {
88
87
  return factory_block_js_1.FactoryBlock.serializeMergedFactory(className, factoryName);
89
88
  })
90
89
  .join('');
91
90
  return body;
92
91
  };
93
- ClassBlock.buildFooter = (config, typeName, _className) => {
92
+ ClassBlock.buildFooter = (_className) => {
94
93
  return (0, visitor_plugin_common_1.indent)(`factory ${_className}.fromJson(Map<String, dynamic> json) => _$${_className}FromJson(json);\n}\n\n`);
95
94
  };
@@ -1,6 +1,6 @@
1
1
  import { appliesOnBlock } from '../utils.js';
2
2
  import { Pattern } from './pattern.js';
3
- import { DART_SCALARS, defaultFreezedPluginConfig, } from './plugin-config.js';
3
+ import { APPLIES_ON_ALL_BLOCKS, DART_SCALARS, defaultFreezedPluginConfig, } from './plugin-config.js';
4
4
  export class Config {
5
5
  }
6
6
  Config.camelCasedEnums = (config) => {
@@ -43,7 +43,7 @@ Config.escapeDartKeywords = (config, blockAppliesOn, typeName, fieldName) => {
43
43
  else if (typeName && Array.isArray(escapeDartKeywords) && escapeDartKeywords.length > 0) {
44
44
  const [, prefix, suffix] = escapeDartKeywords
45
45
  .filter(([pattern, , , configAppliesOn]) => Pattern.findLastConfiguration(pattern, typeName, fieldName) &&
46
- appliesOnBlock(configAppliesOn, blockAppliesOn))
46
+ appliesOnBlock(configAppliesOn !== null && configAppliesOn !== void 0 ? configAppliesOn : [...APPLIES_ON_ALL_BLOCKS], blockAppliesOn))
47
47
  .slice(-1)[0];
48
48
  return [prefix, suffix];
49
49
  }
@@ -111,7 +111,7 @@ Config.unionKey = ( /* config: FlutterFreezedPluginConfig, typeName: TypeName */
111
111
  Config.unionValueCase = ( /* config: FlutterFreezedPluginConfig, typeName: TypeName */) => {
112
112
  return undefined;
113
113
  };
114
- Config.unionValueDecorator = () => {
114
+ Config.unionValueFactoryDecorator = () => {
115
115
  return undefined;
116
116
  };
117
117
  Config.enableWithBooleanOrTypeFieldName = (value, typeName) => {
@@ -23,6 +23,7 @@ export const APPLIES_ON_PARAMETERS = [
23
23
  'union_factory_parameter',
24
24
  'merged_factory_parameter',
25
25
  ];
26
+ export const APPLIES_ON_ALL_BLOCKS = ['enum', 'enum_value', 'class', 'factory', 'parameter'];
26
27
  /**
27
28
  * maps GraphQL scalar types to Dart's scalar types
28
29
  */
@@ -16,7 +16,7 @@ export class ClassBlock {
16
16
  block += this.buildDecorators(config, node);
17
17
  block += this.buildHeader(config, typeName, _className);
18
18
  block += this.buildBody(config, node);
19
- block += this.buildFooter(config, typeName, _className);
19
+ block += this.buildFooter(_className);
20
20
  return block;
21
21
  }
22
22
  }
@@ -79,13 +79,12 @@ ClassBlock.buildBody = (config, node) => {
79
79
  .join('');
80
80
  }
81
81
  body += Config.mergeTypes(config, className)
82
- .map(value => {
83
- const factoryName = TypeName.fromString(value);
82
+ .map(factoryName => {
84
83
  return FactoryBlock.serializeMergedFactory(className, factoryName);
85
84
  })
86
85
  .join('');
87
86
  return body;
88
87
  };
89
- ClassBlock.buildFooter = (config, typeName, _className) => {
88
+ ClassBlock.buildFooter = (_className) => {
90
89
  return indent(`factory ${_className}.fromJson(Map<String, dynamic> json) => _$${_className}FromJson(json);\n}\n\n`);
91
90
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphql-codegen/flutter-freezed",
3
- "version": "3.0.0",
3
+ "version": "3.0.1-alpha-20230130180936-04996f117",
4
4
  "description": "GraphQL Code Generator plugin to generate Freezed models from your GraphQL schema",
5
5
  "peerDependencies": {
6
6
  "graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
@@ -12,13 +12,13 @@ export declare class Config {
12
12
  static ignoreTypes: (config: FlutterFreezedPluginConfig, typeName: TypeName) => string[];
13
13
  static immutable: (config: FlutterFreezedPluginConfig, typeName?: TypeName) => boolean;
14
14
  static makeCollectionsUnmodifiable: (config: FlutterFreezedPluginConfig, typeName?: TypeName) => boolean;
15
- static mergeTypes: (config: FlutterFreezedPluginConfig, typeName: TypeName) => string[];
15
+ static mergeTypes: (config: FlutterFreezedPluginConfig, typeName: TypeName) => TypeName[];
16
16
  static mutableInputs: (config: FlutterFreezedPluginConfig, typeName?: TypeName) => boolean;
17
17
  static privateEmptyConstructor: (config: FlutterFreezedPluginConfig, typeName?: TypeName) => boolean;
18
18
  static unionClass: () => any;
19
19
  static unionKey: () => string | undefined;
20
20
  static unionValueCase: () => string | undefined;
21
- static unionValueDecorator: () => any;
21
+ static unionValueFactoryDecorator: () => any;
22
22
  static enableWithBooleanOrTypeFieldName: (value?: boolean | TypeNamePattern, typeName?: TypeName) => boolean;
23
23
  static create: (...config: Partial<FlutterFreezedPluginConfig>[]) => FlutterFreezedPluginConfig;
24
24
  }
@@ -12,13 +12,13 @@ export declare class Config {
12
12
  static ignoreTypes: (config: FlutterFreezedPluginConfig, typeName: TypeName) => string[];
13
13
  static immutable: (config: FlutterFreezedPluginConfig, typeName?: TypeName) => boolean;
14
14
  static makeCollectionsUnmodifiable: (config: FlutterFreezedPluginConfig, typeName?: TypeName) => boolean;
15
- static mergeTypes: (config: FlutterFreezedPluginConfig, typeName: TypeName) => string[];
15
+ static mergeTypes: (config: FlutterFreezedPluginConfig, typeName: TypeName) => TypeName[];
16
16
  static mutableInputs: (config: FlutterFreezedPluginConfig, typeName?: TypeName) => boolean;
17
17
  static privateEmptyConstructor: (config: FlutterFreezedPluginConfig, typeName?: TypeName) => boolean;
18
18
  static unionClass: () => any;
19
19
  static unionKey: () => string | undefined;
20
20
  static unionValueCase: () => string | undefined;
21
- static unionValueDecorator: () => any;
21
+ static unionValueFactoryDecorator: () => any;
22
22
  static enableWithBooleanOrTypeFieldName: (value?: boolean | TypeNamePattern, typeName?: TypeName) => boolean;
23
23
  static create: (...config: Partial<FlutterFreezedPluginConfig>[]) => FlutterFreezedPluginConfig;
24
24
  }
@@ -64,6 +64,9 @@ export declare type FlutterFreezedPluginConfig = {
64
64
  * ```ts filename='codegen.ts'
65
65
  * import type { CodegenConfig } from '@graphql-codegen/cli';
66
66
  *
67
+ * const Droid = TypeName.fromString('Droid');
68
+ * const Starship = TypeName.fromString('Starship');
69
+ *
67
70
  * const config: CodegenConfig = {
68
71
  * // ...
69
72
  * generates: {
@@ -119,7 +122,7 @@ export declare type FlutterFreezedPluginConfig = {
119
122
  customScalars?: Record<string, string>;
120
123
  /**
121
124
  * @name defaultValues
122
- * @type {([pattern: FieldNamePattern, value: string, appliesOn: AppliesOnParameters[], directiveName?: string, directiveArgName?: string][])}
125
+ * @type {([pattern: FieldNamePattern, value: string, appliesOn: AppliesOnParameters[]][])}
123
126
  * @default undefined
124
127
  * @see {@link https://pub.dev/packages/freezed#default-values Default values}
125
128
  * @see {@link https://pub.dev/documentation/freezed_annotation/latest/freezed_annotation/Default-class.html Default class}
@@ -132,12 +135,14 @@ export declare type FlutterFreezedPluginConfig = {
132
135
  *
133
136
  * Use the `appliesOn` to specify where this option should be applied on
134
137
  *
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
138
  * @exampleMarkdown
137
139
  * ## Usage:
138
140
  * ```ts filename='codegen.ts'
139
141
  * import type { CodegenConfig } from '@graphql-codegen/cli';
140
142
  *
143
+ * const MovieCharacter = TypeName.fromString('MovieCharacter');
144
+ * const appearsIn = FieldName.fromString('appearsIn');
145
+ *
141
146
  * const config: CodegenConfig = {
142
147
  * // ...
143
148
  * generates: {
@@ -182,6 +187,14 @@ export declare type FlutterFreezedPluginConfig = {
182
187
  * ```ts filename='codegen.ts'
183
188
  * import type { CodegenConfig } from '@graphql-codegen/cli';
184
189
  *
190
+ * const MovieCharacter = TypeName.fromString('MovieCharacter');
191
+ * const Droid = TypeName.fromString('Droid');
192
+ * const Starship = TypeName.fromString('Starship');
193
+ * const Human = TypeName.fromString('Human');
194
+ *
195
+ * const name = FieldName.fromString('name');
196
+ * const appearsIn = FieldName.fromString('appearsIn');
197
+ *
185
198
  * const config: CodegenConfig = {
186
199
  * // ...
187
200
  * generates: {
@@ -208,7 +221,7 @@ export declare type FlutterFreezedPluginConfig = {
208
221
  * @name equal
209
222
  * @type {(boolean | TypeNamePattern)}
210
223
  * @default undefined
211
- * @see {@link url Freezed equal helper method usage}
224
+ * @see {@link https://pub.dev/packages/freezed#changing-the-behavior-for-a-specific-model Freezed equal helper method usage}
212
225
  * @see {@link https://pub.dev/documentation/freezed_annotation/latest/freezed_annotation/Freezed/equal.html Freezed annotation equal property}
213
226
  * @summary enables Freezed equal helper method
214
227
  * @description The [`freezed`](https://pub.dev/packages/freezed) library has this option enabled by default.
@@ -225,6 +238,9 @@ export declare type FlutterFreezedPluginConfig = {
225
238
  * ```ts filename='codegen.ts'
226
239
  * import type { CodegenConfig } from '@graphql-codegen/cli';
227
240
  *
241
+ * const Droid = TypeName.fromString('Droid');
242
+ * const Starship = TypeName.fromString('Starship');
243
+ *
228
244
  * const config: CodegenConfig = {
229
245
  * // ...
230
246
  * generates: {
@@ -246,11 +262,11 @@ export declare type FlutterFreezedPluginConfig = {
246
262
  equal?: boolean | TypeNamePattern;
247
263
  /**
248
264
  * @name escapeDartKeywords
265
+ * @type {(boolean | [pattern: Pattern, prefix?: string, suffix?: string, appliesOn?: AppliesOn[]][])}
249
266
  * @default true
250
267
  * @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
- *
268
+ * @summary ensures that the generated Freezed models do not use any of Dart's reserved keywords as identifiers
269
+ * @description Wraps the fields names that are valid Dart keywords with the prefix and suffix given
254
270
  *
255
271
  * @exampleMarkdown
256
272
  * ## Usage:
@@ -258,6 +274,8 @@ export declare type FlutterFreezedPluginConfig = {
258
274
  * ```ts filename='codegen.ts'
259
275
  * import type { CodegenConfig } from '@graphql-codegen/cli';
260
276
  *
277
+ * const Episode = TypeName.fromString('Episode');
278
+ *
261
279
  * const config: CodegenConfig = {
262
280
  * // ...
263
281
  * generates: {
@@ -270,15 +288,15 @@ export declare type FlutterFreezedPluginConfig = {
270
288
  * // OR configure how Dart keywords are handled for each type
271
289
  * escapeDartKeywords: [
272
290
  * [
273
- * 'Episode.@*FieldNames',
291
+ * Pattern.compose([
292
+ * TypeNamePattern.forAllTypeNames(),
293
+ * FieldNamePattern.forAllFieldNamesOfTypeName([Episode]),
294
+ * ]),
274
295
  * // `prefix`: defaults to an empty string `''` if undefined.
275
- * // Note that using a underscore `_` as a prefix will make the field as private
296
+ * // WARNING: Note that using a underscore `_` as a prefix will make the field as private
276
297
  * undefined,
277
298
  * // `suffix`: defaults to an underscore `_` if undefined
278
299
  * undefined,
279
- * // `casing`: maintains the original casing if undefined.
280
- * // Available options: `snake_cased`, `camelCase` or `PascalCase`
281
- * undefined,
282
300
  * // `appliesOn`: defaults to an ['enum', 'enum_value', 'class', 'factory', 'parameter'] if undefined.
283
301
  * undefined,
284
302
  * ],
@@ -294,18 +312,18 @@ export declare type FlutterFreezedPluginConfig = {
294
312
  escapeDartKeywords?: boolean | [pattern: Pattern, prefix?: string, suffix?: string, appliesOn?: AppliesOn[]][];
295
313
  /**
296
314
  * @name final
315
+ * @type {([pattern: FieldNamePattern, appliesOn: AppliesOnParameters[]][])}
316
+ * @default undefined
317
+ * @see {@link https://pub.dev/packages/freezed#defining-a-mutable-class-instead-of-an-immutable-one Freezed annotation equal property}
297
318
  * @summary marks fields as final
298
319
  * @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
320
  * @exampleMarkdown
305
321
  * ## Usage:
306
322
  * ```ts filename='codegen.ts'
307
323
  * import type { CodegenConfig } from '@graphql-codegen/cli';
308
324
  *
325
+ * const id = FieldName.fromString('id');
326
+ *
309
327
  * const config: CodegenConfig = {
310
328
  * // ...
311
329
  * generates: {
@@ -313,10 +331,7 @@ export declare type FlutterFreezedPluginConfig = {
313
331
  * plugins: {
314
332
  * 'flutter-freezed': {
315
333
  * // ...
316
- * final: [
317
- * ['Human.[name]', ['parameter']],
318
- * ['Starship.[id],Droid.[id],Human.[id]', ['default_factory_parameter']],
319
- * ],
334
+ * final: [[FieldNamePattern.forFieldNamesOfAllTypeNames([id]), ['parameter']]],
320
335
  * },
321
336
  * },
322
337
  * },
@@ -337,6 +352,8 @@ export declare type FlutterFreezedPluginConfig = {
337
352
  * ```ts filename='codegen.ts'
338
353
  * import type { CodegenConfig } from '@graphql-codegen/cli';
339
354
  *
355
+ * const PaginatorInfo = TypeName.fromString('PaginatorInfo');
356
+ *
340
357
  * const config: CodegenConfig = {
341
358
  * // ...
342
359
  * generates: {
@@ -344,7 +361,7 @@ export declare type FlutterFreezedPluginConfig = {
344
361
  * plugins: {
345
362
  * 'flutter-freezed': {
346
363
  * // ...
347
- * ignoreTypes: ['PaginatorInfo'],
364
+ * ignoreTypes: TypeNamePattern.forTypeNames([PaginatorInfo]),
348
365
  * },
349
366
  * },
350
367
  * },
@@ -371,6 +388,9 @@ export declare type FlutterFreezedPluginConfig = {
371
388
  * ```ts filename='codegen.ts'
372
389
  * import type { CodegenConfig } from '@graphql-codegen/cli';
373
390
  *
391
+ * const Droid = TypeName.fromString('Droid');
392
+ * const Starship = TypeName.fromString('Starship');
393
+ *
374
394
  * const config: CodegenConfig = {
375
395
  * // ...
376
396
  * generates: {
@@ -392,14 +412,19 @@ export declare type FlutterFreezedPluginConfig = {
392
412
  immutable?: boolean | TypeNamePattern;
393
413
  /**
394
414
  * @name makeCollectionsUnmodifiable
395
- * @description allows collections(lists/maps) to be modified even if class is immutable
415
+ * @type {(boolean | TypeNamePattern)}
396
416
  * @default undefined
417
+ * @see {@link https://pub.dev/packages/freezed#allowing-the-mutation-of-listsmapssets Allowing the mutation of Lists/Maps/Sets}
418
+ * @description allows collections(lists/maps) to be modified even if class is immutable
397
419
  *
398
420
  * @exampleMarkdown
399
421
  * ## Usage:
400
422
  * ```ts filename='codegen.ts'
401
423
  * import type { CodegenConfig } from '@graphql-codegen/cli';
402
424
  *
425
+ * const Droid = TypeName.fromString('Droid');
426
+ * const Starship = TypeName.fromString('Starship');
427
+ *
403
428
  * const config: CodegenConfig = {
404
429
  * // ...
405
430
  * generates: {
@@ -408,10 +433,8 @@ export declare type FlutterFreezedPluginConfig = {
408
433
  * 'flutter-freezed': {
409
434
  * // ...
410
435
  * makeCollectionsUnmodifiable: true,
411
- * // OR: a comma-separated string
412
- * makeCollectionsUnmodifiable: 'Droid,Starship',
413
- * // OR: a list of GRaphQL Type names
414
- * makeCollectionsUnmodifiable: ['Droid', 'Starship'],
436
+ * // OR: enable it for only Droid and Starship GraphQL types
437
+ * makeCollectionsUnmodifiable: TypeNamePattern.forTypeNames([Droid, Starship]),
415
438
  * },
416
439
  * },
417
440
  * },
@@ -423,25 +446,43 @@ export declare type FlutterFreezedPluginConfig = {
423
446
  makeCollectionsUnmodifiable?: boolean | TypeNamePattern;
424
447
  /**
425
448
  * @name mergeTypes
449
+ * @type {(Record<string, TypeName[]>)}
426
450
  * @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.
451
+ * @description maps over the value(array of typeNames) and transform each as a named factory constructor inside a class generated for the key(target GraphQL Object Type).
431
452
  * @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"]
453
+ * ## Usage:
454
+ * ```ts filename='codegen.ts'
455
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
456
+ *
457
+ * const Movie = TypeName.fromString('Movie');
458
+ * const CreateMovieInput = TypeName.fromString('CreateMovieInput');
459
+ * const UpdateMovieInput = TypeName.fromString('UpdateMovieInput');
460
+ * const UpsertMovieInput = TypeName.fromString('UpsertMovieInput');
461
+ *
462
+ * const config: CodegenConfig = {
463
+ * // ...
464
+ * generates: {
465
+ * 'lib/data/models/app_models.dart': {
466
+ * plugins: {
467
+ * 'flutter-freezed': {
468
+ * // ...
469
+ * mergeTypes: {
470
+ * [Movie.value]: [CreateMovieInput, UpdateMovieInput, UpsertMovieInput],
471
+ * },
472
+ * },
473
+ * },
474
+ * },
475
+ * },
476
+ * };
477
+ * export default config;
439
478
  * ```
440
479
  */
441
- mergeTypes?: Record<string, string[]>;
480
+ mergeTypes?: Record<string, TypeName[]>;
442
481
  /**
443
482
  * @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`.
483
+ * @description since inputs will be used to collect data, it makes sense to make them mutable with Freezed's `@unfreezed` decorator.
484
+ *
485
+ * This overrides(in order words: has a higher precedence than) the `immutable` config value `ONLY` for GraphQL `input types`.
445
486
  * @default true
446
487
  *
447
488
  * @exampleMarkdown
@@ -449,6 +490,9 @@ export declare type FlutterFreezedPluginConfig = {
449
490
  * ```ts filename='codegen.ts'
450
491
  * import type { CodegenConfig } from '@graphql-codegen/cli';
451
492
  *
493
+ * const CreateMovieInput = TypeName.fromString('CreateMovieInput');
494
+ * const UpdateMovieInput = TypeName.fromString('UpdateMovieInput');
495
+ *
452
496
  * const config: CodegenConfig = {
453
497
  * // ...
454
498
  * generates: {
@@ -457,10 +501,8 @@ export declare type FlutterFreezedPluginConfig = {
457
501
  * 'flutter-freezed': {
458
502
  * // ...
459
503
  * mutableInputs: true,
460
- * // OR: a comma-separated string
461
- * mutableInputs: 'Droid,Starship',
462
- * // OR: a list of GRaphQL Type names
463
- * mutableInputs: ['Droid', 'Starship'],
504
+ * // OR: enable it for only Droid and Starship GraphQL types
505
+ * mutableInputs: TypeNamePattern.forTypeNames([CreateMovieInput, UpdateMovieInput]),
464
506
  * },
465
507
  * },
466
508
  * },
@@ -480,6 +522,9 @@ export declare type FlutterFreezedPluginConfig = {
480
522
  * ```ts filename='codegen.ts'
481
523
  * import type { CodegenConfig } from '@graphql-codegen/cli';
482
524
  *
525
+ * const Droid = TypeName.fromString('Droid');
526
+ * const Starship = TypeName.fromString('Starship');
527
+ *
483
528
  * const config: CodegenConfig = {
484
529
  * // ...
485
530
  * generates: {
@@ -488,10 +533,8 @@ export declare type FlutterFreezedPluginConfig = {
488
533
  * 'flutter-freezed': {
489
534
  * // ...
490
535
  * privateEmptyConstructor: true,
491
- * // OR: a comma-separated string
492
- * privateEmptyConstructor: 'Droid,Starship',
493
- * // OR: a list of GRaphQL Type names
494
- * privateEmptyConstructor: ['Droid', 'Starship'],
536
+ * // OR: enable it for only Droid and Starship GraphQL types
537
+ * privateEmptyConstructor: TypeNamePattern.forTypeNames([Droid, Starship]),
495
538
  * },
496
539
  * },
497
540
  * },
@@ -586,6 +629,7 @@ export declare type AppliesOnMergedFactoryParameters = (typeof APPLIES_ON_MERGED
586
629
  export declare type AppliesOnNamedParameters = AppliesOnUnionFactoryParameters | AppliesOnMergedFactoryParameters;
587
630
  export declare const APPLIES_ON_PARAMETERS: readonly ["parameter", "default_factory_parameter", "named_factory_parameter", "union_factory_parameter", "merged_factory_parameter"];
588
631
  export declare type AppliesOnParameters = AppliesOnDefaultFactoryParameters | AppliesOnNamedParameters;
632
+ export declare const APPLIES_ON_ALL_BLOCKS: readonly ["enum", "enum_value", "class", "factory", "parameter"];
589
633
  export declare type DartIdentifierCasing = 'snake_case' | 'camelCase' | 'PascalCase';
590
634
  export declare type NodeType = ObjectTypeDefinitionNode | InputObjectTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode;
591
635
  export declare type FieldType = FieldDefinitionNode | InputValueDefinitionNode;
@@ -64,6 +64,9 @@ export declare type FlutterFreezedPluginConfig = {
64
64
  * ```ts filename='codegen.ts'
65
65
  * import type { CodegenConfig } from '@graphql-codegen/cli';
66
66
  *
67
+ * const Droid = TypeName.fromString('Droid');
68
+ * const Starship = TypeName.fromString('Starship');
69
+ *
67
70
  * const config: CodegenConfig = {
68
71
  * // ...
69
72
  * generates: {
@@ -119,7 +122,7 @@ export declare type FlutterFreezedPluginConfig = {
119
122
  customScalars?: Record<string, string>;
120
123
  /**
121
124
  * @name defaultValues
122
- * @type {([pattern: FieldNamePattern, value: string, appliesOn: AppliesOnParameters[], directiveName?: string, directiveArgName?: string][])}
125
+ * @type {([pattern: FieldNamePattern, value: string, appliesOn: AppliesOnParameters[]][])}
123
126
  * @default undefined
124
127
  * @see {@link https://pub.dev/packages/freezed#default-values Default values}
125
128
  * @see {@link https://pub.dev/documentation/freezed_annotation/latest/freezed_annotation/Default-class.html Default class}
@@ -132,12 +135,14 @@ export declare type FlutterFreezedPluginConfig = {
132
135
  *
133
136
  * Use the `appliesOn` to specify where this option should be applied on
134
137
  *
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
138
  * @exampleMarkdown
137
139
  * ## Usage:
138
140
  * ```ts filename='codegen.ts'
139
141
  * import type { CodegenConfig } from '@graphql-codegen/cli';
140
142
  *
143
+ * const MovieCharacter = TypeName.fromString('MovieCharacter');
144
+ * const appearsIn = FieldName.fromString('appearsIn');
145
+ *
141
146
  * const config: CodegenConfig = {
142
147
  * // ...
143
148
  * generates: {
@@ -182,6 +187,14 @@ export declare type FlutterFreezedPluginConfig = {
182
187
  * ```ts filename='codegen.ts'
183
188
  * import type { CodegenConfig } from '@graphql-codegen/cli';
184
189
  *
190
+ * const MovieCharacter = TypeName.fromString('MovieCharacter');
191
+ * const Droid = TypeName.fromString('Droid');
192
+ * const Starship = TypeName.fromString('Starship');
193
+ * const Human = TypeName.fromString('Human');
194
+ *
195
+ * const name = FieldName.fromString('name');
196
+ * const appearsIn = FieldName.fromString('appearsIn');
197
+ *
185
198
  * const config: CodegenConfig = {
186
199
  * // ...
187
200
  * generates: {
@@ -208,7 +221,7 @@ export declare type FlutterFreezedPluginConfig = {
208
221
  * @name equal
209
222
  * @type {(boolean | TypeNamePattern)}
210
223
  * @default undefined
211
- * @see {@link url Freezed equal helper method usage}
224
+ * @see {@link https://pub.dev/packages/freezed#changing-the-behavior-for-a-specific-model Freezed equal helper method usage}
212
225
  * @see {@link https://pub.dev/documentation/freezed_annotation/latest/freezed_annotation/Freezed/equal.html Freezed annotation equal property}
213
226
  * @summary enables Freezed equal helper method
214
227
  * @description The [`freezed`](https://pub.dev/packages/freezed) library has this option enabled by default.
@@ -225,6 +238,9 @@ export declare type FlutterFreezedPluginConfig = {
225
238
  * ```ts filename='codegen.ts'
226
239
  * import type { CodegenConfig } from '@graphql-codegen/cli';
227
240
  *
241
+ * const Droid = TypeName.fromString('Droid');
242
+ * const Starship = TypeName.fromString('Starship');
243
+ *
228
244
  * const config: CodegenConfig = {
229
245
  * // ...
230
246
  * generates: {
@@ -246,11 +262,11 @@ export declare type FlutterFreezedPluginConfig = {
246
262
  equal?: boolean | TypeNamePattern;
247
263
  /**
248
264
  * @name escapeDartKeywords
265
+ * @type {(boolean | [pattern: Pattern, prefix?: string, suffix?: string, appliesOn?: AppliesOn[]][])}
249
266
  * @default true
250
267
  * @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
- *
268
+ * @summary ensures that the generated Freezed models do not use any of Dart's reserved keywords as identifiers
269
+ * @description Wraps the fields names that are valid Dart keywords with the prefix and suffix given
254
270
  *
255
271
  * @exampleMarkdown
256
272
  * ## Usage:
@@ -258,6 +274,8 @@ export declare type FlutterFreezedPluginConfig = {
258
274
  * ```ts filename='codegen.ts'
259
275
  * import type { CodegenConfig } from '@graphql-codegen/cli';
260
276
  *
277
+ * const Episode = TypeName.fromString('Episode');
278
+ *
261
279
  * const config: CodegenConfig = {
262
280
  * // ...
263
281
  * generates: {
@@ -270,15 +288,15 @@ export declare type FlutterFreezedPluginConfig = {
270
288
  * // OR configure how Dart keywords are handled for each type
271
289
  * escapeDartKeywords: [
272
290
  * [
273
- * 'Episode.@*FieldNames',
291
+ * Pattern.compose([
292
+ * TypeNamePattern.forAllTypeNames(),
293
+ * FieldNamePattern.forAllFieldNamesOfTypeName([Episode]),
294
+ * ]),
274
295
  * // `prefix`: defaults to an empty string `''` if undefined.
275
- * // Note that using a underscore `_` as a prefix will make the field as private
296
+ * // WARNING: Note that using a underscore `_` as a prefix will make the field as private
276
297
  * undefined,
277
298
  * // `suffix`: defaults to an underscore `_` if undefined
278
299
  * undefined,
279
- * // `casing`: maintains the original casing if undefined.
280
- * // Available options: `snake_cased`, `camelCase` or `PascalCase`
281
- * undefined,
282
300
  * // `appliesOn`: defaults to an ['enum', 'enum_value', 'class', 'factory', 'parameter'] if undefined.
283
301
  * undefined,
284
302
  * ],
@@ -294,18 +312,18 @@ export declare type FlutterFreezedPluginConfig = {
294
312
  escapeDartKeywords?: boolean | [pattern: Pattern, prefix?: string, suffix?: string, appliesOn?: AppliesOn[]][];
295
313
  /**
296
314
  * @name final
315
+ * @type {([pattern: FieldNamePattern, appliesOn: AppliesOnParameters[]][])}
316
+ * @default undefined
317
+ * @see {@link https://pub.dev/packages/freezed#defining-a-mutable-class-instead-of-an-immutable-one Freezed annotation equal property}
297
318
  * @summary marks fields as final
298
319
  * @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
320
  * @exampleMarkdown
305
321
  * ## Usage:
306
322
  * ```ts filename='codegen.ts'
307
323
  * import type { CodegenConfig } from '@graphql-codegen/cli';
308
324
  *
325
+ * const id = FieldName.fromString('id');
326
+ *
309
327
  * const config: CodegenConfig = {
310
328
  * // ...
311
329
  * generates: {
@@ -313,10 +331,7 @@ export declare type FlutterFreezedPluginConfig = {
313
331
  * plugins: {
314
332
  * 'flutter-freezed': {
315
333
  * // ...
316
- * final: [
317
- * ['Human.[name]', ['parameter']],
318
- * ['Starship.[id],Droid.[id],Human.[id]', ['default_factory_parameter']],
319
- * ],
334
+ * final: [[FieldNamePattern.forFieldNamesOfAllTypeNames([id]), ['parameter']]],
320
335
  * },
321
336
  * },
322
337
  * },
@@ -337,6 +352,8 @@ export declare type FlutterFreezedPluginConfig = {
337
352
  * ```ts filename='codegen.ts'
338
353
  * import type { CodegenConfig } from '@graphql-codegen/cli';
339
354
  *
355
+ * const PaginatorInfo = TypeName.fromString('PaginatorInfo');
356
+ *
340
357
  * const config: CodegenConfig = {
341
358
  * // ...
342
359
  * generates: {
@@ -344,7 +361,7 @@ export declare type FlutterFreezedPluginConfig = {
344
361
  * plugins: {
345
362
  * 'flutter-freezed': {
346
363
  * // ...
347
- * ignoreTypes: ['PaginatorInfo'],
364
+ * ignoreTypes: TypeNamePattern.forTypeNames([PaginatorInfo]),
348
365
  * },
349
366
  * },
350
367
  * },
@@ -371,6 +388,9 @@ export declare type FlutterFreezedPluginConfig = {
371
388
  * ```ts filename='codegen.ts'
372
389
  * import type { CodegenConfig } from '@graphql-codegen/cli';
373
390
  *
391
+ * const Droid = TypeName.fromString('Droid');
392
+ * const Starship = TypeName.fromString('Starship');
393
+ *
374
394
  * const config: CodegenConfig = {
375
395
  * // ...
376
396
  * generates: {
@@ -392,14 +412,19 @@ export declare type FlutterFreezedPluginConfig = {
392
412
  immutable?: boolean | TypeNamePattern;
393
413
  /**
394
414
  * @name makeCollectionsUnmodifiable
395
- * @description allows collections(lists/maps) to be modified even if class is immutable
415
+ * @type {(boolean | TypeNamePattern)}
396
416
  * @default undefined
417
+ * @see {@link https://pub.dev/packages/freezed#allowing-the-mutation-of-listsmapssets Allowing the mutation of Lists/Maps/Sets}
418
+ * @description allows collections(lists/maps) to be modified even if class is immutable
397
419
  *
398
420
  * @exampleMarkdown
399
421
  * ## Usage:
400
422
  * ```ts filename='codegen.ts'
401
423
  * import type { CodegenConfig } from '@graphql-codegen/cli';
402
424
  *
425
+ * const Droid = TypeName.fromString('Droid');
426
+ * const Starship = TypeName.fromString('Starship');
427
+ *
403
428
  * const config: CodegenConfig = {
404
429
  * // ...
405
430
  * generates: {
@@ -408,10 +433,8 @@ export declare type FlutterFreezedPluginConfig = {
408
433
  * 'flutter-freezed': {
409
434
  * // ...
410
435
  * makeCollectionsUnmodifiable: true,
411
- * // OR: a comma-separated string
412
- * makeCollectionsUnmodifiable: 'Droid,Starship',
413
- * // OR: a list of GRaphQL Type names
414
- * makeCollectionsUnmodifiable: ['Droid', 'Starship'],
436
+ * // OR: enable it for only Droid and Starship GraphQL types
437
+ * makeCollectionsUnmodifiable: TypeNamePattern.forTypeNames([Droid, Starship]),
415
438
  * },
416
439
  * },
417
440
  * },
@@ -423,25 +446,43 @@ export declare type FlutterFreezedPluginConfig = {
423
446
  makeCollectionsUnmodifiable?: boolean | TypeNamePattern;
424
447
  /**
425
448
  * @name mergeTypes
449
+ * @type {(Record<string, TypeName[]>)}
426
450
  * @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.
451
+ * @description maps over the value(array of typeNames) and transform each as a named factory constructor inside a class generated for the key(target GraphQL Object Type).
431
452
  * @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"]
453
+ * ## Usage:
454
+ * ```ts filename='codegen.ts'
455
+ * import type { CodegenConfig } from '@graphql-codegen/cli';
456
+ *
457
+ * const Movie = TypeName.fromString('Movie');
458
+ * const CreateMovieInput = TypeName.fromString('CreateMovieInput');
459
+ * const UpdateMovieInput = TypeName.fromString('UpdateMovieInput');
460
+ * const UpsertMovieInput = TypeName.fromString('UpsertMovieInput');
461
+ *
462
+ * const config: CodegenConfig = {
463
+ * // ...
464
+ * generates: {
465
+ * 'lib/data/models/app_models.dart': {
466
+ * plugins: {
467
+ * 'flutter-freezed': {
468
+ * // ...
469
+ * mergeTypes: {
470
+ * [Movie.value]: [CreateMovieInput, UpdateMovieInput, UpsertMovieInput],
471
+ * },
472
+ * },
473
+ * },
474
+ * },
475
+ * },
476
+ * };
477
+ * export default config;
439
478
  * ```
440
479
  */
441
- mergeTypes?: Record<string, string[]>;
480
+ mergeTypes?: Record<string, TypeName[]>;
442
481
  /**
443
482
  * @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`.
483
+ * @description since inputs will be used to collect data, it makes sense to make them mutable with Freezed's `@unfreezed` decorator.
484
+ *
485
+ * This overrides(in order words: has a higher precedence than) the `immutable` config value `ONLY` for GraphQL `input types`.
445
486
  * @default true
446
487
  *
447
488
  * @exampleMarkdown
@@ -449,6 +490,9 @@ export declare type FlutterFreezedPluginConfig = {
449
490
  * ```ts filename='codegen.ts'
450
491
  * import type { CodegenConfig } from '@graphql-codegen/cli';
451
492
  *
493
+ * const CreateMovieInput = TypeName.fromString('CreateMovieInput');
494
+ * const UpdateMovieInput = TypeName.fromString('UpdateMovieInput');
495
+ *
452
496
  * const config: CodegenConfig = {
453
497
  * // ...
454
498
  * generates: {
@@ -457,10 +501,8 @@ export declare type FlutterFreezedPluginConfig = {
457
501
  * 'flutter-freezed': {
458
502
  * // ...
459
503
  * mutableInputs: true,
460
- * // OR: a comma-separated string
461
- * mutableInputs: 'Droid,Starship',
462
- * // OR: a list of GRaphQL Type names
463
- * mutableInputs: ['Droid', 'Starship'],
504
+ * // OR: enable it for only Droid and Starship GraphQL types
505
+ * mutableInputs: TypeNamePattern.forTypeNames([CreateMovieInput, UpdateMovieInput]),
464
506
  * },
465
507
  * },
466
508
  * },
@@ -480,6 +522,9 @@ export declare type FlutterFreezedPluginConfig = {
480
522
  * ```ts filename='codegen.ts'
481
523
  * import type { CodegenConfig } from '@graphql-codegen/cli';
482
524
  *
525
+ * const Droid = TypeName.fromString('Droid');
526
+ * const Starship = TypeName.fromString('Starship');
527
+ *
483
528
  * const config: CodegenConfig = {
484
529
  * // ...
485
530
  * generates: {
@@ -488,10 +533,8 @@ export declare type FlutterFreezedPluginConfig = {
488
533
  * 'flutter-freezed': {
489
534
  * // ...
490
535
  * privateEmptyConstructor: true,
491
- * // OR: a comma-separated string
492
- * privateEmptyConstructor: 'Droid,Starship',
493
- * // OR: a list of GRaphQL Type names
494
- * privateEmptyConstructor: ['Droid', 'Starship'],
536
+ * // OR: enable it for only Droid and Starship GraphQL types
537
+ * privateEmptyConstructor: TypeNamePattern.forTypeNames([Droid, Starship]),
495
538
  * },
496
539
  * },
497
540
  * },
@@ -586,6 +629,7 @@ export declare type AppliesOnMergedFactoryParameters = (typeof APPLIES_ON_MERGED
586
629
  export declare type AppliesOnNamedParameters = AppliesOnUnionFactoryParameters | AppliesOnMergedFactoryParameters;
587
630
  export declare const APPLIES_ON_PARAMETERS: readonly ["parameter", "default_factory_parameter", "named_factory_parameter", "union_factory_parameter", "merged_factory_parameter"];
588
631
  export declare type AppliesOnParameters = AppliesOnDefaultFactoryParameters | AppliesOnNamedParameters;
632
+ export declare const APPLIES_ON_ALL_BLOCKS: readonly ["enum", "enum_value", "class", "factory", "parameter"];
589
633
  export declare type DartIdentifierCasing = 'snake_case' | 'camelCase' | 'PascalCase';
590
634
  export declare type NodeType = ObjectTypeDefinitionNode | InputObjectTypeDefinitionNode | UnionTypeDefinitionNode | EnumTypeDefinitionNode;
591
635
  export declare type FieldType = FieldDefinitionNode | InputValueDefinitionNode;
@@ -8,5 +8,5 @@ export declare class ClassBlock {
8
8
  static decorateAsUnfreezed: (config: FlutterFreezedPluginConfig, node: NodeType) => "@unfreezed\n" | "@freezed\n";
9
9
  static buildHeader: (config: FlutterFreezedPluginConfig, typeName: TypeName, _className: string) => string;
10
10
  static buildBody: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
11
- static buildFooter: (config: FlutterFreezedPluginConfig, typeName: TypeName, _className: string) => string;
11
+ static buildFooter: (_className: string) => string;
12
12
  }
@@ -8,5 +8,5 @@ export declare class ClassBlock {
8
8
  static decorateAsUnfreezed: (config: FlutterFreezedPluginConfig, node: NodeType) => "@unfreezed\n" | "@freezed\n";
9
9
  static buildHeader: (config: FlutterFreezedPluginConfig, typeName: TypeName, _className: string) => string;
10
10
  static buildBody: (config: FlutterFreezedPluginConfig, node: NodeType) => string;
11
- static buildFooter: (config: FlutterFreezedPluginConfig, typeName: TypeName, _className: string) => string;
11
+ static buildFooter: (_className: string) => string;
12
12
  }