nuxt-auto-crud 1.10.0 → 1.11.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.
package/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "nuxt-auto-crud",
3
3
  "configKey": "autoCrud",
4
- "version": "1.10.0",
4
+ "version": "1.11.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -4,7 +4,7 @@ declare const _default: import("h3").EventHandler<import("h3").EventHandlerReque
4
4
  name: string;
5
5
  type: string;
6
6
  required: any;
7
- selectOptions: undefined;
7
+ selectOptions: string[] | undefined;
8
8
  }[];
9
9
  }>>;
10
10
  export default _default;
@@ -4,7 +4,7 @@ export declare function drizzleTableToFields(table: any, resourceName: string):
4
4
  name: string;
5
5
  type: string;
6
6
  required: any;
7
- selectOptions: undefined;
7
+ selectOptions: string[] | undefined;
8
8
  }[];
9
9
  };
10
10
  export declare function getRelations(): Promise<Record<string, Record<string, string>>>;
@@ -15,6 +15,6 @@ export declare function getSchema(tableName: string): Promise<{
15
15
  name: string;
16
16
  type: string;
17
17
  required: any;
18
- selectOptions: undefined;
18
+ selectOptions: string[] | undefined;
19
19
  }[];
20
20
  } | undefined>;
@@ -8,8 +8,12 @@ export function drizzleTableToFields(table, resourceName) {
8
8
  const column = col;
9
9
  const isRequired = column.notNull;
10
10
  let type = "string";
11
- const selectOptions = void 0;
12
- if (column.dataType === "number" || column.columnType === "SQLiteInteger" || column.columnType === "SQLiteReal") {
11
+ let selectOptions = void 0;
12
+ const enumValues = column.enumValues || column.config?.enumValues;
13
+ if (enumValues) {
14
+ type = "enum";
15
+ selectOptions = enumValues;
16
+ } else if (column.dataType === "number" || column.columnType === "SQLiteInteger" || column.columnType === "SQLiteReal") {
13
17
  type = "number";
14
18
  if (column.name.endsWith("_at") || column.name.endsWith("At")) {
15
19
  type = "date";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nuxt-auto-crud",
3
- "version": "1.10.0",
3
+ "version": "1.11.0",
4
4
  "description": "Exposes RESTful CRUD APIs for your Nuxt app based solely on your database migrations.",
5
5
  "author": "Cliford Pereira",
6
6
  "license": "MIT",
@@ -12,10 +12,17 @@ export function drizzleTableToFields(table: any, resourceName: string) {
12
12
  const column = col as any
13
13
  const isRequired = column.notNull
14
14
  let type = 'string'
15
- const selectOptions: string[] | undefined = undefined
15
+ let selectOptions: string[] | undefined = undefined
16
16
 
17
+ // Check for enum values (Drizzle stores them in enumValues or config.enumValues)
18
+ const enumValues = column.enumValues || column.config?.enumValues
19
+
20
+ if (enumValues) {
21
+ type = 'enum'
22
+ selectOptions = enumValues
23
+ }
17
24
  // Map Drizzle types to frontend types
18
- if (column.dataType === 'number' || column.columnType === 'SQLiteInteger' || column.columnType === 'SQLiteReal') {
25
+ else if (column.dataType === 'number' || column.columnType === 'SQLiteInteger' || column.columnType === 'SQLiteReal') {
19
26
  type = 'number'
20
27
  // Check if it is a timestamp
21
28
  if (column.name.endsWith('_at') || column.name.endsWith('At')) {