@btst/stack 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/index.cjs +9 -1
- package/dist/api/index.d.cts +4 -4
- package/dist/api/index.d.mts +4 -4
- package/dist/api/index.d.ts +4 -4
- package/dist/api/index.mjs +9 -1
- package/dist/client/index.d.cts +2 -2
- package/dist/client/index.d.mts +2 -2
- package/dist/client/index.d.ts +2 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/packages/stack/src/plugins/ai-chat/api/getters.cjs +42 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/getters.mjs +39 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.cjs +5 -0
- package/dist/packages/stack/src/plugins/ai-chat/api/plugin.mjs +5 -0
- package/dist/packages/stack/src/plugins/blog/api/getters.cjs +131 -0
- package/dist/packages/stack/src/plugins/blog/api/getters.mjs +127 -0
- package/dist/packages/stack/src/plugins/blog/api/plugin.cjs +60 -107
- package/dist/packages/stack/src/plugins/blog/api/plugin.mjs +60 -107
- package/dist/packages/stack/src/plugins/blog/api/query-key-defs.cjs +18 -0
- package/dist/packages/stack/src/plugins/blog/api/query-key-defs.mjs +15 -0
- package/dist/packages/stack/src/plugins/blog/api/serializers.cjs +21 -0
- package/dist/packages/stack/src/plugins/blog/api/serializers.mjs +18 -0
- package/dist/packages/stack/src/plugins/blog/client/plugin.cjs +16 -1
- package/dist/packages/stack/src/plugins/blog/client/plugin.mjs +17 -2
- package/dist/packages/stack/src/plugins/cms/api/getters.cjs +156 -0
- package/dist/packages/stack/src/plugins/cms/api/getters.mjs +147 -0
- package/dist/packages/stack/src/plugins/cms/api/plugin.cjs +624 -617
- package/dist/packages/stack/src/plugins/cms/api/plugin.mjs +623 -616
- package/dist/packages/stack/src/plugins/cms/api/query-key-defs.cjs +29 -0
- package/dist/packages/stack/src/plugins/cms/api/query-key-defs.mjs +26 -0
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.cjs +1 -1
- package/dist/packages/stack/src/plugins/cms/client/components/pages/content-editor-page.internal.mjs +1 -1
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.cjs +6 -3
- package/dist/packages/stack/src/plugins/cms/client/hooks/cms-hooks.mjs +6 -3
- package/dist/packages/stack/src/plugins/cms/client/plugin.cjs +15 -0
- package/dist/packages/stack/src/plugins/cms/client/plugin.mjs +16 -1
- package/dist/packages/stack/src/plugins/form-builder/api/getters.cjs +120 -0
- package/dist/packages/stack/src/plugins/form-builder/api/getters.mjs +112 -0
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.cjs +75 -86
- package/dist/packages/stack/src/plugins/form-builder/api/plugin.mjs +71 -82
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.cjs +37 -0
- package/dist/packages/stack/src/plugins/form-builder/api/query-key-defs.mjs +33 -0
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.cjs +1 -1
- package/dist/packages/stack/src/plugins/form-builder/client/components/pages/submissions-page.internal.mjs +1 -1
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.cjs +15 -0
- package/dist/packages/stack/src/plugins/form-builder/client/plugin.mjs +16 -1
- package/dist/packages/stack/src/plugins/kanban/api/getters.cjs +84 -0
- package/dist/packages/stack/src/plugins/kanban/api/getters.mjs +81 -0
- package/dist/packages/stack/src/plugins/kanban/api/plugin.cjs +37 -123
- package/dist/packages/stack/src/plugins/kanban/api/plugin.mjs +37 -123
- package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.cjs +26 -0
- package/dist/packages/stack/src/plugins/kanban/api/query-key-defs.mjs +23 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.cjs +30 -0
- package/dist/packages/stack/src/plugins/kanban/api/serializers.mjs +26 -0
- package/dist/packages/stack/src/plugins/kanban/client/plugin.cjs +11 -1
- package/dist/packages/stack/src/plugins/kanban/client/plugin.mjs +12 -2
- package/dist/packages/stack/src/plugins/utils.cjs +6 -0
- package/dist/packages/stack/src/plugins/utils.mjs +6 -1
- package/dist/plugins/ai-chat/api/index.cjs +3 -0
- package/dist/plugins/ai-chat/api/index.d.cts +27 -4
- package/dist/plugins/ai-chat/api/index.d.mts +27 -4
- package/dist/plugins/ai-chat/api/index.d.ts +27 -4
- package/dist/plugins/ai-chat/api/index.mjs +1 -0
- package/dist/plugins/ai-chat/client/hooks/index.d.cts +2 -2
- package/dist/plugins/ai-chat/client/hooks/index.d.mts +2 -2
- package/dist/plugins/ai-chat/client/hooks/index.d.ts +2 -2
- package/dist/plugins/ai-chat/query-keys.d.cts +9 -284
- package/dist/plugins/ai-chat/query-keys.d.mts +9 -284
- package/dist/plugins/ai-chat/query-keys.d.ts +9 -284
- package/dist/plugins/api/index.d.cts +4 -3
- package/dist/plugins/api/index.d.mts +4 -3
- package/dist/plugins/api/index.d.ts +4 -3
- package/dist/plugins/blog/api/index.cjs +9 -0
- package/dist/plugins/blog/api/index.d.cts +20 -4
- package/dist/plugins/blog/api/index.d.mts +20 -4
- package/dist/plugins/blog/api/index.d.ts +20 -4
- package/dist/plugins/blog/api/index.mjs +3 -0
- package/dist/plugins/blog/client/hooks/index.d.cts +5 -5
- package/dist/plugins/blog/client/hooks/index.d.mts +5 -5
- package/dist/plugins/blog/client/hooks/index.d.ts +5 -5
- 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.cjs +13 -9
- package/dist/plugins/blog/query-keys.d.cts +8 -333
- package/dist/plugins/blog/query-keys.d.mts +8 -333
- package/dist/plugins/blog/query-keys.d.ts +8 -333
- package/dist/plugins/blog/query-keys.mjs +13 -9
- package/dist/plugins/client/index.cjs +1 -0
- package/dist/plugins/client/index.d.cts +10 -3
- package/dist/plugins/client/index.d.mts +10 -3
- package/dist/plugins/client/index.d.ts +10 -3
- package/dist/plugins/client/index.mjs +1 -1
- package/dist/plugins/cms/api/index.cjs +10 -0
- package/dist/plugins/cms/api/index.d.cts +7 -163
- package/dist/plugins/cms/api/index.d.mts +7 -163
- package/dist/plugins/cms/api/index.d.ts +7 -163
- package/dist/plugins/cms/api/index.mjs +2 -0
- package/dist/plugins/cms/client/hooks/index.d.cts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.mts +1 -1
- package/dist/plugins/cms/client/hooks/index.d.ts +1 -1
- package/dist/plugins/cms/query-keys.cjs +2 -1
- package/dist/plugins/cms/query-keys.d.cts +6 -9
- package/dist/plugins/cms/query-keys.d.mts +6 -9
- package/dist/plugins/cms/query-keys.d.ts +6 -9
- package/dist/plugins/cms/query-keys.mjs +2 -1
- package/dist/plugins/form-builder/api/index.cjs +10 -0
- package/dist/plugins/form-builder/api/index.d.cts +7 -141
- package/dist/plugins/form-builder/api/index.d.mts +7 -141
- package/dist/plugins/form-builder/api/index.d.ts +7 -141
- package/dist/plugins/form-builder/api/index.mjs +2 -0
- package/dist/plugins/form-builder/client/components/index.d.cts +1 -1
- package/dist/plugins/form-builder/client/components/index.d.mts +1 -1
- package/dist/plugins/form-builder/client/components/index.d.ts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.cts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.mts +1 -1
- package/dist/plugins/form-builder/client/hooks/index.d.ts +1 -1
- package/dist/plugins/form-builder/query-keys.cjs +3 -2
- package/dist/plugins/form-builder/query-keys.d.cts +7 -6
- package/dist/plugins/form-builder/query-keys.d.mts +7 -6
- package/dist/plugins/form-builder/query-keys.d.ts +7 -6
- package/dist/plugins/form-builder/query-keys.mjs +3 -2
- package/dist/plugins/kanban/api/index.cjs +9 -0
- package/dist/plugins/kanban/api/index.d.cts +17 -395
- package/dist/plugins/kanban/api/index.d.mts +17 -395
- package/dist/plugins/kanban/api/index.d.ts +17 -395
- package/dist/plugins/kanban/api/index.mjs +3 -0
- package/dist/plugins/kanban/client/components/index.d.cts +1 -1
- package/dist/plugins/kanban/client/components/index.d.mts +1 -1
- package/dist/plugins/kanban/client/components/index.d.ts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.cts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.mts +1 -1
- package/dist/plugins/kanban/client/hooks/index.d.ts +1 -1
- package/dist/plugins/kanban/client/index.d.cts +1 -1
- package/dist/plugins/kanban/client/index.d.mts +1 -1
- package/dist/plugins/kanban/client/index.d.ts +1 -1
- package/dist/plugins/kanban/query-keys.cjs +6 -12
- package/dist/plugins/kanban/query-keys.d.cts +5 -16
- package/dist/plugins/kanban/query-keys.d.mts +5 -16
- package/dist/plugins/kanban/query-keys.d.ts +5 -16
- package/dist/plugins/kanban/query-keys.mjs +6 -12
- package/dist/plugins/open-api/api/index.d.cts +2 -2
- package/dist/plugins/open-api/api/index.d.mts +2 -2
- package/dist/plugins/open-api/api/index.d.ts +2 -2
- package/dist/plugins/route-docs/client/index.d.cts +1 -1
- package/dist/plugins/route-docs/client/index.d.mts +1 -1
- package/dist/plugins/route-docs/client/index.d.ts +1 -1
- package/dist/plugins/ui-builder/index.d.cts +1 -1
- package/dist/plugins/ui-builder/index.d.mts +1 -1
- package/dist/plugins/ui-builder/index.d.ts +1 -1
- package/dist/shared/{stack.BoA0xkJv.d.cts → stack.7n9Y_u7N.d.cts} +33 -7
- package/dist/shared/{stack.BoA0xkJv.d.mts → stack.7n9Y_u7N.d.mts} +33 -7
- package/dist/shared/{stack.BoA0xkJv.d.ts → stack.7n9Y_u7N.d.ts} +33 -7
- package/dist/shared/stack.B1EeBt1b.d.ts +297 -0
- package/dist/shared/stack.BIXEI6v_.d.mts +419 -0
- package/dist/shared/stack.BKfolAyK.d.ts +419 -0
- package/dist/shared/stack.BeSm90va.d.ts +289 -0
- package/dist/shared/stack.BpolpQpf.d.cts +445 -0
- package/dist/shared/stack.C5dtIncc.d.mts +293 -0
- package/dist/shared/stack.CIP6QS9l.d.ts +293 -0
- package/dist/shared/stack.CMh_EdxW.d.cts +289 -0
- package/dist/shared/stack.CP68pFEH.d.mts +297 -0
- package/dist/shared/{stack.BsXokfNh.d.mts → stack.CVDTkMoO.d.cts} +8 -2
- package/dist/shared/{stack.BsXokfNh.d.ts → stack.CVDTkMoO.d.mts} +8 -2
- package/dist/shared/{stack.BsXokfNh.d.cts → stack.CVDTkMoO.d.ts} +8 -2
- package/dist/shared/{stack.DKDMI-QO.d.mts → stack.DJaKVY7v.d.cts} +7 -1
- package/dist/shared/{stack.DKDMI-QO.d.ts → stack.DJaKVY7v.d.mts} +7 -1
- package/dist/shared/{stack.DKDMI-QO.d.cts → stack.DJaKVY7v.d.ts} +7 -1
- package/dist/shared/{stack.DzH_wcvr.d.mts → stack.DdI5W6MB.d.cts} +9 -3
- package/dist/shared/{stack.DzH_wcvr.d.ts → stack.DdI5W6MB.d.mts} +9 -3
- package/dist/shared/{stack.DzH_wcvr.d.cts → stack.DdI5W6MB.d.ts} +9 -3
- package/dist/shared/stack.Dg09R0oB.d.mts +289 -0
- package/dist/shared/stack.Dw0Ly2TM.d.cts +293 -0
- package/dist/shared/stack.IdtKDRka.d.cts +297 -0
- package/dist/shared/stack.TIBF2AOx.d.ts +445 -0
- package/dist/shared/stack.rTy7-wQU.d.mts +445 -0
- package/dist/shared/stack.snB1EDP7.d.cts +419 -0
- package/package.json +3 -3
- package/src/__tests__/stack-api.test.ts +118 -0
- package/src/api/index.ts +15 -1
- package/src/plugins/ai-chat/__tests__/getters.test.ts +109 -0
- package/src/plugins/ai-chat/api/getters.ts +71 -0
- package/src/plugins/ai-chat/api/index.ts +1 -0
- package/src/plugins/ai-chat/api/plugin.ts +8 -0
- package/src/plugins/api/index.ts +3 -1
- package/src/plugins/blog/__tests__/getters.test.ts +540 -0
- package/src/plugins/blog/api/getters.ts +243 -0
- package/src/plugins/blog/api/index.ts +9 -0
- package/src/plugins/blog/api/plugin.ts +98 -141
- package/src/plugins/blog/api/query-key-defs.ts +46 -0
- package/src/plugins/blog/api/serializers.ts +27 -0
- package/src/plugins/blog/client/plugin.tsx +21 -1
- package/src/plugins/blog/query-keys.ts +21 -20
- package/src/plugins/client/index.ts +1 -1
- package/src/plugins/cms/__tests__/getters.test.ts +206 -0
- package/src/plugins/cms/api/getters.ts +268 -0
- package/src/plugins/cms/api/index.ts +15 -1
- package/src/plugins/cms/api/plugin.ts +151 -150
- package/src/plugins/cms/api/query-key-defs.ts +53 -0
- package/src/plugins/cms/api/serializers.ts +12 -0
- package/src/plugins/cms/client/components/pages/content-editor-page.internal.tsx +1 -1
- package/src/plugins/cms/client/hooks/cms-hooks.tsx +3 -0
- package/src/plugins/cms/client/plugin.tsx +19 -0
- package/src/plugins/cms/query-keys.ts +2 -1
- package/src/plugins/cms/types.ts +1 -1
- package/src/plugins/form-builder/__tests__/getters.test.ts +159 -0
- package/src/plugins/form-builder/api/getters.ts +226 -0
- package/src/plugins/form-builder/api/index.ts +15 -1
- package/src/plugins/form-builder/api/plugin.ts +107 -109
- package/src/plugins/form-builder/api/query-key-defs.ts +79 -0
- package/src/plugins/form-builder/api/serializers.ts +12 -0
- package/src/plugins/form-builder/client/components/pages/submissions-page.internal.tsx +1 -1
- package/src/plugins/form-builder/client/plugin.tsx +19 -0
- package/src/plugins/form-builder/query-keys.ts +6 -2
- package/src/plugins/form-builder/types.ts +2 -2
- package/src/plugins/kanban/__tests__/getters.test.ts +172 -0
- package/src/plugins/kanban/api/getters.ts +149 -0
- package/src/plugins/kanban/api/index.ts +4 -0
- package/src/plugins/kanban/api/plugin.ts +65 -146
- package/src/plugins/kanban/api/query-key-defs.ts +54 -0
- package/src/plugins/kanban/api/serializers.ts +49 -0
- package/src/plugins/kanban/client/plugin.tsx +15 -1
- package/src/plugins/kanban/query-keys.ts +10 -14
- package/src/plugins/utils.ts +19 -0
- package/src/types.ts +44 -5
- package/dist/shared/{stack.CbuN2zVV.d.cts → stack.CBON0dWL.d.cts} +7 -7
- package/dist/shared/{stack.CbuN2zVV.d.mts → stack.CBON0dWL.d.mts} +7 -7
- package/dist/shared/{stack.CbuN2zVV.d.ts → stack.CBON0dWL.d.ts} +7 -7
|
@@ -4,38 +4,77 @@ import { formSchemaToZod } from '../../../../../ui/src/lib/schema-converter.mjs'
|
|
|
4
4
|
import { formBuilderSchema } from '../db.mjs';
|
|
5
5
|
import { listFormsQuerySchema, createFormSchema, updateFormSchema, listSubmissionsQuerySchema } from '../schemas.mjs';
|
|
6
6
|
import { extractUserAgent, extractIpAddress, slugify } from '../utils.mjs';
|
|
7
|
+
import { getFormSubmissions, getFormBySlug, getFormById, getAllForms, serializeForm, serializeFormSubmission, serializeFormSubmissionWithData } from './getters.mjs';
|
|
8
|
+
import { FORM_QUERY_KEYS } from './query-key-defs.mjs';
|
|
7
9
|
|
|
8
|
-
function
|
|
9
|
-
return {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
10
|
+
function createFormBuilderPrefetchForRoute(adapter) {
|
|
11
|
+
return async function prefetchForRoute(key, qc, params) {
|
|
12
|
+
switch (key) {
|
|
13
|
+
case "formList": {
|
|
14
|
+
const result = await getAllForms(adapter, { limit: 20, offset: 0 });
|
|
15
|
+
qc.setQueryData(FORM_QUERY_KEYS.formsList({ limit: 20, offset: 0 }), {
|
|
16
|
+
pages: [
|
|
17
|
+
{
|
|
18
|
+
items: result.items,
|
|
19
|
+
total: result.total,
|
|
20
|
+
limit: result.limit ?? 20,
|
|
21
|
+
offset: result.offset ?? 0
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
pageParams: [0]
|
|
25
|
+
});
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case "editForm": {
|
|
29
|
+
const id = params?.id ?? "";
|
|
30
|
+
if (id) {
|
|
31
|
+
const form = await getFormById(adapter, id);
|
|
32
|
+
qc.setQueryData(FORM_QUERY_KEYS.formById(id), form);
|
|
33
|
+
}
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case "submissions": {
|
|
37
|
+
const id = params?.id ?? "";
|
|
38
|
+
if (id) {
|
|
39
|
+
const [form, submissionsResult] = await Promise.all([
|
|
40
|
+
getFormById(adapter, id),
|
|
41
|
+
getFormSubmissions(adapter, id, { limit: 20, offset: 0 })
|
|
42
|
+
]);
|
|
43
|
+
qc.setQueryData(FORM_QUERY_KEYS.formById(id), form);
|
|
44
|
+
qc.setQueryData(
|
|
45
|
+
FORM_QUERY_KEYS.submissionsList({
|
|
46
|
+
formId: id,
|
|
47
|
+
limit: 20,
|
|
48
|
+
offset: 0
|
|
49
|
+
}),
|
|
50
|
+
{
|
|
51
|
+
pages: [
|
|
52
|
+
{
|
|
53
|
+
items: submissionsResult.items,
|
|
54
|
+
total: submissionsResult.total,
|
|
55
|
+
limit: submissionsResult.limit ?? 20,
|
|
56
|
+
offset: submissionsResult.offset ?? 0
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
pageParams: [0]
|
|
60
|
+
}
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
34
66
|
};
|
|
35
67
|
}
|
|
36
68
|
const formBuilderBackendPlugin = (config = {}) => defineBackendPlugin({
|
|
37
69
|
name: "form-builder",
|
|
38
70
|
dbPlugin: formBuilderSchema,
|
|
71
|
+
api: (adapter) => ({
|
|
72
|
+
getAllForms: (params) => getAllForms(adapter, params),
|
|
73
|
+
getFormById: (id) => getFormById(adapter, id),
|
|
74
|
+
getFormBySlug: (slug) => getFormBySlug(adapter, slug),
|
|
75
|
+
getFormSubmissions: (formId, params) => getFormSubmissions(adapter, formId, params),
|
|
76
|
+
prefetchForRoute: createFormBuilderPrefetchForRoute(adapter)
|
|
77
|
+
}),
|
|
39
78
|
routes: (adapter) => {
|
|
40
79
|
const createContext = (headers) => ({
|
|
41
80
|
headers,
|
|
@@ -62,35 +101,10 @@ const formBuilderBackendPlugin = (config = {}) => defineBackendPlugin({
|
|
|
62
101
|
throw ctx.error(403, { message: "Access denied" });
|
|
63
102
|
}
|
|
64
103
|
}
|
|
65
|
-
|
|
66
|
-
if (status) {
|
|
67
|
-
whereConditions.push({
|
|
68
|
-
field: "status",
|
|
69
|
-
value: status,
|
|
70
|
-
operator: "eq"
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
const allForms = await adapter.findMany({
|
|
74
|
-
model: "form",
|
|
75
|
-
where: whereConditions.length > 0 ? whereConditions : void 0
|
|
76
|
-
});
|
|
77
|
-
const total = allForms.length;
|
|
78
|
-
const forms = await adapter.findMany({
|
|
79
|
-
model: "form",
|
|
80
|
-
where: whereConditions.length > 0 ? whereConditions : void 0,
|
|
81
|
-
limit,
|
|
82
|
-
offset,
|
|
83
|
-
sortBy: { field: "createdAt", direction: "desc" }
|
|
84
|
-
});
|
|
85
|
-
return {
|
|
86
|
-
items: forms.map(serializeForm),
|
|
87
|
-
total,
|
|
88
|
-
limit,
|
|
89
|
-
offset
|
|
90
|
-
};
|
|
104
|
+
return getAllForms(adapter, { status, limit, offset });
|
|
91
105
|
}
|
|
92
106
|
);
|
|
93
|
-
const getFormBySlug = createEndpoint(
|
|
107
|
+
const getFormBySlug$1 = createEndpoint(
|
|
94
108
|
"/forms/:slug",
|
|
95
109
|
{
|
|
96
110
|
method: "GET",
|
|
@@ -105,14 +119,11 @@ const formBuilderBackendPlugin = (config = {}) => defineBackendPlugin({
|
|
|
105
119
|
throw ctx.error(403, { message: "Access denied" });
|
|
106
120
|
}
|
|
107
121
|
}
|
|
108
|
-
const form = await adapter
|
|
109
|
-
model: "form",
|
|
110
|
-
where: [{ field: "slug", value: slug, operator: "eq" }]
|
|
111
|
-
});
|
|
122
|
+
const form = await getFormBySlug(adapter, slug);
|
|
112
123
|
if (!form) {
|
|
113
124
|
throw ctx.error(404, { message: "Form not found" });
|
|
114
125
|
}
|
|
115
|
-
return
|
|
126
|
+
return form;
|
|
116
127
|
}
|
|
117
128
|
);
|
|
118
129
|
const getFormById = createEndpoint(
|
|
@@ -479,29 +490,7 @@ const formBuilderBackendPlugin = (config = {}) => defineBackendPlugin({
|
|
|
479
490
|
throw ctx.error(403, { message: "Access denied" });
|
|
480
491
|
}
|
|
481
492
|
}
|
|
482
|
-
|
|
483
|
-
model: "formSubmission",
|
|
484
|
-
where: [
|
|
485
|
-
{ field: "formId", value: formId, operator: "eq" }
|
|
486
|
-
]
|
|
487
|
-
});
|
|
488
|
-
const total = allSubmissions.length;
|
|
489
|
-
const submissions = await adapter.findMany({
|
|
490
|
-
model: "formSubmission",
|
|
491
|
-
where: [
|
|
492
|
-
{ field: "formId", value: formId, operator: "eq" }
|
|
493
|
-
],
|
|
494
|
-
limit,
|
|
495
|
-
offset,
|
|
496
|
-
sortBy: { field: "submittedAt", direction: "desc" },
|
|
497
|
-
join: { form: true }
|
|
498
|
-
});
|
|
499
|
-
return {
|
|
500
|
-
items: submissions.map(serializeFormSubmissionWithData),
|
|
501
|
-
total,
|
|
502
|
-
limit,
|
|
503
|
-
offset
|
|
504
|
-
};
|
|
493
|
+
return getFormSubmissions(adapter, formId, { limit, offset });
|
|
505
494
|
}
|
|
506
495
|
);
|
|
507
496
|
const getSubmission = createEndpoint(
|
|
@@ -570,7 +559,7 @@ const formBuilderBackendPlugin = (config = {}) => defineBackendPlugin({
|
|
|
570
559
|
);
|
|
571
560
|
return {
|
|
572
561
|
listForms,
|
|
573
|
-
getFormBySlug,
|
|
562
|
+
getFormBySlug: getFormBySlug$1,
|
|
574
563
|
getFormById,
|
|
575
564
|
createForm,
|
|
576
565
|
updateForm,
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function formsListDiscriminator(params) {
|
|
4
|
+
return {
|
|
5
|
+
status: params?.status,
|
|
6
|
+
limit: params?.limit ?? 20,
|
|
7
|
+
offset: params?.offset ?? 0
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
function submissionsListDiscriminator(params) {
|
|
11
|
+
return {
|
|
12
|
+
formId: params.formId,
|
|
13
|
+
limit: params.limit ?? 20,
|
|
14
|
+
offset: params.offset ?? 0
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
const FORM_QUERY_KEYS = {
|
|
18
|
+
/**
|
|
19
|
+
* Key for forms.list(params) query.
|
|
20
|
+
* Full key: ["forms", "list", "list", { status, limit, offset }]
|
|
21
|
+
*/
|
|
22
|
+
formsList: (params) => ["forms", "list", "list", formsListDiscriminator(params)],
|
|
23
|
+
/**
|
|
24
|
+
* Key for forms.byId(id) query.
|
|
25
|
+
* Full key: ["forms", "byId", "byId", id]
|
|
26
|
+
*/
|
|
27
|
+
formById: (id) => ["forms", "byId", "byId", id],
|
|
28
|
+
/**
|
|
29
|
+
* Key for formSubmissions.list(params) query.
|
|
30
|
+
* Full key: ["formSubmissions", "list", { formId, limit, offset }]
|
|
31
|
+
*/
|
|
32
|
+
submissionsList: (params) => ["formSubmissions", "list", submissionsListDiscriminator(params)]
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
exports.FORM_QUERY_KEYS = FORM_QUERY_KEYS;
|
|
36
|
+
exports.formsListDiscriminator = formsListDiscriminator;
|
|
37
|
+
exports.submissionsListDiscriminator = submissionsListDiscriminator;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
function formsListDiscriminator(params) {
|
|
2
|
+
return {
|
|
3
|
+
status: params?.status,
|
|
4
|
+
limit: params?.limit ?? 20,
|
|
5
|
+
offset: params?.offset ?? 0
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
function submissionsListDiscriminator(params) {
|
|
9
|
+
return {
|
|
10
|
+
formId: params.formId,
|
|
11
|
+
limit: params.limit ?? 20,
|
|
12
|
+
offset: params.offset ?? 0
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
const FORM_QUERY_KEYS = {
|
|
16
|
+
/**
|
|
17
|
+
* Key for forms.list(params) query.
|
|
18
|
+
* Full key: ["forms", "list", "list", { status, limit, offset }]
|
|
19
|
+
*/
|
|
20
|
+
formsList: (params) => ["forms", "list", "list", formsListDiscriminator(params)],
|
|
21
|
+
/**
|
|
22
|
+
* Key for forms.byId(id) query.
|
|
23
|
+
* Full key: ["forms", "byId", "byId", id]
|
|
24
|
+
*/
|
|
25
|
+
formById: (id) => ["forms", "byId", "byId", id],
|
|
26
|
+
/**
|
|
27
|
+
* Key for formSubmissions.list(params) query.
|
|
28
|
+
* Full key: ["formSubmissions", "list", { formId, limit, offset }]
|
|
29
|
+
*/
|
|
30
|
+
submissionsList: (params) => ["formSubmissions", "list", submissionsListDiscriminator(params)]
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
export { FORM_QUERY_KEYS, formsListDiscriminator, submissionsListDiscriminator };
|
|
@@ -76,7 +76,7 @@ function SubmissionsPage({ formId }) {
|
|
|
76
76
|
sub.id.slice(0, 8),
|
|
77
77
|
"..."
|
|
78
78
|
] }),
|
|
79
|
-
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "max-w-xs truncate text-sm text-muted-foreground", children: formatSubmissionData(sub.parsedData) }),
|
|
79
|
+
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "max-w-xs truncate text-sm text-muted-foreground", children: formatSubmissionData(sub.parsedData ?? {}) }),
|
|
80
80
|
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "text-muted-foreground", children: new Date(sub.submittedAt).toLocaleString() }),
|
|
81
81
|
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { className: "text-muted-foreground font-mono text-xs", children: sub.ipAddress || "-" }),
|
|
82
82
|
/* @__PURE__ */ jsxRuntime.jsx(table.TableCell, { children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex gap-1", children: [
|
|
@@ -74,7 +74,7 @@ function SubmissionsPage({ formId }) {
|
|
|
74
74
|
sub.id.slice(0, 8),
|
|
75
75
|
"..."
|
|
76
76
|
] }),
|
|
77
|
-
/* @__PURE__ */ jsx(TableCell, { className: "max-w-xs truncate text-sm text-muted-foreground", children: formatSubmissionData(sub.parsedData) }),
|
|
77
|
+
/* @__PURE__ */ jsx(TableCell, { className: "max-w-xs truncate text-sm text-muted-foreground", children: formatSubmissionData(sub.parsedData ?? {}) }),
|
|
78
78
|
/* @__PURE__ */ jsx(TableCell, { className: "text-muted-foreground", children: new Date(sub.submittedAt).toLocaleString() }),
|
|
79
79
|
/* @__PURE__ */ jsx(TableCell, { className: "text-muted-foreground font-mono text-xs", children: sub.ipAddress || "-" }),
|
|
80
80
|
/* @__PURE__ */ jsx(TableCell, { children: /* @__PURE__ */ jsxs("div", { className: "flex gap-1", children: [
|
|
@@ -70,6 +70,11 @@ function createFormListLoader(config) {
|
|
|
70
70
|
await hooks.onLoadError(error, context);
|
|
71
71
|
}
|
|
72
72
|
} catch (error) {
|
|
73
|
+
if (client.isConnectionError(error)) {
|
|
74
|
+
console.warn(
|
|
75
|
+
"[btst/form-builder] route.loader() failed \u2014 no server running at build time. Use myStack.api.formBuilder.prefetchForRoute() for SSG data prefetching."
|
|
76
|
+
);
|
|
77
|
+
}
|
|
73
78
|
if (hooks?.onLoadError) {
|
|
74
79
|
await hooks.onLoadError(error, context);
|
|
75
80
|
}
|
|
@@ -117,6 +122,11 @@ function createFormBuilderLoader(id, config) {
|
|
|
117
122
|
}
|
|
118
123
|
}
|
|
119
124
|
} catch (error) {
|
|
125
|
+
if (client.isConnectionError(error)) {
|
|
126
|
+
console.warn(
|
|
127
|
+
"[btst/form-builder] route.loader() failed \u2014 no server running at build time. Use myStack.api.formBuilder.prefetchForRoute() for SSG data prefetching."
|
|
128
|
+
);
|
|
129
|
+
}
|
|
120
130
|
if (hooks?.onLoadError) {
|
|
121
131
|
await hooks.onLoadError(error, context);
|
|
122
132
|
}
|
|
@@ -189,6 +199,11 @@ function createSubmissionsLoader(formId, config) {
|
|
|
189
199
|
await hooks.onLoadError(error, context);
|
|
190
200
|
}
|
|
191
201
|
} catch (error) {
|
|
202
|
+
if (client.isConnectionError(error)) {
|
|
203
|
+
console.warn(
|
|
204
|
+
"[btst/form-builder] route.loader() failed \u2014 no server running at build time. Use myStack.api.formBuilder.prefetchForRoute() for SSG data prefetching."
|
|
205
|
+
);
|
|
206
|
+
}
|
|
192
207
|
if (hooks?.onLoadError) {
|
|
193
208
|
await hooks.onLoadError(error, context);
|
|
194
209
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { lazy } from 'react';
|
|
3
|
-
import { defineClientPlugin, createApiClient } from '@btst/stack/plugins/client';
|
|
3
|
+
import { defineClientPlugin, createApiClient, isConnectionError } from '@btst/stack/plugins/client';
|
|
4
4
|
import { createRoute } from '@btst/yar';
|
|
5
5
|
import { createFormBuilderQueryKeys } from '../../../../../../plugins/form-builder/query-keys.mjs';
|
|
6
6
|
|
|
@@ -68,6 +68,11 @@ function createFormListLoader(config) {
|
|
|
68
68
|
await hooks.onLoadError(error, context);
|
|
69
69
|
}
|
|
70
70
|
} catch (error) {
|
|
71
|
+
if (isConnectionError(error)) {
|
|
72
|
+
console.warn(
|
|
73
|
+
"[btst/form-builder] route.loader() failed \u2014 no server running at build time. Use myStack.api.formBuilder.prefetchForRoute() for SSG data prefetching."
|
|
74
|
+
);
|
|
75
|
+
}
|
|
71
76
|
if (hooks?.onLoadError) {
|
|
72
77
|
await hooks.onLoadError(error, context);
|
|
73
78
|
}
|
|
@@ -115,6 +120,11 @@ function createFormBuilderLoader(id, config) {
|
|
|
115
120
|
}
|
|
116
121
|
}
|
|
117
122
|
} catch (error) {
|
|
123
|
+
if (isConnectionError(error)) {
|
|
124
|
+
console.warn(
|
|
125
|
+
"[btst/form-builder] route.loader() failed \u2014 no server running at build time. Use myStack.api.formBuilder.prefetchForRoute() for SSG data prefetching."
|
|
126
|
+
);
|
|
127
|
+
}
|
|
118
128
|
if (hooks?.onLoadError) {
|
|
119
129
|
await hooks.onLoadError(error, context);
|
|
120
130
|
}
|
|
@@ -187,6 +197,11 @@ function createSubmissionsLoader(formId, config) {
|
|
|
187
197
|
await hooks.onLoadError(error, context);
|
|
188
198
|
}
|
|
189
199
|
} catch (error) {
|
|
200
|
+
if (isConnectionError(error)) {
|
|
201
|
+
console.warn(
|
|
202
|
+
"[btst/form-builder] route.loader() failed \u2014 no server running at build time. Use myStack.api.formBuilder.prefetchForRoute() for SSG data prefetching."
|
|
203
|
+
);
|
|
204
|
+
}
|
|
190
205
|
if (hooks?.onLoadError) {
|
|
191
206
|
await hooks.onLoadError(error, context);
|
|
192
207
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
async function hydrateColumnsWithTasks(adapter, board) {
|
|
4
|
+
const columnIds = (board.column || []).map((c) => c.id);
|
|
5
|
+
const tasksByColumn = /* @__PURE__ */ new Map();
|
|
6
|
+
if (columnIds.length > 0) {
|
|
7
|
+
const taskResults = await Promise.all(
|
|
8
|
+
columnIds.map(
|
|
9
|
+
(columnId) => adapter.findMany({
|
|
10
|
+
model: "kanbanTask",
|
|
11
|
+
where: [
|
|
12
|
+
{ field: "columnId", value: columnId, operator: "eq" }
|
|
13
|
+
],
|
|
14
|
+
sortBy: { field: "order", direction: "asc" }
|
|
15
|
+
})
|
|
16
|
+
)
|
|
17
|
+
);
|
|
18
|
+
for (let i = 0; i < columnIds.length; i++) {
|
|
19
|
+
const columnId = columnIds[i];
|
|
20
|
+
const tasks = taskResults[i];
|
|
21
|
+
if (columnId && tasks) {
|
|
22
|
+
tasksByColumn.set(columnId, tasks);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const columns = (board.column || []).sort((a, b) => a.order - b.order).map((col) => ({ ...col, tasks: tasksByColumn.get(col.id) || [] }));
|
|
27
|
+
const { column: _, ...boardWithoutJoin } = board;
|
|
28
|
+
return { ...boardWithoutJoin, columns };
|
|
29
|
+
}
|
|
30
|
+
async function getAllBoards(adapter, params) {
|
|
31
|
+
const query = params ?? {};
|
|
32
|
+
const whereConditions = [];
|
|
33
|
+
if (query.slug) {
|
|
34
|
+
whereConditions.push({
|
|
35
|
+
field: "slug",
|
|
36
|
+
value: query.slug,
|
|
37
|
+
operator: "eq"
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
if (query.ownerId) {
|
|
41
|
+
whereConditions.push({
|
|
42
|
+
field: "ownerId",
|
|
43
|
+
value: query.ownerId,
|
|
44
|
+
operator: "eq"
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
if (query.organizationId) {
|
|
48
|
+
whereConditions.push({
|
|
49
|
+
field: "organizationId",
|
|
50
|
+
value: query.organizationId,
|
|
51
|
+
operator: "eq"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
const where = whereConditions.length > 0 ? whereConditions : void 0;
|
|
55
|
+
const [boards, total] = await Promise.all([
|
|
56
|
+
adapter.findMany({
|
|
57
|
+
model: "kanbanBoard",
|
|
58
|
+
limit: query.limit ?? 50,
|
|
59
|
+
offset: query.offset ?? 0,
|
|
60
|
+
where,
|
|
61
|
+
sortBy: { field: "createdAt", direction: "desc" },
|
|
62
|
+
join: { kanbanColumn: true }
|
|
63
|
+
}),
|
|
64
|
+
adapter.count({ model: "kanbanBoard", where })
|
|
65
|
+
]);
|
|
66
|
+
const items = await Promise.all(
|
|
67
|
+
boards.map((board) => hydrateColumnsWithTasks(adapter, board))
|
|
68
|
+
);
|
|
69
|
+
return { items, total, limit: query.limit, offset: query.offset };
|
|
70
|
+
}
|
|
71
|
+
async function getBoardById(adapter, id) {
|
|
72
|
+
const board = await adapter.findOne({
|
|
73
|
+
model: "kanbanBoard",
|
|
74
|
+
where: [{ field: "id", value: id, operator: "eq" }],
|
|
75
|
+
join: { kanbanColumn: true }
|
|
76
|
+
});
|
|
77
|
+
if (!board) {
|
|
78
|
+
return null;
|
|
79
|
+
}
|
|
80
|
+
return hydrateColumnsWithTasks(adapter, board);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
exports.getAllBoards = getAllBoards;
|
|
84
|
+
exports.getBoardById = getBoardById;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
async function hydrateColumnsWithTasks(adapter, board) {
|
|
2
|
+
const columnIds = (board.column || []).map((c) => c.id);
|
|
3
|
+
const tasksByColumn = /* @__PURE__ */ new Map();
|
|
4
|
+
if (columnIds.length > 0) {
|
|
5
|
+
const taskResults = await Promise.all(
|
|
6
|
+
columnIds.map(
|
|
7
|
+
(columnId) => adapter.findMany({
|
|
8
|
+
model: "kanbanTask",
|
|
9
|
+
where: [
|
|
10
|
+
{ field: "columnId", value: columnId, operator: "eq" }
|
|
11
|
+
],
|
|
12
|
+
sortBy: { field: "order", direction: "asc" }
|
|
13
|
+
})
|
|
14
|
+
)
|
|
15
|
+
);
|
|
16
|
+
for (let i = 0; i < columnIds.length; i++) {
|
|
17
|
+
const columnId = columnIds[i];
|
|
18
|
+
const tasks = taskResults[i];
|
|
19
|
+
if (columnId && tasks) {
|
|
20
|
+
tasksByColumn.set(columnId, tasks);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const columns = (board.column || []).sort((a, b) => a.order - b.order).map((col) => ({ ...col, tasks: tasksByColumn.get(col.id) || [] }));
|
|
25
|
+
const { column: _, ...boardWithoutJoin } = board;
|
|
26
|
+
return { ...boardWithoutJoin, columns };
|
|
27
|
+
}
|
|
28
|
+
async function getAllBoards(adapter, params) {
|
|
29
|
+
const query = params ?? {};
|
|
30
|
+
const whereConditions = [];
|
|
31
|
+
if (query.slug) {
|
|
32
|
+
whereConditions.push({
|
|
33
|
+
field: "slug",
|
|
34
|
+
value: query.slug,
|
|
35
|
+
operator: "eq"
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
if (query.ownerId) {
|
|
39
|
+
whereConditions.push({
|
|
40
|
+
field: "ownerId",
|
|
41
|
+
value: query.ownerId,
|
|
42
|
+
operator: "eq"
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
if (query.organizationId) {
|
|
46
|
+
whereConditions.push({
|
|
47
|
+
field: "organizationId",
|
|
48
|
+
value: query.organizationId,
|
|
49
|
+
operator: "eq"
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
const where = whereConditions.length > 0 ? whereConditions : void 0;
|
|
53
|
+
const [boards, total] = await Promise.all([
|
|
54
|
+
adapter.findMany({
|
|
55
|
+
model: "kanbanBoard",
|
|
56
|
+
limit: query.limit ?? 50,
|
|
57
|
+
offset: query.offset ?? 0,
|
|
58
|
+
where,
|
|
59
|
+
sortBy: { field: "createdAt", direction: "desc" },
|
|
60
|
+
join: { kanbanColumn: true }
|
|
61
|
+
}),
|
|
62
|
+
adapter.count({ model: "kanbanBoard", where })
|
|
63
|
+
]);
|
|
64
|
+
const items = await Promise.all(
|
|
65
|
+
boards.map((board) => hydrateColumnsWithTasks(adapter, board))
|
|
66
|
+
);
|
|
67
|
+
return { items, total, limit: query.limit, offset: query.offset };
|
|
68
|
+
}
|
|
69
|
+
async function getBoardById(adapter, id) {
|
|
70
|
+
const board = await adapter.findOne({
|
|
71
|
+
model: "kanbanBoard",
|
|
72
|
+
where: [{ field: "id", value: id, operator: "eq" }],
|
|
73
|
+
join: { kanbanColumn: true }
|
|
74
|
+
});
|
|
75
|
+
if (!board) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return hydrateColumnsWithTasks(adapter, board);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export { getAllBoards, getBoardById };
|