@cfast/admin 0.1.0 → 0.2.1

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 CHANGED
@@ -23,7 +23,7 @@ This means:
23
23
  - **Permission-aware by default.** The admin panel uses `@cfast/db` under the hood. Admins see everything. Moderators see what moderators see. The admin UI doesn't bypass your permission system — it uses it.
24
24
  - **User management built in.** View users, assign roles, revoke roles, impersonate users. Integrated with `@cfast/auth`.
25
25
  - **Customizable, not locked in.** Override any view, any field, any action. But the default is good enough to ship.
26
- - **UI delegated to `@cfast/ui`.** Admin generates configuration. `@cfast/ui/joy` renders it.
26
+ - **UI delegated to `@cfast/ui`.** Admin generates configuration. `@cfast/joy` renders it.
27
27
 
28
28
  ## API
29
29
 
package/dist/index.d.ts CHANGED
@@ -297,8 +297,8 @@ type AdminConfig = {
297
297
  db: CreateDbFn;
298
298
  /** Auth adapter that provides user authentication, role management, and impersonation. See {@link AdminAuthConfig}. */
299
299
  auth: AdminAuthConfig;
300
- /** Your Drizzle schema object (e.g., `import * as schema from "~/schema"`). Tables are introspected from this. */
301
- schema: Record<string, SQLiteTable>;
300
+ /** Your Drizzle schema object (e.g., `import * as schema from "~/schema"`). Non-table exports (Relations, helpers) are silently skipped. */
301
+ schema: Record<string, unknown>;
302
302
  /** Per-table display and behavior overrides, keyed by table name. See {@link TableOverrides}. */
303
303
  tables?: Record<string, TableOverrides>;
304
304
  /** Configuration for the built-in user management views. See {@link UserManagementConfig}. */
@@ -640,7 +640,7 @@ declare function createAdmin(config: AdminConfig): {
640
640
  * });
641
641
  * ```
642
642
  */
643
- declare function introspectSchema(schema: Record<string, SQLiteTable>, tableOverrides?: Record<string, TableOverrides>): AdminTableMeta[];
643
+ declare function introspectSchema(schema: Record<string, unknown>, tableOverrides?: Record<string, TableOverrides>): AdminTableMeta[];
644
644
 
645
645
  /**
646
646
  * Create an admin loader function from config and introspected table metadata.
package/dist/index.js CHANGED
@@ -1,6 +1,7 @@
1
1
  // src/introspect.ts
2
2
  import { getTableConfig } from "drizzle-orm/sqlite-core";
3
3
  import { getTableColumns, getTableName } from "drizzle-orm";
4
+ import { isTable } from "drizzle-orm";
4
5
  var AUTO_EXCLUDED_TABLES = /* @__PURE__ */ new Set([
5
6
  "session",
6
7
  "account",
@@ -42,7 +43,11 @@ function columnNameToLabel(name) {
42
43
  }
43
44
  function introspectSchema(schema, tableOverrides) {
44
45
  const result = [];
45
- for (const [_key, table] of Object.entries(schema)) {
46
+ for (const [_key, value] of Object.entries(schema)) {
47
+ if (!isTable(value)) {
48
+ continue;
49
+ }
50
+ const table = value;
46
51
  const tableName = getTableName(table);
47
52
  const overrides = tableOverrides?.[tableName] ?? {};
48
53
  if (overrides.exclude === true) {
@@ -127,7 +132,7 @@ function defaultSearchableColumns(columns) {
127
132
  }
128
133
 
129
134
  // src/loader.ts
130
- import { getTableColumns as getTableColumns2, getTableName as getTableName2, eq, like, or, asc, desc } from "drizzle-orm";
135
+ import { getTableColumns as getTableColumns2, getTableName as getTableName2, eq, like, or, asc, desc, isTable as isTable2 } from "drizzle-orm";
131
136
 
132
137
  // src/utils.ts
133
138
  var USERS_VIEW = "_users";
@@ -265,10 +270,11 @@ function getColumn(drizzleTable, columnName) {
265
270
  return columns[columnName];
266
271
  }
267
272
  function findUsersTable(schema) {
268
- for (const table of Object.values(schema)) {
269
- const name = getTableName2(table);
273
+ for (const value of Object.values(schema)) {
274
+ if (!isTable2(value)) continue;
275
+ const name = getTableName2(value);
270
276
  if (name === "user" || name === "users") {
271
- return table;
277
+ return value;
272
278
  }
273
279
  }
274
280
  return void 0;
@@ -1432,7 +1438,7 @@ import Input2 from "@mui/joy/Input";
1432
1438
  import Table3 from "@mui/joy/Table";
1433
1439
  import Sheet4 from "@mui/joy/Sheet";
1434
1440
  import Stack4 from "@mui/joy/Stack";
1435
- import { RoleBadge } from "@cfast/ui/joy";
1441
+ import { RoleBadge } from "@cfast/joy";
1436
1442
  import { jsx as jsx7, jsxs as jsxs7 } from "react/jsx-runtime";
1437
1443
  function UserList({
1438
1444
  items,
@@ -1570,7 +1576,7 @@ import Chip2 from "@mui/joy/Chip";
1570
1576
  import Select from "@mui/joy/Select";
1571
1577
  import Option from "@mui/joy/Option";
1572
1578
  import Divider2 from "@mui/joy/Divider";
1573
- import { RoleBadge as RoleBadge2, AvatarWithInitials } from "@cfast/ui/joy";
1579
+ import { RoleBadge as RoleBadge2, AvatarWithInitials } from "@cfast/joy";
1574
1580
  import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs8 } from "react/jsx-runtime";
1575
1581
  function UserDetail({
1576
1582
  targetUser,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfast/admin",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Auto-generated admin UI from your Drizzle schema with role management and impersonation",
5
5
  "keywords": [
6
6
  "cfast",
@@ -55,6 +55,7 @@
55
55
  "@cfast/db": "workspace:*",
56
56
  "@cfast/forms": "workspace:*",
57
57
  "@cfast/permissions": "workspace:*",
58
+ "@cfast/joy": "workspace:*",
58
59
  "@cfast/ui": "workspace:*"
59
60
  },
60
61
  "devDependencies": {