@zerotal/arch 1.7.0

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 (160) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/LICENSE +21 -0
  3. package/README.md +67 -0
  4. package/api-surface.md +283 -0
  5. package/docs/about.md +676 -0
  6. package/docs/admin/actions.md +183 -0
  7. package/docs/admin/auth.md +89 -0
  8. package/docs/admin/dashboard.md +155 -0
  9. package/docs/admin/extending-ui.md +229 -0
  10. package/docs/admin/extending.md +205 -0
  11. package/docs/admin/forms.md +155 -0
  12. package/docs/admin/index.md +144 -0
  13. package/docs/admin/operations.md +224 -0
  14. package/docs/admin/references.md +174 -0
  15. package/docs/admin/resources.md +132 -0
  16. package/docs/admin/structure.md +158 -0
  17. package/docs/admin/tables.md +185 -0
  18. package/docs/admin/testing.md +138 -0
  19. package/docs/ai.md +373 -0
  20. package/docs/application.md +435 -0
  21. package/docs/arch.md +263 -0
  22. package/docs/assets.md +755 -0
  23. package/docs/audit.md +367 -0
  24. package/docs/authentication.md +1000 -0
  25. package/docs/authorization.md +529 -0
  26. package/docs/broadcasting/channels.md +170 -0
  27. package/docs/broadcasting/client.md +108 -0
  28. package/docs/broadcasting/events.md +190 -0
  29. package/docs/broadcasting/index.md +163 -0
  30. package/docs/broadcasting/references.md +84 -0
  31. package/docs/broadcasting/testing.md +132 -0
  32. package/docs/cache.md +387 -0
  33. package/docs/carbon.md +830 -0
  34. package/docs/changelog.md +465 -0
  35. package/docs/client/auth.md +113 -0
  36. package/docs/client/errors.md +139 -0
  37. package/docs/client/files.md +118 -0
  38. package/docs/client/index.md +128 -0
  39. package/docs/client/references.md +58 -0
  40. package/docs/client/requests.md +131 -0
  41. package/docs/client/resilience.md +141 -0
  42. package/docs/client/testing.md +146 -0
  43. package/docs/commands.md +450 -0
  44. package/docs/components.md +2427 -0
  45. package/docs/config-system.md +258 -0
  46. package/docs/container.md +596 -0
  47. package/docs/context.md +579 -0
  48. package/docs/contributing.md +164 -0
  49. package/docs/controllers.md +354 -0
  50. package/docs/conventions.md +466 -0
  51. package/docs/cookies.md +101 -0
  52. package/docs/csrf.md +206 -0
  53. package/docs/database.md +476 -0
  54. package/docs/deployment.md +434 -0
  55. package/docs/devtools.md +1013 -0
  56. package/docs/email-verification.md +320 -0
  57. package/docs/encryption.md +380 -0
  58. package/docs/errors.md +317 -0
  59. package/docs/events.md +420 -0
  60. package/docs/flow/components.md +846 -0
  61. package/docs/flow/decorators.md +458 -0
  62. package/docs/flow/events.md +420 -0
  63. package/docs/flow/forms.md +551 -0
  64. package/docs/flow/index.md +568 -0
  65. package/docs/flow/layouts.md +793 -0
  66. package/docs/flow/lifecycle.md +336 -0
  67. package/docs/flow/pagination.md +402 -0
  68. package/docs/flow/performance.md +262 -0
  69. package/docs/flow/references.md +317 -0
  70. package/docs/flow/routing.md +550 -0
  71. package/docs/flow/testing.md +447 -0
  72. package/docs/getting-started.md +286 -0
  73. package/docs/health.md +269 -0
  74. package/docs/helpers.md +423 -0
  75. package/docs/i18n.md +414 -0
  76. package/docs/index.md +65 -0
  77. package/docs/inertia/build.md +95 -0
  78. package/docs/inertia/devtools.md +197 -0
  79. package/docs/inertia/index.md +267 -0
  80. package/docs/inertia/middleware.md +81 -0
  81. package/docs/inertia/props.md +507 -0
  82. package/docs/inertia/references.md +144 -0
  83. package/docs/inertia/rendering.md +189 -0
  84. package/docs/inertia/ssr.md +102 -0
  85. package/docs/inspirations.md +257 -0
  86. package/docs/lifecycle.md +331 -0
  87. package/docs/lock.md +454 -0
  88. package/docs/logger.md +517 -0
  89. package/docs/media.md +582 -0
  90. package/docs/middleware.md +509 -0
  91. package/docs/migrations.md +529 -0
  92. package/docs/monitor.md +377 -0
  93. package/docs/notifications.md +848 -0
  94. package/docs/orm/casts.md +365 -0
  95. package/docs/orm/factories.md +231 -0
  96. package/docs/orm/index.md +663 -0
  97. package/docs/orm/lifecycle.md +421 -0
  98. package/docs/orm/queries.md +692 -0
  99. package/docs/orm/relationships.md +440 -0
  100. package/docs/orm/serialization.md +251 -0
  101. package/docs/package-development.md +536 -0
  102. package/docs/pagination.md +340 -0
  103. package/docs/password-reset.md +335 -0
  104. package/docs/providers.md +447 -0
  105. package/docs/query-builder.md +465 -0
  106. package/docs/queue.md +549 -0
  107. package/docs/rate-limiting.md +253 -0
  108. package/docs/responses.md +336 -0
  109. package/docs/roles-and-2fa.md +418 -0
  110. package/docs/routing.md +1008 -0
  111. package/docs/scaffolding.md +335 -0
  112. package/docs/scheduler.md +533 -0
  113. package/docs/seeding.md +229 -0
  114. package/docs/session.md +451 -0
  115. package/docs/social.md +524 -0
  116. package/docs/storage.md +622 -0
  117. package/docs/structure.md +230 -0
  118. package/docs/support-policy.md +114 -0
  119. package/docs/telemetry.md +505 -0
  120. package/docs/tenancy.md +608 -0
  121. package/docs/testing/browser.md +153 -0
  122. package/docs/testing/console.md +130 -0
  123. package/docs/testing/database.md +238 -0
  124. package/docs/testing/flow-browser.md +216 -0
  125. package/docs/testing/http.md +441 -0
  126. package/docs/testing/index.md +240 -0
  127. package/docs/testing/mocking.md +410 -0
  128. package/docs/upgrade.md +192 -0
  129. package/docs/validator.md +549 -0
  130. package/docs/view.md +453 -0
  131. package/package.json +60 -0
  132. package/src/bin/mcp.ts +73 -0
  133. package/src/config.ts +63 -0
  134. package/src/errors.ts +27 -0
  135. package/src/index.ts +56 -0
  136. package/src/install/ArchInstallCommand.ts +189 -0
  137. package/src/install/detect.ts +98 -0
  138. package/src/install/guidelines.ts +290 -0
  139. package/src/install/markers.ts +77 -0
  140. package/src/install/mcpConfig.ts +81 -0
  141. package/src/mcp/index.ts +27 -0
  142. package/src/mcp/jsonrpc.ts +133 -0
  143. package/src/mcp/server.ts +307 -0
  144. package/src/mcp/stdio.ts +111 -0
  145. package/src/mcp/types.ts +146 -0
  146. package/src/probe/ArchProbeCommand.ts +48 -0
  147. package/src/probe/sentinel.ts +13 -0
  148. package/src/probe/topics.ts +291 -0
  149. package/src/provider/ArchProvider.ts +101 -0
  150. package/src/tools/_probe.ts +164 -0
  151. package/src/tools/apiSurface.ts +241 -0
  152. package/src/tools/appInfo.ts +88 -0
  153. package/src/tools/baselines.ts +210 -0
  154. package/src/tools/context.ts +37 -0
  155. package/src/tools/doctor.ts +93 -0
  156. package/src/tools/index.ts +50 -0
  157. package/src/tools/logs.ts +265 -0
  158. package/src/tools/routes.ts +133 -0
  159. package/src/tools/schema.ts +119 -0
  160. package/src/tools/searchDocs.ts +345 -0
@@ -0,0 +1,230 @@
1
+ ---
2
+ title: Directory Structure
3
+ description: Where each kind of file lives in a Zerotal app and how the framework wires those directories by convention.
4
+ ---
5
+
6
+ # Directory Structure
7
+
8
+ A freshly scaffolded Zerotal app organizes code into predictable directories, most
9
+ of which are auto-discovered and wired by convention so you rarely touch the
10
+ bootstrap files.
11
+
12
+ ```text
13
+ # project root
14
+ my-app/
15
+ ├── app/
16
+ │ ├── controllers/
17
+ │ ├── events/ ← event classes (auto-discovered)
18
+ │ ├── exceptions/
19
+ │ │ └── Handler.ts
20
+ │ ├── jobs/
21
+ │ ├── listeners/ ← event listeners (auto-discovered)
22
+ │ ├── middleware/
23
+ │ ├── models/ ← ORM models (auto-discovered)
24
+ │ ├── observers/ ← model observers (auto-discovered)
25
+ │ ├── policies/ ← authorization policies (auto-discovered)
26
+ │ ├── providers/
27
+ │ │ └── AppServiceProvider.ts
28
+ │ ├── flow/ ← Flow Pages (server-driven UI)
29
+ │ │ └── pages/
30
+ │ └── requests/ ← FormRequest validation classes
31
+ ├── bootstrap/
32
+ │ ├── app.ts ← Application bootstrap
33
+ │ └── providers.ts ← Provider registry
34
+ ├── config/
35
+ │ ├── app.ts
36
+ │ ├── database.ts
37
+ │ ├── mail.ts
38
+ │ └── ...
39
+ ├── database/
40
+ │ ├── migrations/
41
+ │ ├── seeders/
42
+ │ └── factories/
43
+ ├── docs/ ← Optional: serve with Router.markdown()
44
+ ├── public/ ← Static assets
45
+ │ └── uploads/
46
+ ├── resources/
47
+ │ └── views/ ← JSX / TSX view components
48
+ ├── routes/
49
+ │ └── index.ts ← Explicit route definitions
50
+ ├── tests/
51
+ │ ├── Feature/
52
+ │ └── Unit/
53
+ ├── .env
54
+ ├── .env.example
55
+ ├── bun.lockb
56
+ ├── package.json
57
+ └── zt.ts ← CLI entry point (don't edit)
58
+ ```
59
+
60
+ ## Key directories
61
+
62
+ ### app/
63
+
64
+ Application code lives here. Zerotal uses no magic autoloading — you import what
65
+ you need explicitly, so names and locations are entirely up to you.
66
+
67
+ **`app/controllers/`** — HTTP controller classes. Each method maps to a route
68
+ action. Name them freely; the framework just needs the class and method name at
69
+ `Router.get('/path', MyController, 'method')`.
70
+
71
+ **`app/exceptions/Handler.ts`** — your custom exception handler. Extends
72
+ `ExceptionHandler` from `zerotal`. Registered in `bootstrap/app.ts` via
73
+ `app.withExceptionHandler(Handler)`.
74
+
75
+ **`app/jobs/`** — background job classes for `@zerotal/queue`.
76
+
77
+ **`app/middleware/`** — custom middleware classes implementing `Pipe<HttpContext>`.
78
+
79
+ **`app/models/`** — ORM model classes extending `Model` from `@zerotal/orm`.
80
+ Auto-discovered at boot; the table name is derived by convention, so `@table` is optional.
81
+
82
+ **`app/providers/`** — service providers for registering custom bindings and
83
+ booting application services.
84
+
85
+ **`app/flow/pages/`** — Flow Component classes. When using file-based routing these
86
+ are scanned automatically and registered as reactive WebSocket routes.
87
+
88
+ **`app/requests/`** — FormRequest validation classes. Group by domain:
89
+ `app/requests/posts/StorePostRequest.ts`.
90
+
91
+ Providers, middleware, observers, policies, listeners, events, jobs, and validators
92
+ are all auto-discovered and wired by convention. Providers run their full lifecycle
93
+ without being listed in `bootstrap/providers.ts`; middleware registers as a named
94
+ group (reference it by class name, or set `static global = true`); observers and
95
+ policies attach by name; listeners bind via `static listens`; jobs and validators
96
+ self-register on import. No manual wiring — see
97
+ [Conventions](/docs/conventions).
98
+
99
+ ### bootstrap/
100
+
101
+ **`bootstrap/app.ts`** — the application singleton. Wires together exception
102
+ handling, global middleware, and opt-in conventions:
103
+
104
+ ```ts
105
+ // bootstrap/app.ts
106
+ import { Application } from "zerotal";
107
+ import { DevtoolsInjectionMiddleware } from "@zerotal/devtools";
108
+ import { Handler } from "../app/exceptions/Handler.ts";
109
+ import providers from "./providers.ts";
110
+
111
+ export default Application.create({ providers })
112
+ .withExceptionHandler(Handler)
113
+ .routing({ web: `${import.meta.dir}/../routes/index.ts` })
114
+ .fileBasedRouting({ web: `${import.meta.dir}/../app/routes` })
115
+ .use([DevtoolsInjectionMiddleware]);
116
+ ```
117
+
118
+ Auth resolves the session user automatically from your registered `AuthUser` model —
119
+ no `withUserResolver(...)` wiring. Override with `app.withUserResolver(...)` or
120
+ `AuthProvider.resolveUsing(...)` only for custom logic.
121
+
122
+ **`bootstrap/providers.ts`** — ordered list of provider classes. Registration
123
+ order matters: providers lower in the list can depend on bindings from providers
124
+ higher up.
125
+
126
+ > **Note** — Most providers are auto-discovered from `app/providers/`. Use
127
+ > `bootstrap/providers.ts` for the package providers you register explicitly and
128
+ > when registration order is load-bearing.
129
+
130
+ ### config/
131
+
132
+ Each file exports a typed config object (default export); an optional named
133
+ `validate(config)` export is run at startup. The `zt.ts` entry point loads the
134
+ whole directory synchronously with `configLoader("./config")` and injects it via
135
+ `app.useConfig(config.all())`. Access at runtime via the `Config` [facade](/docs/container#facades) — a static
136
+ accessor over a container binding — or typed
137
+ per-package helpers. App-wide auto-discovery settings live under the `conventions`
138
+ key of `config/app.ts` — see [Conventions](/docs/conventions)
139
+ and the [Config system](/docs/config-system) for the full loading flow.
140
+
141
+ ### database/
142
+
143
+ **`database/migrations/`** — migration files named `YYYY_MM_DD_HHMMSS_description.ts`.
144
+ Run with `bun zt migrate`.
145
+
146
+ **`database/seeders/`** — seeder classes for populating the database with
147
+ test or default data.
148
+
149
+ **`database/factories/`** — model factories used in tests and seeders.
150
+
151
+ ### public/
152
+
153
+ Files placed here are served directly as static assets. Register the directory
154
+ with `Router.static('/assets', './public/assets')` in `routes/index.ts`.
155
+
156
+ ### routes/index.ts
157
+
158
+ All explicit route registrations. This file runs after file-based routes are
159
+ scanned, so explicit routes take precedence over file routes for the same path.
160
+
161
+ ```ts
162
+ // routes/index.ts
163
+ import { Router } from "zerotal";
164
+ import { PostController } from "../app/controllers/PostController.ts";
165
+
166
+ Router.get("/posts", PostController, "index").name("posts.index");
167
+ ```
168
+
169
+ ### zt.ts
170
+
171
+ The universal CLI entry point managed by the framework. Do not edit.
172
+
173
+ ```bash
174
+ # in your project root
175
+ bun zt serve # start HTTP server
176
+ bun zt worker # start background worker
177
+ bun zt migrate # run pending migrations
178
+ bun zt route:list # list all routes
179
+ bun zt make:model # scaffold a model
180
+ bun zt list # all available commands
181
+ ```
182
+
183
+ ## File-based routing directory
184
+
185
+ If you call `app.fileBasedRouting({ web: "./app/routes" })`, that directory mirrors
186
+ the URL structure of your app. See the [Routing](/docs/routing) guide for full
187
+ details.
188
+
189
+ ```text
190
+ # app/routes/ — paths map to URLs
191
+ app/routes/
192
+ index.ts → GET /
193
+ about.ts → GET /about
194
+ users/
195
+ index.ts → GET /users
196
+ [id].ts → GET /users/:id, DELETE /users/:id
197
+ [id]/
198
+ posts.ts → GET /users/:id/posts
199
+ (api)/
200
+ _middleware.ts ← middleware for everything below
201
+ status.ts → GET /status
202
+ ```
203
+
204
+ ## Flow Pages directory
205
+
206
+ Flow Pages have their own directory under `app/flow/pages/` (or wherever you
207
+ point `fileBasedRouting`). The directory supports the same `(group)` and `[param]`
208
+ conventions as file-based routes. A `_middleware.ts` file in any subdirectory
209
+ applies to all Flow Pages below it.
210
+
211
+ ```text
212
+ # app/flow/pages/ — Flow routes
213
+ app/flow/pages/
214
+ (auth)/
215
+ _middleware.ts ← GuestMiddleware — only guests see these
216
+ login.tsx → /login
217
+ register.tsx → /register
218
+ (protected)/
219
+ _middleware.ts ← AuthMiddleware
220
+ dashboard.tsx → /dashboard
221
+ settings.tsx → /settings
222
+ index.tsx → /
223
+ ```
224
+
225
+ ## Next steps
226
+
227
+ - [Conventions](/docs/conventions) — how Zerotal wires these directories by name.
228
+ - [Config system](/docs/config-system) — how the `config/` directory is loaded.
229
+ - [Routing](/docs/routing) — define routes in `routes/index.ts`.
230
+ - [Lifecycle](/docs/lifecycle) — how `bootstrap/app.ts` boots the app.
@@ -0,0 +1,114 @@
1
+ ---
2
+ title: Support Policy
3
+ description: What Zerotal supports and for how long — Bun versions, databases, release cadence, maturity levels, and deprecation.
4
+ ---
5
+
6
+ # Support Policy
7
+
8
+ This page is the compatibility contract: which runtime and database versions
9
+ Zerotal stands behind, how releases and deprecations work, and what the maturity
10
+ label on each package promises. If a claim is not on this page, treat it as
11
+ untested.
12
+
13
+ ## Runtime
14
+
15
+ Zerotal runs on **Bun only**. Node.js and Deno are not supported and there is no
16
+ compatibility layer planned — the framework builds directly on `Bun.serve`,
17
+ `Bun.sql`, `Bun.CryptoHasher`, `Bun.RedisClient`, S3 storage, and the Bun test
18
+ runner, which is where its speed and its small dependency footprint come from.
19
+
20
+ The supported Bun range is what CI actually proves, not a hopeful floor:
21
+
22
+ | Bun version | Status |
23
+ | --------------------- | ------------------------------------------------- |
24
+ | 1.3.14 | Supported — the tested floor, pinned in CI |
25
+ | Latest stable release | Supported — CI tracks it alongside the floor |
26
+ | Older than 1.3.14 | Not supported — core APIs Zerotal uses are absent |
27
+
28
+ Every package declares this floor in its `engines.bun` field, so an install on
29
+ an unsupported Bun fails at install time rather than at runtime.
30
+
31
+ ### The platform-risk position
32
+
33
+ Betting on one runtime deserves a stated answer to "what if Bun changes
34
+ course?", so this is it:
35
+
36
+ - **Which Bun APIs are load-bearing:** `Bun.serve` (HTTP), `Bun.sql` (SQLite and
37
+ Postgres drivers), `Bun.RedisClient` (cache, session, queue, broadcasting),
38
+ `Bun.CryptoHasher` and `Bun.password` (crypto and hashing), `Bun.S3Client`
39
+ (storage), `Bun.build` (dev asset pipeline), and the `bun test` runner. A
40
+ breaking change in any of these is treated as a breaking change in Zerotal and
41
+ handled in a release, never silently.
42
+ - **How fast Zerotal tracks Bun:** CI runs the tested floor and the latest stable
43
+ Bun on every merge, so a Bun regression that affects the framework surfaces
44
+ within days of the Bun release, not when users hit it. The floor moves forward
45
+ deliberately — in minor releases, with the change called out in the release
46
+ notes.
47
+ - **Pinning guidance:** pin the Bun version in production images and move it
48
+ when you upgrade Zerotal, exactly as you would any other runtime.
49
+
50
+ ## Databases
51
+
52
+ | Database | Status |
53
+ | ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
54
+ | SQLite | Supported. The default; the full test suite runs against it on every merge. |
55
+ | PostgreSQL | Supported, hardening. The ORM suite runs against a real Postgres in CI; remaining dialect gaps are being driven to zero before the job blocks merges. |
56
+ | MySQL | Experimental. The ORM ships a MySQL dialect and the scaffolder can configure it, but no CI suite runs against a real MySQL server yet — treat it as unverified until it joins the tested matrix. |
57
+
58
+ Redis-backed drivers (cache, session, queue, broadcasting) build on
59
+ `Bun.RedisClient` and are tested against the protocol surface it provides.
60
+
61
+ ## Releases and versioning
62
+
63
+ All `@zerotal/*` packages and `create-zerotal` share **one version line and
64
+ publish lockstep** — a release publishes every package at the same version, in
65
+ dependency order, from CI. Never mix versions across packages.
66
+
67
+ - **Semantic versioning:** patch for fixes, minor for compatible features, major
68
+ for breaking changes. The [Upgrade Guide](/docs/upgrade) describes the upgrade
69
+ procedure; the [Release Notes](/docs/changelog) list what changed.
70
+ - **Provenance:** packages are published with npm provenance, so you can verify
71
+ a tarball was built by this repository's release workflow rather than someone's
72
+ laptop.
73
+ - **Cadence:** releases ship when they are ready rather than on a calendar.
74
+ Security fixes are released out of band — see the response windows in
75
+ [SECURITY.md](https://github.com/zerotaldev/zerotal/blob/main/SECURITY.md).
76
+ - **Supported versions:** fixes land on the latest minor of the current major.
77
+ There is no long-term-support line yet; one will be declared when the project's
78
+ adoption warrants maintaining two lines honestly rather than nominally.
79
+
80
+ ## Maturity levels
81
+
82
+ Each package declares a `maturity` field in its `package.json`, and the label is
83
+ a contract, not a mood:
84
+
85
+ - **stable** — the public API follows SemVer strictly. Anything importable that
86
+ does not carry an `@internal` marker is covered by the compatibility promise,
87
+ and its shape is snapshotted in the package's `api-surface.md`, which CI diffs
88
+ on every change.
89
+ - **beta** — the API is close to final and breaking changes are rare, called out
90
+ in release notes with migration steps, but a minor release may still contain
91
+ one. Production use is reasonable if you read release notes before upgrading.
92
+ - **experimental** — no compatibility promise. The API may change or the package
93
+ may be absorbed into another in any release. Build on it with your eyes open.
94
+
95
+ A package is never more mature than what it is built on: a stable package whose
96
+ foundation can change under it is not stable, whatever its own label says. So
97
+ `@zerotal/admin` and `@zerotal/monitor` cannot pass `@zerotal/flow`, and the
98
+ maturity of your app is the lowest level among the packages it actually uses.
99
+
100
+ ## Deprecation policy
101
+
102
+ In stable packages, an API is never removed in the release that deprecates it:
103
+ deprecation lands in a minor release (a `@deprecated` marker with the
104
+ replacement named, and a runtime warning where one is practical), the API keeps
105
+ working for the remainder of the major line, and removal happens at the next
106
+ major. Release notes list every deprecation and every removal.
107
+
108
+ ## Getting help
109
+
110
+ - **Bugs and feature requests** — [GitHub issues](https://github.com/zerotaldev/zerotal/issues).
111
+ - **Security vulnerabilities** — privately, per
112
+ [SECURITY.md](https://github.com/zerotaldev/zerotal/blob/main/SECURITY.md);
113
+ never in a public issue.
114
+ - **Contributing** — the [Contribution Guide](/docs/contributing).