@terreno/admin-backend 57.2.0 → 57.4.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.
Files changed (53) hide show
  1. package/.ai/guidelines/core.md +12 -4
  2. package/.claude/CLAUDE.local.md +17 -2
  3. package/.cursor/rules/00-root.mdc +17 -2
  4. package/.github/copilot-instructions.md +17 -2
  5. package/AGENTS.md +17 -2
  6. package/README.md +3 -1
  7. package/bunfig.toml +9 -1
  8. package/dist/adminApp.d.ts +20 -2
  9. package/dist/adminApp.js +480 -474
  10. package/dist/adminConfigIdentity.d.ts +1 -0
  11. package/dist/adminConfigIdentity.js +1 -0
  12. package/dist/adminMigrations.d.ts +10 -0
  13. package/dist/adminMigrations.js +205 -0
  14. package/dist/adminScriptJob.d.ts +32 -0
  15. package/dist/adminScriptJob.js +360 -0
  16. package/dist/adminTextSearch.d.ts +1 -0
  17. package/dist/adminTextSearch.js +1 -0
  18. package/dist/adminUiV2.d.ts +2 -0
  19. package/dist/aggregateAdmin.js +6 -1
  20. package/dist/documentStorageApp.js +1 -4
  21. package/dist/enrichAdminListFilters.d.ts +7 -0
  22. package/dist/enrichAdminListFilters.js +37 -0
  23. package/dist/filterParser.js +139 -12
  24. package/dist/index.d.ts +2 -0
  25. package/dist/index.js +4 -1
  26. package/dist/legacy.js +4 -2
  27. package/dist/resolvedAdminModel.js +2 -1
  28. package/package.json +8 -8
  29. package/src/adminApp.migrations.test.ts +232 -0
  30. package/src/adminApp.models.test.ts +647 -5
  31. package/src/adminApp.syncMeta.test.ts +237 -0
  32. package/src/adminApp.test.ts +92 -0
  33. package/src/adminApp.ts +354 -240
  34. package/src/adminConfigIdentity.ts +1 -0
  35. package/src/adminHttpGoldens.test.ts +337 -0
  36. package/src/adminMigrations.ts +157 -0
  37. package/src/adminScriptJob.test.ts +297 -0
  38. package/src/adminScriptJob.ts +271 -0
  39. package/src/adminSyncMutationAuthMismatch.test.ts +650 -0
  40. package/src/adminTextSearch.test.ts +28 -0
  41. package/src/adminTextSearch.ts +1 -0
  42. package/src/adminUiV2.test.ts +71 -1
  43. package/src/adminUiV2.ts +2 -0
  44. package/src/aggregateAdmin.test.ts +125 -0
  45. package/src/aggregateAdmin.ts +7 -4
  46. package/src/documentStorageApp.ts +1 -3
  47. package/src/enrichAdminListFilters.test.ts +44 -0
  48. package/src/enrichAdminListFilters.ts +29 -0
  49. package/src/filterParser.test.ts +95 -0
  50. package/src/filterParser.ts +156 -10
  51. package/src/index.ts +2 -0
  52. package/src/legacy.ts +5 -1
  53. package/src/resolvedAdminModel.ts +2 -1
@@ -1,5 +1,13 @@
1
- ## Admin Panel (backend)
1
+ ## Admin panel backend
2
2
 
3
- The backend uses `@terreno/admin-backend`'s `AdminApp` for auto-generated admin CRUD endpoints.
4
- All admin routes require `IsAdmin` permission and are mounted at `/admin`.
5
- Add models to `AdminApp` in `src/server.ts` to expose them in the admin panel.
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`.
@@ -1,6 +1,21 @@
1
1
  # Terreno
2
2
 
3
- A monorepo containing shared packages for building full-stack applications with React Native and Express/Mongoose.
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 with 88+ components:
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
- A monorepo containing shared packages for building full-stack applications with React Native and Express/Mongoose.
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 with 88+ components:
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
- A monorepo containing shared packages for building full-stack applications with React Native and Express/Mongoose.
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 with 88+ components:
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
- A monorepo containing shared packages for building full-stack applications with React Native and Express/Mongoose.
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 with 88+ components:
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
- See [Add a model to the admin](../docs/how-to/admin-add-model.md) for the recommended
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/bunfig.toml CHANGED
@@ -1,7 +1,15 @@
1
1
  [test]
2
2
  preload = ["./src/tests/bunSetup.ts"]
3
3
  root = "./src"
4
- coveragePathIgnorePatterns = ["**/*.test.ts", "../api/**", "dist/**", "**/node_modules/**"]
4
+ coveragePathIgnorePatterns = [
5
+ "**/*.test.ts",
6
+ "**/tests/**",
7
+ # Sibling workspace packages are compiled into `dist/` for this package's CI run;
8
+ # they carry their own coverage gates.
9
+ "../**",
10
+ "dist/**",
11
+ "**/node_modules/**",
12
+ ]
5
13
  # Enforced by scripts/check-coverage.ts; Bun parses this key but does not
6
14
  # fail the run when coverage is below threshold. See
7
15
  # https://github.com/oven-sh/bun/issues/7367 and https://github.com/oven-sh/bun/pull/27933.
@@ -114,6 +114,9 @@ export interface AdminCustomScreenConfig {
114
114
  name: string;
115
115
  /** Optional subtitle or help text shown with the screen card in the admin UI */
116
116
  description?: string;
117
+ /** Sidebar group label; grouped screens render with matching model groups in AdminShell. */
118
+ group?: string;
119
+ icon?: string;
117
120
  /** RBAC or custom authorization for exposing this screen in admin metadata/navigation. */
118
121
  adminAccess?: Pick<AdminAccessConfig, "authorize" | "resource"> & {
119
122
  action?: string;
@@ -134,14 +137,27 @@ export interface AdminOptions {
134
137
  /** Extra custom screens merged with built-ins (e.g. version-config) */
135
138
  customScreens?: AdminCustomScreenConfig[];
136
139
  /**
137
- * Optional audit sink for admin CRUD after modelRouter succeeds.
138
- * Consumers typically persist to an `AdminAuditLog` collection.
140
+ * Extra audit sink after successful admin CRUD. When `AuditApp` is registered,
141
+ * AdminApp also writes `AuditEvent` rows (`source: "admin"`) without this hook.
139
142
  */
140
143
  onAdminAudit?: (event: AdminAuditEvent, req: express.Request) => void | Promise<void>;
141
144
  /** When set, admin shell entry requires `admin:access`; model CRUD also requires
142
145
  * resource/action permissions (for example `user:update`) from the same Access instance. */
143
146
  accessControl?: AnyTerrenoAccess;
147
+ /**
148
+ * When `dir` is set, admin exposes GET/POST `/migrations` and
149
+ * `GET /admin/config` includes `migrations.enabled: true`.
150
+ */
151
+ migrations?: {
152
+ dir: string;
153
+ };
154
+ /**
155
+ * Scope admin CRUD for models with an `organizationId` schema path.
156
+ * Default false so existing single-tenant admin panels remain unchanged.
157
+ */
158
+ organizations?: boolean;
144
159
  }
160
+ /** @internal */
145
161
  export declare const getArrayEmbeddedSchemaType: (schemaPath: mongoose.SchemaType) => mongoose.SchemaType | undefined;
146
162
  /**
147
163
  * TerrenoPlugin that auto-generates admin CRUD endpoints for Mongoose models.
@@ -193,7 +209,9 @@ export declare class AdminApp {
193
209
  * @param options - Admin panel configuration including models and base path
194
210
  */
195
211
  constructor(options: AdminOptions);
212
+ private isOrganizationScoped;
196
213
  private adminAccessPermissions;
214
+ private adminRunScriptsPermissions;
197
215
  private hasScriptPermission;
198
216
  private hasConfigurationPermission;
199
217
  private canAnyResourceAction;