@btst/stack 1.0.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/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # BETTER STACK
2
+
3
+ WIP
@@ -0,0 +1,30 @@
1
+ 'use strict';
2
+
3
+ const betterCall = require('better-call');
4
+ const db = require('@btst/db');
5
+
6
+ function betterStack(config) {
7
+ const { plugins, adapter, dbSchema } = config;
8
+ const allRoutes = {};
9
+ let betterDbSchema = dbSchema ?? db.defineDb({});
10
+ for (const [pluginKey, plugin] of Object.entries(plugins)) {
11
+ betterDbSchema = betterDbSchema.use(plugin.dbPlugin);
12
+ }
13
+ for (const [pluginKey, plugin] of Object.entries(plugins)) {
14
+ const pluginRoutes = plugin.routes(adapter(betterDbSchema));
15
+ for (const [routeKey, endpoint] of Object.entries(pluginRoutes)) {
16
+ const compositeKey = `${pluginKey}_${routeKey}`;
17
+ allRoutes[compositeKey] = endpoint;
18
+ }
19
+ }
20
+ const router = betterCall.createRouter(allRoutes, {
21
+ basePath: "/api"
22
+ });
23
+ return {
24
+ handler: router.handler,
25
+ router,
26
+ dbSchema: betterDbSchema
27
+ };
28
+ }
29
+
30
+ exports.betterStack = betterStack;
@@ -0,0 +1,29 @@
1
+ import { e as PrefixedPluginRoutes, f as BackendLibConfig, g as BackendLib } from '../shared/stack.Dva9muUy.cjs';
2
+ export { B as BackendPlugin } from '../shared/stack.Dva9muUy.cjs';
3
+ import '@btst/yar';
4
+ import '@btst/db';
5
+ import 'better-call';
6
+
7
+ /**
8
+ * Creates the backend library with plugin support
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const api = betterStack({
13
+ * plugins: {
14
+ * messages: messagesPlugin.backend
15
+ * },
16
+ * adapter: memoryAdapter
17
+ * });
18
+ *
19
+ * // Use in API route:
20
+ * export const GET = api.handler;
21
+ * export const POST = api.handler;
22
+ * ```
23
+ *
24
+ * @template TPlugins - The exact plugins map (inferred from config)
25
+ * @template TRoutes - All routes with prefixed keys like "pluginName_routeName" (computed automatically)
26
+ */
27
+ declare function betterStack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes>;
28
+
29
+ export { BackendLib, BackendLibConfig, betterStack };
@@ -0,0 +1,29 @@
1
+ import { e as PrefixedPluginRoutes, f as BackendLibConfig, g as BackendLib } from '../shared/stack.Dva9muUy.mjs';
2
+ export { B as BackendPlugin } from '../shared/stack.Dva9muUy.mjs';
3
+ import '@btst/yar';
4
+ import '@btst/db';
5
+ import 'better-call';
6
+
7
+ /**
8
+ * Creates the backend library with plugin support
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const api = betterStack({
13
+ * plugins: {
14
+ * messages: messagesPlugin.backend
15
+ * },
16
+ * adapter: memoryAdapter
17
+ * });
18
+ *
19
+ * // Use in API route:
20
+ * export const GET = api.handler;
21
+ * export const POST = api.handler;
22
+ * ```
23
+ *
24
+ * @template TPlugins - The exact plugins map (inferred from config)
25
+ * @template TRoutes - All routes with prefixed keys like "pluginName_routeName" (computed automatically)
26
+ */
27
+ declare function betterStack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes>;
28
+
29
+ export { BackendLib, BackendLibConfig, betterStack };
@@ -0,0 +1,29 @@
1
+ import { e as PrefixedPluginRoutes, f as BackendLibConfig, g as BackendLib } from '../shared/stack.Dva9muUy.js';
2
+ export { B as BackendPlugin } from '../shared/stack.Dva9muUy.js';
3
+ import '@btst/yar';
4
+ import '@btst/db';
5
+ import 'better-call';
6
+
7
+ /**
8
+ * Creates the backend library with plugin support
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * const api = betterStack({
13
+ * plugins: {
14
+ * messages: messagesPlugin.backend
15
+ * },
16
+ * adapter: memoryAdapter
17
+ * });
18
+ *
19
+ * // Use in API route:
20
+ * export const GET = api.handler;
21
+ * export const POST = api.handler;
22
+ * ```
23
+ *
24
+ * @template TPlugins - The exact plugins map (inferred from config)
25
+ * @template TRoutes - All routes with prefixed keys like "pluginName_routeName" (computed automatically)
26
+ */
27
+ declare function betterStack<TPlugins extends Record<string, any>, TRoutes extends PrefixedPluginRoutes<TPlugins> = PrefixedPluginRoutes<TPlugins>>(config: BackendLibConfig<TPlugins>): BackendLib<TRoutes>;
28
+
29
+ export { BackendLib, BackendLibConfig, betterStack };
@@ -0,0 +1,28 @@
1
+ import { createRouter } from 'better-call';
2
+ import { defineDb } from '@btst/db';
3
+
4
+ function betterStack(config) {
5
+ const { plugins, adapter, dbSchema } = config;
6
+ const allRoutes = {};
7
+ let betterDbSchema = dbSchema ?? defineDb({});
8
+ for (const [pluginKey, plugin] of Object.entries(plugins)) {
9
+ betterDbSchema = betterDbSchema.use(plugin.dbPlugin);
10
+ }
11
+ for (const [pluginKey, plugin] of Object.entries(plugins)) {
12
+ const pluginRoutes = plugin.routes(adapter(betterDbSchema));
13
+ for (const [routeKey, endpoint] of Object.entries(pluginRoutes)) {
14
+ const compositeKey = `${pluginKey}_${routeKey}`;
15
+ allRoutes[compositeKey] = endpoint;
16
+ }
17
+ }
18
+ const router = createRouter(allRoutes, {
19
+ basePath: "/api"
20
+ });
21
+ return {
22
+ handler: router.handler,
23
+ router,
24
+ dbSchema: betterDbSchema
25
+ };
26
+ }
27
+
28
+ export { betterStack };
@@ -0,0 +1,34 @@
1
+ 'use strict';
2
+
3
+ const yar = require('@btst/yar');
4
+ const context_index = require('../context/index.cjs');
5
+ const utils = require('../shared/stack.Br2KMECJ.cjs');
6
+ require('react/jsx-runtime');
7
+ require('react');
8
+ require('better-call/client');
9
+
10
+ function createStackClient(config) {
11
+ const { plugins } = config;
12
+ const allRoutes = {};
13
+ const allHooks = {};
14
+ for (const [pluginKey, plugin] of Object.entries(plugins)) {
15
+ const pluginRoutes = plugin.routes();
16
+ Object.assign(allRoutes, pluginRoutes);
17
+ if (plugin.hooks) {
18
+ allHooks[pluginKey] = plugin.hooks();
19
+ }
20
+ }
21
+ const router = yar.createRouter(allRoutes);
22
+ return {
23
+ router,
24
+ hooks: allHooks
25
+ };
26
+ }
27
+
28
+ exports.BetterStackProvider = context_index.BetterStackProvider;
29
+ exports.useBetterStack = context_index.useBetterStack;
30
+ exports.usePluginOverride = context_index.usePluginOverride;
31
+ exports.usePluginOverrides = context_index.usePluginOverrides;
32
+ exports.createApiClient = utils.createApiClient;
33
+ exports.getServerBaseURL = utils.getServerBaseURL;
34
+ exports.createStackClient = createStackClient;
@@ -0,0 +1,36 @@
1
+ import { C as ClientPlugin, P as PluginRoutes, a as PluginHooks, b as ClientLibConfig, c as ClientLib } from '../shared/stack.Dva9muUy.cjs';
2
+ export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides } from '../context/index.cjs';
3
+ export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.cjs';
4
+ import '@btst/yar';
5
+ import '@btst/db';
6
+ import 'better-call';
7
+ import 'react/jsx-runtime';
8
+ import 'react';
9
+ import 'better-call/client';
10
+
11
+ /**
12
+ * Creates the client library with plugin support
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // For Next.js with SSR:
17
+ * const lib = createStackClient({
18
+ * plugins: {
19
+ * messages: messagesPlugin.client
20
+ * }
21
+ * });
22
+ *
23
+ * // Access router for page routing
24
+ * const route = lib.router.getRoute('/messages');
25
+ *
26
+ * // For SPA (just use hooks directly):
27
+ * const { useMessages } = lib.hooks.messages;
28
+ * ```
29
+ *
30
+ * @template TPlugins - The exact plugins map (inferred from config)
31
+ * @template TRoutes - All routes from all plugins, merged (computed automatically)
32
+ * @template THooks - All hooks from all plugins, organized by plugin name (computed automatically)
33
+ */
34
+ declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>, THooks extends PluginHooks<TPlugins> = PluginHooks<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes, THooks>;
35
+
36
+ export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
@@ -0,0 +1,36 @@
1
+ import { C as ClientPlugin, P as PluginRoutes, a as PluginHooks, b as ClientLibConfig, c as ClientLib } from '../shared/stack.Dva9muUy.mjs';
2
+ export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides } from '../context/index.mjs';
3
+ export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.mjs';
4
+ import '@btst/yar';
5
+ import '@btst/db';
6
+ import 'better-call';
7
+ import 'react/jsx-runtime';
8
+ import 'react';
9
+ import 'better-call/client';
10
+
11
+ /**
12
+ * Creates the client library with plugin support
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // For Next.js with SSR:
17
+ * const lib = createStackClient({
18
+ * plugins: {
19
+ * messages: messagesPlugin.client
20
+ * }
21
+ * });
22
+ *
23
+ * // Access router for page routing
24
+ * const route = lib.router.getRoute('/messages');
25
+ *
26
+ * // For SPA (just use hooks directly):
27
+ * const { useMessages } = lib.hooks.messages;
28
+ * ```
29
+ *
30
+ * @template TPlugins - The exact plugins map (inferred from config)
31
+ * @template TRoutes - All routes from all plugins, merged (computed automatically)
32
+ * @template THooks - All hooks from all plugins, organized by plugin name (computed automatically)
33
+ */
34
+ declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>, THooks extends PluginHooks<TPlugins> = PluginHooks<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes, THooks>;
35
+
36
+ export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
@@ -0,0 +1,36 @@
1
+ import { C as ClientPlugin, P as PluginRoutes, a as PluginHooks, b as ClientLibConfig, c as ClientLib } from '../shared/stack.Dva9muUy.js';
2
+ export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides } from '../context/index.js';
3
+ export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.js';
4
+ import '@btst/yar';
5
+ import '@btst/db';
6
+ import 'better-call';
7
+ import 'react/jsx-runtime';
8
+ import 'react';
9
+ import 'better-call/client';
10
+
11
+ /**
12
+ * Creates the client library with plugin support
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * // For Next.js with SSR:
17
+ * const lib = createStackClient({
18
+ * plugins: {
19
+ * messages: messagesPlugin.client
20
+ * }
21
+ * });
22
+ *
23
+ * // Access router for page routing
24
+ * const route = lib.router.getRoute('/messages');
25
+ *
26
+ * // For SPA (just use hooks directly):
27
+ * const { useMessages } = lib.hooks.messages;
28
+ * ```
29
+ *
30
+ * @template TPlugins - The exact plugins map (inferred from config)
31
+ * @template TRoutes - All routes from all plugins, merged (computed automatically)
32
+ * @template THooks - All hooks from all plugins, organized by plugin name (computed automatically)
33
+ */
34
+ declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>, THooks extends PluginHooks<TPlugins> = PluginHooks<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes, THooks>;
35
+
36
+ export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
@@ -0,0 +1,26 @@
1
+ import { createRouter } from '@btst/yar';
2
+ export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides } from '../context/index.mjs';
3
+ export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.CwGEQ10b.mjs';
4
+ import 'react/jsx-runtime';
5
+ import 'react';
6
+ import 'better-call/client';
7
+
8
+ function createStackClient(config) {
9
+ const { plugins } = config;
10
+ const allRoutes = {};
11
+ const allHooks = {};
12
+ for (const [pluginKey, plugin] of Object.entries(plugins)) {
13
+ const pluginRoutes = plugin.routes();
14
+ Object.assign(allRoutes, pluginRoutes);
15
+ if (plugin.hooks) {
16
+ allHooks[pluginKey] = plugin.hooks();
17
+ }
18
+ }
19
+ const router = createRouter(allRoutes);
20
+ return {
21
+ router,
22
+ hooks: allHooks
23
+ };
24
+ }
25
+
26
+ export { createStackClient };
@@ -0,0 +1,55 @@
1
+ "use client";
2
+ 'use strict';
3
+
4
+ const jsxRuntime = require('react/jsx-runtime');
5
+ const react = require('react');
6
+
7
+ const BetterStackContext = react.createContext(
8
+ null
9
+ );
10
+ function BetterStackProvider({
11
+ children,
12
+ overrides
13
+ }) {
14
+ const value = {
15
+ overrides
16
+ };
17
+ return /* @__PURE__ */ jsxRuntime.jsx(BetterStackContext.Provider, { value, children });
18
+ }
19
+ function useBetterStack() {
20
+ const context = react.useContext(
21
+ BetterStackContext
22
+ );
23
+ if (!context) {
24
+ throw new Error(
25
+ "useBetterStack must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
26
+ );
27
+ }
28
+ return context;
29
+ }
30
+ function usePluginOverrides(pluginName) {
31
+ const context = useBetterStack();
32
+ const overrides = context.overrides[pluginName];
33
+ if (!overrides) {
34
+ throw new Error(
35
+ `Plugin "${pluginName}" not found in BetterStackProvider. Available plugins: ${Object.keys(context.overrides).join(", ")}`
36
+ );
37
+ }
38
+ return overrides;
39
+ }
40
+ function usePluginOverride(pluginName, overrideKey) {
41
+ const overrides = usePluginOverrides(pluginName);
42
+ const override = overrides[overrideKey];
43
+ if (override === void 0) {
44
+ const availableKeys = overrides && typeof overrides === "object" ? Object.keys(overrides).join(", ") : "none";
45
+ throw new Error(
46
+ `Override "${overrideKey}" not found for plugin "${pluginName}". Available overrides: ${availableKeys}`
47
+ );
48
+ }
49
+ return override;
50
+ }
51
+
52
+ exports.BetterStackProvider = BetterStackProvider;
53
+ exports.useBetterStack = useBetterStack;
54
+ exports.usePluginOverride = usePluginOverride;
55
+ exports.usePluginOverrides = usePluginOverrides;
@@ -0,0 +1,86 @@
1
+ "use client";
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { ReactNode } from 'react';
4
+
5
+ /**
6
+ * Context value that provides plugin-specific overrides
7
+ * Generic over the shape of all plugin overrides
8
+ */
9
+ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
10
+ overrides: TPluginOverrides;
11
+ }
12
+ /**
13
+ * Provider component for BetterStack context
14
+ * Provides type-safe access to plugin-specific overrides
15
+ *
16
+ * Only requires override values, not plugin objects - keeps bundle size minimal!
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * // Define the type shape (no import of plugin values needed!)
21
+ * type MyPluginOverrides = {
22
+ * todos: TodosPluginOverrides;
23
+ * messages: MessagesPluginOverrides;
24
+ * };
25
+ *
26
+ * <BetterStackProvider<MyPluginOverrides>
27
+ * overrides={{
28
+ * todos: {
29
+ * Link: (props) => <NextLink {...props} />,
30
+ * navigate: (path) => router.push(path),
31
+ * },
32
+ * messages: {
33
+ * MarkdownRenderer: (props) => <ReactMarkdown {...props} />,
34
+ * }
35
+ * }}
36
+ * >
37
+ * {children}
38
+ * </BetterStackProvider>
39
+ * ```
40
+ */
41
+ declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
42
+ children: ReactNode;
43
+ overrides: TPluginOverrides;
44
+ }): react_jsx_runtime.JSX.Element;
45
+ /**
46
+ * Hook to access the entire context
47
+ * Useful if you need access to multiple plugins or the full context
48
+ */
49
+ declare function useBetterStack<TPluginOverrides extends Record<string, any> = Record<string, any>>(): BetterStackContextValue<TPluginOverrides>;
50
+ /**
51
+ * Hook to access overrides for a specific plugin
52
+ * This is type-safe and will only expose the overrides defined by that plugin
53
+ *
54
+ * @example
55
+ * ```tsx
56
+ * // In a todos plugin component
57
+ * function TodosList() {
58
+ * const { Link, navigate } = usePluginOverrides<TodosPluginOverrides>("todos");
59
+ *
60
+ * return (
61
+ * <Link href="/todos/add">
62
+ * <button onClick={() => navigate("/todos")}>
63
+ * Add Todo
64
+ * </button>
65
+ * </Link>
66
+ * );
67
+ * }
68
+ * ```
69
+ */
70
+ declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOverrides;
71
+ /**
72
+ * Hook to access a specific override from a plugin
73
+ * Provides fine-grained access with full type safety
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * function TodosList() {
78
+ * const Link = usePluginOverride<typeof NextLink>("todos", "Link");
79
+ *
80
+ * return <Link href="/todos/add">Add Todo</Link>;
81
+ * }
82
+ * ```
83
+ */
84
+ declare function usePluginOverride<TOverride = any>(pluginName: string, overrideKey: string): TOverride;
85
+
86
+ export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides };
@@ -0,0 +1,86 @@
1
+ "use client";
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { ReactNode } from 'react';
4
+
5
+ /**
6
+ * Context value that provides plugin-specific overrides
7
+ * Generic over the shape of all plugin overrides
8
+ */
9
+ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
10
+ overrides: TPluginOverrides;
11
+ }
12
+ /**
13
+ * Provider component for BetterStack context
14
+ * Provides type-safe access to plugin-specific overrides
15
+ *
16
+ * Only requires override values, not plugin objects - keeps bundle size minimal!
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * // Define the type shape (no import of plugin values needed!)
21
+ * type MyPluginOverrides = {
22
+ * todos: TodosPluginOverrides;
23
+ * messages: MessagesPluginOverrides;
24
+ * };
25
+ *
26
+ * <BetterStackProvider<MyPluginOverrides>
27
+ * overrides={{
28
+ * todos: {
29
+ * Link: (props) => <NextLink {...props} />,
30
+ * navigate: (path) => router.push(path),
31
+ * },
32
+ * messages: {
33
+ * MarkdownRenderer: (props) => <ReactMarkdown {...props} />,
34
+ * }
35
+ * }}
36
+ * >
37
+ * {children}
38
+ * </BetterStackProvider>
39
+ * ```
40
+ */
41
+ declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
42
+ children: ReactNode;
43
+ overrides: TPluginOverrides;
44
+ }): react_jsx_runtime.JSX.Element;
45
+ /**
46
+ * Hook to access the entire context
47
+ * Useful if you need access to multiple plugins or the full context
48
+ */
49
+ declare function useBetterStack<TPluginOverrides extends Record<string, any> = Record<string, any>>(): BetterStackContextValue<TPluginOverrides>;
50
+ /**
51
+ * Hook to access overrides for a specific plugin
52
+ * This is type-safe and will only expose the overrides defined by that plugin
53
+ *
54
+ * @example
55
+ * ```tsx
56
+ * // In a todos plugin component
57
+ * function TodosList() {
58
+ * const { Link, navigate } = usePluginOverrides<TodosPluginOverrides>("todos");
59
+ *
60
+ * return (
61
+ * <Link href="/todos/add">
62
+ * <button onClick={() => navigate("/todos")}>
63
+ * Add Todo
64
+ * </button>
65
+ * </Link>
66
+ * );
67
+ * }
68
+ * ```
69
+ */
70
+ declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOverrides;
71
+ /**
72
+ * Hook to access a specific override from a plugin
73
+ * Provides fine-grained access with full type safety
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * function TodosList() {
78
+ * const Link = usePluginOverride<typeof NextLink>("todos", "Link");
79
+ *
80
+ * return <Link href="/todos/add">Add Todo</Link>;
81
+ * }
82
+ * ```
83
+ */
84
+ declare function usePluginOverride<TOverride = any>(pluginName: string, overrideKey: string): TOverride;
85
+
86
+ export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides };
@@ -0,0 +1,86 @@
1
+ "use client";
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import { ReactNode } from 'react';
4
+
5
+ /**
6
+ * Context value that provides plugin-specific overrides
7
+ * Generic over the shape of all plugin overrides
8
+ */
9
+ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
10
+ overrides: TPluginOverrides;
11
+ }
12
+ /**
13
+ * Provider component for BetterStack context
14
+ * Provides type-safe access to plugin-specific overrides
15
+ *
16
+ * Only requires override values, not plugin objects - keeps bundle size minimal!
17
+ *
18
+ * @example
19
+ * ```tsx
20
+ * // Define the type shape (no import of plugin values needed!)
21
+ * type MyPluginOverrides = {
22
+ * todos: TodosPluginOverrides;
23
+ * messages: MessagesPluginOverrides;
24
+ * };
25
+ *
26
+ * <BetterStackProvider<MyPluginOverrides>
27
+ * overrides={{
28
+ * todos: {
29
+ * Link: (props) => <NextLink {...props} />,
30
+ * navigate: (path) => router.push(path),
31
+ * },
32
+ * messages: {
33
+ * MarkdownRenderer: (props) => <ReactMarkdown {...props} />,
34
+ * }
35
+ * }}
36
+ * >
37
+ * {children}
38
+ * </BetterStackProvider>
39
+ * ```
40
+ */
41
+ declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
42
+ children: ReactNode;
43
+ overrides: TPluginOverrides;
44
+ }): react_jsx_runtime.JSX.Element;
45
+ /**
46
+ * Hook to access the entire context
47
+ * Useful if you need access to multiple plugins or the full context
48
+ */
49
+ declare function useBetterStack<TPluginOverrides extends Record<string, any> = Record<string, any>>(): BetterStackContextValue<TPluginOverrides>;
50
+ /**
51
+ * Hook to access overrides for a specific plugin
52
+ * This is type-safe and will only expose the overrides defined by that plugin
53
+ *
54
+ * @example
55
+ * ```tsx
56
+ * // In a todos plugin component
57
+ * function TodosList() {
58
+ * const { Link, navigate } = usePluginOverrides<TodosPluginOverrides>("todos");
59
+ *
60
+ * return (
61
+ * <Link href="/todos/add">
62
+ * <button onClick={() => navigate("/todos")}>
63
+ * Add Todo
64
+ * </button>
65
+ * </Link>
66
+ * );
67
+ * }
68
+ * ```
69
+ */
70
+ declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOverrides;
71
+ /**
72
+ * Hook to access a specific override from a plugin
73
+ * Provides fine-grained access with full type safety
74
+ *
75
+ * @example
76
+ * ```tsx
77
+ * function TodosList() {
78
+ * const Link = usePluginOverride<typeof NextLink>("todos", "Link");
79
+ *
80
+ * return <Link href="/todos/add">Add Todo</Link>;
81
+ * }
82
+ * ```
83
+ */
84
+ declare function usePluginOverride<TOverride = any>(pluginName: string, overrideKey: string): TOverride;
85
+
86
+ export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides };