@btst/stack 1.5.2 → 1.7.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 (241) hide show
  1. package/dist/api/index.cjs +7 -1
  2. package/dist/api/index.d.cts +2 -2
  3. package/dist/api/index.d.mts +2 -2
  4. package/dist/api/index.d.ts +2 -2
  5. package/dist/api/index.mjs +7 -1
  6. package/dist/client/index.d.cts +1 -1
  7. package/dist/client/index.d.mts +1 -1
  8. package/dist/client/index.d.ts +1 -1
  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/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.0/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.cjs +68 -0
  13. package/dist/node_modules/.pnpm/@dnd-kit_accessibility@3.1.1_react@19.2.0/node_modules/@dnd-kit/accessibility/dist/accessibility.esm.mjs +60 -0
  14. package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@dnd-kit/core/dist/core.esm.cjs +3937 -0
  15. package/dist/node_modules/.pnpm/@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0/node_modules/@dnd-kit/core/dist/core.esm.mjs +3907 -0
  16. package/dist/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.cjs +30 -0
  17. package/dist/node_modules/.pnpm/@dnd-kit_modifiers@9.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/modifiers/dist/modifiers.esm.mjs +28 -0
  18. package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.cjs +675 -0
  19. package/dist/node_modules/.pnpm/@dnd-kit_sortable@10.0.0_@dnd-kit_core@6.3.1_react-dom@19.2.0_react@19.2.0__react@19.2.0__react@19.2.0/node_modules/@dnd-kit/sortable/dist/sortable.esm.mjs +661 -0
  20. package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.cjs +358 -0
  21. package/dist/node_modules/.pnpm/@dnd-kit_utilities@3.2.2_react@19.2.0/node_modules/@dnd-kit/utilities/dist/utilities.esm.mjs +332 -0
  22. package/dist/node_modules/.pnpm/@radix-ui_react-tabs@1.1.13_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_865f042350eb43f3338b0fffb33f6246/node_modules/@radix-ui/react-tabs/dist/index.cjs +211 -0
  23. package/dist/node_modules/.pnpm/@radix-ui_react-tabs@1.1.13_@types_react-dom@19.2.3_@types_react@19.2.6__@types_react@1_865f042350eb43f3338b0fffb33f6246/node_modules/@radix-ui/react-tabs/dist/index.mjs +188 -0
  24. package/dist/packages/better-stack/src/plugins/cms/api/plugin.cjs +3 -2
  25. package/dist/packages/better-stack/src/plugins/cms/api/plugin.mjs +3 -2
  26. package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.cjs +15 -15
  27. package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.mjs +16 -16
  28. package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.cjs +588 -0
  29. package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.mjs +586 -0
  30. package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +131 -0
  31. package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +129 -0
  32. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.cjs +32 -0
  33. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.mjs +30 -0
  34. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.cjs +21 -0
  35. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.mjs +19 -0
  36. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.cjs +34 -0
  37. package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.mjs +32 -0
  38. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.cjs +20 -0
  39. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.mjs +18 -0
  40. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +19 -0
  41. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +186 -0
  42. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +184 -0
  43. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +17 -0
  44. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +19 -0
  45. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +165 -0
  46. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +163 -0
  47. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +17 -0
  48. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +19 -0
  49. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +177 -0
  50. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +175 -0
  51. package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +17 -0
  52. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.cjs +17 -0
  53. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.mjs +15 -0
  54. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.cjs +16 -0
  55. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.mjs +14 -0
  56. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +27 -0
  57. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +25 -0
  58. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.cjs +39 -0
  59. package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.mjs +37 -0
  60. package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +551 -0
  61. package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +537 -0
  62. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.cjs +36 -0
  63. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.mjs +34 -0
  64. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.cjs +19 -0
  65. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.mjs +17 -0
  66. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.cjs +21 -0
  67. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.mjs +19 -0
  68. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.cjs +19 -0
  69. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.mjs +17 -0
  70. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.cjs +14 -0
  71. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.mjs +12 -0
  72. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.cjs +17 -0
  73. package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.mjs +15 -0
  74. package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.cjs +278 -0
  75. package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.mjs +276 -0
  76. package/dist/packages/better-stack/src/plugins/form-builder/db.cjs +99 -0
  77. package/dist/packages/better-stack/src/plugins/form-builder/db.mjs +97 -0
  78. package/dist/packages/better-stack/src/plugins/form-builder/schemas.cjs +82 -0
  79. package/dist/packages/better-stack/src/plugins/form-builder/schemas.mjs +74 -0
  80. package/dist/packages/better-stack/src/plugins/form-builder/utils.cjs +37 -0
  81. package/dist/packages/better-stack/src/plugins/form-builder/utils.mjs +29 -0
  82. package/dist/packages/better-stack/src/plugins/open-api/api/generator.cjs +300 -0
  83. package/dist/packages/better-stack/src/plugins/open-api/api/generator.mjs +284 -0
  84. package/dist/packages/better-stack/src/plugins/open-api/api/plugin.cjs +115 -0
  85. package/dist/packages/better-stack/src/plugins/open-api/api/plugin.mjs +113 -0
  86. package/dist/packages/better-stack/src/plugins/open-api/db.cjs +7 -0
  87. package/dist/packages/better-stack/src/plugins/open-api/db.mjs +5 -0
  88. package/dist/packages/better-stack/src/plugins/open-api/logo.cjs +8 -0
  89. package/dist/packages/better-stack/src/plugins/open-api/logo.mjs +6 -0
  90. package/dist/packages/ui/src/components/auto-form/index.cjs +2 -12
  91. package/dist/packages/ui/src/components/auto-form/index.mjs +2 -9
  92. package/dist/packages/ui/src/components/auto-form/stepped-auto-form.cjs +377 -0
  93. package/dist/packages/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
  94. package/dist/packages/ui/src/components/auto-form/utils.cjs +1 -56
  95. package/dist/packages/ui/src/components/auto-form/utils.mjs +2 -56
  96. package/dist/packages/ui/src/components/form-builder/canvas.cjs +111 -0
  97. package/dist/packages/ui/src/components/form-builder/canvas.mjs +109 -0
  98. package/dist/packages/ui/src/components/form-builder/components/index.cjs +570 -0
  99. package/dist/packages/ui/src/components/form-builder/components/index.mjs +553 -0
  100. package/dist/packages/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
  101. package/dist/packages/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
  102. package/dist/packages/ui/src/components/form-builder/form-preview.cjs +73 -0
  103. package/dist/packages/ui/src/components/form-builder/form-preview.mjs +71 -0
  104. package/dist/packages/ui/src/components/form-builder/index.cjs +353 -0
  105. package/dist/packages/ui/src/components/form-builder/index.mjs +344 -0
  106. package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
  107. package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
  108. package/dist/packages/ui/src/components/form-builder/palette.cjs +52 -0
  109. package/dist/packages/ui/src/components/form-builder/palette.mjs +49 -0
  110. package/dist/packages/ui/src/components/form-builder/schema-utils.cjs +120 -0
  111. package/dist/packages/ui/src/components/form-builder/schema-utils.mjs +114 -0
  112. package/dist/packages/ui/src/components/form-builder/sortable-field.cjs +151 -0
  113. package/dist/packages/ui/src/components/form-builder/sortable-field.mjs +148 -0
  114. package/dist/packages/ui/src/components/form-builder/step-tabs.cjs +180 -0
  115. package/dist/packages/ui/src/components/form-builder/step-tabs.mjs +178 -0
  116. package/dist/packages/ui/src/components/form-builder/types.cjs +7 -0
  117. package/dist/packages/ui/src/components/form-builder/types.mjs +5 -0
  118. package/dist/packages/ui/src/components/form-builder/validation-schemas.cjs +67 -0
  119. package/dist/packages/ui/src/components/form-builder/validation-schemas.mjs +56 -0
  120. package/dist/packages/ui/src/components/tabs.cjs +70 -0
  121. package/dist/packages/ui/src/components/tabs.mjs +65 -0
  122. package/dist/packages/ui/src/lib/schema-converter.cjs +130 -0
  123. package/dist/packages/ui/src/lib/schema-converter.mjs +124 -0
  124. package/dist/plugins/api/index.d.cts +2 -2
  125. package/dist/plugins/api/index.d.mts +2 -2
  126. package/dist/plugins/api/index.d.ts +2 -2
  127. package/dist/plugins/blog/api/index.d.cts +1 -1
  128. package/dist/plugins/blog/api/index.d.mts +1 -1
  129. package/dist/plugins/blog/api/index.d.ts +1 -1
  130. package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
  131. package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
  132. package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
  133. package/dist/plugins/blog/client/index.d.cts +1 -1
  134. package/dist/plugins/blog/client/index.d.mts +1 -1
  135. package/dist/plugins/blog/client/index.d.ts +1 -1
  136. package/dist/plugins/blog/query-keys.d.cts +2 -2
  137. package/dist/plugins/blog/query-keys.d.mts +2 -2
  138. package/dist/plugins/blog/query-keys.d.ts +2 -2
  139. package/dist/plugins/client/index.d.cts +2 -2
  140. package/dist/plugins/client/index.d.mts +2 -2
  141. package/dist/plugins/client/index.d.ts +2 -2
  142. package/dist/plugins/cms/client/index.cjs +6 -0
  143. package/dist/plugins/cms/client/index.d.cts +6 -113
  144. package/dist/plugins/cms/client/index.d.mts +6 -113
  145. package/dist/plugins/cms/client/index.d.ts +6 -113
  146. package/dist/plugins/cms/client/index.mjs +1 -0
  147. package/dist/plugins/form-builder/api/index.cjs +7 -0
  148. package/dist/plugins/form-builder/api/index.d.cts +141 -0
  149. package/dist/plugins/form-builder/api/index.d.mts +141 -0
  150. package/dist/plugins/form-builder/api/index.d.ts +141 -0
  151. package/dist/plugins/form-builder/api/index.mjs +1 -0
  152. package/dist/plugins/form-builder/client/components/index.cjs +29 -0
  153. package/dist/plugins/form-builder/client/components/index.d.cts +93 -0
  154. package/dist/plugins/form-builder/client/components/index.d.mts +93 -0
  155. package/dist/plugins/form-builder/client/components/index.d.ts +93 -0
  156. package/dist/plugins/form-builder/client/components/index.mjs +18 -0
  157. package/dist/plugins/form-builder/client/hooks/index.cjs +19 -0
  158. package/dist/plugins/form-builder/client/hooks/index.d.cts +154 -0
  159. package/dist/plugins/form-builder/client/hooks/index.d.mts +154 -0
  160. package/dist/plugins/form-builder/client/hooks/index.d.ts +154 -0
  161. package/dist/plugins/form-builder/client/hooks/index.mjs +1 -0
  162. package/dist/plugins/form-builder/client/index.cjs +13 -0
  163. package/dist/plugins/form-builder/client/index.d.cts +381 -0
  164. package/dist/plugins/form-builder/client/index.d.mts +381 -0
  165. package/dist/plugins/form-builder/client/index.d.ts +381 -0
  166. package/dist/plugins/form-builder/client/index.mjs +2 -0
  167. package/dist/plugins/form-builder/client.css +3 -0
  168. package/dist/plugins/form-builder/query-keys.cjs +143 -0
  169. package/dist/plugins/form-builder/query-keys.d.cts +74 -0
  170. package/dist/plugins/form-builder/query-keys.d.mts +74 -0
  171. package/dist/plugins/form-builder/query-keys.d.ts +74 -0
  172. package/dist/plugins/form-builder/query-keys.mjs +141 -0
  173. package/dist/plugins/form-builder/style.css +19 -0
  174. package/dist/plugins/open-api/api/index.cjs +9 -0
  175. package/dist/plugins/open-api/api/index.d.cts +95 -0
  176. package/dist/plugins/open-api/api/index.d.mts +95 -0
  177. package/dist/plugins/open-api/api/index.d.ts +95 -0
  178. package/dist/plugins/open-api/api/index.mjs +2 -0
  179. package/dist/shared/stack.AX5nZ6A3.d.cts +86 -0
  180. package/dist/shared/stack.AX5nZ6A3.d.mts +86 -0
  181. package/dist/shared/stack.AX5nZ6A3.d.ts +86 -0
  182. package/dist/shared/stack.BIh2AXaW.d.cts +123 -0
  183. package/dist/shared/stack.BIh2AXaW.d.mts +123 -0
  184. package/dist/shared/stack.BIh2AXaW.d.ts +123 -0
  185. package/dist/shared/{stack.ByOugz9d.d.cts → stack.CSce37mX.d.cts} +15 -2
  186. package/dist/shared/{stack.ByOugz9d.d.mts → stack.CSce37mX.d.mts} +15 -2
  187. package/dist/shared/{stack.ByOugz9d.d.ts → stack.CSce37mX.d.ts} +15 -2
  188. package/dist/shared/stack.DzH_wcvr.d.cts +195 -0
  189. package/dist/shared/stack.DzH_wcvr.d.mts +195 -0
  190. package/dist/shared/stack.DzH_wcvr.d.ts +195 -0
  191. package/package.json +67 -1
  192. package/src/api/index.ts +14 -2
  193. package/src/plugins/cms/api/plugin.ts +9 -4
  194. package/src/plugins/cms/client/components/forms/content-form.tsx +23 -25
  195. package/src/plugins/cms/client/index.ts +11 -0
  196. package/src/plugins/form-builder/api/index.ts +1 -0
  197. package/src/plugins/form-builder/api/plugin.ts +776 -0
  198. package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +253 -0
  199. package/src/plugins/form-builder/client/components/index.tsx +24 -0
  200. package/src/plugins/form-builder/client/components/loading/form-builder-skeleton.tsx +42 -0
  201. package/src/plugins/form-builder/client/components/loading/form-list-skeleton.tsx +25 -0
  202. package/src/plugins/form-builder/client/components/loading/index.tsx +3 -0
  203. package/src/plugins/form-builder/client/components/loading/submissions-skeleton.tsx +40 -0
  204. package/src/plugins/form-builder/client/components/pages/404-page.tsx +28 -0
  205. package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +253 -0
  206. package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +26 -0
  207. package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +231 -0
  208. package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +22 -0
  209. package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +268 -0
  210. package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +26 -0
  211. package/src/plugins/form-builder/client/components/shared/default-error.tsx +30 -0
  212. package/src/plugins/form-builder/client/components/shared/empty-state.tsx +26 -0
  213. package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +32 -0
  214. package/src/plugins/form-builder/client/components/shared/pagination.tsx +52 -0
  215. package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +799 -0
  216. package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
  217. package/src/plugins/form-builder/client/index.ts +22 -0
  218. package/src/plugins/form-builder/client/localization/form-builder-common.ts +36 -0
  219. package/src/plugins/form-builder/client/localization/form-builder-editor.ts +18 -0
  220. package/src/plugins/form-builder/client/localization/form-builder-list.ts +17 -0
  221. package/src/plugins/form-builder/client/localization/form-builder-submissions.ts +17 -0
  222. package/src/plugins/form-builder/client/localization/form-builder-toasts.ts +10 -0
  223. package/src/plugins/form-builder/client/localization/index.ts +15 -0
  224. package/src/plugins/form-builder/client/overrides.ts +146 -0
  225. package/src/plugins/form-builder/client/plugin.tsx +488 -0
  226. package/src/plugins/form-builder/client.css +3 -0
  227. package/src/plugins/form-builder/db.ts +99 -0
  228. package/src/plugins/form-builder/query-keys.ts +198 -0
  229. package/src/plugins/form-builder/schemas.ts +122 -0
  230. package/src/plugins/form-builder/style.css +19 -0
  231. package/src/plugins/form-builder/types.ts +317 -0
  232. package/src/plugins/form-builder/utils.ts +63 -0
  233. package/src/plugins/open-api/api/generator.ts +433 -0
  234. package/src/plugins/open-api/api/index.ts +8 -0
  235. package/src/plugins/open-api/api/plugin.ts +243 -0
  236. package/src/plugins/open-api/db.ts +7 -0
  237. package/src/plugins/open-api/logo.ts +7 -0
  238. package/src/types.ts +15 -1
  239. package/dist/shared/{stack.DLhzx1-D.d.mts → stack.CcI4sYJP.d.cts} +1 -1
  240. package/dist/shared/{stack.DLhzx1-D.d.ts → stack.CcI4sYJP.d.mts} +1 -1
  241. package/dist/shared/{stack.DLhzx1-D.d.cts → stack.CcI4sYJP.d.ts} +1 -1
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Unified Schema Converter Module
5
+ *
6
+ * Provides consistent bidirectional conversion between Zod schemas and JSON Schema,
7
+ * handling all edge cases in one place:
8
+ *
9
+ * 1. Date handling: z.date() ↔ { type: "string", format: "date-time" }
10
+ * 2. Steps metadata: Preserves multi-step form configuration
11
+ * 3. Step group mapping: Tracks which fields belong to which step
12
+ * 4. Date constraints: Preserves min/max date validations
13
+ *
14
+ * Usage:
15
+ * ```ts
16
+ * // Zod → JSON Schema (for storage/transport)
17
+ * const jsonSchema = zodToFormSchema(myZodSchema);
18
+ *
19
+ * // JSON Schema → Zod (for validation)
20
+ * const zodSchema = formSchemaToZod(jsonSchema);
21
+ * ```
22
+ */
23
+
24
+ interface FormStep {
25
+ id: string;
26
+ title: string;
27
+ }
28
+ interface FormSchemaMetadata {
29
+ /** Multi-step form step definitions */
30
+ steps?: FormStep[];
31
+ /** Map of field names to their step indices */
32
+ stepGroupMap?: Record<string, number>;
33
+ }
34
+ interface JsonSchemaProperty {
35
+ type?: string;
36
+ format?: string;
37
+ formatMinimum?: string;
38
+ formatMaximum?: string;
39
+ stepGroup?: number;
40
+ properties?: Record<string, JsonSchemaProperty>;
41
+ [key: string]: unknown;
42
+ }
43
+ interface FormJsonSchema {
44
+ type?: string;
45
+ properties?: Record<string, JsonSchemaProperty>;
46
+ required?: string[];
47
+ steps?: FormStep[];
48
+ stepGroupMap?: Record<string, number>;
49
+ [key: string]: unknown;
50
+ }
51
+ /**
52
+ * Convert a Zod schema to JSON Schema with proper handling for:
53
+ * - z.date() → { type: "string", format: "date-time" }
54
+ * - Date min/max constraints → formatMinimum/formatMaximum
55
+ * - Steps metadata (if provided via schema.meta() or explicit metadata param)
56
+ *
57
+ * @param schema - The Zod schema to convert
58
+ * @param metadata - Optional explicit metadata to include (overrides schema meta)
59
+ */
60
+ declare function zodToFormSchema<T extends z.ZodType>(schema: T, metadata?: FormSchemaMetadata): FormJsonSchema;
61
+ /**
62
+ * Convert JSON Schema to Zod schema with proper handling for:
63
+ * - { type: "string", format: "date-time" } → date field (with constraints)
64
+ * - Steps metadata re-attachment (preserved via .meta())
65
+ * - Step group mapping
66
+ *
67
+ * @param jsonSchema - The JSON Schema to convert
68
+ * @returns A Zod schema ready for validation, with all metadata preserved
69
+ */
70
+ declare function formSchemaToZod(jsonSchema: FormJsonSchema): z.ZodType;
71
+ /**
72
+ * Check if a JSON Schema has multi-step configuration.
73
+ */
74
+ declare function hasSteps(jsonSchema: FormJsonSchema): boolean;
75
+ /**
76
+ * Get steps from a JSON Schema.
77
+ */
78
+ declare function getSteps(jsonSchema: FormJsonSchema): FormStep[];
79
+ /**
80
+ * Get the step group map from a JSON Schema.
81
+ * Returns a map of field names to step indices.
82
+ */
83
+ declare function getStepGroupMap(jsonSchema: FormJsonSchema): Record<string, number>;
84
+
85
+ export { getStepGroupMap as a, formSchemaToZod as f, getSteps as g, hasSteps as h, zodToFormSchema as z };
86
+ export type { FormStep as F, FormSchemaMetadata as b };
@@ -0,0 +1,86 @@
1
+ import { z } from 'zod';
2
+
3
+ /**
4
+ * Unified Schema Converter Module
5
+ *
6
+ * Provides consistent bidirectional conversion between Zod schemas and JSON Schema,
7
+ * handling all edge cases in one place:
8
+ *
9
+ * 1. Date handling: z.date() ↔ { type: "string", format: "date-time" }
10
+ * 2. Steps metadata: Preserves multi-step form configuration
11
+ * 3. Step group mapping: Tracks which fields belong to which step
12
+ * 4. Date constraints: Preserves min/max date validations
13
+ *
14
+ * Usage:
15
+ * ```ts
16
+ * // Zod → JSON Schema (for storage/transport)
17
+ * const jsonSchema = zodToFormSchema(myZodSchema);
18
+ *
19
+ * // JSON Schema → Zod (for validation)
20
+ * const zodSchema = formSchemaToZod(jsonSchema);
21
+ * ```
22
+ */
23
+
24
+ interface FormStep {
25
+ id: string;
26
+ title: string;
27
+ }
28
+ interface FormSchemaMetadata {
29
+ /** Multi-step form step definitions */
30
+ steps?: FormStep[];
31
+ /** Map of field names to their step indices */
32
+ stepGroupMap?: Record<string, number>;
33
+ }
34
+ interface JsonSchemaProperty {
35
+ type?: string;
36
+ format?: string;
37
+ formatMinimum?: string;
38
+ formatMaximum?: string;
39
+ stepGroup?: number;
40
+ properties?: Record<string, JsonSchemaProperty>;
41
+ [key: string]: unknown;
42
+ }
43
+ interface FormJsonSchema {
44
+ type?: string;
45
+ properties?: Record<string, JsonSchemaProperty>;
46
+ required?: string[];
47
+ steps?: FormStep[];
48
+ stepGroupMap?: Record<string, number>;
49
+ [key: string]: unknown;
50
+ }
51
+ /**
52
+ * Convert a Zod schema to JSON Schema with proper handling for:
53
+ * - z.date() → { type: "string", format: "date-time" }
54
+ * - Date min/max constraints → formatMinimum/formatMaximum
55
+ * - Steps metadata (if provided via schema.meta() or explicit metadata param)
56
+ *
57
+ * @param schema - The Zod schema to convert
58
+ * @param metadata - Optional explicit metadata to include (overrides schema meta)
59
+ */
60
+ declare function zodToFormSchema<T extends z.ZodType>(schema: T, metadata?: FormSchemaMetadata): FormJsonSchema;
61
+ /**
62
+ * Convert JSON Schema to Zod schema with proper handling for:
63
+ * - { type: "string", format: "date-time" } → date field (with constraints)
64
+ * - Steps metadata re-attachment (preserved via .meta())
65
+ * - Step group mapping
66
+ *
67
+ * @param jsonSchema - The JSON Schema to convert
68
+ * @returns A Zod schema ready for validation, with all metadata preserved
69
+ */
70
+ declare function formSchemaToZod(jsonSchema: FormJsonSchema): z.ZodType;
71
+ /**
72
+ * Check if a JSON Schema has multi-step configuration.
73
+ */
74
+ declare function hasSteps(jsonSchema: FormJsonSchema): boolean;
75
+ /**
76
+ * Get steps from a JSON Schema.
77
+ */
78
+ declare function getSteps(jsonSchema: FormJsonSchema): FormStep[];
79
+ /**
80
+ * Get the step group map from a JSON Schema.
81
+ * Returns a map of field names to step indices.
82
+ */
83
+ declare function getStepGroupMap(jsonSchema: FormJsonSchema): Record<string, number>;
84
+
85
+ export { getStepGroupMap as a, formSchemaToZod as f, getSteps as g, hasSteps as h, zodToFormSchema as z };
86
+ export type { FormStep as F, FormSchemaMetadata as b };
@@ -0,0 +1,123 @@
1
+ import { ControllerRenderProps, FieldValues } from 'react-hook-form';
2
+ import * as zod from 'zod';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ declare function AutoFormCheckbox({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
6
+
7
+ declare function AutoFormDate({ label, isRequired, field, fieldConfigItem, fieldProps, zodItem, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
8
+
9
+ declare function AutoFormEnum({ label, isRequired, field, fieldConfigItem, zodItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
10
+
11
+ declare function AutoFormInput({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
12
+
13
+ declare function AutoFormNumber({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
14
+
15
+ declare function AutoFormRadioGroup({ label, isRequired, field, zodItem, fieldProps, fieldConfigItem, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
16
+
17
+ declare function AutoFormSwitch({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
18
+
19
+ declare function AutoFormTextarea({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
20
+
21
+ declare const INPUT_COMPONENTS: {
22
+ checkbox: typeof AutoFormCheckbox;
23
+ date: typeof AutoFormDate;
24
+ select: typeof AutoFormEnum;
25
+ radio: typeof AutoFormRadioGroup;
26
+ switch: typeof AutoFormSwitch;
27
+ textarea: typeof AutoFormTextarea;
28
+ number: typeof AutoFormNumber;
29
+ fallback: typeof AutoFormInput;
30
+ };
31
+
32
+ /**
33
+ * Shared types between form-builder and auto-form.
34
+ *
35
+ * These types ensure consistency when:
36
+ * - form-builder creates JSON Schema properties
37
+ * - auto-form consumes JSON Schema properties
38
+ * - inputProps flow from form-builder → JSON Schema → auto-form
39
+ */
40
+
41
+ /**
42
+ * Common input props shared by all field types.
43
+ */
44
+ interface BaseInputProps {
45
+ /** Whether the field is disabled */
46
+ disabled?: boolean;
47
+ /** Whether the field is read-only */
48
+ readOnly?: boolean;
49
+ /** Whether the field is required */
50
+ required?: boolean;
51
+ /** Whether to show the label (auto-form specific) */
52
+ showLabel?: boolean;
53
+ }
54
+ /**
55
+ * Generic input props that accept any field type.
56
+ * Use this when the backing type is not known at compile time.
57
+ *
58
+ * This is the catch-all type used for runtime flexibility.
59
+ */
60
+ interface SerializableInputProps extends BaseInputProps {
61
+ placeholder?: string;
62
+ type?: string;
63
+ defaultValue?: unknown;
64
+ min?: number | string;
65
+ max?: number | string;
66
+ step?: number | string;
67
+ minLength?: number;
68
+ maxLength?: number;
69
+ pattern?: string;
70
+ autoComplete?: string;
71
+ /** Allow additional props for extensibility */
72
+ [key: string]: unknown;
73
+ }
74
+
75
+ /**
76
+ * Input props for form fields.
77
+ *
78
+ * This is the runtime type that accepts any input props.
79
+ * For type-safe props, use the discriminated types:
80
+ * - StringInputProps for text inputs
81
+ * - NumberInputProps for number inputs
82
+ * - BooleanInputProps for checkboxes/switches
83
+ * - DateInputProps for date pickers
84
+ * - EnumInputProps for selects/radios
85
+ */
86
+ type FieldInputProps = SerializableInputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof SerializableInputProps> & Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof SerializableInputProps>;
87
+ /**
88
+ * Configuration for a single field in AutoForm.
89
+ *
90
+ * Note: This type is designed to align with form-builder's FormBuilderFieldProps
91
+ * so that JSON Schema properties can be easily converted to field configs.
92
+ */
93
+ type FieldConfigItem = {
94
+ /** Description text or React node */
95
+ description?: React.ReactNode;
96
+ /** Input props passed to the field component */
97
+ inputProps?: FieldInputProps;
98
+ /** Display label */
99
+ label?: string;
100
+ /** Field type override - built-in type or custom component */
101
+ fieldType?: keyof typeof INPUT_COMPONENTS | React.FC<AutoFormInputComponentProps>;
102
+ /** Wrapper component for custom field layout */
103
+ renderParent?: (props: {
104
+ children: React.ReactNode;
105
+ }) => React.ReactElement | null;
106
+ /** Display order for field ordering */
107
+ order?: number;
108
+ };
109
+ /**
110
+ * A FormInput component can handle a specific Zod type (e.g. "ZodBoolean")
111
+ */
112
+ type AutoFormInputComponentProps = {
113
+ zodInputProps: React.InputHTMLAttributes<HTMLInputElement>;
114
+ field: ControllerRenderProps<FieldValues, any>;
115
+ fieldConfigItem: FieldConfigItem;
116
+ label: string;
117
+ isRequired: boolean;
118
+ fieldProps: any;
119
+ zodItem: zod.ZodType;
120
+ className?: string;
121
+ };
122
+
123
+ export type { AutoFormInputComponentProps as A };
@@ -0,0 +1,123 @@
1
+ import { ControllerRenderProps, FieldValues } from 'react-hook-form';
2
+ import * as zod from 'zod';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ declare function AutoFormCheckbox({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
6
+
7
+ declare function AutoFormDate({ label, isRequired, field, fieldConfigItem, fieldProps, zodItem, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
8
+
9
+ declare function AutoFormEnum({ label, isRequired, field, fieldConfigItem, zodItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
10
+
11
+ declare function AutoFormInput({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
12
+
13
+ declare function AutoFormNumber({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
14
+
15
+ declare function AutoFormRadioGroup({ label, isRequired, field, zodItem, fieldProps, fieldConfigItem, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
16
+
17
+ declare function AutoFormSwitch({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
18
+
19
+ declare function AutoFormTextarea({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
20
+
21
+ declare const INPUT_COMPONENTS: {
22
+ checkbox: typeof AutoFormCheckbox;
23
+ date: typeof AutoFormDate;
24
+ select: typeof AutoFormEnum;
25
+ radio: typeof AutoFormRadioGroup;
26
+ switch: typeof AutoFormSwitch;
27
+ textarea: typeof AutoFormTextarea;
28
+ number: typeof AutoFormNumber;
29
+ fallback: typeof AutoFormInput;
30
+ };
31
+
32
+ /**
33
+ * Shared types between form-builder and auto-form.
34
+ *
35
+ * These types ensure consistency when:
36
+ * - form-builder creates JSON Schema properties
37
+ * - auto-form consumes JSON Schema properties
38
+ * - inputProps flow from form-builder → JSON Schema → auto-form
39
+ */
40
+
41
+ /**
42
+ * Common input props shared by all field types.
43
+ */
44
+ interface BaseInputProps {
45
+ /** Whether the field is disabled */
46
+ disabled?: boolean;
47
+ /** Whether the field is read-only */
48
+ readOnly?: boolean;
49
+ /** Whether the field is required */
50
+ required?: boolean;
51
+ /** Whether to show the label (auto-form specific) */
52
+ showLabel?: boolean;
53
+ }
54
+ /**
55
+ * Generic input props that accept any field type.
56
+ * Use this when the backing type is not known at compile time.
57
+ *
58
+ * This is the catch-all type used for runtime flexibility.
59
+ */
60
+ interface SerializableInputProps extends BaseInputProps {
61
+ placeholder?: string;
62
+ type?: string;
63
+ defaultValue?: unknown;
64
+ min?: number | string;
65
+ max?: number | string;
66
+ step?: number | string;
67
+ minLength?: number;
68
+ maxLength?: number;
69
+ pattern?: string;
70
+ autoComplete?: string;
71
+ /** Allow additional props for extensibility */
72
+ [key: string]: unknown;
73
+ }
74
+
75
+ /**
76
+ * Input props for form fields.
77
+ *
78
+ * This is the runtime type that accepts any input props.
79
+ * For type-safe props, use the discriminated types:
80
+ * - StringInputProps for text inputs
81
+ * - NumberInputProps for number inputs
82
+ * - BooleanInputProps for checkboxes/switches
83
+ * - DateInputProps for date pickers
84
+ * - EnumInputProps for selects/radios
85
+ */
86
+ type FieldInputProps = SerializableInputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof SerializableInputProps> & Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof SerializableInputProps>;
87
+ /**
88
+ * Configuration for a single field in AutoForm.
89
+ *
90
+ * Note: This type is designed to align with form-builder's FormBuilderFieldProps
91
+ * so that JSON Schema properties can be easily converted to field configs.
92
+ */
93
+ type FieldConfigItem = {
94
+ /** Description text or React node */
95
+ description?: React.ReactNode;
96
+ /** Input props passed to the field component */
97
+ inputProps?: FieldInputProps;
98
+ /** Display label */
99
+ label?: string;
100
+ /** Field type override - built-in type or custom component */
101
+ fieldType?: keyof typeof INPUT_COMPONENTS | React.FC<AutoFormInputComponentProps>;
102
+ /** Wrapper component for custom field layout */
103
+ renderParent?: (props: {
104
+ children: React.ReactNode;
105
+ }) => React.ReactElement | null;
106
+ /** Display order for field ordering */
107
+ order?: number;
108
+ };
109
+ /**
110
+ * A FormInput component can handle a specific Zod type (e.g. "ZodBoolean")
111
+ */
112
+ type AutoFormInputComponentProps = {
113
+ zodInputProps: React.InputHTMLAttributes<HTMLInputElement>;
114
+ field: ControllerRenderProps<FieldValues, any>;
115
+ fieldConfigItem: FieldConfigItem;
116
+ label: string;
117
+ isRequired: boolean;
118
+ fieldProps: any;
119
+ zodItem: zod.ZodType;
120
+ className?: string;
121
+ };
122
+
123
+ export type { AutoFormInputComponentProps as A };
@@ -0,0 +1,123 @@
1
+ import { ControllerRenderProps, FieldValues } from 'react-hook-form';
2
+ import * as zod from 'zod';
3
+ import * as react_jsx_runtime from 'react/jsx-runtime';
4
+
5
+ declare function AutoFormCheckbox({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
6
+
7
+ declare function AutoFormDate({ label, isRequired, field, fieldConfigItem, fieldProps, zodItem, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
8
+
9
+ declare function AutoFormEnum({ label, isRequired, field, fieldConfigItem, zodItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
10
+
11
+ declare function AutoFormInput({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
12
+
13
+ declare function AutoFormNumber({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
14
+
15
+ declare function AutoFormRadioGroup({ label, isRequired, field, zodItem, fieldProps, fieldConfigItem, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
16
+
17
+ declare function AutoFormSwitch({ label, isRequired, field, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
18
+
19
+ declare function AutoFormTextarea({ label, isRequired, fieldConfigItem, fieldProps, }: AutoFormInputComponentProps): react_jsx_runtime.JSX.Element;
20
+
21
+ declare const INPUT_COMPONENTS: {
22
+ checkbox: typeof AutoFormCheckbox;
23
+ date: typeof AutoFormDate;
24
+ select: typeof AutoFormEnum;
25
+ radio: typeof AutoFormRadioGroup;
26
+ switch: typeof AutoFormSwitch;
27
+ textarea: typeof AutoFormTextarea;
28
+ number: typeof AutoFormNumber;
29
+ fallback: typeof AutoFormInput;
30
+ };
31
+
32
+ /**
33
+ * Shared types between form-builder and auto-form.
34
+ *
35
+ * These types ensure consistency when:
36
+ * - form-builder creates JSON Schema properties
37
+ * - auto-form consumes JSON Schema properties
38
+ * - inputProps flow from form-builder → JSON Schema → auto-form
39
+ */
40
+
41
+ /**
42
+ * Common input props shared by all field types.
43
+ */
44
+ interface BaseInputProps {
45
+ /** Whether the field is disabled */
46
+ disabled?: boolean;
47
+ /** Whether the field is read-only */
48
+ readOnly?: boolean;
49
+ /** Whether the field is required */
50
+ required?: boolean;
51
+ /** Whether to show the label (auto-form specific) */
52
+ showLabel?: boolean;
53
+ }
54
+ /**
55
+ * Generic input props that accept any field type.
56
+ * Use this when the backing type is not known at compile time.
57
+ *
58
+ * This is the catch-all type used for runtime flexibility.
59
+ */
60
+ interface SerializableInputProps extends BaseInputProps {
61
+ placeholder?: string;
62
+ type?: string;
63
+ defaultValue?: unknown;
64
+ min?: number | string;
65
+ max?: number | string;
66
+ step?: number | string;
67
+ minLength?: number;
68
+ maxLength?: number;
69
+ pattern?: string;
70
+ autoComplete?: string;
71
+ /** Allow additional props for extensibility */
72
+ [key: string]: unknown;
73
+ }
74
+
75
+ /**
76
+ * Input props for form fields.
77
+ *
78
+ * This is the runtime type that accepts any input props.
79
+ * For type-safe props, use the discriminated types:
80
+ * - StringInputProps for text inputs
81
+ * - NumberInputProps for number inputs
82
+ * - BooleanInputProps for checkboxes/switches
83
+ * - DateInputProps for date pickers
84
+ * - EnumInputProps for selects/radios
85
+ */
86
+ type FieldInputProps = SerializableInputProps & Omit<React.InputHTMLAttributes<HTMLInputElement>, keyof SerializableInputProps> & Omit<React.TextareaHTMLAttributes<HTMLTextAreaElement>, keyof SerializableInputProps>;
87
+ /**
88
+ * Configuration for a single field in AutoForm.
89
+ *
90
+ * Note: This type is designed to align with form-builder's FormBuilderFieldProps
91
+ * so that JSON Schema properties can be easily converted to field configs.
92
+ */
93
+ type FieldConfigItem = {
94
+ /** Description text or React node */
95
+ description?: React.ReactNode;
96
+ /** Input props passed to the field component */
97
+ inputProps?: FieldInputProps;
98
+ /** Display label */
99
+ label?: string;
100
+ /** Field type override - built-in type or custom component */
101
+ fieldType?: keyof typeof INPUT_COMPONENTS | React.FC<AutoFormInputComponentProps>;
102
+ /** Wrapper component for custom field layout */
103
+ renderParent?: (props: {
104
+ children: React.ReactNode;
105
+ }) => React.ReactElement | null;
106
+ /** Display order for field ordering */
107
+ order?: number;
108
+ };
109
+ /**
110
+ * A FormInput component can handle a specific Zod type (e.g. "ZodBoolean")
111
+ */
112
+ type AutoFormInputComponentProps = {
113
+ zodInputProps: React.InputHTMLAttributes<HTMLInputElement>;
114
+ field: ControllerRenderProps<FieldValues, any>;
115
+ fieldConfigItem: FieldConfigItem;
116
+ label: string;
117
+ isRequired: boolean;
118
+ fieldProps: any;
119
+ zodItem: zod.ZodType;
120
+ className?: string;
121
+ };
122
+
123
+ export type { AutoFormInputComponentProps as A };
@@ -2,6 +2,18 @@ import { Route, createRouter } from '@btst/yar';
2
2
  import { Adapter, DbPlugin, DatabaseDefinition } from '@btst/db';
3
3
  import { Endpoint, Router } from 'better-call';
4
4
 
5
+ /**
6
+ * Context passed to backend plugins during route creation
7
+ * Provides access to all registered plugins for introspection (used by openAPI plugin)
8
+ */
9
+ interface BetterStackContext {
10
+ /** All registered backend plugins */
11
+ plugins: Record<string, BackendPlugin<any>>;
12
+ /** The API base path (e.g., "/api/data") */
13
+ basePath: string;
14
+ /** The database adapter */
15
+ adapter: Adapter;
16
+ }
5
17
  /**
6
18
  * Backend plugin definition
7
19
  * Defines API routes and data access for a feature
@@ -20,8 +32,9 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
20
32
  *
21
33
  * @param adapter - Better DB adapter instance with methods:
22
34
  * create, update, updateMany, delete, deleteMany, findOne, findMany, count
35
+ * @param context - Optional context with access to all plugins (for introspection)
23
36
  */
24
- routes: (adapter: Adapter) => TRoutes;
37
+ routes: (adapter: Adapter, context?: BetterStackContext) => TRoutes;
25
38
  dbPlugin: DbPlugin;
26
39
  }
27
40
  /**
@@ -129,4 +142,4 @@ type SitemapEntry = {
129
142
  };
130
143
  type Sitemap = Array<SitemapEntry>;
131
144
 
132
- export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, PluginRoutes as a, ClientLibConfig as b, ClientLib as c, PrefixedPluginRoutes as d, BackendLibConfig as e, BackendLib as f };
145
+ export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, BetterStackContext as a, PluginRoutes as b, ClientLibConfig as c, ClientLib as d, PrefixedPluginRoutes as e, BackendLibConfig as f, BackendLib as g };
@@ -2,6 +2,18 @@ import { Route, createRouter } from '@btst/yar';
2
2
  import { Adapter, DbPlugin, DatabaseDefinition } from '@btst/db';
3
3
  import { Endpoint, Router } from 'better-call';
4
4
 
5
+ /**
6
+ * Context passed to backend plugins during route creation
7
+ * Provides access to all registered plugins for introspection (used by openAPI plugin)
8
+ */
9
+ interface BetterStackContext {
10
+ /** All registered backend plugins */
11
+ plugins: Record<string, BackendPlugin<any>>;
12
+ /** The API base path (e.g., "/api/data") */
13
+ basePath: string;
14
+ /** The database adapter */
15
+ adapter: Adapter;
16
+ }
5
17
  /**
6
18
  * Backend plugin definition
7
19
  * Defines API routes and data access for a feature
@@ -20,8 +32,9 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
20
32
  *
21
33
  * @param adapter - Better DB adapter instance with methods:
22
34
  * create, update, updateMany, delete, deleteMany, findOne, findMany, count
35
+ * @param context - Optional context with access to all plugins (for introspection)
23
36
  */
24
- routes: (adapter: Adapter) => TRoutes;
37
+ routes: (adapter: Adapter, context?: BetterStackContext) => TRoutes;
25
38
  dbPlugin: DbPlugin;
26
39
  }
27
40
  /**
@@ -129,4 +142,4 @@ type SitemapEntry = {
129
142
  };
130
143
  type Sitemap = Array<SitemapEntry>;
131
144
 
132
- export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, PluginRoutes as a, ClientLibConfig as b, ClientLib as c, PrefixedPluginRoutes as d, BackendLibConfig as e, BackendLib as f };
145
+ export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, BetterStackContext as a, PluginRoutes as b, ClientLibConfig as c, ClientLib as d, PrefixedPluginRoutes as e, BackendLibConfig as f, BackendLib as g };
@@ -2,6 +2,18 @@ import { Route, createRouter } from '@btst/yar';
2
2
  import { Adapter, DbPlugin, DatabaseDefinition } from '@btst/db';
3
3
  import { Endpoint, Router } from 'better-call';
4
4
 
5
+ /**
6
+ * Context passed to backend plugins during route creation
7
+ * Provides access to all registered plugins for introspection (used by openAPI plugin)
8
+ */
9
+ interface BetterStackContext {
10
+ /** All registered backend plugins */
11
+ plugins: Record<string, BackendPlugin<any>>;
12
+ /** The API base path (e.g., "/api/data") */
13
+ basePath: string;
14
+ /** The database adapter */
15
+ adapter: Adapter;
16
+ }
5
17
  /**
6
18
  * Backend plugin definition
7
19
  * Defines API routes and data access for a feature
@@ -20,8 +32,9 @@ interface BackendPlugin<TRoutes extends Record<string, Endpoint> = Record<string
20
32
  *
21
33
  * @param adapter - Better DB adapter instance with methods:
22
34
  * create, update, updateMany, delete, deleteMany, findOne, findMany, count
35
+ * @param context - Optional context with access to all plugins (for introspection)
23
36
  */
24
- routes: (adapter: Adapter) => TRoutes;
37
+ routes: (adapter: Adapter, context?: BetterStackContext) => TRoutes;
25
38
  dbPlugin: DbPlugin;
26
39
  }
27
40
  /**
@@ -129,4 +142,4 @@ type SitemapEntry = {
129
142
  };
130
143
  type Sitemap = Array<SitemapEntry>;
131
144
 
132
- export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, PluginRoutes as a, ClientLibConfig as b, ClientLib as c, PrefixedPluginRoutes as d, BackendLibConfig as e, BackendLib as f };
145
+ export type { BackendPlugin as B, ClientPlugin as C, PluginOverrides as P, Sitemap as S, BetterStackContext as a, PluginRoutes as b, ClientLibConfig as c, ClientLib as d, PrefixedPluginRoutes as e, BackendLibConfig as f, BackendLib as g };