@cinnabun/admin 0.0.1 → 0.0.7

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 ADDED
@@ -0,0 +1,82 @@
1
+ # @cinnabun/admin
2
+
3
+ Admin UI for Cinnabun. Auto-generated CRUD for your entities.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @cinnabun/admin
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ### 1. Define an admin resource
14
+
15
+ ```typescript
16
+ import { AdminResource, AdminField } from "@cinnabun/admin";
17
+
18
+ @AdminResource({
19
+ path: "/users",
20
+ model: User,
21
+ repository: UserRepository,
22
+ })
23
+ class UserAdmin {
24
+ @AdminField()
25
+ id!: string;
26
+
27
+ @AdminField()
28
+ name!: string;
29
+
30
+ @AdminField({ type: "email" })
31
+ email!: string;
32
+
33
+ @AdminField({ type: "date" })
34
+ createdAt!: Date;
35
+ }
36
+ ```
37
+
38
+ ### 2. Register the module
39
+
40
+ ```typescript
41
+ import { CinnabunApp, CinnabunFactory } from "@cinnabun/core";
42
+ import { AdminModule, AdminPlugin } from "@cinnabun/admin";
43
+
44
+ @CinnabunApp({
45
+ port: 3000,
46
+ scanPaths: [],
47
+ imports: [
48
+ AdminModule.forRoot({
49
+ path: "/admin",
50
+ resources: [UserAdmin],
51
+ }),
52
+ ],
53
+ plugins: [new AdminPlugin()],
54
+ })
55
+ class App {}
56
+
57
+ CinnabunFactory.run(App);
58
+ ```
59
+
60
+ ### 3. Implement AdminRepository
61
+
62
+ Your repository must implement `AdminRepository`:
63
+
64
+ ```typescript
65
+ interface AdminRepository<T> {
66
+ findMany(options: ListOptions): Promise<ListResult<T>>;
67
+ findOne(id: string): Promise<T | null>;
68
+ create(data: Partial<T>): Promise<T>;
69
+ update(id: string, data: Partial<T>): Promise<T>;
70
+ delete(id: string): Promise<void>;
71
+ }
72
+ ```
73
+
74
+ ## Field types
75
+
76
+ - `text`, `email`, `number`, `boolean`
77
+ - `date`, `datetime`
78
+ - `relation` (for foreign keys)
79
+
80
+ ## License
81
+
82
+ MIT
@@ -1,6 +1,6 @@
1
- import { Module } from "@cinnabun/core";
1
+ import { type Constructor } from "@cinnabun/core";
2
2
  import type { AdminModuleOptions } from "./interfaces/admin-options.js";
3
3
  export declare class AdminModule {
4
- static forRoot(options: AdminModuleOptions): ReturnType<typeof Module>;
4
+ static forRoot(options: AdminModuleOptions): Constructor;
5
5
  static getOptions(): AdminModuleOptions;
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cinnabun/admin",
3
- "version": "0.0.1",
3
+ "version": "0.0.7",
4
4
  "description": "Auto-generated admin UI for CRUD operations",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",