@@ -23,7 +23,7 @@ import { afLogger } from "./logger.js";
2323import { ADMINFORTH_VERSION , listify , md5hash , getLoginPromptHTML , hookResponseError } from './utils.js' ;
2424
2525import AdminForthAuth from "../auth.js" ;
26- import { ActionCheckSource , AdminForthConfigMenuItem , AdminForthDataTypes , AdminForthFilterOperators , AdminForthResourceColumnInputCommon , AdminForthResourceCommon , AdminForthResourcePages ,
26+ import { ActionCheckSource , AdminForthConfigMenuItem , AdminForthDataTypes , AdminForthFilterOperators , AdminForthResourceColumnInputCommon , AdminForthResourceFrontend , AdminForthResourcePages ,
2727 AdminForthSortDirections ,
2828 AdminUser , AllowedActionsEnum , AllowedActionsResolved ,
2929 AnnouncementBadgeResponse ,
@@ -78,6 +78,11 @@ async function isFilledOnCreate( col: AdminForthResource['columns'][number] ):
7878 return fillOnCreate ;
7979}
8080
81+ function stripResourceColumnFrontendMeta ( column : Record < string , any > ) {
82+ const { default : _default , _baseTypeDebug, ...sanitizedColumn } = column ;
83+ return sanitizedColumn ;
84+ }
85+
8186const SIMPLE_FILTER_OPERATORS = Object . values ( AdminForthFilterOperators ) . filter ( ( operator ) => {
8287 return operator !== AdminForthFilterOperators . AND && operator !== AdminForthFilterOperators . OR ;
8388} ) ;
@@ -1045,7 +1050,7 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
10451050 description : 'Returns the definition of a single resource. The response includes translated labels, column metadata, allowed actions, visible bulk actions, frontend action metadata, and resource options after permission checks and removal of backend-only internals.' ,
10461051 request_schema : getResourceRequestSchema ,
10471052 response_schema : getResourceResponseSchema ,
1048- handler : async ( { body, adminUser, tr } ) : Promise < { resource ?: AdminForthResourceCommon , error ?: string } > => {
1053+ handler : async ( { body, adminUser, tr } ) : Promise < { resource ?: AdminForthResourceFrontend , error ?: string } > => {
10491054 const { resourceId } = body ;
10501055 if ( ! this . adminforth . statuses . dbDiscover ) {
10511056 return { error : 'Database discovery not started' } ;
@@ -1106,13 +1111,13 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
11061111
11071112
11081113 const toReturn = {
1109- ... resource ,
1114+ resourceId : resource . resourceId ,
11101115 label : translated . resLabel ,
11111116 columns :
11121117 await Promise . all (
11131118 resource . columns . map (
11141119 async ( inCol , i ) => {
1115- const col = JSON . parse ( JSON . stringify ( inCol ) ) ;
1120+ const col = JSON . parse ( JSON . stringify ( stripResourceColumnFrontendMeta ( inCol ) ) ) ;
11161121 let validation = null ;
11171122 if ( col . validation ) {
11181123 validation = await Promise . all (
@@ -1188,14 +1193,13 @@ export default class AdminForthRestAPI implements IAdminForthRestAPI {
11881193 ) ,
11891194 actions : resource . options . actions ?. map ( ( action ) => ( {
11901195 ...action ,
1196+ id : action . id ! ,
11911197 hasBulkHandler : ! ! action . bulkHandler ,
11921198 bulkHandler : undefined ,
11931199 } ) ) ,
11941200 allowedActions,
11951201 }
11961202 }
1197- delete toReturn . hooks ;
1198- delete toReturn . plugins ;
11991203
12001204 return {
12011205 resource : toReturn ,
0 commit comments