@comet/admin-generator 8.17.1 → 9.0.0-beta.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 (87) hide show
  1. package/bin/admin-generator.mjs +3 -0
  2. package/dist/adminGenerator.d.mts +1 -0
  3. package/dist/adminGenerator.mjs +4441 -0
  4. package/dist/index.d.mts +344 -0
  5. package/dist/index.mjs +4440 -0
  6. package/package.json +31 -21
  7. package/bin/admin-generator.js +0 -8
  8. package/lib/adminGenerator.d.ts +0 -1
  9. package/lib/adminGenerator.js +0 -8
  10. package/lib/commands/generate/config/parseConfig.d.ts +0 -1
  11. package/lib/commands/generate/config/parseConfig.js +0 -72
  12. package/lib/commands/generate/config/transformConfig.d.ts +0 -7
  13. package/lib/commands/generate/config/transformConfig.js +0 -264
  14. package/lib/commands/generate/generate-command.d.ts +0 -340
  15. package/lib/commands/generate/generate-command.js +0 -112
  16. package/lib/commands/generate/generateForm/asyncSelect/generateAsyncSelect.d.ts +0 -26
  17. package/lib/commands/generate/generateForm/asyncSelect/generateAsyncSelect.js +0 -364
  18. package/lib/commands/generate/generateForm/extractErrorEnums.d.ts +0 -16
  19. package/lib/commands/generate/generateForm/extractErrorEnums.js +0 -100
  20. package/lib/commands/generate/generateForm/flatFormFieldsFromFormConfig.d.ts +0 -2
  21. package/lib/commands/generate/generateForm/flatFormFieldsFromFormConfig.js +0 -22
  22. package/lib/commands/generate/generateForm/formField/findIntrospectionFieldType.d.ts +0 -6
  23. package/lib/commands/generate/generateForm/formField/findIntrospectionFieldType.js +0 -22
  24. package/lib/commands/generate/generateForm/formField/options.d.ts +0 -24
  25. package/lib/commands/generate/generateForm/formField/options.js +0 -85
  26. package/lib/commands/generate/generateForm/generateComponentFormField.d.ts +0 -5
  27. package/lib/commands/generate/generateForm/generateComponentFormField.js +0 -22
  28. package/lib/commands/generate/generateForm/generateErrorHandling.d.ts +0 -8
  29. package/lib/commands/generate/generateForm/generateErrorHandling.js +0 -24
  30. package/lib/commands/generate/generateForm/generateErrorMessages.d.ts +0 -11
  31. package/lib/commands/generate/generateForm/generateErrorMessages.js +0 -28
  32. package/lib/commands/generate/generateForm/generateFields.d.ts +0 -42
  33. package/lib/commands/generate/generateForm/generateFields.js +0 -87
  34. package/lib/commands/generate/generateForm/generateForm.d.ts +0 -14
  35. package/lib/commands/generate/generateForm/generateForm.js +0 -565
  36. package/lib/commands/generate/generateForm/generateFormField.d.ts +0 -12
  37. package/lib/commands/generate/generateForm/generateFormField.js +0 -368
  38. package/lib/commands/generate/generateForm/generateFormLayout.d.ts +0 -12
  39. package/lib/commands/generate/generateForm/generateFormLayout.js +0 -154
  40. package/lib/commands/generate/generateForm/generateFormValues.d.ts +0 -40
  41. package/lib/commands/generate/generateForm/generateFormValues.js +0 -219
  42. package/lib/commands/generate/generateForm/generateFragmentByFormFragmentFields.d.ts +0 -11
  43. package/lib/commands/generate/generateForm/generateFragmentByFormFragmentFields.js +0 -29
  44. package/lib/commands/generate/generateForm/getForwardedGqlArgs.d.ts +0 -18
  45. package/lib/commands/generate/generateForm/getForwardedGqlArgs.js +0 -79
  46. package/lib/commands/generate/generateGrid/detectMuiXVersion.d.ts +0 -5
  47. package/lib/commands/generate/generateGrid/detectMuiXVersion.js +0 -32
  48. package/lib/commands/generate/generateGrid/findInputObjectType.d.ts +0 -2
  49. package/lib/commands/generate/generateGrid/findInputObjectType.js +0 -15
  50. package/lib/commands/generate/generateGrid/generateGqlFieldList.d.ts +0 -6
  51. package/lib/commands/generate/generateGrid/generateGqlFieldList.js +0 -56
  52. package/lib/commands/generate/generateGrid/generateGrid.d.ts +0 -16
  53. package/lib/commands/generate/generateGrid/generateGrid.js +0 -1017
  54. package/lib/commands/generate/generateGrid/generateGridToolbar.d.ts +0 -15
  55. package/lib/commands/generate/generateGrid/generateGridToolbar.js +0 -90
  56. package/lib/commands/generate/generateGrid/getForwardedGqlArgs.d.ts +0 -13
  57. package/lib/commands/generate/generateGrid/getForwardedGqlArgs.js +0 -59
  58. package/lib/commands/generate/generateGrid/getPropsForFilterProp.d.ts +0 -14
  59. package/lib/commands/generate/generateGrid/getPropsForFilterProp.js +0 -13
  60. package/lib/commands/generate/generateGrid/usableFields.d.ts +0 -14
  61. package/lib/commands/generate/generateGrid/usableFields.js +0 -3
  62. package/lib/commands/generate/utils/camelCaseToHumanReadable.d.ts +0 -1
  63. package/lib/commands/generate/utils/camelCaseToHumanReadable.js +0 -7
  64. package/lib/commands/generate/utils/columnVisibility.d.ts +0 -6
  65. package/lib/commands/generate/utils/columnVisibility.js +0 -2
  66. package/lib/commands/generate/utils/convertConfigImport.d.ts +0 -6
  67. package/lib/commands/generate/utils/convertConfigImport.js +0 -14
  68. package/lib/commands/generate/utils/findMutationType.d.ts +0 -3
  69. package/lib/commands/generate/utils/findMutationType.js +0 -18
  70. package/lib/commands/generate/utils/findQueryType.d.ts +0 -2
  71. package/lib/commands/generate/utils/findQueryType.js +0 -18
  72. package/lib/commands/generate/utils/findRootBlocks.d.ts +0 -8
  73. package/lib/commands/generate/utils/findRootBlocks.js +0 -66
  74. package/lib/commands/generate/utils/generateGqlOperation.d.ts +0 -12
  75. package/lib/commands/generate/utils/generateGqlOperation.js +0 -87
  76. package/lib/commands/generate/utils/generateImportsCode.d.ts +0 -6
  77. package/lib/commands/generate/utils/generateImportsCode.js +0 -31
  78. package/lib/commands/generate/utils/intl.d.ts +0 -20
  79. package/lib/commands/generate/utils/intl.js +0 -44
  80. package/lib/commands/generate/utils/isFieldOptional.d.ts +0 -7
  81. package/lib/commands/generate/utils/isFieldOptional.js +0 -21
  82. package/lib/commands/generate/utils/runtimeTypeGuards.d.ts +0 -20
  83. package/lib/commands/generate/utils/runtimeTypeGuards.js +0 -22
  84. package/lib/commands/generate/utils/writeGenerated.d.ts +0 -1
  85. package/lib/commands/generate/utils/writeGenerated.js +0 -123
  86. package/lib/index.d.ts +0 -2
  87. package/lib/index.js +0 -6
@@ -1,219 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formValuesConfigToTree = formValuesConfigToTree;
4
- exports.generateFormValuesType = generateFormValuesType;
5
- exports.generateInitialValues = generateInitialValues;
6
- exports.generateDestructFormValueForInput = generateDestructFormValueForInput;
7
- exports.generateFormValuesToGqlInput = generateFormValuesToGqlInput;
8
- // internal represenstation of formValuesConfig as tree to allow recursive processing
9
- function formValuesConfigToTree({ formValuesConfig, gqlIntrospection, gqlType, }) {
10
- const treeRoot = { children: {} };
11
- for (const formValueConfig of formValuesConfig) {
12
- const fieldName = formValueConfig.fieldName;
13
- let currentTreeNode = treeRoot;
14
- let currentGqlType = gqlType;
15
- for (const part of fieldName.split(".")) {
16
- const introspectionObject = gqlIntrospection.__schema.types.find((type) => type.kind === "OBJECT" && type.name === currentGqlType);
17
- if (!introspectionObject)
18
- throw new Error(`didn't find object ${gqlType} in gql introspection`);
19
- const introspectionField = introspectionObject.fields.find((field) => field.name === part);
20
- const introspectionFieldType = introspectionField
21
- ? introspectionField.type.kind === "NON_NULL"
22
- ? introspectionField.type.ofType
23
- : introspectionField.type
24
- : undefined;
25
- if ((introspectionFieldType === null || introspectionFieldType === void 0 ? void 0 : introspectionFieldType.kind) === "OBJECT") {
26
- // for next loop iteration (nested fields)
27
- currentGqlType = introspectionFieldType.name;
28
- }
29
- if (!currentTreeNode.children[part]) {
30
- currentTreeNode.children[part] = { children: {} };
31
- }
32
- currentTreeNode.children[part].nullable = (introspectionField === null || introspectionField === void 0 ? void 0 : introspectionField.type.kind) !== "NON_NULL";
33
- currentTreeNode = currentTreeNode.children[part];
34
- }
35
- currentTreeNode.config = formValueConfig;
36
- }
37
- return treeRoot.children;
38
- }
39
- function generateFormValuesTypeFromTree(tree, currentTypeName, currentIsNullable) {
40
- var _a, _b, _c;
41
- const omitKeys = [];
42
- let appendCode = "";
43
- for (const [key, value] of Object.entries(tree)) {
44
- if (Object.keys(value.children).length > 0) {
45
- let childRootType = `${currentTypeName}["${key}"]`;
46
- if (currentIsNullable) {
47
- childRootType = `NonNullable<${currentTypeName}>["${key}"]`;
48
- }
49
- const childOmit = generateFormValuesTypeFromTree(value.children, childRootType, (_a = value.nullable) !== null && _a !== void 0 ? _a : false);
50
- if (childOmit !== childRootType) {
51
- appendCode += `${key}: ${childOmit}`;
52
- omitKeys.push(key);
53
- }
54
- if ((_b = value.config) === null || _b === void 0 ? void 0 : _b.typeCode) {
55
- throw new Error("Field has both subfields and direct typeCode, which is not supported.");
56
- }
57
- if ((_c = value.config) === null || _c === void 0 ? void 0 : _c.omitFromFragmentType) {
58
- throw new Error("Field has both subfields and direct omitFromFragmentType, which is not supported.");
59
- }
60
- }
61
- else if (value.config) {
62
- if (value.config.typeCode) {
63
- appendCode += `${key}${value.config.typeCode.nullable ? "?" : ""}: ${value.config.typeCode.type}; `;
64
- }
65
- if (value.config.omitFromFragmentType) {
66
- omitKeys.push(key);
67
- }
68
- }
69
- }
70
- let code = omitKeys.length
71
- ? `Omit<${currentIsNullable ? `NonNullable<` : ""}${currentTypeName}${currentIsNullable ? `>` : ""}, ${omitKeys.map((k) => `"${k}"`).join(" | ")}>`
72
- : currentTypeName;
73
- if (appendCode.length) {
74
- code += ` & { ${appendCode} }`;
75
- }
76
- return code;
77
- }
78
- function generateFormValuesType({ formValuesConfig, filterByFragmentType, gqlIntrospection, gqlType, }) {
79
- const tree = formValuesConfigToTree({ formValuesConfig, gqlIntrospection, gqlType });
80
- return `type FormValues = ${generateFormValuesTypeFromTree(tree, filterByFragmentType, false)};`;
81
- }
82
- function generateInitialValuesFromTree(tree, dataObject, generationType) {
83
- var _a;
84
- let code = "";
85
- for (const [key, value] of Object.entries(tree)) {
86
- if (Object.keys(value.children).length > 0) {
87
- let childCode = generateInitialValuesFromTree(value.children, dataObject ? `${dataObject}.${key}` : null, generationType);
88
- if (childCode.length) {
89
- if (dataObject) {
90
- childCode = `{ ...${dataObject}.${key}, ${childCode} }`;
91
- if (value.nullable) {
92
- code += `${key}: ${dataObject}.${key} ? ${childCode} : undefined, `;
93
- }
94
- else {
95
- code += `${key}: ${childCode}, `;
96
- }
97
- }
98
- else {
99
- code += `${key}: { ${childCode} }, `;
100
- }
101
- }
102
- if ((_a = value.config) === null || _a === void 0 ? void 0 : _a[generationType]) {
103
- throw new Error("Field has both subfields and direct initialization code, which is not supported.");
104
- }
105
- }
106
- else if (value.config) {
107
- if (value.config[generationType]) {
108
- code += `${key}: ${value.config[generationType]}, `;
109
- }
110
- }
111
- }
112
- return code;
113
- }
114
- function generateInitialValues({ mode, formValuesConfig, filterByFragmentType, gqlIntrospection, gqlType, initialValuesAsProp, }) {
115
- const instanceGqlType = gqlType[0].toLowerCase() + gqlType.substring(1);
116
- const editMode = mode === "edit" || mode == "all";
117
- const tree = formValuesConfigToTree({ formValuesConfig, gqlIntrospection, gqlType });
118
- if (editMode) {
119
- return `const initialValues = useMemo<Partial<FormValues>>(() => data?.${instanceGqlType}
120
- ? {
121
- ...filterByFragment<${filterByFragmentType}>(${instanceGqlType}FormFragment, data.${instanceGqlType}),
122
- ${generateInitialValuesFromTree(tree, `data.${instanceGqlType}`, "initializationCode")}
123
- }
124
- : {
125
- ${generateInitialValuesFromTree(tree, initialValuesAsProp ? `passedInitialValues` : null, "defaultInitializationCode")}
126
- ${initialValuesAsProp ? `...passedInitialValues,` : ""}
127
- }
128
- , [data]);`;
129
- }
130
- else {
131
- return `const initialValues = {
132
- ${generateInitialValuesFromTree(tree, initialValuesAsProp ? `passedInitialValues` : null, "defaultInitializationCode")}
133
- ${initialValuesAsProp ? `...passedInitialValues,` : ""}
134
- };`;
135
- }
136
- }
137
- function generateDestructFormValueForInputFromTree(tree, restObject) {
138
- let code = "";
139
- for (const [key, value] of Object.entries(tree)) {
140
- if (Object.keys(value.children).length > 0) {
141
- const childCode = generateDestructFormValueForInputFromTree(value.children, `${restObject}${key.substring(0, 1).toUpperCase()}${key.substring(1)}`);
142
- if (childCode.length) {
143
- code += `${key}: { ${childCode} }, `;
144
- }
145
- }
146
- else if (value.config) {
147
- if (value.config.destructFromFormValues) {
148
- code += `${key}, `;
149
- }
150
- }
151
- }
152
- if (code.length) {
153
- code += `...${restObject}Rest`;
154
- return code;
155
- }
156
- else {
157
- return "";
158
- }
159
- }
160
- function generateDestructFormValueForInput({ formValuesConfig, gqlIntrospection, gqlType, }) {
161
- const tree = formValuesConfigToTree({ formValuesConfig, gqlIntrospection, gqlType });
162
- const code = generateDestructFormValueForInputFromTree(tree, "formValues");
163
- return code.length ? `{ ${code} }` : "formValues";
164
- }
165
- function generateFormValuesToGqlInputFromTree(tree, dataObject, restObject) {
166
- var _a, _b;
167
- let code = "";
168
- for (const [key, value] of Object.entries(tree)) {
169
- if (Object.keys(value.children).length > 0) {
170
- const childRestObject = `${restObject.replace(/Rest$/, "")}${key.substring(0, 1).toUpperCase()}${key.substring(1)}Rest`;
171
- const hasChildDestruct = hasChildDestructTree(value.children);
172
- let childCode = generateFormValuesToGqlInputFromTree(value.children, hasChildDestruct ? childRestObject : `${dataObject}.${key}`, childRestObject);
173
- if (childCode.length || hasChildDestruct) {
174
- childCode = `{ ...${hasChildDestruct ? childRestObject : `${dataObject}.${key}`}, ${childCode} }`;
175
- if ((_a = value.config) === null || _a === void 0 ? void 0 : _a.wrapFormValueToGqlInputCode) {
176
- childCode = value.config.wrapFormValueToGqlInputCode
177
- .replaceAll("$fieldName", `${dataObject}.${key}`)
178
- .replaceAll("$inner", childCode);
179
- }
180
- code += `${key}: ${childCode}, `;
181
- }
182
- if ((_b = value.config) === null || _b === void 0 ? void 0 : _b.formValueToGqlInputCode) {
183
- throw new Error("Field has both subfields and direct formValueToGqlInputCode, which is not supported.");
184
- }
185
- }
186
- else if (value.config) {
187
- if (value.config.formValueToGqlInputCode) {
188
- code += `${key}: ${value.config.formValueToGqlInputCode.replaceAll("$fieldName", `${dataObject}.${key}`)}, `;
189
- }
190
- }
191
- }
192
- return code;
193
- }
194
- function hasChildDestructTree(tree) {
195
- return Object.values(tree).some((childValue) => {
196
- var _a;
197
- if ((_a = childValue.config) === null || _a === void 0 ? void 0 : _a.destructFromFormValues) {
198
- return true;
199
- }
200
- if (Object.keys(childValue.children).length > 0) {
201
- return hasChildDestructTree(childValue.children);
202
- }
203
- return false;
204
- });
205
- }
206
- function generateFormValuesToGqlInput({ formValuesConfig, gqlIntrospection, gqlType, }) {
207
- const tree = formValuesConfigToTree({ formValuesConfig, gqlIntrospection, gqlType });
208
- const hasChildDestruct = hasChildDestructTree(tree);
209
- const code = generateFormValuesToGqlInputFromTree(tree, hasChildDestruct ? "formValuesRest" : "formValues", hasChildDestruct ? "formValuesRest" : "formValues");
210
- if (code.length) {
211
- return `const output = { ...${hasChildDestruct ? "formValuesRest" : "formValues"}, ${code} };`;
212
- }
213
- else if (hasChildDestruct) {
214
- return `const output = formValuesRest;`;
215
- }
216
- else {
217
- return `const output = formValues;`;
218
- }
219
- }
@@ -1,11 +0,0 @@
1
- /**
2
- * Helper function that generates a GraphQL fragment from form fragment fields (array of dot.separated.fields).
3
- *
4
- * - Fragments are supported as "foo...FragmentName"
5
- * - for FinalFormFileUpload and FinalFormFileUploadDownloadable the needed variable is added automatically
6
- */
7
- export declare function generateFragmentByFormFragmentFields({ formFragmentName, gqlType, formFragmentFields, }: {
8
- formFragmentName: string;
9
- gqlType: string;
10
- formFragmentFields: string[];
11
- }): string;
@@ -1,29 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.generateFragmentByFormFragmentFields = generateFragmentByFormFragmentFields;
4
- const generateGqlOperation_1 = require("../utils/generateGqlOperation");
5
- /**
6
- * Helper function that generates a GraphQL fragment from form fragment fields (array of dot.separated.fields).
7
- *
8
- * - Fragments are supported as "foo...FragmentName"
9
- * - for FinalFormFileUpload and FinalFormFileUploadDownloadable the needed variable is added automatically
10
- */
11
- function generateFragmentByFormFragmentFields({ formFragmentName, gqlType, formFragmentFields, }) {
12
- let fragmentCode = `
13
- fragment ${formFragmentName} on ${gqlType} {
14
- ${(0, generateGqlOperation_1.generateGqlQueryTreeFromFields)(formFragmentFields)}
15
- }
16
- `;
17
- // 3. add fragment instance variables when fragments are used
18
- // this only works for hardcoded special cases, and the imports are also not handled here - if there would be more, this needs improvement
19
- const fragments = {
20
- "...FinalFormFileUpload": "${finalFormFileUploadFragment}",
21
- "...FinalFormFileUploadDownloadable": "${finalFormFileUploadDownloadableFragment}",
22
- };
23
- for (const [fragmentName, fragmentVar] of Object.entries(fragments)) {
24
- if (fragmentCode.match(`${fragmentName.replace(".", "\\.")}\\b`) && !fragmentCode.includes(fragmentVar)) {
25
- fragmentCode += `\n${fragmentVar}`;
26
- }
27
- }
28
- return fragmentCode;
29
- }
@@ -1,18 +0,0 @@
1
- import { type IntrospectionField, type IntrospectionQuery } from "graphql";
2
- import { type FormFieldConfig } from "../generate-command";
3
- import { type Imports } from "../utils/generateImportsCode";
4
- import { type Prop } from "./generateForm";
5
- export type GqlArg = {
6
- type: string;
7
- name: string;
8
- isInputArgSubfield: boolean;
9
- };
10
- export declare function getForwardedGqlArgs({ fields, gqlOperation, gqlIntrospection, }: {
11
- fields: FormFieldConfig<any>[];
12
- gqlOperation: IntrospectionField;
13
- gqlIntrospection: IntrospectionQuery;
14
- }): {
15
- imports: Imports;
16
- prop: Prop;
17
- gqlArg: GqlArg;
18
- }[];
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getForwardedGqlArgs = getForwardedGqlArgs;
4
- function getForwardedGqlArgs({ fields, gqlOperation, gqlIntrospection, }) {
5
- const ret = [];
6
- getArgsIncludingInputArgSubfields(gqlOperation, gqlIntrospection).forEach((arg) => {
7
- if (arg.isInputArgSubfield) {
8
- if (fields.some((field) => {
9
- return field.name === arg.name || field.name.startsWith(`${arg.name}.`);
10
- })) {
11
- // there is a field (or subfield) in this form, no need to forward this arg
12
- return;
13
- }
14
- }
15
- let prop;
16
- const imports = [];
17
- if (arg.type === "ID" || arg.type === "String" || arg.type === "DateTime") {
18
- prop = { name: arg.name, optional: false, type: "string" };
19
- }
20
- else if (arg.type === "Boolean") {
21
- prop = { name: arg.name, optional: false, type: "boolean" };
22
- }
23
- else if (arg.type === "Int" || arg.type === "Float") {
24
- prop = { name: arg.name, optional: false, type: "number" };
25
- }
26
- else if (arg.type === "JSONObject") {
27
- prop = { name: arg.name, optional: false, type: "unknown" };
28
- }
29
- else {
30
- prop = { name: arg.name, optional: false, type: `GQL${arg.type}` }; // generated types contain GQL prefix
31
- imports.push({ name: `GQL${arg.type}`, importPath: "@src/graphql.generated" });
32
- }
33
- ret.push({ gqlArg: arg, prop, imports });
34
- });
35
- return ret;
36
- }
37
- function getArgsIncludingInputArgSubfields(gqlOperation, gqlIntrospection) {
38
- const nativeScalars = ["ID", "String", "Boolean", "Int", "Float", "DateTime", "JSONObject"];
39
- // reducer is not created inline to reuse it to look into "input" arg
40
- function reducer(acc, inputField) {
41
- if (inputField.type.kind !== "NON_NULL" || inputField.defaultValue)
42
- return acc;
43
- const gqlType = inputField.type.ofType;
44
- if (gqlType.kind === "INPUT_OBJECT") {
45
- if (inputField.name === "input") {
46
- // input-arg typically contains entity fields, so look into it
47
- const typeDef = gqlIntrospection.__schema.types.find((type) => type.kind === "INPUT_OBJECT" && type.name === gqlType.name);
48
- if (typeDef && typeDef.kind === "INPUT_OBJECT") {
49
- const inputArgSubfields = typeDef.inputFields.reduce(reducer, []).map((inputArgSubfield) => {
50
- return Object.assign(Object.assign({}, inputArgSubfield), { isInputArgSubfield: true });
51
- });
52
- acc.push(...inputArgSubfields);
53
- }
54
- else {
55
- console.warn(`IntrospectionType for ${gqlType.name} not found or no INPUT_OBJECT`);
56
- }
57
- }
58
- else {
59
- acc.push({ name: inputField.name, type: gqlType.name, isInputArgSubfield: false });
60
- }
61
- }
62
- else if (gqlType.kind === "SCALAR") {
63
- if (!nativeScalars.includes(gqlType.name)) {
64
- console.warn(`Currently not supported special SCALAR of type ${gqlType.name} in arg/field ${inputField.name}`);
65
- }
66
- else {
67
- acc.push({ name: inputField.name, type: gqlType.name, isInputArgSubfield: false });
68
- }
69
- }
70
- else if (gqlType.kind === "ENUM") {
71
- acc.push({ name: inputField.name, type: gqlType.name, isInputArgSubfield: false });
72
- }
73
- else if (gqlType.kind === "LIST") {
74
- throw new Error(`Not supported kind ${gqlType.kind}, arg: input.${inputField.name}`);
75
- }
76
- return acc;
77
- }
78
- return gqlOperation.args.reduce(reducer, []);
79
- }
@@ -1,5 +0,0 @@
1
- export declare function detectMuiXGridVariant(): {
2
- variant: "community" | "pro" | "premium";
3
- package: string;
4
- gridComponent: string;
5
- };
@@ -1,32 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.detectMuiXGridVariant = detectMuiXGridVariant;
7
- const fs_1 = __importDefault(require("fs"));
8
- function detectMuiXGridVariant() {
9
- const packageJson = JSON.parse(fs_1.default.readFileSync("package.json", "utf-8"));
10
- const packages = Object.keys(packageJson.dependencies);
11
- if (packages.includes("@mui/x-data-grid-premium")) {
12
- return {
13
- variant: "premium",
14
- package: "@mui/x-data-grid-premium",
15
- gridComponent: "DataGridPremium",
16
- };
17
- }
18
- else if (packages.includes("@mui/x-data-grid-pro")) {
19
- return {
20
- variant: "pro",
21
- package: "@mui/x-data-grid-pro",
22
- gridComponent: "DataGridPro",
23
- };
24
- }
25
- else {
26
- return {
27
- variant: "community",
28
- package: "@mui/x-data-grid",
29
- gridComponent: "DataGrid",
30
- };
31
- }
32
- }
@@ -1,2 +0,0 @@
1
- import { type IntrospectionInputObjectType, type IntrospectionInputValue, type IntrospectionQuery } from "graphql";
2
- export declare function findInputObjectType(input: IntrospectionInputValue, schema: IntrospectionQuery): IntrospectionInputObjectType | undefined;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findInputObjectType = findInputObjectType;
4
- function findInputObjectType(input, schema) {
5
- let type = input.type;
6
- if (type.kind == "NON_NULL") {
7
- type = type.ofType;
8
- }
9
- if (type.kind !== "INPUT_OBJECT") {
10
- throw new Error("must be INPUT_OBJECT");
11
- }
12
- const typeName = type.name;
13
- const filterType = schema.__schema.types.find((type) => type.kind === "INPUT_OBJECT" && type.name === typeName);
14
- return filterType;
15
- }
@@ -1,6 +0,0 @@
1
- import { type GridConfig } from "../generate-command";
2
- export declare function generateGqlFieldList<T extends {
3
- __typename?: string;
4
- }>({ columns }: {
5
- columns: GridConfig<T>["columns"];
6
- }): string;
@@ -1,56 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.generateGqlFieldList = generateGqlFieldList;
7
- const object_path_1 = __importDefault(require("object-path"));
8
- const recursiveStringify = (obj) => {
9
- let ret = "";
10
- let prefixField = "";
11
- for (const key in obj) {
12
- const valueForKey = obj[key];
13
- if (typeof valueForKey === "boolean") {
14
- ret += `${prefixField}${key}`;
15
- }
16
- else if (typeof valueForKey === "string") {
17
- ret += `${prefixField}${key}${valueForKey}`;
18
- }
19
- else {
20
- ret += `${prefixField}${key} { ${recursiveStringify(valueForKey)} }`;
21
- }
22
- prefixField = " ";
23
- }
24
- return ret;
25
- };
26
- function generateGqlFieldList({ columns }) {
27
- const fieldsObject = columns.reduce((acc, field) => {
28
- var _a, _b;
29
- if (field.type === "actions") {
30
- (_a = field.queryFields) === null || _a === void 0 ? void 0 : _a.forEach((queryField) => {
31
- object_path_1.default.set(acc, queryField, true);
32
- });
33
- }
34
- else if (field.name === "id") {
35
- // exclude id because it's always required
36
- }
37
- else {
38
- let hasCustomFields = false;
39
- if ("labelField" in field && field.labelField) {
40
- object_path_1.default.set(acc, `${field.name}.${field.labelField}`, true);
41
- hasCustomFields = true;
42
- }
43
- if ("queryFields" in field) {
44
- (_b = field.queryFields) === null || _b === void 0 ? void 0 : _b.forEach((queryField) => {
45
- object_path_1.default.set(acc, queryField, true);
46
- });
47
- hasCustomFields = true;
48
- }
49
- if (!hasCustomFields) {
50
- object_path_1.default.set(acc, field.name, true);
51
- }
52
- }
53
- return acc;
54
- }, {});
55
- return recursiveStringify(fieldsObject);
56
- }
@@ -1,16 +0,0 @@
1
- import { type IntrospectionQuery } from "graphql";
2
- import { type GeneratorReturn, type GridConfig } from "../generate-command";
3
- export type Prop = {
4
- type: string;
5
- optional: boolean;
6
- name: string;
7
- defaultValue?: string | number;
8
- };
9
- export declare function generateGrid<T extends {
10
- __typename?: string;
11
- }>({ exportName, baseOutputFilename, targetDirectory, gqlIntrospection, }: {
12
- exportName: string;
13
- baseOutputFilename: string;
14
- targetDirectory: string;
15
- gqlIntrospection: IntrospectionQuery;
16
- }, config: GridConfig<T>): GeneratorReturn;