@terreno/admin-backend 57.1.0 → 57.3.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/.ai/guidelines/core.md +12 -4
- package/.claude/CLAUDE.local.md +17 -2
- package/.cursor/rules/00-root.mdc +17 -2
- package/.github/copilot-instructions.md +17 -2
- package/AGENTS.md +17 -2
- package/README.md +3 -1
- package/dist/adminApp.d.ts +15 -1
- package/dist/adminApp.js +406 -175
- package/dist/aggregateAdmin.js +5 -1
- package/dist/documentStorageApp.js +1 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +2 -1
- package/dist/resolvedAdminModel.js +1 -0
- package/package.json +5 -5
- package/src/adminApp.models.test.ts +429 -4
- package/src/adminApp.ts +285 -121
- package/src/adminUiV2.test.ts +71 -1
- package/src/aggregateAdmin.ts +6 -4
- package/src/documentStorageApp.ts +1 -3
- package/src/index.ts +1 -1
- package/src/resolvedAdminModel.ts +1 -0
package/.ai/guidelines/core.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
## Admin
|
|
1
|
+
## Admin panel backend
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
Read the architecture first:
|
|
4
|
+
|
|
5
|
+
- `docs/explanation/admin-interface.md`
|
|
6
|
+
- `docs/how-to/admin-add-model.md`
|
|
7
|
+
- `docs/how-to/build-admin-screens.md`
|
|
8
|
+
|
|
9
|
+
Put `admin` on `modelRouter`. Use plugin `adminContribution()` for plugin-owned
|
|
10
|
+
models and screens. `AdminApp.customScreens` `name` must match the frontend widget
|
|
11
|
+
key. `admin:access` opens `/admin/config`; model CRUD is not a substitute.
|
|
12
|
+
|
|
13
|
+
Agent workflow: skill `building-admin-interfaces`.
|
package/.claude/CLAUDE.local.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Terreno
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Terreno is Django/Rails for TypeScript — with universal app support.
|
|
4
|
+
|
|
5
|
+
Terreno is Django/Rails for TypeScript — a batteries-included, full-stack
|
|
6
|
+
framework where the undifferentiated 80% of an app is already written. On the
|
|
7
|
+
backend you get Mongoose models, auto-generated REST APIs, permissions, an admin
|
|
8
|
+
panel, authentication, and an AI service. On the frontend you get one universal
|
|
9
|
+
app — a single React Native codebase that ships to iOS, Android, and web. It is
|
|
10
|
+
built to be driven by AI coding agents from the first prompt to a production
|
|
11
|
+
deploy.
|
|
12
|
+
|
|
13
|
+
- Batteries included — auth, CRUD APIs, admin, permissions, AI, realtime,
|
|
14
|
+
feature flags, and consent are already built, so your code is business logic.
|
|
15
|
+
- Universal by default — one React Native codebase ships to iOS, Android, and
|
|
16
|
+
web. Not a web framework with a mobile bolt-on.
|
|
17
|
+
- AI-native — agents are a first-class client of the framework, not an
|
|
18
|
+
afterthought.
|
|
4
19
|
|
|
5
20
|
## Packages
|
|
6
21
|
|
|
@@ -151,7 +166,7 @@ import {
|
|
|
151
166
|
|
|
152
167
|
### @terreno/ui
|
|
153
168
|
|
|
154
|
-
React Native component library
|
|
169
|
+
React Native UI component library (a large component library):
|
|
155
170
|
|
|
156
171
|
- **Layout**: Box, Page, SplitPage, Card
|
|
157
172
|
- **Forms**: TextField, SelectField, DateTimeField, CheckBox
|
|
@@ -5,7 +5,22 @@ globs: **/*
|
|
|
5
5
|
|
|
6
6
|
# Terreno
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Terreno is Django/Rails for TypeScript — with universal app support.
|
|
9
|
+
|
|
10
|
+
Terreno is Django/Rails for TypeScript — a batteries-included, full-stack
|
|
11
|
+
framework where the undifferentiated 80% of an app is already written. On the
|
|
12
|
+
backend you get Mongoose models, auto-generated REST APIs, permissions, an admin
|
|
13
|
+
panel, authentication, and an AI service. On the frontend you get one universal
|
|
14
|
+
app — a single React Native codebase that ships to iOS, Android, and web. It is
|
|
15
|
+
built to be driven by AI coding agents from the first prompt to a production
|
|
16
|
+
deploy.
|
|
17
|
+
|
|
18
|
+
- Batteries included — auth, CRUD APIs, admin, permissions, AI, realtime,
|
|
19
|
+
feature flags, and consent are already built, so your code is business logic.
|
|
20
|
+
- Universal by default — one React Native codebase ships to iOS, Android, and
|
|
21
|
+
web. Not a web framework with a mobile bolt-on.
|
|
22
|
+
- AI-native — agents are a first-class client of the framework, not an
|
|
23
|
+
afterthought.
|
|
9
24
|
|
|
10
25
|
## Packages
|
|
11
26
|
|
|
@@ -206,7 +221,7 @@ router.get("/yourRoute/:id", [
|
|
|
206
221
|
|
|
207
222
|
### @terreno/ui
|
|
208
223
|
|
|
209
|
-
React Native component library
|
|
224
|
+
React Native UI component library (a large component library):
|
|
210
225
|
|
|
211
226
|
- **Layout**: Box, Page, SplitPage, Card
|
|
212
227
|
- **Forms**: TextField, SelectField, DateTimeField, CheckBox
|
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Terreno
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Terreno is Django/Rails for TypeScript — with universal app support.
|
|
4
|
+
|
|
5
|
+
Terreno is Django/Rails for TypeScript — a batteries-included, full-stack
|
|
6
|
+
framework where the undifferentiated 80% of an app is already written. On the
|
|
7
|
+
backend you get Mongoose models, auto-generated REST APIs, permissions, an admin
|
|
8
|
+
panel, authentication, and an AI service. On the frontend you get one universal
|
|
9
|
+
app — a single React Native codebase that ships to iOS, Android, and web. It is
|
|
10
|
+
built to be driven by AI coding agents from the first prompt to a production
|
|
11
|
+
deploy.
|
|
12
|
+
|
|
13
|
+
- Batteries included — auth, CRUD APIs, admin, permissions, AI, realtime,
|
|
14
|
+
feature flags, and consent are already built, so your code is business logic.
|
|
15
|
+
- Universal by default — one React Native codebase ships to iOS, Android, and
|
|
16
|
+
web. Not a web framework with a mobile bolt-on.
|
|
17
|
+
- AI-native — agents are a first-class client of the framework, not an
|
|
18
|
+
afterthought.
|
|
4
19
|
|
|
5
20
|
## Packages
|
|
6
21
|
|
|
@@ -201,7 +216,7 @@ router.get("/yourRoute/:id", [
|
|
|
201
216
|
|
|
202
217
|
### @terreno/ui
|
|
203
218
|
|
|
204
|
-
React Native component library
|
|
219
|
+
React Native UI component library (a large component library):
|
|
205
220
|
|
|
206
221
|
- **Layout**: Box, Page, SplitPage, Card
|
|
207
222
|
- **Forms**: TextField, SelectField, DateTimeField, CheckBox
|
package/AGENTS.md
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
# Terreno
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Terreno is Django/Rails for TypeScript — with universal app support.
|
|
4
|
+
|
|
5
|
+
Terreno is Django/Rails for TypeScript — a batteries-included, full-stack
|
|
6
|
+
framework where the undifferentiated 80% of an app is already written. On the
|
|
7
|
+
backend you get Mongoose models, auto-generated REST APIs, permissions, an admin
|
|
8
|
+
panel, authentication, and an AI service. On the frontend you get one universal
|
|
9
|
+
app — a single React Native codebase that ships to iOS, Android, and web. It is
|
|
10
|
+
built to be driven by AI coding agents from the first prompt to a production
|
|
11
|
+
deploy.
|
|
12
|
+
|
|
13
|
+
- Batteries included — auth, CRUD APIs, admin, permissions, AI, realtime,
|
|
14
|
+
feature flags, and consent are already built, so your code is business logic.
|
|
15
|
+
- Universal by default — one React Native codebase ships to iOS, Android, and
|
|
16
|
+
web. Not a web framework with a mobile bolt-on.
|
|
17
|
+
- AI-native — agents are a first-class client of the framework, not an
|
|
18
|
+
afterthought.
|
|
4
19
|
|
|
5
20
|
## Packages
|
|
6
21
|
|
|
@@ -201,7 +216,7 @@ router.get("/yourRoute/:id", [
|
|
|
201
216
|
|
|
202
217
|
### @terreno/ui
|
|
203
218
|
|
|
204
|
-
React Native component library
|
|
219
|
+
React Native UI component library (a large component library):
|
|
205
220
|
|
|
206
221
|
- **Layout**: Box, Page, SplitPage, Card
|
|
207
222
|
- **Forms**: TextField, SelectField, DateTimeField, CheckBox
|
package/README.md
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
# @terreno/admin-backend
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Admin panel backend plugin for @terreno/api.
|
|
4
|
+
|
|
5
|
+
See [Add a model to the admin](https://github.com/flourishhealth/terreno/blob/master/docs/how-to/admin-add-model.md) for the recommended
|
|
4
6
|
`modelRouter({admin: ...})` setup.
|
|
5
7
|
|
|
6
8
|
Admin panel backend plugin for `@terreno/api` that auto-generates admin CRUD endpoints and metadata for Mongoose models.
|
package/dist/adminApp.d.ts
CHANGED
|
@@ -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.
|