@veap/plugins 0.1.0 → 0.1.1

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 CHANGED
@@ -1,5 +1,6 @@
1
- [![CI](https://github.com/veapjs/veap-plugins/actions/workflows/ci.yml/badge.svg)](https://github.com/veapjs/veap-plugins/actions/workflows/ci.yml)
2
- [![Release](https://github.com/veapjs/veap-plugins/actions/workflows/release.yml/badge.svg)](https://github.com/veapjs/veap-plugins/actions/workflows/release.yml)
1
+ [![CI](https://github.com/veapjs/veap-plugins/actions/workflows/CI.yml/badge.svg)](https://github.com/veapjs/veap-plugins/actions/workflows/CI.yml)
2
+ [![Release](https://github.com/veapjs/veap-plugins/actions/workflows/RELEASE.yml/badge.svg)](https://github.com/veapjs/veap-plugins/actions/workflows/RELEASE.yml)
3
+ [![Version](https://img.shields.io/npm/v/@veap/plugins?style=flat&colorA=000000&colorB=000000)](https://www.npmjs.com/package/@veap/plugins)
3
4
 
4
5
  # @veap/plugins
5
6
 
@@ -1,3 +1,4 @@
1
- export * from "./context";
2
- export * from "./events";
3
- export * from "./types";
1
+ export * from "./context.js";
2
+ export * from "./events.js";
3
+ export * from "./tokens.js";
4
+ export * from "./types.js";
@@ -1,3 +1,4 @@
1
- export * from "./context";
2
- export * from "./events";
3
- export * from "./types";
1
+ export * from "./context.js";
2
+ export * from "./events.js";
3
+ export * from "./tokens.js";
4
+ export * from "./types.js";
@@ -0,0 +1,14 @@
1
+ import type { Token } from "@veap/kernel";
2
+ import type { RouterService } from "../router/router.service.js";
3
+ /**
4
+ * IoC Token for the application plugins array.
5
+ */
6
+ export declare const APP_PLUGINS: Token<any[]>;
7
+ /**
8
+ * IoC Token for the virtual RouterService.
9
+ */
10
+ export declare const ROUTER_SERVICE: Token<RouterService>;
11
+ /**
12
+ * IoC Token for the main site layout component.
13
+ */
14
+ export declare const SITE_LAYOUT: Token<any>;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * IoC Token for the application plugins array.
3
+ */
4
+ export const APP_PLUGINS = Symbol.for("veap:kernel:app-plugins");
5
+ /**
6
+ * IoC Token for the virtual RouterService.
7
+ */
8
+ export const ROUTER_SERVICE = Symbol.for("veap:router:service");
9
+ /**
10
+ * IoC Token for the main site layout component.
11
+ */
12
+ export const SITE_LAYOUT = Symbol.for("veap:router:site-layout");
@@ -1,6 +1,15 @@
1
1
  import type { UserPermission, UserRole } from "@veap/auth";
2
2
  import type { SystemEvent } from "@veap/kernel";
3
3
  export type { SystemEvent };
4
+ declare module "@veap/kernel" {
5
+ interface VeapConfig {
6
+ /**
7
+ * Prefix for all administrative routes.
8
+ * Default: "/app"
9
+ */
10
+ privatePath?: string;
11
+ }
12
+ }
4
13
  import type * as React from "react";
5
14
  import { z } from "zod";
6
15
  export type SidebarGroupType = {
@@ -49,8 +58,7 @@ export interface PluginManifest {
49
58
  [key: string]: any;
50
59
  }
51
60
  /**
52
- * Shape of the `veap` field in a plugin `package.json`.
53
- * This replaces the standalone `manifest.json` file.
61
+ * Shape of the `veap` field in a plugin `package.json`.\n * This replaces the standalone `manifest.json` file.
54
62
  */
55
63
  export interface VeapPackageMetadata {
56
64
  type?: string;
@@ -77,8 +85,7 @@ export interface VeapPackageJson {
77
85
  [key: string]: any;
78
86
  }
79
87
  /**
80
- * Helper to build a `PluginManifest` from a `package.json` import.
81
- * Eliminates the need for a standalone `manifest.json` file.
88
+ * Helper to build a `PluginManifest` from a `package.json` import.\n * Eliminates the need for a standalone `manifest.json` file.
82
89
  *
83
90
  * @example
84
91
  * ```ts
@@ -12,8 +12,7 @@ export const PluginManifestSchema = z.object({
12
12
  author: z.string().optional(),
13
13
  });
14
14
  /**
15
- * Helper to build a `PluginManifest` from a `package.json` import.
16
- * Eliminates the need for a standalone `manifest.json` file.
15
+ * Helper to build a `PluginManifest` from a `package.json` import.\n * Eliminates the need for a standalone `manifest.json` file.
17
16
  *
18
17
  * @example
19
18
  * ```ts
@@ -0,0 +1,15 @@
1
+ import { ServiceProvider } from "@veap/kernel";
2
+ declare module "@veap/kernel" {
3
+ interface ApplicationBuilder {
4
+ /**
5
+ * Registers plugins with the application IoC container and configures PluginsServiceProvider.
6
+ */
7
+ withPlugins(plugins: any[]): this;
8
+ }
9
+ }
10
+ declare class PluginsConfigProvider extends ServiceProvider {
11
+ private plugins;
12
+ constructor(container: any, plugins?: any[]);
13
+ register(): void;
14
+ }
15
+ export { PluginsConfigProvider };
@@ -0,0 +1,20 @@
1
+ import { ApplicationBuilder, ServiceProvider } from "@veap/kernel";
2
+ import { APP_PLUGINS } from "./common/tokens.js";
3
+ import { PluginsServiceProvider } from "./providers/plugins.provider.js";
4
+ class PluginsConfigProvider extends ServiceProvider {
5
+ plugins;
6
+ constructor(container, plugins = []) {
7
+ super(container);
8
+ this.plugins = plugins;
9
+ }
10
+ register() {
11
+ this.container.register({ token: APP_PLUGINS, useValue: this.plugins });
12
+ this.container.register({ token: "AppPlugins", useValue: this.plugins });
13
+ }
14
+ }
15
+ if (!ApplicationBuilder.prototype.withPlugins) {
16
+ ApplicationBuilder.prototype.withPlugins = function (plugins) {
17
+ return this.use((c) => new PluginsConfigProvider(c, plugins)).use(PluginsServiceProvider);
18
+ };
19
+ }
20
+ export { PluginsConfigProvider };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export * from "./common";
2
- export * from "./migrations";
3
- export * from "./navigation";
4
- export * from "./providers";
5
- export * from "./registry";
1
+ export * from "./common/index.js";
2
+ export * from "./composition.js";
3
+ export * from "./migrations/index.js";
4
+ export * from "./navigation/index.js";
5
+ export * from "./providers/index.js";
6
+ export * from "./registry/index.js";
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
- export * from "./common";
2
- export * from "./migrations";
3
- export * from "./navigation";
4
- export * from "./providers";
5
- export * from "./registry";
1
+ export * from "./common/index.js";
2
+ export * from "./composition.js";
3
+ export * from "./migrations/index.js";
4
+ export * from "./navigation/index.js";
5
+ export * from "./providers/index.js";
6
+ export * from "./registry/index.js";
@@ -1,15 +1,16 @@
1
1
  import { isDatabaseInitialized } from "@veap/database";
2
2
  import { IntlService } from "@veap/intl/server";
3
- import { APP_PLUGINS, eventBus, ROUTER_SERVICE, ServiceProvider, SITE_LAYOUT, } from "@veap/kernel";
4
- import { bindPluginsContext } from "../common/context";
5
- import { runPluginMigrations } from "../migrations";
6
- import { NavigationService } from "../navigation/navigation.service";
7
- import { MIGRATION_RUNNER, PLUGIN_REPOSITORY } from "../registry/contracts";
8
- import { ensurePluginsInitialized, registerPlugins } from "../registry/facade";
9
- import { KnexMigrationRunner } from "../registry/migration-runner";
10
- import { ActiveRecordPluginRepository } from "../registry/plugin.repository";
11
- import { PluginRegistry } from "../registry/registry.service";
12
- import { RouterService } from "../router/router.service";
3
+ import { eventBus, ServiceProvider } from "@veap/kernel";
4
+ import { bindPluginsContext } from "../common/context.js";
5
+ import { APP_PLUGINS, ROUTER_SERVICE, SITE_LAYOUT } from "../common/tokens.js";
6
+ import { runPluginMigrations } from "../migrations/index.js";
7
+ import { NavigationService } from "../navigation/navigation.service.js";
8
+ import { MIGRATION_RUNNER, PLUGIN_REPOSITORY } from "../registry/contracts.js";
9
+ import { ensurePluginsInitialized, registerPlugins, } from "../registry/facade.js";
10
+ import { KnexMigrationRunner } from "../registry/migration-runner.js";
11
+ import { ActiveRecordPluginRepository } from "../registry/plugin.repository.js";
12
+ import { PluginRegistry } from "../registry/registry.service.js";
13
+ import { RouterService } from "../router/router.service.js";
13
14
  export class PluginsServiceProvider extends ServiceProvider {
14
15
  config;
15
16
  constructor(container, config) {
@@ -1,6 +1,6 @@
1
1
  import { type IEventBus, type ILogger } from "@veap/kernel";
2
- import { type IMigrationRunner, type IPluginRepository } from "./contracts";
3
2
  import type { IPlugin } from "../common";
3
+ import { type IMigrationRunner, type IPluginRepository } from "./contracts";
4
4
  export declare class PluginRegistry {
5
5
  private readonly repository;
6
6
  private readonly migrationRunner;
@@ -2,12 +2,13 @@
2
2
  * @module router
3
3
  * @description Virtual Router API for Veap Plugin system.
4
4
  */
5
- export { addRouteRewrite, buildRouteTree, getModulesWithHomepage, getPluginsWithHomepage, getRouteRewrites, matchRoute, } from "./discovery";
6
- export { handleVeapApiRequest } from "./handler";
7
- export { matchRoute as matchVirtualRoute } from "./matcher";
8
- export { ApiEnsuredAuth, ApiSameOrigin, EnsuredAuth, EnsuredGuest, EnsuredUser, runApiPipeline, runPipeline, SameOrigin, SkipSecurity, } from "./middlewares";
9
- export { RouterErrorBoundary, SoftNavigationInterceptor, VeapRouter, type WithRouterConfig, withRouter, } from "./react";
10
- export { extractParamName, isCatchAllSegment, isDynamicSegment, isGroupSegment, isOptionalCatchAllSegment, isParallelSlot, type LayoutChainEntry, type MatchResult, type RouteNode, RouteTree, resolveMagicPrefix, segmentMatchesUrlPart, } from "./route-tree";
11
- export { RouterService } from "./router.service";
12
- export { discoverRoutes, generateRouteManifest, globToTree, } from "./scanner";
13
- export { collectApiMiddlewares, collectAuthRequirements, collectMiddlewares, } from "./utils";
5
+ export { ROUTER_SERVICE, SITE_LAYOUT } from "../common/tokens.js";
6
+ export { addRouteRewrite, buildRouteTree, getModulesWithHomepage, getPluginsWithHomepage, getRouteRewrites, matchRoute, } from "./discovery.js";
7
+ export { handleVeapApiRequest } from "./handler.js";
8
+ export { matchRoute as matchVirtualRoute } from "./matcher.js";
9
+ export { ApiEnsuredAuth, ApiSameOrigin, EnsuredAuth, EnsuredGuest, EnsuredUser, runApiPipeline, runPipeline, SameOrigin, SkipSecurity, } from "./middlewares.js";
10
+ export { RouterErrorBoundary, SoftNavigationInterceptor, VeapRouter, type WithRouterConfig, withRouter, } from "./react/index.js";
11
+ export { extractParamName, isCatchAllSegment, isDynamicSegment, isGroupSegment, isOptionalCatchAllSegment, isParallelSlot, type LayoutChainEntry, type MatchResult, type RouteNode, RouteTree, resolveMagicPrefix, segmentMatchesUrlPart, } from "./route-tree.js";
12
+ export { RouterService } from "./router.service.js";
13
+ export { discoverRoutes, generateRouteManifest, globToTree, } from "./scanner.js";
14
+ export { collectApiMiddlewares, collectAuthRequirements, collectMiddlewares, } from "./utils.js";
@@ -2,12 +2,13 @@
2
2
  * @module router
3
3
  * @description Virtual Router API for Veap Plugin system.
4
4
  */
5
- export { addRouteRewrite, buildRouteTree, getModulesWithHomepage, getPluginsWithHomepage, getRouteRewrites, matchRoute, } from "./discovery";
6
- export { handleVeapApiRequest } from "./handler";
7
- export { matchRoute as matchVirtualRoute } from "./matcher";
8
- export { ApiEnsuredAuth, ApiSameOrigin, EnsuredAuth, EnsuredGuest, EnsuredUser, runApiPipeline, runPipeline, SameOrigin, SkipSecurity, } from "./middlewares";
9
- export { RouterErrorBoundary, SoftNavigationInterceptor, VeapRouter, withRouter, } from "./react";
10
- export { extractParamName, isCatchAllSegment, isDynamicSegment, isGroupSegment, isOptionalCatchAllSegment, isParallelSlot, RouteTree, resolveMagicPrefix, segmentMatchesUrlPart, } from "./route-tree";
11
- export { RouterService } from "./router.service";
12
- export { discoverRoutes, generateRouteManifest, globToTree, } from "./scanner";
13
- export { collectApiMiddlewares, collectAuthRequirements, collectMiddlewares, } from "./utils";
5
+ export { ROUTER_SERVICE, SITE_LAYOUT } from "../common/tokens.js";
6
+ export { addRouteRewrite, buildRouteTree, getModulesWithHomepage, getPluginsWithHomepage, getRouteRewrites, matchRoute, } from "./discovery.js";
7
+ export { handleVeapApiRequest } from "./handler.js";
8
+ export { matchRoute as matchVirtualRoute } from "./matcher.js";
9
+ export { ApiEnsuredAuth, ApiSameOrigin, EnsuredAuth, EnsuredGuest, EnsuredUser, runApiPipeline, runPipeline, SameOrigin, SkipSecurity, } from "./middlewares.js";
10
+ export { RouterErrorBoundary, SoftNavigationInterceptor, VeapRouter, withRouter, } from "./react/index.js";
11
+ export { extractParamName, isCatchAllSegment, isDynamicSegment, isGroupSegment, isOptionalCatchAllSegment, isParallelSlot, RouteTree, resolveMagicPrefix, segmentMatchesUrlPart, } from "./route-tree.js";
12
+ export { RouterService } from "./router.service.js";
13
+ export { discoverRoutes, generateRouteManifest, globToTree, } from "./scanner.js";
14
+ export { collectApiMiddlewares, collectAuthRequirements, collectMiddlewares, } from "./utils.js";
@@ -186,7 +186,10 @@ function matchRecursive(node, remainingSegments, currentParams, currentChain, cu
186
186
  !isOptionalCatchAllSegment(child.segment) &&
187
187
  child.segment === currentSegment) {
188
188
  const nextChain = hasLayoutChainContent(child)
189
- ? [...currentChain, buildChainEntry(child, [...currentMatched, currentSegment])]
189
+ ? [
190
+ ...currentChain,
191
+ buildChainEntry(child, [...currentMatched, currentSegment]),
192
+ ]
190
193
  : currentChain;
191
194
  const result = matchRecursive(child, rest, currentParams, nextChain, [...currentMatched, currentSegment], bestPartialMatch);
192
195
  if (result)
@@ -205,7 +208,10 @@ function matchRecursive(node, remainingSegments, currentParams, currentChain, cu
205
208
  if (isDynamicSegment(child.segment)) {
206
209
  const paramName = extractParamName(child.segment);
207
210
  const nextChain = hasLayoutChainContent(child)
208
- ? [...currentChain, buildChainEntry(child, [...currentMatched, currentSegment])]
211
+ ? [
212
+ ...currentChain,
213
+ buildChainEntry(child, [...currentMatched, currentSegment]),
214
+ ]
209
215
  : currentChain;
210
216
  const result = matchRecursive(child, rest, { ...currentParams, [paramName]: currentSegment }, nextChain, [...currentMatched, currentSegment], bestPartialMatch);
211
217
  if (result)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@veap/plugins",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
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.0",
60
- "@veap/database": "0.1.0",
61
- "@veap/intl": "0.1.0",
62
- "@veap/kernel": "0.1.0",
59
+ "@veap/auth": "0.1.1",
60
+ "@veap/database": "0.1.1",
61
+ "@veap/intl": "0.1.1",
62
+ "@veap/kernel": "0.1.1",
63
63
  "chalk": "^5.3.0",
64
64
  "ora": "^8.1.1",
65
65
  "zod": "^4.6.5"