adminforth 1.1.8 → 1.1.10

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/index.js CHANGED
@@ -67,11 +67,14 @@ class AdminForth {
67
67
  if (!component) {
68
68
  return component;
69
69
  }
70
- let obj = component;
71
- if (typeof obj === 'string') {
70
+ let obj;
71
+ if (typeof component === 'string') {
72
72
  obj = { file: component, meta: {} };
73
73
  }
74
- errors.push(...this.checkCustomFileExists(this.config.auth.loginBackgroundImage));
74
+ else {
75
+ obj = component;
76
+ }
77
+ errors.push(...this.checkCustomFileExists(obj.file));
75
78
  return obj;
76
79
  }
77
80
  validateConfig() {
@@ -310,20 +313,14 @@ class AdminForth {
310
313
  for (const resource of this.config.resources) {
311
314
  for (const column of resource.columns) {
312
315
  if (column.components) {
313
- Object.entries(column.components).forEach(([key, comp]) => {
314
- column.components[key] = this.validateComponent(comp, errors);
315
- });
316
316
  console.log('🔧🔧🔧 Validating components for resource', column.components);
317
- for (const [key, { file }] of Object.entries(column.components)) {
318
- if (this.codeInjector.allComponentNames[file]) {
317
+ for (const comp of Object.values(column.components)) {
318
+ if (this.codeInjector.allComponentNames[comp.file]) {
319
319
  // not obvious, but if we are in this if, it means that this is plugin component
320
320
  // and there is no sense to check if it exists in users folder
321
321
  continue;
322
322
  }
323
- const path = file.replace('@@', this.config.customization.customComponentsDir);
324
- if (!fs.existsSync(path)) {
325
- throw new Error(`Component file ${path} does not exist`);
326
- }
323
+ this.validateComponent(comp, errors);
327
324
  }
328
325
  }
329
326
  }
package/index.ts CHANGED
@@ -9,7 +9,7 @@ import ExpressServer from './servers/express.js';
9
9
  import {v1 as uuid} from 'uuid';
10
10
  import fs from 'fs';
11
11
  import { ADMINFORTH_VERSION } from './modules/utils.js';
12
- import { AdminForthConfig, AdminForthClass, AdminForthComponentDeclaration,
12
+ import { AdminForthConfig, AdminForthClass, AdminForthComponentDeclaration, AdminForthComponentDeclarationFull,
13
13
  AdminForthFilterOperators, AdminForthDataTypes, AdminForthResourcePages } from './types/AdminForthConfig.js';
14
14
  import { getFunctionList } from './modules/utils.js';
15
15
  import path from 'path';
@@ -87,11 +87,13 @@ class AdminForth implements AdminForthClass {
87
87
  if (!component) {
88
88
  return component;
89
89
  }
90
- let obj: AdminForthComponentDeclaration = component;
91
- if (typeof obj === 'string') {
92
- obj = { file: component, meta: {} } as AdminForthComponentDeclaration;
90
+ let obj: AdminForthComponentDeclarationFull;
91
+ if (typeof component === 'string') {
92
+ obj = { file: component, meta: {} };
93
+ } else {
94
+ obj = component;
93
95
  }
94
- errors.push(...this.checkCustomFileExists(this.config.auth.loginBackgroundImage));
96
+ errors.push(...this.checkCustomFileExists(obj.file));
95
97
 
96
98
  return obj;
97
99
  }
@@ -369,21 +371,15 @@ class AdminForth implements AdminForthClass {
369
371
  for (const resource of this.config.resources) {
370
372
  for (const column of resource.columns) {
371
373
  if (column.components) {
372
- Object.entries(column.components).forEach(([key, comp]) => {
373
- column.components[key] = this.validateComponent(comp, errors);
374
- });
375
374
  console.log('🔧🔧🔧 Validating components for resource', column.components);
376
375
 
377
- for (const [key, { file }] of Object.entries(column.components as {any})) {
378
- if (this.codeInjector.allComponentNames[file]) {
379
- // not obvious, but if we are in this if, it means that this is plugin component
380
- // and there is no sense to check if it exists in users folder
381
- continue;
382
- }
383
- const path = file.replace('@@', this.config.customization.customComponentsDir);
384
- if (!fs.existsSync(path)) {
385
- throw new Error(`Component file ${path} does not exist`);
376
+ for (const comp of Object.values(column.components) as Array<AdminForthComponentDeclarationFull>) {
377
+ if (this.codeInjector.allComponentNames[comp.file]) {
378
+ // not obvious, but if we are in this if, it means that this is plugin component
379
+ // and there is no sense to check if it exists in users folder
380
+ continue;
386
381
  }
382
+ this.validateComponent(comp, errors);
387
383
  }
388
384
  }
389
385
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adminforth",
3
- "version": "1.1.8",
3
+ "version": "1.1.10",
4
4
  "description": "OpenSource Vue3 powered forth-generation admin panel",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -802,7 +802,7 @@ export type ValidationObject = {
802
802
  message: string,
803
803
  }
804
804
 
805
- export type AdminForthComponentDeclaration = {
805
+ export type AdminForthComponentDeclarationFull = {
806
806
  /**
807
807
  * Path to custom component which will be used to render field in the admin panel.
808
808
  * e.g. `@@/MyCustomComponent.vue`
@@ -858,7 +858,9 @@ export type AdminForthComponentDeclaration = {
858
858
  *
859
859
  */
860
860
  meta?: any,
861
- } | string;
861
+ }
862
+
863
+ export type AdminForthComponentDeclaration = AdminForthComponentDeclarationFull | string;
862
864
 
863
865
  export type AdminForthFieldComponents = {
864
866
  /**