@questpie/admin 3.5.3 → 3.5.4
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 +8 -0
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/builder/index.d.mts +1 -1
- package/dist/client/builder/types/collection-types.d.mts +80 -5
- package/dist/client/builder/types/common.d.mts +5 -0
- package/dist/client/builder/types/field-types.d.mts +41 -1
- package/dist/client/builder/view/view.d.mts +3 -2
- package/dist/client/components/admin-link.d.mts +2 -2
- package/dist/client/components/fields/boolean-field.mjs +2 -1
- package/dist/client/components/fields/date-field.mjs +2 -1
- package/dist/client/components/fields/datetime-field.mjs +2 -1
- package/dist/client/components/fields/email-field.mjs +2 -1
- package/dist/client/components/fields/field-utils.d.mts +11 -0
- package/dist/client/components/fields/field-utils.mjs +3 -1
- package/dist/client/components/fields/field-wrapper.mjs +3 -3
- package/dist/client/components/fields/number-field.mjs +2 -1
- package/dist/client/components/fields/object-field.mjs +2 -1
- package/dist/client/components/fields/relation/displays/types.mjs +3 -3
- package/dist/client/components/fields/rich-text-editor/extensions.mjs +2 -1
- package/dist/client/components/fields/rich-text-editor/image-popover.mjs +6 -2
- package/dist/client/components/fields/rich-text-editor/image-upload.mjs +2 -1
- package/dist/client/components/fields/rich-text-editor/index.d.mts +3 -2
- package/dist/client/components/fields/rich-text-editor/index.mjs +4 -3
- package/dist/client/components/fields/select-field.mjs +2 -1
- package/dist/client/components/fields/text-field.mjs +2 -1
- package/dist/client/components/fields/textarea-field.mjs +2 -1
- package/dist/client/components/fields/time-field.mjs +2 -1
- package/dist/client/components/layout/field-layout-renderer.mjs +4 -4
- package/dist/client/components/media/media-grid.mjs +2 -1
- package/dist/client/components/primitives/asset-preview.mjs +4 -2
- package/dist/client/components/primitives/dropzone.d.mts +100 -0
- package/dist/client/components/primitives/field-select-control.mjs +2 -1
- package/dist/client/components/ui/button.d.mts +23 -0
- package/dist/client/components/ui/button.mjs +2 -2
- package/dist/client/components/ui/dropdown-menu.d.mts +49 -0
- package/dist/client/components/ui/dropdown-menu.mjs +22 -1
- package/dist/client/components/ui/popover.mjs +1 -1
- package/dist/client/components/ui/search-input.d.mts +56 -0
- package/dist/client/components/ui/select.mjs +2 -2
- package/dist/client/components/ui/sheet.d.mts +40 -0
- package/dist/client/components/ui/table.d.mts +49 -0
- package/dist/client/components/ui/table.mjs +15 -1
- package/dist/client/components/ui/tooltip.d.mts +21 -0
- package/dist/client/contexts/focus-context.d.mts +2 -2
- package/dist/client/hooks/use-admin-config.mjs +20 -1
- package/dist/client/hooks/use-autosave.mjs +91 -0
- package/dist/client/hooks/use-collection.mjs +65 -23
- package/dist/client/hooks/use-upload.d.mts +40 -0
- package/dist/client/hooks/use-upload.mjs +4 -2
- package/dist/client/i18n/hooks.d.mts +20 -0
- package/dist/client/lib/utils.d.mts +6 -0
- 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-field.d.mts +4 -4
- package/dist/client/runtime/provider.mjs +22 -3
- package/dist/client/scope/picker.d.mts +2 -2
- package/dist/client/scope/provider.d.mts +2 -2
- package/dist/client/styles/base.css +22 -18
- package/dist/client/utils/asset-url.mjs +27 -0
- package/dist/client/views/auth/accept-invite-form.d.mts +2 -2
- package/dist/client/views/auth/auth-layout.d.mts +3 -3
- package/dist/client/views/auth/forgot-password-form.d.mts +2 -2
- package/dist/client/views/auth/login-form.d.mts +2 -2
- package/dist/client/views/auth/reset-password-form.d.mts +2 -2
- package/dist/client/views/auth/setup-form.d.mts +2 -2
- package/dist/client/views/collection/auto-form-fields.mjs +4 -4
- package/dist/client/views/collection/cells/shared/asset-thumbnail.d.mts +7 -0
- package/dist/client/views/collection/cells/shared/asset-thumbnail.mjs +3 -2
- package/dist/client/views/collection/cells/shared/cell-helpers.mjs +3 -2
- package/dist/client/views/collection/cells/upload-cells.mjs +2 -1
- package/dist/client/views/collection/document-view.d.mts +30 -0
- package/dist/client/views/collection/document-view.mjs +377 -0
- package/dist/client/views/collection/field-context.mjs +3 -2
- package/dist/client/views/collection/field-renderer.mjs +2 -2
- package/dist/client/views/collection/form-view.mjs +14 -80
- package/dist/client/views/collection/list-view.mjs +19 -15
- package/dist/client/views/collection/table-view.mjs +1 -1
- package/dist/client/views/layout/admin-layout-provider.mjs +4 -3
- package/dist/client/views/layout/admin-layout.mjs +107 -20
- package/dist/client/views/layout/admin-router.mjs +19 -3
- package/dist/client/views/layout/admin-sidebar.mjs +50 -6
- package/dist/client/views/layout/admin-view-layout.d.mts +36 -0
- package/dist/client/views/pages/accept-invite-page.d.mts +2 -2
- 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/invite-page.d.mts +2 -2
- package/dist/client/views/pages/login-page.d.mts +2 -2
- package/dist/client/views/pages/reset-password-page.d.mts +2 -2
- package/dist/client/views/pages/setup-page.d.mts +2 -2
- package/dist/client.d.mts +17 -2
- package/dist/client.mjs +16 -1
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/factories.d.mts +4 -2
- package/dist/factories.mjs +2 -2
- package/dist/index.d.mts +17 -3
- package/dist/index.mjs +16 -1
- package/dist/server/adapters/index.d.mts +2 -0
- package/dist/server/adapters/nextjs.d.mts +1 -0
- package/dist/server/augmentation/actions.d.mts +5 -0
- package/dist/server/augmentation/form-layout.d.mts +5 -0
- package/dist/server/augmentation/views.d.mts +4 -1
- package/dist/server/auth-helpers.d.mts +1 -0
- package/dist/server/fields/blocks.mjs +4 -1
- package/dist/server/fields/reactive-runtime.mjs +3 -0
- package/dist/server/modules/admin/.generated/module.d.mts +1 -1
- package/dist/server/modules/admin/auth-helpers.mjs +7 -1
- package/dist/server/modules/admin/block/introspection.mjs +28 -4
- package/dist/server/modules/admin/block/prefetch.d.mts +11 -0
- package/dist/server/modules/admin/block/prefetch.mjs +108 -27
- package/dist/server/modules/admin/client/.generated/module.d.mts +68 -67
- package/dist/server/modules/admin/client/.generated/module.mjs +2 -0
- package/dist/server/modules/admin/client/views/collection-document.d.mts +6 -0
- package/dist/server/modules/admin/client/views/collection-document.mjs +10 -0
- package/dist/server/modules/admin/collections/account.d.mts +53 -53
- package/dist/server/modules/admin/collections/admin-locks.d.mts +57 -57
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +22 -22
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +50 -50
- package/dist/server/modules/admin/collections/apikey.d.mts +79 -71
- package/dist/server/modules/admin/collections/assets.d.mts +42 -42
- package/dist/server/modules/admin/collections/session.d.mts +45 -45
- package/dist/server/modules/admin/collections/user.d.mts +66 -66
- package/dist/server/modules/admin/collections/verification.d.mts +39 -39
- package/dist/server/modules/admin/dto/admin-config.dto.mjs +34 -4
- package/dist/server/modules/admin/factories.mjs +4 -34
- package/dist/server/modules/admin/index.d.mts +1 -1
- package/dist/server/modules/admin/routes/admin-config.d.mts +4 -2
- package/dist/server/modules/admin/routes/admin-config.mjs +18 -2
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/execute-action.mjs +10 -4
- package/dist/server/modules/admin/routes/locales.d.mts +2 -2
- package/dist/server/modules/admin/routes/locales.mjs +1 -1
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/preview.mjs +6 -5
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/reactive.mjs +2 -2
- package/dist/server/modules/admin/routes/route-helpers.mjs +1 -1
- package/dist/server/modules/admin/routes/setup.d.mts +7 -7
- package/dist/server/modules/admin/routes/translations.d.mts +4 -4
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin/routes/widget-data.mjs +1 -1
- package/dist/server/modules/admin-preferences/collections/saved-views.d.mts +41 -41
- package/dist/server/modules/audit/.generated/module.d.mts +6 -6
- package/dist/server/modules/audit/collections/audit-log.d.mts +78 -78
- package/dist/server/modules/audit/jobs/audit-cleanup.d.mts +2 -2
- package/dist/server/plugin.mjs +8 -3
- package/dist/server/proxy-factories.d.mts +8 -1
- package/dist/server/proxy-factories.mjs +33 -1
- package/dist/server.d.mts +2 -0
- package/package.json +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createActionCallbackProxy } from "../../proxy-factories.mjs";
|
|
1
|
+
import { createActionCallbackProxy, createActionFieldBuilderProxy } from "../../proxy-factories.mjs";
|
|
2
2
|
import { CollectionBuilder } from "questpie";
|
|
3
3
|
|
|
4
4
|
//#region src/server/modules/admin/factories.ts
|
|
@@ -26,37 +26,6 @@ const _componentProxy = new Proxy({}, { get: (_, prop) => (...args) => ({
|
|
|
26
26
|
props: typeof args[0] === "string" ? { name: args[0] } : args[0] ?? {}
|
|
27
27
|
}) });
|
|
28
28
|
const _fieldRefProxy = new Proxy({}, { get: (_, prop) => String(prop) });
|
|
29
|
-
/**
|
|
30
|
-
* Field builder proxy for actions context.
|
|
31
|
-
* Supports `f.text().required().label({...})` chaining.
|
|
32
|
-
* Each method call returns a new proxy with accumulated properties.
|
|
33
|
-
*/
|
|
34
|
-
function _createFieldBuilderProxy() {
|
|
35
|
-
return new Proxy({}, { get: (_, prop) => {
|
|
36
|
-
if (typeof prop !== "string") return void 0;
|
|
37
|
-
return (...args) => {
|
|
38
|
-
const def = { type: prop };
|
|
39
|
-
if (Array.isArray(args[0])) def.options = args[0];
|
|
40
|
-
else if (args[0] && typeof args[0] === "object") Object.assign(def, args[0]);
|
|
41
|
-
else if (args[0] !== void 0) def.value = args[0];
|
|
42
|
-
return _chainable(def);
|
|
43
|
-
};
|
|
44
|
-
} });
|
|
45
|
-
}
|
|
46
|
-
function _chainable(def) {
|
|
47
|
-
return new Proxy(def, { get: (target, prop) => {
|
|
48
|
-
if (typeof prop !== "string") return Reflect.get(target, prop);
|
|
49
|
-
if (prop in target) return target[prop];
|
|
50
|
-
if (prop === "set") return (key, value) => _chainable({
|
|
51
|
-
...target,
|
|
52
|
-
[key]: value
|
|
53
|
-
});
|
|
54
|
-
return (...args) => _chainable({
|
|
55
|
-
...target,
|
|
56
|
-
[prop]: args.length === 0 ? true : args[0]
|
|
57
|
-
});
|
|
58
|
-
} });
|
|
59
|
-
}
|
|
60
29
|
const _actionBuilderProxy = createActionCallbackProxy();
|
|
61
30
|
const _simpleActionProxy = createActionCallbackProxy();
|
|
62
31
|
const _collExt = {
|
|
@@ -81,7 +50,8 @@ const _collExt = {
|
|
|
81
50
|
collectionTable: "collection-table"
|
|
82
51
|
}),
|
|
83
52
|
f: _fieldRefProxy,
|
|
84
|
-
a: _simpleActionProxy
|
|
53
|
+
a: _simpleActionProxy,
|
|
54
|
+
c: _componentProxy
|
|
85
55
|
}) : configOrFn
|
|
86
56
|
};
|
|
87
57
|
}
|
|
@@ -112,7 +82,7 @@ const _collExt = {
|
|
|
112
82
|
if (typeof configOrFn === "function") return configOrFn({
|
|
113
83
|
a: _actionBuilderProxy,
|
|
114
84
|
c: _componentProxy,
|
|
115
|
-
f:
|
|
85
|
+
f: createActionFieldBuilderProxy()
|
|
116
86
|
});
|
|
117
87
|
return configOrFn;
|
|
118
88
|
}
|
|
@@ -927,7 +927,7 @@ declare const adminModule: {
|
|
|
927
927
|
$Infer: {
|
|
928
928
|
body: {
|
|
929
929
|
permissions: {
|
|
930
|
-
readonly user?: ("
|
|
930
|
+
readonly user?: ("create" | "update" | "list" | "set-role" | "ban" | "impersonate" | "impersonate-admins" | "delete" | "set-password" | "get")[] | undefined;
|
|
931
931
|
readonly session?: ("list" | "delete" | "revoke")[] | undefined;
|
|
932
932
|
};
|
|
933
933
|
} & {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import "./route-helpers.mjs";
|
|
2
|
+
import * as questpie456 from "questpie";
|
|
2
3
|
|
|
3
4
|
//#region src/server/modules/admin/routes/admin-config.d.ts
|
|
4
5
|
|
|
@@ -7,7 +8,8 @@ import * as questpie259 from "questpie";
|
|
|
7
8
|
* Registered via module routes and exposed through the fetch handler.
|
|
8
9
|
*/
|
|
9
10
|
declare const adminConfigFunctions: {
|
|
10
|
-
readonly getAdminConfig:
|
|
11
|
+
readonly getAdminConfig: questpie456.JsonRouteDefinition<Record<string, never> | undefined, any, questpie456.JsonRouteParams>;
|
|
12
|
+
readonly getPublicAdminConfig: questpie456.JsonRouteDefinition<Record<string, never> | undefined, any, questpie456.JsonRouteParams>;
|
|
11
13
|
};
|
|
12
14
|
//#endregion
|
|
13
15
|
export { adminConfigFunctions };
|
|
@@ -514,6 +514,11 @@ async function processDashboardItems(items, accessibleCollections, accessCtx) {
|
|
|
514
514
|
}
|
|
515
515
|
const getAdminConfigSchema = z.object({}).optional();
|
|
516
516
|
const getAdminConfigOutputSchema = adminConfigDTOSchema;
|
|
517
|
+
function buildPublicAdminConfig(adminCfg) {
|
|
518
|
+
const response = {};
|
|
519
|
+
if (adminCfg.branding) response.branding = adminCfg.branding;
|
|
520
|
+
return stripUndefinedDeep(response);
|
|
521
|
+
}
|
|
517
522
|
/**
|
|
518
523
|
* Get admin configuration including dashboard, sidebar, blocks,
|
|
519
524
|
* and collection/global metadata.
|
|
@@ -535,7 +540,7 @@ const getAdminConfigOutputSchema = adminConfigDTOSchema;
|
|
|
535
540
|
* const config = await client.routes.getAdminConfig({});
|
|
536
541
|
* ```
|
|
537
542
|
*/
|
|
538
|
-
const getAdminConfig = route().post().access((ctx) =>
|
|
543
|
+
const getAdminConfig = route().post().access((ctx) => ctx.session?.user?.role === "admin").schema(getAdminConfigSchema).outputSchema(getAdminConfigOutputSchema).handler(async (ctx) => {
|
|
539
544
|
const app = getApp(ctx);
|
|
540
545
|
const appState = getAppState(app);
|
|
541
546
|
const adminCfg = getAdminConfig$1(app);
|
|
@@ -590,10 +595,21 @@ const getAdminConfig = route().post().access((ctx) => !!ctx.session).schema(getA
|
|
|
590
595
|
return stripUndefinedDeep(response);
|
|
591
596
|
});
|
|
592
597
|
/**
|
|
598
|
+
* Get public admin bootstrap configuration for unauthenticated auth pages.
|
|
599
|
+
*
|
|
600
|
+
* This intentionally exposes only branding. Full admin config, sidebar,
|
|
601
|
+
* dashboard, blocks, upload collections, and resource metadata stay behind
|
|
602
|
+
* getAdminConfig's admin-session guard.
|
|
603
|
+
*/
|
|
604
|
+
const getPublicAdminConfig = route().post().access(true).schema(getAdminConfigSchema).outputSchema(getAdminConfigOutputSchema).handler(async (ctx) => buildPublicAdminConfig(getAdminConfig$1(getApp(ctx))));
|
|
605
|
+
/**
|
|
593
606
|
* Admin config route handlers.
|
|
594
607
|
* Registered via module routes and exposed through the fetch handler.
|
|
595
608
|
*/
|
|
596
|
-
const adminConfigFunctions = {
|
|
609
|
+
const adminConfigFunctions = {
|
|
610
|
+
getAdminConfig,
|
|
611
|
+
getPublicAdminConfig
|
|
612
|
+
};
|
|
597
613
|
|
|
598
614
|
//#endregion
|
|
599
615
|
export { adminConfigFunctions };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ServerActionDefinition, ServerActionResult } from "../../../augmentation/actions.mjs";
|
|
2
2
|
import "../../../augmentation.mjs";
|
|
3
3
|
import { App } from "./route-helpers.mjs";
|
|
4
|
-
import * as
|
|
4
|
+
import * as questpie64 from "questpie";
|
|
5
5
|
|
|
6
6
|
//#region src/server/modules/admin/routes/execute-action.d.ts
|
|
7
7
|
|
|
@@ -56,37 +56,37 @@ declare function executeAction(app: App, request: ExecuteActionRequest, session?
|
|
|
56
56
|
* });
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
declare const executeActionFn:
|
|
59
|
+
declare const executeActionFn: questpie64.JsonRouteDefinition<{
|
|
60
60
|
collection: string;
|
|
61
61
|
actionId: string;
|
|
62
62
|
itemId?: string | undefined;
|
|
63
63
|
itemIds?: string[] | undefined;
|
|
64
64
|
data?: Record<string, unknown> | undefined;
|
|
65
65
|
locale?: string | undefined;
|
|
66
|
-
}, any,
|
|
66
|
+
}, any, questpie64.JsonRouteParams>;
|
|
67
67
|
/**
|
|
68
68
|
* Get actions configuration for a collection.
|
|
69
69
|
* Returns action definitions without handlers for client rendering.
|
|
70
70
|
*/
|
|
71
|
-
declare const getActionsConfigFn:
|
|
71
|
+
declare const getActionsConfigFn: questpie64.JsonRouteDefinition<{
|
|
72
72
|
collection: string;
|
|
73
|
-
}, any,
|
|
73
|
+
}, any, questpie64.JsonRouteParams>;
|
|
74
74
|
/**
|
|
75
75
|
* QUESTPIE functions for action execution.
|
|
76
76
|
* These are registered on the `adminModule`.
|
|
77
77
|
*/
|
|
78
78
|
declare const actionFunctions: {
|
|
79
|
-
executeAction:
|
|
79
|
+
executeAction: questpie64.JsonRouteDefinition<{
|
|
80
80
|
collection: string;
|
|
81
81
|
actionId: string;
|
|
82
82
|
itemId?: string | undefined;
|
|
83
83
|
itemIds?: string[] | undefined;
|
|
84
84
|
data?: Record<string, unknown> | undefined;
|
|
85
85
|
locale?: string | undefined;
|
|
86
|
-
}, any,
|
|
87
|
-
getActionsConfig:
|
|
86
|
+
}, any, questpie64.JsonRouteParams>;
|
|
87
|
+
getActionsConfig: questpie64.JsonRouteDefinition<{
|
|
88
88
|
collection: string;
|
|
89
|
-
}, any,
|
|
89
|
+
}, any, questpie64.JsonRouteParams>;
|
|
90
90
|
};
|
|
91
91
|
//#endregion
|
|
92
92
|
export { ExecuteActionRequest, ExecuteActionResponse, actionFunctions, executeAction, executeActionFn, getActionsConfig, getActionsConfigFn };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { getApp, getCollection, getCollectionCrud, getCollectionCruds, getGlobalCruds, getSession } from "./route-helpers.mjs";
|
|
2
2
|
import { translateAdminMessage } from "./i18n-helpers.mjs";
|
|
3
3
|
import { z } from "zod";
|
|
4
|
-
import { route, runWithContext } from "questpie";
|
|
4
|
+
import { extractAppServices, route, runWithContext } from "questpie";
|
|
5
5
|
|
|
6
6
|
//#region src/server/modules/admin/routes/execute-action.ts
|
|
7
7
|
/**
|
|
@@ -144,6 +144,11 @@ async function executeAction(app, request, session) {
|
|
|
144
144
|
}
|
|
145
145
|
try {
|
|
146
146
|
const appRec = app;
|
|
147
|
+
const services = extractAppServices(app, {
|
|
148
|
+
db: appRec.db,
|
|
149
|
+
session,
|
|
150
|
+
locale
|
|
151
|
+
});
|
|
147
152
|
const context = {
|
|
148
153
|
data: data || {},
|
|
149
154
|
itemId,
|
|
@@ -154,7 +159,8 @@ async function executeAction(app, request, session) {
|
|
|
154
159
|
db: appRec.db,
|
|
155
160
|
session,
|
|
156
161
|
locale,
|
|
157
|
-
t
|
|
162
|
+
t,
|
|
163
|
+
workflows: services.workflows
|
|
158
164
|
};
|
|
159
165
|
const result = await runWithContext({
|
|
160
166
|
app,
|
|
@@ -474,7 +480,7 @@ const getActionsConfigResponseSchema = z.object({
|
|
|
474
480
|
* });
|
|
475
481
|
* ```
|
|
476
482
|
*/
|
|
477
|
-
const executeActionFn = route().post().access((ctx) =>
|
|
483
|
+
const executeActionFn = route().post().access((ctx) => ctx.session?.user?.role === "admin").schema(executeActionRequestSchema).outputSchema(executeActionResponseSchema).handler(async (ctx) => {
|
|
478
484
|
const app = getApp(ctx);
|
|
479
485
|
const session = getSession(ctx);
|
|
480
486
|
return executeAction(app, ctx.input, session);
|
|
@@ -483,7 +489,7 @@ const executeActionFn = route().post().access((ctx) => !!ctx.session).schema(exe
|
|
|
483
489
|
* Get actions configuration for a collection.
|
|
484
490
|
* Returns action definitions without handlers for client rendering.
|
|
485
491
|
*/
|
|
486
|
-
const getActionsConfigFn = route().post().access((ctx) =>
|
|
492
|
+
const getActionsConfigFn = route().post().access((ctx) => ctx.session?.user?.role === "admin").schema(getActionsConfigRequestSchema).outputSchema(getActionsConfigResponseSchema).handler((ctx) => {
|
|
487
493
|
return getActionsConfig(getApp(ctx), ctx.input.collection);
|
|
488
494
|
});
|
|
489
495
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie460 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/locales.d.ts
|
|
4
4
|
|
|
@@ -12,7 +12,7 @@ import * as questpie344 from "questpie";
|
|
|
12
12
|
* Bundle of locale-related functions.
|
|
13
13
|
*/
|
|
14
14
|
declare const localeFunctions: {
|
|
15
|
-
readonly getContentLocales:
|
|
15
|
+
readonly getContentLocales: questpie460.JsonRouteDefinition<Record<string, never> | undefined, any, questpie460.JsonRouteParams>;
|
|
16
16
|
};
|
|
17
17
|
//#endregion
|
|
18
18
|
export { localeFunctions };
|
|
@@ -39,7 +39,7 @@ const getContentLocalesOutputSchema = z.object({
|
|
|
39
39
|
* // }
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
const getContentLocales = route().post().schema(getContentLocalesSchema).outputSchema(getContentLocalesOutputSchema).handler(async (ctx) => {
|
|
42
|
+
const getContentLocales = route().post().access(true).schema(getContentLocalesSchema).outputSchema(getContentLocalesOutputSchema).handler(async (ctx) => {
|
|
43
43
|
const localeConfig = getApp(ctx).config.locale;
|
|
44
44
|
if (!localeConfig) return {
|
|
45
45
|
locales: [{
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie72 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/preview.d.ts
|
|
4
4
|
|
|
@@ -25,13 +25,13 @@ interface PreviewTokenPayload {
|
|
|
25
25
|
* @returns Object with preview functions
|
|
26
26
|
*/
|
|
27
27
|
declare function createPreviewFunctions(secret?: PreviewSecretSource): {
|
|
28
|
-
mintPreviewToken:
|
|
28
|
+
mintPreviewToken: questpie72.JsonRouteDefinition<{
|
|
29
29
|
path: string;
|
|
30
30
|
ttlMs?: number | undefined;
|
|
31
|
-
}, any,
|
|
32
|
-
verifyPreviewToken:
|
|
31
|
+
}, any, questpie72.JsonRouteParams>;
|
|
32
|
+
verifyPreviewToken: questpie72.JsonRouteDefinition<{
|
|
33
33
|
token: string;
|
|
34
|
-
}, any,
|
|
34
|
+
}, any, questpie72.JsonRouteParams>;
|
|
35
35
|
};
|
|
36
36
|
/**
|
|
37
37
|
* Verify a preview token without RPC.
|
|
@@ -68,18 +68,18 @@ declare function createPreviewTokenVerifier(secret: string): (token: string) =>
|
|
|
68
68
|
* Used by the `adminModule` to register preview RPC functions.
|
|
69
69
|
*/
|
|
70
70
|
declare const previewFunctions: {
|
|
71
|
-
getPreviewUrl:
|
|
71
|
+
getPreviewUrl: questpie72.JsonRouteDefinition<{
|
|
72
72
|
collection: string;
|
|
73
73
|
record: Record<string, unknown>;
|
|
74
74
|
locale?: string | undefined;
|
|
75
|
-
}, any,
|
|
76
|
-
mintPreviewToken:
|
|
75
|
+
}, any, questpie72.JsonRouteParams>;
|
|
76
|
+
mintPreviewToken: questpie72.JsonRouteDefinition<{
|
|
77
77
|
path: string;
|
|
78
78
|
ttlMs?: number | undefined;
|
|
79
|
-
}, any,
|
|
80
|
-
verifyPreviewToken:
|
|
79
|
+
}, any, questpie72.JsonRouteParams>;
|
|
80
|
+
verifyPreviewToken: questpie72.JsonRouteDefinition<{
|
|
81
81
|
token: string;
|
|
82
|
-
}, any,
|
|
82
|
+
}, any, questpie72.JsonRouteParams>;
|
|
83
83
|
};
|
|
84
84
|
//#endregion
|
|
85
85
|
export { PreviewTokenPayload, createPreviewFunctions, createPreviewTokenVerifier, previewFunctions, verifyPreviewTokenDirect };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { hasAdminRole } from "../auth-helpers.mjs";
|
|
2
|
+
import { getApp, getCollectionState, getLocale } from "./route-helpers.mjs";
|
|
2
3
|
import { translateAdminMessage } from "./i18n-helpers.mjs";
|
|
3
4
|
import { z } from "zod";
|
|
4
5
|
import { ApiError, route } from "questpie";
|
|
@@ -103,11 +104,11 @@ const DEFAULT_TTL_MS = 3600 * 1e3;
|
|
|
103
104
|
*/
|
|
104
105
|
function createPreviewFunctions(secret = defaultPreviewSecret) {
|
|
105
106
|
return {
|
|
106
|
-
mintPreviewToken: route().post().schema(mintPreviewTokenSchema).outputSchema(mintPreviewTokenOutputSchema).handler(async (ctx) => {
|
|
107
|
+
mintPreviewToken: route().post().access((ctx) => ctx.session?.user?.role === "admin").schema(mintPreviewTokenSchema).outputSchema(mintPreviewTokenOutputSchema).handler(async (ctx) => {
|
|
107
108
|
const { input } = ctx;
|
|
108
109
|
const locale = getLocale(ctx);
|
|
109
110
|
const t = (key, params) => translateAdminMessage(locale, key, params);
|
|
110
|
-
if (!
|
|
111
|
+
if (!hasAdminRole(ctx)) throw ApiError.unauthorized(t("preview.adminSessionRequired"));
|
|
111
112
|
const { path, ttlMs = DEFAULT_TTL_MS } = input;
|
|
112
113
|
const expiresAt = Date.now() + ttlMs;
|
|
113
114
|
const payload = {
|
|
@@ -210,11 +211,11 @@ const getPreviewUrlOutputSchema = z.object({
|
|
|
210
211
|
* // Returns: "/about?preview=true"
|
|
211
212
|
* ```
|
|
212
213
|
*/
|
|
213
|
-
const getPreviewUrl = route().post().schema(getPreviewUrlSchema).outputSchema(getPreviewUrlOutputSchema).handler(async (ctx) => {
|
|
214
|
+
const getPreviewUrl = route().post().access((ctx) => ctx.session?.user?.role === "admin").schema(getPreviewUrlSchema).outputSchema(getPreviewUrlOutputSchema).handler(async (ctx) => {
|
|
214
215
|
const { input } = ctx;
|
|
215
216
|
const messageLocale = getLocale(ctx) ?? input.locale;
|
|
216
217
|
const t = (key, params) => translateAdminMessage(messageLocale, key, params);
|
|
217
|
-
if (!
|
|
218
|
+
if (!hasAdminRole(ctx)) return {
|
|
218
219
|
url: null,
|
|
219
220
|
error: t("preview.adminSessionRequired")
|
|
220
221
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie82 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/reactive.d.ts
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ import * as questpie121 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: questpie82.JsonRouteDefinition<{
|
|
17
17
|
collection: string;
|
|
18
18
|
type: "collection" | "global";
|
|
19
19
|
requests: {
|
|
@@ -27,12 +27,12 @@ declare const batchReactive: questpie121.JsonRouteDefinition<{
|
|
|
27
27
|
}[];
|
|
28
28
|
formData?: Record<string, unknown> | undefined;
|
|
29
29
|
prevData?: Record<string, unknown> | null | undefined;
|
|
30
|
-
}, any,
|
|
30
|
+
}, any, questpie82.JsonRouteParams>;
|
|
31
31
|
/**
|
|
32
32
|
* Dynamic options endpoint.
|
|
33
33
|
* Fetches options for select/relation fields with search and pagination.
|
|
34
34
|
*/
|
|
35
|
-
declare const fieldOptions:
|
|
35
|
+
declare const fieldOptions: questpie82.JsonRouteDefinition<{
|
|
36
36
|
collection: string;
|
|
37
37
|
type: "collection" | "global";
|
|
38
38
|
field: string;
|
|
@@ -41,12 +41,12 @@ declare const fieldOptions: questpie121.JsonRouteDefinition<{
|
|
|
41
41
|
page: number;
|
|
42
42
|
limit: number;
|
|
43
43
|
siblingData?: Record<string, unknown> | null | undefined;
|
|
44
|
-
}, any,
|
|
44
|
+
}, any, questpie82.JsonRouteParams>;
|
|
45
45
|
/**
|
|
46
46
|
* Reactive functions bundle.
|
|
47
47
|
*/
|
|
48
48
|
declare const reactiveFunctions: {
|
|
49
|
-
readonly batchReactive:
|
|
49
|
+
readonly batchReactive: questpie82.JsonRouteDefinition<{
|
|
50
50
|
collection: string;
|
|
51
51
|
type: "collection" | "global";
|
|
52
52
|
requests: {
|
|
@@ -60,8 +60,8 @@ declare const reactiveFunctions: {
|
|
|
60
60
|
}[];
|
|
61
61
|
formData?: Record<string, unknown> | undefined;
|
|
62
62
|
prevData?: Record<string, unknown> | null | undefined;
|
|
63
|
-
}, any,
|
|
64
|
-
readonly fieldOptions:
|
|
63
|
+
}, any, questpie82.JsonRouteParams>;
|
|
64
|
+
readonly fieldOptions: questpie82.JsonRouteDefinition<{
|
|
65
65
|
collection: string;
|
|
66
66
|
type: "collection" | "global";
|
|
67
67
|
field: string;
|
|
@@ -70,7 +70,7 @@ declare const reactiveFunctions: {
|
|
|
70
70
|
page: number;
|
|
71
71
|
limit: number;
|
|
72
72
|
siblingData?: Record<string, unknown> | null | undefined;
|
|
73
|
-
}, any,
|
|
73
|
+
}, any, questpie82.JsonRouteParams>;
|
|
74
74
|
};
|
|
75
75
|
//#endregion
|
|
76
76
|
export { batchReactive, fieldOptions, reactiveFunctions };
|
|
@@ -306,7 +306,7 @@ const optionsOutputSchema = z.object({
|
|
|
306
306
|
* Batch reactive endpoint.
|
|
307
307
|
* Executes multiple reactive handlers in a single request.
|
|
308
308
|
*/
|
|
309
|
-
const batchReactive = route().post().access((ctx) =>
|
|
309
|
+
const batchReactive = route().post().access((ctx) => ctx.session?.user?.role === "admin").schema(batchReactiveInputSchema).outputSchema(batchReactiveOutputSchema).handler(async (ctx) => {
|
|
310
310
|
const app = getApp(ctx);
|
|
311
311
|
const { collection: entityName, type: entityType, requests, formData: sharedFormData, prevData: sharedPrevData } = ctx.input;
|
|
312
312
|
const serverCtx = buildServerContext(ctx);
|
|
@@ -359,7 +359,7 @@ const batchReactive = route().post().access((ctx) => !!ctx.session).schema(batch
|
|
|
359
359
|
* Dynamic options endpoint.
|
|
360
360
|
* Fetches options for select/relation fields with search and pagination.
|
|
361
361
|
*/
|
|
362
|
-
const fieldOptions = route().post().access((ctx) =>
|
|
362
|
+
const fieldOptions = route().post().access((ctx) => ctx.session?.user?.role === "admin").schema(optionsInputSchema).outputSchema(optionsOutputSchema).handler(async (ctx) => {
|
|
363
363
|
const app = getApp(ctx);
|
|
364
364
|
const { collection: entityName, type: entityType, field: field$1, formData, siblingData, search, page, limit } = ctx.input;
|
|
365
365
|
const serverCtx = buildServerContext(ctx);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie90 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/setup.d.ts
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ import * as questpie139 from "questpie";
|
|
|
13
13
|
* }
|
|
14
14
|
* ```
|
|
15
15
|
*/
|
|
16
|
-
declare const isSetupRequired:
|
|
16
|
+
declare const isSetupRequired: questpie90.JsonRouteDefinition<Record<string, never>, any, questpie90.JsonRouteParams>;
|
|
17
17
|
/**
|
|
18
18
|
* Create the first admin user in the system.
|
|
19
19
|
* This function only works when no admin users exist (setup mode).
|
|
@@ -36,21 +36,21 @@ declare const isSetupRequired: questpie139.JsonRouteDefinition<Record<string, ne
|
|
|
36
36
|
* }
|
|
37
37
|
* ```
|
|
38
38
|
*/
|
|
39
|
-
declare const createFirstAdmin:
|
|
39
|
+
declare const createFirstAdmin: questpie90.JsonRouteDefinition<{
|
|
40
40
|
email: string;
|
|
41
41
|
password: string;
|
|
42
42
|
name: string;
|
|
43
|
-
}, any,
|
|
43
|
+
}, any, questpie90.JsonRouteParams>;
|
|
44
44
|
/**
|
|
45
45
|
* Bundle of setup-related functions.
|
|
46
46
|
*/
|
|
47
47
|
declare const setupFunctions: {
|
|
48
|
-
readonly isSetupRequired:
|
|
49
|
-
readonly createFirstAdmin:
|
|
48
|
+
readonly isSetupRequired: questpie90.JsonRouteDefinition<Record<string, never>, any, questpie90.JsonRouteParams>;
|
|
49
|
+
readonly createFirstAdmin: questpie90.JsonRouteDefinition<{
|
|
50
50
|
email: string;
|
|
51
51
|
password: string;
|
|
52
52
|
name: string;
|
|
53
|
-
}, any,
|
|
53
|
+
}, any, questpie90.JsonRouteParams>;
|
|
54
54
|
};
|
|
55
55
|
//#endregion
|
|
56
56
|
export { createFirstAdmin, isSetupRequired, setupFunctions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie462 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/translations.d.ts
|
|
4
4
|
|
|
@@ -17,10 +17,10 @@ import * as questpie346 from "questpie";
|
|
|
17
17
|
* Bundle of translation-related functions.
|
|
18
18
|
*/
|
|
19
19
|
declare const translationFunctions: {
|
|
20
|
-
readonly getAdminTranslations:
|
|
20
|
+
readonly getAdminTranslations: questpie462.JsonRouteDefinition<{
|
|
21
21
|
locale: string;
|
|
22
|
-
}, any,
|
|
23
|
-
readonly getAdminLocales:
|
|
22
|
+
}, any, questpie462.JsonRouteParams>;
|
|
23
|
+
readonly getAdminLocales: questpie462.JsonRouteDefinition<Record<string, never> | undefined, any, questpie462.JsonRouteParams>;
|
|
24
24
|
};
|
|
25
25
|
//#endregion
|
|
26
26
|
export { translationFunctions };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie16 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/widget-data.d.ts
|
|
4
4
|
|
|
@@ -20,13 +20,13 @@ import * as questpie147 from "questpie";
|
|
|
20
20
|
* const data = await client.routes.fetchWidgetData({ widgetId: "my-widget" });
|
|
21
21
|
* ```
|
|
22
22
|
*/
|
|
23
|
-
declare const fetchWidgetData:
|
|
23
|
+
declare const fetchWidgetData: questpie16.JsonRouteDefinition<{
|
|
24
24
|
widgetId: string;
|
|
25
|
-
}, any,
|
|
25
|
+
}, any, questpie16.JsonRouteParams>;
|
|
26
26
|
declare const widgetDataFunctions: {
|
|
27
|
-
readonly fetchWidgetData:
|
|
27
|
+
readonly fetchWidgetData: questpie16.JsonRouteDefinition<{
|
|
28
28
|
widgetId: string;
|
|
29
|
-
}, any,
|
|
29
|
+
}, any, questpie16.JsonRouteParams>;
|
|
30
30
|
};
|
|
31
31
|
//#endregion
|
|
32
32
|
export { fetchWidgetData, widgetDataFunctions };
|
|
@@ -39,7 +39,7 @@ const fetchWidgetDataSchema = z.object({ widgetId: z.string() });
|
|
|
39
39
|
* const data = await client.routes.fetchWidgetData({ widgetId: "my-widget" });
|
|
40
40
|
* ```
|
|
41
41
|
*/
|
|
42
|
-
const fetchWidgetData = route().post().access((ctx) =>
|
|
42
|
+
const fetchWidgetData = route().post().access((ctx) => ctx.session?.user?.role === "admin").schema(fetchWidgetDataSchema).outputSchema(z.unknown()).handler(async (ctx) => {
|
|
43
43
|
const stored = tryGetContext();
|
|
44
44
|
const routeApp = ctx.app ?? stored?.app;
|
|
45
45
|
const appState = routeApp?.state || {};
|