@questpie/admin 3.3.0 → 3.4.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/README.md +4 -6
- package/dist/client/blocks/block-renderer.d.mts +2 -2
- package/dist/client/builder/admin-types.d.mts +3 -3
- package/dist/client/builder/types/action-types.d.mts +1 -1
- package/dist/client/builder/types/collection-types.d.mts +59 -2
- package/dist/client/modules/admin.d.mts +3 -0
- package/dist/client/modules/admin.mjs +3 -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/views/collection/list-view.mjs +830 -0
- package/dist/client/views/collection/outline.mjs +363 -0
- package/dist/client/views/collection/table-view.mjs +6 -3
- package/dist/client/views/layout/admin-layout.d.mts +15 -1
- package/dist/client/views/layout/admin-layout.mjs +95 -31
- package/dist/client.d.mts +6 -6
- package/dist/components/rich-text/rich-text-renderer.d.mts +2 -2
- package/dist/factories.d.mts +19 -0
- package/dist/factories.mjs +11 -0
- package/dist/fields.d.mts +4 -0
- package/dist/fields.mjs +5 -0
- package/dist/index.d.mts +6 -6
- package/dist/modules/admin.d.mts +10 -0
- package/dist/modules/admin.mjs +9 -0
- package/dist/modules/audit.d.mts +5 -0
- package/dist/modules/audit.mjs +5 -0
- package/dist/server/augmentation/form-layout.d.mts +57 -2
- package/dist/server/augmentation/index.d.mts +3 -1
- package/dist/server/augmentation/shell.d.mts +48 -0
- package/dist/server/augmentation.d.mts +2 -1
- package/dist/server/codegen/admin-client-template.mjs +11 -4
- package/dist/server/fields/blocks.d.mts +9 -2
- package/dist/server/fields/blocks.mjs +1 -1
- package/dist/server/fields/index.d.mts +2 -2
- package/dist/server/fields/index.mjs +2 -2
- package/dist/server/fields/rich-text.d.mts +9 -2
- package/dist/server/fields/rich-text.mjs +1 -1
- package/dist/server/modules/admin/.generated/module.d.mts +24 -19
- package/dist/server/modules/admin/.generated/module.mjs +5 -1
- package/dist/server/modules/admin/.generated/registries.d.mts +6 -4
- package/dist/server/modules/admin/client/.generated/module.d.mts +70 -70
- package/dist/server/modules/admin/client/.generated/module.mjs +3 -1
- package/dist/server/modules/admin/client/views/collection-form.d.mts +6 -0
- package/dist/server/modules/admin/client/views/collection-table.d.mts +6 -0
- package/dist/server/modules/admin/client/views/global-form.d.mts +6 -0
- package/dist/server/modules/admin/client/views/list-view.d.mts +6 -0
- package/dist/server/modules/admin/client/views/list-view.mjs +10 -0
- package/dist/server/modules/admin/collections/account.d.mts +46 -46
- package/dist/server/modules/admin/collections/admin-locks.d.mts +54 -54
- package/dist/server/modules/admin/collections/admin-preferences.d.mts +34 -34
- package/dist/server/modules/admin/collections/admin-saved-views.d.mts +47 -47
- package/dist/server/modules/admin/collections/apikey.d.mts +68 -68
- package/dist/server/modules/admin/collections/assets.d.mts +34 -34
- package/dist/server/modules/admin/collections/session.d.mts +38 -38
- package/dist/server/modules/admin/dto/admin-config.dto.mjs +17 -0
- package/dist/server/modules/admin/index.d.mts +30 -31
- package/dist/server/modules/admin/routes/admin-config.d.mts +0 -15
- package/dist/server/modules/admin/routes/admin-config.mjs +21 -5
- package/dist/server/modules/admin/routes/execute-action.d.mts +9 -9
- package/dist/server/modules/admin/routes/execute-action.mjs +18 -12
- package/dist/server/modules/admin/routes/i18n-helpers.d.mts +4 -0
- package/dist/server/modules/admin/routes/preview.d.mts +11 -11
- package/dist/server/modules/admin/routes/reactive.d.mts +9 -9
- package/dist/server/modules/admin/routes/route-helpers.mjs +36 -1
- package/dist/server/modules/admin/routes/setup.d.mts +7 -14
- package/dist/server/modules/admin/routes/setup.mjs +16 -3
- package/dist/server/modules/admin/routes/widget-data.d.mts +5 -5
- package/dist/server/modules/admin/views/list-view.d.mts +8 -0
- package/dist/server/modules/admin/views/list-view.mjs +7 -0
- package/dist/server/modules/audit/collections/audit-log.d.mts +7 -2
- package/dist/server/modules/audit/index.d.mts +1 -1
- package/dist/server/plugin.d.mts +1 -1
- package/dist/server/plugin.mjs +28 -28
- package/dist/server.d.mts +5 -4
- package/dist/server.mjs +7 -7
- package/package.json +13 -3
|
@@ -10,7 +10,6 @@ import "./index.mjs";
|
|
|
10
10
|
import * as zod0 from "zod";
|
|
11
11
|
import * as questpie0 from "questpie";
|
|
12
12
|
import * as better_auth0 from "better-auth";
|
|
13
|
-
import * as better_call0 from "better-call";
|
|
14
13
|
import * as better_auth_plugins0 from "better-auth/plugins";
|
|
15
14
|
import * as zod_v4_core0 from "zod/v4/core";
|
|
16
15
|
import * as questpie_src_server_modules_core_fields_email_js0 from "questpie/src/server/modules/core/fields/email.js";
|
|
@@ -168,18 +167,18 @@ declare const adminModule: {
|
|
|
168
167
|
hooks: {
|
|
169
168
|
after: {
|
|
170
169
|
matcher(context: better_auth0.HookEndpointContext): boolean;
|
|
171
|
-
handler: (inputContext:
|
|
170
|
+
handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<better_auth_plugins0.SessionWithImpersonatedBy[] | undefined>;
|
|
172
171
|
}[];
|
|
173
172
|
};
|
|
174
173
|
endpoints: {
|
|
175
|
-
setRole:
|
|
174
|
+
setRole: better_auth0.StrictEndpoint<"/admin/set-role", {
|
|
176
175
|
method: "POST";
|
|
177
176
|
body: zod0.ZodObject<{
|
|
178
177
|
userId: zod0.ZodCoercedString<unknown>;
|
|
179
178
|
role: zod0.ZodUnion<readonly [zod0.ZodString, zod0.ZodArray<zod0.ZodString>]>;
|
|
180
179
|
}, zod_v4_core0.$strip>;
|
|
181
180
|
requireHeaders: true;
|
|
182
|
-
use: ((inputContext:
|
|
181
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
183
182
|
session: {
|
|
184
183
|
user: better_auth_plugins0.UserWithRole;
|
|
185
184
|
session: {
|
|
@@ -227,12 +226,12 @@ declare const adminModule: {
|
|
|
227
226
|
}, {
|
|
228
227
|
user: better_auth_plugins0.UserWithRole;
|
|
229
228
|
}>;
|
|
230
|
-
getUser:
|
|
229
|
+
getUser: better_auth0.StrictEndpoint<"/admin/get-user", {
|
|
231
230
|
method: "GET";
|
|
232
231
|
query: zod0.ZodObject<{
|
|
233
232
|
id: zod0.ZodString;
|
|
234
233
|
}, zod_v4_core0.$strip>;
|
|
235
|
-
use: ((inputContext:
|
|
234
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
236
235
|
session: {
|
|
237
236
|
user: better_auth_plugins0.UserWithRole;
|
|
238
237
|
session: {
|
|
@@ -272,7 +271,7 @@ declare const adminModule: {
|
|
|
272
271
|
};
|
|
273
272
|
};
|
|
274
273
|
}, better_auth_plugins0.UserWithRole>;
|
|
275
|
-
createUser:
|
|
274
|
+
createUser: better_auth0.StrictEndpoint<"/admin/create-user", {
|
|
276
275
|
method: "POST";
|
|
277
276
|
body: zod0.ZodObject<{
|
|
278
277
|
email: zod0.ZodString;
|
|
@@ -317,13 +316,13 @@ declare const adminModule: {
|
|
|
317
316
|
}, {
|
|
318
317
|
user: better_auth_plugins0.UserWithRole;
|
|
319
318
|
}>;
|
|
320
|
-
adminUpdateUser:
|
|
319
|
+
adminUpdateUser: better_auth0.StrictEndpoint<"/admin/update-user", {
|
|
321
320
|
method: "POST";
|
|
322
321
|
body: zod0.ZodObject<{
|
|
323
322
|
userId: zod0.ZodCoercedString<unknown>;
|
|
324
323
|
data: zod0.ZodRecord<zod0.ZodAny, zod0.ZodAny>;
|
|
325
324
|
}, zod_v4_core0.$strip>;
|
|
326
|
-
use: ((inputContext:
|
|
325
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
327
326
|
session: {
|
|
328
327
|
user: better_auth_plugins0.UserWithRole;
|
|
329
328
|
session: {
|
|
@@ -363,9 +362,9 @@ declare const adminModule: {
|
|
|
363
362
|
};
|
|
364
363
|
};
|
|
365
364
|
}, better_auth_plugins0.UserWithRole>;
|
|
366
|
-
listUsers:
|
|
365
|
+
listUsers: better_auth0.StrictEndpoint<"/admin/list-users", {
|
|
367
366
|
method: "GET";
|
|
368
|
-
use: ((inputContext:
|
|
367
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
369
368
|
session: {
|
|
370
369
|
user: better_auth_plugins0.UserWithRole;
|
|
371
370
|
session: {
|
|
@@ -455,9 +454,9 @@ declare const adminModule: {
|
|
|
455
454
|
users: better_auth_plugins0.UserWithRole[];
|
|
456
455
|
total: number;
|
|
457
456
|
}>;
|
|
458
|
-
listUserSessions:
|
|
457
|
+
listUserSessions: better_auth0.StrictEndpoint<"/admin/list-user-sessions", {
|
|
459
458
|
method: "POST";
|
|
460
|
-
use: ((inputContext:
|
|
459
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
461
460
|
session: {
|
|
462
461
|
user: better_auth_plugins0.UserWithRole;
|
|
463
462
|
session: {
|
|
@@ -505,12 +504,12 @@ declare const adminModule: {
|
|
|
505
504
|
}, {
|
|
506
505
|
sessions: better_auth_plugins0.SessionWithImpersonatedBy[];
|
|
507
506
|
}>;
|
|
508
|
-
unbanUser:
|
|
507
|
+
unbanUser: better_auth0.StrictEndpoint<"/admin/unban-user", {
|
|
509
508
|
method: "POST";
|
|
510
509
|
body: zod0.ZodObject<{
|
|
511
510
|
userId: zod0.ZodCoercedString<unknown>;
|
|
512
511
|
}, zod_v4_core0.$strip>;
|
|
513
|
-
use: ((inputContext:
|
|
512
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
514
513
|
session: {
|
|
515
514
|
user: better_auth_plugins0.UserWithRole;
|
|
516
515
|
session: {
|
|
@@ -552,14 +551,14 @@ declare const adminModule: {
|
|
|
552
551
|
}, {
|
|
553
552
|
user: better_auth_plugins0.UserWithRole;
|
|
554
553
|
}>;
|
|
555
|
-
banUser:
|
|
554
|
+
banUser: better_auth0.StrictEndpoint<"/admin/ban-user", {
|
|
556
555
|
method: "POST";
|
|
557
556
|
body: zod0.ZodObject<{
|
|
558
557
|
userId: zod0.ZodCoercedString<unknown>;
|
|
559
558
|
banReason: zod0.ZodOptional<zod0.ZodString>;
|
|
560
559
|
banExpiresIn: zod0.ZodOptional<zod0.ZodNumber>;
|
|
561
560
|
}, zod_v4_core0.$strip>;
|
|
562
|
-
use: ((inputContext:
|
|
561
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
563
562
|
session: {
|
|
564
563
|
user: better_auth_plugins0.UserWithRole;
|
|
565
564
|
session: {
|
|
@@ -601,12 +600,12 @@ declare const adminModule: {
|
|
|
601
600
|
}, {
|
|
602
601
|
user: better_auth_plugins0.UserWithRole;
|
|
603
602
|
}>;
|
|
604
|
-
impersonateUser:
|
|
603
|
+
impersonateUser: better_auth0.StrictEndpoint<"/admin/impersonate-user", {
|
|
605
604
|
method: "POST";
|
|
606
605
|
body: zod0.ZodObject<{
|
|
607
606
|
userId: zod0.ZodCoercedString<unknown>;
|
|
608
607
|
}, zod_v4_core0.$strip>;
|
|
609
|
-
use: ((inputContext:
|
|
608
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
610
609
|
session: {
|
|
611
610
|
user: better_auth_plugins0.UserWithRole;
|
|
612
611
|
session: {
|
|
@@ -661,7 +660,7 @@ declare const adminModule: {
|
|
|
661
660
|
};
|
|
662
661
|
user: better_auth_plugins0.UserWithRole;
|
|
663
662
|
}>;
|
|
664
|
-
stopImpersonating:
|
|
663
|
+
stopImpersonating: better_auth0.StrictEndpoint<"/admin/stop-impersonating", {
|
|
665
664
|
method: "POST";
|
|
666
665
|
requireHeaders: true;
|
|
667
666
|
}, {
|
|
@@ -685,12 +684,12 @@ declare const adminModule: {
|
|
|
685
684
|
image?: string | null | undefined;
|
|
686
685
|
} & Record<string, any>;
|
|
687
686
|
}>;
|
|
688
|
-
revokeUserSession:
|
|
687
|
+
revokeUserSession: better_auth0.StrictEndpoint<"/admin/revoke-user-session", {
|
|
689
688
|
method: "POST";
|
|
690
689
|
body: zod0.ZodObject<{
|
|
691
690
|
sessionToken: zod0.ZodString;
|
|
692
691
|
}, zod_v4_core0.$strip>;
|
|
693
|
-
use: ((inputContext:
|
|
692
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
694
693
|
session: {
|
|
695
694
|
user: better_auth_plugins0.UserWithRole;
|
|
696
695
|
session: {
|
|
@@ -732,12 +731,12 @@ declare const adminModule: {
|
|
|
732
731
|
}, {
|
|
733
732
|
success: boolean;
|
|
734
733
|
}>;
|
|
735
|
-
revokeUserSessions:
|
|
734
|
+
revokeUserSessions: better_auth0.StrictEndpoint<"/admin/revoke-user-sessions", {
|
|
736
735
|
method: "POST";
|
|
737
736
|
body: zod0.ZodObject<{
|
|
738
737
|
userId: zod0.ZodCoercedString<unknown>;
|
|
739
738
|
}, zod_v4_core0.$strip>;
|
|
740
|
-
use: ((inputContext:
|
|
739
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
741
740
|
session: {
|
|
742
741
|
user: better_auth_plugins0.UserWithRole;
|
|
743
742
|
session: {
|
|
@@ -779,12 +778,12 @@ declare const adminModule: {
|
|
|
779
778
|
}, {
|
|
780
779
|
success: boolean;
|
|
781
780
|
}>;
|
|
782
|
-
removeUser:
|
|
781
|
+
removeUser: better_auth0.StrictEndpoint<"/admin/remove-user", {
|
|
783
782
|
method: "POST";
|
|
784
783
|
body: zod0.ZodObject<{
|
|
785
784
|
userId: zod0.ZodCoercedString<unknown>;
|
|
786
785
|
}, zod_v4_core0.$strip>;
|
|
787
|
-
use: ((inputContext:
|
|
786
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
788
787
|
session: {
|
|
789
788
|
user: better_auth_plugins0.UserWithRole;
|
|
790
789
|
session: {
|
|
@@ -826,13 +825,13 @@ declare const adminModule: {
|
|
|
826
825
|
}, {
|
|
827
826
|
success: boolean;
|
|
828
827
|
}>;
|
|
829
|
-
setUserPassword:
|
|
828
|
+
setUserPassword: better_auth0.StrictEndpoint<"/admin/set-user-password", {
|
|
830
829
|
method: "POST";
|
|
831
830
|
body: zod0.ZodObject<{
|
|
832
831
|
newPassword: zod0.ZodString;
|
|
833
832
|
userId: zod0.ZodCoercedString<unknown>;
|
|
834
833
|
}, zod_v4_core0.$strip>;
|
|
835
|
-
use: ((inputContext:
|
|
834
|
+
use: ((inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
836
835
|
session: {
|
|
837
836
|
user: better_auth_plugins0.UserWithRole;
|
|
838
837
|
session: {
|
|
@@ -874,7 +873,7 @@ declare const adminModule: {
|
|
|
874
873
|
}, {
|
|
875
874
|
status: boolean;
|
|
876
875
|
}>;
|
|
877
|
-
userHasPermission:
|
|
876
|
+
userHasPermission: better_auth0.StrictEndpoint<"/admin/has-permission", {
|
|
878
877
|
method: "POST";
|
|
879
878
|
body: zod0.ZodIntersection<zod0.ZodObject<{
|
|
880
879
|
userId: zod0.ZodOptional<zod0.ZodCoercedString<unknown>>;
|
|
@@ -1007,7 +1006,7 @@ declare const adminModule: {
|
|
|
1007
1006
|
hooks: {
|
|
1008
1007
|
before: {
|
|
1009
1008
|
matcher(context: better_auth0.HookEndpointContext): boolean;
|
|
1010
|
-
handler: (inputContext:
|
|
1009
|
+
handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<{
|
|
1011
1010
|
context: {
|
|
1012
1011
|
headers: Headers;
|
|
1013
1012
|
};
|
|
@@ -1015,7 +1014,7 @@ declare const adminModule: {
|
|
|
1015
1014
|
}[];
|
|
1016
1015
|
after: {
|
|
1017
1016
|
matcher(context: better_auth0.HookEndpointContext): true;
|
|
1018
|
-
handler: (inputContext:
|
|
1017
|
+
handler: (inputContext: better_auth0.MiddlewareInputContext<better_auth0.MiddlewareOptions>) => Promise<void>;
|
|
1019
1018
|
}[];
|
|
1020
1019
|
};
|
|
1021
1020
|
options: better_auth_plugins0.BearerOptions | undefined;
|
|
@@ -2,21 +2,6 @@ import * as questpie454 from "questpie";
|
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/admin-config.d.ts
|
|
4
4
|
|
|
5
|
-
/**
|
|
6
|
-
* Admin Config Functions
|
|
7
|
-
*
|
|
8
|
-
* Provides server-defined admin configuration (dashboard, sidebar,
|
|
9
|
-
* collection/global metadata) to the client via RPC.
|
|
10
|
-
*
|
|
11
|
-
* Filters results by the current user's read access.
|
|
12
|
-
*
|
|
13
|
-
* @example
|
|
14
|
-
* ```ts
|
|
15
|
-
* // Client usage
|
|
16
|
-
* const config = await client.routes.getAdminConfig({});
|
|
17
|
-
* // { dashboard: {...}, sidebar: {...}, collections: {...}, globals: {...} }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
5
|
/**
|
|
21
6
|
* Admin config route handlers.
|
|
22
7
|
* Registered via module routes and exposed through the fetch handler.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { introspectBlocks } from "../block/introspection.mjs";
|
|
2
1
|
import { resolveDashboardCallback, resolveSidebarCallback } from "../../../proxy-factories.mjs";
|
|
2
|
+
import { introspectBlocks } from "../block/introspection.mjs";
|
|
3
3
|
import { adminConfigDTOSchema } from "../dto/admin-config.dto.mjs";
|
|
4
4
|
import { getAccessContext, getAdminConfig as getAdminConfig$1, getApp, getAppState, getCollectionState, getGlobalState } from "./route-helpers.mjs";
|
|
5
5
|
import { z } from "zod";
|
|
@@ -21,6 +21,21 @@ import { executeAccessRule, route } from "questpie";
|
|
|
21
21
|
* // { dashboard: {...}, sidebar: {...}, collections: {...}, globals: {...} }
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
|
+
function isPlainRecord(value) {
|
|
25
|
+
if (value === null || typeof value !== "object") return false;
|
|
26
|
+
const proto = Object.getPrototypeOf(value);
|
|
27
|
+
return proto === Object.prototype || proto === null;
|
|
28
|
+
}
|
|
29
|
+
function stripUndefinedDeep(value) {
|
|
30
|
+
if (Array.isArray(value)) return value.filter((item) => item !== void 0).map((item) => stripUndefinedDeep(item));
|
|
31
|
+
if (!isPlainRecord(value)) return value;
|
|
32
|
+
const result = {};
|
|
33
|
+
for (const [key, child] of Object.entries(value)) {
|
|
34
|
+
if (child === void 0) continue;
|
|
35
|
+
result[key] = stripUndefinedDeep(child);
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
24
39
|
/**
|
|
25
40
|
* Check if the current user has read access to a collection or global.
|
|
26
41
|
* Returns true if accessible, false if denied.
|
|
@@ -468,7 +483,7 @@ async function processDashboardItems(items, accessibleCollections, accessCtx) {
|
|
|
468
483
|
if (action.action?.type === "create") return accessibleCollections.has(action.action.collection);
|
|
469
484
|
return true;
|
|
470
485
|
});
|
|
471
|
-
const { loader: loader$1, access:
|
|
486
|
+
const { loader: loader$1, access: _access$1, filterFn: _filterFn$1, ...serializable$1 } = widget;
|
|
472
487
|
if (loader$1) serializable$1.hasLoader = true;
|
|
473
488
|
if (serializable$1.label && !serializable$1.title) serializable$1.title = serializable$1.label;
|
|
474
489
|
result.push({
|
|
@@ -478,7 +493,7 @@ async function processDashboardItems(items, accessibleCollections, accessCtx) {
|
|
|
478
493
|
});
|
|
479
494
|
continue;
|
|
480
495
|
}
|
|
481
|
-
const { loader, access, filterFn, ...serializable } = widget;
|
|
496
|
+
const { loader, access: _access, filterFn: _filterFn, ...serializable } = widget;
|
|
482
497
|
if (loader) serializable.hasLoader = true;
|
|
483
498
|
if (serializable.label && !serializable.title) serializable.title = serializable.label;
|
|
484
499
|
result.push(serializable);
|
|
@@ -497,7 +512,7 @@ const getAdminConfigOutputSchema = adminConfigDTOSchema;
|
|
|
497
512
|
* ```ts title="questpie/server/config/admin.ts"
|
|
498
513
|
* import { adminConfig } from "#questpie/factories";
|
|
499
514
|
*
|
|
500
|
-
* export
|
|
515
|
+
* export const config = adminConfig({
|
|
501
516
|
* dashboard: { items: [] },
|
|
502
517
|
* sidebar: { sections: [], items: [] },
|
|
503
518
|
* });
|
|
@@ -527,6 +542,7 @@ const getAdminConfig = route().post().schema(getAdminConfigSchema).outputSchema(
|
|
|
527
542
|
defaultCollection: uploadCollections.length === 1 ? uploadCollections[0] : void 0
|
|
528
543
|
};
|
|
529
544
|
if (adminCfg.branding) response.branding = adminCfg.branding;
|
|
545
|
+
if (adminCfg.shell) response.shell = adminCfg.shell;
|
|
530
546
|
if (adminCfg.dashboard) {
|
|
531
547
|
let dashboard;
|
|
532
548
|
if (isLegacyDashboardConfig(adminCfg.dashboard)) dashboard = adminCfg.dashboard;
|
|
@@ -555,7 +571,7 @@ const getAdminConfig = route().post().schema(getAdminConfigSchema).outputSchema(
|
|
|
555
571
|
if (appState.blocks && Object.keys(appState.blocks).length > 0) response.blocks = introspectBlocks(appState.blocks);
|
|
556
572
|
response.collections = filteredCollectionsMeta;
|
|
557
573
|
response.globals = filteredGlobalsMeta;
|
|
558
|
-
return response;
|
|
574
|
+
return stripUndefinedDeep(response);
|
|
559
575
|
});
|
|
560
576
|
/**
|
|
561
577
|
* Admin config route handlers.
|
|
@@ -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 questpie123 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: questpie123.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, questpie123.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: questpie123.JsonRouteDefinition<{
|
|
72
72
|
collection: string;
|
|
73
|
-
}, any,
|
|
73
|
+
}, any, questpie123.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: questpie123.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, questpie123.JsonRouteParams>;
|
|
87
|
+
getActionsConfig: questpie123.JsonRouteDefinition<{
|
|
88
88
|
collection: string;
|
|
89
|
-
}, any,
|
|
89
|
+
}, any, questpie123.JsonRouteParams>;
|
|
90
90
|
};
|
|
91
91
|
//#endregion
|
|
92
92
|
export { ExecuteActionRequest, ExecuteActionResponse, actionFunctions, executeAction, executeActionFn, getActionsConfig, getActionsConfigFn };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { getApp,
|
|
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
4
|
import { route } from "questpie";
|
|
@@ -26,7 +26,7 @@ import { route } from "questpie";
|
|
|
26
26
|
* Returns action definitions without handlers (for client-side rendering).
|
|
27
27
|
*/
|
|
28
28
|
function getActionsConfig(app, collectionSlug) {
|
|
29
|
-
const collection$1 =
|
|
29
|
+
const collection$1 = getCollection(app, collectionSlug);
|
|
30
30
|
if (!collection$1) return null;
|
|
31
31
|
const actionsConfig = (collection$1.state || collection$1).adminActions;
|
|
32
32
|
if (!actionsConfig) return {
|
|
@@ -98,7 +98,7 @@ function serializeActionFormFields(fields) {
|
|
|
98
98
|
*/
|
|
99
99
|
async function executeAction(app, request, session) {
|
|
100
100
|
const { collection: collectionSlug, actionId, itemId, itemIds, data, locale } = request;
|
|
101
|
-
const collection$1 =
|
|
101
|
+
const collection$1 = getCollection(app, collectionSlug);
|
|
102
102
|
const t = (key, params) => translateAdminMessage(locale, key, params);
|
|
103
103
|
if (!collection$1) return {
|
|
104
104
|
success: false,
|
|
@@ -148,8 +148,8 @@ async function executeAction(app, request, session) {
|
|
|
148
148
|
itemId,
|
|
149
149
|
itemIds,
|
|
150
150
|
auth: appRec.auth,
|
|
151
|
-
collections:
|
|
152
|
-
globals:
|
|
151
|
+
collections: getCollectionCruds(app),
|
|
152
|
+
globals: getGlobalCruds(app),
|
|
153
153
|
db: appRec.db,
|
|
154
154
|
session,
|
|
155
155
|
locale
|
|
@@ -177,7 +177,7 @@ async function executeBuiltinAction(app, params) {
|
|
|
177
177
|
const { collectionSlug, actionId, itemId, itemIds, data, locale } = params;
|
|
178
178
|
const t = (key, messageParams) => translateAdminMessage(locale, key, messageParams);
|
|
179
179
|
const appRec = app;
|
|
180
|
-
const collectionCrud =
|
|
180
|
+
const collectionCrud = getCollectionCrud(app, collectionSlug);
|
|
181
181
|
const crudContext = {
|
|
182
182
|
db: appRec.db,
|
|
183
183
|
session: params.session,
|
|
@@ -186,7 +186,7 @@ async function executeBuiltinAction(app, params) {
|
|
|
186
186
|
try {
|
|
187
187
|
switch (actionId) {
|
|
188
188
|
case "create": {
|
|
189
|
-
const result = await appRec.create(collectionSlug, data || {});
|
|
189
|
+
const result = collectionCrud?.create ? await collectionCrud.create(data || {}, crudContext) : await appRec.create(collectionSlug, data || {});
|
|
190
190
|
return {
|
|
191
191
|
success: true,
|
|
192
192
|
result: {
|
|
@@ -207,7 +207,11 @@ async function executeBuiltinAction(app, params) {
|
|
|
207
207
|
toast: { message: t("action.itemIdRequired.save") }
|
|
208
208
|
}
|
|
209
209
|
};
|
|
210
|
-
await
|
|
210
|
+
if (collectionCrud?.updateById) await collectionCrud.updateById({
|
|
211
|
+
id: itemId,
|
|
212
|
+
data: data || {}
|
|
213
|
+
}, crudContext);
|
|
214
|
+
else await appRec.update(collectionSlug, itemId, data || {});
|
|
211
215
|
return {
|
|
212
216
|
success: true,
|
|
213
217
|
result: {
|
|
@@ -224,7 +228,8 @@ async function executeBuiltinAction(app, params) {
|
|
|
224
228
|
toast: { message: t("action.itemIdRequired.delete") }
|
|
225
229
|
}
|
|
226
230
|
};
|
|
227
|
-
await
|
|
231
|
+
if (collectionCrud?.deleteById) await collectionCrud.deleteById({ id: itemId }, crudContext);
|
|
232
|
+
else await appRec.delete(collectionSlug, itemId);
|
|
228
233
|
return {
|
|
229
234
|
success: true,
|
|
230
235
|
result: {
|
|
@@ -244,7 +249,8 @@ async function executeBuiltinAction(app, params) {
|
|
|
244
249
|
toast: { message: t("action.itemIdsRequired.bulkDelete") }
|
|
245
250
|
}
|
|
246
251
|
};
|
|
247
|
-
await Promise.all(itemIds.map((id) =>
|
|
252
|
+
if (collectionCrud?.deleteById) await Promise.all(itemIds.map((id) => collectionCrud.deleteById({ id }, crudContext)));
|
|
253
|
+
else await Promise.all(itemIds.map((id) => appRec.delete(collectionSlug, id)));
|
|
248
254
|
return {
|
|
249
255
|
success: true,
|
|
250
256
|
result: {
|
|
@@ -314,7 +320,7 @@ async function executeBuiltinAction(app, params) {
|
|
|
314
320
|
toast: { message: t("action.itemIdRequired.duplicate") }
|
|
315
321
|
}
|
|
316
322
|
};
|
|
317
|
-
const original = await appRec.findById(collectionSlug, itemId);
|
|
323
|
+
const original = collectionCrud?.findOne ? await collectionCrud.findOne({ where: { id: itemId } }, crudContext) : await appRec.findById(collectionSlug, itemId);
|
|
318
324
|
if (!original) return {
|
|
319
325
|
success: false,
|
|
320
326
|
result: {
|
|
@@ -323,7 +329,7 @@ async function executeBuiltinAction(app, params) {
|
|
|
323
329
|
}
|
|
324
330
|
};
|
|
325
331
|
const { id, createdAt, updatedAt, ...duplicateData } = original;
|
|
326
|
-
const duplicated = await appRec.create(collectionSlug, duplicateData);
|
|
332
|
+
const duplicated = collectionCrud?.create ? await collectionCrud.create(duplicateData, crudContext) : await appRec.create(collectionSlug, duplicateData);
|
|
327
333
|
return {
|
|
328
334
|
success: true,
|
|
329
335
|
result: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie113 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: questpie113.JsonRouteDefinition<{
|
|
29
29
|
path: string;
|
|
30
30
|
ttlMs?: number | undefined;
|
|
31
|
-
}, any,
|
|
32
|
-
verifyPreviewToken:
|
|
31
|
+
}, any, questpie113.JsonRouteParams>;
|
|
32
|
+
verifyPreviewToken: questpie113.JsonRouteDefinition<{
|
|
33
33
|
token: string;
|
|
34
|
-
}, any,
|
|
34
|
+
}, any, questpie113.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: questpie113.JsonRouteDefinition<{
|
|
72
72
|
collection: string;
|
|
73
73
|
record: Record<string, unknown>;
|
|
74
74
|
locale?: string | undefined;
|
|
75
|
-
}, any,
|
|
76
|
-
mintPreviewToken:
|
|
75
|
+
}, any, questpie113.JsonRouteParams>;
|
|
76
|
+
mintPreviewToken: questpie113.JsonRouteDefinition<{
|
|
77
77
|
path: string;
|
|
78
78
|
ttlMs?: number | undefined;
|
|
79
|
-
}, any,
|
|
80
|
-
verifyPreviewToken:
|
|
79
|
+
}, any, questpie113.JsonRouteParams>;
|
|
80
|
+
verifyPreviewToken: questpie113.JsonRouteDefinition<{
|
|
81
81
|
token: string;
|
|
82
|
-
}, any,
|
|
82
|
+
}, any, questpie113.JsonRouteParams>;
|
|
83
83
|
};
|
|
84
84
|
//#endregion
|
|
85
85
|
export { PreviewTokenPayload, createPreviewFunctions, createPreviewTokenVerifier, previewFunctions, verifyPreviewTokenDirect };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as
|
|
1
|
+
import * as questpie131 from "questpie";
|
|
2
2
|
|
|
3
3
|
//#region src/server/modules/admin/routes/reactive.d.ts
|
|
4
4
|
|
|
@@ -13,7 +13,7 @@ import * as questpie113 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: questpie131.JsonRouteDefinition<{
|
|
17
17
|
collection: string;
|
|
18
18
|
type: "collection" | "global";
|
|
19
19
|
requests: {
|
|
@@ -27,12 +27,12 @@ declare const batchReactive: questpie113.JsonRouteDefinition<{
|
|
|
27
27
|
}[];
|
|
28
28
|
formData?: Record<string, unknown> | undefined;
|
|
29
29
|
prevData?: Record<string, unknown> | null | undefined;
|
|
30
|
-
}, any,
|
|
30
|
+
}, any, questpie131.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: questpie131.JsonRouteDefinition<{
|
|
36
36
|
collection: string;
|
|
37
37
|
type: "collection" | "global";
|
|
38
38
|
field: string;
|
|
@@ -41,12 +41,12 @@ declare const fieldOptions: questpie113.JsonRouteDefinition<{
|
|
|
41
41
|
page: number;
|
|
42
42
|
limit: number;
|
|
43
43
|
siblingData?: Record<string, unknown> | null | undefined;
|
|
44
|
-
}, any,
|
|
44
|
+
}, any, questpie131.JsonRouteParams>;
|
|
45
45
|
/**
|
|
46
46
|
* Reactive functions bundle.
|
|
47
47
|
*/
|
|
48
48
|
declare const reactiveFunctions: {
|
|
49
|
-
readonly batchReactive:
|
|
49
|
+
readonly batchReactive: questpie131.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, questpie131.JsonRouteParams>;
|
|
64
|
+
readonly fieldOptions: questpie131.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, questpie131.JsonRouteParams>;
|
|
74
74
|
};
|
|
75
75
|
//#endregion
|
|
76
76
|
export { batchReactive, fieldOptions, reactiveFunctions };
|
|
@@ -60,6 +60,41 @@ function getAdminConfig(app) {
|
|
|
60
60
|
return getAppState(app).config?.admin || {};
|
|
61
61
|
}
|
|
62
62
|
/**
|
|
63
|
+
* Get registered collection definitions from the current or legacy app shape.
|
|
64
|
+
*/
|
|
65
|
+
function getCollections(app) {
|
|
66
|
+
const appRec = app;
|
|
67
|
+
if (typeof appRec.getCollections === "function") return appRec.getCollections();
|
|
68
|
+
return getAppState(app).collections ?? {};
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Get a registered collection definition by slug.
|
|
72
|
+
*/
|
|
73
|
+
function getCollection(app, collectionSlug) {
|
|
74
|
+
return getCollections(app)[collectionSlug];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Get collection CRUD APIs from the current or legacy app shape.
|
|
78
|
+
*/
|
|
79
|
+
function getCollectionCrud(app, collectionSlug) {
|
|
80
|
+
const appRec = app;
|
|
81
|
+
return appRec.collections?.[collectionSlug] ?? appRec.api?.collections?.[collectionSlug] ?? appRec._api?.collections?.[collectionSlug];
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Get all collection CRUD APIs from the current or legacy app shape.
|
|
85
|
+
*/
|
|
86
|
+
function getCollectionCruds(app) {
|
|
87
|
+
const appRec = app;
|
|
88
|
+
return appRec.collections ?? appRec.api?.collections ?? appRec._api?.collections;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Get all global CRUD APIs from the current or legacy app shape.
|
|
92
|
+
*/
|
|
93
|
+
function getGlobalCruds(app) {
|
|
94
|
+
const appRec = app;
|
|
95
|
+
return appRec.globals ?? appRec.api?.globals ?? appRec._api?.globals;
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
63
98
|
* Build a ReactiveServerContext from route handler context.
|
|
64
99
|
*/
|
|
65
100
|
function buildServerContext(ctx) {
|
|
@@ -73,4 +108,4 @@ function buildServerContext(ctx) {
|
|
|
73
108
|
}
|
|
74
109
|
|
|
75
110
|
//#endregion
|
|
76
|
-
export { buildServerContext, getAccessContext, getAdminConfig, getApp, getAppState, getCollectionState, getGlobalState, getLocale, getSession };
|
|
111
|
+
export { buildServerContext, getAccessContext, getAdminConfig, getApp, getAppState, getCollection, getCollectionCrud, getCollectionCruds, getCollectionState, getGlobalCruds, getGlobalState, getLocale, getSession };
|