@btst/stack 2.1.0 → 2.3.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.
Files changed (229) hide show
  1. package/dist/api/index.cjs +9 -1
  2. package/dist/api/index.d.cts +4 -4
  3. package/dist/api/index.d.mts +4 -4
  4. package/dist/api/index.d.ts +4 -4
  5. package/dist/api/index.mjs +9 -1
  6. package/dist/client/index.d.cts +2 -2
  7. package/dist/client/index.d.mts +2 -2
  8. package/dist/client/index.d.ts +2 -2
  9. package/dist/index.d.cts +1 -1
  10. package/dist/index.d.mts +1 -1
  11. package/dist/index.d.ts +1 -1
  12. package/dist/packages/stack/src/plugins/ai-chat/api/getters.cjs +42 -0
  13. package/dist/packages/stack/src/plugins/ai-chat/api/getters.mjs +39 -0
  14. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +5 -0
  15. package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +5 -0
  16. package/dist/packages/stack/src/plugins/blog/api/getters.cjs +131 -0
  17. package/dist/packages/stack/src/plugins/blog/api/getters.mjs +127 -0
  18. package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +60 -107
  19. package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +60 -107
  20. package/dist/packages/stack/src/plugins/blog/api/query-key-defs.cjs +18 -0
  21. package/dist/packages/stack/src/plugins/blog/api/query-key-defs.mjs +15 -0
  22. package/dist/packages/stack/src/plugins/blog/api/serializers.cjs +21 -0
  23. package/dist/packages/stack/src/plugins/blog/api/serializers.mjs +18 -0
  24. package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +16 -1
  25. package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +17 -2
  26. package/dist/packages/stack/src/plugins/cms/api/getters.cjs +156 -0
  27. package/dist/packages/stack/src/plugins/cms/api/getters.mjs +147 -0
  28. package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +624 -617
  29. package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +623 -616
  30. package/dist/packages/stack/src/plugins/cms/api/query-key-defs.cjs +29 -0
  31. package/dist/packages/stack/src/plugins/cms/api/query-key-defs.mjs +26 -0
  32. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +1 -1
  33. package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +1 -1
  34. package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.cjs +6 -3
  35. package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.mjs +6 -3
  36. package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +15 -0
  37. package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +16 -1
  38. package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +120 -0
  39. package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +112 -0
  40. package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +75 -86
  41. package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +71 -82
  42. package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +37 -0
  43. package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +33 -0
  44. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +1 -1
  45. package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +1 -1
  46. package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +15 -0
  47. package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +16 -1
  48. package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +84 -0
  49. package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +81 -0
  50. package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +37 -123
  51. package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +37 -123
  52. package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.cjs +26 -0
  53. package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.mjs +23 -0
  54. package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +30 -0
  55. package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +26 -0
  56. package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +11 -1
  57. package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +12 -2
  58. package/dist/packages/stack/src/plugins/utils.cjs +6 -0
  59. package/dist/packages/stack/src/plugins/utils.mjs +6 -1
  60. package/dist/plugins/ai-chat/api/index.cjs +3 -0
  61. package/dist/plugins/ai-chat/api/index.d.cts +27 -4
  62. package/dist/plugins/ai-chat/api/index.d.mts +27 -4
  63. package/dist/plugins/ai-chat/api/index.d.ts +27 -4
  64. package/dist/plugins/ai-chat/api/index.mjs +1 -0
  65. package/dist/plugins/ai-chat/client/hooks/index.d.cts +2 -2
  66. package/dist/plugins/ai-chat/client/hooks/index.d.mts +2 -2
  67. package/dist/plugins/ai-chat/client/hooks/index.d.ts +2 -2
  68. package/dist/plugins/ai-chat/query-keys.d.cts +9 -284
  69. package/dist/plugins/ai-chat/query-keys.d.mts +9 -284
  70. package/dist/plugins/ai-chat/query-keys.d.ts +9 -284
  71. package/dist/plugins/api/index.d.cts +4 -3
  72. package/dist/plugins/api/index.d.mts +4 -3
  73. package/dist/plugins/api/index.d.ts +4 -3
  74. package/dist/plugins/blog/api/index.cjs +9 -0
  75. package/dist/plugins/blog/api/index.d.cts +20 -4
  76. package/dist/plugins/blog/api/index.d.mts +20 -4
  77. package/dist/plugins/blog/api/index.d.ts +20 -4
  78. package/dist/plugins/blog/api/index.mjs +3 -0
  79. package/dist/plugins/blog/client/hooks/index.d.cts +5 -5
  80. package/dist/plugins/blog/client/hooks/index.d.mts +5 -5
  81. package/dist/plugins/blog/client/hooks/index.d.ts +5 -5
  82. package/dist/plugins/blog/client/index.d.cts +1 -1
  83. package/dist/plugins/blog/client/index.d.mts +1 -1
  84. package/dist/plugins/blog/client/index.d.ts +1 -1
  85. package/dist/plugins/blog/query-keys.cjs +13 -9
  86. package/dist/plugins/blog/query-keys.d.cts +8 -333
  87. package/dist/plugins/blog/query-keys.d.mts +8 -333
  88. package/dist/plugins/blog/query-keys.d.ts +8 -333
  89. package/dist/plugins/blog/query-keys.mjs +13 -9
  90. package/dist/plugins/client/index.cjs +1 -0
  91. package/dist/plugins/client/index.d.cts +10 -3
  92. package/dist/plugins/client/index.d.mts +10 -3
  93. package/dist/plugins/client/index.d.ts +10 -3
  94. package/dist/plugins/client/index.mjs +1 -1
  95. package/dist/plugins/cms/api/index.cjs +10 -0
  96. package/dist/plugins/cms/api/index.d.cts +7 -163
  97. package/dist/plugins/cms/api/index.d.mts +7 -163
  98. package/dist/plugins/cms/api/index.d.ts +7 -163
  99. package/dist/plugins/cms/api/index.mjs +2 -0
  100. package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
  101. package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
  102. package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
  103. package/dist/plugins/cms/query-keys.cjs +2 -1
  104. package/dist/plugins/cms/query-keys.d.cts +6 -9
  105. package/dist/plugins/cms/query-keys.d.mts +6 -9
  106. package/dist/plugins/cms/query-keys.d.ts +6 -9
  107. package/dist/plugins/cms/query-keys.mjs +2 -1
  108. package/dist/plugins/form-builder/api/index.cjs +10 -0
  109. package/dist/plugins/form-builder/api/index.d.cts +7 -141
  110. package/dist/plugins/form-builder/api/index.d.mts +7 -141
  111. package/dist/plugins/form-builder/api/index.d.ts +7 -141
  112. package/dist/plugins/form-builder/api/index.mjs +2 -0
  113. package/dist/plugins/form-builder/client/components/index.d.cts +1 -1
  114. package/dist/plugins/form-builder/client/components/index.d.mts +1 -1
  115. package/dist/plugins/form-builder/client/components/index.d.ts +1 -1
  116. package/dist/plugins/form-builder/client/hooks/index.d.cts +1 -1
  117. package/dist/plugins/form-builder/client/hooks/index.d.mts +1 -1
  118. package/dist/plugins/form-builder/client/hooks/index.d.ts +1 -1
  119. package/dist/plugins/form-builder/query-keys.cjs +3 -2
  120. package/dist/plugins/form-builder/query-keys.d.cts +7 -6
  121. package/dist/plugins/form-builder/query-keys.d.mts +7 -6
  122. package/dist/plugins/form-builder/query-keys.d.ts +7 -6
  123. package/dist/plugins/form-builder/query-keys.mjs +3 -2
  124. package/dist/plugins/kanban/api/index.cjs +9 -0
  125. package/dist/plugins/kanban/api/index.d.cts +17 -395
  126. package/dist/plugins/kanban/api/index.d.mts +17 -395
  127. package/dist/plugins/kanban/api/index.d.ts +17 -395
  128. package/dist/plugins/kanban/api/index.mjs +3 -0
  129. package/dist/plugins/kanban/client/components/index.d.cts +1 -1
  130. package/dist/plugins/kanban/client/components/index.d.mts +1 -1
  131. package/dist/plugins/kanban/client/components/index.d.ts +1 -1
  132. package/dist/plugins/kanban/client/hooks/index.d.cts +1 -1
  133. package/dist/plugins/kanban/client/hooks/index.d.mts +1 -1
  134. package/dist/plugins/kanban/client/hooks/index.d.ts +1 -1
  135. package/dist/plugins/kanban/client/index.d.cts +1 -1
  136. package/dist/plugins/kanban/client/index.d.mts +1 -1
  137. package/dist/plugins/kanban/client/index.d.ts +1 -1
  138. package/dist/plugins/kanban/query-keys.cjs +6 -12
  139. package/dist/plugins/kanban/query-keys.d.cts +5 -16
  140. package/dist/plugins/kanban/query-keys.d.mts +5 -16
  141. package/dist/plugins/kanban/query-keys.d.ts +5 -16
  142. package/dist/plugins/kanban/query-keys.mjs +6 -12
  143. package/dist/plugins/open-api/api/index.d.cts +2 -2
  144. package/dist/plugins/open-api/api/index.d.mts +2 -2
  145. package/dist/plugins/open-api/api/index.d.ts +2 -2
  146. package/dist/plugins/route-docs/client/index.d.cts +1 -1
  147. package/dist/plugins/route-docs/client/index.d.mts +1 -1
  148. package/dist/plugins/route-docs/client/index.d.ts +1 -1
  149. package/dist/plugins/ui-builder/index.d.cts +1 -1
  150. package/dist/plugins/ui-builder/index.d.mts +1 -1
  151. package/dist/plugins/ui-builder/index.d.ts +1 -1
  152. package/dist/shared/{stack.BoA0xkJv.d.cts → stack.7n9Y_u7N.d.cts} +33 -7
  153. package/dist/shared/{stack.BoA0xkJv.d.mts → stack.7n9Y_u7N.d.mts} +33 -7
  154. package/dist/shared/{stack.BoA0xkJv.d.ts → stack.7n9Y_u7N.d.ts} +33 -7
  155. package/dist/shared/stack.B1EeBt1b.d.ts +297 -0
  156. package/dist/shared/stack.BIXEI6v_.d.mts +419 -0
  157. package/dist/shared/stack.BKfolAyK.d.ts +419 -0
  158. package/dist/shared/stack.BeSm90va.d.ts +289 -0
  159. package/dist/shared/stack.BpolpQpf.d.cts +445 -0
  160. package/dist/shared/stack.C5dtIncc.d.mts +293 -0
  161. package/dist/shared/stack.CIP6QS9l.d.ts +293 -0
  162. package/dist/shared/stack.CMh_EdxW.d.cts +289 -0
  163. package/dist/shared/stack.CP68pFEH.d.mts +297 -0
  164. package/dist/shared/{stack.BsXokfNh.d.mts → stack.CVDTkMoO.d.cts} +8 -2
  165. package/dist/shared/{stack.BsXokfNh.d.ts → stack.CVDTkMoO.d.mts} +8 -2
  166. package/dist/shared/{stack.BsXokfNh.d.cts → stack.CVDTkMoO.d.ts} +8 -2
  167. package/dist/shared/{stack.DKDMI-QO.d.mts → stack.DJaKVY7v.d.cts} +7 -1
  168. package/dist/shared/{stack.DKDMI-QO.d.ts → stack.DJaKVY7v.d.mts} +7 -1
  169. package/dist/shared/{stack.DKDMI-QO.d.cts → stack.DJaKVY7v.d.ts} +7 -1
  170. package/dist/shared/{stack.DzH_wcvr.d.mts → stack.DdI5W6MB.d.cts} +9 -3
  171. package/dist/shared/{stack.DzH_wcvr.d.ts → stack.DdI5W6MB.d.mts} +9 -3
  172. package/dist/shared/{stack.DzH_wcvr.d.cts → stack.DdI5W6MB.d.ts} +9 -3
  173. package/dist/shared/stack.Dg09R0oB.d.mts +289 -0
  174. package/dist/shared/stack.Dw0Ly2TM.d.cts +293 -0
  175. package/dist/shared/stack.IdtKDRka.d.cts +297 -0
  176. package/dist/shared/stack.TIBF2AOx.d.ts +445 -0
  177. package/dist/shared/stack.rTy7-wQU.d.mts +445 -0
  178. package/dist/shared/stack.snB1EDP7.d.cts +419 -0
  179. package/package.json +3 -3
  180. package/src/__tests__/stack-api.test.ts +118 -0
  181. package/src/api/index.ts +15 -1
  182. package/src/plugins/ai-chat/__tests__/getters.test.ts +109 -0
  183. package/src/plugins/ai-chat/api/getters.ts +71 -0
  184. package/src/plugins/ai-chat/api/index.ts +1 -0
  185. package/src/plugins/ai-chat/api/plugin.ts +8 -0
  186. package/src/plugins/api/index.ts +3 -1
  187. package/src/plugins/blog/__tests__/getters.test.ts +540 -0
  188. package/src/plugins/blog/api/getters.ts +243 -0
  189. package/src/plugins/blog/api/index.ts +9 -0
  190. package/src/plugins/blog/api/plugin.ts +98 -141
  191. package/src/plugins/blog/api/query-key-defs.ts +46 -0
  192. package/src/plugins/blog/api/serializers.ts +27 -0
  193. package/src/plugins/blog/client/plugin.tsx +21 -1
  194. package/src/plugins/blog/query-keys.ts +21 -20
  195. package/src/plugins/client/index.ts +1 -1
  196. package/src/plugins/cms/__tests__/getters.test.ts +206 -0
  197. package/src/plugins/cms/api/getters.ts +268 -0
  198. package/src/plugins/cms/api/index.ts +15 -1
  199. package/src/plugins/cms/api/plugin.ts +151 -150
  200. package/src/plugins/cms/api/query-key-defs.ts +53 -0
  201. package/src/plugins/cms/api/serializers.ts +12 -0
  202. package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +1 -1
  203. package/src/plugins/cms/client/hooks/cms-hooks.tsx +3 -0
  204. package/src/plugins/cms/client/plugin.tsx +19 -0
  205. package/src/plugins/cms/query-keys.ts +2 -1
  206. package/src/plugins/cms/types.ts +1 -1
  207. package/src/plugins/form-builder/__tests__/getters.test.ts +159 -0
  208. package/src/plugins/form-builder/api/getters.ts +226 -0
  209. package/src/plugins/form-builder/api/index.ts +15 -1
  210. package/src/plugins/form-builder/api/plugin.ts +107 -109
  211. package/src/plugins/form-builder/api/query-key-defs.ts +79 -0
  212. package/src/plugins/form-builder/api/serializers.ts +12 -0
  213. package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +1 -1
  214. package/src/plugins/form-builder/client/plugin.tsx +19 -0
  215. package/src/plugins/form-builder/query-keys.ts +6 -2
  216. package/src/plugins/form-builder/types.ts +2 -2
  217. package/src/plugins/kanban/__tests__/getters.test.ts +172 -0
  218. package/src/plugins/kanban/api/getters.ts +149 -0
  219. package/src/plugins/kanban/api/index.ts +4 -0
  220. package/src/plugins/kanban/api/plugin.ts +65 -146
  221. package/src/plugins/kanban/api/query-key-defs.ts +54 -0
  222. package/src/plugins/kanban/api/serializers.ts +49 -0
  223. package/src/plugins/kanban/client/plugin.tsx +15 -1
  224. package/src/plugins/kanban/query-keys.ts +10 -14
  225. package/src/plugins/utils.ts +19 -0
  226. package/src/types.ts +44 -5
  227. package/dist/shared/{stack.CbuN2zVV.d.cts → stack.CBON0dWL.d.cts} +7 -7
  228. package/dist/shared/{stack.CbuN2zVV.d.mts → stack.CBON0dWL.d.mts} +7 -7
  229. package/dist/shared/{stack.CbuN2zVV.d.ts → stack.CBON0dWL.d.ts} +7 -7
@@ -1,9 +1,10 @@
1
1
  import * as _tanstack_react_query from '@tanstack/react-query';
2
+ import { K as KanbanApiRouter, f as BoardsListDiscriminator } from '../../shared/stack.TIBF2AOx.js';
2
3
  import { createApiClient } from '@btst/stack/plugins/client';
3
- import { S as SerializedBoardWithColumns } from '../../shared/stack.DKDMI-QO.js';
4
- import { KanbanApiRouter } from './api/index.js';
4
+ import { S as SerializedBoardWithColumns } from '../../shared/stack.DJaKVY7v.js';
5
5
  import '@btst/stack/plugins/api';
6
6
  import 'better-call';
7
+ import '@btst/db';
7
8
  import 'zod';
8
9
 
9
10
  interface BoardsListParams {
@@ -18,20 +19,8 @@ declare function createKanbanQueryKeys(client: ReturnType<typeof createApiClient
18
19
  _def: readonly ["boards"];
19
20
  } & {
20
21
  list: ((params?: BoardsListParams | undefined) => Omit<{
21
- queryKey: readonly ["boards", "list", {
22
- slug: string | undefined;
23
- ownerId: string | undefined;
24
- organizationId: string | undefined;
25
- limit: number;
26
- offset: number;
27
- }];
28
- queryFn: _tanstack_react_query.QueryFunction<SerializedBoardWithColumns[], readonly ["boards", "list", {
29
- slug: string | undefined;
30
- ownerId: string | undefined;
31
- organizationId: string | undefined;
32
- limit: number;
33
- offset: number;
34
- }]>;
22
+ queryKey: readonly ["boards", "list", BoardsListDiscriminator];
23
+ queryFn: _tanstack_react_query.QueryFunction<SerializedBoardWithColumns[], readonly ["boards", "list", BoardsListDiscriminator]>;
35
24
  } & {
36
25
  _def: readonly ["boards", "list"];
37
26
  }, "_def">) & {
@@ -1,4 +1,5 @@
1
1
  import { mergeQueryKeys, createQueryKeys } from '@lukemorales/query-key-factory';
2
+ import { boardsListDiscriminator } from '../../packages/stack/src/plugins/kanban/api/query-key-defs.mjs';
2
3
 
3
4
  function isErrorResponse(response) {
4
5
  return typeof response === "object" && response !== null && "error" in response && response.error !== null && response.error !== void 0;
@@ -23,15 +24,7 @@ function createKanbanQueryKeys(client, headers) {
23
24
  function createBoardsQueries(client, headers) {
24
25
  return createQueryKeys("boards", {
25
26
  list: (params) => ({
26
- queryKey: [
27
- {
28
- slug: params?.slug,
29
- ownerId: params?.ownerId,
30
- organizationId: params?.organizationId,
31
- limit: params?.limit ?? 50,
32
- offset: params?.offset ?? 0
33
- }
34
- ],
27
+ queryKey: [boardsListDiscriminator(params)],
35
28
  queryFn: async () => {
36
29
  try {
37
30
  const response = await client("/boards", {
@@ -49,7 +42,8 @@ function createBoardsQueries(client, headers) {
49
42
  const errorResponse = response;
50
43
  throw toError(errorResponse.error);
51
44
  }
52
- return response.data ?? [];
45
+ const envelope = response.data;
46
+ return envelope?.items ?? [];
53
47
  } catch (error) {
54
48
  throw error;
55
49
  }
@@ -90,8 +84,8 @@ function createBoardsQueries(client, headers) {
90
84
  const errorResponse = response;
91
85
  throw toError(errorResponse.error);
92
86
  }
93
- const boards = response.data ?? [];
94
- return boards[0] ?? null;
87
+ const envelope = response.data;
88
+ return envelope?.items?.[0] ?? null;
95
89
  } catch (error) {
96
90
  throw error;
97
91
  }
@@ -1,6 +1,6 @@
1
1
  import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
2
2
  import * as better_call from 'better-call';
3
- import { S as StackContext } from '../../../shared/stack.BoA0xkJv.cjs';
3
+ import { S as StackContext } from '../../../shared/stack.7n9Y_u7N.cjs';
4
4
  import '@btst/yar';
5
5
  import '@btst/db';
6
6
 
@@ -79,7 +79,7 @@ declare const openApiBackendPlugin: (options?: OpenAPIOptions) => _btst_stack_pl
79
79
  readonly reference: better_call.StrictEndpoint<string, {
80
80
  method: "GET";
81
81
  }, Response>;
82
- }>;
82
+ }, never>;
83
83
  type OpenApiRouter = ReturnType<ReturnType<typeof openApiBackendPlugin>["routes"]>;
84
84
 
85
85
  /**
@@ -1,6 +1,6 @@
1
1
  import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
2
2
  import * as better_call from 'better-call';
3
- import { S as StackContext } from '../../../shared/stack.BoA0xkJv.mjs';
3
+ import { S as StackContext } from '../../../shared/stack.7n9Y_u7N.mjs';
4
4
  import '@btst/yar';
5
5
  import '@btst/db';
6
6
 
@@ -79,7 +79,7 @@ declare const openApiBackendPlugin: (options?: OpenAPIOptions) => _btst_stack_pl
79
79
  readonly reference: better_call.StrictEndpoint<string, {
80
80
  method: "GET";
81
81
  }, Response>;
82
- }>;
82
+ }, never>;
83
83
  type OpenApiRouter = ReturnType<ReturnType<typeof openApiBackendPlugin>["routes"]>;
84
84
 
85
85
  /**
@@ -1,6 +1,6 @@
1
1
  import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
2
2
  import * as better_call from 'better-call';
3
- import { S as StackContext } from '../../../shared/stack.BoA0xkJv.js';
3
+ import { S as StackContext } from '../../../shared/stack.7n9Y_u7N.js';
4
4
  import '@btst/yar';
5
5
  import '@btst/db';
6
6
 
@@ -79,7 +79,7 @@ declare const openApiBackendPlugin: (options?: OpenAPIOptions) => _btst_stack_pl
79
79
  readonly reference: better_call.StrictEndpoint<string, {
80
80
  method: "GET";
81
81
  }, Response>;
82
- }>;
82
+ }, never>;
83
83
  type OpenApiRouter = ReturnType<ReturnType<typeof openApiBackendPlugin>["routes"]>;
84
84
 
85
85
  /**
@@ -2,7 +2,7 @@ import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import * as react from 'react';
3
3
  import * as _btst_yar from '@btst/yar';
4
4
  import { QueryClient } from '@tanstack/react-query';
5
- import { a as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.BoA0xkJv.cjs';
5
+ import { a as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.7n9Y_u7N.cjs';
6
6
  import '@btst/db';
7
7
  import 'better-call';
8
8
 
@@ -2,7 +2,7 @@ import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import * as react from 'react';
3
3
  import * as _btst_yar from '@btst/yar';
4
4
  import { QueryClient } from '@tanstack/react-query';
5
- import { a as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.BoA0xkJv.mjs';
5
+ import { a as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.7n9Y_u7N.mjs';
6
6
  import '@btst/db';
7
7
  import 'better-call';
8
8
 
@@ -2,7 +2,7 @@ import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
2
2
  import * as react from 'react';
3
3
  import * as _btst_yar from '@btst/yar';
4
4
  import { QueryClient } from '@tanstack/react-query';
5
- import { a as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.BoA0xkJv.js';
5
+ import { a as SitemapEntry, b as ClientStackContext } from '../../../shared/stack.7n9Y_u7N.js';
6
6
  import '@btst/db';
7
7
  import 'better-call';
8
8
 
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { C as ContentTypeConfig } from '../../shared/stack.BsXokfNh.cjs';
2
+ import { C as ContentTypeConfig } from '../../shared/stack.CVDTkMoO.cjs';
3
3
  export { L as LoaderContext, b as PaginatedUIBuilderPages, P as ParsedUIBuilderPage, S as SerializedUIBuilderPage, c as UIBuilderClientHooks, a as UIBuilderPage, U as UIBuilderPageData } from '../../shared/stack.C-WUPMT6.cjs';
4
4
  export { C as ComponentLayer, a as ComponentRegistry, R as RegistryEntry, V as Variable } from '../../shared/stack.B-YHz18S.cjs';
5
5
  import 'react';
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { C as ContentTypeConfig } from '../../shared/stack.BsXokfNh.mjs';
2
+ import { C as ContentTypeConfig } from '../../shared/stack.CVDTkMoO.mjs';
3
3
  export { L as LoaderContext, b as PaginatedUIBuilderPages, P as ParsedUIBuilderPage, S as SerializedUIBuilderPage, c as UIBuilderClientHooks, a as UIBuilderPage, U as UIBuilderPageData } from '../../shared/stack.6fUOjLs9.mjs';
4
4
  export { C as ComponentLayer, a as ComponentRegistry, R as RegistryEntry, V as Variable } from '../../shared/stack.D1DMlJp-.mjs';
5
5
  import 'react';
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { C as ContentTypeConfig } from '../../shared/stack.BsXokfNh.js';
2
+ import { C as ContentTypeConfig } from '../../shared/stack.CVDTkMoO.js';
3
3
  export { L as LoaderContext, b as PaginatedUIBuilderPages, P as ParsedUIBuilderPage, S as SerializedUIBuilderPage, c as UIBuilderClientHooks, a as UIBuilderPage, U as UIBuilderPageData } from '../../shared/stack.C-Ptrz8s.js';
4
4
  export { C as ComponentLayer, a as ComponentRegistry, R as RegistryEntry, V as Variable } from '../../shared/stack.GygI_T3X.js';
5
5
  import 'react';
@@ -8,7 +8,7 @@ import { Endpoint, Router } from 'better-call';
8
8
  */
9
9
  interface StackContext {
10
10
  /** All registered backend plugins */
11
- plugins: Record<string, BackendPlugin<any>>;
11
+ plugins: Record<string, BackendPlugin<any, any>>;
12
12
  /** The API base path (e.g., "/api/data") */
13
13
  basePath: string;
14
14
  /** The database adapter */
@@ -33,8 +33,11 @@ interface ClientStackContext<TPlugins extends Record<string, ClientPlugin<any, a
33
33
  * You can optionally provide a base schema via the dbSchema config option.
34
34
  *
35
35
  * @template TRoutes - The exact shape of routes this plugin provides (preserves keys and endpoint types)
36
+ * @template TApi - The shape of the server-side API surface exposed via `stack().api`.
37
+ * Defaults to `never` so that plugins without an `api` factory are excluded from the
38
+ * `stack().api` namespace entirely, preventing accidental access of `undefined` at runtime.
36
39
  */
37
- interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>> {
40
+ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>, TApi extends Record<string, (...args: any[]) => any> = never> {
38
41
  name: string;
39
42
  /**
40
43
  * Create API endpoints for this plugin
@@ -46,6 +49,14 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
46
49
  */
47
50
  routes: (adapter: Adapter, context?: StackContext) => TRoutes;
48
51
  dbPlugin: DbPlugin;
52
+ /**
53
+ * Optional factory that returns server-side getter functions bound to the adapter.
54
+ * The returned object is merged into `stack().api.<pluginName>.*` for direct
55
+ * server-side or SSG data access without going through HTTP.
56
+ *
57
+ * @param adapter - The adapter instance shared with `routes`
58
+ */
59
+ api?: (adapter: Adapter) => TApi;
49
60
  }
50
61
  /**
51
62
  * Frontend plugin definition
@@ -70,10 +81,21 @@ interface ClientPlugin<TOverrides = Record<string, never>, TRoutes extends Recor
70
81
  */
71
82
  sitemap?: () => Promise<Sitemap> | Sitemap;
72
83
  }
84
+ /**
85
+ * Utility type that maps each plugin key to the return type of its `api` factory.
86
+ * Plugin keys whose `TApi` resolves to `never` (i.e. plugins with no `api` factory)
87
+ * are excluded from the resulting type via key remapping, preventing TypeScript from
88
+ * suggesting callable functions on what is actually `undefined` at runtime.
89
+ */
90
+ type PluginApis<TPlugins extends Record<string, BackendPlugin<any, any>>> = {
91
+ [K in keyof TPlugins as _ApiOf<TPlugins[K]> extends never ? never : K]: _ApiOf<TPlugins[K]>;
92
+ };
93
+ /** @internal Extract the TApi parameter from a BackendPlugin type. */
94
+ type _ApiOf<T> = T extends BackendPlugin<any, infer TApi> ? TApi : never;
73
95
  /**
74
96
  * Configuration for creating the backend library
75
97
  */
76
- interface BackendLibConfig<TPlugins extends Record<string, BackendPlugin<any>> = Record<string, BackendPlugin<any>>> {
98
+ interface BackendLibConfig<TPlugins extends Record<string, BackendPlugin<any, any>> = Record<string, BackendPlugin<any, any>>> {
77
99
  basePath: string;
78
100
  dbSchema?: DatabaseDefinition;
79
101
  plugins: TPlugins;
@@ -109,18 +131,22 @@ type PluginRoutes<TPlugins extends Record<string, ClientPlugin<any, any>>> = Mer
109
131
  * Prefix all backend plugin route keys with the plugin name
110
132
  * Example: { messages: { list: Endpoint } } => { messages_list: Endpoint }
111
133
  */
112
- type PrefixedPluginRoutes<TPlugins extends Record<string, BackendPlugin<any>>> = UnionToIntersection<{
113
- [PluginKey in keyof TPlugins]: TPlugins[PluginKey] extends BackendPlugin<infer TRoutes> ? {
134
+ type PrefixedPluginRoutes<TPlugins extends Record<string, BackendPlugin<any, any>>> = UnionToIntersection<{
135
+ [PluginKey in keyof TPlugins]: TPlugins[PluginKey] extends BackendPlugin<infer TRoutes, any> ? {
114
136
  [RouteKey in keyof TRoutes as `${PluginKey & string}_${RouteKey & string}`]: TRoutes[RouteKey];
115
137
  } : never;
116
138
  }[keyof TPlugins]> extends infer U ? U extends Record<string, Endpoint> ? U : Record<string, Endpoint> : Record<string, Endpoint>;
117
139
  /**
118
140
  * Result of creating the backend library
119
141
  */
120
- interface BackendLib<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>> {
142
+ interface BackendLib<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>, TApis extends Record<string, Record<string, (...args: any[]) => any>> = Record<string, Record<string, (...args: any[]) => any>>> {
121
143
  handler: (request: Request) => Promise<Response>;
122
144
  router: Router;
123
145
  dbSchema: DatabaseDefinition;
146
+ /** The database adapter shared across all plugins */
147
+ adapter: Adapter;
148
+ /** Fully-typed server-side getter functions, namespaced per plugin */
149
+ api: TApis;
124
150
  }
125
151
  /**
126
152
  * Helper type to extract routes from a client plugin
@@ -154,4 +180,4 @@ type SitemapEntry = {
154
180
  };
155
181
  type Sitemap = Array<SitemapEntry>;
156
182
 
157
- export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, StackContext as S, SitemapEntry 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 };
183
+ export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, StackContext as S, SitemapEntry 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, PluginApis as j };
@@ -8,7 +8,7 @@ import { Endpoint, Router } from 'better-call';
8
8
  */
9
9
  interface StackContext {
10
10
  /** All registered backend plugins */
11
- plugins: Record<string, BackendPlugin<any>>;
11
+ plugins: Record<string, BackendPlugin<any, any>>;
12
12
  /** The API base path (e.g., "/api/data") */
13
13
  basePath: string;
14
14
  /** The database adapter */
@@ -33,8 +33,11 @@ interface ClientStackContext<TPlugins extends Record<string, ClientPlugin<any, a
33
33
  * You can optionally provide a base schema via the dbSchema config option.
34
34
  *
35
35
  * @template TRoutes - The exact shape of routes this plugin provides (preserves keys and endpoint types)
36
+ * @template TApi - The shape of the server-side API surface exposed via `stack().api`.
37
+ * Defaults to `never` so that plugins without an `api` factory are excluded from the
38
+ * `stack().api` namespace entirely, preventing accidental access of `undefined` at runtime.
36
39
  */
37
- interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>> {
40
+ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>, TApi extends Record<string, (...args: any[]) => any> = never> {
38
41
  name: string;
39
42
  /**
40
43
  * Create API endpoints for this plugin
@@ -46,6 +49,14 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
46
49
  */
47
50
  routes: (adapter: Adapter, context?: StackContext) => TRoutes;
48
51
  dbPlugin: DbPlugin;
52
+ /**
53
+ * Optional factory that returns server-side getter functions bound to the adapter.
54
+ * The returned object is merged into `stack().api.<pluginName>.*` for direct
55
+ * server-side or SSG data access without going through HTTP.
56
+ *
57
+ * @param adapter - The adapter instance shared with `routes`
58
+ */
59
+ api?: (adapter: Adapter) => TApi;
49
60
  }
50
61
  /**
51
62
  * Frontend plugin definition
@@ -70,10 +81,21 @@ interface ClientPlugin<TOverrides = Record<string, never>, TRoutes extends Recor
70
81
  */
71
82
  sitemap?: () => Promise<Sitemap> | Sitemap;
72
83
  }
84
+ /**
85
+ * Utility type that maps each plugin key to the return type of its `api` factory.
86
+ * Plugin keys whose `TApi` resolves to `never` (i.e. plugins with no `api` factory)
87
+ * are excluded from the resulting type via key remapping, preventing TypeScript from
88
+ * suggesting callable functions on what is actually `undefined` at runtime.
89
+ */
90
+ type PluginApis<TPlugins extends Record<string, BackendPlugin<any, any>>> = {
91
+ [K in keyof TPlugins as _ApiOf<TPlugins[K]> extends never ? never : K]: _ApiOf<TPlugins[K]>;
92
+ };
93
+ /** @internal Extract the TApi parameter from a BackendPlugin type. */
94
+ type _ApiOf<T> = T extends BackendPlugin<any, infer TApi> ? TApi : never;
73
95
  /**
74
96
  * Configuration for creating the backend library
75
97
  */
76
- interface BackendLibConfig<TPlugins extends Record<string, BackendPlugin<any>> = Record<string, BackendPlugin<any>>> {
98
+ interface BackendLibConfig<TPlugins extends Record<string, BackendPlugin<any, any>> = Record<string, BackendPlugin<any, any>>> {
77
99
  basePath: string;
78
100
  dbSchema?: DatabaseDefinition;
79
101
  plugins: TPlugins;
@@ -109,18 +131,22 @@ type PluginRoutes<TPlugins extends Record<string, ClientPlugin<any, any>>> = Mer
109
131
  * Prefix all backend plugin route keys with the plugin name
110
132
  * Example: { messages: { list: Endpoint } } => { messages_list: Endpoint }
111
133
  */
112
- type PrefixedPluginRoutes<TPlugins extends Record<string, BackendPlugin<any>>> = UnionToIntersection<{
113
- [PluginKey in keyof TPlugins]: TPlugins[PluginKey] extends BackendPlugin<infer TRoutes> ? {
134
+ type PrefixedPluginRoutes<TPlugins extends Record<string, BackendPlugin<any, any>>> = UnionToIntersection<{
135
+ [PluginKey in keyof TPlugins]: TPlugins[PluginKey] extends BackendPlugin<infer TRoutes, any> ? {
114
136
  [RouteKey in keyof TRoutes as `${PluginKey & string}_${RouteKey & string}`]: TRoutes[RouteKey];
115
137
  } : never;
116
138
  }[keyof TPlugins]> extends infer U ? U extends Record<string, Endpoint> ? U : Record<string, Endpoint> : Record<string, Endpoint>;
117
139
  /**
118
140
  * Result of creating the backend library
119
141
  */
120
- interface BackendLib<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>> {
142
+ interface BackendLib<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>, TApis extends Record<string, Record<string, (...args: any[]) => any>> = Record<string, Record<string, (...args: any[]) => any>>> {
121
143
  handler: (request: Request) => Promise<Response>;
122
144
  router: Router;
123
145
  dbSchema: DatabaseDefinition;
146
+ /** The database adapter shared across all plugins */
147
+ adapter: Adapter;
148
+ /** Fully-typed server-side getter functions, namespaced per plugin */
149
+ api: TApis;
124
150
  }
125
151
  /**
126
152
  * Helper type to extract routes from a client plugin
@@ -154,4 +180,4 @@ type SitemapEntry = {
154
180
  };
155
181
  type Sitemap = Array<SitemapEntry>;
156
182
 
157
- export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, StackContext as S, SitemapEntry 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 };
183
+ export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, StackContext as S, SitemapEntry 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, PluginApis as j };
@@ -8,7 +8,7 @@ import { Endpoint, Router } from 'better-call';
8
8
  */
9
9
  interface StackContext {
10
10
  /** All registered backend plugins */
11
- plugins: Record<string, BackendPlugin<any>>;
11
+ plugins: Record<string, BackendPlugin<any, any>>;
12
12
  /** The API base path (e.g., "/api/data") */
13
13
  basePath: string;
14
14
  /** The database adapter */
@@ -33,8 +33,11 @@ interface ClientStackContext<TPlugins extends Record<string, ClientPlugin<any, a
33
33
  * You can optionally provide a base schema via the dbSchema config option.
34
34
  *
35
35
  * @template TRoutes - The exact shape of routes this plugin provides (preserves keys and endpoint types)
36
+ * @template TApi - The shape of the server-side API surface exposed via `stack().api`.
37
+ * Defaults to `never` so that plugins without an `api` factory are excluded from the
38
+ * `stack().api` namespace entirely, preventing accidental access of `undefined` at runtime.
36
39
  */
37
- interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>> {
40
+ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>, TApi extends Record<string, (...args: any[]) => any> = never> {
38
41
  name: string;
39
42
  /**
40
43
  * Create API endpoints for this plugin
@@ -46,6 +49,14 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
46
49
  */
47
50
  routes: (adapter: Adapter, context?: StackContext) => TRoutes;
48
51
  dbPlugin: DbPlugin;
52
+ /**
53
+ * Optional factory that returns server-side getter functions bound to the adapter.
54
+ * The returned object is merged into `stack().api.<pluginName>.*` for direct
55
+ * server-side or SSG data access without going through HTTP.
56
+ *
57
+ * @param adapter - The adapter instance shared with `routes`
58
+ */
59
+ api?: (adapter: Adapter) => TApi;
49
60
  }
50
61
  /**
51
62
  * Frontend plugin definition
@@ -70,10 +81,21 @@ interface ClientPlugin<TOverrides = Record<string, never>, TRoutes extends Recor
70
81
  */
71
82
  sitemap?: () => Promise<Sitemap> | Sitemap;
72
83
  }
84
+ /**
85
+ * Utility type that maps each plugin key to the return type of its `api` factory.
86
+ * Plugin keys whose `TApi` resolves to `never` (i.e. plugins with no `api` factory)
87
+ * are excluded from the resulting type via key remapping, preventing TypeScript from
88
+ * suggesting callable functions on what is actually `undefined` at runtime.
89
+ */
90
+ type PluginApis<TPlugins extends Record<string, BackendPlugin<any, any>>> = {
91
+ [K in keyof TPlugins as _ApiOf<TPlugins[K]> extends never ? never : K]: _ApiOf<TPlugins[K]>;
92
+ };
93
+ /** @internal Extract the TApi parameter from a BackendPlugin type. */
94
+ type _ApiOf<T> = T extends BackendPlugin<any, infer TApi> ? TApi : never;
73
95
  /**
74
96
  * Configuration for creating the backend library
75
97
  */
76
- interface BackendLibConfig<TPlugins extends Record<string, BackendPlugin<any>> = Record<string, BackendPlugin<any>>> {
98
+ interface BackendLibConfig<TPlugins extends Record<string, BackendPlugin<any, any>> = Record<string, BackendPlugin<any, any>>> {
77
99
  basePath: string;
78
100
  dbSchema?: DatabaseDefinition;
79
101
  plugins: TPlugins;
@@ -109,18 +131,22 @@ type PluginRoutes<TPlugins extends Record<string, ClientPlugin<any, any>>> = Mer
109
131
  * Prefix all backend plugin route keys with the plugin name
110
132
  * Example: { messages: { list: Endpoint } } => { messages_list: Endpoint }
111
133
  */
112
- type PrefixedPluginRoutes<TPlugins extends Record<string, BackendPlugin<any>>> = UnionToIntersection<{
113
- [PluginKey in keyof TPlugins]: TPlugins[PluginKey] extends BackendPlugin<infer TRoutes> ? {
134
+ type PrefixedPluginRoutes<TPlugins extends Record<string, BackendPlugin<any, any>>> = UnionToIntersection<{
135
+ [PluginKey in keyof TPlugins]: TPlugins[PluginKey] extends BackendPlugin<infer TRoutes, any> ? {
114
136
  [RouteKey in keyof TRoutes as `${PluginKey & string}_${RouteKey & string}`]: TRoutes[RouteKey];
115
137
  } : never;
116
138
  }[keyof TPlugins]> extends infer U ? U extends Record<string, Endpoint> ? U : Record<string, Endpoint> : Record<string, Endpoint>;
117
139
  /**
118
140
  * Result of creating the backend library
119
141
  */
120
- interface BackendLib<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>> {
142
+ interface BackendLib<TRoutes extends Record<string, Endpoint> = Record<string, Endpoint>, TApis extends Record<string, Record<string, (...args: any[]) => any>> = Record<string, Record<string, (...args: any[]) => any>>> {
121
143
  handler: (request: Request) => Promise<Response>;
122
144
  router: Router;
123
145
  dbSchema: DatabaseDefinition;
146
+ /** The database adapter shared across all plugins */
147
+ adapter: Adapter;
148
+ /** Fully-typed server-side getter functions, namespaced per plugin */
149
+ api: TApis;
124
150
  }
125
151
  /**
126
152
  * Helper type to extract routes from a client plugin
@@ -154,4 +180,4 @@ type SitemapEntry = {
154
180
  };
155
181
  type Sitemap = Array<SitemapEntry>;
156
182
 
157
- export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, StackContext as S, SitemapEntry 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 };
183
+ export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, StackContext as S, SitemapEntry 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, PluginApis as j };