adminforth 1.2.23 → 1.2.25
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/dataConnectors/mongo.ts +3 -1
- package/dist/dataConnectors/mongo.js +3 -1
- package/dist/modules/codeInjector.js +1 -0
- package/dist/modules/configValidator.js +5 -0
- package/dist/spa/spa/src/components/ResourceForm.vue +1 -1
- package/modules/codeInjector.ts +1 -0
- package/modules/configValidator.ts +5 -0
- package/package.json +1 -1
- package/spa/src/components/ResourceForm.vue +1 -1
- package/types/AdminForthConfig.ts +6 -0
package/dataConnectors/mongo.ts
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
import { MongoClient } from 'mongodb';
|
|
3
3
|
import { AdminForthDataTypes, AdminForthFilterOperators, AdminForthSortDirections, IAdminForthDataSourceConnector } from '../types/AdminForthConfig.js';
|
|
4
|
+
import AdminForthBaseConnector from './baseConnector.js';
|
|
4
5
|
|
|
5
|
-
class MongoConnector implements IAdminForthDataSourceConnector {
|
|
6
|
+
class MongoConnector extends AdminForthBaseConnector implements IAdminForthDataSourceConnector {
|
|
6
7
|
db: MongoClient
|
|
7
8
|
|
|
8
9
|
constructor({ url }: { url: string }) {
|
|
10
|
+
super();
|
|
9
11
|
this.db = new MongoClient(url);
|
|
10
12
|
(async () => {
|
|
11
13
|
try {
|
|
@@ -10,8 +10,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import dayjs from 'dayjs';
|
|
11
11
|
import { MongoClient } from 'mongodb';
|
|
12
12
|
import { AdminForthDataTypes, AdminForthFilterOperators, AdminForthSortDirections } from '../types/AdminForthConfig.js';
|
|
13
|
-
|
|
13
|
+
import AdminForthBaseConnector from './baseConnector.js';
|
|
14
|
+
class MongoConnector extends AdminForthBaseConnector {
|
|
14
15
|
constructor({ url }) {
|
|
16
|
+
super();
|
|
15
17
|
this.OperatorsMap = {
|
|
16
18
|
[AdminForthFilterOperators.EQ]: (value) => value,
|
|
17
19
|
[AdminForthFilterOperators.NE]: (value) => ({ $ne: value }),
|
|
@@ -404,6 +404,7 @@ class CodeInjector {
|
|
|
404
404
|
const pluginPackages = [];
|
|
405
405
|
// for every installed plugin generate packages
|
|
406
406
|
for (const plugin of this.adminforth.activatedPlugins) {
|
|
407
|
+
console.log('🔧 Checking packages for plugin', plugin.customFolderPath);
|
|
407
408
|
const [lockHash, packages] = yield this.packagesFromNpm(plugin.customFolderPath);
|
|
408
409
|
if (packages.length) {
|
|
409
410
|
pluginPackages.push({
|
|
@@ -405,5 +405,10 @@ export default class ConfigValidator {
|
|
|
405
405
|
}
|
|
406
406
|
});
|
|
407
407
|
resource.dataSourceColumns = resource.columns.filter((col) => !col.virtual);
|
|
408
|
+
(resource.plugins || []).forEach((plugin) => {
|
|
409
|
+
if (plugin.validateConfigAfterDiscover) {
|
|
410
|
+
plugin.validateConfigAfterDiscover(this.adminforth, resource);
|
|
411
|
+
}
|
|
412
|
+
});
|
|
408
413
|
}
|
|
409
414
|
}
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
@input="setCurrentValue(column.name, $event.target.value)"
|
|
96
96
|
/>
|
|
97
97
|
<textarea
|
|
98
|
-
v-else-if="['text'].includes(column.type)"
|
|
98
|
+
v-else-if="['text', 'richtext'].includes(column.type)"
|
|
99
99
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
100
100
|
placeholder="Text"
|
|
101
101
|
:value="currentValues[column.name]"
|
package/modules/codeInjector.ts
CHANGED
|
@@ -462,6 +462,7 @@ class CodeInjector implements ICodeInjector {
|
|
|
462
462
|
|
|
463
463
|
// for every installed plugin generate packages
|
|
464
464
|
for (const plugin of this.adminforth.activatedPlugins) {
|
|
465
|
+
console.log('🔧 Checking packages for plugin', plugin.customFolderPath);
|
|
465
466
|
const [lockHash, packages] = await this.packagesFromNpm(plugin.customFolderPath);
|
|
466
467
|
if (packages.length) {
|
|
467
468
|
pluginPackages.push({
|
|
@@ -449,5 +449,10 @@ export default class ConfigValidator implements IConfigValidator {
|
|
|
449
449
|
}
|
|
450
450
|
})
|
|
451
451
|
resource.dataSourceColumns = resource.columns.filter((col) => !col.virtual);
|
|
452
|
+
(resource.plugins || []).forEach((plugin) => {
|
|
453
|
+
if (plugin.validateConfigAfterDiscover) {
|
|
454
|
+
plugin.validateConfigAfterDiscover(this.adminforth, resource);
|
|
455
|
+
}
|
|
456
|
+
});
|
|
452
457
|
}
|
|
453
458
|
}
|
package/package.json
CHANGED
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
@input="setCurrentValue(column.name, $event.target.value)"
|
|
96
96
|
/>
|
|
97
97
|
<textarea
|
|
98
|
-
v-else-if="['text'].includes(column.type)"
|
|
98
|
+
v-else-if="['text', 'richtext'].includes(column.type)"
|
|
99
99
|
class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500"
|
|
100
100
|
placeholder="Text"
|
|
101
101
|
:value="currentValues[column.name]"
|
|
@@ -285,6 +285,12 @@ export interface IAdminForthPlugin {
|
|
|
285
285
|
modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
|
|
286
286
|
componentPath(componentFile: string): string;
|
|
287
287
|
|
|
288
|
+
/**
|
|
289
|
+
* Optional method which will be called after AdminForth discovers all resources and their columns.
|
|
290
|
+
* Can be used to validate types of columns, check if some columns are missing, etc.
|
|
291
|
+
*/
|
|
292
|
+
validateConfigAfterDiscover?(adminforth: IAdminForth, resourceConfig: AdminForthResource): void;
|
|
293
|
+
|
|
288
294
|
/**
|
|
289
295
|
* Here you can register custom endpoints for your plugin.
|
|
290
296
|
*
|