@graphql-codegen/flutter-freezed 2.11.2 → 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.
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 +141 -0
  4. package/cjs/freezed-declaration-blocks/class-block.js +86 -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 +138 -0
  16. package/esm/freezed-declaration-blocks/class-block.js +85 -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 +5 -5
  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 +727 -0
  31. package/typings/config/plugin-config.d.ts +727 -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,132 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Config = void 0;
4
+ const utils_js_1 = require("../utils.js");
5
+ const pattern_js_1 = require("./pattern.js");
6
+ const plugin_config_js_1 = require("./plugin-config.js");
7
+ class Config {
8
+ }
9
+ exports.Config = Config;
10
+ Config.camelCasedEnums = (config) => {
11
+ const _camelCasedEnums = config.camelCasedEnums;
12
+ if (_camelCasedEnums === true) {
13
+ return 'camelCase';
14
+ }
15
+ else if (_camelCasedEnums === false) {
16
+ return undefined;
17
+ }
18
+ return _camelCasedEnums;
19
+ };
20
+ Config.copyWith = (config, typeName) => {
21
+ return Config.enableWithBooleanOrTypeFieldName(config.copyWith, typeName);
22
+ };
23
+ Config.customScalars = (config, graphqlScalar) => {
24
+ var _a, _b, _c;
25
+ return (_c = (_b = (_a = config.customScalars) === null || _a === void 0 ? void 0 : _a[graphqlScalar]) !== null && _b !== void 0 ? _b : plugin_config_js_1.DART_SCALARS[graphqlScalar]) !== null && _c !== void 0 ? _c : graphqlScalar;
26
+ };
27
+ Config.defaultValues = (config, blockAppliesOn, typeName, fieldName) => {
28
+ var _a, _b, _c, _d;
29
+ const decorator = (defaultValue) => (defaultValue ? `@Default(${defaultValue})\n` : '');
30
+ const defaultValue = (_d = (_c = (_b = (_a = config.defaultValues) === null || _a === void 0 ? void 0 : _a.filter(([pattern, , configAppliesOn]) => pattern_js_1.Pattern.findLastConfiguration(pattern, typeName, fieldName) && (0, utils_js_1.appliesOnBlock)(configAppliesOn, blockAppliesOn))) === null || _b === void 0 ? void 0 : _b.slice(-1)) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d[1];
31
+ return decorator(defaultValue);
32
+ };
33
+ Config.deprecated = (config, blockAppliesOn, typeName, fieldName) => {
34
+ var _a, _b, _c;
35
+ const isDeprecated = ((_c = (_b = (_a = config.deprecated) === null || _a === void 0 ? void 0 : _a.filter(([pattern, configAppliesOn]) => pattern_js_1.Pattern.findLastConfiguration(pattern, typeName, fieldName) &&
36
+ (0, utils_js_1.appliesOnBlock)(configAppliesOn, blockAppliesOn))) === null || _b === void 0 ? void 0 : _b.slice(-1)) === null || _c === void 0 ? void 0 : _c[0]) !== undefined;
37
+ return isDeprecated ? '@deprecated\n' : '';
38
+ };
39
+ Config.equal = (config, typeName) => {
40
+ return Config.enableWithBooleanOrTypeFieldName(config.equal, typeName);
41
+ };
42
+ Config.escapeDartKeywords = (config, blockAppliesOn, typeName, fieldName) => {
43
+ const escapeDartKeywords = config.escapeDartKeywords;
44
+ if (escapeDartKeywords === true) {
45
+ return ['', '_']; // use a suffix `_`
46
+ }
47
+ else if (typeName && Array.isArray(escapeDartKeywords) && escapeDartKeywords.length > 0) {
48
+ const [, prefix, suffix] = escapeDartKeywords
49
+ .filter(([pattern, , , configAppliesOn]) => pattern_js_1.Pattern.findLastConfiguration(pattern, typeName, fieldName) &&
50
+ (0, utils_js_1.appliesOnBlock)(configAppliesOn !== null && configAppliesOn !== void 0 ? configAppliesOn : [...plugin_config_js_1.APPLIES_ON_ALL_BLOCKS], blockAppliesOn))
51
+ .slice(-1)[0];
52
+ return [prefix, suffix];
53
+ }
54
+ return ['', '']; // no suffix
55
+ };
56
+ Config.final = (config, blockAppliesOn, typeName, fieldName) => {
57
+ var _a, _b, _c;
58
+ return (((_c = (_b = (_a = config.final) === null || _a === void 0 ? void 0 : _a.filter(([pattern, configAppliesOn]) => pattern_js_1.Pattern.findLastConfiguration(pattern, typeName, fieldName) &&
59
+ (0, utils_js_1.appliesOnBlock)(configAppliesOn, blockAppliesOn))) === null || _b === void 0 ? void 0 : _b.slice(-1)) === null || _c === void 0 ? void 0 : _c[0]) !== undefined);
60
+ };
61
+ /* static fromJsonToJson = ( // TODO: @next-version
62
+ config: FlutterFreezedPluginConfig,
63
+ blockAppliesOn?: readonly AppliesOnParameters[],
64
+ typeName?: TypeName,
65
+ fieldName?: FieldName
66
+ ) => {
67
+ const fromJsonToJson = config.fromJsonToJson;
68
+
69
+ if (typeName && fieldName && Array.isArray(fromJsonToJson)) {
70
+ const [, classOrFunctionName, useClassConverter] = (fromJsonToJson ?? [])
71
+ ?.filter(
72
+ ([pattern, , , appliesOn]) =>
73
+ Pattern.findLastConfiguration(pattern, typeName, fieldName) && appliesOnBlock(appliesOn, blockAppliesOn)
74
+ )
75
+ ?.slice(-1)?.[0];
76
+ return [classOrFunctionName, useClassConverter] as [classOrFunctionName: string, useClassConverter?: boolean];
77
+ } else if (typeName && fromJsonToJson instanceof TypeNamePattern) {
78
+ return Pattern.findLastConfiguration(fromJsonToJson, typeName);
79
+ }
80
+
81
+ return fromJsonToJson as boolean;
82
+ };
83
+ */
84
+ Config.ignoreTypes = (config, typeName) => {
85
+ const ignoreTypes = config.ignoreTypes;
86
+ if (ignoreTypes) {
87
+ const isIgnored = pattern_js_1.Pattern.findLastConfiguration(ignoreTypes, typeName);
88
+ return isIgnored ? [typeName.value] : [];
89
+ }
90
+ return [];
91
+ };
92
+ Config.immutable = (config, typeName) => {
93
+ return Config.enableWithBooleanOrTypeFieldName(config.immutable, typeName);
94
+ };
95
+ Config.makeCollectionsUnmodifiable = (config, typeName) => {
96
+ return Config.enableWithBooleanOrTypeFieldName(config.makeCollectionsUnmodifiable, typeName);
97
+ };
98
+ Config.mergeTypes = (config, typeName) => {
99
+ var _a, _b;
100
+ return (_b = (_a = config.mergeTypes) === null || _a === void 0 ? void 0 : _a[typeName.value]) !== null && _b !== void 0 ? _b : [];
101
+ };
102
+ Config.mutableInputs = (config, typeName) => {
103
+ return Config.enableWithBooleanOrTypeFieldName(config.mutableInputs, typeName);
104
+ };
105
+ Config.privateEmptyConstructor = (config, typeName) => {
106
+ return Config.enableWithBooleanOrTypeFieldName(config.privateEmptyConstructor, typeName);
107
+ };
108
+ Config.unionClass = ( /* config: FlutterFreezedPluginConfig, index: number, unionTypeName: TypeName */) => {
109
+ // const unionClass = config['unionClass'];
110
+ return undefined;
111
+ };
112
+ Config.unionKey = ( /* config: FlutterFreezedPluginConfig, typeName: TypeName */) => {
113
+ return undefined;
114
+ };
115
+ Config.unionValueCase = ( /* config: FlutterFreezedPluginConfig, typeName: TypeName */) => {
116
+ return undefined;
117
+ };
118
+ Config.unionValueFactoryDecorator = () => {
119
+ return undefined;
120
+ };
121
+ Config.enableWithBooleanOrTypeFieldName = (value, typeName) => {
122
+ if (typeof value === 'boolean') {
123
+ return value;
124
+ }
125
+ else if (value !== undefined && typeName !== undefined) {
126
+ return pattern_js_1.Pattern.findLastConfiguration(value, typeName);
127
+ }
128
+ return undefined;
129
+ };
130
+ Config.create = (...config) => {
131
+ return Object.assign({}, plugin_config_js_1.defaultFreezedPluginConfig, ...config);
132
+ };