@cfast/admin 0.2.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/dist/index.d.ts +3 -3
- package/dist/index.js +11 -5
- package/package.json +1 -1
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"`).
|
|
301
|
-
schema: Record<string,
|
|
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,
|
|
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,
|
|
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
|
|
269
|
-
|
|
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
|
|
277
|
+
return value;
|
|
272
278
|
}
|
|
273
279
|
}
|
|
274
280
|
return void 0;
|