@terreno/admin-backend 57.0.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.
- package/README.md +3 -0
- package/dist/adminApp.d.ts +25 -4
- package/dist/adminApp.js +1195 -269
- package/dist/adminConfigIdentity.d.ts +16 -0
- package/dist/adminConfigIdentity.js +100 -0
- package/dist/adminTextSearch.d.ts +17 -0
- package/dist/adminTextSearch.js +117 -0
- package/dist/adminUiV2.js +1 -1
- package/dist/aggregateAdmin.d.ts +20 -0
- package/dist/aggregateAdmin.js +276 -0
- package/dist/documentStorageApp.d.ts +3 -1
- package/dist/documentStorageApp.js +20 -42
- package/dist/filterParser.d.ts +11 -0
- package/dist/filterParser.js +260 -0
- package/dist/index.d.ts +10 -1
- package/dist/index.js +16 -1
- package/dist/legacy.d.ts +9 -0
- package/dist/legacy.js +61 -0
- package/dist/resolvedAdminModel.d.ts +23 -0
- package/dist/resolvedAdminModel.js +131 -0
- package/dist/routePath.d.ts +2 -0
- package/dist/routePath.js +18 -0
- package/package.json +5 -4
- package/src/adminApp.models.test.ts +1321 -1
- package/src/adminApp.test.ts +35 -1
- package/src/adminApp.ts +873 -102
- package/src/adminConfigIdentity.test.ts +56 -0
- package/src/adminConfigIdentity.ts +87 -0
- package/src/adminTextSearch.test.ts +73 -0
- package/src/adminTextSearch.ts +74 -0
- package/src/adminUiV2.test.ts +1 -0
- package/src/adminUiV2.ts +1 -1
- package/src/aggregateAdmin.test.ts +220 -0
- package/src/aggregateAdmin.ts +207 -0
- package/src/documentStorageApp.test.ts +11 -0
- package/src/documentStorageApp.ts +20 -39
- package/src/filterParser.test.ts +68 -0
- package/src/filterParser.ts +229 -0
- package/src/index.ts +36 -1
- package/src/legacy.test.ts +34 -0
- package/src/legacy.ts +63 -0
- package/src/resolvedAdminModel.ts +115 -0
- package/src/routePath.ts +14 -0
package/README.md
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# @terreno/admin-backend
|
|
2
2
|
|
|
3
|
+
See [Add a model to the admin](../docs/how-to/admin-add-model.md) for the recommended
|
|
4
|
+
`modelRouter({admin: ...})` setup.
|
|
5
|
+
|
|
3
6
|
Admin panel backend plugin for `@terreno/api` that auto-generates admin CRUD endpoints and metadata for Mongoose models.
|
|
4
7
|
|
|
5
8
|
## Install
|
package/dist/adminApp.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type PopulatePath, type ScriptArgDef, type ScriptRunner, 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,13 +114,17 @@ 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.
|
|
113
124
|
*/
|
|
114
125
|
export interface AdminOptions {
|
|
115
|
-
/**
|
|
116
|
-
models
|
|
126
|
+
/** Legacy model configurations (deprecated — prefer modelRouter `admin:` or plugin contributions). */
|
|
127
|
+
models?: AdminModelConfig[];
|
|
117
128
|
/** Array of scripts that can be run from the admin panel */
|
|
118
129
|
scripts?: AdminScriptConfig[];
|
|
119
130
|
/** Base path for all admin routes. Defaults to "/admin". */
|
|
@@ -127,6 +138,9 @@ export interface AdminOptions {
|
|
|
127
138
|
* Consumers typically persist to an `AdminAuditLog` collection.
|
|
128
139
|
*/
|
|
129
140
|
onAdminAudit?: (event: AdminAuditEvent, req: express.Request) => void | Promise<void>;
|
|
141
|
+
/** When set, admin shell entry requires `admin:access`; model CRUD also requires
|
|
142
|
+
* resource/action permissions (for example `user:update`) from the same Access instance. */
|
|
143
|
+
accessControl?: AnyTerrenoAccess;
|
|
130
144
|
}
|
|
131
145
|
export declare const getArrayEmbeddedSchemaType: (schemaPath: mongoose.SchemaType) => mongoose.SchemaType | undefined;
|
|
132
146
|
/**
|
|
@@ -179,6 +193,13 @@ export declare class AdminApp {
|
|
|
179
193
|
* @param options - Admin panel configuration including models and base path
|
|
180
194
|
*/
|
|
181
195
|
constructor(options: AdminOptions);
|
|
196
|
+
private adminAccessPermissions;
|
|
197
|
+
private hasScriptPermission;
|
|
198
|
+
private hasConfigurationPermission;
|
|
199
|
+
private canAnyResourceAction;
|
|
200
|
+
private adminResource;
|
|
201
|
+
private isAdminModelOwned;
|
|
202
|
+
private resourceActionPermissions;
|
|
182
203
|
/**
|
|
183
204
|
* Register admin routes with the Express application.
|
|
184
205
|
*
|
|
@@ -195,6 +216,6 @@ export declare class AdminApp {
|
|
|
195
216
|
*
|
|
196
217
|
* @param app - The Express application instance to register with
|
|
197
218
|
*/
|
|
198
|
-
register(app: express.Application, openApi?: unknown): void;
|
|
219
|
+
register(app: express.Application, openApi?: unknown, terrenoApp?: TerrenoApp): void;
|
|
199
220
|
private mountScriptRoutes;
|
|
200
221
|
}
|