@veap/plugins 0.1.5 → 0.1.7
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/README.md +30 -25
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@ without modifying core application code.
|
|
|
26
26
|
via the integrated router service.
|
|
27
27
|
- **Database persistence**: Storing plugin activation states and user widget
|
|
28
28
|
layouts in database tables managed by `@veap/database`.
|
|
29
|
-
- **IoC integration**: `
|
|
29
|
+
- **IoC integration**: `PluginsServiceProvider` boots and registers plugin
|
|
30
30
|
capabilities cleanly into the application container.
|
|
31
31
|
|
|
32
32
|
## Installation
|
|
@@ -46,21 +46,25 @@ npm install @veap/plugins @veap/kernel @veap/database @veap/auth
|
|
|
46
46
|
|
|
47
47
|
### Define a Custom Plugin
|
|
48
48
|
|
|
49
|
-
Create a plugin definition implementing the
|
|
49
|
+
Create a plugin definition implementing the `IPlugin` contract:
|
|
50
50
|
|
|
51
51
|
```tsx
|
|
52
|
-
import type {
|
|
53
|
-
|
|
54
|
-
export const AnalyticsPlugin:
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
import type { IPlugin } from "@veap/plugins";
|
|
53
|
+
|
|
54
|
+
export const AnalyticsPlugin: IPlugin = {
|
|
55
|
+
manifest: {
|
|
56
|
+
id: "com.example.analytics",
|
|
57
|
+
name: "Analytics Tracker",
|
|
58
|
+
version: "1.0.0",
|
|
59
|
+
description: "Injects telemetry script and admin dashboard widgets",
|
|
60
|
+
enabled: true,
|
|
61
|
+
},
|
|
59
62
|
|
|
60
63
|
widgets: [
|
|
61
64
|
{
|
|
62
65
|
id: "analytics-overview",
|
|
63
|
-
|
|
66
|
+
name: "Visitor Traffic",
|
|
67
|
+
area: "admin:dashboard",
|
|
64
68
|
component: () => (
|
|
65
69
|
<div className="p-4 border rounded">
|
|
66
70
|
<p className="text-sm font-semibold">Active Visitors: 42</p>
|
|
@@ -69,24 +73,23 @@ export const AnalyticsPlugin: PluginDefinition = {
|
|
|
69
73
|
},
|
|
70
74
|
],
|
|
71
75
|
|
|
72
|
-
async
|
|
73
|
-
console.log("Analytics plugin
|
|
76
|
+
async init() {
|
|
77
|
+
console.log("Analytics plugin initialized!");
|
|
74
78
|
},
|
|
75
79
|
};
|
|
76
80
|
```
|
|
77
81
|
|
|
78
82
|
### Register Plugins in Application Builder
|
|
79
83
|
|
|
80
|
-
Pass plugins to `Application.configure()`:
|
|
84
|
+
Pass plugins to `Application.configure()` via `PluginsServiceProvider`:
|
|
81
85
|
|
|
82
86
|
```ts
|
|
83
87
|
import { Application } from "@veap/kernel";
|
|
84
|
-
import {
|
|
88
|
+
import { PluginsServiceProvider } from "@veap/plugins";
|
|
85
89
|
import { AnalyticsPlugin } from "./plugins/analytics";
|
|
86
90
|
|
|
87
91
|
export const app = Application.configure()
|
|
88
|
-
.use(
|
|
89
|
-
.withPlugins([AnalyticsPlugin])
|
|
92
|
+
.use((c) => new PluginsServiceProvider(c, { plugins: [AnalyticsPlugin] }))
|
|
90
93
|
.create();
|
|
91
94
|
```
|
|
92
95
|
|
|
@@ -97,14 +100,14 @@ Use extension components from `@veap/plugins/client`:
|
|
|
97
100
|
```tsx
|
|
98
101
|
"use client";
|
|
99
102
|
|
|
100
|
-
import {
|
|
103
|
+
import { ExtensionPointClient } from "@veap/plugins/client";
|
|
101
104
|
|
|
102
105
|
export function DashboardHeader() {
|
|
103
106
|
return (
|
|
104
107
|
<header className="flex justify-between items-center p-4">
|
|
105
108
|
<h1>Admin Dashboard</h1>
|
|
106
109
|
{/* External plugins can inject actions here */}
|
|
107
|
-
<
|
|
110
|
+
<ExtensionPointClient target="dashboard:header" point="actions" />
|
|
108
111
|
</header>
|
|
109
112
|
);
|
|
110
113
|
}
|
|
@@ -112,13 +115,15 @@ export function DashboardHeader() {
|
|
|
112
115
|
|
|
113
116
|
## Subpath Exports
|
|
114
117
|
|
|
115
|
-
| Export Path | Content
|
|
116
|
-
| -------------------------- |
|
|
117
|
-
| `@veap/plugins` | Core plugin definitions, lifecycle
|
|
118
|
-
| `@veap/plugins/
|
|
119
|
-
| `@veap/plugins/
|
|
120
|
-
| `@veap/plugins/
|
|
121
|
-
| `@veap/plugins/
|
|
118
|
+
| Export Path | Content |
|
|
119
|
+
| -------------------------- | ---------------------------------------------------------------------------- |
|
|
120
|
+
| `@veap/plugins` | Core plugin definitions (`IPlugin`), lifecycle, and `PluginsServiceProvider` |
|
|
121
|
+
| `@veap/plugins/server` | Server-side `ExtensionPoint`, `WidgetArea`, and plugin registry utilities |
|
|
122
|
+
| `@veap/plugins/client` | Client components (`ExtensionPointClient`, `WidgetAreaClient`) |
|
|
123
|
+
| `@veap/plugins/actions` | Next.js Server Actions for plugin and widget management |
|
|
124
|
+
| `@veap/plugins/router` | Virtual router infrastructure (`PluginRouter`) |
|
|
125
|
+
| `@veap/plugins/models` | Active Record models (`SystemPlugin`, `SystemUserWidget`) |
|
|
126
|
+
| `@veap/plugins/migrations` | Knex migrations for plugin persistence |
|
|
122
127
|
|
|
123
128
|
## Documentation
|
|
124
129
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@veap/plugins",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Plugin lifecycle, extension points, and virtual router for Veap",
|
|
5
5
|
"bugs": "https://github.com/veapjs/veap-plugins/issues",
|
|
6
6
|
"repository": {
|
|
@@ -56,10 +56,10 @@
|
|
|
56
56
|
"@dnd-kit/core": "^6.3.1",
|
|
57
57
|
"@dnd-kit/sortable": "^10.0.0",
|
|
58
58
|
"@dnd-kit/utilities": "^3.2.2",
|
|
59
|
-
"@veap/auth": "0.1.
|
|
60
|
-
"@veap/database": "0.1.
|
|
61
|
-
"@veap/intl": "0.1.
|
|
62
|
-
"@veap/kernel": "0.
|
|
59
|
+
"@veap/auth": "0.1.7",
|
|
60
|
+
"@veap/database": "0.1.7",
|
|
61
|
+
"@veap/intl": "0.1.7",
|
|
62
|
+
"@veap/kernel": "0.2.0",
|
|
63
63
|
"chalk": "^5.3.0",
|
|
64
64
|
"ora": "^8.1.1",
|
|
65
65
|
"zod": "^4.6.5"
|