@cfast/admin 0.2.0 → 0.2.2

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Daniel Schmidt
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
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;
package/llms.txt CHANGED
@@ -165,3 +165,8 @@ const admin = createAdmin({
165
165
  - Not providing `impersonate`/`stopImpersonation` callbacks and expecting impersonation to work -- these are optional but required for that feature.
166
166
  - Trying to customize rendering by passing JSX to `createAdmin` -- instead, override fields via `TableOverrides.fields` (for forms) or use `@cfast/ui` components directly in custom routes.
167
167
  - Expecting auth-internal tables (`session`, `account`, `verification`, `passkey`) to show up -- they are auto-excluded. Set `exclude: false` in table overrides to show them.
168
+
169
+ ## See Also
170
+
171
+ - `@cfast/forms` -- Schema-derived forms used for create/edit views.
172
+ - `@cfast/ui` + `@cfast/joy` -- Headless components and Joy UI styling.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cfast/admin",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "Auto-generated admin UI from your Drizzle schema with role management and impersonation",
5
5
  "keywords": [
6
6
  "cfast",
@@ -32,13 +32,6 @@
32
32
  "publishConfig": {
33
33
  "access": "public"
34
34
  },
35
- "scripts": {
36
- "build": "tsup src/index.ts --format esm --dts",
37
- "dev": "tsup src/index.ts --format esm --dts --watch",
38
- "typecheck": "tsc --noEmit",
39
- "lint": "eslint src/",
40
- "test": "vitest run"
41
- },
42
35
  "peerDependencies": {
43
36
  "@mui/joy": ">=5.0.0-beta.0",
44
37
  "react": ">=19",
@@ -52,11 +45,11 @@
52
45
  }
53
46
  },
54
47
  "dependencies": {
55
- "@cfast/db": "workspace:*",
56
- "@cfast/forms": "workspace:*",
57
- "@cfast/permissions": "workspace:*",
58
- "@cfast/joy": "workspace:*",
59
- "@cfast/ui": "workspace:*"
48
+ "@cfast/db": "0.1.1",
49
+ "@cfast/forms": "0.1.0",
50
+ "@cfast/permissions": "0.1.0",
51
+ "@cfast/ui": "0.2.1",
52
+ "@cfast/joy": "0.1.0"
60
53
  },
61
54
  "devDependencies": {
62
55
  "@emotion/react": "^11.14.0",
@@ -71,5 +64,12 @@
71
64
  "tsup": "^8",
72
65
  "typescript": "^5.7",
73
66
  "vitest": "^4.1.0"
67
+ },
68
+ "scripts": {
69
+ "build": "tsup src/index.ts --format esm --dts",
70
+ "dev": "tsup src/index.ts --format esm --dts --watch",
71
+ "typecheck": "tsc --noEmit",
72
+ "lint": "eslint src/",
73
+ "test": "vitest run"
74
74
  }
75
- }
75
+ }