@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.
- package/dist/api/index.cjs +7 -1
- package/dist/api/index.d.cts +2 -2
- package/dist/api/index.d.mts +2 -2
- package/dist/api/index.d.ts +2 -2
- package/dist/api/index.mjs +7 -1
- package/dist/client/index.d.cts +1 -1
- package/dist/client/index.d.mts +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- package/dist/packages/better-stack/src/plugins/cms/api/plugin.cjs +3 -2
- package/dist/packages/better-stack/src/plugins/cms/api/plugin.mjs +3 -2
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.cjs +15 -15
- package/dist/packages/better-stack/src/plugins/cms/client/components/forms/content-form.mjs +16 -16
- package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.cjs +588 -0
- package/dist/packages/better-stack/src/plugins/form-builder/api/plugin.mjs +586 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.cjs +131 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/forms/form-renderer.mjs +129 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.cjs +32 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-builder-skeleton.mjs +30 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.cjs +21 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/form-list-skeleton.mjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.cjs +34 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/loading/submissions-skeleton.mjs +32 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.cjs +20 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/404-page.mjs +18 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.cjs +186 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.internal.mjs +184 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-builder-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.cjs +165 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.internal.mjs +163 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/form-list-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +177 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +175 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/pages/submissions-page.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.cjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/default-error.mjs +15 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.cjs +16 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/empty-state.mjs +14 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.cjs +27 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/page-wrapper.mjs +25 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.cjs +39 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/components/shared/pagination.mjs +37 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.cjs +551 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/hooks/form-builder-hooks.mjs +537 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.cjs +36 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-common.mjs +34 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-editor.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.cjs +21 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-list.mjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.cjs +19 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-submissions.mjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.cjs +14 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/form-builder-toasts.mjs +12 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.cjs +17 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/localization/index.mjs +15 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.cjs +278 -0
- package/dist/packages/better-stack/src/plugins/form-builder/client/plugin.mjs +276 -0
- package/dist/packages/better-stack/src/plugins/form-builder/db.cjs +99 -0
- package/dist/packages/better-stack/src/plugins/form-builder/db.mjs +97 -0
- package/dist/packages/better-stack/src/plugins/form-builder/schemas.cjs +82 -0
- package/dist/packages/better-stack/src/plugins/form-builder/schemas.mjs +74 -0
- package/dist/packages/better-stack/src/plugins/form-builder/utils.cjs +37 -0
- package/dist/packages/better-stack/src/plugins/form-builder/utils.mjs +29 -0
- package/dist/packages/better-stack/src/plugins/open-api/api/generator.cjs +300 -0
- package/dist/packages/better-stack/src/plugins/open-api/api/generator.mjs +284 -0
- package/dist/packages/better-stack/src/plugins/open-api/api/plugin.cjs +115 -0
- package/dist/packages/better-stack/src/plugins/open-api/api/plugin.mjs +113 -0
- package/dist/packages/better-stack/src/plugins/open-api/db.cjs +7 -0
- package/dist/packages/better-stack/src/plugins/open-api/db.mjs +5 -0
- package/dist/packages/better-stack/src/plugins/open-api/logo.cjs +8 -0
- package/dist/packages/better-stack/src/plugins/open-api/logo.mjs +6 -0
- package/dist/packages/ui/src/components/auto-form/index.cjs +2 -12
- package/dist/packages/ui/src/components/auto-form/index.mjs +2 -9
- package/dist/packages/ui/src/components/auto-form/stepped-auto-form.cjs +377 -0
- package/dist/packages/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/packages/ui/src/components/auto-form/utils.cjs +1 -56
- package/dist/packages/ui/src/components/auto-form/utils.mjs +2 -56
- package/dist/packages/ui/src/components/form-builder/canvas.cjs +111 -0
- package/dist/packages/ui/src/components/form-builder/canvas.mjs +109 -0
- package/dist/packages/ui/src/components/form-builder/components/index.cjs +570 -0
- package/dist/packages/ui/src/components/form-builder/components/index.mjs +553 -0
- package/dist/packages/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
- package/dist/packages/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
- package/dist/packages/ui/src/components/form-builder/form-preview.cjs +73 -0
- package/dist/packages/ui/src/components/form-builder/form-preview.mjs +71 -0
- package/dist/packages/ui/src/components/form-builder/index.cjs +353 -0
- package/dist/packages/ui/src/components/form-builder/index.mjs +344 -0
- package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
- package/dist/packages/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
- package/dist/packages/ui/src/components/form-builder/palette.cjs +52 -0
- package/dist/packages/ui/src/components/form-builder/palette.mjs +49 -0
- package/dist/packages/ui/src/components/form-builder/schema-utils.cjs +120 -0
- package/dist/packages/ui/src/components/form-builder/schema-utils.mjs +114 -0
- package/dist/packages/ui/src/components/form-builder/sortable-field.cjs +151 -0
- package/dist/packages/ui/src/components/form-builder/sortable-field.mjs +148 -0
- package/dist/packages/ui/src/components/form-builder/step-tabs.cjs +180 -0
- package/dist/packages/ui/src/components/form-builder/step-tabs.mjs +178 -0
- package/dist/packages/ui/src/components/form-builder/types.cjs +7 -0
- package/dist/packages/ui/src/components/form-builder/types.mjs +5 -0
- package/dist/packages/ui/src/components/form-builder/validation-schemas.cjs +67 -0
- package/dist/packages/ui/src/components/form-builder/validation-schemas.mjs +56 -0
- package/dist/packages/ui/src/components/tabs.cjs +70 -0
- package/dist/packages/ui/src/components/tabs.mjs +65 -0
- package/dist/packages/ui/src/lib/schema-converter.cjs +130 -0
- package/dist/packages/ui/src/lib/schema-converter.mjs +124 -0
- package/dist/plugins/api/index.d.cts +2 -2
- package/dist/plugins/api/index.d.mts +2 -2
- package/dist/plugins/api/index.d.ts +2 -2
- package/dist/plugins/blog/api/index.d.cts +1 -1
- package/dist/plugins/blog/api/index.d.mts +1 -1
- package/dist/plugins/blog/api/index.d.ts +1 -1
- package/dist/plugins/blog/client/hooks/index.d.cts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.mts +2 -2
- package/dist/plugins/blog/client/hooks/index.d.ts +2 -2
- package/dist/plugins/blog/client/index.d.cts +1 -1
- package/dist/plugins/blog/client/index.d.mts +1 -1
- package/dist/plugins/blog/client/index.d.ts +1 -1
- package/dist/plugins/blog/query-keys.d.cts +2 -2
- package/dist/plugins/blog/query-keys.d.mts +2 -2
- package/dist/plugins/blog/query-keys.d.ts +2 -2
- package/dist/plugins/client/index.d.cts +2 -2
- package/dist/plugins/client/index.d.mts +2 -2
- package/dist/plugins/client/index.d.ts +2 -2
- package/dist/plugins/cms/client/index.cjs +6 -0
- package/dist/plugins/cms/client/index.d.cts +6 -113
- package/dist/plugins/cms/client/index.d.mts +6 -113
- package/dist/plugins/cms/client/index.d.ts +6 -113
- package/dist/plugins/cms/client/index.mjs +1 -0
- package/dist/plugins/form-builder/api/index.cjs +7 -0
- package/dist/plugins/form-builder/api/index.d.cts +141 -0
- package/dist/plugins/form-builder/api/index.d.mts +141 -0
- package/dist/plugins/form-builder/api/index.d.ts +141 -0
- package/dist/plugins/form-builder/api/index.mjs +1 -0
- package/dist/plugins/form-builder/client/components/index.cjs +29 -0
- package/dist/plugins/form-builder/client/components/index.d.cts +93 -0
- package/dist/plugins/form-builder/client/components/index.d.mts +93 -0
- package/dist/plugins/form-builder/client/components/index.d.ts +93 -0
- package/dist/plugins/form-builder/client/components/index.mjs +18 -0
- package/dist/plugins/form-builder/client/hooks/index.cjs +19 -0
- package/dist/plugins/form-builder/client/hooks/index.d.cts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.d.mts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.d.ts +154 -0
- package/dist/plugins/form-builder/client/hooks/index.mjs +1 -0
- package/dist/plugins/form-builder/client/index.cjs +13 -0
- package/dist/plugins/form-builder/client/index.d.cts +381 -0
- package/dist/plugins/form-builder/client/index.d.mts +381 -0
- package/dist/plugins/form-builder/client/index.d.ts +381 -0
- package/dist/plugins/form-builder/client/index.mjs +2 -0
- package/dist/plugins/form-builder/client.css +3 -0
- package/dist/plugins/form-builder/query-keys.cjs +143 -0
- package/dist/plugins/form-builder/query-keys.d.cts +74 -0
- package/dist/plugins/form-builder/query-keys.d.mts +74 -0
- package/dist/plugins/form-builder/query-keys.d.ts +74 -0
- package/dist/plugins/form-builder/query-keys.mjs +141 -0
- package/dist/plugins/form-builder/style.css +19 -0
- package/dist/plugins/open-api/api/index.cjs +9 -0
- package/dist/plugins/open-api/api/index.d.cts +95 -0
- package/dist/plugins/open-api/api/index.d.mts +95 -0
- package/dist/plugins/open-api/api/index.d.ts +95 -0
- package/dist/plugins/open-api/api/index.mjs +2 -0
- package/dist/shared/stack.AX5nZ6A3.d.cts +86 -0
- package/dist/shared/stack.AX5nZ6A3.d.mts +86 -0
- package/dist/shared/stack.AX5nZ6A3.d.ts +86 -0
- package/dist/shared/stack.BIh2AXaW.d.cts +123 -0
- package/dist/shared/stack.BIh2AXaW.d.mts +123 -0
- package/dist/shared/stack.BIh2AXaW.d.ts +123 -0
- package/dist/shared/{stack.ByOugz9d.d.cts → stack.CSce37mX.d.cts} +15 -2
- package/dist/shared/{stack.ByOugz9d.d.mts → stack.CSce37mX.d.mts} +15 -2
- package/dist/shared/{stack.ByOugz9d.d.ts → stack.CSce37mX.d.ts} +15 -2
- package/dist/shared/stack.DzH_wcvr.d.cts +195 -0
- package/dist/shared/stack.DzH_wcvr.d.mts +195 -0
- package/dist/shared/stack.DzH_wcvr.d.ts +195 -0
- package/package.json +67 -1
- package/src/api/index.ts +14 -2
- package/src/plugins/cms/api/plugin.ts +9 -4
- package/src/plugins/cms/client/components/forms/content-form.tsx +23 -25
- package/src/plugins/cms/client/index.ts +11 -0
- package/src/plugins/form-builder/api/index.ts +1 -0
- package/src/plugins/form-builder/api/plugin.ts +776 -0
- package/src/plugins/form-builder/client/components/forms/form-renderer.tsx +253 -0
- package/src/plugins/form-builder/client/components/index.tsx +24 -0
- package/src/plugins/form-builder/client/components/loading/form-builder-skeleton.tsx +42 -0
- package/src/plugins/form-builder/client/components/loading/form-list-skeleton.tsx +25 -0
- package/src/plugins/form-builder/client/components/loading/index.tsx +3 -0
- package/src/plugins/form-builder/client/components/loading/submissions-skeleton.tsx +40 -0
- package/src/plugins/form-builder/client/components/pages/404-page.tsx +28 -0
- package/src/plugins/form-builder/client/components/pages/form-builder-page.internal.tsx +253 -0
- package/src/plugins/form-builder/client/components/pages/form-builder-page.tsx +26 -0
- package/src/plugins/form-builder/client/components/pages/form-list-page.internal.tsx +231 -0
- package/src/plugins/form-builder/client/components/pages/form-list-page.tsx +22 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +268 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.tsx +26 -0
- package/src/plugins/form-builder/client/components/shared/default-error.tsx +30 -0
- package/src/plugins/form-builder/client/components/shared/empty-state.tsx +26 -0
- package/src/plugins/form-builder/client/components/shared/page-wrapper.tsx +32 -0
- package/src/plugins/form-builder/client/components/shared/pagination.tsx +52 -0
- package/src/plugins/form-builder/client/hooks/form-builder-hooks.tsx +799 -0
- package/src/plugins/form-builder/client/hooks/index.tsx +1 -0
- package/src/plugins/form-builder/client/index.ts +22 -0
- package/src/plugins/form-builder/client/localization/form-builder-common.ts +36 -0
- package/src/plugins/form-builder/client/localization/form-builder-editor.ts +18 -0
- package/src/plugins/form-builder/client/localization/form-builder-list.ts +17 -0
- package/src/plugins/form-builder/client/localization/form-builder-submissions.ts +17 -0
- package/src/plugins/form-builder/client/localization/form-builder-toasts.ts +10 -0
- package/src/plugins/form-builder/client/localization/index.ts +15 -0
- package/src/plugins/form-builder/client/overrides.ts +146 -0
- package/src/plugins/form-builder/client/plugin.tsx +488 -0
- package/src/plugins/form-builder/client.css +3 -0
- package/src/plugins/form-builder/db.ts +99 -0
- package/src/plugins/form-builder/query-keys.ts +198 -0
- package/src/plugins/form-builder/schemas.ts +122 -0
- package/src/plugins/form-builder/style.css +19 -0
- package/src/plugins/form-builder/types.ts +317 -0
- package/src/plugins/form-builder/utils.ts +63 -0
- package/src/plugins/open-api/api/generator.ts +433 -0
- package/src/plugins/open-api/api/index.ts +8 -0
- package/src/plugins/open-api/api/plugin.ts +243 -0
- package/src/plugins/open-api/db.ts +7 -0
- package/src/plugins/open-api/logo.ts +7 -0
- package/src/types.ts +15 -1
- package/dist/shared/{stack.DLhzx1-D.d.mts → stack.CcI4sYJP.d.cts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.ts → stack.CcI4sYJP.d.mts} +1 -1
- package/dist/shared/{stack.DLhzx1-D.d.cts → stack.CcI4sYJP.d.ts} +1 -1
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
2
|
+
import { createApiClient } from '@btst/stack/plugins/client';
|
|
3
|
+
import { P as PaginatedForms, S as SerializedForm, c as PaginatedFormSubmissions, b as SerializedFormSubmissionWithData } from '../../shared/stack.DzH_wcvr.js';
|
|
4
|
+
import { FormBuilderApiRouter } from './api/index.js';
|
|
5
|
+
import '@btst/stack/plugins/api';
|
|
6
|
+
import 'better-call';
|
|
7
|
+
import 'zod';
|
|
8
|
+
|
|
9
|
+
interface FormListParams {
|
|
10
|
+
status?: "active" | "inactive" | "archived";
|
|
11
|
+
limit?: number;
|
|
12
|
+
offset?: number;
|
|
13
|
+
}
|
|
14
|
+
interface SubmissionListParams {
|
|
15
|
+
formId: string;
|
|
16
|
+
limit?: number;
|
|
17
|
+
offset?: number;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Create Form Builder query keys for React Query
|
|
21
|
+
* Used by consumers to fetch forms and submissions
|
|
22
|
+
*/
|
|
23
|
+
declare function createFormBuilderQueryKeys(client: ReturnType<typeof createApiClient<FormBuilderApiRouter>>, headers?: HeadersInit): {
|
|
24
|
+
forms: {
|
|
25
|
+
_def: readonly ["forms"];
|
|
26
|
+
} & {
|
|
27
|
+
list: ((params?: FormListParams | undefined) => Omit<{
|
|
28
|
+
queryKey: readonly ["forms", "list", string, FormListParams];
|
|
29
|
+
queryFn: _tanstack_react_query.QueryFunction<PaginatedForms, readonly ["forms", "list", string, FormListParams]>;
|
|
30
|
+
} & {
|
|
31
|
+
_def: readonly ["forms", "list"];
|
|
32
|
+
}, "_def">) & {
|
|
33
|
+
_def: readonly ["forms", "list"];
|
|
34
|
+
};
|
|
35
|
+
bySlug: ((slug: string) => Omit<{
|
|
36
|
+
queryKey: readonly ["forms", "bySlug", string, string];
|
|
37
|
+
queryFn: _tanstack_react_query.QueryFunction<SerializedForm | null, readonly ["forms", "bySlug", string, string]>;
|
|
38
|
+
} & {
|
|
39
|
+
_def: readonly ["forms", "bySlug"];
|
|
40
|
+
}, "_def">) & {
|
|
41
|
+
_def: readonly ["forms", "bySlug"];
|
|
42
|
+
};
|
|
43
|
+
byId: ((id: string) => Omit<{
|
|
44
|
+
queryKey: readonly ["forms", "byId", string, string];
|
|
45
|
+
queryFn: _tanstack_react_query.QueryFunction<SerializedForm | null, readonly ["forms", "byId", string, string]>;
|
|
46
|
+
} & {
|
|
47
|
+
_def: readonly ["forms", "byId"];
|
|
48
|
+
}, "_def">) & {
|
|
49
|
+
_def: readonly ["forms", "byId"];
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
formSubmissions: {
|
|
53
|
+
_def: readonly ["formSubmissions"];
|
|
54
|
+
} & {
|
|
55
|
+
list: ((params: SubmissionListParams) => Omit<{
|
|
56
|
+
queryKey: readonly ["formSubmissions", "list", SubmissionListParams];
|
|
57
|
+
queryFn: _tanstack_react_query.QueryFunction<PaginatedFormSubmissions<Record<string, unknown>>, readonly ["formSubmissions", "list", SubmissionListParams]>;
|
|
58
|
+
} & {
|
|
59
|
+
_def: readonly ["formSubmissions", "list"];
|
|
60
|
+
}, "_def">) & {
|
|
61
|
+
_def: readonly ["formSubmissions", "list"];
|
|
62
|
+
};
|
|
63
|
+
detail: ((formId: string, subId: string) => Omit<{
|
|
64
|
+
queryKey: readonly ["formSubmissions", "detail", string, string];
|
|
65
|
+
queryFn: _tanstack_react_query.QueryFunction<SerializedFormSubmissionWithData<Record<string, unknown>> | null, readonly ["formSubmissions", "detail", string, string]>;
|
|
66
|
+
} & {
|
|
67
|
+
_def: readonly ["formSubmissions", "detail"];
|
|
68
|
+
}, "_def">) & {
|
|
69
|
+
_def: readonly ["formSubmissions", "detail"];
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
export { createFormBuilderQueryKeys };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { mergeQueryKeys, createQueryKeys } from '@lukemorales/query-key-factory';
|
|
2
|
+
|
|
3
|
+
function isErrorResponse(response) {
|
|
4
|
+
if (typeof response !== "object" || response === null) {
|
|
5
|
+
return false;
|
|
6
|
+
}
|
|
7
|
+
const obj = response;
|
|
8
|
+
return "error" in obj && obj.error !== null && obj.error !== void 0;
|
|
9
|
+
}
|
|
10
|
+
function toError(error) {
|
|
11
|
+
if (error instanceof Error) {
|
|
12
|
+
return error;
|
|
13
|
+
}
|
|
14
|
+
if (typeof error === "object" && error !== null) {
|
|
15
|
+
const errorObj = error;
|
|
16
|
+
const message = (typeof errorObj.message === "string" ? errorObj.message : null) || (typeof errorObj.error === "string" ? errorObj.error : null) || JSON.stringify(error);
|
|
17
|
+
const err = new Error(message);
|
|
18
|
+
Object.assign(err, error);
|
|
19
|
+
return err;
|
|
20
|
+
}
|
|
21
|
+
return new Error(String(error));
|
|
22
|
+
}
|
|
23
|
+
function createFormBuilderQueryKeys(client, headers) {
|
|
24
|
+
const forms = createFormsQueries(client, headers);
|
|
25
|
+
const submissions = createSubmissionsQueries(client, headers);
|
|
26
|
+
return mergeQueryKeys(forms, submissions);
|
|
27
|
+
}
|
|
28
|
+
function createFormsQueries(client, headers) {
|
|
29
|
+
return createQueryKeys("forms", {
|
|
30
|
+
list: (params = {}) => ({
|
|
31
|
+
queryKey: ["list", params],
|
|
32
|
+
queryFn: async () => {
|
|
33
|
+
try {
|
|
34
|
+
const response = await client("/forms", {
|
|
35
|
+
method: "GET",
|
|
36
|
+
query: {
|
|
37
|
+
status: params.status,
|
|
38
|
+
limit: params.limit ?? 20,
|
|
39
|
+
offset: params.offset ?? 0
|
|
40
|
+
},
|
|
41
|
+
headers
|
|
42
|
+
});
|
|
43
|
+
if (isErrorResponse(response)) {
|
|
44
|
+
throw toError(response.error);
|
|
45
|
+
}
|
|
46
|
+
return response.data;
|
|
47
|
+
} catch (error) {
|
|
48
|
+
throw error;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}),
|
|
52
|
+
bySlug: (slug) => ({
|
|
53
|
+
queryKey: ["bySlug", slug],
|
|
54
|
+
queryFn: async () => {
|
|
55
|
+
if (!slug) return null;
|
|
56
|
+
try {
|
|
57
|
+
const response = await client("/forms/:slug", {
|
|
58
|
+
method: "GET",
|
|
59
|
+
params: { slug },
|
|
60
|
+
headers
|
|
61
|
+
});
|
|
62
|
+
if (isErrorResponse(response)) {
|
|
63
|
+
throw toError(response.error);
|
|
64
|
+
}
|
|
65
|
+
return response.data;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
throw error;
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}),
|
|
71
|
+
byId: (id) => ({
|
|
72
|
+
queryKey: ["byId", id],
|
|
73
|
+
queryFn: async () => {
|
|
74
|
+
if (!id) return null;
|
|
75
|
+
try {
|
|
76
|
+
const response = await client("/forms/id/:id", {
|
|
77
|
+
method: "GET",
|
|
78
|
+
params: { id },
|
|
79
|
+
headers
|
|
80
|
+
});
|
|
81
|
+
if (isErrorResponse(response)) {
|
|
82
|
+
throw toError(response.error);
|
|
83
|
+
}
|
|
84
|
+
return response.data;
|
|
85
|
+
} catch (error) {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
})
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
function createSubmissionsQueries(client, headers) {
|
|
93
|
+
return createQueryKeys("formSubmissions", {
|
|
94
|
+
list: (params) => ({
|
|
95
|
+
queryKey: [params],
|
|
96
|
+
queryFn: async () => {
|
|
97
|
+
try {
|
|
98
|
+
const response = await client("/forms/:formId/submissions", {
|
|
99
|
+
method: "GET",
|
|
100
|
+
params: { formId: params.formId },
|
|
101
|
+
query: {
|
|
102
|
+
limit: params.limit ?? 20,
|
|
103
|
+
offset: params.offset ?? 0
|
|
104
|
+
},
|
|
105
|
+
headers
|
|
106
|
+
});
|
|
107
|
+
if (isErrorResponse(response)) {
|
|
108
|
+
throw toError(response.error);
|
|
109
|
+
}
|
|
110
|
+
return response.data;
|
|
111
|
+
} catch (error) {
|
|
112
|
+
throw error;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
}),
|
|
116
|
+
detail: (formId, subId) => ({
|
|
117
|
+
queryKey: [formId, subId],
|
|
118
|
+
queryFn: async () => {
|
|
119
|
+
if (!formId || !subId) return null;
|
|
120
|
+
try {
|
|
121
|
+
const response = await client(
|
|
122
|
+
"/forms/:formId/submissions/:subId",
|
|
123
|
+
{
|
|
124
|
+
method: "GET",
|
|
125
|
+
params: { formId, subId },
|
|
126
|
+
headers
|
|
127
|
+
}
|
|
128
|
+
);
|
|
129
|
+
if (isErrorResponse(response)) {
|
|
130
|
+
throw toError(response.error);
|
|
131
|
+
}
|
|
132
|
+
return response.data;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
throw error;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
})
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export { createFormBuilderQueryKeys };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
@import "./client.css";
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
* Form Builder Plugin CSS - Includes Tailwind class scanning
|
|
5
|
+
*
|
|
6
|
+
* When consumed from npm, Tailwind v4 will automatically scan this package's
|
|
7
|
+
* source files for Tailwind classes. Consumers only need:
|
|
8
|
+
* @import "@btst/stack/plugins/form-builder/css";
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/* Scan this package's source files for Tailwind classes */
|
|
12
|
+
@source "../../../src/**/*.{ts,tsx}";
|
|
13
|
+
|
|
14
|
+
/* Scan UI package components (when installed as npm package the UI package will be in this dir) */
|
|
15
|
+
@source "../../packages/ui/src";
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* alternatively consumer can use @source "../node_modules/@btst/stack/src/**\/*.{ts,tsx}";
|
|
19
|
+
*/
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const plugin = require('../../../packages/better-stack/src/plugins/open-api/api/plugin.cjs');
|
|
4
|
+
const generator = require('../../../packages/better-stack/src/plugins/open-api/api/generator.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
exports.openApiBackendPlugin = plugin.openApiBackendPlugin;
|
|
9
|
+
exports.generateOpenAPISchema = generator.generateOpenAPISchema;
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
|
+
import * as better_call from 'better-call';
|
|
3
|
+
import { a as BetterStackContext } from '../../../shared/stack.CSce37mX.cjs';
|
|
4
|
+
import '@btst/yar';
|
|
5
|
+
import '@btst/db';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Scalar API Reference themes
|
|
9
|
+
*/
|
|
10
|
+
type ScalarTheme = "alternate" | "default" | "moon" | "purple" | "solarized" | "bluePlanet" | "saturn" | "kepler" | "mars" | "deepSpace" | "laserwave" | "none";
|
|
11
|
+
/**
|
|
12
|
+
* OpenAPI plugin configuration options
|
|
13
|
+
*/
|
|
14
|
+
interface OpenAPIOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The path to the OpenAPI reference page
|
|
17
|
+
* This path is relative to the API base path
|
|
18
|
+
* @default "/reference"
|
|
19
|
+
*/
|
|
20
|
+
path?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Disable the default HTML reference page
|
|
23
|
+
* Only the JSON schema endpoint will be available
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
disableDefaultReference?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Theme for the Scalar API Reference page
|
|
29
|
+
* @default "default"
|
|
30
|
+
*/
|
|
31
|
+
theme?: ScalarTheme;
|
|
32
|
+
/**
|
|
33
|
+
* CSP nonce for inline scripts
|
|
34
|
+
* Required for strict Content Security Policy
|
|
35
|
+
*/
|
|
36
|
+
nonce?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Custom title for the API documentation
|
|
39
|
+
* @default "Better Stack API"
|
|
40
|
+
*/
|
|
41
|
+
title?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Custom description for the API documentation
|
|
44
|
+
*/
|
|
45
|
+
description?: string;
|
|
46
|
+
/**
|
|
47
|
+
* API version string
|
|
48
|
+
* @default "1.0.0"
|
|
49
|
+
*/
|
|
50
|
+
version?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* OpenAPI plugin for Better Stack
|
|
54
|
+
*
|
|
55
|
+
* Automatically generates OpenAPI 3.1 documentation for all registered plugins.
|
|
56
|
+
* Provides both a JSON schema endpoint and an interactive Scalar UI reference page.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const { handler } = betterStack({
|
|
61
|
+
* basePath: "/api/data",
|
|
62
|
+
* plugins: {
|
|
63
|
+
* blog: blogBackendPlugin(),
|
|
64
|
+
* cms: cmsBackendPlugin({ ... }),
|
|
65
|
+
* openApi: openApiBackendPlugin({ theme: "moon" }),
|
|
66
|
+
* },
|
|
67
|
+
* adapter: (db) => createMemoryAdapter(db)({}),
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Access:
|
|
71
|
+
* // - GET /api/data/open-api/schema - JSON schema
|
|
72
|
+
* // - GET /api/data/reference - Interactive Scalar UI
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare const openApiBackendPlugin: (options?: OpenAPIOptions) => _btst_stack_plugins_api.BackendPlugin<{
|
|
76
|
+
readonly generateSchema: better_call.StrictEndpoint<"/open-api/schema", {
|
|
77
|
+
method: "GET";
|
|
78
|
+
}, Record<string, any>>;
|
|
79
|
+
readonly reference: better_call.StrictEndpoint<string, {
|
|
80
|
+
method: "GET";
|
|
81
|
+
}, Response>;
|
|
82
|
+
}>;
|
|
83
|
+
type OpenApiRouter = ReturnType<ReturnType<typeof openApiBackendPlugin>["routes"]>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Generate OpenAPI 3.1 schema from Better Stack context
|
|
87
|
+
*/
|
|
88
|
+
declare function generateOpenAPISchema(context: BetterStackContext, options?: {
|
|
89
|
+
title?: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
version?: string;
|
|
92
|
+
}): Record<string, any>;
|
|
93
|
+
|
|
94
|
+
export { generateOpenAPISchema, openApiBackendPlugin };
|
|
95
|
+
export type { OpenAPIOptions, OpenApiRouter, ScalarTheme };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
|
+
import * as better_call from 'better-call';
|
|
3
|
+
import { a as BetterStackContext } from '../../../shared/stack.CSce37mX.mjs';
|
|
4
|
+
import '@btst/yar';
|
|
5
|
+
import '@btst/db';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Scalar API Reference themes
|
|
9
|
+
*/
|
|
10
|
+
type ScalarTheme = "alternate" | "default" | "moon" | "purple" | "solarized" | "bluePlanet" | "saturn" | "kepler" | "mars" | "deepSpace" | "laserwave" | "none";
|
|
11
|
+
/**
|
|
12
|
+
* OpenAPI plugin configuration options
|
|
13
|
+
*/
|
|
14
|
+
interface OpenAPIOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The path to the OpenAPI reference page
|
|
17
|
+
* This path is relative to the API base path
|
|
18
|
+
* @default "/reference"
|
|
19
|
+
*/
|
|
20
|
+
path?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Disable the default HTML reference page
|
|
23
|
+
* Only the JSON schema endpoint will be available
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
disableDefaultReference?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Theme for the Scalar API Reference page
|
|
29
|
+
* @default "default"
|
|
30
|
+
*/
|
|
31
|
+
theme?: ScalarTheme;
|
|
32
|
+
/**
|
|
33
|
+
* CSP nonce for inline scripts
|
|
34
|
+
* Required for strict Content Security Policy
|
|
35
|
+
*/
|
|
36
|
+
nonce?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Custom title for the API documentation
|
|
39
|
+
* @default "Better Stack API"
|
|
40
|
+
*/
|
|
41
|
+
title?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Custom description for the API documentation
|
|
44
|
+
*/
|
|
45
|
+
description?: string;
|
|
46
|
+
/**
|
|
47
|
+
* API version string
|
|
48
|
+
* @default "1.0.0"
|
|
49
|
+
*/
|
|
50
|
+
version?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* OpenAPI plugin for Better Stack
|
|
54
|
+
*
|
|
55
|
+
* Automatically generates OpenAPI 3.1 documentation for all registered plugins.
|
|
56
|
+
* Provides both a JSON schema endpoint and an interactive Scalar UI reference page.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const { handler } = betterStack({
|
|
61
|
+
* basePath: "/api/data",
|
|
62
|
+
* plugins: {
|
|
63
|
+
* blog: blogBackendPlugin(),
|
|
64
|
+
* cms: cmsBackendPlugin({ ... }),
|
|
65
|
+
* openApi: openApiBackendPlugin({ theme: "moon" }),
|
|
66
|
+
* },
|
|
67
|
+
* adapter: (db) => createMemoryAdapter(db)({}),
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Access:
|
|
71
|
+
* // - GET /api/data/open-api/schema - JSON schema
|
|
72
|
+
* // - GET /api/data/reference - Interactive Scalar UI
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare const openApiBackendPlugin: (options?: OpenAPIOptions) => _btst_stack_plugins_api.BackendPlugin<{
|
|
76
|
+
readonly generateSchema: better_call.StrictEndpoint<"/open-api/schema", {
|
|
77
|
+
method: "GET";
|
|
78
|
+
}, Record<string, any>>;
|
|
79
|
+
readonly reference: better_call.StrictEndpoint<string, {
|
|
80
|
+
method: "GET";
|
|
81
|
+
}, Response>;
|
|
82
|
+
}>;
|
|
83
|
+
type OpenApiRouter = ReturnType<ReturnType<typeof openApiBackendPlugin>["routes"]>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Generate OpenAPI 3.1 schema from Better Stack context
|
|
87
|
+
*/
|
|
88
|
+
declare function generateOpenAPISchema(context: BetterStackContext, options?: {
|
|
89
|
+
title?: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
version?: string;
|
|
92
|
+
}): Record<string, any>;
|
|
93
|
+
|
|
94
|
+
export { generateOpenAPISchema, openApiBackendPlugin };
|
|
95
|
+
export type { OpenAPIOptions, OpenApiRouter, ScalarTheme };
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_api from '@btst/stack/plugins/api';
|
|
2
|
+
import * as better_call from 'better-call';
|
|
3
|
+
import { a as BetterStackContext } from '../../../shared/stack.CSce37mX.js';
|
|
4
|
+
import '@btst/yar';
|
|
5
|
+
import '@btst/db';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Scalar API Reference themes
|
|
9
|
+
*/
|
|
10
|
+
type ScalarTheme = "alternate" | "default" | "moon" | "purple" | "solarized" | "bluePlanet" | "saturn" | "kepler" | "mars" | "deepSpace" | "laserwave" | "none";
|
|
11
|
+
/**
|
|
12
|
+
* OpenAPI plugin configuration options
|
|
13
|
+
*/
|
|
14
|
+
interface OpenAPIOptions {
|
|
15
|
+
/**
|
|
16
|
+
* The path to the OpenAPI reference page
|
|
17
|
+
* This path is relative to the API base path
|
|
18
|
+
* @default "/reference"
|
|
19
|
+
*/
|
|
20
|
+
path?: string;
|
|
21
|
+
/**
|
|
22
|
+
* Disable the default HTML reference page
|
|
23
|
+
* Only the JSON schema endpoint will be available
|
|
24
|
+
* @default false
|
|
25
|
+
*/
|
|
26
|
+
disableDefaultReference?: boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Theme for the Scalar API Reference page
|
|
29
|
+
* @default "default"
|
|
30
|
+
*/
|
|
31
|
+
theme?: ScalarTheme;
|
|
32
|
+
/**
|
|
33
|
+
* CSP nonce for inline scripts
|
|
34
|
+
* Required for strict Content Security Policy
|
|
35
|
+
*/
|
|
36
|
+
nonce?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Custom title for the API documentation
|
|
39
|
+
* @default "Better Stack API"
|
|
40
|
+
*/
|
|
41
|
+
title?: string;
|
|
42
|
+
/**
|
|
43
|
+
* Custom description for the API documentation
|
|
44
|
+
*/
|
|
45
|
+
description?: string;
|
|
46
|
+
/**
|
|
47
|
+
* API version string
|
|
48
|
+
* @default "1.0.0"
|
|
49
|
+
*/
|
|
50
|
+
version?: string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* OpenAPI plugin for Better Stack
|
|
54
|
+
*
|
|
55
|
+
* Automatically generates OpenAPI 3.1 documentation for all registered plugins.
|
|
56
|
+
* Provides both a JSON schema endpoint and an interactive Scalar UI reference page.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* const { handler } = betterStack({
|
|
61
|
+
* basePath: "/api/data",
|
|
62
|
+
* plugins: {
|
|
63
|
+
* blog: blogBackendPlugin(),
|
|
64
|
+
* cms: cmsBackendPlugin({ ... }),
|
|
65
|
+
* openApi: openApiBackendPlugin({ theme: "moon" }),
|
|
66
|
+
* },
|
|
67
|
+
* adapter: (db) => createMemoryAdapter(db)({}),
|
|
68
|
+
* });
|
|
69
|
+
*
|
|
70
|
+
* // Access:
|
|
71
|
+
* // - GET /api/data/open-api/schema - JSON schema
|
|
72
|
+
* // - GET /api/data/reference - Interactive Scalar UI
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare const openApiBackendPlugin: (options?: OpenAPIOptions) => _btst_stack_plugins_api.BackendPlugin<{
|
|
76
|
+
readonly generateSchema: better_call.StrictEndpoint<"/open-api/schema", {
|
|
77
|
+
method: "GET";
|
|
78
|
+
}, Record<string, any>>;
|
|
79
|
+
readonly reference: better_call.StrictEndpoint<string, {
|
|
80
|
+
method: "GET";
|
|
81
|
+
}, Response>;
|
|
82
|
+
}>;
|
|
83
|
+
type OpenApiRouter = ReturnType<ReturnType<typeof openApiBackendPlugin>["routes"]>;
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Generate OpenAPI 3.1 schema from Better Stack context
|
|
87
|
+
*/
|
|
88
|
+
declare function generateOpenAPISchema(context: BetterStackContext, options?: {
|
|
89
|
+
title?: string;
|
|
90
|
+
description?: string;
|
|
91
|
+
version?: string;
|
|
92
|
+
}): Record<string, any>;
|
|
93
|
+
|
|
94
|
+
export { generateOpenAPISchema, openApiBackendPlugin };
|
|
95
|
+
export type { OpenAPIOptions, OpenApiRouter, ScalarTheme };
|
|
@@ -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 };
|