@questpie/admin 3.0.3 → 3.0.5
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/README.md +34 -5
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/blocks/block-renderer.mjs +4 -1
- package/dist/client/builder/types/action-types.d.mts +31 -3
- package/dist/client/builder/types/collection-types.d.mts +140 -0
- package/dist/client/builder/types/ui-config.d.mts +16 -2
- package/dist/client/builder/types/views.d.mts +57 -0
- package/dist/client/builder/types/widget-types.d.mts +5 -0
- package/dist/client/components/actions/action-button.mjs +137 -199
- package/dist/client/components/actions/action-dialog.mjs +198 -156
- package/dist/client/components/actions/confirmation-dialog.mjs +2 -2
- package/dist/client/components/actions/header-actions.mjs +52 -53
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/auth/auth-loading.mjs +41 -18
- package/dist/client/components/blocks/block-editor-layout.mjs +2 -2
- package/dist/client/components/blocks/block-fields-renderer.mjs +64 -28
- package/dist/client/components/blocks/block-insert-button.mjs +4 -4
- package/dist/client/components/blocks/block-item.mjs +2 -2
- package/dist/client/components/blocks/block-library-sidebar.mjs +91 -63
- package/dist/client/components/component-renderer.mjs +1 -1
- package/dist/client/components/fields/array-field.mjs +14 -14
- package/dist/client/components/fields/asset-preview-field.mjs +1 -1
- package/dist/client/components/fields/blocks-field/blocks-field.mjs +84 -104
- package/dist/client/components/fields/json-field.mjs +2 -2
- package/dist/client/components/fields/object-array-field.mjs +22 -22
- package/dist/client/components/fields/object-field.mjs +5 -5
- package/dist/client/components/fields/relation/displays/cards-display.mjs +16 -9
- package/dist/client/components/fields/relation/displays/chips-display.mjs +15 -12
- package/dist/client/components/fields/relation/displays/grid-display.mjs +15 -11
- package/dist/client/components/fields/relation/displays/list-display.mjs +33 -20
- package/dist/client/components/fields/relation/displays/table-display.mjs +62 -93
- package/dist/client/components/fields/relation/relation-items-display.mjs +1 -1
- package/dist/client/components/fields/relation-picker.mjs +7 -6
- package/dist/client/components/fields/relation-select.mjs +71 -47
- package/dist/client/components/fields/rich-text-editor/bubble-menu.mjs +392 -82
- package/dist/client/components/fields/rich-text-editor/extensions.mjs +54 -23
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +24 -50
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +66 -0
- package/dist/client/components/fields/rich-text-editor/index.d.mts +38 -0
- package/dist/client/components/fields/rich-text-editor/index.mjs +637 -376
- package/dist/client/components/fields/rich-text-editor/link-utils.mjs +26 -0
- package/dist/client/components/fields/rich-text-editor/presets.d.mts +10 -0
- package/dist/client/components/fields/rich-text-editor/slash-commands.mjs +27 -6
- package/dist/client/components/fields/rich-text-editor/toolbar.mjs +464 -346
- package/dist/client/components/fields/rich-text-editor/types.d.mts +77 -0
- package/dist/client/components/fields/upload-field.mjs +45 -49
- package/dist/client/components/filter-builder/columns-tab.mjs +69 -62
- package/dist/client/components/filter-builder/filter-builder-sheet.mjs +473 -308
- package/dist/client/components/filter-builder/filters-tab.mjs +109 -82
- package/dist/client/components/filter-builder/saved-views-tab.mjs +300 -198
- package/dist/client/components/history-sidebar.mjs +850 -340
- package/dist/client/components/layout/field-layout-renderer.mjs +6 -5
- package/dist/client/components/locale-switcher.mjs +8 -8
- package/dist/client/components/media/media-grid.mjs +106 -86
- package/dist/client/components/media/media-picker-dialog.mjs +242 -230
- package/dist/client/components/preview/live-preview-mode.mjs +1 -1
- package/dist/client/components/primitives/asset-preview.mjs +37 -22
- package/dist/client/components/primitives/date-input.mjs +212 -249
- package/dist/client/components/primitives/dropzone.mjs +192 -159
- package/dist/client/components/primitives/field-select-control.mjs +93 -0
- package/dist/client/components/primitives/select-multi.mjs +406 -365
- package/dist/client/components/primitives/select-single.mjs +391 -323
- package/dist/client/components/primitives/time-input.mjs +2 -2
- package/dist/client/components/sheets/resource-sheet.mjs +2 -0
- package/dist/client/components/ui/accordion.mjs +4 -4
- package/dist/client/components/ui/alert.mjs +3 -3
- package/dist/client/components/ui/badge.mjs +4 -4
- package/dist/client/components/ui/button.mjs +47 -37
- package/dist/client/components/ui/card.mjs +2 -2
- package/dist/client/components/ui/checkbox.mjs +1 -1
- package/dist/client/components/ui/command.mjs +5 -5
- package/dist/client/components/ui/dialog.mjs +3 -3
- package/dist/client/components/ui/drawer.mjs +1 -1
- package/dist/client/components/ui/dropdown-menu.mjs +157 -15
- package/dist/client/components/ui/empty-state.mjs +88 -59
- package/dist/client/components/ui/field.mjs +2 -2
- package/dist/client/components/ui/input-group.mjs +3 -3
- package/dist/client/components/ui/input.mjs +1 -1
- package/dist/client/components/ui/kbd.mjs +1 -1
- package/dist/client/components/ui/label.mjs +1 -1
- package/dist/client/components/ui/popover.mjs +19 -11
- package/dist/client/components/ui/scroll-fade.mjs +170 -0
- package/dist/client/components/ui/search-input.mjs +1 -1
- package/dist/client/components/ui/select.mjs +129 -27
- package/dist/client/components/ui/sheet.mjs +54 -34
- package/dist/client/components/ui/sidebar.mjs +15 -14
- package/dist/client/components/ui/skeleton.mjs +28 -12
- package/dist/client/components/ui/switch.mjs +2 -2
- package/dist/client/components/ui/table.mjs +82 -74
- package/dist/client/components/ui/tabs.mjs +26 -31
- package/dist/client/components/ui/textarea.mjs +1 -1
- package/dist/client/components/ui/tooltip.mjs +1 -1
- package/dist/client/components/widgets/chart-widget.mjs +154 -100
- package/dist/client/components/widgets/progress-widget.mjs +63 -36
- package/dist/client/components/widgets/quick-actions-widget.mjs +207 -115
- package/dist/client/components/widgets/recent-items-widget.mjs +147 -103
- package/dist/client/components/widgets/stats-widget.mjs +91 -72
- package/dist/client/components/widgets/table-widget.mjs +161 -247
- package/dist/client/components/widgets/timeline-widget.mjs +119 -78
- package/dist/client/components/widgets/value-widget.mjs +286 -157
- package/dist/client/components/widgets/widget-empty-state.mjs +88 -0
- package/dist/client/components/widgets/widget-skeletons.mjs +53 -20
- package/dist/client/contexts/focus-context.d.mts +2 -2
- package/dist/client/hooks/use-action.mjs +63 -55
- package/dist/client/hooks/use-audit-history.mjs +1 -65
- package/dist/client/hooks/use-collection-validation.mjs +36 -23
- package/dist/client/hooks/use-collection.mjs +96 -1
- package/dist/client/hooks/use-saved-views.mjs +70 -49
- package/dist/client/hooks/use-server-actions.mjs +70 -46
- package/dist/client/hooks/use-server-validation.mjs +156 -41
- package/dist/client/hooks/use-server-widget-data.mjs +1 -1
- package/dist/client/hooks/use-setup-status.d.mts +3 -3
- package/dist/client/hooks/use-setup-status.mjs +2 -2
- package/dist/client/hooks/use-transition-stage.mjs +2 -10
- package/dist/client/hooks/use-validation-error-map.mjs +31 -13
- package/dist/client/hooks/use-view-state.mjs +238 -174
- package/dist/client/i18n/date-locale.mjs +33 -0
- package/dist/client/i18n/hooks.mjs +17 -1
- package/dist/client/lib/utils.mjs +3 -2
- package/dist/client/preview/block-scope-context.d.mts +2 -2
- package/dist/client/preview/preview-banner.d.mts +2 -2
- package/dist/client/preview/preview-banner.mjs +75 -46
- package/dist/client/preview/preview-field.d.mts +4 -4
- package/dist/client/preview/preview-field.mjs +2 -2
- package/dist/client/runtime/provider.mjs +8 -1
- package/dist/client/runtime/translations-provider.mjs +1 -1
- package/dist/client/scope/picker.d.mts +2 -2
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/styles/base.css +1022 -0
- package/dist/client/styles/index.css +3 -589
- package/dist/client/utils/auto-expand-fields.mjs +4 -2
- package/dist/client/utils/keyboard-shortcuts.mjs +26 -0
- package/dist/client/utils/use-lazy-component.mjs +80 -0
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/auth-layout.d.mts +17 -10
- package/dist/client/views/auth/auth-layout.mjs +291 -80
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/forgot-password-form.mjs +2 -2
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.mjs +1 -1
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.mjs +2 -2
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/collection/auto-form-fields.mjs +11 -9
- package/dist/client/views/collection/bulk-action-toolbar.mjs +173 -138
- package/dist/client/views/collection/cells/complex-cells.mjs +22 -22
- package/dist/client/views/collection/cells/primitive-cells.mjs +1 -1
- package/dist/client/views/collection/cells/relation-cells.mjs +147 -129
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +224 -278
- package/dist/client/views/collection/cells/shared/relation-chip.mjs +64 -36
- package/dist/client/views/collection/cells/upload-cells.mjs +199 -9
- package/dist/client/views/collection/columns/build-columns.mjs +29 -9
- package/dist/client/views/collection/columns/column-defaults.mjs +2 -2
- package/dist/client/views/collection/field-renderer.mjs +50 -89
- package/dist/client/views/collection/form-view.mjs +237 -227
- package/dist/client/views/collection/table-view.mjs +1167 -234
- package/dist/client/views/collection/view-skeletons.mjs +222 -79
- package/dist/client/views/common/global-search.mjs +29 -18
- package/dist/client/views/dashboard/dashboard-grid.mjs +678 -501
- package/dist/client/views/dashboard/dashboard-widget.mjs +6 -3
- package/dist/client/views/dashboard/widget-card.mjs +23 -14
- package/dist/client/views/globals/global-form-view.mjs +634 -589
- package/dist/client/views/layout/admin-layout-provider.mjs +67 -70
- package/dist/client/views/layout/admin-layout.d.mts +3 -6
- package/dist/client/views/layout/admin-layout.mjs +152 -155
- package/dist/client/views/layout/admin-router.mjs +936 -616
- package/dist/client/views/layout/admin-sidebar.d.mts +38 -1
- package/dist/client/views/layout/admin-sidebar.mjs +762 -592
- package/dist/client/views/layout/admin-theme.d.mts +10 -0
- package/dist/client/views/layout/admin-theme.mjs +84 -0
- package/dist/client/views/layout/admin-view-layout.mjs +161 -0
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- package/dist/client/views/pages/accept-invite-page.mjs +49 -26
- package/dist/client/views/pages/dashboard-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.d.mts +2 -2
- package/dist/client/views/pages/forgot-password-page.mjs +2 -19
- package/dist/client/views/pages/invite-page.d.mts +2 -2
- package/dist/client/views/pages/invite-page.mjs +2 -19
- package/dist/client/views/pages/login-page.d.mts +3 -3
- package/dist/client/views/pages/login-page.mjs +4 -21
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.mjs +3 -20
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.mjs +70 -71
- package/dist/client.d.mts +6 -2
- package/dist/client.mjs +2 -1
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/index.d.mts +6 -2
- package/dist/index.mjs +2 -1
- package/dist/server/augmentation/dashboard.d.mts +67 -3
- package/dist/server/augmentation/form-layout.d.mts +21 -0
- package/dist/server/augmentation/index.d.mts +1 -1
- package/dist/server/codegen/admin-client-template.mjs +4 -0
- package/dist/server/fields/blocks.d.mts +1 -1
- package/dist/server/fields/blocks.mjs +12 -0
- package/dist/server/fields/rich-text.d.mts +1 -1
- package/dist/server/fields/rich-text.mjs +8 -0
- package/dist/server/i18n/index.mjs +29 -7
- package/dist/server/i18n/messages/cs.mjs +414 -1
- package/dist/server/i18n/messages/de.mjs +412 -1
- package/dist/server/i18n/messages/en.mjs +166 -1
- package/dist/server/i18n/messages/es.mjs +412 -1
- package/dist/server/i18n/messages/fr.mjs +412 -1
- package/dist/server/i18n/messages/pl.mjs +416 -1
- package/dist/server/i18n/messages/pt.mjs +409 -1
- package/dist/server/i18n/messages/sk.mjs +216 -2
- package/dist/server/modules/admin/block/introspection.mjs +4 -1
- package/dist/server/modules/admin/block/prefetch.mjs +12 -2
- package/dist/server/modules/admin/collections/account.d.mts +2 -2
- package/dist/server/modules/admin/collections/admin-locks.d.mts +2 -2
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +39 -39
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +42 -42
- package/dist/server/modules/admin/collections/assets.d.mts +20 -20
- package/dist/server/modules/admin/collections/assets.mjs +0 -1
- package/dist/server/modules/admin/collections/session.d.mts +42 -42
- package/dist/server/modules/admin/collections/user.d.mts +40 -28
- package/dist/server/modules/admin/collections/user.mjs +40 -9
- package/dist/server/modules/admin/collections/verification.d.mts +36 -36
- package/dist/server/modules/admin/dto/admin-config.dto.mjs +2 -0
- package/dist/server/modules/admin/factories.mjs +7 -18
- package/dist/server/modules/admin/index.d.mts +1 -1
- package/dist/server/modules/admin/routes/admin-config.d.mts +2 -2
- package/dist/server/modules/admin/routes/admin-config.mjs +34 -16
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/execute-action.mjs +67 -28
- package/dist/server/modules/admin/routes/i18n-helpers.mjs +34 -0
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/preview.mjs +25 -17
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/route-helpers.mjs +1 -1
- package/dist/server/modules/admin/routes/setup.d.mts +10 -10
- package/dist/server/modules/admin/routes/setup.mjs +16 -13
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/translations.mjs +5 -1
- package/dist/server/modules/admin-preferences/collections/admin-preferences.mjs +1 -1
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +2 -2
- package/dist/server/modules/audit/.generated/module.d.mts +1 -1
- package/dist/server/modules/audit/.generated/module.mjs +1 -1
- package/dist/server/modules/audit/collections/audit-log.d.mts +2 -2
- package/dist/server/modules/audit/collections/audit-log.mjs +1 -1
- package/dist/server/modules/audit/config/app.mjs +99 -42
- package/dist/server/modules/audit/jobs/audit-cleanup.mjs +1 -1
- package/dist/server/plugin.mjs +4 -2
- package/dist/server/proxy-factories.d.mts +4 -3
- package/dist/server/proxy-factories.mjs +34 -8
- package/dist/shared/types/saved-views.types.d.mts +2 -0
- package/package.json +6 -4
- package/dist/client/components/fields/rich-text-editor/link-popover.mjs +0 -85
- package/dist/client/components/ui/spinner.mjs +0 -52
- package/dist/client/components/ui/toolbar.mjs +0 -136
- package/dist/client/contexts/breadcrumb-context.mjs +0 -60
- package/dist/client/views/layout/admin-topbar.mjs +0 -236
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { getApp, getCollectionState, getSession } from "./route-helpers.mjs";
|
|
1
|
+
import { getApp, getCollectionState, getLocale, getSession } from "./route-helpers.mjs";
|
|
2
|
+
import { translateAdminMessage } from "./i18n-helpers.mjs";
|
|
2
3
|
import { getPreviewSecret } from "../../../../shared/preview-utils.mjs";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { ApiError, route } from "questpie";
|
|
@@ -23,7 +24,7 @@ function base64UrlDecode(input) {
|
|
|
23
24
|
return Buffer.from(base64, "base64").toString("utf8");
|
|
24
25
|
}
|
|
25
26
|
const mintPreviewTokenSchema = z.object({
|
|
26
|
-
path: z.string().min(1
|
|
27
|
+
path: z.string().min(1),
|
|
27
28
|
ttlMs: z.number().positive().optional()
|
|
28
29
|
});
|
|
29
30
|
const mintPreviewTokenOutputSchema = z.object({
|
|
@@ -50,7 +51,9 @@ function createPreviewFunctions(secret) {
|
|
|
50
51
|
return {
|
|
51
52
|
mintPreviewToken: route().post().schema(mintPreviewTokenSchema).outputSchema(mintPreviewTokenOutputSchema).handler(async (ctx) => {
|
|
52
53
|
const { input } = ctx;
|
|
53
|
-
|
|
54
|
+
const locale = getLocale(ctx);
|
|
55
|
+
const t = (key, params) => translateAdminMessage(locale, key, params);
|
|
56
|
+
if (!getSession(ctx)) throw ApiError.unauthorized(t("preview.adminSessionRequired"));
|
|
54
57
|
const { path, ttlMs = DEFAULT_TTL_MS } = input;
|
|
55
58
|
const expiresAt = Date.now() + ttlMs;
|
|
56
59
|
const payload = {
|
|
@@ -63,37 +66,40 @@ function createPreviewFunctions(secret) {
|
|
|
63
66
|
expiresAt
|
|
64
67
|
};
|
|
65
68
|
}),
|
|
66
|
-
verifyPreviewToken: route().post().schema(verifyPreviewTokenSchema).outputSchema(verifyPreviewTokenOutputSchema).handler(async (
|
|
69
|
+
verifyPreviewToken: route().post().schema(verifyPreviewTokenSchema).outputSchema(verifyPreviewTokenOutputSchema).handler(async (ctx) => {
|
|
70
|
+
const { input } = ctx;
|
|
71
|
+
const locale = getLocale(ctx);
|
|
72
|
+
const t = (key, params) => translateAdminMessage(locale, key, params);
|
|
67
73
|
const { token } = input;
|
|
68
74
|
const [encodedPayload, signature] = token.split(".");
|
|
69
75
|
if (!encodedPayload || !signature) return {
|
|
70
76
|
valid: false,
|
|
71
|
-
error: "
|
|
77
|
+
error: t("preview.invalidTokenFormat")
|
|
72
78
|
};
|
|
73
79
|
const expectedSignature = signPayload(encodedPayload);
|
|
74
80
|
const signatureBuffer = Uint8Array.from(Buffer.from(signature));
|
|
75
81
|
const expectedBuffer = Uint8Array.from(Buffer.from(expectedSignature));
|
|
76
82
|
if (signatureBuffer.length !== expectedBuffer.length) return {
|
|
77
83
|
valid: false,
|
|
78
|
-
error: "
|
|
84
|
+
error: t("preview.invalidSignature")
|
|
79
85
|
};
|
|
80
86
|
if (!timingSafeEqual(signatureBuffer, expectedBuffer)) return {
|
|
81
87
|
valid: false,
|
|
82
|
-
error: "
|
|
88
|
+
error: t("preview.invalidSignature")
|
|
83
89
|
};
|
|
84
90
|
try {
|
|
85
91
|
const payload = JSON.parse(base64UrlDecode(encodedPayload));
|
|
86
92
|
if (!payload?.exp || typeof payload.exp !== "number") return {
|
|
87
93
|
valid: false,
|
|
88
|
-
error: "
|
|
94
|
+
error: t("preview.invalidPayload")
|
|
89
95
|
};
|
|
90
96
|
if (payload.exp < Date.now()) return {
|
|
91
97
|
valid: false,
|
|
92
|
-
error: "
|
|
98
|
+
error: t("preview.tokenExpired")
|
|
93
99
|
};
|
|
94
100
|
if (!payload.path || typeof payload.path !== "string") return {
|
|
95
101
|
valid: false,
|
|
96
|
-
error: "
|
|
102
|
+
error: t("preview.invalidPath")
|
|
97
103
|
};
|
|
98
104
|
return {
|
|
99
105
|
valid: true,
|
|
@@ -102,7 +108,7 @@ function createPreviewFunctions(secret) {
|
|
|
102
108
|
} catch {
|
|
103
109
|
return {
|
|
104
110
|
valid: false,
|
|
105
|
-
error: "
|
|
111
|
+
error: t("preview.invalidPayload")
|
|
106
112
|
};
|
|
107
113
|
}
|
|
108
114
|
})
|
|
@@ -160,7 +166,7 @@ function createPreviewTokenVerifier(secret) {
|
|
|
160
166
|
};
|
|
161
167
|
}
|
|
162
168
|
const getPreviewUrlSchema = z.object({
|
|
163
|
-
collection: z.string().min(1
|
|
169
|
+
collection: z.string().min(1),
|
|
164
170
|
record: z.record(z.string(), z.unknown()),
|
|
165
171
|
locale: z.string().optional()
|
|
166
172
|
});
|
|
@@ -186,24 +192,26 @@ const getPreviewUrlOutputSchema = z.object({
|
|
|
186
192
|
*/
|
|
187
193
|
const getPreviewUrl = route().post().schema(getPreviewUrlSchema).outputSchema(getPreviewUrlOutputSchema).handler(async (ctx) => {
|
|
188
194
|
const { input } = ctx;
|
|
195
|
+
const messageLocale = getLocale(ctx) ?? input.locale;
|
|
196
|
+
const t = (key, params) => translateAdminMessage(messageLocale, key, params);
|
|
189
197
|
if (!getSession(ctx)) return {
|
|
190
198
|
url: null,
|
|
191
|
-
error: "
|
|
199
|
+
error: t("preview.adminSessionRequired")
|
|
192
200
|
};
|
|
193
201
|
const { collection: collectionName, record, locale } = input;
|
|
194
202
|
const collection$1 = getApp(ctx).getCollections()[collectionName];
|
|
195
203
|
if (!collection$1) return {
|
|
196
204
|
url: null,
|
|
197
|
-
error:
|
|
205
|
+
error: t("preview.collectionNotFound", { collection: collectionName })
|
|
198
206
|
};
|
|
199
207
|
const previewConfig = getCollectionState(collection$1).adminPreview;
|
|
200
208
|
if (!previewConfig?.url) return {
|
|
201
209
|
url: null,
|
|
202
|
-
error: "
|
|
210
|
+
error: t("preview.noUrlConfigured")
|
|
203
211
|
};
|
|
204
212
|
if (previewConfig.enabled === false) return {
|
|
205
213
|
url: null,
|
|
206
|
-
error: "
|
|
214
|
+
error: t("preview.disabledForCollection")
|
|
207
215
|
};
|
|
208
216
|
try {
|
|
209
217
|
return { url: previewConfig.url({
|
|
@@ -213,7 +221,7 @@ const getPreviewUrl = route().post().schema(getPreviewUrlSchema).outputSchema(ge
|
|
|
213
221
|
} catch (err) {
|
|
214
222
|
return {
|
|
215
223
|
url: null,
|
|
216
|
-
error:
|
|
224
|
+
error: t("preview.generateUrlFailed", { message: err instanceof Error ? err.message : t("error.unknown") })
|
|
217
225
|
};
|
|
218
226
|
}
|
|
219
227
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie135 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/reactive.d.ts
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ import * as questpie143 from "questpie";
|
|
|
13
13
|
* Batch reactive endpoint.
|
|
14
14
|
* Executes multiple reactive handlers in a single request.
|
|
15
15
|
*/
|
|
16
|
-
declare const batchReactive:
|
|
16
|
+
declare const batchReactive: questpie135.JsonRouteDefinition<{
|
|
17
17
|
collection: string;
|
|
18
18
|
type: "collection" | "global";
|
|
19
19
|
requests: {
|
|
@@ -26,12 +26,12 @@ declare const batchReactive: questpie143.JsonRouteDefinition<{
|
|
|
26
26
|
}[];
|
|
27
27
|
formData?: Record<string, unknown> | undefined;
|
|
28
28
|
prevData?: Record<string, unknown> | null | undefined;
|
|
29
|
-
}, any,
|
|
29
|
+
}, any, questpie135.JsonRouteParams>;
|
|
30
30
|
/**
|
|
31
31
|
* Dynamic options endpoint.
|
|
32
32
|
* Fetches options for select/relation fields with search and pagination.
|
|
33
33
|
*/
|
|
34
|
-
declare const fieldOptions:
|
|
34
|
+
declare const fieldOptions: questpie135.JsonRouteDefinition<{
|
|
35
35
|
collection: string;
|
|
36
36
|
type: "collection" | "global";
|
|
37
37
|
field: string;
|
|
@@ -40,12 +40,12 @@ declare const fieldOptions: questpie143.JsonRouteDefinition<{
|
|
|
40
40
|
page: number;
|
|
41
41
|
limit: number;
|
|
42
42
|
siblingData?: Record<string, unknown> | null | undefined;
|
|
43
|
-
}, any,
|
|
43
|
+
}, any, questpie135.JsonRouteParams>;
|
|
44
44
|
/**
|
|
45
45
|
* Reactive functions bundle.
|
|
46
46
|
*/
|
|
47
47
|
declare const reactiveFunctions: {
|
|
48
|
-
readonly batchReactive:
|
|
48
|
+
readonly batchReactive: questpie135.JsonRouteDefinition<{
|
|
49
49
|
collection: string;
|
|
50
50
|
type: "collection" | "global";
|
|
51
51
|
requests: {
|
|
@@ -58,8 +58,8 @@ declare const reactiveFunctions: {
|
|
|
58
58
|
}[];
|
|
59
59
|
formData?: Record<string, unknown> | undefined;
|
|
60
60
|
prevData?: Record<string, unknown> | null | undefined;
|
|
61
|
-
}, any,
|
|
62
|
-
readonly fieldOptions:
|
|
61
|
+
}, any, questpie135.JsonRouteParams>;
|
|
62
|
+
readonly fieldOptions: questpie135.JsonRouteDefinition<{
|
|
63
63
|
collection: string;
|
|
64
64
|
type: "collection" | "global";
|
|
65
65
|
field: string;
|
|
@@ -68,7 +68,7 @@ declare const reactiveFunctions: {
|
|
|
68
68
|
page: number;
|
|
69
69
|
limit: number;
|
|
70
70
|
siblingData?: Record<string, unknown> | null | undefined;
|
|
71
|
-
}, any,
|
|
71
|
+
}, any, questpie135.JsonRouteParams>;
|
|
72
72
|
};
|
|
73
73
|
//#endregion
|
|
74
74
|
export { batchReactive, fieldOptions, reactiveFunctions };
|
|
@@ -73,4 +73,4 @@ function buildServerContext(ctx) {
|
|
|
73
73
|
}
|
|
74
74
|
|
|
75
75
|
//#endregion
|
|
76
|
-
export { buildServerContext, getAccessContext, getAdminConfig, getApp, getAppState, getCollectionState, getGlobalState, getSession };
|
|
76
|
+
export { buildServerContext, getAccessContext, getAdminConfig, getApp, getAppState, getCollectionState, getGlobalState, getLocale, getSession };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie143 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/setup.d.ts
|
|
4
4
|
|
|
@@ -10,7 +10,7 @@ import * as questpie135 from "questpie";
|
|
|
10
10
|
* need an existing admin to create the first invitation.
|
|
11
11
|
*/
|
|
12
12
|
/**
|
|
13
|
-
* Check if setup is required (no users exist in the system).
|
|
13
|
+
* Check if setup is required (no admin users exist in the system).
|
|
14
14
|
*
|
|
15
15
|
* @example
|
|
16
16
|
* ```ts
|
|
@@ -20,12 +20,12 @@ import * as questpie135 from "questpie";
|
|
|
20
20
|
* }
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
declare const isSetupRequired:
|
|
23
|
+
declare const isSetupRequired: questpie143.JsonRouteDefinition<Record<string, never>, any, questpie143.JsonRouteParams>;
|
|
24
24
|
/**
|
|
25
25
|
* Create the first admin user in the system.
|
|
26
|
-
* This function only works when no users exist (setup mode).
|
|
26
|
+
* This function only works when no admin users exist (setup mode).
|
|
27
27
|
*
|
|
28
|
-
* Security: Once any user exists, this function will refuse to create more users.
|
|
28
|
+
* Security: Once any admin user exists, this function will refuse to create more users.
|
|
29
29
|
* This prevents unauthorized admin creation after initial setup.
|
|
30
30
|
*
|
|
31
31
|
* @example
|
|
@@ -43,21 +43,21 @@ declare const isSetupRequired: questpie135.JsonRouteDefinition<Record<string, ne
|
|
|
43
43
|
* }
|
|
44
44
|
* ```
|
|
45
45
|
*/
|
|
46
|
-
declare const createFirstAdmin:
|
|
46
|
+
declare const createFirstAdmin: questpie143.JsonRouteDefinition<{
|
|
47
47
|
email: string;
|
|
48
48
|
password: string;
|
|
49
49
|
name: string;
|
|
50
|
-
}, any,
|
|
50
|
+
}, any, questpie143.JsonRouteParams>;
|
|
51
51
|
/**
|
|
52
52
|
* Bundle of setup-related functions.
|
|
53
53
|
*/
|
|
54
54
|
declare const setupFunctions: {
|
|
55
|
-
readonly isSetupRequired:
|
|
56
|
-
readonly createFirstAdmin:
|
|
55
|
+
readonly isSetupRequired: questpie143.JsonRouteDefinition<Record<string, never>, any, questpie143.JsonRouteParams>;
|
|
56
|
+
readonly createFirstAdmin: questpie143.JsonRouteDefinition<{
|
|
57
57
|
email: string;
|
|
58
58
|
password: string;
|
|
59
59
|
name: string;
|
|
60
|
-
}, any,
|
|
60
|
+
}, any, questpie143.JsonRouteParams>;
|
|
61
61
|
};
|
|
62
62
|
//#endregion
|
|
63
63
|
export { createFirstAdmin, isSetupRequired, setupFunctions };
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { getApp } from "./route-helpers.mjs";
|
|
1
|
+
import { getApp, getLocale } from "./route-helpers.mjs";
|
|
2
|
+
import { translateAdminMessage } from "./i18n-helpers.mjs";
|
|
2
3
|
import { z } from "zod";
|
|
3
4
|
import { route } from "questpie";
|
|
4
|
-
import { eq, sql as sql$1 } from "drizzle
|
|
5
|
+
import { eq, sql as sql$1 } from "questpie/drizzle";
|
|
5
6
|
|
|
6
7
|
//#region src/server/modules/admin/routes/setup.ts
|
|
7
8
|
/**
|
|
@@ -14,9 +15,9 @@ import { eq, sql as sql$1 } from "drizzle-orm";
|
|
|
14
15
|
const isSetupRequiredSchema = z.object({});
|
|
15
16
|
const isSetupRequiredOutputSchema = z.object({ required: z.boolean() });
|
|
16
17
|
const createFirstAdminSchema = z.object({
|
|
17
|
-
email: z.string().email(
|
|
18
|
-
password: z.string().min(8
|
|
19
|
-
name: z.string().min(2
|
|
18
|
+
email: z.string().email(),
|
|
19
|
+
password: z.string().min(8),
|
|
20
|
+
name: z.string().min(2)
|
|
20
21
|
});
|
|
21
22
|
const createFirstAdminOutputSchema = z.object({
|
|
22
23
|
success: z.boolean(),
|
|
@@ -28,7 +29,7 @@ const createFirstAdminOutputSchema = z.object({
|
|
|
28
29
|
error: z.string().optional()
|
|
29
30
|
});
|
|
30
31
|
/**
|
|
31
|
-
* Check if setup is required (no users exist in the system).
|
|
32
|
+
* Check if setup is required (no admin users exist in the system).
|
|
32
33
|
*
|
|
33
34
|
* @example
|
|
34
35
|
* ```ts
|
|
@@ -41,13 +42,13 @@ const createFirstAdminOutputSchema = z.object({
|
|
|
41
42
|
const isSetupRequired = route().post().schema(isSetupRequiredSchema).outputSchema(isSetupRequiredOutputSchema).handler(async (ctx) => {
|
|
42
43
|
const app = getApp(ctx);
|
|
43
44
|
const userCollection = app.getCollectionConfig("user");
|
|
44
|
-
return { required: (await app.db.select({ count: sql$1`count(*)::int` }).from(userCollection.table))[0].count === 0 };
|
|
45
|
+
return { required: (await app.db.select({ count: sql$1`count(*)::int` }).from(userCollection.table).where(eq(userCollection.table.role, "admin")))[0].count === 0 };
|
|
45
46
|
});
|
|
46
47
|
/**
|
|
47
48
|
* Create the first admin user in the system.
|
|
48
|
-
* This function only works when no users exist (setup mode).
|
|
49
|
+
* This function only works when no admin users exist (setup mode).
|
|
49
50
|
*
|
|
50
|
-
* Security: Once any user exists, this function will refuse to create more users.
|
|
51
|
+
* Security: Once any admin user exists, this function will refuse to create more users.
|
|
51
52
|
* This prevents unauthorized admin creation after initial setup.
|
|
52
53
|
*
|
|
53
54
|
* @example
|
|
@@ -67,11 +68,13 @@ const isSetupRequired = route().post().schema(isSetupRequiredSchema).outputSchem
|
|
|
67
68
|
*/
|
|
68
69
|
const createFirstAdmin = route().post().schema(createFirstAdminSchema).outputSchema(createFirstAdminOutputSchema).handler(async (ctx) => {
|
|
69
70
|
const app = getApp(ctx);
|
|
71
|
+
const locale = getLocale(ctx);
|
|
72
|
+
const t = (key, params) => translateAdminMessage(locale, key, params);
|
|
70
73
|
const input = ctx.input;
|
|
71
74
|
const userCollection = app.getCollectionConfig("user");
|
|
72
|
-
if ((await app.db.select({ count: sql$1`count(*)::int` }).from(userCollection.table))[0].count > 0) return {
|
|
75
|
+
if ((await app.db.select({ count: sql$1`count(*)::int` }).from(userCollection.table).where(eq(userCollection.table.role, "admin")))[0].count > 0) return {
|
|
73
76
|
success: false,
|
|
74
|
-
error: "
|
|
77
|
+
error: t("auth.setupAlreadyCompleted")
|
|
75
78
|
};
|
|
76
79
|
try {
|
|
77
80
|
const signUpResult = await app.auth.api.signUpEmail({ body: {
|
|
@@ -81,7 +84,7 @@ const createFirstAdmin = route().post().schema(createFirstAdminSchema).outputSch
|
|
|
81
84
|
} });
|
|
82
85
|
if (!signUpResult.user) return {
|
|
83
86
|
success: false,
|
|
84
|
-
error: "
|
|
87
|
+
error: t("auth.failedToCreateUserAccount")
|
|
85
88
|
};
|
|
86
89
|
await app.db.update(userCollection.table).set({
|
|
87
90
|
role: "admin",
|
|
@@ -98,7 +101,7 @@ const createFirstAdmin = route().post().schema(createFirstAdminSchema).outputSch
|
|
|
98
101
|
} catch (error) {
|
|
99
102
|
return {
|
|
100
103
|
success: false,
|
|
101
|
-
error: error instanceof Error ? error.message : "
|
|
104
|
+
error: error instanceof Error ? error.message : t("error.unexpectedError")
|
|
102
105
|
};
|
|
103
106
|
}
|
|
104
107
|
});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie464 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/translations.d.ts
|
|
4
4
|
|
|
@@ -17,10 +17,10 @@ import * as questpie462 from "questpie";
|
|
|
17
17
|
* Bundle of translation-related functions.
|
|
18
18
|
*/
|
|
19
19
|
declare const translationFunctions: {
|
|
20
|
-
readonly getAdminTranslations:
|
|
20
|
+
readonly getAdminTranslations: questpie464.JsonRouteDefinition<{
|
|
21
21
|
locale: string;
|
|
22
|
-
}, any,
|
|
23
|
-
readonly getAdminLocales:
|
|
22
|
+
}, any, questpie464.JsonRouteParams>;
|
|
23
|
+
readonly getAdminLocales: questpie464.JsonRouteDefinition<Record<string, never> | undefined, any, questpie464.JsonRouteParams>;
|
|
24
24
|
};
|
|
25
25
|
//#endregion
|
|
26
26
|
export { translationFunctions };
|
|
@@ -29,7 +29,11 @@ function getAdminLocaleConfig(app) {
|
|
|
29
29
|
const getAdminTranslationsSchema = z.object({ locale: z.string() });
|
|
30
30
|
const messageValueSchema = z.union([z.string(), z.object({
|
|
31
31
|
one: z.string(),
|
|
32
|
-
other: z.string()
|
|
32
|
+
other: z.string(),
|
|
33
|
+
zero: z.string().optional(),
|
|
34
|
+
two: z.string().optional(),
|
|
35
|
+
few: z.string().optional(),
|
|
36
|
+
many: z.string().optional()
|
|
33
37
|
})]);
|
|
34
38
|
const getAdminTranslationsOutputSchema = z.object({
|
|
35
39
|
locale: z.string(),
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { FilterOperator, FilterRule, SortConfig, ViewConfiguration } from "../../../../shared/types/saved-views.types.mjs";
|
|
2
2
|
import * as questpie_shared15 from "questpie/shared";
|
|
3
3
|
import * as questpie73 from "questpie";
|
|
4
|
-
import * as drizzle_orm_pg_core22 from "drizzle-orm/pg-core";
|
|
5
|
-
import * as drizzle_orm5 from "drizzle-orm";
|
|
6
4
|
import * as questpie_src_server_modules_core_fields_email_js1 from "questpie/src/server/modules/core/fields/email.js";
|
|
7
5
|
import * as questpie_src_server_modules_core_fields_json_js1 from "questpie/src/server/modules/core/fields/json.js";
|
|
6
|
+
import * as drizzle_orm_pg_core22 from "drizzle-orm/pg-core";
|
|
7
|
+
import * as drizzle_orm5 from "drizzle-orm";
|
|
8
8
|
|
|
9
9
|
//#region src/server/modules/admin-preferences/collections/saved-views.d.ts
|
|
10
10
|
|
|
@@ -4,7 +4,7 @@ import * as questpie64 from "questpie";
|
|
|
4
4
|
|
|
5
5
|
//#region src/server/modules/audit/.generated/module.d.ts
|
|
6
6
|
interface AuditCollections {
|
|
7
|
-
|
|
7
|
+
admin_audit_log: typeof auditLogCollection;
|
|
8
8
|
}
|
|
9
9
|
interface AuditJobs {
|
|
10
10
|
auditCleanup: typeof auditCleanupJob;
|
|
@@ -6,7 +6,7 @@ import app_default from "../config/app.mjs";
|
|
|
6
6
|
//#region src/server/modules/audit/.generated/module.ts
|
|
7
7
|
const _module = {
|
|
8
8
|
name: "questpie-audit",
|
|
9
|
-
collections: { auditLogCollection },
|
|
9
|
+
collections: { admin_audit_log: auditLogCollection },
|
|
10
10
|
jobs: { auditCleanup: auditCleanupJob },
|
|
11
11
|
globals: {},
|
|
12
12
|
routes: {},
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import * as questpie_shared0 from "questpie/shared";
|
|
2
2
|
import * as questpie16 from "questpie";
|
|
3
|
-
import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
4
|
-
import * as drizzle_orm0 from "drizzle-orm";
|
|
5
3
|
import * as questpie_src_server_modules_core_fields_email_js0 from "questpie/src/server/modules/core/fields/email.js";
|
|
6
4
|
import * as questpie_src_server_modules_core_fields_json_js0 from "questpie/src/server/modules/core/fields/json.js";
|
|
5
|
+
import * as drizzle_orm_pg_core0 from "drizzle-orm/pg-core";
|
|
6
|
+
import * as drizzle_orm0 from "drizzle-orm";
|
|
7
7
|
import * as questpie_src_server_fields_operators_builtin_js0 from "questpie/src/server/fields/operators/builtin.js";
|
|
8
8
|
|
|
9
9
|
//#region src/server/modules/audit/collections/audit-log.d.ts
|