@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,252 @@
1
+ /**
2
+ * A list of GraphQL Type Names
3
+ */
4
+ declare type TypeNames = TypeName | TypeName[];
5
+ /**
6
+ * A list of field names of a GraphQL Type
7
+ */
8
+ declare type FieldNames = FieldName | FieldName[];
9
+ /**
10
+ * @name TypeName
11
+ * @description represents a single valid GraphQL Type Name used in the GraphQL Schema provided
12
+ * @exampleMarkdown
13
+ * ```ts filename:"config.ts"
14
+ * // returns a TypeName
15
+ * let typeName: TypeName = TypeName.fromString('Droid');
16
+ *
17
+ * // to configure a FactoryBlock, use the `TypeName.fromUnionOfTypeNames(className, factoryName)`
18
+ * let typeName: TypeName = TypeName.fromUnionOfTypeNames(SearchResult, Droid);
19
+
20
+ * // the following will throw an error
21
+ * // can contain only a single value...
22
+ * let typeName: TypeName = TypeName.fromString('Droid, Human'); // throws an Error
23
+ *
24
+ * // value can not be an empty string...
25
+ * let typeName: TypeName = TypeName.fromString(''); // throws an Error
26
+ *
27
+ * // value must contain only AlphaNumeric characters only...
28
+ * let typeName: TypeName = TypeName.fromString('Invalid.Name'); // throws an Error
29
+ * ```
30
+ */
31
+ export declare class TypeName {
32
+ private _value;
33
+ private constructor();
34
+ get value(): string;
35
+ static get allTypeNames(): string;
36
+ static fromUnionOfTypeNames: (className: TypeName, factoryName: TypeName) => TypeName;
37
+ static fromString: (value: string) => TypeName;
38
+ }
39
+ /**
40
+ * @name FieldName
41
+ * @description Represents a single valid name of a field belong to a Graphql Type.
42
+ * @exampleMarkdown
43
+ * ```ts filename:"config.ts"
44
+ * // returns a FieldName
45
+ * let fieldName: FieldName = FieldName.fromString('id');
46
+ *
47
+ * // the following will throw an error
48
+ * // can contain only a single value...
49
+ * let fieldName: FieldName = FieldName.fromString('id, name'); // throws an Error
50
+ *
51
+ * // value can not be an empty string...
52
+ * let fieldName: FieldName = FieldName.fromString(''); // throws an Error
53
+ *
54
+ * // value must contain only AlphaNumeric characters only...
55
+ * let fieldName: FieldName = FieldName.fromString('Invalid.Name'); // throws an Error
56
+ * ```
57
+ */
58
+ export declare class FieldName {
59
+ private _value;
60
+ private constructor();
61
+ get value(): string;
62
+ static get allFieldNames(): string;
63
+ static fromString: (value: string) => FieldName;
64
+ }
65
+ /**
66
+ * @name Pattern
67
+ * @description The base class for TypeNamePattern and FieldNamePattern
68
+ * @see {@link url TypeNamePattern}
69
+ * @see {@link url FieldNamePattern}
70
+ */
71
+ export declare class Pattern {
72
+ private _value;
73
+ protected constructor(value: string);
74
+ get value(): string;
75
+ protected static fromString: (value: string) => Pattern;
76
+ static attemptMatchAndConfigure: (pattern: FieldNamePattern, typeName: TypeName, fieldName?: FieldName) => MatchAndConfigure;
77
+ static compose: (data: Pattern[]) => Pattern;
78
+ static split: (pattern: Pattern) => Pattern[];
79
+ static getMatchList: (patternType: 'TypeNamePattern' | 'FieldNamePattern' | 'Pattern') => string[];
80
+ /**
81
+ * finds the last pattern that configures the typeName and/or fieldName given
82
+ * @param pattern
83
+ * @param typeName
84
+ * @param fieldName
85
+ * @returns true if a pattern marks the typeName and or fieldName given to be configured, otherwise false
86
+ */
87
+ static findLastConfiguration: (pattern: Pattern, typeName: TypeName, fieldName?: FieldName) => boolean;
88
+ }
89
+ /**
90
+ * @name TypeNamePattern
91
+ *
92
+ * @description A compact string of patterns used in the config for granular configuration of Graphql Types.
93
+ *
94
+ * The string can contain one or more patterns, each pattern ends with a semi-colon (`;`).
95
+ *
96
+ * To apply an option to all Graphql Types or all fields, use the allTypeNames (`@*TypeNames`) tokens.
97
+ *
98
+ * Wherever you use the allTypeNames token, know very well that you can make some exceptions. After all, to every rule, there is an exception.
99
+ *
100
+ * A **square bracket** (`[]`) is used to specify what should be included and a **negated square bracket** (`-[]`) is used to specify what should be excluded.
101
+ *
102
+ * Manually typing out a pattern may be prone to typos resulting in invalid patterns therefore the [`TypeNamePattern`]() class exposes some builder methods to be used in the plugin config file.
103
+ *
104
+ * ## Available Builder Methods and the patterns they make
105
+ * ```ts
106
+ * const Droid = TypeName.fromString('Droid');
107
+ * const Starship = TypeName.fromString('Starship');
108
+ * const Human = TypeName.fromString('Human');
109
+ * const Movie = TypeName.fromString('Movie');
110
+
111
+ *
112
+ * // Configuring specific Graphql Types
113
+ * const pattern = TypeNamePattern.forTypeNames([Droid, Starship]);
114
+ * console.log(pattern); // "Droid;Starship;"
115
+ *
116
+ * // Configuring all Graphql Types
117
+ * const pattern = TypeNamePattern.forAllTypeNames();
118
+ * console.log(pattern); // "@*TypeNames;"
119
+
120
+ * // Configuring all Graphql Types except those specified in the exclusion list of TypeNames
121
+ * const pattern = TypeNamePattern.forAllTypeNamesExcludeTypeNames([Droid, Starship]);
122
+ * console.log(pattern); // "@*TypeNames-[Droid,Starship];"
123
+ *
124
+ */
125
+ export declare class TypeNamePattern extends Pattern {
126
+ private constructor();
127
+ static forTypeNames: (typeNames: TypeNames) => TypeNamePattern;
128
+ static regexpForTypeNames: RegExp;
129
+ static matchAndConfigureTypeNames: (pattern: TypeNamePattern, typeName: TypeName) => MatchAndConfigure;
130
+ static forAllTypeNames: () => TypeNamePattern;
131
+ static regexpForAllTypeNames: RegExp;
132
+ static matchAndConfigureAllTypeNames: (pattern: TypeNamePattern, typeName: TypeName) => MatchAndConfigure;
133
+ static forAllTypeNamesExcludeTypeNames: (typeNames: TypeNames) => TypeNamePattern;
134
+ static regexpForAllTypeNamesExcludeTypeNames: RegExp;
135
+ static matchAndConfigureAllTypeNamesExcludeTypeNames: (pattern: TypeNamePattern, typeName: TypeName) => MatchAndConfigure;
136
+ }
137
+ /**
138
+ * @name FieldNamePattern
139
+ *
140
+ * @description A compact string of patterns used in the config for granular configuration the fields of a Graphql Type
141
+ *
142
+ * The string can contain one or more patterns, each pattern ends with a semi-colon (`;`).
143
+ *
144
+ * A dot (`.`) is used to separate the TypeName from the FieldNames in each pattern.
145
+ *
146
+ * To apply an option to all Graphql Types or all fields, use the allTypeNames (`@*TypeNames`) and allFieldNames (`@*FieldNames`) tokens respectively.
147
+ *
148
+ * Wherever you use the allTypeNames and the allFieldNames, know very well that you can make some exceptions. After all, to every rule, there is an exception.
149
+ *
150
+ * A **square bracket** (`[]`) is used to specify what should be included and a **negated square bracket** (`-[]`) is used to specify what should be excluded.
151
+ *
152
+ * Manually typing out a pattern may be prone to typos resulting in invalid patterns therefore the [`FieldName`]() class exposes some builder methods to be used in your plugin config file.
153
+ *
154
+ * ## Available Builder Methods and the patterns they make
155
+ * ```ts
156
+ * const Droid = TypeName.fromString('Droid');
157
+ * const Starship = TypeName.fromString('Starship');
158
+ * const Human = TypeName.fromString('Human');
159
+ * const Movie = TypeName.fromString('Movie');
160
+ *
161
+ * const id = FieldName.fromString('id');
162
+ * const name = FieldName.fromString('name');
163
+ * const friends = FieldName.fromString('friends');
164
+ * const friend = FieldName.fromString('friend');
165
+ * const title = FieldName.fromString('title');
166
+ * const episode = FieldName.fromString('episode');
167
+ * const length = FieldName.fromString('length');
168
+ *
169
+ * // Configuring specific fields of a specific Graphql Type
170
+ * const pattern = FieldNamePattern.forFieldNamesOfTypeName([
171
+ * [Droid, [id, name, friends]], // individual
172
+ * [Human, [id, name, title]], // individual
173
+ * [Starship, [name, length]], // individual
174
+ * ]);
175
+ * console.log(pattern); // "Droid.[id,name,friends];Human.[id,name,title];Starship.[name,length];"
176
+ *
177
+ * // Configuring all fields of a specific Graphql Type
178
+ * const pattern = FieldNamePattern.forAllFieldNamesOfTypeName([Droid, Movie]);
179
+ * console.log(pattern); // "Droid.@*FieldNames;Movie.@*FieldNames;"
180
+ *
181
+ * // Configuring all fields except those specified in the exclusion list of FieldNames for a specific GraphQL Type
182
+ * const pattern = FieldNamePattern.forAllFieldNamesExcludeFieldNamesOfTypeName([
183
+ * [Droid, [id, name, friends]], // individual
184
+ * [Human, [id, name, title]], // individual
185
+ * [Starship, [name, length]], // individual
186
+ * ]);
187
+ * console.log(pattern); // "Droid.@*FieldNames-[id,name,friends];Human.@*FieldNames-[id,name,title];Starship.@*FieldNames-[name,length];"
188
+ *
189
+ * // Configuring specific fields of all Graphql Types
190
+ * const pattern = FieldNamePattern.forFieldNamesOfAllTypeNames([id, name, friends]);
191
+ * console.log(pattern); // "@*TypeNames.[id,name,friends];"
192
+ *
193
+ * // Configuring all fields of all Graphql Types
194
+ * const pattern = FieldNamePattern.forAllFieldNamesOfAllTypeNames();
195
+ * console.log(pattern); // "@*TypeNames.@*FieldNames;"
196
+ *
197
+ * // Configuring all fields except those specified in the exclusion list of FieldNames for all GraphQL Types
198
+ * const pattern = FieldNamePattern.forAllFieldNamesExcludeFieldNamesOfAllTypeNames([id, name, friends]);
199
+ * console.log(pattern); // "@*TypeNames.@*FieldNames-[id,name,friends];"
200
+ *
201
+ * // Configuring specific fields of all GraphQL Types except those specified in the exclusion list of TypeNames
202
+ * const pattern = FieldNamePattern.forFieldNamesOfAllTypeNamesExcludeTypeNames([Droid, Human], [id, name, friends]);
203
+ * console.log(pattern); // "@*TypeNames-[Droid,Human].[id,name,friends];"
204
+ *
205
+ * // Configuring all fields of all GraphQL Types except those specified in the exclusion list of TypeNames
206
+ * const pattern = FieldNamePattern.forAllFieldNamesOfAllTypeNamesExcludeTypeNames([Droid, Human]);
207
+ * console.log(pattern); // "@*TypeNames-[Droid,Human].@*FieldNames;"
208
+ *
209
+ * // Configuring all fields except those specified in the exclusion list of FieldNames of all GraphQL Types except those specified in the exclusion list of TypeNames
210
+ * const pattern = FieldNamePattern.forAllFieldNamesExcludeFieldNamesOfAllTypeNamesExcludeTypeNames(
211
+ * [Droid, Human],
212
+ * [id, name, friends]
213
+ * );
214
+ * console.log(pattern); // "@*TypeNames-[Droid,Human].@*FieldNames-[id,name,friends];"
215
+ * ```
216
+ *
217
+ */
218
+ export declare class FieldNamePattern extends Pattern {
219
+ private constructor();
220
+ static forFieldNamesOfTypeName: (data: [typeNames: TypeNames, fieldNames: FieldNames][]) => FieldNamePattern;
221
+ static regexpForFieldNamesOfTypeName: RegExp;
222
+ static matchAndConfigureFieldNamesOfTypeName: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
223
+ static forAllFieldNamesOfTypeName: (typeNames: TypeNames) => FieldNamePattern;
224
+ static regexpForAllFieldNamesOfTypeName: RegExp;
225
+ static matchAndConfigureAllFieldNamesOfTypeName: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
226
+ static forAllFieldNamesExcludeFieldNamesOfTypeName: (data: [typeNames: TypeNames, fieldNames: FieldNames][]) => FieldNamePattern;
227
+ static regexpForAllFieldNamesExcludeFieldNamesOfTypeName: RegExp;
228
+ static matchAndConfigureAllFieldNamesExcludeFieldNamesOfTypeName: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
229
+ static forFieldNamesOfAllTypeNames: (fieldNames: FieldNames) => FieldNamePattern;
230
+ static regexpForFieldNamesOfAllTypeNames: RegExp;
231
+ static matchAndConfigureFieldNamesOfAllTypeNames: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
232
+ static forAllFieldNamesOfAllTypeNames: () => FieldNamePattern;
233
+ static regexpForAllFieldNamesOfAllTypeNames: RegExp;
234
+ static matchAndConfigureAllFieldNamesOfAllTypeNames: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
235
+ static forAllFieldNamesExcludeFieldNamesOfAllTypeNames: (fieldNames: FieldNames) => FieldNamePattern;
236
+ static regexpForAllFieldNamesExcludeFieldNamesOfAllTypeNames: RegExp;
237
+ static matchAndConfigureAllFieldNamesExcludeFieldNamesOfAllTypeNames: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
238
+ static forFieldNamesOfAllTypeNamesExcludeTypeNames: (typeNames: TypeNames, fieldNames: FieldNames) => FieldNamePattern;
239
+ static regexpForFieldNamesOfAllTypeNamesExcludeTypeNames: RegExp;
240
+ static matchAndConfigureFieldNamesOfAllTypeNamesExcludeTypeNames: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
241
+ static forAllFieldNamesOfAllTypeNamesExcludeTypeNames: (typeNames: TypeNames) => FieldNamePattern;
242
+ static regexpForAllFieldNamesOfAllTypeNamesExcludeTypeNames: RegExp;
243
+ static matchAndConfigureAllFieldNamesOfAllTypeNamesExcludeTypeNames: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
244
+ static forAllFieldNamesExcludeFieldNamesOfAllTypeNamesExcludeTypeNames: (typeNames: TypeNames, fieldNames: FieldNames) => FieldNamePattern;
245
+ static regexpForAllFieldNamesExcludeFieldNamesOfAllTypeNamesExcludeTypeNames: RegExp;
246
+ static matchAndConfigureAllFieldNamesExcludeFieldNamesOfAllTypeNamesExcludeTypeNames: (pattern: FieldNamePattern, typeName: TypeName, fieldName: FieldName) => MatchAndConfigure;
247
+ }
248
+ export declare type MatchAndConfigure = Record<string, {
249
+ matchFound: boolean;
250
+ shouldBeConfigured: boolean;
251
+ }>;
252
+ export {};