@gadmin2n/prisma-react-generator 0.0.44 → 0.0.46

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.
@@ -5,7 +5,7 @@ const case_1 = require("case");
5
5
  const generateResources = ({ models, templateHelpers: t, }) => `
6
6
  import { ResourceProps } from "@refinedev/core";
7
7
 
8
- ${t.each(models, (model) => `import { ${model.name}List, ${model.name}Create, ${model.name}Edit, ${model.name}Show } from "../pages/${(0, case_1.camel)(model.name)}";`, '\n')}
8
+ ${t.each(models, (model) => `import { ${model.name}List, ${model.name}Create, ${model.name}Edit, ${model.name}Show } from "../routes/${(0, case_1.camel)(model.name)}";`, '\n')}
9
9
 
10
10
  const resources: ResourceProps[] = [
11
11
  ${t.each(models, (model) => `{
@@ -260,7 +260,7 @@ function getModelConfigStruct(model, enums = []) {
260
260
  const editableFields = [...relationFields, ...relationsFields].reduce((acc, cur) => {
261
261
  acc.push(`!${cur}.*`);
262
262
  return acc;
263
- }, ['*', '!creator', '!createdAt', '!updatedAt']);
263
+ }, ['*', '!creator', '!createdAt', '!updatedAt', '!created_at', '!updated_at']);
264
264
  const textFieldsExclude = model.fields
265
265
  .filter((field) => {
266
266
  const { formItem: { type }, } = (0, helpers_1.parseDocumentation)(field.documentation || '', field);
@@ -272,7 +272,7 @@ function getModelConfigStruct(model, enums = []) {
272
272
  acc.push(`!${cur}.*`);
273
273
  acc.push(`_count.${cur}`);
274
274
  return acc;
275
- }, ['*', '!createdAt', ...textFieldsExclude])
275
+ }, ['*', '!createdAt', '!created_at', ...textFieldsExclude])
276
276
  .concat(relationFields.reduce((acc, cur) => {
277
277
  acc.push(`!${cur}.*`);
278
278
  acc.push(`${cur}`);
@@ -50,6 +50,7 @@ declare type UiType = {
50
50
  type: 'String' | 'Boolean' | 'Int' | 'BigInt' | 'Float' | 'Decimal' | 'DateTime' | 'Markdown' | 'Html' | 'Url' | 'Email' | 'Other';
51
51
  args: {};
52
52
  };
53
+ tooltip?: string;
53
54
  };
54
55
  export declare function parseDocumentation(documentation: string, field: DMMF.Field): UiType;
55
56
  export {};
@@ -281,15 +281,21 @@ function getModelsEnum(enumTypesModel) {
281
281
  exports.getModelsEnum = getModelsEnum;
282
282
  function parseDocumentation(documentation, field) {
283
283
  var _a;
284
- const formFieldRe = /@FormItem\(([^\)]+)\)/gi;
285
- const matches = formFieldRe.exec(documentation);
286
284
  let fieldType = 'String';
287
285
  let args = [];
288
- if (matches) {
289
- [fieldType, ...args] = matches[1].split(',').map((arg) => arg.trim());
286
+ let tooltip = undefined;
287
+ const lineMatch = /@FormItem\(([^\n]+)/i.exec(documentation);
288
+ if (lineMatch) {
289
+ let content = lineMatch[1].replace(/\)\s*$/, '');
290
+ const tooltipIdx = content.indexOf('tooltip=');
291
+ if (tooltipIdx !== -1) {
292
+ tooltip = content.slice(tooltipIdx + 'tooltip='.length).trim();
293
+ content = content.slice(0, tooltipIdx).replace(/,\s*$/, '');
294
+ }
295
+ [fieldType, ...args] = content.split(',').map((arg) => arg.trim());
290
296
  args = args.map(arg => arg.trim());
291
297
  }
292
- else {
298
+ if (!fieldType) {
293
299
  if ([
294
300
  'String',
295
301
  'Boolean',
@@ -315,6 +321,7 @@ function parseDocumentation(documentation, field) {
315
321
  sizeLimit: Number(args[2]) || 1024 * 1024 * 10,
316
322
  },
317
323
  },
324
+ ...(tooltip && { tooltip }),
318
325
  };
319
326
  }
320
327
  else if (fieldType === 'Text') {
@@ -323,6 +330,7 @@ function parseDocumentation(documentation, field) {
323
330
  type: fieldType,
324
331
  args: { rows: Number(args[0] || '5') },
325
332
  },
333
+ ...(tooltip && { tooltip }),
326
334
  };
327
335
  }
328
336
  else if (['CheckBox', 'Radio'].includes(fieldType)) {
@@ -331,6 +339,7 @@ function parseDocumentation(documentation, field) {
331
339
  type: fieldType,
332
340
  args: { options: (args[0] || '').split('|').map((arg) => arg.trim()) },
333
341
  },
342
+ ...(tooltip && { tooltip }),
334
343
  };
335
344
  }
336
345
  else if (fieldType === 'Select') {
@@ -342,6 +351,7 @@ function parseDocumentation(documentation, field) {
342
351
  mode: args[1],
343
352
  },
344
353
  },
354
+ ...(tooltip && { tooltip }),
345
355
  };
346
356
  }
347
357
  else {
@@ -350,6 +360,7 @@ function parseDocumentation(documentation, field) {
350
360
  type: fieldType,
351
361
  args: {},
352
362
  },
363
+ ...(tooltip && { tooltip }),
353
364
  };
354
365
  }
355
366
  }
@@ -73,11 +73,11 @@ const run = ({ output, dmmf, ...options }) => {
73
73
  }),
74
74
  };
75
75
  if (existingPageModels === null || existingPageModels === void 0 ? void 0 : existingPageModels.has(modelDirName)) {
76
- sdk_1.logger.info(`Skipping page generation for Model ${model.name} (already exists in pages/)`);
76
+ sdk_1.logger.info(`Skipping page generation for Model ${model.name} (already exists in routes/)`);
77
77
  return [configFile, modelFile];
78
78
  }
79
79
  const createPageFile = {
80
- fileName: node_path_1.default.join(output, 'pages', modelDirName, `create.tsx`),
80
+ fileName: node_path_1.default.join(output, 'routes', modelDirName, `create.tsx`),
81
81
  content: (0, generate_create_page_1.generateCreatePage)({
82
82
  model,
83
83
  templateHelpers,
@@ -86,7 +86,7 @@ const run = ({ output, dmmf, ...options }) => {
86
86
  }),
87
87
  };
88
88
  const editPageFile = {
89
- fileName: node_path_1.default.join(output, 'pages', modelDirName, `edit.tsx`),
89
+ fileName: node_path_1.default.join(output, 'routes', modelDirName, `edit.tsx`),
90
90
  content: (0, generate_edit_page_1.generateEditPage)({
91
91
  model,
92
92
  templateHelpers,
@@ -95,7 +95,7 @@ const run = ({ output, dmmf, ...options }) => {
95
95
  }),
96
96
  };
97
97
  const indexPageFile = {
98
- fileName: node_path_1.default.join(output, 'pages', modelDirName, `index.tsx`),
98
+ fileName: node_path_1.default.join(output, 'routes', modelDirName, `index.tsx`),
99
99
  content: (0, generate_index_page_1.generateIndexPage)({
100
100
  model,
101
101
  templateHelpers,
@@ -104,7 +104,7 @@ const run = ({ output, dmmf, ...options }) => {
104
104
  }),
105
105
  };
106
106
  const listPageFile = {
107
- fileName: node_path_1.default.join(output, 'pages', modelDirName, `list.tsx`),
107
+ fileName: node_path_1.default.join(output, 'routes', modelDirName, `list.tsx`),
108
108
  content: (0, generate_list_page_1.generateListPage)({
109
109
  model,
110
110
  templateHelpers,
@@ -113,7 +113,7 @@ const run = ({ output, dmmf, ...options }) => {
113
113
  }),
114
114
  };
115
115
  const showPageFile = {
116
- fileName: node_path_1.default.join(output, 'pages', modelDirName, `show.tsx`),
116
+ fileName: node_path_1.default.join(output, 'routes', modelDirName, `show.tsx`),
117
117
  content: (0, generate_show_page_1.generatePageShow)({
118
118
  model,
119
119
  templateHelpers,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gadmin2n/prisma-react-generator",
3
3
  "description": "Generates react props and components from Prisma Schema for Tea/Antd ui lib.",
4
- "version": "0.0.44",
4
+ "version": "0.0.46",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "kavenma",