@btst/stack 1.7.0 → 1.9.0
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/dist/api/index.d.cts +2 -2
- package/dist/api/index.d.mts +2 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/client/index.cjs +6 -2
- package/dist/client/index.d.cts +2 -1
- package/dist/client/index.d.mts +2 -1
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.mjs +6 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/packages/better-stack/src/plugins/cms/api/plugin.cjs +445 -16
- package/dist/packages/better-stack/src/plugins/cms/api/plugin.mjs +445 -16
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.cjs +24 -7
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.mjs +25 -8
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/relation-field.cjs +224 -0
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/relation-field.mjs +222 -0
- package/dist/packages/better-stack/src/plugins/cms/client/components/inverse-relations-panel.cjs +243 -0
- package/dist/packages/better-stack/src/plugins/cms/client/components/inverse-relations-panel.mjs +241 -0
- package/dist/packages/better-stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +56 -2
- package/dist/packages/better-stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +56 -2
- package/dist/packages/better-stack/src/plugins/cms/client/hooks/cms-hooks.cjs +190 -0
- package/dist/packages/better-stack/src/plugins/cms/client/hooks/cms-hooks.mjs +187 -1
- package/dist/packages/better-stack/src/plugins/cms/db.cjs +38 -0
- package/dist/packages/better-stack/src/plugins/cms/db.mjs +38 -0
- package/dist/packages/better-stack/src/plugins/route-docs/client/components/loading/docs-skeleton.cjs +43 -0
- package/dist/packages/better-stack/src/plugins/route-docs/client/components/loading/docs-skeleton.mjs +41 -0
- package/dist/packages/better-stack/src/plugins/route-docs/client/components/pages/docs-page.cjs +794 -0
- package/dist/packages/better-stack/src/plugins/route-docs/client/components/pages/docs-page.mjs +788 -0
- package/dist/packages/better-stack/src/plugins/route-docs/client/plugin.cjs +111 -0
- package/dist/packages/better-stack/src/plugins/route-docs/client/plugin.mjs +106 -0
- package/dist/packages/better-stack/src/plugins/route-docs/generator.cjs +244 -0
- package/dist/packages/better-stack/src/plugins/route-docs/generator.mjs +227 -0
- package/dist/packages/ui/src/components/auto-form/fields/object.cjs +81 -1
- package/dist/packages/ui/src/components/auto-form/fields/object.mjs +81 -1
- package/dist/packages/ui/src/components/dialog.cjs +6 -0
- package/dist/packages/ui/src/components/dialog.mjs +6 -1
- package/dist/packages/ui/src/components/sheet.cjs +25 -0
- package/dist/packages/ui/src/components/sheet.mjs +24 -1
- package/dist/plugins/api/index.d.cts +2 -2
- package/dist/plugins/api/index.d.mts +2 -2
- package/dist/plugins/api/index.d.ts +2 -2
- package/dist/plugins/blog/api/index.d.cts +1 -1
- package/dist/plugins/blog/api/index.d.mts +1 -1
- package/dist/plugins/blog/api/index.d.ts +1 -1
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +1 -1
- package/dist/plugins/blog/client/index.d.mts +1 -1
- package/dist/plugins/blog/client/index.d.ts +1 -1
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/dist/plugins/client/index.d.cts +2 -2
- package/dist/plugins/client/index.d.mts +2 -2
- package/dist/plugins/client/index.d.ts +2 -2
- package/dist/plugins/cms/api/index.d.cts +67 -3
- package/dist/plugins/cms/api/index.d.mts +67 -3
- package/dist/plugins/cms/api/index.d.ts +67 -3
- package/dist/plugins/cms/client/hooks/index.cjs +4 -0
- package/dist/plugins/cms/client/hooks/index.d.cts +82 -3
- package/dist/plugins/cms/client/hooks/index.d.mts +82 -3
- package/dist/plugins/cms/client/hooks/index.d.ts +82 -3
- package/dist/plugins/cms/client/hooks/index.mjs +1 -1
- package/dist/plugins/cms/query-keys.d.cts +1 -1
- package/dist/plugins/cms/query-keys.d.mts +1 -1
- package/dist/plugins/cms/query-keys.d.ts +1 -1
- package/dist/plugins/form-builder/api/index.d.cts +1 -1
- package/dist/plugins/form-builder/api/index.d.mts +1 -1
- package/dist/plugins/form-builder/api/index.d.ts +1 -1
- package/dist/plugins/open-api/api/index.d.cts +1 -1
- package/dist/plugins/open-api/api/index.d.mts +1 -1
- package/dist/plugins/open-api/api/index.d.ts +1 -1
- package/dist/plugins/route-docs/client/index.cjs +10 -0
- package/dist/plugins/route-docs/client/index.d.cts +126 -0
- package/dist/plugins/route-docs/client/index.d.mts +126 -0
- package/dist/plugins/route-docs/client/index.d.ts +126 -0
- package/dist/plugins/route-docs/client/index.mjs +1 -0
- package/dist/plugins/route-docs/client.css +3 -0
- package/dist/plugins/route-docs/style.css +19 -0
- package/dist/shared/{stack.L-UFwz2G.d.mts → stack.oGOteE6g.d.cts} +27 -5
- package/dist/shared/{stack.L-UFwz2G.d.ts → stack.oGOteE6g.d.mts} +27 -5
- package/dist/shared/{stack.L-UFwz2G.d.cts → stack.oGOteE6g.d.ts} +27 -5
- package/dist/shared/{stack.CSce37mX.d.cts → stack.u9iYV6vt.d.cts} +14 -2
- package/dist/shared/{stack.CSce37mX.d.mts → stack.u9iYV6vt.d.mts} +14 -2
- package/dist/shared/{stack.CSce37mX.d.ts → stack.u9iYV6vt.d.ts} +14 -2
- package/package.json +15 -1
- package/src/client/index.ts +11 -4
- package/src/plugins/cms/api/plugin.ts +667 -21
- package/src/plugins/cms/client/components/forms/content-form.tsx +60 -18
- package/src/plugins/cms/client/components/forms/relation-field.tsx +299 -0
- package/src/plugins/cms/client/components/inverse-relations-panel.tsx +329 -0
- package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +127 -1
- package/src/plugins/cms/client/hooks/cms-hooks.tsx +344 -0
- package/src/plugins/cms/db.ts +38 -0
- package/src/plugins/cms/types.ts +99 -10
- package/src/plugins/route-docs/client/components/loading/docs-skeleton.tsx +82 -0
- package/src/plugins/route-docs/client/components/loading/index.tsx +1 -0
- package/src/plugins/route-docs/client/components/pages/docs-page.tsx +1240 -0
- package/src/plugins/route-docs/client/index.ts +7 -0
- package/src/plugins/route-docs/client/plugin.tsx +187 -0
- package/src/plugins/route-docs/client.css +3 -0
- package/src/plugins/route-docs/generator.ts +385 -0
- package/src/plugins/route-docs/index.ts +12 -0
- package/src/plugins/route-docs/style.css +19 -0
- package/src/types.ts +19 -1
- package/dist/shared/{stack.CcI4sYJP.d.mts → stack.DLhzx1-D.d.cts} +1 -1
- package/dist/shared/{stack.CcI4sYJP.d.ts → stack.DLhzx1-D.d.mts} +1 -1
- package/dist/shared/{stack.CcI4sYJP.d.cts → stack.DLhzx1-D.d.ts} +1 -1
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import * as _btst_yar from '@btst/yar';
|
|
4
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
+
import { S as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.u9iYV6vt.cjs';
|
|
6
|
+
import '@btst/db';
|
|
7
|
+
import 'better-call';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a documented route parameter
|
|
11
|
+
*/
|
|
12
|
+
interface RouteParameter {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
schema?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sitemap entry with plugin source
|
|
21
|
+
*/
|
|
22
|
+
interface PluginSitemapEntry extends SitemapEntry {
|
|
23
|
+
pluginKey: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents a documented route
|
|
27
|
+
*/
|
|
28
|
+
interface DocumentedRoute {
|
|
29
|
+
/** Route key from the plugin */
|
|
30
|
+
key: string;
|
|
31
|
+
/** The route path pattern (e.g., "/users/:id") */
|
|
32
|
+
path: string;
|
|
33
|
+
/** Path parameters extracted from the path */
|
|
34
|
+
pathParams: RouteParameter[];
|
|
35
|
+
/** Query parameters from the route's query schema */
|
|
36
|
+
queryParams: RouteParameter[];
|
|
37
|
+
/** Route metadata */
|
|
38
|
+
meta?: {
|
|
39
|
+
title?: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
tags?: string[];
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Represents a plugin's documented routes
|
|
47
|
+
*/
|
|
48
|
+
interface DocumentedPlugin {
|
|
49
|
+
/** Plugin key */
|
|
50
|
+
key: string;
|
|
51
|
+
/** Plugin name */
|
|
52
|
+
name: string;
|
|
53
|
+
/** Routes from this plugin */
|
|
54
|
+
routes: DocumentedRoute[];
|
|
55
|
+
/** Sitemap entries from this plugin */
|
|
56
|
+
sitemapEntries: PluginSitemapEntry[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The complete route documentation schema
|
|
60
|
+
*/
|
|
61
|
+
interface RouteDocsSchema {
|
|
62
|
+
/** All documented plugins */
|
|
63
|
+
plugins: DocumentedPlugin[];
|
|
64
|
+
/** Generation timestamp */
|
|
65
|
+
generatedAt: string;
|
|
66
|
+
/** All sitemap entries aggregated */
|
|
67
|
+
allSitemapEntries: PluginSitemapEntry[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Query key for route docs schema
|
|
72
|
+
*/
|
|
73
|
+
declare const ROUTE_DOCS_QUERY_KEY: readonly ["route-docs", "schema"];
|
|
74
|
+
/**
|
|
75
|
+
* Get the stored client stack context
|
|
76
|
+
* Used by the docs page component to generate schema on client-side navigation
|
|
77
|
+
*/
|
|
78
|
+
declare function getStoredContext(): ClientStackContext | null;
|
|
79
|
+
/**
|
|
80
|
+
* Generate the route docs schema from the stored context
|
|
81
|
+
* This can be called from both server and client
|
|
82
|
+
*/
|
|
83
|
+
declare function generateSchema(): Promise<RouteDocsSchema>;
|
|
84
|
+
/**
|
|
85
|
+
* Configuration for Route Docs client plugin
|
|
86
|
+
*/
|
|
87
|
+
interface RouteDocsClientConfig {
|
|
88
|
+
/** React Query client for SSR prefetching */
|
|
89
|
+
queryClient: QueryClient;
|
|
90
|
+
/** Title for the documentation page */
|
|
91
|
+
title?: string;
|
|
92
|
+
/** Description for the documentation page */
|
|
93
|
+
description?: string;
|
|
94
|
+
/** Site base path for constructing URLs (e.g., "/pages") */
|
|
95
|
+
siteBasePath: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Route Docs client plugin
|
|
99
|
+
* Provides a route that displays documentation for all client routes
|
|
100
|
+
*/
|
|
101
|
+
declare const routeDocsClientPlugin: (config: RouteDocsClientConfig) => _btst_stack_plugins_client.ClientPlugin<Record<string, never>, {
|
|
102
|
+
docs: {
|
|
103
|
+
(inputCtx_0?: _btst_yar.InputContext<"/route-docs", _btst_yar.RouteOptions> | undefined): {
|
|
104
|
+
PageComponent?: react.ComponentType<unknown> | undefined;
|
|
105
|
+
LoadingComponent?: react.ComponentType<unknown> | undefined;
|
|
106
|
+
ErrorComponent?: react.ComponentType<unknown> | undefined;
|
|
107
|
+
loader?: (() => Promise<void>) | undefined;
|
|
108
|
+
meta?: (() => ({
|
|
109
|
+
title: string;
|
|
110
|
+
name?: undefined;
|
|
111
|
+
content?: undefined;
|
|
112
|
+
} | {
|
|
113
|
+
name: string;
|
|
114
|
+
content: string;
|
|
115
|
+
title?: undefined;
|
|
116
|
+
})[]) | undefined;
|
|
117
|
+
extra?: (() => any) | undefined;
|
|
118
|
+
};
|
|
119
|
+
options: _btst_yar.RouteOptions | undefined;
|
|
120
|
+
path: "/route-docs";
|
|
121
|
+
meta: _btst_yar.RouteMeta | undefined;
|
|
122
|
+
};
|
|
123
|
+
}>;
|
|
124
|
+
|
|
125
|
+
export { ROUTE_DOCS_QUERY_KEY, generateSchema, getStoredContext, routeDocsClientPlugin };
|
|
126
|
+
export type { RouteDocsClientConfig };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import * as _btst_yar from '@btst/yar';
|
|
4
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
+
import { S as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.u9iYV6vt.mjs';
|
|
6
|
+
import '@btst/db';
|
|
7
|
+
import 'better-call';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a documented route parameter
|
|
11
|
+
*/
|
|
12
|
+
interface RouteParameter {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
schema?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sitemap entry with plugin source
|
|
21
|
+
*/
|
|
22
|
+
interface PluginSitemapEntry extends SitemapEntry {
|
|
23
|
+
pluginKey: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents a documented route
|
|
27
|
+
*/
|
|
28
|
+
interface DocumentedRoute {
|
|
29
|
+
/** Route key from the plugin */
|
|
30
|
+
key: string;
|
|
31
|
+
/** The route path pattern (e.g., "/users/:id") */
|
|
32
|
+
path: string;
|
|
33
|
+
/** Path parameters extracted from the path */
|
|
34
|
+
pathParams: RouteParameter[];
|
|
35
|
+
/** Query parameters from the route's query schema */
|
|
36
|
+
queryParams: RouteParameter[];
|
|
37
|
+
/** Route metadata */
|
|
38
|
+
meta?: {
|
|
39
|
+
title?: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
tags?: string[];
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Represents a plugin's documented routes
|
|
47
|
+
*/
|
|
48
|
+
interface DocumentedPlugin {
|
|
49
|
+
/** Plugin key */
|
|
50
|
+
key: string;
|
|
51
|
+
/** Plugin name */
|
|
52
|
+
name: string;
|
|
53
|
+
/** Routes from this plugin */
|
|
54
|
+
routes: DocumentedRoute[];
|
|
55
|
+
/** Sitemap entries from this plugin */
|
|
56
|
+
sitemapEntries: PluginSitemapEntry[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The complete route documentation schema
|
|
60
|
+
*/
|
|
61
|
+
interface RouteDocsSchema {
|
|
62
|
+
/** All documented plugins */
|
|
63
|
+
plugins: DocumentedPlugin[];
|
|
64
|
+
/** Generation timestamp */
|
|
65
|
+
generatedAt: string;
|
|
66
|
+
/** All sitemap entries aggregated */
|
|
67
|
+
allSitemapEntries: PluginSitemapEntry[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Query key for route docs schema
|
|
72
|
+
*/
|
|
73
|
+
declare const ROUTE_DOCS_QUERY_KEY: readonly ["route-docs", "schema"];
|
|
74
|
+
/**
|
|
75
|
+
* Get the stored client stack context
|
|
76
|
+
* Used by the docs page component to generate schema on client-side navigation
|
|
77
|
+
*/
|
|
78
|
+
declare function getStoredContext(): ClientStackContext | null;
|
|
79
|
+
/**
|
|
80
|
+
* Generate the route docs schema from the stored context
|
|
81
|
+
* This can be called from both server and client
|
|
82
|
+
*/
|
|
83
|
+
declare function generateSchema(): Promise<RouteDocsSchema>;
|
|
84
|
+
/**
|
|
85
|
+
* Configuration for Route Docs client plugin
|
|
86
|
+
*/
|
|
87
|
+
interface RouteDocsClientConfig {
|
|
88
|
+
/** React Query client for SSR prefetching */
|
|
89
|
+
queryClient: QueryClient;
|
|
90
|
+
/** Title for the documentation page */
|
|
91
|
+
title?: string;
|
|
92
|
+
/** Description for the documentation page */
|
|
93
|
+
description?: string;
|
|
94
|
+
/** Site base path for constructing URLs (e.g., "/pages") */
|
|
95
|
+
siteBasePath: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Route Docs client plugin
|
|
99
|
+
* Provides a route that displays documentation for all client routes
|
|
100
|
+
*/
|
|
101
|
+
declare const routeDocsClientPlugin: (config: RouteDocsClientConfig) => _btst_stack_plugins_client.ClientPlugin<Record<string, never>, {
|
|
102
|
+
docs: {
|
|
103
|
+
(inputCtx_0?: _btst_yar.InputContext<"/route-docs", _btst_yar.RouteOptions> | undefined): {
|
|
104
|
+
PageComponent?: react.ComponentType<unknown> | undefined;
|
|
105
|
+
LoadingComponent?: react.ComponentType<unknown> | undefined;
|
|
106
|
+
ErrorComponent?: react.ComponentType<unknown> | undefined;
|
|
107
|
+
loader?: (() => Promise<void>) | undefined;
|
|
108
|
+
meta?: (() => ({
|
|
109
|
+
title: string;
|
|
110
|
+
name?: undefined;
|
|
111
|
+
content?: undefined;
|
|
112
|
+
} | {
|
|
113
|
+
name: string;
|
|
114
|
+
content: string;
|
|
115
|
+
title?: undefined;
|
|
116
|
+
})[]) | undefined;
|
|
117
|
+
extra?: (() => any) | undefined;
|
|
118
|
+
};
|
|
119
|
+
options: _btst_yar.RouteOptions | undefined;
|
|
120
|
+
path: "/route-docs";
|
|
121
|
+
meta: _btst_yar.RouteMeta | undefined;
|
|
122
|
+
};
|
|
123
|
+
}>;
|
|
124
|
+
|
|
125
|
+
export { ROUTE_DOCS_QUERY_KEY, generateSchema, getStoredContext, routeDocsClientPlugin };
|
|
126
|
+
export type { RouteDocsClientConfig };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
|
|
2
|
+
import * as react from 'react';
|
|
3
|
+
import * as _btst_yar from '@btst/yar';
|
|
4
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
5
|
+
import { S as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.u9iYV6vt.js';
|
|
6
|
+
import '@btst/db';
|
|
7
|
+
import 'better-call';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Represents a documented route parameter
|
|
11
|
+
*/
|
|
12
|
+
interface RouteParameter {
|
|
13
|
+
name: string;
|
|
14
|
+
type: string;
|
|
15
|
+
required: boolean;
|
|
16
|
+
description?: string;
|
|
17
|
+
schema?: Record<string, any>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Sitemap entry with plugin source
|
|
21
|
+
*/
|
|
22
|
+
interface PluginSitemapEntry extends SitemapEntry {
|
|
23
|
+
pluginKey: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Represents a documented route
|
|
27
|
+
*/
|
|
28
|
+
interface DocumentedRoute {
|
|
29
|
+
/** Route key from the plugin */
|
|
30
|
+
key: string;
|
|
31
|
+
/** The route path pattern (e.g., "/users/:id") */
|
|
32
|
+
path: string;
|
|
33
|
+
/** Path parameters extracted from the path */
|
|
34
|
+
pathParams: RouteParameter[];
|
|
35
|
+
/** Query parameters from the route's query schema */
|
|
36
|
+
queryParams: RouteParameter[];
|
|
37
|
+
/** Route metadata */
|
|
38
|
+
meta?: {
|
|
39
|
+
title?: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
tags?: string[];
|
|
42
|
+
[key: string]: any;
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Represents a plugin's documented routes
|
|
47
|
+
*/
|
|
48
|
+
interface DocumentedPlugin {
|
|
49
|
+
/** Plugin key */
|
|
50
|
+
key: string;
|
|
51
|
+
/** Plugin name */
|
|
52
|
+
name: string;
|
|
53
|
+
/** Routes from this plugin */
|
|
54
|
+
routes: DocumentedRoute[];
|
|
55
|
+
/** Sitemap entries from this plugin */
|
|
56
|
+
sitemapEntries: PluginSitemapEntry[];
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The complete route documentation schema
|
|
60
|
+
*/
|
|
61
|
+
interface RouteDocsSchema {
|
|
62
|
+
/** All documented plugins */
|
|
63
|
+
plugins: DocumentedPlugin[];
|
|
64
|
+
/** Generation timestamp */
|
|
65
|
+
generatedAt: string;
|
|
66
|
+
/** All sitemap entries aggregated */
|
|
67
|
+
allSitemapEntries: PluginSitemapEntry[];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Query key for route docs schema
|
|
72
|
+
*/
|
|
73
|
+
declare const ROUTE_DOCS_QUERY_KEY: readonly ["route-docs", "schema"];
|
|
74
|
+
/**
|
|
75
|
+
* Get the stored client stack context
|
|
76
|
+
* Used by the docs page component to generate schema on client-side navigation
|
|
77
|
+
*/
|
|
78
|
+
declare function getStoredContext(): ClientStackContext | null;
|
|
79
|
+
/**
|
|
80
|
+
* Generate the route docs schema from the stored context
|
|
81
|
+
* This can be called from both server and client
|
|
82
|
+
*/
|
|
83
|
+
declare function generateSchema(): Promise<RouteDocsSchema>;
|
|
84
|
+
/**
|
|
85
|
+
* Configuration for Route Docs client plugin
|
|
86
|
+
*/
|
|
87
|
+
interface RouteDocsClientConfig {
|
|
88
|
+
/** React Query client for SSR prefetching */
|
|
89
|
+
queryClient: QueryClient;
|
|
90
|
+
/** Title for the documentation page */
|
|
91
|
+
title?: string;
|
|
92
|
+
/** Description for the documentation page */
|
|
93
|
+
description?: string;
|
|
94
|
+
/** Site base path for constructing URLs (e.g., "/pages") */
|
|
95
|
+
siteBasePath: string;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Route Docs client plugin
|
|
99
|
+
* Provides a route that displays documentation for all client routes
|
|
100
|
+
*/
|
|
101
|
+
declare const routeDocsClientPlugin: (config: RouteDocsClientConfig) => _btst_stack_plugins_client.ClientPlugin<Record<string, never>, {
|
|
102
|
+
docs: {
|
|
103
|
+
(inputCtx_0?: _btst_yar.InputContext<"/route-docs", _btst_yar.RouteOptions> | undefined): {
|
|
104
|
+
PageComponent?: react.ComponentType<unknown> | undefined;
|
|
105
|
+
LoadingComponent?: react.ComponentType<unknown> | undefined;
|
|
106
|
+
ErrorComponent?: react.ComponentType<unknown> | undefined;
|
|
107
|
+
loader?: (() => Promise<void>) | undefined;
|
|
108
|
+
meta?: (() => ({
|
|
109
|
+
title: string;
|
|
110
|
+
name?: undefined;
|
|
111
|
+
content?: undefined;
|
|
112
|
+
} | {
|
|
113
|
+
name: string;
|
|
114
|
+
content: string;
|
|
115
|
+
title?: undefined;
|
|
116
|
+
})[]) | undefined;
|
|
117
|
+
extra?: (() => any) | undefined;
|
|
118
|
+
};
|
|
119
|
+
options: _btst_yar.RouteOptions | undefined;
|
|
120
|
+
path: "/route-docs";
|
|
121
|
+
meta: _btst_yar.RouteMeta | undefined;
|
|
122
|
+
};
|
|
123
|
+
}>;
|
|
124
|
+
|
|
125
|
+
export { ROUTE_DOCS_QUERY_KEY, generateSchema, getStoredContext, routeDocsClientPlugin };
|
|
126
|
+
export type { RouteDocsClientConfig };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { ROUTE_DOCS_QUERY_KEY, generateSchema, getStoredContext, routeDocsClientPlugin } from '../../../packages/better-stack/src/plugins/route-docs/client/plugin.mjs';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@import "./client.css";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Route Docs Plugin CSS - Includes Tailwind class scanning
|
|
5
|
+
*
|
|
6
|
+
* When consumed from npm, Tailwind v4 will automatically scan this package's
|
|
7
|
+
* source files for Tailwind classes. Consumers only need:
|
|
8
|
+
* @import "@btst/stack/plugins/route-docs/css";
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* Scan this package's source files for Tailwind classes */
|
|
12
|
+
@source "../../../src/**/*.{ts,tsx}";
|
|
13
|
+
|
|
14
|
+
/* Scan UI package components (when installed as npm package the UI package will be in this dir) */
|
|
15
|
+
@source "../../packages/ui/src";
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* alternatively consumer can use @source "../node_modules/@btst/stack/src/**\/*.{ts,tsx}";
|
|
19
|
+
*/
|
|
@@ -58,6 +58,19 @@ type ContentItem = {
|
|
|
58
58
|
createdAt: Date;
|
|
59
59
|
updatedAt: Date;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Represents an inverse relation (content types that reference this type via belongsTo)
|
|
63
|
+
*/
|
|
64
|
+
interface InverseRelation {
|
|
65
|
+
/** The content type slug that has the belongsTo relation */
|
|
66
|
+
sourceType: string;
|
|
67
|
+
/** Display name of the source content type */
|
|
68
|
+
sourceTypeName: string;
|
|
69
|
+
/** The field name that contains the belongsTo relation */
|
|
70
|
+
fieldName: string;
|
|
71
|
+
/** Count of items with this relation (when itemId is provided) */
|
|
72
|
+
count: number;
|
|
73
|
+
}
|
|
61
74
|
/**
|
|
62
75
|
* Serialized content type for API responses (dates as strings)
|
|
63
76
|
*/
|
|
@@ -81,6 +94,11 @@ interface SerializedContentItemWithType<TData = Record<string, unknown>> extends
|
|
|
81
94
|
parsedData: TData;
|
|
82
95
|
/** Joined content type */
|
|
83
96
|
contentType?: SerializedContentType;
|
|
97
|
+
/**
|
|
98
|
+
* Populated relation data (only present when using populated endpoints/hooks).
|
|
99
|
+
* Keys are field names, values are arrays of related content items.
|
|
100
|
+
*/
|
|
101
|
+
_relations?: Record<string, SerializedContentItemWithType[]>;
|
|
84
102
|
}
|
|
85
103
|
/**
|
|
86
104
|
* Paginated list response for content items
|
|
@@ -105,14 +123,18 @@ interface CMSHookContext {
|
|
|
105
123
|
}
|
|
106
124
|
/**
|
|
107
125
|
* Hooks for customizing CMS backend behavior
|
|
126
|
+
*
|
|
127
|
+
* Note: Before hooks can only deny operations by returning `false`.
|
|
128
|
+
* They cannot modify the data being saved. This ensures consistency
|
|
129
|
+
* between the stored content item data and relation junction tables.
|
|
108
130
|
*/
|
|
109
131
|
interface CMSBackendHooks {
|
|
110
|
-
/** Called before creating a content item */
|
|
111
|
-
onBeforeCreate?: (data: Record<string, unknown>, context: CMSHookContext) => Promise<
|
|
132
|
+
/** Called before creating a content item. Return false to deny the operation. */
|
|
133
|
+
onBeforeCreate?: (data: Record<string, unknown>, context: CMSHookContext) => Promise<false | void> | false | void;
|
|
112
134
|
/** Called after creating a content item */
|
|
113
135
|
onAfterCreate?: (item: SerializedContentItem, context: CMSHookContext) => Promise<void> | void;
|
|
114
|
-
/** Called before updating a content item */
|
|
115
|
-
onBeforeUpdate?: (id: string, data: Record<string, unknown>, context: CMSHookContext) => Promise<
|
|
136
|
+
/** Called before updating a content item. Return false to deny the operation. */
|
|
137
|
+
onBeforeUpdate?: (id: string, data: Record<string, unknown>, context: CMSHookContext) => Promise<false | void> | false | void;
|
|
116
138
|
/** Called after updating a content item */
|
|
117
139
|
onAfterUpdate?: (item: SerializedContentItem, context: CMSHookContext) => Promise<void> | void;
|
|
118
140
|
/** Called before deleting a content item */
|
|
@@ -132,4 +154,4 @@ interface CMSBackendConfig {
|
|
|
132
154
|
hooks?: CMSBackendHooks;
|
|
133
155
|
}
|
|
134
156
|
|
|
135
|
-
export type { CMSBackendConfig as C, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a };
|
|
157
|
+
export type { CMSBackendConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a };
|
|
@@ -58,6 +58,19 @@ type ContentItem = {
|
|
|
58
58
|
createdAt: Date;
|
|
59
59
|
updatedAt: Date;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Represents an inverse relation (content types that reference this type via belongsTo)
|
|
63
|
+
*/
|
|
64
|
+
interface InverseRelation {
|
|
65
|
+
/** The content type slug that has the belongsTo relation */
|
|
66
|
+
sourceType: string;
|
|
67
|
+
/** Display name of the source content type */
|
|
68
|
+
sourceTypeName: string;
|
|
69
|
+
/** The field name that contains the belongsTo relation */
|
|
70
|
+
fieldName: string;
|
|
71
|
+
/** Count of items with this relation (when itemId is provided) */
|
|
72
|
+
count: number;
|
|
73
|
+
}
|
|
61
74
|
/**
|
|
62
75
|
* Serialized content type for API responses (dates as strings)
|
|
63
76
|
*/
|
|
@@ -81,6 +94,11 @@ interface SerializedContentItemWithType<TData = Record<string, unknown>> extends
|
|
|
81
94
|
parsedData: TData;
|
|
82
95
|
/** Joined content type */
|
|
83
96
|
contentType?: SerializedContentType;
|
|
97
|
+
/**
|
|
98
|
+
* Populated relation data (only present when using populated endpoints/hooks).
|
|
99
|
+
* Keys are field names, values are arrays of related content items.
|
|
100
|
+
*/
|
|
101
|
+
_relations?: Record<string, SerializedContentItemWithType[]>;
|
|
84
102
|
}
|
|
85
103
|
/**
|
|
86
104
|
* Paginated list response for content items
|
|
@@ -105,14 +123,18 @@ interface CMSHookContext {
|
|
|
105
123
|
}
|
|
106
124
|
/**
|
|
107
125
|
* Hooks for customizing CMS backend behavior
|
|
126
|
+
*
|
|
127
|
+
* Note: Before hooks can only deny operations by returning `false`.
|
|
128
|
+
* They cannot modify the data being saved. This ensures consistency
|
|
129
|
+
* between the stored content item data and relation junction tables.
|
|
108
130
|
*/
|
|
109
131
|
interface CMSBackendHooks {
|
|
110
|
-
/** Called before creating a content item */
|
|
111
|
-
onBeforeCreate?: (data: Record<string, unknown>, context: CMSHookContext) => Promise<
|
|
132
|
+
/** Called before creating a content item. Return false to deny the operation. */
|
|
133
|
+
onBeforeCreate?: (data: Record<string, unknown>, context: CMSHookContext) => Promise<false | void> | false | void;
|
|
112
134
|
/** Called after creating a content item */
|
|
113
135
|
onAfterCreate?: (item: SerializedContentItem, context: CMSHookContext) => Promise<void> | void;
|
|
114
|
-
/** Called before updating a content item */
|
|
115
|
-
onBeforeUpdate?: (id: string, data: Record<string, unknown>, context: CMSHookContext) => Promise<
|
|
136
|
+
/** Called before updating a content item. Return false to deny the operation. */
|
|
137
|
+
onBeforeUpdate?: (id: string, data: Record<string, unknown>, context: CMSHookContext) => Promise<false | void> | false | void;
|
|
116
138
|
/** Called after updating a content item */
|
|
117
139
|
onAfterUpdate?: (item: SerializedContentItem, context: CMSHookContext) => Promise<void> | void;
|
|
118
140
|
/** Called before deleting a content item */
|
|
@@ -132,4 +154,4 @@ interface CMSBackendConfig {
|
|
|
132
154
|
hooks?: CMSBackendHooks;
|
|
133
155
|
}
|
|
134
156
|
|
|
135
|
-
export type { CMSBackendConfig as C, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a };
|
|
157
|
+
export type { CMSBackendConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a };
|
|
@@ -58,6 +58,19 @@ type ContentItem = {
|
|
|
58
58
|
createdAt: Date;
|
|
59
59
|
updatedAt: Date;
|
|
60
60
|
};
|
|
61
|
+
/**
|
|
62
|
+
* Represents an inverse relation (content types that reference this type via belongsTo)
|
|
63
|
+
*/
|
|
64
|
+
interface InverseRelation {
|
|
65
|
+
/** The content type slug that has the belongsTo relation */
|
|
66
|
+
sourceType: string;
|
|
67
|
+
/** Display name of the source content type */
|
|
68
|
+
sourceTypeName: string;
|
|
69
|
+
/** The field name that contains the belongsTo relation */
|
|
70
|
+
fieldName: string;
|
|
71
|
+
/** Count of items with this relation (when itemId is provided) */
|
|
72
|
+
count: number;
|
|
73
|
+
}
|
|
61
74
|
/**
|
|
62
75
|
* Serialized content type for API responses (dates as strings)
|
|
63
76
|
*/
|
|
@@ -81,6 +94,11 @@ interface SerializedContentItemWithType<TData = Record<string, unknown>> extends
|
|
|
81
94
|
parsedData: TData;
|
|
82
95
|
/** Joined content type */
|
|
83
96
|
contentType?: SerializedContentType;
|
|
97
|
+
/**
|
|
98
|
+
* Populated relation data (only present when using populated endpoints/hooks).
|
|
99
|
+
* Keys are field names, values are arrays of related content items.
|
|
100
|
+
*/
|
|
101
|
+
_relations?: Record<string, SerializedContentItemWithType[]>;
|
|
84
102
|
}
|
|
85
103
|
/**
|
|
86
104
|
* Paginated list response for content items
|
|
@@ -105,14 +123,18 @@ interface CMSHookContext {
|
|
|
105
123
|
}
|
|
106
124
|
/**
|
|
107
125
|
* Hooks for customizing CMS backend behavior
|
|
126
|
+
*
|
|
127
|
+
* Note: Before hooks can only deny operations by returning `false`.
|
|
128
|
+
* They cannot modify the data being saved. This ensures consistency
|
|
129
|
+
* between the stored content item data and relation junction tables.
|
|
108
130
|
*/
|
|
109
131
|
interface CMSBackendHooks {
|
|
110
|
-
/** Called before creating a content item */
|
|
111
|
-
onBeforeCreate?: (data: Record<string, unknown>, context: CMSHookContext) => Promise<
|
|
132
|
+
/** Called before creating a content item. Return false to deny the operation. */
|
|
133
|
+
onBeforeCreate?: (data: Record<string, unknown>, context: CMSHookContext) => Promise<false | void> | false | void;
|
|
112
134
|
/** Called after creating a content item */
|
|
113
135
|
onAfterCreate?: (item: SerializedContentItem, context: CMSHookContext) => Promise<void> | void;
|
|
114
|
-
/** Called before updating a content item */
|
|
115
|
-
onBeforeUpdate?: (id: string, data: Record<string, unknown>, context: CMSHookContext) => Promise<
|
|
136
|
+
/** Called before updating a content item. Return false to deny the operation. */
|
|
137
|
+
onBeforeUpdate?: (id: string, data: Record<string, unknown>, context: CMSHookContext) => Promise<false | void> | false | void;
|
|
116
138
|
/** Called after updating a content item */
|
|
117
139
|
onAfterUpdate?: (item: SerializedContentItem, context: CMSHookContext) => Promise<void> | void;
|
|
118
140
|
/** Called before deleting a content item */
|
|
@@ -132,4 +154,4 @@ interface CMSBackendConfig {
|
|
|
132
154
|
hooks?: CMSBackendHooks;
|
|
133
155
|
}
|
|
134
156
|
|
|
135
|
-
export type { CMSBackendConfig as C, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a };
|
|
157
|
+
export type { CMSBackendConfig as C, InverseRelation as I, PaginatedContentItems as P, SerializedContentType as S, SerializedContentItemWithType as a };
|
|
@@ -14,6 +14,16 @@ interface BetterStackContext {
|
|
|
14
14
|
/** The database adapter */
|
|
15
15
|
adapter: Adapter;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Context passed to client plugins during route creation
|
|
19
|
+
* Provides access to all registered plugins for introspection (used by routeDocs plugin)
|
|
20
|
+
*/
|
|
21
|
+
interface ClientStackContext<TPlugins extends Record<string, ClientPlugin<any, any>> = Record<string, ClientPlugin<any, any>>> {
|
|
22
|
+
/** All registered client plugins */
|
|
23
|
+
plugins: TPlugins;
|
|
24
|
+
/** The base path for the client (e.g., "/app") */
|
|
25
|
+
basePath?: string;
|
|
26
|
+
}
|
|
17
27
|
/**
|
|
18
28
|
* Backend plugin definition
|
|
19
29
|
* Defines API routes and data access for a feature
|
|
@@ -50,8 +60,10 @@ interface ClientPlugin<TOverrides = Record<string, never>, TRoutes extends Recor
|
|
|
50
60
|
/**
|
|
51
61
|
* Define routes (pages) for this plugin
|
|
52
62
|
* Returns yar routes that will be composed into the router
|
|
63
|
+
*
|
|
64
|
+
* @param context - Optional context with access to all plugins (for introspection)
|
|
53
65
|
*/
|
|
54
|
-
routes: () => TRoutes;
|
|
66
|
+
routes: (context?: ClientStackContext) => TRoutes;
|
|
55
67
|
/**
|
|
56
68
|
* Optional sitemap generator for this plugin. Should return absolute URLs.
|
|
57
69
|
* Implementations can call their own API endpoints to include dynamic routes.
|
|
@@ -142,4 +154,4 @@ type SitemapEntry = {
|
|
|
142
154
|
};
|
|
143
155
|
type Sitemap = Array<SitemapEntry>;
|
|
144
156
|
|
|
145
|
-
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P,
|
|
157
|
+
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, SitemapEntry as S, BetterStackContext as a, ClientStackContext as b, Sitemap as c, PluginRoutes as d, ClientLibConfig as e, ClientLib as f, PrefixedPluginRoutes as g, BackendLibConfig as h, BackendLib as i };
|
|
@@ -14,6 +14,16 @@ interface BetterStackContext {
|
|
|
14
14
|
/** The database adapter */
|
|
15
15
|
adapter: Adapter;
|
|
16
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Context passed to client plugins during route creation
|
|
19
|
+
* Provides access to all registered plugins for introspection (used by routeDocs plugin)
|
|
20
|
+
*/
|
|
21
|
+
interface ClientStackContext<TPlugins extends Record<string, ClientPlugin<any, any>> = Record<string, ClientPlugin<any, any>>> {
|
|
22
|
+
/** All registered client plugins */
|
|
23
|
+
plugins: TPlugins;
|
|
24
|
+
/** The base path for the client (e.g., "/app") */
|
|
25
|
+
basePath?: string;
|
|
26
|
+
}
|
|
17
27
|
/**
|
|
18
28
|
* Backend plugin definition
|
|
19
29
|
* Defines API routes and data access for a feature
|
|
@@ -50,8 +60,10 @@ interface ClientPlugin<TOverrides = Record<string, never>, TRoutes extends Recor
|
|
|
50
60
|
/**
|
|
51
61
|
* Define routes (pages) for this plugin
|
|
52
62
|
* Returns yar routes that will be composed into the router
|
|
63
|
+
*
|
|
64
|
+
* @param context - Optional context with access to all plugins (for introspection)
|
|
53
65
|
*/
|
|
54
|
-
routes: () => TRoutes;
|
|
66
|
+
routes: (context?: ClientStackContext) => TRoutes;
|
|
55
67
|
/**
|
|
56
68
|
* Optional sitemap generator for this plugin. Should return absolute URLs.
|
|
57
69
|
* Implementations can call their own API endpoints to include dynamic routes.
|
|
@@ -142,4 +154,4 @@ type SitemapEntry = {
|
|
|
142
154
|
};
|
|
143
155
|
type Sitemap = Array<SitemapEntry>;
|
|
144
156
|
|
|
145
|
-
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P,
|
|
157
|
+
export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, SitemapEntry as S, BetterStackContext as a, ClientStackContext as b, Sitemap as c, PluginRoutes as d, ClientLibConfig as e, ClientLib as f, PrefixedPluginRoutes as g, BackendLibConfig as h, BackendLib as i };
|