openadminjs 0.2.0 → 0.3.0-rc.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.
Files changed (219) hide show
  1. package/README.md +106 -151
  2. package/dist/adapt-package-manager.js +4 -1
  3. package/dist/create-project.d.ts +46 -0
  4. package/dist/create-project.js +417 -150
  5. package/dist/doctor.d.ts +13 -0
  6. package/dist/doctor.js +35 -6
  7. package/dist/index.d.ts +1 -0
  8. package/dist/index.js +257 -39
  9. package/dist/render-schema.d.ts +0 -17
  10. package/dist/render-schema.js +25 -29
  11. package/dist/resource-slug.d.ts +1 -0
  12. package/dist/resource-slug.js +7 -0
  13. package/dist/runtime-mode.d.ts +16 -0
  14. package/dist/runtime-mode.js +138 -0
  15. package/dist/upgrade.d.ts +10 -0
  16. package/dist/upgrade.js +133 -0
  17. package/package.json +14 -11
  18. package/template/.dockerignore +15 -0
  19. package/template/.env.production.example +5 -0
  20. package/template/Dockerfile +12 -0
  21. package/template/README.md +4 -3
  22. package/template/apps/admin/app/api/auth/login/route.ts +9 -9
  23. package/template/apps/admin/app/api/auth/logout/route.ts +11 -3
  24. package/template/apps/admin/app/api/auth/oidc/callback/route.ts +19 -0
  25. package/template/apps/admin/app/api/auth/oidc/start/route.ts +11 -0
  26. package/template/apps/admin/app/api/auth/oidc/status/route.ts +6 -0
  27. package/template/apps/admin/app/api/auth/refresh/route.ts +18 -11
  28. package/template/apps/admin/app/api/backend/[...path]/route.ts +48 -0
  29. package/template/apps/admin/app/api-tokens/page.tsx +39 -39
  30. package/template/apps/admin/app/assistant/page.tsx +11 -0
  31. package/template/apps/admin/app/dashboard/page.tsx +45 -462
  32. package/template/apps/admin/app/globals.css +52 -16
  33. package/template/apps/admin/app/layout.tsx +1 -1
  34. package/template/apps/admin/app/login/page.tsx +13 -145
  35. package/template/apps/admin/app/plugins/page.tsx +16 -402
  36. package/template/apps/admin/app/profile/page.tsx +5 -2
  37. package/template/apps/admin/app/settings/page.tsx +14 -265
  38. package/template/apps/admin/components/ai-assistant-widget.tsx +3 -6
  39. package/template/apps/admin/components/app-shell.tsx +25 -373
  40. package/template/apps/admin/components/auth-guard.tsx +8 -28
  41. package/template/apps/admin/components/logo.tsx +1 -30
  42. package/template/apps/admin/components/resource-form.tsx +3 -3
  43. package/template/apps/admin/components/resource-table.tsx +12 -8
  44. package/template/apps/admin/lib/api.ts +45 -107
  45. package/template/apps/admin/lib/resource-table-prefs.ts +1 -57
  46. package/template/apps/admin/lib/server-api.ts +7 -0
  47. package/template/apps/admin/lib/tokens.ts +9 -81
  48. package/template/apps/admin/middleware.ts +9 -50
  49. package/template/apps/admin/next.config.mjs +4 -0
  50. package/template/apps/admin/package.json +2 -1
  51. package/template/apps/admin/public/brand/favicon.svg +4 -1
  52. package/template/apps/admin/tailwind.config.ts +9 -8
  53. package/template/apps/api/package.json +10 -6
  54. package/template/apps/api/src/access/catalog.ts +4 -0
  55. package/template/apps/api/src/admin/admin-ai.controller.ts +15 -125
  56. package/template/apps/api/src/admin/admin-analytics.service.ts +16 -148
  57. package/template/apps/api/src/admin/admin-logs.controller.ts +4 -1
  58. package/template/apps/api/src/admin/admin-plugins.controller.ts +8 -8
  59. package/template/apps/api/src/admin/admin-plugins.service.ts +15 -259
  60. package/template/apps/api/src/admin/admin-resource.service.ts +105 -254
  61. package/template/apps/api/src/admin/admin.controller.ts +17 -4
  62. package/template/apps/api/src/admin/admin.module.ts +2 -2
  63. package/template/apps/api/src/admin/resource-policy.ts +1 -0
  64. package/template/apps/api/src/admin/resource-query.ts +1 -0
  65. package/template/apps/api/src/admin/safe-ai.service.ts +43 -0
  66. package/template/apps/api/src/admin/validate-resource-payload.ts +2 -0
  67. package/template/apps/api/src/auth/auth.controller.ts +4 -2
  68. package/template/apps/api/src/auth/auth.service.ts +68 -83
  69. package/template/apps/api/src/auth/sso-oidc.controller.ts +12 -74
  70. package/template/apps/api/src/auth/sso-oidc.service.ts +51 -268
  71. package/template/apps/api/src/common/api-exception.filter.ts +1 -0
  72. package/template/apps/api/src/common/auth.guard.ts +66 -39
  73. package/template/apps/api/src/common/json-field-codec.ts +12 -13
  74. package/template/apps/api/src/common/prisma.service.ts +9 -17
  75. package/template/apps/api/src/common/request-logging.interceptor.ts +8 -3
  76. package/template/apps/api/src/graphql/graphql.module.ts +5 -4
  77. package/template/apps/api/src/health/health.controller.ts +6 -0
  78. package/template/apps/api/src/main.ts +11 -2
  79. package/template/apps/api/src/plugins/plugin-loader.ts +5 -3
  80. package/template/apps/api/src/resources/commerce.resource.ts +3 -34
  81. package/template/apps/api/src/resources/operations.resource.ts +1 -0
  82. package/template/apps/api/src/store/payment/payment.controller.ts +15 -92
  83. package/template/apps/api/src/store/payment/payment.module.ts +2 -3
  84. package/template/apps/api/src/store/payment/payment.service.ts +121 -227
  85. package/template/apps/api/webpack.config.cjs +2 -1
  86. package/template/apps/web/next.config.mjs +4 -0
  87. package/template/apps/web/public/brand/favicon.svg +4 -1
  88. package/template/compose.yaml +56 -0
  89. package/template/examples/crm-admin/README.md +31 -0
  90. package/template/examples/crm-admin/package.json +17 -0
  91. package/template/examples/crm-admin/prisma/models.fragment.prisma +50 -0
  92. package/template/examples/crm-admin/src/index.ts +7 -0
  93. package/template/examples/crm-admin/src/resources/activities.resource.ts +29 -0
  94. package/template/examples/crm-admin/src/resources/companies.resource.ts +21 -0
  95. package/template/examples/crm-admin/src/resources/contacts.resource.ts +24 -0
  96. package/template/examples/crm-admin/src/resources/deals.resource.ts +30 -0
  97. package/template/examples/crm-admin/tsconfig.json +7 -0
  98. package/template/package.json +6 -1
  99. package/template/packages/admin-client/package.json +18 -0
  100. package/template/packages/admin-client/src/contracts.ts +29 -0
  101. package/template/packages/admin-client/src/index.ts +2 -0
  102. package/template/packages/admin-client/src/preferences.ts +57 -0
  103. package/template/packages/admin-client/tsconfig.json +12 -0
  104. package/template/packages/auth/package.json +1 -1
  105. package/template/packages/brand/site/assets/brand/favicon.svg +4 -1
  106. package/template/packages/brand/src/generate-assets.mjs +17 -186
  107. package/template/packages/core/package.json +1 -1
  108. package/template/packages/mail/package.json +1 -1
  109. package/template/packages/nest/package.json +22 -0
  110. package/template/packages/nest/src/api-exception.filter.ts +23 -0
  111. package/template/packages/nest/src/index.ts +3 -0
  112. package/template/packages/nest/src/resource-policy.ts +64 -0
  113. package/template/packages/nest/src/resource-query.ts +103 -0
  114. package/template/packages/nest/tsconfig.json +12 -0
  115. package/template/packages/notifications/package.json +1 -1
  116. package/template/packages/payments/package.json +1 -1
  117. package/template/packages/permissions/package.json +1 -1
  118. package/template/packages/permissions/src/index.ts +2 -2
  119. package/template/packages/plugin-sdk/package.json +1 -1
  120. package/template/packages/plugin-sdk/src/index.ts +2 -2
  121. package/template/packages/prisma/package.json +21 -0
  122. package/template/packages/prisma/schema/ai.prisma +36 -0
  123. package/template/packages/prisma/schema/audit.prisma +13 -0
  124. package/template/packages/prisma/schema/commerce.prisma +79 -0
  125. package/template/packages/prisma/schema/content.prisma +27 -0
  126. package/template/packages/prisma/schema/core.prisma +106 -0
  127. package/template/packages/prisma/schema/header.prisma +8 -0
  128. package/template/packages/prisma/schema/jobs.prisma +9 -0
  129. package/template/packages/prisma/schema/media.prisma +9 -0
  130. package/template/packages/prisma/schema/modules.json +47 -0
  131. package/template/packages/prisma/schema/notifications.prisma +9 -0
  132. package/template/packages/prisma/schema/settings.prisma +8 -0
  133. package/template/packages/prisma/schema/tokens.prisma +10 -0
  134. package/template/packages/prisma/src/index.d.ts +12 -0
  135. package/template/packages/prisma/src/index.mjs +138 -0
  136. package/template/packages/queue/package.json +1 -1
  137. package/template/packages/resource/package.json +1 -1
  138. package/template/packages/resource/src/index.ts +1 -0
  139. package/template/packages/storage/package.json +1 -1
  140. package/template/packages/storage/src/index.ts +37 -0
  141. package/template/prisma/migrations/20261126130000_add_sessions/migration.sql +26 -0
  142. package/template/prisma/migrations/20261126140000_api_token_hash/migration.sql +3 -0
  143. package/template/prisma/migrations/20261126150000_payment_idempotency/migration.sql +6 -0
  144. package/template/prisma/schema.prisma +82 -54
  145. package/template/prisma/seed.ts +14 -38
  146. package/template/runtime-versions.json +15 -0
  147. package/template/scripts/db-init.mjs +33 -0
  148. package/template/scripts/install-crm.mjs +50 -0
  149. package/template/scripts/migrate-existing.mjs +65 -0
  150. package/template/scripts/schema.mjs +48 -0
  151. package/template/tsconfig.base.json +23 -5
  152. package/LICENSE +0 -21
  153. package/dist/adapt-package-manager.test.d.ts +0 -1
  154. package/dist/adapt-package-manager.test.js +0 -76
  155. package/dist/cli.e2e.test.d.ts +0 -1
  156. package/dist/cli.e2e.test.js +0 -87
  157. package/dist/create-project.test.d.ts +0 -1
  158. package/dist/create-project.test.js +0 -275
  159. package/dist/database-providers.integration.test.d.ts +0 -1
  160. package/dist/database-providers.integration.test.js +0 -64
  161. package/dist/db-commands.test.d.ts +0 -1
  162. package/dist/db-commands.test.js +0 -27
  163. package/dist/doctor.test.d.ts +0 -1
  164. package/dist/doctor.test.js +0 -102
  165. package/dist/index.test.d.ts +0 -1
  166. package/dist/index.test.js +0 -11
  167. package/dist/render-schema.test.d.ts +0 -1
  168. package/dist/render-schema.test.js +0 -57
  169. package/dist/resource-slug.test.d.ts +0 -1
  170. package/dist/resource-slug.test.js +0 -9
  171. package/dist/secrets.test.d.ts +0 -1
  172. package/dist/secrets.test.js +0 -36
  173. package/dist/security.test.d.ts +0 -1
  174. package/dist/security.test.js +0 -54
  175. package/dist/validate-name.test.d.ts +0 -1
  176. package/dist/validate-name.test.js +0 -63
  177. package/template/apps/admin/.storybook/main.ts +0 -12
  178. package/template/apps/admin/.storybook/preview.ts +0 -10
  179. package/template/apps/admin/app/login/page.test.tsx +0 -18
  180. package/template/apps/admin/components/auth-guard.test.tsx +0 -55
  181. package/template/apps/admin/components/logo.stories.tsx +0 -24
  182. package/template/apps/admin/lib/api.test.ts +0 -118
  183. package/template/apps/admin/lib/auth-flow.e2e.test.ts +0 -79
  184. package/template/apps/admin/vitest.config.ts +0 -7
  185. package/template/apps/api/src/access/derive-permissions.test.ts +0 -26
  186. package/template/apps/api/src/admin/admin-resource.service.test.ts +0 -118
  187. package/template/apps/api/src/admin/validate-resource-payload.test.ts +0 -44
  188. package/template/apps/api/src/app.module.test.ts +0 -12
  189. package/template/apps/api/src/auth/auth.service.test.ts +0 -78
  190. package/template/apps/api/src/auth/sso-oidc.service.test.ts +0 -84
  191. package/template/apps/api/src/common/auth.guard.test.ts +0 -62
  192. package/template/apps/api/src/common/casl-ability.factory.test.ts +0 -33
  193. package/template/apps/api/src/common/json-field-codec.test.ts +0 -76
  194. package/template/apps/api/src/common/prisma.service.test.ts +0 -19
  195. package/template/apps/api/src/common/request-logging.interceptor.test.ts +0 -39
  196. package/template/apps/api/src/graphql/admin-resources.resolver.test.ts +0 -45
  197. package/template/apps/api/src/graphql/ensure-gql-paramtypes.test.ts +0 -44
  198. package/template/apps/api/src/graphql/graphql-apollo-config.test.ts +0 -26
  199. package/template/apps/api/src/graphql/graphql-schema.test.ts +0 -26
  200. package/template/apps/api/src/plugins/manifest.schema.test.ts +0 -36
  201. package/template/apps/api/src/plugins/plugin-runtime.test.ts +0 -24
  202. package/template/apps/api/src/queue/queue.service.test.ts +0 -33
  203. package/template/apps/api/src/resources/resource-hooks.registry.test.ts +0 -72
  204. package/template/apps/api/vitest.config.ts +0 -21
  205. package/template/apps/web/lib/seo.test.ts +0 -41
  206. package/template/apps/web/vitest.config.ts +0 -19
  207. package/template/packages/auth/src/index.test.ts +0 -10
  208. package/template/packages/brand/src/index.test.ts +0 -9
  209. package/template/packages/core/src/index.test.ts +0 -27
  210. package/template/packages/core/vitest.config.ts +0 -9
  211. package/template/packages/mail/src/index.test.ts +0 -23
  212. package/template/packages/notifications/src/index.test.ts +0 -9
  213. package/template/packages/permissions/src/blueprints.test.ts +0 -62
  214. package/template/packages/permissions/src/index.test.ts +0 -34
  215. package/template/packages/plugin-sdk/src/sdk.test.ts +0 -13
  216. package/template/packages/plugin-sdk/vitest.config.ts +0 -5
  217. package/template/packages/queue/src/index.test.ts +0 -12
  218. package/template/packages/resource/src/index.test.ts +0 -196
  219. package/template/packages/storage/src/index.test.ts +0 -10
package/README.md CHANGED
@@ -1,208 +1,163 @@
1
1
  # OpenAdminJS CLI
2
2
 
3
- **`openadminjs` is a CLI scaffold generator**, not a runtime library you import into React/Next/Nest apps. It creates a full pnpm monorepo (NestJS API, Next.js admin/web, shared packages).
3
+ **`openadminjs` is a CLI scaffold generator**, not a runtime library you import into React/Next/Nest apps. It creates a full monorepo (NestJS API, Next.js admin/web, shared packages).
4
4
 
5
5
  Full documentation: [https://js-senpai.github.io/open-admin-js/docs.html](https://js-senpai.github.io/open-admin-js/docs.html)
6
6
 
7
7
  ## Requirements
8
8
 
9
9
  - **Node.js 20+**
10
- - **pnpm 9+** (the only supported package manager)
11
- - **PostgreSQL 14+**, **MySQL 8+**, or **SQLite 3** (local file)
10
+ - **One of:** pnpm 9+ (recommended), npm 9+, or yarn 1.x / Berry
11
+ - **Database:** PostgreSQL 14+, MySQL 8+, or **SQLite 3** (local file, zero external DB)
12
+ - **Redis:** optional — background job queues are disabled when `REDIS_URL` is blank
13
+ - **Network:** Prisma downloads engine binaries on first install/generate (corporate proxies may need configuration)
12
14
 
13
- The CLI verifies Node.js and pnpm before writing any files.
15
+ The CLI verifies Node.js before writing files and detects which package managers are installed.
14
16
 
15
- ## Quick start
17
+ ## Quick start (interactive)
16
18
 
17
19
  ```bash
18
20
  npx openadminjs create my-app
19
21
  cd my-app
20
- pnpm install # skipped if you chose install during create
21
- pnpm db:migrate # skipped if install ran during create
22
- pnpm db:seed # skipped if install ran during create
23
- pnpm dev
22
+ pnpm dev # or: npm run dev / yarn dev
24
23
  ```
25
24
 
26
- The scaffold generates a **pnpm** monorepo backed by **PostgreSQL**, **MySQL**, or
27
- **SQLite**; the CLI fills `DATABASE_URL` for you. For MySQL/SQLite the Prisma schema
28
- is adapted and the initial migration is created on first `db:migrate`. On SQLite the
29
- API JSON-encodes `Json` columns into `String` fields at runtime. npm and yarn are
30
- **not** offered.
25
+ If you skipped install during create:
31
26
 
32
- ### Configure environment
33
-
34
- The scaffold wizard asks for database access and writes ready-to-use values into
35
- `apps/api/.env` (including `SUPERADMIN_EMAIL` / `SUPERADMIN_PASSWORD` for
36
- non-interactive seed). **JWT secrets are generated with `crypto.randomBytes`** —
37
- never predictable defaults. `ADMIN_ORIGIN` and `API_PORT` default to
38
- `http://localhost:3000` and `4000`.
39
-
40
- Every new project includes a root **`.gitignore`** (written before `git init`) that
41
- excludes all `.env` files, plus a tracked **`.env.example`** with placeholders. Real
42
- secrets live only in `apps/api/.env` and are never printed by the CLI.
43
-
44
- Typical `apps/api/.env` keys (after create, edit as needed):
45
-
46
- | Provider | `DATABASE_URL` example |
47
- | --- | --- |
48
- | PostgreSQL | `postgresql://USER:PASSWORD@localhost:5432/openadminjs?schema=public` |
49
- | MySQL | `mysql://USER:PASSWORD@localhost:3306/openadminjs` |
50
- | SQLite | `file:./dev.db` |
51
-
52
- ```env
53
- REDIS_URL=redis://localhost:6379
54
- JWT_SECRET=replace-with-a-long-random-string-at-least-32-chars
55
- JWT_REFRESH_SECRET=another-long-random-string
56
- ADMIN_ORIGIN=http://localhost:3000
57
- API_PORT=4000
58
- SUPERADMIN_EMAIL=admin@localhost.dev
59
- SUPERADMIN_PASSWORD=your-secure-password
60
- ```
61
-
62
- Optional (elsewhere / advanced):
63
-
64
- ```env
65
- OPENADMIN_PLUGIN_PNPM_INSTALL=0
27
+ ```bash
28
+ pnpm install && pnpm db:migrate && pnpm db:seed
66
29
  ```
67
30
 
68
- ### Run project
31
+ During create, choosing **install** runs dependency install, schema apply, and seed automatically.
69
32
 
70
- ```bash
71
- pnpm dev
72
- ```
33
+ ### What `dev` starts
73
34
 
74
- Typical URLs:
35
+ The root **`dev` script starts the admin UI and the API only** (not the public web app):
75
36
 
76
- | App | URL |
37
+ | Service | URL |
77
38
  | ----------- | ------------------------------ |
78
39
  | Admin | http://localhost:3000 |
79
40
  | API | http://localhost:4000 |
80
41
  | API Swagger | http://localhost:4000/api/docs |
81
- | Web (demo) | http://localhost:3001 |
82
-
83
- ### Sign in
84
42
 
85
- After project creation, migrations and seed are run automatically. Use the superadmin credentials you entered in the scaffold wizard:
43
+ Optional public web app (port 3001):
86
44
 
87
- - **Email:** your `Superadmin email`
88
- - **Password:** your `Superadmin password`
45
+ ```bash
46
+ pnpm --filter @openadminjs/web dev # npm: npm run dev --workspace=@openadminjs/web
47
+ ```
89
48
 
90
- ## Programmatic API
49
+ ## Non-interactive / CI
91
50
 
92
- ```ts
93
- import { createProject, databaseUrl } from "openadminjs";
94
- import { randomBytes } from "node:crypto";
51
+ When stdin is not a TTY (or you pass `--yes` / `--non-interactive`), the CLI uses flags and safe defaults — no prompts.
95
52
 
96
- // PostgreSQL (ships baseline migration)
97
- createProject({
98
- projectName: "my-app",
99
- packageManager: "pnpm",
100
- database: "postgresql",
101
- databaseUrl: databaseUrl("my-app", "postgresql"),
102
- // ...
103
- });
53
+ ```bash
54
+ export OPENADMIN_ADMIN_PASSWORD="$(openssl rand -base64 24)"
104
55
 
105
- // MySQL (run db:migrate after install to create the initial migration)
106
- createProject({
107
- projectName: "my-app",
108
- packageManager: "pnpm",
109
- database: "mysql",
110
- databaseUrl: databaseUrl("my-app", "mysql"),
111
- superadminEmail: "admin@localhost.dev",
112
- superadminPassword: "a-strong-password",
113
- redisUrl: "redis://localhost:6379",
114
- jwtSecret: randomBytes(48).toString("base64url"),
115
- jwtRefreshSecret: randomBytes(48).toString("base64url"),
116
- adminOrigin: "http://localhost:3000",
117
- apiPort: "4000"
118
- });
56
+ npx openadminjs create my-app \
57
+ --yes \
58
+ --package-manager npm \
59
+ --database sqlite \
60
+ --admin-email admin@example.com \
61
+ --admin-password-env OPENADMIN_ADMIN_PASSWORD \
62
+ --skip-redis
119
63
 
120
- // SQLite (local file — API JSON-encodes Json columns at runtime)
121
- createProject({
122
- projectName: "my-app",
123
- packageManager: "pnpm",
124
- database: "sqlite",
125
- databaseUrl: "file:./dev.db",
126
- superadminEmail: "admin@localhost.dev",
127
- superadminPassword: "a-strong-password",
128
- redisUrl: "redis://localhost:6379",
129
- jwtSecret: randomBytes(48).toString("base64url"),
130
- jwtRefreshSecret: randomBytes(48).toString("base64url"),
131
- adminOrigin: "http://localhost:3000",
132
- apiPort: "4000"
133
- });
64
+ cd my-app && npm run dev
134
65
  ```
135
66
 
136
- ## Health & security checks
137
-
138
- ```bash
139
- openadminjs doctor # verify the project is ready to run
140
- openadminjs doctor --json
141
- openadminjs security check
142
- openadminjs security check --json
143
- ```
67
+ Prefer **`--admin-password-env`** over `--admin-password` so secrets are not stored in shell history.
144
68
 
145
- `templateDir` defaults to the bundled template. The interactive wizard offers
146
- **pnpm** + **PostgreSQL / MySQL / SQLite**; the programmatic API accepts the
147
- `packageManager`/`database` options for advanced use.
69
+ | Flag | Description |
70
+ | --- | --- |
71
+ | `--package-manager`, `--pm` | `pnpm`, `npm`, or `yarn` |
72
+ | `--database`, `--db` | `postgresql`, `mysql`, or `sqlite` |
73
+ | `--admin-email` | Superadmin email |
74
+ | `--admin-password-env <VAR>` | Read password from environment (recommended) |
75
+ | `--admin-password <value>` | Password on CLI (discouraged) |
76
+ | `--db-url <url>` | Override `DATABASE_URL` |
77
+ | `--redis-url <url>` | Redis URL (blank disables queues) |
78
+ | `--skip-redis` | Disable background job queues |
79
+ | `--no-install` | Skip install / DB setup |
80
+ | `--no-git` | Skip `git init` |
81
+ | `-y`, `--yes` | Non-interactive with defaults |
82
+
83
+ ## Package managers
84
+
85
+ | Manager | Notes |
86
+ | --- | --- |
87
+ | **pnpm** | Default; ships `pnpm-workspace.yaml` and `workspace:*` deps |
88
+ | **npm** | Adds npm `workspaces`; rewrites `workspace:*` → `*` for local linking |
89
+ | **yarn** | Adds `workspaces`; rewrites `workspace:*` → `*` |
148
90
 
149
- ## MVP scope
91
+ If your preferred manager is missing, the interactive wizard offers installed alternatives or Corepack hints for pnpm.
150
92
 
151
- - Resource-driven admin metadata with safe defaults.
152
- - Auth, RBAC contracts, generic CRUD API, audit log and file/settings modules.
153
- - Next.js admin shell with login, dashboard, resource screens and operational pages.
154
- - Generated app `apps/web` for public frontend pages and SEO.
155
- - CLI: `create`, `dev`, `build`, `db migrate|seed|studio|reset`, `generate resource|field|plugin`, `doctor`, `security check`.
93
+ ## SQLite zero-setup
156
94
 
157
- ## Plugin Platform
95
+ SQLite uses a local `file:./dev.db` — no PostgreSQL/MySQL server required. **Redis is optional** for SQLite: leave the Redis prompt blank or pass `--skip-redis`. The API starts without Redis; queue endpoints return a clear `503` until `REDIS_URL` is set.
158
96
 
159
- OpenAdminJS now uses a broad extension model (no legacy compatibility layer). Plugins can register multiple surfaces through `@openadminjs/plugin-sdk`:
97
+ Prisma Client is generated automatically before `dev`, `build`, and `db:seed` via lifecycle scripts.
160
98
 
161
- - `resource` hooks (CRUD lifecycle)
162
- - `api` hooks/routes
163
- - `media` pipeline (upload transforms)
164
- - `seo` metadata/sitemap contributors
165
- - `jobs` handlers
166
- - `adminUi` extensions (menus/pages/widgets/actions)
99
+ ## Environment
167
100
 
168
- Plugins are controlled by manifest capabilities and trust mode (`trusted` / `sandboxed`) in `apps/api/plugins.manifest.json`.
101
+ Secrets are written to **`apps/api/.env`** (git-ignored). JWT keys are generated with `crypto.randomBytes`. A tracked **`.env.example`** contains placeholders only — the CLI never prints secret values.
169
102
 
170
- ### Capability matrix
103
+ ```env
104
+ DATABASE_URL=file:./dev.db # or postgres/mysql URL
105
+ REDIS_URL= # blank = queues disabled
106
+ JWT_SECRET=<generated>
107
+ JWT_REFRESH_SECRET=<generated>
108
+ ADMIN_ORIGIN=http://localhost:3000
109
+ API_PORT=4000
110
+ SUPERADMIN_EMAIL=admin@localhost.dev
111
+ SUPERADMIN_PASSWORD=<your password>
112
+ ```
171
113
 
172
- - `resource.hooks` — CRUD lifecycle hooks per resource.
173
- - `api.hooks` / `api.routes` — request lifecycle hooks and custom API endpoints.
174
- - `media.pipeline` — file/image transform pipeline.
175
- - `seo.extend` — metadata + sitemap contributors.
176
- - `jobs.run` — background job handlers.
177
- - `admin.ui.extend` — admin menu/page/widget/action extensions.
114
+ ## Sign in
178
115
 
179
- `trusted` mode may run with broad access; `sandboxed` mode should explicitly declare only required capabilities.
116
+ After create (with install), use the superadmin email and password from the wizard or `apps/api/.env`.
180
117
 
181
- Generate a starter plugin:
118
+ ## Health & troubleshooting
182
119
 
183
120
  ```bash
184
- pnpm exec openadminjs generate plugin com.example.my-plugin
121
+ openadminjs doctor # verify install, env, Prisma client, scripts
122
+ openadminjs doctor --skip-network # offline-friendly
123
+ openadminjs security check
185
124
  ```
186
125
 
187
- ### Queue setup
126
+ **Prisma Client not initialized:** run `pnpm db:migrate` (or `npm run db:migrate`) from the project root, or `prisma generate` from `apps/api`.
188
127
 
189
- Set `REDIS_URL` in your environment to run queue processing (example: `redis://localhost:6379`).
128
+ **Prisma engine download failed:** check network/proxy; retry install from the project root.
190
129
 
191
- ## Partners
130
+ **Setup failed mid-create:** the project directory is preserved with a resume command in the error message.
192
131
 
193
- OpenAdminJS is community-powered and stays free thanks to partner support.
132
+ **npm `EUNSUPPORTEDPROTOCOL workspace:*`:** upgrade to the latest `openadminjs` CLI — npm projects must use `*` not `workspace:*`.
194
133
 
195
- Want to become a partner and place your logo in the project materials?
196
- Email us at `openadminjs@proton.me`.
134
+ ## Commands
135
+
136
+ ```bash
137
+ openadminjs create [name] [options]
138
+ openadminjs db migrate [dev|deploy] | seed | studio | reset
139
+ openadminjs generate resource <Model> | field <resource> <field> | plugin <id>
140
+ openadminjs doctor [--json] [--skip-network]
141
+ openadminjs security check [--json]
142
+ ```
197
143
 
198
- ## Financial support
144
+ ## Programmatic API
199
145
 
200
- If you want to support development, hosting and community tooling:
146
+ ```ts
147
+ import { createProject, databaseUrl, generateSecret } from "openadminjs";
201
148
 
202
- - Open a sponsorship discussion in GitHub issues/discussions.
203
- - Contribute with code, examples or QA.
204
- - Contact maintainers for direct support options: `openadminjs@proton.me`.
205
- - Crypto wallets:
206
- - BTC (SegWit): `bc1qpcc4hd7w82jjvsdhvx6hgu2kfuz8jgfuvxurd7`
207
- - ETH / USDC (ERC-20): `0xe5ac19c6f1f5070a7c713973fd25ee02eaf9eb48`
208
- - USDT (TRC-20): `TWyzMehesWqJS7qs5LYL4QGmgTpohNy3gf`
149
+ createProject({
150
+ projectName: "my-app",
151
+ packageManager: "npm",
152
+ database: "sqlite",
153
+ databaseUrl: "file:./dev.db",
154
+ redisUrl: "", // optional — blank disables queues
155
+ superadminEmail: "admin@localhost.dev",
156
+ superadminPassword: process.env.ADMIN_PASSWORD!,
157
+ jwtSecret: generateSecret(),
158
+ jwtRefreshSecret: generateSecret(),
159
+ adminOrigin: "http://localhost:3000",
160
+ apiPort: "4000",
161
+ install: true
162
+ });
163
+ ```
@@ -106,7 +106,10 @@ export function adaptProjectForPackageManager(targetDir, packageManager) {
106
106
  if (existsSync(pnpmWorkspaceFile)) {
107
107
  rmSync(pnpmWorkspaceFile);
108
108
  }
109
- const workspaceReplacement = packageManager === "yarn" ? "*" : "workspace:*";
109
+ // Neither npm nor Yarn Classic understand pnpm's `workspace:` protocol
110
+ // (npm throws EUNSUPPORTEDPROTOCOL). Both resolve `"*"` to the local
111
+ // workspace package by name, so rewrite every `workspace:<range>` to `"*"`.
112
+ const workspaceReplacement = "*";
110
113
  for (const file of findPackageJsonFiles(targetDir)) {
111
114
  const pkg = readPackageJson(file);
112
115
  replaceWorkspaceProtocol(pkg, workspaceReplacement);
@@ -11,7 +11,10 @@ export type CreateProjectOptions = {
11
11
  superadminEmail?: string;
12
12
  superadminPassword?: string;
13
13
  databaseUrl?: string;
14
+ /** Empty string disables Redis-backed queues (see `skipRedis`). */
14
15
  redisUrl?: string;
16
+ /** When true, force Redis (and background job queues) off. */
17
+ skipRedis?: boolean;
15
18
  jwtSecret?: string;
16
19
  jwtRefreshSecret?: string;
17
20
  adminOrigin?: string;
@@ -19,6 +22,13 @@ export type CreateProjectOptions = {
19
22
  git?: boolean;
20
23
  install?: boolean;
21
24
  templateDir?: string;
25
+ runtimeMode?: "source" | "registry";
26
+ /**
27
+ * Skip all interactive prompts. Missing optional values fall back to safe
28
+ * defaults; a missing superadmin password is generated (CSPRNG). Used for
29
+ * CI / scripting and auto-enabled when stdin is not a TTY.
30
+ */
31
+ nonInteractive?: boolean;
22
32
  };
23
33
  export type CreateProjectResult = {
24
34
  appName: string;
@@ -30,6 +40,10 @@ export type CreateProjectResult = {
30
40
  git: boolean;
31
41
  install: boolean;
32
42
  dbInitialized: boolean;
43
+ /** True when a REDIS_URL was configured (background job queues enabled). */
44
+ redisEnabled: boolean;
45
+ /** True when the superadmin password was generated (non-interactive). */
46
+ passwordGenerated: boolean;
33
47
  };
34
48
  export declare function toPackageName(input: string): string;
35
49
  export declare function defaultTemplateDir(): string;
@@ -49,6 +63,16 @@ export declare function resolveSuperadminEmail(value: string, fallback?: string)
49
63
  * resolution), so pressing Enter to accept the default is always valid.
50
64
  */
51
65
  export declare function validateSuperadminEmailInput(value: string, fallback?: string): string | undefined;
66
+ export declare const DEFAULT_REDIS_URL = "redis://localhost:6379";
67
+ export declare const PACKAGE_MANAGERS: readonly PackageManager[];
68
+ /** Returns the first package manager that is installed on PATH, or undefined. */
69
+ export declare function firstAvailablePackageManager(preference?: readonly PackageManager[]): PackageManager | undefined;
70
+ /**
71
+ * Validates a Redis URL. An empty value is VALID — it disables background job
72
+ * queues. A non-empty value must be a parseable redis:// (or rediss://) URL so
73
+ * pressing Enter on the shown default is always accepted.
74
+ */
75
+ export declare function validateRedisUrlInput(value: string): string | undefined;
52
76
  export declare function databaseUrl(packageName: string, database: DatabaseDriver): string;
53
77
  /**
54
78
  * Generates the scaffold into a sibling staging directory and atomically renames
@@ -58,7 +82,29 @@ export declare function databaseUrl(packageName: string, database: DatabaseDrive
58
82
  export declare function createProject(options: CreateProjectOptions & {
59
83
  projectName: string;
60
84
  }): CreateProjectResult;
85
+ /**
86
+ * Thrown when the scaffold was generated successfully but a later step
87
+ * (install, migrate, seed) failed. Carries the exact command to resume so the
88
+ * user never has to guess, and signals that the directory was intentionally
89
+ * preserved (never auto-deleted).
90
+ */
91
+ export declare class SetupIncompleteError extends Error {
92
+ readonly targetDir: string;
93
+ readonly resumeCommand: string;
94
+ constructor(message: string, meta: {
95
+ targetDir: string;
96
+ appName: string;
97
+ packageManager: PackageManager;
98
+ });
99
+ }
61
100
  export declare function printNextSteps(result: CreateProjectResult): void;
62
101
  /** Warns where secrets live and that they must never be committed. Never prints secret values. */
63
102
  export declare function printSecurityNotice(result: CreateProjectResult): void;
103
+ /** Generates a strong, human-usable password (used in non-interactive mode). */
104
+ export declare function generatePassword(): string;
64
105
  export declare function createProjectInteractive(options?: CreateProjectOptions): Promise<CreateProjectResult | undefined>;
106
+ /**
107
+ * Validates a DATABASE_URL against the FINAL resolved value so pressing Enter to
108
+ * accept the shown default is always valid.
109
+ */
110
+ export declare function validateDatabaseUrlInput(database: DatabaseDriver, value: string, fallback: string): string | undefined;