@terreno/admin-backend 57.1.0 → 57.2.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.
@@ -1,4 +1,4 @@
1
- import { type AnyTerrenoAccess, type PopulatePath, type ScriptArgDef, type ScriptRunner, type TerrenoApp, type User } from "@terreno/api";
1
+ import { type AdminAccessConfig, type AnyTerrenoAccess, type PopulatePath, type ScriptArgDef, type ScriptRunner, type TerrenoApp, type User } from "@terreno/api";
2
2
  import express from "express";
3
3
  import type { Model } from "mongoose";
4
4
  import mongoose from "mongoose";
@@ -10,6 +10,11 @@ export interface AdminFieldOverride {
10
10
  /** Widget to use for this field in the admin form (e.g., "markdown") */
11
11
  widget?: string;
12
12
  }
13
+ /**
14
+ * Builds an ownership check for writeOwned admin access. The field may contain an id
15
+ * directly or a populated document with `_id`.
16
+ */
17
+ export declare const adminOwnedBy: (field: string) => NonNullable<AdminAccessConfig["isOwned"]>;
13
18
  export interface AdminModelConfig {
14
19
  /** The Mongoose model to expose in the admin panel */
15
20
  model: Model<any>;
@@ -53,6 +58,8 @@ export interface AdminModelConfig {
53
58
  populatePaths?: PopulatePath[];
54
59
  /** UI-only hint that live updates may be available */
55
60
  realtime?: boolean;
61
+ /** Fine-grained admin RBAC and optional ownership/custom authorization. */
62
+ adminAccess?: AdminAccessConfig;
56
63
  /**
57
64
  * Field key used for the edit screen title (browser tab / stack header). When omitted, the
58
65
  * admin UI derives a label from common keys (`name`, `title`, …) then the first scalar
@@ -107,6 +114,10 @@ export interface AdminCustomScreenConfig {
107
114
  name: string;
108
115
  /** Optional subtitle or help text shown with the screen card in the admin UI */
109
116
  description?: string;
117
+ /** RBAC or custom authorization for exposing this screen in admin metadata/navigation. */
118
+ adminAccess?: Pick<AdminAccessConfig, "authorize" | "resource"> & {
119
+ action?: string;
120
+ };
110
121
  }
111
122
  /**
112
123
  * Configuration options for the AdminApp plugin.
@@ -185,6 +196,9 @@ export declare class AdminApp {
185
196
  private adminAccessPermissions;
186
197
  private hasScriptPermission;
187
198
  private hasConfigurationPermission;
199
+ private canAnyResourceAction;
200
+ private adminResource;
201
+ private isAdminModelOwned;
188
202
  private resourceActionPermissions;
189
203
  /**
190
204
  * Register admin routes with the Express application.