@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
@@ -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 };
@@ -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 };
@@ -9,14 +9,9 @@ interface CreateApiClientOptions {
9
9
  * Creates a Better Call API client with proper URL handling for both server and client side
10
10
  * @param options - Configuration options
11
11
  * @param options.baseURL - The base URL (e.g., 'http://localhost:3000'). If not provided, uses relative URLs (same domain)
12
- * @param options.basePath - The API base path (defaults to '/api')
12
+ * @param options.basePath - The API base path (defaults to '/')
13
13
  * @template TRouter - The router type (Router or Record<string, Endpoint>)
14
14
  */
15
15
  declare function createApiClient<TRouter extends Router | Record<string, Endpoint> = Record<string, Endpoint>>(options?: CreateApiClientOptions): ReturnType<typeof createClient<TRouter>>;
16
- /**
17
- * Helper to get the server-side baseURL
18
- * On the server, we need an absolute URL. On the client, we can use relative URLs.
19
- */
20
- declare function getServerBaseURL(): string | undefined;
21
16
 
22
- export { createApiClient as c, getServerBaseURL as g };
17
+ export { createApiClient as c };
@@ -9,14 +9,9 @@ interface CreateApiClientOptions {
9
9
  * Creates a Better Call API client with proper URL handling for both server and client side
10
10
  * @param options - Configuration options
11
11
  * @param options.baseURL - The base URL (e.g., 'http://localhost:3000'). If not provided, uses relative URLs (same domain)
12
- * @param options.basePath - The API base path (defaults to '/api')
12
+ * @param options.basePath - The API base path (defaults to '/')
13
13
  * @template TRouter - The router type (Router or Record<string, Endpoint>)
14
14
  */
15
15
  declare function createApiClient<TRouter extends Router | Record<string, Endpoint> = Record<string, Endpoint>>(options?: CreateApiClientOptions): ReturnType<typeof createClient<TRouter>>;
16
- /**
17
- * Helper to get the server-side baseURL
18
- * On the server, we need an absolute URL. On the client, we can use relative URLs.
19
- */
20
- declare function getServerBaseURL(): string | undefined;
21
16
 
22
- export { createApiClient as c, getServerBaseURL as g };
17
+ export { createApiClient as c };
@@ -9,14 +9,9 @@ interface CreateApiClientOptions {
9
9
  * Creates a Better Call API client with proper URL handling for both server and client side
10
10
  * @param options - Configuration options
11
11
  * @param options.baseURL - The base URL (e.g., 'http://localhost:3000'). If not provided, uses relative URLs (same domain)
12
- * @param options.basePath - The API base path (defaults to '/api')
12
+ * @param options.basePath - The API base path (defaults to '/')
13
13
  * @template TRouter - The router type (Router or Record<string, Endpoint>)
14
14
  */
15
15
  declare function createApiClient<TRouter extends Router | Record<string, Endpoint> = Record<string, Endpoint>>(options?: CreateApiClientOptions): ReturnType<typeof createClient<TRouter>>;
16
- /**
17
- * Helper to get the server-side baseURL
18
- * On the server, we need an absolute URL. On the client, we can use relative URLs.
19
- */
20
- declare function getServerBaseURL(): string | undefined;
21
16
 
22
- export { createApiClient as c, getServerBaseURL as g };
17
+ export { createApiClient as c };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@btst/stack",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "A composable, plugin-based library for building full-stack applications.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -102,7 +102,7 @@
102
102
  },
103
103
  "dependencies": {
104
104
  "@btst/db": "1.0.2",
105
- "@btst/yar": "1.1.0",
105
+ "@btst/yar": "1.1.1",
106
106
  "better-call": "1.0.19",
107
107
  "zod": "^4.1.5"
108
108
  },
@@ -114,7 +114,7 @@
114
114
  "devDependencies": {
115
115
  "@btst/adapter-memory": "1.0.2",
116
116
  "@tanstack/react-query": "^5.0.0",
117
- "@types/react": "^18.3.23",
117
+ "@types/react": "^19.0.0",
118
118
  "react": "^19.1.1",
119
119
  "react-dom": "^19.1.1",
120
120
  "typescript": "catalog:",