From 18f4cf5b3abe66ce46e75a5a8ff67a849b896c96 Mon Sep 17 00:00:00 2001 From: Roman Malenko Date: Wed, 9 Sep 2026 17:27:07 +0300 Subject: [PATCH] fix: use core's column access helpers and require adminforth 3.18 --- package.json | 4 ++-- services/widgetDataService.ts | 26 +++++--------------------- 2 files changed, 7 insertions(+), 23 deletions(-) diff --git a/package.json b/package.json index f2099ca..1eb0b48 100644 --- a/package.json +++ b/package.json @@ -25,14 +25,14 @@ "description": "Dashboard plugin for AdminForth", "devDependencies": { "@types/node": "latest", - "adminforth": "^3.8.2", + "adminforth": "^3.18.0", "semantic-release": "^24.2.1", "semantic-release-slack-bot": "^4.0.2", "typescript": "^5.7.3", "vue-tsc": "^3.3.2" }, "peerDependencies": { - "adminforth": "^3.8.2" + "adminforth": "^3.18.0" }, "release": { "plugins": [ diff --git a/services/widgetDataService.ts b/services/widgetDataService.ts index 3b43b78..3732f83 100644 --- a/services/widgetDataService.ts +++ b/services/widgetDataService.ts @@ -1,4 +1,4 @@ -import { ActionCheckSource, interpretResource, Sorts } from 'adminforth'; +import { ActionCheckSource, interpretResource, isBackendOnly, isShown, Sorts, stripBackendOnly } from 'adminforth'; import type { AdminUser, IAdminForth, @@ -167,27 +167,15 @@ class ResourceDataAccess { const context = { adminUser: this.adminUser, resource, - meta: {}, + meta: { requestBody: query, pk: undefined }, source: ActionCheckSource.ListRequest, adminforth: this.adminforth, }; - const columns = new Map(resource.columns.map((column) => [column.name, column])); // OperationalResource.list() deliberately returns the connector response as-is. // Apply the same response masking as AdminForth's list REST endpoint before hooks run. for (const row of rows) { - for (const key of Object.keys(row)) { - const column = columns.get(key); - const backendOnly = column - ? typeof column.backendOnly === 'function' - ? await column.backendOnly(context) - : Boolean(column.backendOnly) - : true; - - if (!column || backendOnly) { - delete row[key]; - } - } + await stripBackendOnly(row, context); } const afterDatasourceResponse = resource.hooks?.list?.afterDatasourceResponse; @@ -388,12 +376,8 @@ async function assertWidgetQueryHasNoBackendOnlyFields( source: ActionCheckSource.ListRequest, adminforth, }; - const backendOnly = typeof column.backendOnly === 'function' - ? await column.backendOnly(context) - : column.backendOnly; - const shownInList = typeof column.showIn?.list === 'function' - ? await column.showIn.list(context) - : column.showIn?.list !== false; + const backendOnly = await isBackendOnly(column, context); + const shownInList = await isShown(column, 'list', context); if (backendOnly || !shownInList) { const restriction = backendOnly ? 'backendOnly' : 'hidden in list view';