adminforth 1.2.82 → 1.2.84
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/basePlugin.ts +4 -1
- package/dist/basePlugin.js +2 -0
- package/dist/index.js +14 -9
- package/index.ts +10 -1
- package/package.json +1 -1
- package/spa/src/App.vue +3 -3
- package/spa/src/components/ResourceForm.vue +1 -1
- package/types/AdminForthConfig.ts +8 -0
package/basePlugin.ts
CHANGED
|
@@ -15,6 +15,9 @@ export default class AdminForthPlugin implements IAdminForthPlugin {
|
|
|
15
15
|
pluginInstanceId: string;
|
|
16
16
|
customFolderPath: string;
|
|
17
17
|
pluginOptions: any;
|
|
18
|
+
resourceConfig: AdminForthResource;
|
|
19
|
+
|
|
20
|
+
activationOrder: number = 0;
|
|
18
21
|
|
|
19
22
|
constructor(pluginOptions: any, metaUrl: string) {
|
|
20
23
|
// set up plugin here
|
|
@@ -32,7 +35,7 @@ export default class AdminForthPlugin implements IAdminForthPlugin {
|
|
|
32
35
|
}
|
|
33
36
|
|
|
34
37
|
modifyResourceConfig(adminforth: IAdminForth, resourceConfig: AdminForthResource) {
|
|
35
|
-
|
|
38
|
+
this.resourceConfig = resourceConfig;
|
|
36
39
|
const uniqueness = this.instanceUniqueRepresentation(this.pluginOptions);
|
|
37
40
|
|
|
38
41
|
const seed = `af_pl_${this.constructor.name}_${resourceConfig.resourceId}_${uniqueness}`;
|
package/dist/basePlugin.js
CHANGED
|
@@ -6,6 +6,7 @@ import crypto from 'crypto';
|
|
|
6
6
|
export default class AdminForthPlugin {
|
|
7
7
|
constructor(pluginOptions, metaUrl) {
|
|
8
8
|
this.customFolderName = 'custom';
|
|
9
|
+
this.activationOrder = 0;
|
|
9
10
|
// set up plugin here
|
|
10
11
|
this.pluginDir = currentFileDir(metaUrl);
|
|
11
12
|
this.customFolderPath = path.join(this.pluginDir, this.customFolderName);
|
|
@@ -17,6 +18,7 @@ export default class AdminForthPlugin {
|
|
|
17
18
|
return 'non-uniquely-identified';
|
|
18
19
|
}
|
|
19
20
|
modifyResourceConfig(adminforth, resourceConfig) {
|
|
21
|
+
this.resourceConfig = resourceConfig;
|
|
20
22
|
const uniqueness = this.instanceUniqueRepresentation(this.pluginOptions);
|
|
21
23
|
const seed = `af_pl_${this.constructor.name}_${resourceConfig.resourceId}_${uniqueness}`;
|
|
22
24
|
this.pluginInstanceId = crypto.createHash('sha256').update(seed).digest('hex');
|
package/dist/index.js
CHANGED
|
@@ -51,19 +51,24 @@ class AdminForth {
|
|
|
51
51
|
}
|
|
52
52
|
activatePlugins() {
|
|
53
53
|
process.env.HEAVY_DEBUG && console.log('🔌🔌🔌 Activating plugins');
|
|
54
|
+
const allPluginInstances = [];
|
|
54
55
|
for (let resource of this.config.resources) {
|
|
55
56
|
for (let pluginInstance of resource.plugins || []) {
|
|
56
|
-
|
|
57
|
-
const plugin = this.activatedPlugins.find((p) => p.pluginInstanceId === pluginInstance.pluginInstanceId);
|
|
58
|
-
if (plugin) {
|
|
59
|
-
process.env.HEAVY_DEBUG && console.log(`Current plugin pluginInstance.pluginInstanceId ${pluginInstance.pluginInstanceId}`);
|
|
60
|
-
throw new Error(`Attempt to activate Plugin ${pluginInstance.constructor.name} second time for same resource, but plugin does not support it.
|
|
61
|
-
To support multiple plugin instance pre one resource, plugin should return unique string values for each installation from instanceUniqueRepresentation`);
|
|
62
|
-
}
|
|
63
|
-
this.activatedPlugins.push(pluginInstance);
|
|
57
|
+
allPluginInstances.push({ pi: pluginInstance, resource });
|
|
64
58
|
}
|
|
65
59
|
}
|
|
66
|
-
;
|
|
60
|
+
allPluginInstances.sort(({ pi: a }, { pi: b }) => a.activationOrder - b.activationOrder);
|
|
61
|
+
console.log('🔌🔌🔌 Activating plugins', allPluginInstances.map(({ pi }) => pi.activationOrder));
|
|
62
|
+
allPluginInstances.forEach(({ pi: pluginInstance, resource }) => {
|
|
63
|
+
pluginInstance.modifyResourceConfig(this, resource);
|
|
64
|
+
const plugin = this.activatedPlugins.find((p) => p.pluginInstanceId === pluginInstance.pluginInstanceId);
|
|
65
|
+
if (plugin) {
|
|
66
|
+
process.env.HEAVY_DEBUG && console.log(`Current plugin pluginInstance.pluginInstanceId ${pluginInstance.pluginInstanceId}`);
|
|
67
|
+
throw new Error(`Attempt to activate Plugin ${pluginInstance.constructor.name} second time for same resource, but plugin does not support it.
|
|
68
|
+
To support multiple plugin instance pre one resource, plugin should return unique string values for each installation from instanceUniqueRepresentation`);
|
|
69
|
+
}
|
|
70
|
+
this.activatedPlugins.push(pluginInstance);
|
|
71
|
+
});
|
|
67
72
|
}
|
|
68
73
|
discoverDatabases() {
|
|
69
74
|
return __awaiter(this, void 0, void 0, function* () {
|
package/index.ts
CHANGED
|
@@ -20,6 +20,7 @@ import AdminForthPlugin from './basePlugin.js';
|
|
|
20
20
|
import ConfigValidator from './modules/configValidator.js';
|
|
21
21
|
import AdminForthRestAPI from './modules/restApi.js';
|
|
22
22
|
import ClickhouseConnector from './dataConnectors/clickhouse.js';
|
|
23
|
+
import { pid } from 'process';
|
|
23
24
|
|
|
24
25
|
// exports
|
|
25
26
|
export * from './types/AdminForthConfig.js';
|
|
@@ -79,8 +80,16 @@ class AdminForth implements IAdminForth {
|
|
|
79
80
|
|
|
80
81
|
activatePlugins() {
|
|
81
82
|
process.env.HEAVY_DEBUG && console.log('🔌🔌🔌 Activating plugins');
|
|
83
|
+
const allPluginInstances = [];
|
|
82
84
|
for (let resource of this.config.resources) {
|
|
83
85
|
for (let pluginInstance of resource.plugins || []) {
|
|
86
|
+
allPluginInstances.push({pi: pluginInstance, resource});
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
allPluginInstances.sort(({pi: a}, {pi: b}) => a.activationOrder - b.activationOrder);
|
|
90
|
+
console.log('🔌🔌🔌 Activating plugins', allPluginInstances.map(({pi}) => pi.activationOrder));
|
|
91
|
+
allPluginInstances.forEach(
|
|
92
|
+
({pi: pluginInstance, resource}) => {
|
|
84
93
|
pluginInstance.modifyResourceConfig(this, resource);
|
|
85
94
|
const plugin = this.activatedPlugins.find((p) => p.pluginInstanceId === pluginInstance.pluginInstanceId);
|
|
86
95
|
if (plugin) {
|
|
@@ -91,7 +100,7 @@ class AdminForth implements IAdminForth {
|
|
|
91
100
|
}
|
|
92
101
|
this.activatedPlugins.push(pluginInstance);
|
|
93
102
|
}
|
|
94
|
-
|
|
103
|
+
);
|
|
95
104
|
}
|
|
96
105
|
|
|
97
106
|
async discoverDatabases() {
|
package/package.json
CHANGED
package/spa/src/App.vue
CHANGED
|
@@ -108,11 +108,10 @@
|
|
|
108
108
|
|
|
109
109
|
|
|
110
110
|
<div id="dropdown-cta" class="p-4 mt-6 rounded-lg bg-lightAnnouncementBG dark:bg-darkAnnouncementBG
|
|
111
|
-
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent text-sm
|
|
112
|
-
" role="alert"
|
|
111
|
+
fill-lightAnnouncementText dark:fill-darkAccent text-lightAnnouncementText dark:text-darkAccent text-sm" role="alert"
|
|
113
112
|
v-if="ctaBadge"
|
|
114
113
|
>
|
|
115
|
-
<div class="flex items-center mb-3">
|
|
114
|
+
<div class="flex items-center mb-3" :class="!ctaBadge.title ? 'float-right' : ''">
|
|
116
115
|
<!-- <span class="bg-lightPrimaryOpacity dark:bg-darkPrimaryOpacity text-sm font-semibold me-2 px-2.5 py-0.5 rounded "
|
|
117
116
|
v-if="ctaBadge.title"
|
|
118
117
|
> -->
|
|
@@ -121,6 +120,7 @@
|
|
|
121
120
|
</span>
|
|
122
121
|
<button type="button"
|
|
123
122
|
class="ms-auto -mx-1.5 -my-1.5 bg-lightPrimaryOpacity dark:bg-darkPrimaryOpacity inline-flex justify-center items-center w-6 h-6 rounded-lg p-1 hover:brightness-110"
|
|
123
|
+
|
|
124
124
|
data-dismiss-target="#dropdown-cta" aria-label="Close"
|
|
125
125
|
v-if="ctaBadge?.closable" @click="closeCTA"
|
|
126
126
|
>
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="rounded-default">
|
|
3
3
|
<div
|
|
4
|
-
class="relative
|
|
4
|
+
class="relative shadow-resourseFormShadow dark:shadow-darkResourseFormShadow sm:rounded-lg dark:shadow-2xl rounded-default"
|
|
5
5
|
>
|
|
6
6
|
<form autocomplete="off" @submit.prevent>
|
|
7
7
|
<table class="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400 ">
|
|
@@ -277,6 +277,14 @@ export interface IAdminForthPlugin {
|
|
|
277
277
|
pluginInstanceId: string;
|
|
278
278
|
customFolderPath: string;
|
|
279
279
|
pluginOptions: any;
|
|
280
|
+
resourceConfig: AdminForthResource;
|
|
281
|
+
|
|
282
|
+
/**
|
|
283
|
+
* Before activating all plugins are sorted by this number and then activated in order.
|
|
284
|
+
* If you want to make sure that your plugin is activated after some other plugin, set this number to higher value. (default is 0)
|
|
285
|
+
*/
|
|
286
|
+
activationOrder: number;
|
|
287
|
+
|
|
280
288
|
|
|
281
289
|
/**
|
|
282
290
|
* AdminForth plugins concept is based on modification of full AdminForth configuration
|