@btst/plugin-form-builder 0.0.0-stage → 1.0.0-beta.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/LICENSE.md +17 -0
- package/dist/api/getters.cjs +154 -0
- package/dist/api/getters.mjs +145 -0
- package/dist/api/index.cjs +25 -0
- package/dist/api/index.d.cts +119 -0
- package/dist/api/index.d.mts +119 -0
- package/dist/api/index.d.ts +119 -0
- package/dist/api/index.mjs +6 -0
- package/dist/api/lifecycle-migrations.cjs +15 -0
- package/dist/api/lifecycle-migrations.mjs +13 -0
- package/dist/api/operations.cjs +1093 -0
- package/dist/api/operations.mjs +1082 -0
- package/dist/api/plugin.cjs +201 -0
- package/dist/api/plugin.mjs +192 -0
- package/dist/api/query-key-defs.cjs +43 -0
- package/dist/api/query-key-defs.mjs +39 -0
- package/dist/client/components/forms/form-renderer.cjs +193 -0
- package/dist/client/components/forms/form-renderer.mjs +191 -0
- package/dist/client/components/index.cjs +29 -0
- package/dist/client/components/index.d.cts +97 -0
- package/dist/client/components/index.d.mts +97 -0
- package/dist/client/components/index.d.ts +97 -0
- package/dist/client/components/index.mjs +18 -0
- package/dist/client/components/loading/form-builder-skeleton.cjs +32 -0
- package/dist/client/components/loading/form-builder-skeleton.mjs +30 -0
- package/dist/client/components/loading/form-list-skeleton.cjs +21 -0
- package/dist/client/components/loading/form-list-skeleton.mjs +19 -0
- package/dist/client/components/loading/submissions-skeleton.cjs +34 -0
- package/dist/client/components/loading/submissions-skeleton.mjs +32 -0
- package/dist/client/components/pages/404-page.cjs +28 -0
- package/dist/client/components/pages/404-page.mjs +26 -0
- package/dist/client/components/pages/form-builder-page.cjs +77 -0
- package/dist/client/components/pages/form-builder-page.internal.cjs +217 -0
- package/dist/client/components/pages/form-builder-page.internal.mjs +215 -0
- package/dist/client/components/pages/form-builder-page.mjs +75 -0
- package/dist/client/components/pages/form-list-page.cjs +44 -0
- package/dist/client/components/pages/form-list-page.internal.cjs +282 -0
- package/dist/client/components/pages/form-list-page.internal.mjs +280 -0
- package/dist/client/components/pages/form-list-page.mjs +42 -0
- package/dist/client/components/pages/submissions-page.cjs +64 -0
- package/dist/client/components/pages/submissions-page.internal.cjs +255 -0
- package/dist/client/components/pages/submissions-page.internal.mjs +253 -0
- package/dist/client/components/pages/submissions-page.mjs +62 -0
- package/dist/client/components/shared/default-error.cjs +17 -0
- package/dist/client/components/shared/default-error.mjs +15 -0
- package/dist/client/components/shared/empty-state.cjs +16 -0
- package/dist/client/components/shared/empty-state.mjs +14 -0
- package/dist/client/components/shared/page-wrapper.cjs +29 -0
- package/dist/client/components/shared/page-wrapper.mjs +27 -0
- package/dist/client/components/shared/pagination.cjs +49 -0
- package/dist/client/components/shared/pagination.mjs +47 -0
- package/dist/client/constants.cjs +5 -0
- package/dist/client/constants.mjs +3 -0
- package/dist/client/hooks/form-builder-hooks.cjs +203 -0
- package/dist/client/hooks/form-builder-hooks.mjs +186 -0
- package/dist/client/hooks/form-builder-resource.cjs +13 -0
- package/dist/client/hooks/form-builder-resource.mjs +11 -0
- package/dist/client/hooks/index.cjs +22 -0
- package/dist/client/hooks/index.d.cts +378 -0
- package/dist/client/hooks/index.d.mts +378 -0
- package/dist/client/hooks/index.d.ts +378 -0
- package/dist/client/hooks/index.mjs +1 -0
- package/dist/client/index.cjs +13 -0
- package/dist/client/index.d.cts +410 -0
- package/dist/client/index.d.mts +410 -0
- package/dist/client/index.d.ts +410 -0
- package/dist/client/index.mjs +2 -0
- package/dist/client/plugin.cjs +311 -0
- package/dist/client/plugin.mjs +309 -0
- package/dist/client.css +3 -0
- package/dist/db.cjs +99 -0
- package/dist/db.mjs +97 -0
- package/dist/permissions.cjs +95 -0
- package/dist/permissions.d.cts +94 -0
- package/dist/permissions.d.mts +94 -0
- package/dist/permissions.d.ts +94 -0
- package/dist/permissions.mjs +93 -0
- package/dist/query-keys.cjs +140 -0
- package/dist/query-keys.d.cts +392 -0
- package/dist/query-keys.d.mts +392 -0
- package/dist/query-keys.d.ts +392 -0
- package/dist/query-keys.mjs +137 -0
- package/dist/schemas.cjs +91 -0
- package/dist/schemas.mjs +82 -0
- package/dist/shared/plugin-form-builder.BZYGyFgT.d.mts +351 -0
- package/dist/shared/plugin-form-builder.Bbl9NufB.d.cts +408 -0
- package/dist/shared/plugin-form-builder.CSP5HR2O.d.ts +408 -0
- package/dist/shared/plugin-form-builder.Cmk083dA.d.cts +351 -0
- package/dist/shared/plugin-form-builder.D258Qpb8.d.ts +351 -0
- package/dist/shared/plugin-form-builder.DWrQ3lRX.d.cts +118 -0
- package/dist/shared/plugin-form-builder.DWrQ3lRX.d.mts +118 -0
- package/dist/shared/plugin-form-builder.DWrQ3lRX.d.ts +118 -0
- package/dist/shared/plugin-form-builder.lp98rFNl.d.mts +408 -0
- package/dist/style.css +6 -0
- package/dist/types.cjs +2 -0
- package/dist/types.d.cts +6 -0
- package/dist/types.d.mts +6 -0
- package/dist/types.d.ts +6 -0
- package/dist/types.mjs +1 -0
- package/dist/ui/src/components/accordion.cjs +81 -0
- package/dist/ui/src/components/accordion.mjs +62 -0
- package/dist/ui/src/components/alert-dialog.cjs +157 -0
- package/dist/ui/src/components/alert-dialog.mjs +132 -0
- package/dist/ui/src/components/auto-form/common/label.cjs +18 -0
- package/dist/ui/src/components/auto-form/common/label.mjs +16 -0
- package/dist/ui/src/components/auto-form/common/tooltip.cjs +9 -0
- package/dist/ui/src/components/auto-form/common/tooltip.mjs +7 -0
- package/dist/ui/src/components/auto-form/config.cjs +40 -0
- package/dist/ui/src/components/auto-form/config.mjs +37 -0
- package/dist/ui/src/components/auto-form/dependencies.cjs +48 -0
- package/dist/ui/src/components/auto-form/dependencies.mjs +46 -0
- package/dist/ui/src/components/auto-form/fields/array.cjs +266 -0
- package/dist/ui/src/components/auto-form/fields/array.mjs +264 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/checkbox.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/date.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/date.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/enum.cjs +73 -0
- package/dist/ui/src/components/auto-form/fields/enum.mjs +71 -0
- package/dist/ui/src/components/auto-form/fields/input.cjs +32 -0
- package/dist/ui/src/components/auto-form/fields/input.mjs +30 -0
- package/dist/ui/src/components/auto-form/fields/number.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/number.mjs +29 -0
- package/dist/ui/src/components/auto-form/fields/object.cjs +233 -0
- package/dist/ui/src/components/auto-form/fields/object.mjs +217 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.cjs +67 -0
- package/dist/ui/src/components/auto-form/fields/radio-group.mjs +65 -0
- package/dist/ui/src/components/auto-form/fields/switch.cjs +38 -0
- package/dist/ui/src/components/auto-form/fields/switch.mjs +36 -0
- package/dist/ui/src/components/auto-form/fields/textarea.cjs +31 -0
- package/dist/ui/src/components/auto-form/fields/textarea.mjs +29 -0
- package/dist/ui/src/components/auto-form/helpers.cjs +270 -0
- package/dist/ui/src/components/auto-form/helpers.mjs +259 -0
- package/dist/ui/src/components/auto-form/index.cjs +92 -0
- package/dist/ui/src/components/auto-form/index.mjs +86 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.cjs +374 -0
- package/dist/ui/src/components/auto-form/stepped-auto-form.mjs +368 -0
- package/dist/ui/src/components/auto-form/types.cjs +11 -0
- package/dist/ui/src/components/auto-form/types.mjs +9 -0
- package/dist/ui/src/components/button.cjs +56 -0
- package/dist/ui/src/components/button.mjs +53 -0
- package/dist/ui/src/components/calendar.cjs +207 -0
- package/dist/ui/src/components/calendar.mjs +190 -0
- package/dist/ui/src/components/checkbox.cjs +48 -0
- package/dist/ui/src/components/checkbox.mjs +32 -0
- package/dist/ui/src/components/date-picker.cjs +41 -0
- package/dist/ui/src/components/date-picker.mjs +39 -0
- package/dist/ui/src/components/dialog.cjs +141 -0
- package/dist/ui/src/components/dialog.mjs +118 -0
- package/dist/ui/src/components/dropdown-menu.cjs +81 -0
- package/dist/ui/src/components/dropdown-menu.mjs +62 -0
- package/dist/ui/src/components/form-builder/canvas.cjs +111 -0
- package/dist/ui/src/components/form-builder/canvas.mjs +109 -0
- package/dist/ui/src/components/form-builder/components/index.cjs +571 -0
- package/dist/ui/src/components/form-builder/components/index.mjs +554 -0
- package/dist/ui/src/components/form-builder/edit-field-dialog.cjs +131 -0
- package/dist/ui/src/components/form-builder/edit-field-dialog.mjs +129 -0
- package/dist/ui/src/components/form-builder/form-preview.cjs +73 -0
- package/dist/ui/src/components/form-builder/form-preview.mjs +71 -0
- package/dist/ui/src/components/form-builder/index.cjs +350 -0
- package/dist/ui/src/components/form-builder/index.mjs +344 -0
- package/dist/ui/src/components/form-builder/nested-field-editor-dialog.cjs +263 -0
- package/dist/ui/src/components/form-builder/nested-field-editor-dialog.mjs +261 -0
- package/dist/ui/src/components/form-builder/palette.cjs +52 -0
- package/dist/ui/src/components/form-builder/palette.mjs +49 -0
- package/dist/ui/src/components/form-builder/schema-utils.cjs +128 -0
- package/dist/ui/src/components/form-builder/schema-utils.mjs +122 -0
- package/dist/ui/src/components/form-builder/sortable-field.cjs +151 -0
- package/dist/ui/src/components/form-builder/sortable-field.mjs +148 -0
- package/dist/ui/src/components/form-builder/step-tabs.cjs +180 -0
- package/dist/ui/src/components/form-builder/step-tabs.mjs +178 -0
- package/dist/ui/src/components/form-builder/types.cjs +7 -0
- package/dist/ui/src/components/form-builder/types.mjs +5 -0
- package/dist/ui/src/components/form-builder/validation-schemas.cjs +67 -0
- package/dist/ui/src/components/form-builder/validation-schemas.mjs +56 -0
- package/dist/ui/src/components/form.cjs +120 -0
- package/dist/ui/src/components/form.mjs +98 -0
- package/dist/ui/src/components/input.cjs +23 -0
- package/dist/ui/src/components/input.mjs +21 -0
- package/dist/ui/src/components/label.cjs +39 -0
- package/dist/ui/src/components/label.mjs +23 -0
- package/dist/ui/src/components/page-layout.cjs +25 -0
- package/dist/ui/src/components/page-layout.mjs +23 -0
- package/dist/ui/src/components/page-wrapper.cjs +20 -0
- package/dist/ui/src/components/page-wrapper.mjs +18 -0
- package/dist/ui/src/components/popover.cjs +60 -0
- package/dist/ui/src/components/popover.mjs +42 -0
- package/dist/ui/src/components/radio-group.cjs +62 -0
- package/dist/ui/src/components/radio-group.mjs +45 -0
- package/dist/ui/src/components/select.cjs +161 -0
- package/dist/ui/src/components/select.mjs +139 -0
- package/dist/ui/src/components/separator.cjs +43 -0
- package/dist/ui/src/components/separator.mjs +27 -0
- package/dist/ui/src/components/skeleton.cjs +17 -0
- package/dist/ui/src/components/skeleton.mjs +15 -0
- package/dist/ui/src/components/stack-attribution.cjs +24 -0
- package/dist/ui/src/components/stack-attribution.mjs +22 -0
- package/dist/ui/src/components/switch.cjs +48 -0
- package/dist/ui/src/components/switch.mjs +32 -0
- package/dist/ui/src/components/table.cjs +89 -0
- package/dist/ui/src/components/table.mjs +82 -0
- package/dist/ui/src/components/tabs.cjs +84 -0
- package/dist/ui/src/components/tabs.mjs +65 -0
- package/dist/ui/src/components/textarea.cjs +20 -0
- package/dist/ui/src/components/textarea.mjs +18 -0
- package/dist/ui/src/lib/schema-converter.cjs +133 -0
- package/dist/ui/src/lib/schema-converter.mjs +127 -0
- package/dist/ui/src/lib/utils.cjs +10 -0
- package/dist/ui/src/lib/utils.mjs +8 -0
- package/dist/utils.cjs +41 -0
- package/dist/utils.mjs +32 -0
- package/package.json +175 -3
- package/README.md +0 -3
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import * as _btst_stack_plugins_client from '@btst/stack/plugins/client';
|
|
2
|
+
import { createApiClient } from '@btst/stack/plugins/client';
|
|
3
|
+
import { j as FormsListDiscriminator, k as SubmissionsListDiscriminator } from './shared/plugin-form-builder.CSP5HR2O.js';
|
|
4
|
+
import { FormBuilderApiRouter } from './api/index.js';
|
|
5
|
+
import { PaginatedForms, SerializedForm, SerializedFormSubmission, PaginatedFormSubmissions, SerializedFormSubmissionWithData } from './types.js';
|
|
6
|
+
import { StackIdentity } from '@btst/stack/context';
|
|
7
|
+
import '@btst/stack/plugins/api';
|
|
8
|
+
import '@btst/db';
|
|
9
|
+
import 'zod';
|
|
10
|
+
import './permissions.js';
|
|
11
|
+
import '@btst/stack/authorization';
|
|
12
|
+
import 'zod/v4/core';
|
|
13
|
+
import 'better-call';
|
|
14
|
+
import '@tanstack/react-query';
|
|
15
|
+
|
|
16
|
+
/** Params for the paginated forms list (one page per `limit`). */
|
|
17
|
+
interface FormListParams {
|
|
18
|
+
status?: "active" | "inactive" | "archived";
|
|
19
|
+
limit?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Included in the query key discriminator for compatibility with
|
|
22
|
+
* callers that pass it explicitly; the infinite query itself injects
|
|
23
|
+
* the page offset per page (always starting at 0).
|
|
24
|
+
*/
|
|
25
|
+
offset?: number;
|
|
26
|
+
/** Free-text search across form names and slugs */
|
|
27
|
+
search?: string;
|
|
28
|
+
}
|
|
29
|
+
/** Params for the paginated submissions list of one form. */
|
|
30
|
+
interface SubmissionListParams {
|
|
31
|
+
formId: string;
|
|
32
|
+
limit?: number;
|
|
33
|
+
/** See {@link FormListParams.offset} */
|
|
34
|
+
offset?: number;
|
|
35
|
+
}
|
|
36
|
+
/** Input for the create-form mutation. */
|
|
37
|
+
interface CreateFormInput {
|
|
38
|
+
name: string;
|
|
39
|
+
slug: string;
|
|
40
|
+
description?: string;
|
|
41
|
+
schema: string;
|
|
42
|
+
successMessage?: string;
|
|
43
|
+
redirectUrl?: string;
|
|
44
|
+
status?: "active" | "inactive" | "archived";
|
|
45
|
+
}
|
|
46
|
+
/** Input for the update-form mutation. */
|
|
47
|
+
interface UpdateFormInput {
|
|
48
|
+
name?: string;
|
|
49
|
+
slug?: string;
|
|
50
|
+
description?: string;
|
|
51
|
+
schema?: string;
|
|
52
|
+
successMessage?: string;
|
|
53
|
+
redirectUrl?: string;
|
|
54
|
+
status?: "active" | "inactive" | "archived";
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Form Builder resource declaration — the single source of truth for query
|
|
58
|
+
* keys, HTTP mappings and mutations. Feeds both `createFormBuilderQueryKeys`
|
|
59
|
+
* (SSR loaders) and `createResource` (client hooks, see `client/hooks`).
|
|
60
|
+
*
|
|
61
|
+
* Key shapes intentionally match `FORM_QUERY_KEYS` in
|
|
62
|
+
* `api/query-key-defs.ts` so SSG `prefetchForRoute` hydration keeps working.
|
|
63
|
+
* List pages stay as `{ items, total, limit, offset }` envelopes (via
|
|
64
|
+
* `nextPageParam`) so `total` survives SSG dehydration.
|
|
65
|
+
*/
|
|
66
|
+
declare const formBuilderResources: {
|
|
67
|
+
forms: {
|
|
68
|
+
queries: {
|
|
69
|
+
list: {
|
|
70
|
+
path: string;
|
|
71
|
+
query: (p: FormListParams) => {
|
|
72
|
+
status: "active" | "inactive" | "archived" | undefined;
|
|
73
|
+
limit: number;
|
|
74
|
+
search: string | undefined;
|
|
75
|
+
};
|
|
76
|
+
key: (p: FormListParams) => (string | FormsListDiscriminator)[];
|
|
77
|
+
select: (data: any, _p: FormListParams) => PaginatedForms;
|
|
78
|
+
infinite: true;
|
|
79
|
+
pageSize: (p: FormListParams) => number;
|
|
80
|
+
nextPageParam: (lastPage: PaginatedForms, allPages: PaginatedForms[], p: FormListParams) => number | undefined;
|
|
81
|
+
};
|
|
82
|
+
bySlug: {
|
|
83
|
+
path: string;
|
|
84
|
+
params: (slug: string) => {
|
|
85
|
+
slug: string;
|
|
86
|
+
};
|
|
87
|
+
key: (slug: string) => string[];
|
|
88
|
+
select: (data: any, _slug: string) => SerializedForm | null;
|
|
89
|
+
skip: (slug: string) => boolean;
|
|
90
|
+
};
|
|
91
|
+
byId: {
|
|
92
|
+
path: string;
|
|
93
|
+
params: (id: string) => {
|
|
94
|
+
id: string;
|
|
95
|
+
};
|
|
96
|
+
key: (id: string) => string[];
|
|
97
|
+
select: (data: any, _id: string) => SerializedForm | null;
|
|
98
|
+
skip: (id: string) => boolean;
|
|
99
|
+
};
|
|
100
|
+
forUpdate: {
|
|
101
|
+
path: string;
|
|
102
|
+
params: (id: string) => {
|
|
103
|
+
id: string;
|
|
104
|
+
};
|
|
105
|
+
key: (id: string) => string[];
|
|
106
|
+
select: (data: any, _id: string) => SerializedForm | null;
|
|
107
|
+
skip: (id: string) => boolean;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
110
|
+
mutations: {
|
|
111
|
+
create: {
|
|
112
|
+
path: string;
|
|
113
|
+
method: "POST";
|
|
114
|
+
input: (vars: CreateFormInput) => {
|
|
115
|
+
body: CreateFormInput;
|
|
116
|
+
};
|
|
117
|
+
select: (data: any) => SerializedForm;
|
|
118
|
+
invalidates: string[];
|
|
119
|
+
};
|
|
120
|
+
update: {
|
|
121
|
+
path: string;
|
|
122
|
+
method: "PUT";
|
|
123
|
+
input: (vars: {
|
|
124
|
+
id: string;
|
|
125
|
+
data: UpdateFormInput;
|
|
126
|
+
}) => {
|
|
127
|
+
params: {
|
|
128
|
+
id: string;
|
|
129
|
+
};
|
|
130
|
+
body: UpdateFormInput;
|
|
131
|
+
};
|
|
132
|
+
select: (data: any) => SerializedForm;
|
|
133
|
+
invalidates: string[];
|
|
134
|
+
setData: {
|
|
135
|
+
query: string;
|
|
136
|
+
args: (updated: SerializedForm) => string[] | null;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
delete: {
|
|
140
|
+
path: string;
|
|
141
|
+
method: "DELETE";
|
|
142
|
+
input: (id: string) => {
|
|
143
|
+
params: {
|
|
144
|
+
id: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
select: (data: any) => {
|
|
148
|
+
success: boolean;
|
|
149
|
+
};
|
|
150
|
+
invalidates: string[];
|
|
151
|
+
};
|
|
152
|
+
submit: {
|
|
153
|
+
path: string;
|
|
154
|
+
method: "POST";
|
|
155
|
+
input: (vars: {
|
|
156
|
+
slug: string;
|
|
157
|
+
data: Record<string, unknown>;
|
|
158
|
+
}) => {
|
|
159
|
+
params: {
|
|
160
|
+
slug: string;
|
|
161
|
+
};
|
|
162
|
+
body: {
|
|
163
|
+
data: Record<string, unknown>;
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
select: (data: any) => SerializedFormSubmission & {
|
|
167
|
+
form: {
|
|
168
|
+
successMessage?: string;
|
|
169
|
+
redirectUrl?: string;
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
refresh: false;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
formSubmissions: {
|
|
177
|
+
queries: {
|
|
178
|
+
list: {
|
|
179
|
+
path: string;
|
|
180
|
+
params: (p: SubmissionListParams) => {
|
|
181
|
+
formId: string;
|
|
182
|
+
};
|
|
183
|
+
query: (p: SubmissionListParams) => {
|
|
184
|
+
limit: number;
|
|
185
|
+
};
|
|
186
|
+
key: (p: SubmissionListParams) => SubmissionsListDiscriminator[];
|
|
187
|
+
select: (data: any, _p: SubmissionListParams) => PaginatedFormSubmissions;
|
|
188
|
+
infinite: true;
|
|
189
|
+
pageSize: (p: SubmissionListParams) => number;
|
|
190
|
+
nextPageParam: (lastPage: PaginatedFormSubmissions, allPages: PaginatedFormSubmissions[], p: SubmissionListParams) => number | undefined;
|
|
191
|
+
};
|
|
192
|
+
detail: {
|
|
193
|
+
path: string;
|
|
194
|
+
params: (formId: string, subId: string, _identityPartition?: StackIdentity | null) => {
|
|
195
|
+
formId: string;
|
|
196
|
+
subId: string;
|
|
197
|
+
};
|
|
198
|
+
key: (formId: string, subId: string, identityPartition?: StackIdentity | null) => (string | {
|
|
199
|
+
identity: StackIdentity | null;
|
|
200
|
+
})[];
|
|
201
|
+
select: (data: any, _formId: string, _subId: string, _identityPartition?: StackIdentity | null) => SerializedFormSubmissionWithData | null;
|
|
202
|
+
skip: (formId: string, subId: string, _identityPartition?: StackIdentity | null) => boolean;
|
|
203
|
+
};
|
|
204
|
+
};
|
|
205
|
+
mutations: {
|
|
206
|
+
delete: {
|
|
207
|
+
path: string;
|
|
208
|
+
method: "DELETE";
|
|
209
|
+
input: (vars: {
|
|
210
|
+
formId: string;
|
|
211
|
+
subId: string;
|
|
212
|
+
}) => {
|
|
213
|
+
params: {
|
|
214
|
+
formId: string;
|
|
215
|
+
subId: string;
|
|
216
|
+
};
|
|
217
|
+
};
|
|
218
|
+
select: (data: any) => {
|
|
219
|
+
success: boolean;
|
|
220
|
+
};
|
|
221
|
+
invalidates: string[];
|
|
222
|
+
};
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
};
|
|
226
|
+
/**
|
|
227
|
+
* Create Form Builder query keys for React Query
|
|
228
|
+
* Used by consumers and SSR loaders to fetch forms and submissions
|
|
229
|
+
*/
|
|
230
|
+
declare function createFormBuilderQueryKeys(client: ReturnType<typeof createApiClient<FormBuilderApiRouter>>, headers?: HeadersInit): _btst_stack_plugins_client.ResourceQueryKeys<{
|
|
231
|
+
forms: {
|
|
232
|
+
queries: {
|
|
233
|
+
list: {
|
|
234
|
+
path: string;
|
|
235
|
+
query: (p: FormListParams) => {
|
|
236
|
+
status: "active" | "inactive" | "archived" | undefined;
|
|
237
|
+
limit: number;
|
|
238
|
+
search: string | undefined;
|
|
239
|
+
};
|
|
240
|
+
key: (p: FormListParams) => (string | FormsListDiscriminator)[];
|
|
241
|
+
select: (data: any, _p: FormListParams) => PaginatedForms;
|
|
242
|
+
infinite: true;
|
|
243
|
+
pageSize: (p: FormListParams) => number;
|
|
244
|
+
nextPageParam: (lastPage: PaginatedForms, allPages: PaginatedForms[], p: FormListParams) => number | undefined;
|
|
245
|
+
};
|
|
246
|
+
bySlug: {
|
|
247
|
+
path: string;
|
|
248
|
+
params: (slug: string) => {
|
|
249
|
+
slug: string;
|
|
250
|
+
};
|
|
251
|
+
key: (slug: string) => string[];
|
|
252
|
+
select: (data: any, _slug: string) => SerializedForm | null;
|
|
253
|
+
skip: (slug: string) => boolean;
|
|
254
|
+
};
|
|
255
|
+
byId: {
|
|
256
|
+
path: string;
|
|
257
|
+
params: (id: string) => {
|
|
258
|
+
id: string;
|
|
259
|
+
};
|
|
260
|
+
key: (id: string) => string[];
|
|
261
|
+
select: (data: any, _id: string) => SerializedForm | null;
|
|
262
|
+
skip: (id: string) => boolean;
|
|
263
|
+
};
|
|
264
|
+
forUpdate: {
|
|
265
|
+
path: string;
|
|
266
|
+
params: (id: string) => {
|
|
267
|
+
id: string;
|
|
268
|
+
};
|
|
269
|
+
key: (id: string) => string[];
|
|
270
|
+
select: (data: any, _id: string) => SerializedForm | null;
|
|
271
|
+
skip: (id: string) => boolean;
|
|
272
|
+
};
|
|
273
|
+
};
|
|
274
|
+
mutations: {
|
|
275
|
+
create: {
|
|
276
|
+
path: string;
|
|
277
|
+
method: "POST";
|
|
278
|
+
input: (vars: CreateFormInput) => {
|
|
279
|
+
body: CreateFormInput;
|
|
280
|
+
};
|
|
281
|
+
select: (data: any) => SerializedForm;
|
|
282
|
+
invalidates: string[];
|
|
283
|
+
};
|
|
284
|
+
update: {
|
|
285
|
+
path: string;
|
|
286
|
+
method: "PUT";
|
|
287
|
+
input: (vars: {
|
|
288
|
+
id: string;
|
|
289
|
+
data: UpdateFormInput;
|
|
290
|
+
}) => {
|
|
291
|
+
params: {
|
|
292
|
+
id: string;
|
|
293
|
+
};
|
|
294
|
+
body: UpdateFormInput;
|
|
295
|
+
};
|
|
296
|
+
select: (data: any) => SerializedForm;
|
|
297
|
+
invalidates: string[];
|
|
298
|
+
setData: {
|
|
299
|
+
query: string;
|
|
300
|
+
args: (updated: SerializedForm) => string[] | null;
|
|
301
|
+
};
|
|
302
|
+
};
|
|
303
|
+
delete: {
|
|
304
|
+
path: string;
|
|
305
|
+
method: "DELETE";
|
|
306
|
+
input: (id: string) => {
|
|
307
|
+
params: {
|
|
308
|
+
id: string;
|
|
309
|
+
};
|
|
310
|
+
};
|
|
311
|
+
select: (data: any) => {
|
|
312
|
+
success: boolean;
|
|
313
|
+
};
|
|
314
|
+
invalidates: string[];
|
|
315
|
+
};
|
|
316
|
+
submit: {
|
|
317
|
+
path: string;
|
|
318
|
+
method: "POST";
|
|
319
|
+
input: (vars: {
|
|
320
|
+
slug: string;
|
|
321
|
+
data: Record<string, unknown>;
|
|
322
|
+
}) => {
|
|
323
|
+
params: {
|
|
324
|
+
slug: string;
|
|
325
|
+
};
|
|
326
|
+
body: {
|
|
327
|
+
data: Record<string, unknown>;
|
|
328
|
+
};
|
|
329
|
+
};
|
|
330
|
+
select: (data: any) => SerializedFormSubmission & {
|
|
331
|
+
form: {
|
|
332
|
+
successMessage?: string;
|
|
333
|
+
redirectUrl?: string;
|
|
334
|
+
};
|
|
335
|
+
};
|
|
336
|
+
refresh: false;
|
|
337
|
+
};
|
|
338
|
+
};
|
|
339
|
+
};
|
|
340
|
+
formSubmissions: {
|
|
341
|
+
queries: {
|
|
342
|
+
list: {
|
|
343
|
+
path: string;
|
|
344
|
+
params: (p: SubmissionListParams) => {
|
|
345
|
+
formId: string;
|
|
346
|
+
};
|
|
347
|
+
query: (p: SubmissionListParams) => {
|
|
348
|
+
limit: number;
|
|
349
|
+
};
|
|
350
|
+
key: (p: SubmissionListParams) => SubmissionsListDiscriminator[];
|
|
351
|
+
select: (data: any, _p: SubmissionListParams) => PaginatedFormSubmissions;
|
|
352
|
+
infinite: true;
|
|
353
|
+
pageSize: (p: SubmissionListParams) => number;
|
|
354
|
+
nextPageParam: (lastPage: PaginatedFormSubmissions, allPages: PaginatedFormSubmissions[], p: SubmissionListParams) => number | undefined;
|
|
355
|
+
};
|
|
356
|
+
detail: {
|
|
357
|
+
path: string;
|
|
358
|
+
params: (formId: string, subId: string, _identityPartition?: StackIdentity | null) => {
|
|
359
|
+
formId: string;
|
|
360
|
+
subId: string;
|
|
361
|
+
};
|
|
362
|
+
key: (formId: string, subId: string, identityPartition?: StackIdentity | null) => (string | {
|
|
363
|
+
identity: StackIdentity | null;
|
|
364
|
+
})[];
|
|
365
|
+
select: (data: any, _formId: string, _subId: string, _identityPartition?: StackIdentity | null) => SerializedFormSubmissionWithData | null;
|
|
366
|
+
skip: (formId: string, subId: string, _identityPartition?: StackIdentity | null) => boolean;
|
|
367
|
+
};
|
|
368
|
+
};
|
|
369
|
+
mutations: {
|
|
370
|
+
delete: {
|
|
371
|
+
path: string;
|
|
372
|
+
method: "DELETE";
|
|
373
|
+
input: (vars: {
|
|
374
|
+
formId: string;
|
|
375
|
+
subId: string;
|
|
376
|
+
}) => {
|
|
377
|
+
params: {
|
|
378
|
+
formId: string;
|
|
379
|
+
subId: string;
|
|
380
|
+
};
|
|
381
|
+
};
|
|
382
|
+
select: (data: any) => {
|
|
383
|
+
success: boolean;
|
|
384
|
+
};
|
|
385
|
+
invalidates: string[];
|
|
386
|
+
};
|
|
387
|
+
};
|
|
388
|
+
};
|
|
389
|
+
}>;
|
|
390
|
+
|
|
391
|
+
export { createFormBuilderQueryKeys, formBuilderResources };
|
|
392
|
+
export type { CreateFormInput, FormListParams, SubmissionListParams, UpdateFormInput };
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { createResourceQueryKeys } from '@btst/stack/plugins/client';
|
|
2
|
+
import { submissionsListDiscriminator, formsListDiscriminator } from './api/query-key-defs.mjs';
|
|
3
|
+
|
|
4
|
+
function normalizeSearch(search) {
|
|
5
|
+
return search !== void 0 && search.trim() === "" ? void 0 : search;
|
|
6
|
+
}
|
|
7
|
+
function paginatedNextPageParam(lastPage, allPages, limit) {
|
|
8
|
+
const items = Array.isArray(lastPage?.items) ? lastPage.items : [];
|
|
9
|
+
if (items.length < limit) return void 0;
|
|
10
|
+
const loadedCount = allPages.reduce(
|
|
11
|
+
(sum, page) => sum + (Array.isArray(page?.items) ? page.items.length : 0),
|
|
12
|
+
0
|
|
13
|
+
);
|
|
14
|
+
const total = lastPage?.total ?? 0;
|
|
15
|
+
if (loadedCount >= total) return void 0;
|
|
16
|
+
return loadedCount;
|
|
17
|
+
}
|
|
18
|
+
const formBuilderResources = {
|
|
19
|
+
forms: {
|
|
20
|
+
queries: {
|
|
21
|
+
list: {
|
|
22
|
+
path: "/forms",
|
|
23
|
+
query: (p) => ({
|
|
24
|
+
status: p.status,
|
|
25
|
+
limit: p.limit ?? 20,
|
|
26
|
+
search: normalizeSearch(p.search)
|
|
27
|
+
}),
|
|
28
|
+
key: (p) => ["list", formsListDiscriminator(p)],
|
|
29
|
+
select: (data, _p) => data,
|
|
30
|
+
infinite: true,
|
|
31
|
+
pageSize: (p) => p.limit ?? 20,
|
|
32
|
+
nextPageParam: (lastPage, allPages, p) => paginatedNextPageParam(lastPage, allPages, p.limit ?? 20)
|
|
33
|
+
},
|
|
34
|
+
bySlug: {
|
|
35
|
+
path: "/forms/:slug",
|
|
36
|
+
params: (slug) => ({ slug }),
|
|
37
|
+
key: (slug) => ["bySlug", slug],
|
|
38
|
+
select: (data, _slug) => data ?? null,
|
|
39
|
+
skip: (slug) => !slug
|
|
40
|
+
},
|
|
41
|
+
byId: {
|
|
42
|
+
path: "/forms/id/:id",
|
|
43
|
+
params: (id) => ({ id }),
|
|
44
|
+
key: (id) => ["byId", id],
|
|
45
|
+
select: (data, _id) => data ?? null,
|
|
46
|
+
skip: (id) => !id
|
|
47
|
+
},
|
|
48
|
+
forUpdate: {
|
|
49
|
+
path: "/forms/id/:id/edit",
|
|
50
|
+
params: (id) => ({ id }),
|
|
51
|
+
key: (id) => ["forUpdate", id],
|
|
52
|
+
select: (data, _id) => data ?? null,
|
|
53
|
+
skip: (id) => !id
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
mutations: {
|
|
57
|
+
create: {
|
|
58
|
+
path: "@post/forms",
|
|
59
|
+
method: "POST",
|
|
60
|
+
input: (vars) => ({ body: vars }),
|
|
61
|
+
select: (data) => data,
|
|
62
|
+
invalidates: ["forms"]
|
|
63
|
+
},
|
|
64
|
+
update: {
|
|
65
|
+
path: "@put/forms/:id",
|
|
66
|
+
method: "PUT",
|
|
67
|
+
input: (vars) => ({
|
|
68
|
+
params: { id: vars.id },
|
|
69
|
+
body: vars.data
|
|
70
|
+
}),
|
|
71
|
+
select: (data) => data,
|
|
72
|
+
invalidates: ["forms"],
|
|
73
|
+
setData: {
|
|
74
|
+
query: "byId",
|
|
75
|
+
args: (updated) => updated ? [updated.id] : null
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
delete: {
|
|
79
|
+
path: "@delete/forms/:id",
|
|
80
|
+
method: "DELETE",
|
|
81
|
+
input: (id) => ({ params: { id } }),
|
|
82
|
+
select: (data) => data,
|
|
83
|
+
invalidates: ["forms"]
|
|
84
|
+
},
|
|
85
|
+
// Public form submission — no cache invalidation, and no router
|
|
86
|
+
// refresh: the success screen is client state in FormRenderer and a
|
|
87
|
+
// refresh (full reload on public pages) would wipe it.
|
|
88
|
+
submit: {
|
|
89
|
+
path: "@post/forms/:slug/submit",
|
|
90
|
+
method: "POST",
|
|
91
|
+
input: (vars) => ({
|
|
92
|
+
params: { slug: vars.slug },
|
|
93
|
+
body: { data: vars.data }
|
|
94
|
+
}),
|
|
95
|
+
select: (data) => data,
|
|
96
|
+
refresh: false
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
formSubmissions: {
|
|
101
|
+
queries: {
|
|
102
|
+
list: {
|
|
103
|
+
path: "/forms/:formId/submissions",
|
|
104
|
+
params: (p) => ({ formId: p.formId }),
|
|
105
|
+
query: (p) => ({ limit: p.limit ?? 20 }),
|
|
106
|
+
key: (p) => [submissionsListDiscriminator(p)],
|
|
107
|
+
select: (data, _p) => data,
|
|
108
|
+
infinite: true,
|
|
109
|
+
pageSize: (p) => p.limit ?? 20,
|
|
110
|
+
nextPageParam: (lastPage, allPages, p) => paginatedNextPageParam(lastPage, allPages, p.limit ?? 20)
|
|
111
|
+
},
|
|
112
|
+
detail: {
|
|
113
|
+
path: "/forms/:formId/submissions/:subId",
|
|
114
|
+
params: (formId, subId, _identityPartition) => ({ formId, subId }),
|
|
115
|
+
key: (formId, subId, identityPartition) => identityPartition === void 0 ? [formId, subId] : [formId, subId, { identity: identityPartition }],
|
|
116
|
+
select: (data, _formId, _subId, _identityPartition) => data ?? null,
|
|
117
|
+
skip: (formId, subId, _identityPartition) => !formId || !subId
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
mutations: {
|
|
121
|
+
delete: {
|
|
122
|
+
path: "@delete/forms/:formId/submissions/:subId",
|
|
123
|
+
method: "DELETE",
|
|
124
|
+
input: (vars) => ({
|
|
125
|
+
params: { formId: vars.formId, subId: vars.subId }
|
|
126
|
+
}),
|
|
127
|
+
select: (data) => data,
|
|
128
|
+
invalidates: ["formSubmissions"]
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
function createFormBuilderQueryKeys(client, headers) {
|
|
134
|
+
return createResourceQueryKeys(client, formBuilderResources, headers);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export { createFormBuilderQueryKeys, formBuilderResources };
|
package/dist/schemas.cjs
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const z = require('zod');
|
|
4
|
+
|
|
5
|
+
const DEFAULT_MAX_PAGE_SIZE = 1e3;
|
|
6
|
+
const listFormsQuerySchema = z.z.object({
|
|
7
|
+
status: z.z.enum(["active", "inactive", "archived"]).optional(),
|
|
8
|
+
limit: z.z.coerce.number().min(1).max(100).optional().default(20),
|
|
9
|
+
offset: z.z.coerce.number().min(0).optional().default(0),
|
|
10
|
+
search: z.z.string().max(200).optional()
|
|
11
|
+
});
|
|
12
|
+
const createFormSchema = z.z.object({
|
|
13
|
+
name: z.z.string().min(1, "Name is required"),
|
|
14
|
+
slug: z.z.string().min(1, "Slug is required"),
|
|
15
|
+
description: z.z.string().optional(),
|
|
16
|
+
schema: z.z.string().min(1, "Schema is required"),
|
|
17
|
+
successMessage: z.z.string().optional(),
|
|
18
|
+
redirectUrl: z.z.string().url().optional().or(z.z.literal("")),
|
|
19
|
+
status: z.z.enum(["active", "inactive", "archived"]).optional().default("active")
|
|
20
|
+
});
|
|
21
|
+
const updateFormSchema = z.z.object({
|
|
22
|
+
name: z.z.string().min(1, "Name is required").optional(),
|
|
23
|
+
slug: z.z.string().min(1, "Slug is required").optional(),
|
|
24
|
+
description: z.z.string().optional(),
|
|
25
|
+
schema: z.z.string().min(1, "Schema is required").optional(),
|
|
26
|
+
successMessage: z.z.string().optional(),
|
|
27
|
+
redirectUrl: z.z.string().url().optional().or(z.z.literal("")),
|
|
28
|
+
status: z.z.enum(["active", "inactive", "archived"]).optional()
|
|
29
|
+
});
|
|
30
|
+
const formResponseSchema = z.z.object({
|
|
31
|
+
id: z.z.string(),
|
|
32
|
+
name: z.z.string(),
|
|
33
|
+
slug: z.z.string(),
|
|
34
|
+
description: z.z.string().nullable().optional(),
|
|
35
|
+
schema: z.z.string(),
|
|
36
|
+
successMessage: z.z.string().nullable().optional(),
|
|
37
|
+
redirectUrl: z.z.string().nullable().optional(),
|
|
38
|
+
status: z.z.string(),
|
|
39
|
+
createdBy: z.z.string().nullable().optional(),
|
|
40
|
+
createdAt: z.z.string(),
|
|
41
|
+
updatedAt: z.z.string()
|
|
42
|
+
});
|
|
43
|
+
z.z.object({
|
|
44
|
+
items: z.z.array(formResponseSchema),
|
|
45
|
+
total: z.z.number(),
|
|
46
|
+
limit: z.z.number(),
|
|
47
|
+
offset: z.z.number()
|
|
48
|
+
});
|
|
49
|
+
const listSubmissionsQuerySchema = z.z.object({
|
|
50
|
+
limit: z.z.coerce.number().min(1).max(100).optional().default(20),
|
|
51
|
+
offset: z.z.coerce.number().min(0).optional().default(0)
|
|
52
|
+
});
|
|
53
|
+
z.z.object({
|
|
54
|
+
// Use passthrough object for dynamic form data validation
|
|
55
|
+
data: z.z.object({}).passthrough()
|
|
56
|
+
});
|
|
57
|
+
const formSubmissionResponseSchema = z.z.object({
|
|
58
|
+
id: z.z.string(),
|
|
59
|
+
formId: z.z.string(),
|
|
60
|
+
data: z.z.string(),
|
|
61
|
+
submittedAt: z.z.string(),
|
|
62
|
+
submittedBy: z.z.string().nullable().optional(),
|
|
63
|
+
ipAddress: z.z.string().nullable().optional(),
|
|
64
|
+
userAgent: z.z.string().nullable().optional()
|
|
65
|
+
});
|
|
66
|
+
formSubmissionResponseSchema.extend({
|
|
67
|
+
// Use passthrough object for dynamic parsed data
|
|
68
|
+
parsedData: z.z.object({}).passthrough(),
|
|
69
|
+
form: formResponseSchema.optional()
|
|
70
|
+
});
|
|
71
|
+
const formSubmissionSummaryResponseSchema = z.z.object({
|
|
72
|
+
id: z.z.string(),
|
|
73
|
+
formId: z.z.string(),
|
|
74
|
+
submittedAt: z.z.string(),
|
|
75
|
+
submittedBy: z.z.string().optional()
|
|
76
|
+
});
|
|
77
|
+
z.z.object({
|
|
78
|
+
items: z.z.array(formSubmissionSummaryResponseSchema),
|
|
79
|
+
total: z.z.number(),
|
|
80
|
+
limit: z.z.number(),
|
|
81
|
+
offset: z.z.number()
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
exports.DEFAULT_MAX_PAGE_SIZE = DEFAULT_MAX_PAGE_SIZE;
|
|
85
|
+
exports.createFormSchema = createFormSchema;
|
|
86
|
+
exports.formResponseSchema = formResponseSchema;
|
|
87
|
+
exports.formSubmissionResponseSchema = formSubmissionResponseSchema;
|
|
88
|
+
exports.formSubmissionSummaryResponseSchema = formSubmissionSummaryResponseSchema;
|
|
89
|
+
exports.listFormsQuerySchema = listFormsQuerySchema;
|
|
90
|
+
exports.listSubmissionsQuerySchema = listSubmissionsQuerySchema;
|
|
91
|
+
exports.updateFormSchema = updateFormSchema;
|
package/dist/schemas.mjs
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
const DEFAULT_MAX_PAGE_SIZE = 1e3;
|
|
4
|
+
const listFormsQuerySchema = z.object({
|
|
5
|
+
status: z.enum(["active", "inactive", "archived"]).optional(),
|
|
6
|
+
limit: z.coerce.number().min(1).max(100).optional().default(20),
|
|
7
|
+
offset: z.coerce.number().min(0).optional().default(0),
|
|
8
|
+
search: z.string().max(200).optional()
|
|
9
|
+
});
|
|
10
|
+
const createFormSchema = z.object({
|
|
11
|
+
name: z.string().min(1, "Name is required"),
|
|
12
|
+
slug: z.string().min(1, "Slug is required"),
|
|
13
|
+
description: z.string().optional(),
|
|
14
|
+
schema: z.string().min(1, "Schema is required"),
|
|
15
|
+
successMessage: z.string().optional(),
|
|
16
|
+
redirectUrl: z.string().url().optional().or(z.literal("")),
|
|
17
|
+
status: z.enum(["active", "inactive", "archived"]).optional().default("active")
|
|
18
|
+
});
|
|
19
|
+
const updateFormSchema = z.object({
|
|
20
|
+
name: z.string().min(1, "Name is required").optional(),
|
|
21
|
+
slug: z.string().min(1, "Slug is required").optional(),
|
|
22
|
+
description: z.string().optional(),
|
|
23
|
+
schema: z.string().min(1, "Schema is required").optional(),
|
|
24
|
+
successMessage: z.string().optional(),
|
|
25
|
+
redirectUrl: z.string().url().optional().or(z.literal("")),
|
|
26
|
+
status: z.enum(["active", "inactive", "archived"]).optional()
|
|
27
|
+
});
|
|
28
|
+
const formResponseSchema = z.object({
|
|
29
|
+
id: z.string(),
|
|
30
|
+
name: z.string(),
|
|
31
|
+
slug: z.string(),
|
|
32
|
+
description: z.string().nullable().optional(),
|
|
33
|
+
schema: z.string(),
|
|
34
|
+
successMessage: z.string().nullable().optional(),
|
|
35
|
+
redirectUrl: z.string().nullable().optional(),
|
|
36
|
+
status: z.string(),
|
|
37
|
+
createdBy: z.string().nullable().optional(),
|
|
38
|
+
createdAt: z.string(),
|
|
39
|
+
updatedAt: z.string()
|
|
40
|
+
});
|
|
41
|
+
z.object({
|
|
42
|
+
items: z.array(formResponseSchema),
|
|
43
|
+
total: z.number(),
|
|
44
|
+
limit: z.number(),
|
|
45
|
+
offset: z.number()
|
|
46
|
+
});
|
|
47
|
+
const listSubmissionsQuerySchema = z.object({
|
|
48
|
+
limit: z.coerce.number().min(1).max(100).optional().default(20),
|
|
49
|
+
offset: z.coerce.number().min(0).optional().default(0)
|
|
50
|
+
});
|
|
51
|
+
z.object({
|
|
52
|
+
// Use passthrough object for dynamic form data validation
|
|
53
|
+
data: z.object({}).passthrough()
|
|
54
|
+
});
|
|
55
|
+
const formSubmissionResponseSchema = z.object({
|
|
56
|
+
id: z.string(),
|
|
57
|
+
formId: z.string(),
|
|
58
|
+
data: z.string(),
|
|
59
|
+
submittedAt: z.string(),
|
|
60
|
+
submittedBy: z.string().nullable().optional(),
|
|
61
|
+
ipAddress: z.string().nullable().optional(),
|
|
62
|
+
userAgent: z.string().nullable().optional()
|
|
63
|
+
});
|
|
64
|
+
formSubmissionResponseSchema.extend({
|
|
65
|
+
// Use passthrough object for dynamic parsed data
|
|
66
|
+
parsedData: z.object({}).passthrough(),
|
|
67
|
+
form: formResponseSchema.optional()
|
|
68
|
+
});
|
|
69
|
+
const formSubmissionSummaryResponseSchema = z.object({
|
|
70
|
+
id: z.string(),
|
|
71
|
+
formId: z.string(),
|
|
72
|
+
submittedAt: z.string(),
|
|
73
|
+
submittedBy: z.string().optional()
|
|
74
|
+
});
|
|
75
|
+
z.object({
|
|
76
|
+
items: z.array(formSubmissionSummaryResponseSchema),
|
|
77
|
+
total: z.number(),
|
|
78
|
+
limit: z.number(),
|
|
79
|
+
offset: z.number()
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
export { DEFAULT_MAX_PAGE_SIZE, createFormSchema, formResponseSchema, formSubmissionResponseSchema, formSubmissionSummaryResponseSchema, listFormsQuerySchema, listSubmissionsQuerySchema, updateFormSchema };
|