@btst/stack 1.0.0 → 1.0.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.
Files changed (35) hide show
  1. package/README.md +790 -2
  2. package/dist/api/index.cjs +3 -2
  3. package/dist/api/index.d.cts +3 -3
  4. package/dist/api/index.d.mts +3 -3
  5. package/dist/api/index.d.ts +3 -3
  6. package/dist/api/index.mjs +3 -2
  7. package/dist/client/index.cjs +3 -15
  8. package/dist/client/index.d.cts +4 -10
  9. package/dist/client/index.d.mts +4 -10
  10. package/dist/client/index.d.ts +4 -10
  11. package/dist/client/index.mjs +3 -10
  12. package/dist/context/index.cjs +14 -2
  13. package/dist/context/index.d.cts +6 -3
  14. package/dist/context/index.d.mts +6 -3
  15. package/dist/context/index.d.ts +6 -3
  16. package/dist/context/index.mjs +14 -3
  17. package/dist/index.cjs +2 -1
  18. package/dist/index.d.cts +2 -2
  19. package/dist/index.d.mts +2 -2
  20. package/dist/index.d.ts +2 -2
  21. package/dist/index.mjs +1 -1
  22. package/dist/plugins/index.cjs +1 -2
  23. package/dist/plugins/index.d.cts +3 -3
  24. package/dist/plugins/index.d.mts +3 -3
  25. package/dist/plugins/index.d.ts +3 -3
  26. package/dist/plugins/index.mjs +1 -1
  27. package/dist/shared/{stack.CwGEQ10b.mjs → stack.3OUyGp_E.mjs} +2 -8
  28. package/dist/shared/{stack.Br2KMECJ.cjs → stack.CktCg4PJ.cjs} +1 -8
  29. package/dist/shared/{stack.Dva9muUy.d.cts → stack.DORw_1ps.d.cts} +3 -25
  30. package/dist/shared/{stack.Dva9muUy.d.mts → stack.DORw_1ps.d.mts} +3 -25
  31. package/dist/shared/{stack.Dva9muUy.d.ts → stack.DORw_1ps.d.ts} +3 -25
  32. package/dist/shared/{stack.DvFqFlOV.d.ts → stack.DrUAVfIH.d.cts} +2 -7
  33. package/dist/shared/{stack.DvFqFlOV.d.cts → stack.DrUAVfIH.d.mts} +2 -7
  34. package/dist/shared/{stack.DvFqFlOV.d.mts → stack.DrUAVfIH.d.ts} +2 -7
  35. package/package.json +3 -3
@@ -4,7 +4,7 @@ const betterCall = require('better-call');
4
4
  const db = require('@btst/db');
5
5
 
6
6
  function betterStack(config) {
7
- const { plugins, adapter, dbSchema } = config;
7
+ const { plugins, adapter, dbSchema, basePath } = config;
8
8
  const allRoutes = {};
9
9
  let betterDbSchema = dbSchema ?? db.defineDb({});
10
10
  for (const [pluginKey, plugin] of Object.entries(plugins)) {
@@ -18,7 +18,7 @@ function betterStack(config) {
18
18
  }
19
19
  }
20
20
  const router = betterCall.createRouter(allRoutes, {
21
- basePath: "/api"
21
+ basePath
22
22
  });
23
23
  return {
24
24
  handler: router.handler,
@@ -27,4 +27,5 @@ function betterStack(config) {
27
27
  };
28
28
  }
29
29
 
30
+ exports.createEndpoint = betterCall.createEndpoint;
30
31
  exports.betterStack = betterStack;
@@ -1,8 +1,8 @@
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';
1
+ import { d as PrefixedPluginRoutes, e as BackendLibConfig, f as BackendLib } from '../shared/stack.DORw_1ps.cjs';
2
+ export { B as BackendPlugin } from '../shared/stack.DORw_1ps.cjs';
3
+ export { createEndpoint } from 'better-call';
3
4
  import '@btst/yar';
4
5
  import '@btst/db';
5
- import 'better-call';
6
6
 
7
7
  /**
8
8
  * Creates the backend library with plugin support
@@ -1,8 +1,8 @@
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';
1
+ import { d as PrefixedPluginRoutes, e as BackendLibConfig, f as BackendLib } from '../shared/stack.DORw_1ps.mjs';
2
+ export { B as BackendPlugin } from '../shared/stack.DORw_1ps.mjs';
3
+ export { createEndpoint } from 'better-call';
3
4
  import '@btst/yar';
4
5
  import '@btst/db';
5
- import 'better-call';
6
6
 
7
7
  /**
8
8
  * Creates the backend library with plugin support
@@ -1,8 +1,8 @@
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';
1
+ import { d as PrefixedPluginRoutes, e as BackendLibConfig, f as BackendLib } from '../shared/stack.DORw_1ps.js';
2
+ export { B as BackendPlugin } from '../shared/stack.DORw_1ps.js';
3
+ export { createEndpoint } from 'better-call';
3
4
  import '@btst/yar';
4
5
  import '@btst/db';
5
- import 'better-call';
6
6
 
7
7
  /**
8
8
  * Creates the backend library with plugin support
@@ -1,8 +1,9 @@
1
1
  import { createRouter } from 'better-call';
2
+ export { createEndpoint } from 'better-call';
2
3
  import { defineDb } from '@btst/db';
3
4
 
4
5
  function betterStack(config) {
5
- const { plugins, adapter, dbSchema } = config;
6
+ const { plugins, adapter, dbSchema, basePath } = config;
6
7
  const allRoutes = {};
7
8
  let betterDbSchema = dbSchema ?? defineDb({});
8
9
  for (const [pluginKey, plugin] of Object.entries(plugins)) {
@@ -16,7 +17,7 @@ function betterStack(config) {
16
17
  }
17
18
  }
18
19
  const router = createRouter(allRoutes, {
19
- basePath: "/api"
20
+ basePath
20
21
  });
21
22
  return {
22
23
  handler: router.handler,
@@ -1,34 +1,22 @@
1
1
  'use strict';
2
2
 
3
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');
4
+ const utils = require('../shared/stack.CktCg4PJ.cjs');
8
5
  require('better-call/client');
9
6
 
10
7
  function createStackClient(config) {
11
8
  const { plugins } = config;
12
9
  const allRoutes = {};
13
- const allHooks = {};
14
10
  for (const [pluginKey, plugin] of Object.entries(plugins)) {
15
11
  const pluginRoutes = plugin.routes();
16
12
  Object.assign(allRoutes, pluginRoutes);
17
- if (plugin.hooks) {
18
- allHooks[pluginKey] = plugin.hooks();
19
- }
20
13
  }
21
14
  const router = yar.createRouter(allRoutes);
22
15
  return {
23
- router,
24
- hooks: allHooks
16
+ router
25
17
  };
26
18
  }
27
19
 
28
- exports.BetterStackProvider = context_index.BetterStackProvider;
29
- exports.useBetterStack = context_index.useBetterStack;
30
- exports.usePluginOverride = context_index.usePluginOverride;
31
- exports.usePluginOverrides = context_index.usePluginOverrides;
20
+ exports.createRoute = yar.createRoute;
32
21
  exports.createApiClient = utils.createApiClient;
33
- exports.getServerBaseURL = utils.getServerBaseURL;
34
22
  exports.createStackClient = createStackClient;
@@ -1,11 +1,8 @@
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';
1
+ import { C as ClientPlugin, P as PluginRoutes, a as ClientLibConfig, b as ClientLib } from '../shared/stack.DORw_1ps.cjs';
2
+ export { createRoute } from '@btst/yar';
3
+ export { c as createApiClient } from '../shared/stack.DrUAVfIH.cjs';
5
4
  import '@btst/db';
6
5
  import 'better-call';
7
- import 'react/jsx-runtime';
8
- import 'react';
9
6
  import 'better-call/client';
10
7
 
11
8
  /**
@@ -23,14 +20,11 @@ import 'better-call/client';
23
20
  * // Access router for page routing
24
21
  * const route = lib.router.getRoute('/messages');
25
22
  *
26
- * // For SPA (just use hooks directly):
27
- * const { useMessages } = lib.hooks.messages;
28
23
  * ```
29
24
  *
30
25
  * @template TPlugins - The exact plugins map (inferred from config)
31
26
  * @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
27
  */
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>;
28
+ declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes>;
35
29
 
36
30
  export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
@@ -1,11 +1,8 @@
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';
1
+ import { C as ClientPlugin, P as PluginRoutes, a as ClientLibConfig, b as ClientLib } from '../shared/stack.DORw_1ps.mjs';
2
+ export { createRoute } from '@btst/yar';
3
+ export { c as createApiClient } from '../shared/stack.DrUAVfIH.mjs';
5
4
  import '@btst/db';
6
5
  import 'better-call';
7
- import 'react/jsx-runtime';
8
- import 'react';
9
6
  import 'better-call/client';
10
7
 
11
8
  /**
@@ -23,14 +20,11 @@ import 'better-call/client';
23
20
  * // Access router for page routing
24
21
  * const route = lib.router.getRoute('/messages');
25
22
  *
26
- * // For SPA (just use hooks directly):
27
- * const { useMessages } = lib.hooks.messages;
28
23
  * ```
29
24
  *
30
25
  * @template TPlugins - The exact plugins map (inferred from config)
31
26
  * @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
27
  */
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>;
28
+ declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes>;
35
29
 
36
30
  export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
@@ -1,11 +1,8 @@
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';
1
+ import { C as ClientPlugin, P as PluginRoutes, a as ClientLibConfig, b as ClientLib } from '../shared/stack.DORw_1ps.js';
2
+ export { createRoute } from '@btst/yar';
3
+ export { c as createApiClient } from '../shared/stack.DrUAVfIH.js';
5
4
  import '@btst/db';
6
5
  import 'better-call';
7
- import 'react/jsx-runtime';
8
- import 'react';
9
6
  import 'better-call/client';
10
7
 
11
8
  /**
@@ -23,14 +20,11 @@ import 'better-call/client';
23
20
  * // Access router for page routing
24
21
  * const route = lib.router.getRoute('/messages');
25
22
  *
26
- * // For SPA (just use hooks directly):
27
- * const { useMessages } = lib.hooks.messages;
28
23
  * ```
29
24
  *
30
25
  * @template TPlugins - The exact plugins map (inferred from config)
31
26
  * @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
27
  */
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>;
28
+ declare function createStackClient<TPlugins extends Record<string, ClientPlugin<any, any>>, TRoutes extends PluginRoutes<TPlugins> = PluginRoutes<TPlugins>>(config: ClientLibConfig<TPlugins>): ClientLib<TRoutes>;
35
29
 
36
30
  export { ClientLib, ClientLibConfig, ClientPlugin, createStackClient };
@@ -1,25 +1,18 @@
1
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';
2
+ export { createRoute } from '@btst/yar';
3
+ export { c as createApiClient } from '../shared/stack.3OUyGp_E.mjs';
6
4
  import 'better-call/client';
7
5
 
8
6
  function createStackClient(config) {
9
7
  const { plugins } = config;
10
8
  const allRoutes = {};
11
- const allHooks = {};
12
9
  for (const [pluginKey, plugin] of Object.entries(plugins)) {
13
10
  const pluginRoutes = plugin.routes();
14
11
  Object.assign(allRoutes, pluginRoutes);
15
- if (plugin.hooks) {
16
- allHooks[pluginKey] = plugin.hooks();
17
- }
18
12
  }
19
13
  const router = createRouter(allRoutes);
20
14
  return {
21
- router,
22
- hooks: allHooks
15
+ router
23
16
  };
24
17
  }
25
18
 
@@ -9,10 +9,12 @@ const BetterStackContext = react.createContext(
9
9
  );
10
10
  function BetterStackProvider({
11
11
  children,
12
- overrides
12
+ overrides,
13
+ basePath
13
14
  }) {
14
15
  const value = {
15
- overrides
16
+ overrides,
17
+ basePath
16
18
  };
17
19
  return /* @__PURE__ */ jsxRuntime.jsx(BetterStackContext.Provider, { value, children });
18
20
  }
@@ -48,8 +50,18 @@ function usePluginOverride(pluginName, overrideKey) {
48
50
  }
49
51
  return override;
50
52
  }
53
+ function useBasePath() {
54
+ const context = useBetterStack();
55
+ if (!context) {
56
+ throw new Error(
57
+ "useBasePath must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
58
+ );
59
+ }
60
+ return context.basePath;
61
+ }
51
62
 
52
63
  exports.BetterStackProvider = BetterStackProvider;
64
+ exports.useBasePath = useBasePath;
53
65
  exports.useBetterStack = useBetterStack;
54
66
  exports.usePluginOverride = usePluginOverride;
55
67
  exports.usePluginOverrides = usePluginOverrides;
@@ -8,6 +8,7 @@ import { ReactNode } from 'react';
8
8
  */
9
9
  interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
10
10
  overrides: TPluginOverrides;
11
+ basePath: string;
11
12
  }
12
13
  /**
13
14
  * Provider component for BetterStack context
@@ -38,9 +39,10 @@ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>>
38
39
  * </BetterStackProvider>
39
40
  * ```
40
41
  */
41
- declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
42
- children: ReactNode;
42
+ declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, basePath, }: {
43
+ children?: ReactNode;
43
44
  overrides: TPluginOverrides;
45
+ basePath: string;
44
46
  }): react_jsx_runtime.JSX.Element;
45
47
  /**
46
48
  * Hook to access the entire context
@@ -82,5 +84,6 @@ declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOver
82
84
  * ```
83
85
  */
84
86
  declare function usePluginOverride<TOverride = any>(pluginName: string, overrideKey: string): TOverride;
87
+ declare function useBasePath(): string;
85
88
 
86
- export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides };
89
+ export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverride, usePluginOverrides };
@@ -8,6 +8,7 @@ import { ReactNode } from 'react';
8
8
  */
9
9
  interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
10
10
  overrides: TPluginOverrides;
11
+ basePath: string;
11
12
  }
12
13
  /**
13
14
  * Provider component for BetterStack context
@@ -38,9 +39,10 @@ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>>
38
39
  * </BetterStackProvider>
39
40
  * ```
40
41
  */
41
- declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
42
- children: ReactNode;
42
+ declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, basePath, }: {
43
+ children?: ReactNode;
43
44
  overrides: TPluginOverrides;
45
+ basePath: string;
44
46
  }): react_jsx_runtime.JSX.Element;
45
47
  /**
46
48
  * Hook to access the entire context
@@ -82,5 +84,6 @@ declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOver
82
84
  * ```
83
85
  */
84
86
  declare function usePluginOverride<TOverride = any>(pluginName: string, overrideKey: string): TOverride;
87
+ declare function useBasePath(): string;
85
88
 
86
- export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides };
89
+ export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverride, usePluginOverrides };
@@ -8,6 +8,7 @@ import { ReactNode } from 'react';
8
8
  */
9
9
  interface BetterStackContextValue<TPluginOverrides extends Record<string, any>> {
10
10
  overrides: TPluginOverrides;
11
+ basePath: string;
11
12
  }
12
13
  /**
13
14
  * Provider component for BetterStack context
@@ -38,9 +39,10 @@ interface BetterStackContextValue<TPluginOverrides extends Record<string, any>>
38
39
  * </BetterStackProvider>
39
40
  * ```
40
41
  */
41
- declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, }: {
42
- children: ReactNode;
42
+ declare function BetterStackProvider<TPluginOverrides extends Record<string, any> = Record<string, any>>({ children, overrides, basePath, }: {
43
+ children?: ReactNode;
43
44
  overrides: TPluginOverrides;
45
+ basePath: string;
44
46
  }): react_jsx_runtime.JSX.Element;
45
47
  /**
46
48
  * Hook to access the entire context
@@ -82,5 +84,6 @@ declare function usePluginOverrides<TOverrides = any>(pluginName: string): TOver
82
84
  * ```
83
85
  */
84
86
  declare function usePluginOverride<TOverride = any>(pluginName: string, overrideKey: string): TOverride;
87
+ declare function useBasePath(): string;
85
88
 
86
- export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides };
89
+ export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverride, usePluginOverrides };
@@ -7,10 +7,12 @@ const BetterStackContext = createContext(
7
7
  );
8
8
  function BetterStackProvider({
9
9
  children,
10
- overrides
10
+ overrides,
11
+ basePath
11
12
  }) {
12
13
  const value = {
13
- overrides
14
+ overrides,
15
+ basePath
14
16
  };
15
17
  return /* @__PURE__ */ jsx(BetterStackContext.Provider, { value, children });
16
18
  }
@@ -46,5 +48,14 @@ function usePluginOverride(pluginName, overrideKey) {
46
48
  }
47
49
  return override;
48
50
  }
51
+ function useBasePath() {
52
+ const context = useBetterStack();
53
+ if (!context) {
54
+ throw new Error(
55
+ "useBasePath must be used within BetterStackProvider. Wrap your app with <BetterStackProvider> in your layout file."
56
+ );
57
+ }
58
+ return context.basePath;
59
+ }
49
60
 
50
- export { BetterStackProvider, useBetterStack, usePluginOverride, usePluginOverrides };
61
+ export { BetterStackProvider, useBasePath, useBetterStack, usePluginOverride, usePluginOverrides };
package/dist/index.cjs CHANGED
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  const api_index = require('./api/index.cjs');
4
- require('better-call');
4
+ const betterCall = require('better-call');
5
5
  require('@btst/db');
6
6
 
7
7
 
8
8
 
9
9
  exports.betterStack = api_index.betterStack;
10
+ exports.createEndpoint = betterCall.createEndpoint;
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { betterStack } from './api/index.cjs';
2
- export { g as BackendLib, f as BackendLibConfig, B as BackendPlugin } from './shared/stack.Dva9muUy.cjs';
2
+ export { f as BackendLib, e as BackendLibConfig, B as BackendPlugin } from './shared/stack.DORw_1ps.cjs';
3
+ export { createEndpoint } from 'better-call';
3
4
  import '@btst/yar';
4
5
  import '@btst/db';
5
- import 'better-call';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { betterStack } from './api/index.mjs';
2
- export { g as BackendLib, f as BackendLibConfig, B as BackendPlugin } from './shared/stack.Dva9muUy.mjs';
2
+ export { f as BackendLib, e as BackendLibConfig, B as BackendPlugin } from './shared/stack.DORw_1ps.mjs';
3
+ export { createEndpoint } from 'better-call';
3
4
  import '@btst/yar';
4
5
  import '@btst/db';
5
- import 'better-call';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { betterStack } from './api/index.js';
2
- export { g as BackendLib, f as BackendLibConfig, B as BackendPlugin } from './shared/stack.Dva9muUy.js';
2
+ export { f as BackendLib, e as BackendLibConfig, B as BackendPlugin } from './shared/stack.DORw_1ps.js';
3
+ export { createEndpoint } from 'better-call';
3
4
  import '@btst/yar';
4
5
  import '@btst/db';
5
- import 'better-call';
package/dist/index.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  export { betterStack } from './api/index.mjs';
2
- import 'better-call';
2
+ export { createEndpoint } from 'better-call';
3
3
  import '@btst/db';
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const utils = require('../shared/stack.Br2KMECJ.cjs');
3
+ const utils = require('../shared/stack.CktCg4PJ.cjs');
4
4
  require('better-call/client');
5
5
 
6
6
  function defineClientPlugin(plugin) {
@@ -11,6 +11,5 @@ function defineBackendPlugin(plugin) {
11
11
  }
12
12
 
13
13
  exports.createApiClient = utils.createApiClient;
14
- exports.getServerBaseURL = utils.getServerBaseURL;
15
14
  exports.defineBackendPlugin = defineBackendPlugin;
16
15
  exports.defineClientPlugin = defineClientPlugin;
@@ -1,8 +1,8 @@
1
- import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.Dva9muUy.cjs';
2
- export { I as InferPluginOverrides, d as PluginOverrides } from '../shared/stack.Dva9muUy.cjs';
1
+ import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.DORw_1ps.cjs';
2
+ export { I as InferPluginOverrides, c as PluginOverrides } from '../shared/stack.DORw_1ps.cjs';
3
3
  import { Endpoint } from 'better-call';
4
4
  export { Endpoint, Router } from 'better-call';
5
- export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.cjs';
5
+ export { c as createApiClient } from '../shared/stack.DrUAVfIH.cjs';
6
6
  export { Adapter, DatabaseDefinition, DbPlugin } from '@btst/db';
7
7
  export { Route } from '@btst/yar';
8
8
  import 'better-call/client';
@@ -1,8 +1,8 @@
1
- import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.Dva9muUy.mjs';
2
- export { I as InferPluginOverrides, d as PluginOverrides } from '../shared/stack.Dva9muUy.mjs';
1
+ import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.DORw_1ps.mjs';
2
+ export { I as InferPluginOverrides, c as PluginOverrides } from '../shared/stack.DORw_1ps.mjs';
3
3
  import { Endpoint } from 'better-call';
4
4
  export { Endpoint, Router } from 'better-call';
5
- export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.mjs';
5
+ export { c as createApiClient } from '../shared/stack.DrUAVfIH.mjs';
6
6
  export { Adapter, DatabaseDefinition, DbPlugin } from '@btst/db';
7
7
  export { Route } from '@btst/yar';
8
8
  import 'better-call/client';
@@ -1,8 +1,8 @@
1
- import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.Dva9muUy.js';
2
- export { I as InferPluginOverrides, d as PluginOverrides } from '../shared/stack.Dva9muUy.js';
1
+ import { C as ClientPlugin, B as BackendPlugin } from '../shared/stack.DORw_1ps.js';
2
+ export { I as InferPluginOverrides, c as PluginOverrides } from '../shared/stack.DORw_1ps.js';
3
3
  import { Endpoint } from 'better-call';
4
4
  export { Endpoint, Router } from 'better-call';
5
- export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.DvFqFlOV.js';
5
+ export { c as createApiClient } from '../shared/stack.DrUAVfIH.js';
6
6
  export { Adapter, DatabaseDefinition, DbPlugin } from '@btst/db';
7
7
  export { Route } from '@btst/yar';
8
8
  import 'better-call/client';
@@ -1,4 +1,4 @@
1
- export { c as createApiClient, g as getServerBaseURL } from '../shared/stack.CwGEQ10b.mjs';
1
+ export { c as createApiClient } from '../shared/stack.3OUyGp_E.mjs';
2
2
  import 'better-call/client';
3
3
 
4
4
  function defineClientPlugin(plugin) {
@@ -1,7 +1,7 @@
1
1
  import { createClient } from 'better-call/client';
2
2
 
3
3
  function createApiClient(options) {
4
- const { baseURL = "", basePath = "/api" } = options ?? {};
4
+ const { baseURL = "", basePath = "/" } = options ?? {};
5
5
  const normalizedBaseURL = baseURL ? baseURL.replace(/\/$/, "") : "";
6
6
  const normalizedBasePath = basePath.startsWith("/") ? basePath : `/${basePath}`;
7
7
  const finalBasePath = normalizedBasePath.replace(/\/$/, "");
@@ -10,11 +10,5 @@ function createApiClient(options) {
10
10
  baseURL: apiPath
11
11
  });
12
12
  }
13
- function getServerBaseURL() {
14
- if (typeof window === "undefined") {
15
- return process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000";
16
- }
17
- return void 0;
18
- }
19
13
 
20
- export { createApiClient as c, getServerBaseURL as g };
14
+ export { createApiClient as c };
@@ -3,7 +3,7 @@
3
3
  const client = require('better-call/client');
4
4
 
5
5
  function createApiClient(options) {
6
- const { baseURL = "", basePath = "/api" } = options ?? {};
6
+ const { baseURL = "", basePath = "/" } = options ?? {};
7
7
  const normalizedBaseURL = baseURL ? baseURL.replace(/\/$/, "") : "";
8
8
  const normalizedBasePath = basePath.startsWith("/") ? basePath : `/${basePath}`;
9
9
  const finalBasePath = normalizedBasePath.replace(/\/$/, "");
@@ -12,12 +12,5 @@ function createApiClient(options) {
12
12
  baseURL: apiPath
13
13
  });
14
14
  }
15
- function getServerBaseURL() {
16
- if (typeof window === "undefined") {
17
- return process.env.NEXT_PUBLIC_BASE_URL || "http://localhost:3000";
18
- }
19
- return void 0;
20
- }
21
15
 
22
16
  exports.createApiClient = createApiClient;
23
- exports.getServerBaseURL = getServerBaseURL;
@@ -24,11 +24,6 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
24
24
  routes: (adapter: Adapter) => TRoutes;
25
25
  dbPlugin: DbPlugin;
26
26
  }
27
- /**
28
- * Hook function type
29
- * Generic function type for React hooks returned by plugins
30
- */
31
- type HookFunction = (...args: unknown[]) => unknown;
32
27
  /**
33
28
  * Frontend plugin definition
34
29
  * Defines pages, components, loaders, and React Query hooks for a feature
@@ -44,21 +39,12 @@ interface ClientPlugin<TOverrides = Record<string, never>, TRoutes extends Recor
44
39
  * Returns yar routes that will be composed into the router
45
40
  */
46
41
  routes: () => TRoutes;
47
- /**
48
- * Optional: Create React Query hooks for this plugin
49
- * These can be used directly in components without the loader
50
- */
51
- hooks?: () => Record<string, HookFunction>;
52
- /**
53
- * Optional: Default implementations for overridable components/functions
54
- * These will be used if no override is provided in BetterStackContext
55
- */
56
- defaultOverrides?: Partial<TOverrides>;
57
42
  }
58
43
  /**
59
44
  * Configuration for creating the backend library
60
45
  */
61
46
  interface BackendLibConfig<TPlugins extends Record<string, BackendPlugin<any>> = Record<string, BackendPlugin<any>>> {
47
+ basePath: string;
62
48
  dbSchema?: DatabaseDefinition;
63
49
  plugins: TPlugins;
64
50
  adapter: (db: DatabaseDefinition) => Adapter;
@@ -89,13 +75,6 @@ type PluginOverrides<TPlugins extends Record<string, ClientPlugin<any, any>>> =
89
75
  * Extract all routes from all client plugins, merging them into a single record
90
76
  */
91
77
  type PluginRoutes<TPlugins extends Record<string, ClientPlugin<any, any>>> = MergeAllPluginRoutes<TPlugins>;
92
- /**
93
- * Extract all hooks from all client plugins, organized by plugin name
94
- * For plugins without hooks, the type will be an empty object
95
- */
96
- type PluginHooks<TPlugins extends Record<string, ClientPlugin<any, any>>> = {
97
- [K in keyof TPlugins]: TPlugins[K]["hooks"] extends () => infer H ? H : {};
98
- };
99
78
  /**
100
79
  * Prefix all backend plugin route keys with the plugin name
101
80
  * Example: { messages: { list: Endpoint } } => { messages_list: Endpoint }
@@ -130,9 +109,8 @@ type UnionToIntersection<U> = (U extends unknown ? (k: U) => void : never) exten
130
109
  /**
131
110
  * Result of creating the client library
132
111
  */
133
- interface ClientLib<TRoutes extends Record<string, Route> = Record<string, Route>, THooks extends Record<string, any> = Record<string, any>> {
112
+ interface ClientLib<TRoutes extends Record<string, Route> = Record<string, Route>> {
134
113
  router: ReturnType<typeof createRouter<TRoutes, {}>>;
135
- hooks: THooks;
136
114
  }
137
115
 
138
- export type { BackendPlugin as B, ClientPlugin as C, InferPluginOverrides as I, PluginRoutes as P, PluginHooks as a, ClientLibConfig as b, ClientLib as c, PluginOverrides as d, PrefixedPluginRoutes as e, BackendLibConfig as f, BackendLib as g };
116
+ export type { BackendPlugin as B, ClientPlugin as C, InferPluginOverrides as I, PluginRoutes as P, ClientLibConfig as a, ClientLib as b, PluginOverrides as c, PrefixedPluginRoutes as d, BackendLibConfig as e, BackendLib as f };