@egdesk/next-api-plugin 1.2.0 → 1.2.2

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.
@@ -88,7 +88,8 @@ function generateApiWrapper(projectPath) {
88
88
  * Generated by @egdesk/next-api-plugin
89
89
  */
90
90
 
91
- const basePath = process.env.NEXT_PUBLIC_EGDESK_BASE_PATH || '';
91
+ const isDev = process.env.NODE_ENV === 'development';
92
+ const basePath = isDev ? '' : (process.env.NEXT_PUBLIC_EGDESK_BASE_PATH || '');
92
93
 
93
94
  /**
94
95
  * Fetch wrapper that handles basePath for tunneled environments
@@ -9,7 +9,8 @@ export interface UserDataTable {
9
9
  tableName: string;
10
10
  displayName: string;
11
11
  description?: string;
12
- rowCount: number;
12
+ /** May be unknown until the table is synced or counted */
13
+ rowCount?: number;
13
14
  columnCount: number;
14
15
  columns: string[];
15
16
  }
@@ -163,7 +163,7 @@ function updateEnvLocal(projectPath, config) {
163
163
  '',
164
164
  '# Available Tables',
165
165
  `# Total tables: ${config.tables.length}`,
166
- ...config.tables.map((table, index) => `# ${index + 1}. ${table.displayName} (${table.tableName}) - ${table.rowCount} rows, ${table.columnCount} columns`),
166
+ ...config.tables.map((table, index) => `# ${index + 1}. ${table.displayName} (${table.tableName}) - ${table.rowCount != null ? table.rowCount : '?'} rows, ${table.columnCount} columns`),
167
167
  ''
168
168
  ].join('\n');
169
169
  fs.writeFileSync(envPath, envContent.replace(/\r?\n/g, os.EOL), 'utf-8');
@@ -190,20 +190,26 @@ export interface TableDefinition {
190
190
  name: string;
191
191
  displayName: string;
192
192
  description?: string;
193
- rowCount: number;
193
+ /** Omitted or unknown until synced / counted */
194
+ rowCount?: number;
194
195
  columnCount: number;
195
196
  columns: string[];
196
197
  }
197
198
 
198
199
  export const TABLES = {
199
- ${config.tables.map((table, index) => ` table${index + 1}: {
200
- name: '${table.tableName}',
201
- displayName: '${table.displayName}',
202
- description: ${table.description ? `'${table.description}'` : 'undefined'},
203
- rowCount: ${table.rowCount},
204
- columnCount: ${table.columnCount},
205
- columns: [${table.columns.map(col => `'${col}'`).join(', ')}]
206
- } as TableDefinition`).join(',\n')}
200
+ ${config.tables.map((table, index) => {
201
+ const properties = [
202
+ `name: '${table.tableName}'`,
203
+ `displayName: '${table.displayName}'`,
204
+ table.description ? `description: '${table.description}'` : null,
205
+ table.rowCount != null ? `rowCount: ${table.rowCount}` : null,
206
+ `columnCount: ${table.columnCount}`,
207
+ `columns: [${table.columns.map(col => `'${col}'`).join(', ')}]`
208
+ ].filter(Boolean).join(',\n ');
209
+ return ` table${index + 1}: {
210
+ ${properties}
211
+ } as TableDefinition`;
212
+ }).join(',\n')}
207
213
  } as const;
208
214
 
209
215
  ${config.tables.length > 0 ? `
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@egdesk/next-api-plugin",
3
- "version": "1.2.0",
3
+ "version": "1.2.2",
4
4
  "description": "Next.js plugin for EGDesk database proxy integration",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -61,7 +61,8 @@ export function generateApiWrapper(projectPath: string): void {
61
61
  * Generated by @egdesk/next-api-plugin
62
62
  */
63
63
 
64
- const basePath = process.env.NEXT_PUBLIC_EGDESK_BASE_PATH || '';
64
+ const isDev = process.env.NODE_ENV === 'development';
65
+ const basePath = isDev ? '' : (process.env.NEXT_PUBLIC_EGDESK_BASE_PATH || '');
65
66
 
66
67
  /**
67
68
  * Fetch wrapper that handles basePath for tunneled environments
@@ -14,7 +14,8 @@ export interface UserDataTable {
14
14
  tableName: string;
15
15
  displayName: string;
16
16
  description?: string;
17
- rowCount: number;
17
+ /** May be unknown until the table is synced or counted */
18
+ rowCount?: number;
18
19
  columnCount: number;
19
20
  columns: string[];
20
21
  }
@@ -168,7 +169,7 @@ export function updateEnvLocal(
168
169
  '# Available Tables',
169
170
  `# Total tables: ${config.tables.length}`,
170
171
  ...config.tables.map((table, index) =>
171
- `# ${index + 1}. ${table.displayName} (${table.tableName}) - ${table.rowCount} rows, ${table.columnCount} columns`
172
+ `# ${index + 1}. ${table.displayName} (${table.tableName}) - ${table.rowCount != null ? table.rowCount : '?'} rows, ${table.columnCount} columns`
172
173
  ),
173
174
  ''
174
175
  ].join('\n');
@@ -202,20 +203,27 @@ export interface TableDefinition {
202
203
  name: string;
203
204
  displayName: string;
204
205
  description?: string;
205
- rowCount: number;
206
+ /** Omitted or unknown until synced / counted */
207
+ rowCount?: number;
206
208
  columnCount: number;
207
209
  columns: string[];
208
210
  }
209
211
 
210
212
  export const TABLES = {
211
- ${config.tables.map((table, index) => ` table${index + 1}: {
212
- name: '${table.tableName}',
213
- displayName: '${table.displayName}',
214
- description: ${table.description ? `'${table.description}'` : 'undefined'},
215
- rowCount: ${table.rowCount},
216
- columnCount: ${table.columnCount},
217
- columns: [${table.columns.map(col => `'${col}'`).join(', ')}]
218
- } as TableDefinition`).join(',\n')}
213
+ ${config.tables.map((table, index) => {
214
+ const properties = [
215
+ `name: '${table.tableName}'`,
216
+ `displayName: '${table.displayName}'`,
217
+ table.description ? `description: '${table.description}'` : null,
218
+ table.rowCount != null ? `rowCount: ${table.rowCount}` : null,
219
+ `columnCount: ${table.columnCount}`,
220
+ `columns: [${table.columns.map(col => `'${col}'`).join(', ')}]`
221
+ ].filter(Boolean).join(',\n ');
222
+
223
+ return ` table${index + 1}: {
224
+ ${properties}
225
+ } as TableDefinition`;
226
+ }).join(',\n')}
219
227
  } as const;
220
228
 
221
229
  ${config.tables.length > 0 ? `