nextjs-cms 0.9.23 → 0.9.26

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.
Files changed (33) hide show
  1. package/dist/api/actions/pages.d.ts +3 -3
  2. package/dist/api/trpc/root.d.ts +3 -3
  3. package/dist/api/trpc/root.d.ts.map +1 -1
  4. package/dist/api/trpc/routers/config.d.ts.map +1 -1
  5. package/dist/api/trpc/routers/navigation.d.ts +3 -3
  6. package/dist/api/trpc/server.d.ts +9 -9
  7. package/dist/api/trpc/server.d.ts.map +1 -1
  8. package/dist/core/config/config-loader.d.ts +32 -24
  9. package/dist/core/config/config-loader.d.ts.map +1 -1
  10. package/dist/core/config/config-loader.js +32 -1
  11. package/dist/core/config/index.d.ts +1 -1
  12. package/dist/core/config/index.d.ts.map +1 -1
  13. package/dist/core/config/loader-with-jiti.d.ts.map +1 -1
  14. package/dist/core/config/loader-with-jiti.js +13 -12
  15. package/dist/core/factories/section-factory-with-jiti.d.ts.map +1 -1
  16. package/dist/core/factories/section-factory-with-jiti.js +2 -1
  17. package/dist/core/fields/select.d.ts +1 -1
  18. package/dist/core/sections/category.d.ts +42 -42
  19. package/dist/core/sections/hasItems.d.ts +42 -42
  20. package/dist/core/sections/section.d.ts +22 -22
  21. package/dist/core/sections/simple.d.ts +8 -8
  22. package/dist/plugins/define.d.ts +5 -3
  23. package/dist/plugins/define.d.ts.map +1 -1
  24. package/dist/plugins/index.d.ts +1 -1
  25. package/dist/plugins/index.d.ts.map +1 -1
  26. package/dist/plugins/loader.d.ts +4 -56
  27. package/dist/plugins/loader.d.ts.map +1 -1
  28. package/dist/plugins/loader.js +4 -7
  29. package/dist/plugins/types.d.ts +78 -8
  30. package/dist/plugins/types.d.ts.map +1 -1
  31. package/dist/translations/client.d.ts +4 -4
  32. package/dist/translations/server.d.ts +4 -4
  33. package/package.json +4 -12
@@ -1,4 +1,6 @@
1
- import type { CMSPluginMultiRoute, CMSPluginSingleRoute } from './loader.js';
2
- export declare function definePlugin(plugin: CMSPluginSingleRoute): CMSPluginSingleRoute;
3
- export declare function definePlugin(plugin: CMSPluginMultiRoute): CMSPluginMultiRoute;
1
+ import type { CMSPluginDescriptorMultiRoute, CMSPluginDescriptorSingleRoute, CMSPluginMultiRoute, CMSPluginSingleRoute } from './types.js';
2
+ export declare function definePlugin<const TDescriptor extends CMSPluginDescriptorSingleRoute>(plugin: TDescriptor): TDescriptor;
3
+ export declare function definePlugin<const TDescriptor extends CMSPluginDescriptorMultiRoute>(plugin: TDescriptor): TDescriptor;
4
+ export declare function definePlugin<const TPlugin extends CMSPluginSingleRoute>(plugin: TPlugin): TPlugin;
5
+ export declare function definePlugin<const TPlugin extends CMSPluginMultiRoute>(plugin: TPlugin): TPlugin;
4
6
  //# sourceMappingURL=define.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/plugins/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAa,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAA;AAEvF,wBAAgB,YAAY,CAAC,MAAM,EAAE,oBAAoB,GAAG,oBAAoB,CAAA;AAChF,wBAAgB,YAAY,CAAC,MAAM,EAAE,mBAAmB,GAAG,mBAAmB,CAAA"}
1
+ {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../../src/plugins/define.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGR,6BAA6B,EAC7B,8BAA8B,EAC9B,mBAAmB,EACnB,oBAAoB,EACvB,MAAM,YAAY,CAAA;AAEnB,wBAAgB,YAAY,CAAC,KAAK,CAAC,WAAW,SAAS,8BAA8B,EAAE,MAAM,EAAE,WAAW,GAAG,WAAW,CAAA;AACxH,wBAAgB,YAAY,CAAC,KAAK,CAAC,WAAW,SAAS,6BAA6B,EAAE,MAAM,EAAE,WAAW,GAAG,WAAW,CAAA;AACvH,wBAAgB,YAAY,CAAC,KAAK,CAAC,OAAO,SAAS,oBAAoB,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAA;AAClG,wBAAgB,YAAY,CAAC,KAAK,CAAC,OAAO,SAAS,mBAAmB,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAAA"}
@@ -1,3 +1,3 @@
1
- export type { CMSPlugin, CMSPluginMultiRoute, CMSPluginSingleRoute, LoadedPlugin, LoadedPluginRoute, PluginInitContext, PluginModule, PluginRoute, PluginRouteWithoutComponent, PluginRouteWithComponent, } from './loader.js';
1
+ export type { CMSPlugin, CMSPluginDescriptor, CMSPluginDescriptorMultiRoute, CMSPluginDescriptorSingleRoute, CMSPluginMultiRoute, CMSPluginSingleRoute, LoadedPlugin, LoadedPluginRoute, PluginInitContext, PluginModule, PluginRoute, PluginRouteOverride, PluginRouteWithoutComponent, PluginRouteWithComponent, PluginRuntimeConfigEntry, } from './loader.js';
2
2
  export type { MultilingualString } from '../translations/language-utils.js';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,SAAS,EACT,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,2BAA2B,EAC3B,wBAAwB,GAC3B,MAAM,aAAa,CAAA;AAGpB,YAAY,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/plugins/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACR,SAAS,EACT,mBAAmB,EACnB,6BAA6B,EAC7B,8BAA8B,EAC9B,mBAAmB,EACnB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,iBAAiB,EACjB,YAAY,EACZ,WAAW,EACX,mBAAmB,EACnB,2BAA2B,EAC3B,wBAAwB,EACxB,wBAAwB,GAC3B,MAAM,aAAa,CAAA;AAGpB,YAAY,EAAE,kBAAkB,EAAE,MAAM,mCAAmC,CAAA"}
@@ -1,27 +1,8 @@
1
1
  import type { PluginConfigEntry } from '../core/config/config-loader.js';
2
2
  import type { MultilingualString } from '../translations/language-utils.js';
3
3
  import type { IconName } from 'lucide-react/dynamic';
4
- export interface CMSPlugin {
5
- /**
6
- * The human facing title of the plugin.
7
- * Can be a plain string or a localized object with language codes as keys.
8
- * @example 'Some Plugin Title'
9
- * @example { en: 'Some Plugin Title', ar: 'عنوان الإضافة' }
10
- */
11
- title: MultilingualString;
12
- /**
13
- * Optional sidebar icon for the plugin group (multi-route, when `groupRoutes !== false`).
14
- * Single-route plugins use the route's own `icon` instead.
15
- */
16
- icon?: IconName;
17
- version?: string;
18
- router?: any;
19
- routes?: PluginRoute[];
20
- init?: (ctx: PluginInitContext) => Promise<void> | void;
21
- }
22
- export interface PluginInitContext {
23
- config: PluginConfigEntry;
24
- }
4
+ import type { CMSPlugin, PluginRoute } from './types.js';
5
+ export type { CMSPlugin, CMSPluginDescriptor, CMSPluginDescriptorMultiRoute, CMSPluginDescriptorSingleRoute, CMSPluginMultiRoute, CMSPluginSingleRoute, PluginInitContext, PluginRoute, PluginRouteOverride, PluginRouteWithoutComponent, PluginRouteWithComponent, PluginRuntimeConfigEntry, } from './types.js';
25
6
  /**
26
7
  * A plugin instance after loading. The canonical "name" is derived from the
27
8
  * plugin's npm package name (see {@link derivePluginName}), not authored.
@@ -36,46 +17,14 @@ export interface LoadedPlugin {
36
17
  routerKey: string;
37
18
  }
38
19
  export interface PluginModule {
39
- createPlugin?: (options?: Record<string, unknown>) => CMSPlugin;
20
+ createPlugin?: (options?: Record<string, unknown>) => CMSPlugin | Promise<CMSPlugin>;
40
21
  plugin?: CMSPlugin;
41
- default?: CMSPlugin | (() => CMSPlugin);
42
- }
43
- export interface PluginRoute {
44
- path: string;
45
- /**
46
- * The title of the route.
47
- * Can be a plain string or a localized object with language codes as keys.
48
- */
49
- title: MultilingualString;
50
- icon?: IconName | undefined;
51
- component?: string;
52
- /**
53
- * Dot-paths into the host's tRPC router (e.g. `'cpanelEmails.getEmails'`) that the
54
- * host should prefetch on the server before rendering the plugin's component. The
55
- * results are placed into the React Query cache and hydrated into the client tree
56
- * via the host-rendered `<HydrateClient>` boundary.
57
- */
58
- prefetch?: string | string[];
22
+ default?: CMSPlugin | (() => CMSPlugin | Promise<CMSPlugin>);
59
23
  }
60
- export type PluginRouteWithoutComponent = Omit<PluginRoute, 'component'> & {
61
- component?: never;
62
- };
63
- export type PluginRouteWithComponent = PluginRoute & {
64
- component: string;
65
- };
66
24
  export interface LoadedPluginRoute extends PluginRoute {
67
25
  pluginId: string;
68
26
  pluginName: string;
69
27
  }
70
- type CMSPluginBase = Omit<CMSPlugin, 'routes'>;
71
- export type CMSPluginSingleRoute = CMSPluginBase & {
72
- routes?: [] | [PluginRouteWithoutComponent];
73
- };
74
- export type CMSPluginMultiRoute = CMSPluginBase & {
75
- routes: [PluginRouteWithComponent, PluginRouteWithComponent, ...PluginRouteWithComponent[]];
76
- };
77
- export declare function definePlugin(plugin: CMSPluginSingleRoute): CMSPluginSingleRoute;
78
- export declare function definePlugin(plugin: CMSPluginMultiRoute): CMSPluginMultiRoute;
79
28
  export declare const loadPluginModule: (pluginPackage: string) => Promise<unknown>;
80
29
  export declare function loadPlugins(): Promise<LoadedPlugin[]>;
81
30
  export declare function getPluginRoutes(): Promise<LoadedPluginRoute[]>;
@@ -124,5 +73,4 @@ export declare function getDashboardOverride(): Promise<LoadedPluginRoute | null
124
73
  * @returns true if this plugin is configured as the dashboard override
125
74
  */
126
75
  export declare function isDashboardOverridePlugin(pluginName: string): Promise<boolean>;
127
- export {};
128
76
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/plugins/loader.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iCAAiC,CAAA;AAExE,OAAO,KAAK,EAAE,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AAA;IACb,KAAK,EAAE,kBAAkB,CAAA;IACzB,IAAI,CAAC,EAAE,QAAQ,CAAA;IACf,UAAU,EAAE,MAAM,CAAA;IAClB,QAAQ,EAAE;QAAE,KAAK,EAAE,kBAAkB,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,QAAQ,CAAA;KAAE,EAAE,CAAA;CAC3E,CAAA;AAED,MAAM,MAAM,aAAa,GAAG,aAAa,GAAG,cAAc,CAAA;AAE1D;;;;;;;GAOG;AACH,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAkCpE;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAI9E;AAED;;;;GAIG;AACH,wBAAsB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAGpF"}
@@ -7,9 +7,6 @@ import path from 'path';
7
7
  import { getCMSConfig, getConfigImportVersion } from '../core/config/index.js';
8
8
  import { derivePluginName, derivePluginRouterKey } from './derive.js';
9
9
  import { logWarn, logError, logInfo } from '../utils/console-log.js';
10
- export function definePlugin(plugin) {
11
- return plugin;
12
- }
13
10
  let cachedPlugins = null;
14
11
  let cachedConfigVersion = -1;
15
12
  let loadPromise = null;
@@ -60,12 +57,12 @@ export const loadPluginModule = async (pluginPackage) => {
60
57
  const mod = jitiInstance(resolved);
61
58
  return mod?.default ?? mod;
62
59
  };
63
- function resolvePluginInstance(registration, mod) {
64
- const candidate = mod.createPlugin
60
+ async function resolvePluginInstance(registration, mod) {
61
+ const candidate = await (mod.createPlugin
65
62
  ? mod.createPlugin(registration.options)
66
63
  : typeof mod.default === 'function'
67
64
  ? mod.default()
68
- : (mod.default ?? mod.plugin);
65
+ : (mod.default ?? mod.plugin));
69
66
  if (!candidate) {
70
67
  logWarn('plugins', `Plugin "${registration.package}" did not return a plugin instance.`);
71
68
  return null;
@@ -152,7 +149,7 @@ export async function loadPlugins() {
152
149
  const mod = await loadPluginModule(registration.package);
153
150
  if (!mod)
154
151
  continue;
155
- const plugin = resolvePluginInstance(registration, mod);
152
+ const plugin = await resolvePluginInstance(registration, mod);
156
153
  if (!plugin)
157
154
  continue;
158
155
  if (seenNames.has(plugin.name)) {
@@ -1,9 +1,79 @@
1
- /**
2
- * Props passed to a plugin's server component by the host app.
3
- *
4
- * Currently empty — the host owns prefetching (declared via `PluginRoute.prefetch`)
5
- * and wraps the plugin's tree in `<HydrateClient>`. Plugins receive no tRPC `api`
6
- * proxy, which keeps the proxy off the RSC→Client serialization path.
7
- */
8
- export type PluginServerComponentProps = Record<string, never>;
1
+ import type { IconName } from 'lucide-react/dynamic';
2
+ import type { MultilingualString } from '../translations/language-utils.js';
3
+ export interface PluginRouteOverride {
4
+ title?: MultilingualString;
5
+ icon?: IconName;
6
+ }
7
+ export interface PluginRuntimeConfigEntry {
8
+ package: string;
9
+ options?: Record<string, unknown>;
10
+ override?: {
11
+ title?: MultilingualString;
12
+ icon?: IconName;
13
+ routes?: Record<string, PluginRouteOverride>;
14
+ };
15
+ groupRoutes?: boolean;
16
+ }
17
+ export interface PluginInitContext {
18
+ config: PluginRuntimeConfigEntry;
19
+ }
20
+ export interface PluginRoute {
21
+ path: string;
22
+ /**
23
+ * The title of the route.
24
+ * Can be a plain string or a localized object with language codes as keys.
25
+ */
26
+ title: MultilingualString;
27
+ icon?: IconName | undefined;
28
+ component?: string;
29
+ /**
30
+ * Dot-paths into the host's tRPC router (e.g. `'cpanelEmails.getEmails'`) that the
31
+ * host should prefetch on the server before rendering the plugin's component. The
32
+ * results are placed into the React Query cache and hydrated into the client tree
33
+ * via the host-rendered `<HydrateClient>` boundary.
34
+ */
35
+ prefetch?: string | string[];
36
+ }
37
+ export type PluginRouteWithoutComponent = Omit<PluginRoute, 'component'> & {
38
+ component?: never;
39
+ };
40
+ export type PluginRouteWithComponent = PluginRoute & {
41
+ component: string;
42
+ };
43
+ export interface CMSPlugin {
44
+ /**
45
+ * The human facing title of the plugin.
46
+ * Can be a plain string or a localized object with language codes as keys.
47
+ * @example 'Some Plugin Title'
48
+ * @example { en: 'Some Plugin Title', ar: 'عنوان الإضافة' }
49
+ */
50
+ title: MultilingualString;
51
+ /**
52
+ * Optional sidebar icon for the plugin group (multi-route, when `groupRoutes !== false`).
53
+ * Single-route plugins use the route's own `icon` instead.
54
+ */
55
+ icon?: IconName;
56
+ version?: string;
57
+ router?: unknown;
58
+ routes?: readonly PluginRoute[];
59
+ init?: (ctx: PluginInitContext) => Promise<void> | void;
60
+ }
61
+ type CMSPluginBase = Omit<CMSPlugin, 'routes'>;
62
+ export type CMSPluginSingleRoute = CMSPluginBase & {
63
+ routes?: readonly [] | readonly [PluginRouteWithoutComponent];
64
+ };
65
+ export type CMSPluginMultiRoute = CMSPluginBase & {
66
+ routes: readonly [PluginRouteWithComponent, PluginRouteWithComponent, ...PluginRouteWithComponent[]];
67
+ };
68
+ export type CMSPluginDescriptorBase = Omit<CMSPluginBase, 'router' | 'init'> & {
69
+ package: string;
70
+ };
71
+ export type CMSPluginDescriptorSingleRoute = CMSPluginDescriptorBase & {
72
+ routes?: readonly [] | readonly [PluginRouteWithoutComponent];
73
+ };
74
+ export type CMSPluginDescriptorMultiRoute = CMSPluginDescriptorBase & {
75
+ routes: readonly [PluginRouteWithComponent, PluginRouteWithComponent, ...PluginRouteWithComponent[]];
76
+ };
77
+ export type CMSPluginDescriptor = CMSPluginDescriptorSingleRoute | CMSPluginDescriptorMultiRoute;
78
+ export {};
9
79
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/plugins/types.ts"],"names":[],"m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