@dokebi/cli 0.4.52 → 0.4.53
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/AI.md +3 -2
- package/catalog.json +6 -6
- package/dist/capability-guide.js +2 -2
- package/dist/check/browser-sources.d.ts +9 -3
- package/dist/check/browser-sources.js +27 -9
- package/dist/check/index.js +8 -5
- package/dist/check/problems.d.ts +7 -1
- package/dist/check/problems.js +22 -1
- package/dist/check/shared-folder-rules.d.ts +3 -0
- package/dist/check/shared-folder-rules.js +49 -0
- package/dist/check/vite-rules.js +1 -1
- package/dist/generator.d.ts +8 -1
- package/dist/generator.js +15 -1
- package/dist/layout.d.ts +8 -0
- package/dist/layout.js +17 -0
- package/dist/output.d.ts +1 -1
- package/dist/output.js +1 -1
- package/package.json +1 -1
package/AI.md
CHANGED
|
@@ -84,7 +84,7 @@ The `blog` plan, depending on the answers: `init` (when the folder is not a proj
|
|
|
84
84
|
| `dokebi describe [--with-db] [--timeout-ms <ms>]` | What the app has, without serving (D-0077): it loads the project like `start` (the settings file — `DOKEBI_CONFIG`, else dokebi.yaml —, `src/dokebi.generated.ts`, the project's `.env` under the environment, the doctor check first: `START_CHECK_FAILED`) in core's describe mode: every plugin's setup runs, no start or ready hook, so nothing listens, no database, Redis or NATS connection is opened and no job is bound. `--json` is `{ schemaVersion: 1, app: { name, core, plugins[{name, version, described}], apps[], domains[], unknownDomain, web, session, csrf, auth, … }, routes[{method, url, id?, app?, host?, constraints?, schema?{body, querystring, params, headers, response}, config?{auth, can, roles, csrf, …}, auth?{mode, realm, via, can?}, seal?, health?}], pages[{app, engine: ejs\|inertia, template, name, file}], jobs[], schedules[], errors[{code, status, message, hint?}], config: { keys[], env[{name, plugin, purpose}] }, db: { connections[{name, adapter, startup?, dialect?, schemas?, tables?, collections?, unavailable?}], unavailable? }, unavailable[{plugin, section?, code, reason}], warnings?, ms }`, checked by the JSON Schema `describe.schema.json` of this package. `route.auth` is the login rule @dokebi/auth applies (its `default` included); `config.keys` are option paths and `config.env` variable names, **never a value**; `errors` are the codes of `src/shared/errors.ts`. A plugin whose setup fails is listed in `unavailable` (with the plugins that need it, `DEPENDENCY_UNAVAILABLE`) and the rest is still described; a database, Redis, NATS, SMTP or S3 that is not running is never the reason (D-0133: plugins on never-connected clients still set up; a nats event bus refuses only `publish`, with `DESCRIBING`), while a real configuration error (an unknown connection name, a connection of the wrong kind) still is. Without `--with-db` the tables are not read (`db.unavailable` says so; describe mode never connects). **`--with-db`** adds a separate step that connects: for each dokebi-db connection it runs the project's `dokebi-migrate schema --connection <name> --json` (@dokebi/migrate 0.4.2) and puts its `dialect` and `tables` (columns with type, nullable, default, identity, generated; primary key, unique, indexes, foreign keys, checks; `isMigrationHistory` on `dokebi_migrations`) or MongoDB `collections` into `db.connections[]`; a connection it cannot read (not listed in `options.dokebi-migrate.connections`, @dokebi/migrate missing, the database refused, `--timeout-ms` passed) gets its own `unavailable` reason and describe still answers. `startup: 'optional'` marks a connection dokebi.yaml lets the app run without ([D-0127](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0127-optional-db-startup.md); the default `required` is left out); `dokebi-migrate schema` opens it as required, so while it is down it is `unavailable` with the open or check error, and `drift` lists it in `unavailable`. No URL or password is printed. Run it before writing a migration so you change what the database really has. Errors: `DESCRIBE_TIMEOUT` (default 30000 ms), `DESCRIBE_FAILED` (the app exited first; `details.output` holds its last lines), `DESCRIBE_UNSUPPORTED` (@dokebi/core older than 0.4.2), or the app's own code (`INVALID_PLUGIN_OPTIONS`, …). Read it before you change an app you did not write |
|
|
85
85
|
| `dokebi describe --openapi [--app <name>]` | OpenAPI 3.1 of the same description (D-0077 C), **one document per app** (route ids are unique per app): `info.title` the app, `servers` its domains (`http://<host>:<port>` for local hosts, `https://<host>` otherwise), `operationId` the route `config.id` (`<id>_<method>` on every operation when the id names several: a route of several methods, or the routes of one plugin route key such as `oauth.authorize_get` and `oauth.authorize_post`, D-0142), else `<method>_<path>` (`get_posts_id`), numbered `_2` on a collision. Request parameters and bodies (JSON, and form bodies with `formBody`) and responses come from the route schemas (draft-07 `items` tuples, `dependencies`, `nullable` and local `#/definitions` refs rewritten for JSON Schema 2020-12; a ref to an `addSchema` schema becomes an open schema with `x-dokebi-ref`). `components.schemas.DokebiError` is the D-0074 body; operations list 422 `VALIDATION_FAILED` (body or query schema), 400 `INVALID_REQUEST` (params or headers schema), 401 `UNAUTHENTICATED` (a login needed), 403 `FORBIDDEN` (`roles` or `can`) and 403 `CSRF_FAILED` (POST, PUT, PATCH, DELETE under @dokebi/csrf unless `config.csrf: false` or `exclude`, with the token header). Security: `cookieAuth` (the session cookie) and `bearerAuth` (`via: token` or `any`), `{}` added for `optional`; `x-dokebi-auth` keeps `{ mode, realm, via, roles?, can? }` (also `routes[].auth.roles` in `--json`). Health and Vite dev routes are left out; routes outside apps are in every app's document. The app's `defineErrors` codes are `x-dokebi-errors`. Without `--app` and with several apps: `{ apps: { <name>: document } }`; an unknown name is `UNKNOWN_APP`. Without `--json` the document is printed as JSON |
|
|
86
86
|
| `dokebi drift --expected <file> [--timeout-ms <ms>]` | The databases against an expected file (D-0120): `<file>` is JSON of the describe shape, written by hand or by a design tool (only `db.connections` is read; a whole `describe --with-db --json` envelope works too). The actual side is `describe --with-db` (it connects the same way). Only what the file names is compared: each connection, its `tables` (or MongoDB `collections`) when the file lists them, a table's `columns` when it lists them, and a column's `comment` when it is a non-empty string (empty, `null` or absent means "not decided" and is not compared; whitespace runs and the ends are normalized). `--json` is `{ ok, drift[{kind, connection, target, expected_value, code_value}], unavailable[{connection, reason}], compared{connections, tables, columns, comments}, ms }`; `kind` is `connection`, `table`, `collection`, `column` or `column_comment`; `target` is the connection, `<table>` (`<schema>.<table>` outside the first PostgreSQL schema) or `<table>.<column>`; `expected_value` null = only the database has it, `code_value` null = the database has it not (for `column_comment`: no comment). `dokebi_migrations` is never compared. A connection that cannot be read is in `unavailable` and nothing is compared for it. `ok` only without drift and unavailable connections (otherwise exit 1). A comment comes from the migrations: PostgreSQL `COMMENT ON COLUMN <table>.<column> IS '<text>'` (`IS NULL` removes it), MySQL and MariaDB `COMMENT '<text>'` in the column definition (`ALTER TABLE … MODIFY` repeats the whole definition); `describe --with-db` shows it as `columns[].comment`. MongoDB has no column comments. Errors: `DRIFT_EXPECTED_INVALID` (the file cannot be read, is not JSON or not of the describe shape; `details.path`), and those of describe |
|
|
87
|
-
| `dokebi check` | User-code conventions (D-0072). `{ ok, problems[{rule, severity?, file, line, message, fix}], allowed[{rule, file, line, reason}], files, rules, typescript, ms: { total, typescript } }` (`allowed`: every `// dokebi-check: allow <rule> <reason>` marker with a reason under `src/`, the problems silenced on purpose; the human output prints one `allowed` line each, and verify ok asks the final message to list them), exit 1 on a problem (a `severity: 'warning'` problem is reported but never fails: `ok` stays true). The human output prints `file:line rule message` and a `fix:` line per problem, then a summary (`check ok` or `check FAILED: N problems`, files, time). Rules: `empty-catch` (an empty `catch`, `.catch(() => {})`, an empty onRejected of `then`, an empty `on('error', …)`, and the same handlers when they only give back nothing: `() => undefined`, `() => null`, `() => void 0`, `{ return; }`; a fallback value such as `() => false` is not flagged), `missing-cause` (a `catch` that throws a new error and never reads the one it caught — `catch { throw new X() }`, `catch { throw fail() }` (a call that makes the error counts the same) or a named error left unused: the original message and stack are lost; fix `catch (error) { throw new X(…, { cause: error }) }`; a destructured binding counts as read, and throws inside nested functions are not the catch's; D-0118), `floating-promise` (a statement that calls something returning a Promise without await, return, `void` or `.catch`; the project's TypeScript decides the type; `test()` of node:test is exempt), `non-erasable-syntax` (enum, namespaces with values, parameter properties, decorators, `import x =`, `export =`, `<T>x`), `private-import` (a path of `@dokebi/*` outside its exports, such as `@dokebi/core/dist/…`), `missing-package` (an @dokebi package that is not installed → `add`; a feature Dokebi does not have → the absent `instead`; an unknown name), `generated-file` (doctor `MODIFIED_REGISTRATION`, `GUIDE_BLOCK_MODIFIED` and `MODIFIED_TEMPLATE` of CLI-owned files), `secret-in-config` (an option the plugin schema marks secret (`writeOnly`, such as `dokebi-session.secrets`), a plugin check `SECRET_IN_CONFIG`, or any dokebi.yaml value that is a URL with a password such as `postgres://user:password@host`, while dokebi.yaml could be committed; the value is never shown). Warning (D-0074): `inertia-form-only` — an Inertia form submit (`form.post/put/patch/delete/submit(…)` of a `useForm(…)` result, `router.post/put/patch/delete(…)`) whose options are missing or an object literal without `only`; the GET after its redirect would send every prop of the page again. Fix: `form.post(url, { only: ['<props it changes>'] })` (`errors` always comes along). It reads the text of `src/**` files that import `@inertiajs/` (the `<script>` blocks of .vue and .svelte files; comments and strings masked); calls inside a template attribute are not read, and options passed as a variable or with a spread are taken as fine. Security rules (D-0076 §6), on only when their plugin is installed: `plain-password-compare` (an error, with @dokebi/auth) — a value whose name has the word password, passwd, passphrase, pass, pw or pwd compared with `===`, `!==`, `==` or `!=` (not with `''`, `null`, `undefined`, a boolean, a number or `typeof`, and not a password with its confirmation field such as `passwordConfirm` and not two values that both come from the request input, such as `next !== body.confirmPassword` where `next` was read from `body`: a field of `body`, `query`, `params` or a form, or a local made from one; a typed value against a stored one, such as `body.password !== user.passwordHash` (a hash, a field of a user, row, account or credentials object, or a local loaded from one) stays an error), or passed to node:crypto `timingSafeEqual`, `scrypt`, `pbkdf2`, `argon2`, the `update()` of `createHash`/`createHmac`, or a `bcrypt`/`argon2` package; fix: `request.auth.attempt` and `passwords.verify`/`passwords.hash`. `form-without-csrf` (a warning, with @dokebi/csrf) — an EJS `<form method="post">` (any case) without `csrf.field` (also `csrf?.field`) or a `_csrf` field up to its `</form>` (a multipart form may carry `?_csrf=` in its action); fix: `<%- data.csrf.field %>`; EJS is read as text, so a form split over includes is not seen as one. `csrf-exempt-unverified` (a warning, with @dokebi/csrf) — a route `config: { csrf: false }` whose registration call (and its handler functions named in the same file) shows no `rawBody`, signature check (`signature`, `createHmac`, `timingSafeEqual`, `.verify(`), `seal` or @dokebi/auth token refresh (`tokens.refresh(`), and whose `config` has no `oauth` and no `auth: { via: 'token' }` (Bearer only; `via: 'any'` or `'session'` does not count); fix: send the token, or verify the sender. `unknown-error-code` (a warning, [D-0077](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0077-app-self-description.md) D, only when `src/shared/errors.ts` exports a `defineErrors({ … })` result written as an object literal) — app code under `src/apps/` or `src/shared/modules/` that writes an error code as a string: `new DokebiError('CODE', …)`, `Object.assign(new Error(…), { code: 'CODE' })`, `throw { code: 'CODE' }` or `.send({ error: 'CODE' })`. A code missing from the list is unknown (fix: add it to the list and throw `errors.CODE()`), a listed one is written by hand (fix: `throw errors.CODE()`, with the import path from that file). The codes of web, auth and csrf answers (`VALIDATION_FAILED`, `NOT_FOUND`, `INVALID_REQUEST`, `INTERNAL_SERVER_ERROR`, `UNAUTHENTICATED`, `FORBIDDEN`, `CSRF_FAILED`) are fine. The list is read from the file's syntax tree, never by running it; a spread or a computed key turns the rule off. Background work ([D-0103](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0105-check-background-timers-and-structure.md) §1): `background-timer` (an error) — server code under `src/` (not `views/` or `public/`; tests are not read) that runs periodic work on its own timer instead of @dokebi/scheduler and @dokebi/job: any `setInterval` (global, `node:timers`, or the async iterator of `node:timers/promises`), and a `setTimeout` or `setImmediate` whose callback comes back to a function around the call through the functions and methods of the same file (`const tick = () => { …; setTimeout(tick, ms) }`, `#schedule() { setTimeout(() => this.#tick()) }` with `#tick` calling `#schedule`). Fine: one-shot delays and time limits (`setTimeout(() => controller.abort(), ms)`, `new Promise((resolve) => setTimeout(resolve, ms))`), awaited sleeps of `node:timers/promises` (`await setTimeout(ms, undefined, { signal })` between bounded batches of a job handler), and timers inside a function that takes a `request`, `req`, `reply`, `res`, `response`, `socket`, `ws`, `websocket` or `stream` parameter or is passed to a route method (`get`, `post`, …, `route`), unless the timer is stored where it outlives that function: `this.ticker = setInterval(…)` (also `??=`, `||=`) or a variable declared outside it is reported (one worker-wide timer the first request starts). Fix: a job handler registered in the setup of the module that owns the work (`queue(<queue>).handle(<type>, …)`) and an entry of `options.dokebi-scheduler.schedules`. Structure warnings (D-0103 §2–§3): `responsibility-size` — a model (`…/models/…`) with at least 400 code lines (blank and comment-only lines do not count) over at least 8 tables or collections (names after FROM, JOIN, INTO and UPDATE in SQL text, CTE names and upsert columns excluded; Mongo `.collection('x')` and a local helper that wraps it; Kysely `selectFrom`/`insertInto`/`updateTable`/`deleteFrom`), a controller with at least 20 route handlers (public methods and function-valued fields) or 300 code lines, and a service class with at least 5 methods that only pass their parameters on to one call on a field (`return this.model.list(user, filter)`) when they are at least 60% of its methods; files whose first lines say `@generated`, `generated by` or `do not edit` are not read. `memory-filtered-page` — in a model or service, rows an awaited query returned that are skipped by comparing a field of the row with an input of the function and then cut to a page (`for (const row of rows) { if (row.status !== filter.status) continue; …; if (page.length === size) break; }`, or `rows.filter((row) => row.org === input.org).slice(…)`); fix: the filter in the query's WHERE with an index that ends in the sort key, and LIMIT the page size + 1. A search that checks its other terms on a capped candidate set (@dokebi/db AI.md 6.10) compares no input and is not matched; the rule sees only these two shapes, so a clean result does not prove the lists are paged in the database. Dev files ([D-0129](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0129-inertia-dev-file-policy.md)): `vite-dev-files` (a warning, in a project with an Inertia app or @dokebi/template-inertia) — the `vite.config.*` does not use `dokebiInertia()` (a plain `vite` then serves the whole project root: dokebi.yaml, .env, the server code), sets `server.fs.strict: false`, sets `server.fs.deny` (a list of its own replaces Vite's defaults where the framework's policy does not run), or an `allow` list names the project root or server code (`'.'`, `'src'`, `'tests'`, `'scripts'`, `'tools'`, `process.cwd()`, `__dirname`, `searchForWorkspaceRoot(…)`); fix: keep `dokebiInertia()` and drop `server.fs`, add browser folders with `dokebiInertia({ allow: [...] })` and entries with `dokebiInertia({ deny: [...] })`. @dokebi/template-inertia enforces the policy anyway (strict on, its deny entries kept); `formatter-migrations` (a warning, D-0145, when the migrations folder `<dokebi-migrate directory>/migrations` exists) — a code formatter of the project would format it: prettier (a config, a `prettier` key or dependency in package.json) without the folder in `.prettierignore`, biome without `!<folder>` in `files.includes` (biome 1: the folder in `files.ignore`), ESLint with formatting rules (eslint-plugin-prettier, `@stylistic`) whose config does not name it; an applied migration must keep its contents (a reformat is warned as `MIGRATE_REFORMATTED` by @dokebi/migrate, an edit refused); fix: the ignore entry the problem names (`npx dokebi add` writes it for prettier and biome); the rule says that the config asks for less. `formatter-generated` (a warning, R1 measurement) — the same formatters would format `src/dokebi.generated.ts`, which the CLI writes and compares with its record: a reformatted copy is doctor `MODIFIED_REGISTRATION` and add, upgrade and remove refuse to run; fix: `src/dokebi.generated.ts` in `.prettierignore`, `"!src/dokebi.generated.ts"` in biome `files.includes` (`npx dokebi add` writes both). `asset-in-views` (a warning, R1 measurement) — a browser file (a style sheet, an image, a font) in the views of an EJS app (`src/apps/<app>/views/`; an Inertia app with `views/app.js` is not read): move it to `src/apps/<app>/public/` and link `/assets/<path>`, which @dokebi/app serves through @dokebi/static. `asset-route` (a warning, R6 measurement) — a GET or HEAD route of server code (a `get` or `head` call with a path and a handler; a lookup by one key such as `manifest.get('main.css')` is none) for a browser file (`.css`, an image, a font): its path is a fixed file name (`/site.css`), or ends in such an extension and its handler reads a file itself (`createReadStream`, `readFile`, `readFileSync`); such a route sends the file without the validator, 304 and Range of `public/`; fix: put the file in `src/apps/<app>/public/` (a file a package ships, such as a font of @dokebi/font-noto-kr, is copied there with its licence file) and link `/assets/<path>`; a file the route makes per request takes `// dokebi-check: allow asset-route <reason>`. `seal-head-copied` (a warning, R7 measurement; only with @dokebi/app) — a file under `src/` (`.ts`, `.js`, `.mjs`, `.ejs`, `.html`; not in a comment) that loads `/dokebi/seal/forms.mjs` itself, a copied seal `<script>` or import map: write `<%- data.seal?.head ?? '' %>` in the layout of an app page, and for a page rendered outside an app route (an oauth consent page) take `context.getDependency(apps).seal(request).head` (`AppGroupApi` of @dokebi/app ^0.4.5, empty on a plain host); a page that is no app page takes `// dokebi-check: allow seal-head-copied <reason>`. `i18n-missing-key` (a warning, community request A2; only with @dokebi/i18n and `src/shared/locales/`) — a fixed translation key a page or server code asks for (`t('ns.a.b')`, `$t(…)`, `request.i18n.t(…)` in `.vue`, `.ts`, `.js`, `.ejs` under `src/`; the first part a namespace of the catalogs) that the catalogs of the default locale (`dokebi-i18n.defaultLocale` of dokebi.yaml, `en`) lack — the end of every fallback chain, so @dokebi/i18n throws `MISSING_MESSAGE` for it (everywhere but under `npx dokebi dev`) in each locale without it; a key only the default locale has falls back and is not reported; keys built at run time, keys with an explicit default (`t('k', 'Text')`) and lines in a comment are not read; locale folders and the default locale are read as @dokebi/i18n reads them (`Intl.Locale(name).baseName`: a folder `en-us` is the locale `en-US`), and a catalog that is not JSON or a folder that is no locale (or a second folder of one locale) is reported; fix: add the key to `src/shared/locales/<default locale>/<namespace>.json`; a key another catalog provides takes `// dokebi-check: allow i18n-missing-key <reason>`. With catalog layers (D-0181) code under `src/apps/<app>/` is checked against that app's layer, the modules and the shared catalogs, other code against the modules and the shared ones. `i18n-layer-override` (a warning) — one key in one language in two layers: an app's `src/apps/<app>/locales/` over a module's `src/shared/modules/<module>/locales/` or the shared `src/shared/locales/`, a module's over the shared ones, or two modules (the first by name wins, always reported); fix: list an intended override in the overriding file's top-level `"$overrides": ["key", …]` (keys inside the namespace), otherwise rename the key or remove it from one layer; a listed key that overrides nothing is reported too. `i18n-layer-missing` (a warning) — a layer gives keys in one language and lacks them in another language of the project, one problem per layer, language and namespace; fix: add them to that file or remove them from the layer's other languages. `shared-state-memory` (an error, [D-0161](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0161-shared-state-redis.md)) — `options.application-runtime.workers` above 1 while an installed plugin keeps the state its workers share in process memory: the dokebi-session store, dokebi-auth `tokens` or `throttle.store`, the dokebi-oauth store, the dokebi-rate-limit driver (`local`), dokebi-seal `nonces` that are not shared, or a dokebi-websocket-hub not in `mode: cluster`; the plugins refuse to start that way in a cluster worker and in production. Fix: `{ driver: redis, connection: <the project's dokebi-redis connection> }` for each (`npx dokebi add @dokebi/redis` first when there is none); the problem's line is that option in dokebi.yaml. `console-output` (a warning, D-0151) — server code under `src/` (not `views/` or `public/`) that calls `console.log`, `console.info`, `console.warn`, `console.error`, `console.debug`, `console.trace`, `process.stdout.write` or `process.stderr.write`: those lines skip the logger level, the redaction and the targets (the rotated files, the JSON lines `dokebi logs` reads); fix: `context.logger.log(level, 'Fixed message', { code, … })` in a plugin or module hook, `app.logger` in `src/main.ts`. A command line tool of the project that prints its results takes `// dokebi-check: allow console-output <reason>` before its first statement (it covers the whole file), or on or above one line. The framework's own sources pass the same rule as the `check:console` gate. `polling-loop` (an error no marker silences, AI-M35) — a loop that sleeps inside a task started in the background (an immediately invoked async function, or a function the file calls without awaiting or returning it), such as `(async () => { while (!stopped) { await step(); await sleep(ms); } })()` in a module's `start`: move it to an @dokebi/outbox handler (one coalesced item per owner and window) or a @dokebi/job handler with a schedule; per-process upkeep uses a timer (`background-timer` with a marker), never a sleeping loop. A `setInterval` or self-rescheduling timer whose callback reaches database work (a `query`, `execute` or `transaction` call, or a call on a model, repository, pool, client, transaction or outbox object, through the functions of the same file) is reported as `polling-loop` too, marker or not. `in-process-queue` (a warning, AI-M35) — the resolve of a `new Promise` stored in a collection (`.push`, `.unshift`, `.set`, `.add`), directly or through a variable that holds it (`const pending = { input, resolve }`), to be called later: callers wait in a queue of one worker without a bound or deadline; send the work at once and let the pool's `waitTimeoutMs` bound the wait (503 with Retry-After). `wait-count-refusal` (a warning, @dokebi/db AI.md 1.2 and 6.4) — server code under `src/` that compares how many callers wait for a pool connection with a number (pg `pool.waitingCount`, mariadb `pool.taskQueueSize()`, MongoDB `waitQueueSize`, mysql2 `pool._connectionQueue.length`): the count of waiters is not overload, so refusing on it refuses work the database can still do; fix: bound the wait by its deadline (`waitTimeoutMs`, then 503 with Retry-After) and shed a tenant by time, not by waiters; a metric or log line that only reports the number takes `// dokebi-check: allow wait-count-refusal <reason>`. `private-pool` (an error, AI-M37) — server code under `src/` outside `src/infra/db/` that makes a database pool or client with the driver itself (`new Pool`/`new Client` of `pg`, `createPool`/`createConnection`/`createPoolCluster` of `mysql2` and `mariadb`, `new MongoClient` of `mongodb`): it escapes dokebi.yaml (its size and `waitTimeoutMs`, past which the caller gets 503 with Retry-After), the connection sum and the cleanup at stop (M37: private pools with a 30 s wait held callers for 22–51 s); fix: the configured connection (`context.getDependency(db).connection(main)`), `derive('main', { purpose, overrides: { max } })` for a pool of one kind of work, or one more connection in dokebi.yaml; a connection that must stay outside (a LISTEN client) takes `// dokebi-check: allow private-pool <reason>`. `overload-off` (an error, AI-M37) — a route `config: { overload: false }`: under a burst its callers queue behind a stalled worker instead of getting 503 `OVERLOADED` with Retry-After (@dokebi/web AI.md 2.5); fix: remove it (raise `overload.maxEventLoopDelayMs` if it refuses too early); a metrics scrape or an operator status page takes `// dokebi-check: allow overload-off <reason>`. `readiness-off` (an error, M51) — a route `config: { readiness: false }`: it is served while a required dependency is down and while the app drains, so an API route runs its handler against a missing database or Redis; fix: remove it; a metrics scrape or status page that must answer during an outage takes `// dokebi-check: allow readiness-off <reason>`. `fixed-owner-cap` (a warning, AI-M37) — a per-owner count of requests in progress (a Map entry that goes up and down by one, read into a variable) compared with a fixed limit by an `if` that throws or returns, without a free or idle connection in the condition: it refuses work while the database is idle; fix: the owner share of @dokebi/db, `share(main).enter(owner)`, which refuses only while the pool is full (@dokebi/db AI.md 6.4, D-0156); a budget that bounds something else (the report CPU budget of db AI.md 6.9, a plan's quota) takes `// dokebi-check: allow fixed-owner-cap <reason>`. `undeclared-section` (a warning, D-0155) — a section of dokebi.yaml nothing declares (code reads `options.<name>` by hand); fix: `npx dokebi settings add <name>`. `template-fix-missing` (a warning) — doctor's `TEMPLATE_FIX_MISSING` and `RELOAD_NOT_WIRED`: a copied template file lacks a later fix, or an entry passes no `configFile`; fix: doctor's hint. `module-point-not-installed` (D-0130) — a point in `contributes` of `defineModule` imported from an `@dokebi/*` plugin package that is in node_modules but not installed in the project (`dokebi add`): nothing registers its collector, so the app drops the values (warn `POINT_NOT_COLLECTED`); fix: `npx dokebi add <package>` or remove the point (a plugin you register yourself takes the allow marker with a reason). When an empty catch, a background promise, a full-page form submit (a login) or one of the security cases is really intended, put `// dokebi-check: allow <rule> <reason>` on that line or the line above (EJS: `<%# dokebi-check: allow form-without-csrf <reason> %>` on the line above the form; only `empty-catch`, `missing-cause`, `floating-promise`, `inertia-form-only`, `unknown-error-code`, the three security rules, the two mail warnings, the three D-0103 rules, `untyped-browser-import`, `vite-dev-files`, `module-point-not-installed`, `asset-route`, `seal-head-copied`, `i18n-missing-key`, `console-output`, `wait-count-refusal`, `in-process-queue`, `fixed-owner-cap`, `private-pool` and `overload-off` — for example a per-process eviction of in-memory state that no job can reach; without a reason the marker is ignored). The sources are the program of `tsconfig.json` (generated files, `.d.ts` and node_modules excluded), read with the API of the TypeScript 7 installed in the project (`typescript/unstable/sync`). Browser code outside that program is read too (D-0120): the `<script>` and `<script setup>` blocks (`lang` ts or js) of every `.vue` file under `src/`, and the `.js`/`.mjs` files under a `views/` folder (files above 1 MiB are skipped). They get `empty-catch`, `missing-cause` and `floating-promise` only, typed by a second program that extends `tsconfig.json` but resolves imports as the bundler does (`moduleResolution: bundler`, `module: esnext`, the DOM in `lib`; relative imports resolve from the file's folder). An import whose bound names all have no type (the module did not resolve) is the warning `untyped-browser-import` on its line, since floating-promise cannot judge what comes from it; an import of a `.vue`, style, image or JSON file and `import type` are not judged; a module that really has no types takes `// dokebi-check: allow untyped-browser-import <reason>`, and the problems name the `.vue` or `.js` file and its line; the markers work the same inside a script block. A browser promise left floating is an unhandled rejection the page never handles: `await` it, or end it with `.catch(error => …)` that shows or reports the error. When it cannot be loaded `TYPESCRIPT_UNAVAILABLE` (`npm install`), when tsconfig cannot be opened `TSCONFIG_INVALID` |
|
|
87
|
+
| `dokebi check` | User-code conventions (D-0072). `{ ok, problems[{rule, severity?, file, line, message, fix}], allowed[{rule, file, line, reason}], files, rules, typescript, ms: { total, typescript } }` (`allowed`: every `// dokebi-check: allow <rule> <reason>` marker with a reason under `src/`, the problems silenced on purpose; the human output prints one `allowed` line each, and verify ok asks the final message to list them), exit 1 on a problem (a `severity: 'warning'` problem is reported but never fails: `ok` stays true). The human output prints `file:line rule message` and a `fix:` line per problem, then a summary (`check ok` or `check FAILED: N problems`, files, time). Rules: `empty-catch` (an empty `catch`, `.catch(() => {})`, an empty onRejected of `then`, an empty `on('error', …)`, and the same handlers when they only give back nothing: `() => undefined`, `() => null`, `() => void 0`, `{ return; }`; a fallback value such as `() => false` is not flagged), `missing-cause` (a `catch` that throws a new error and never reads the one it caught — `catch { throw new X() }`, `catch { throw fail() }` (a call that makes the error counts the same) or a named error left unused: the original message and stack are lost; fix `catch (error) { throw new X(…, { cause: error }) }`; a destructured binding counts as read, and throws inside nested functions are not the catch's; D-0118), `floating-promise` (a statement that calls something returning a Promise without await, return, `void` or `.catch`; the project's TypeScript decides the type; `test()` of node:test is exempt), `non-erasable-syntax` (enum, namespaces with values, parameter properties, decorators, `import x =`, `export =`, `<T>x`), `private-import` (a path of `@dokebi/*` outside its exports, such as `@dokebi/core/dist/…`), `missing-package` (an @dokebi package that is not installed → `add`; a feature Dokebi does not have → the absent `instead`; an unknown name), `generated-file` (doctor `MODIFIED_REGISTRATION`, `GUIDE_BLOCK_MODIFIED` and `MODIFIED_TEMPLATE` of CLI-owned files), `secret-in-config` (an option the plugin schema marks secret (`writeOnly`, such as `dokebi-session.secrets`), a plugin check `SECRET_IN_CONFIG`, or any dokebi.yaml value that is a URL with a password such as `postgres://user:password@host`, while dokebi.yaml could be committed; the value is never shown). Warning (D-0074): `inertia-form-only` — an Inertia form submit (`form.post/put/patch/delete/submit(…)` of a `useForm(…)` result, `router.post/put/patch/delete(…)`) whose options are missing or an object literal without `only`; the GET after its redirect would send every prop of the page again. Fix: `form.post(url, { only: ['<props it changes>'] })` (`errors` always comes along). It reads the text of `src/**` files that import `@inertiajs/` (the `<script>` blocks of .vue and .svelte files; comments and strings masked); calls inside a template attribute are not read, and options passed as a variable or with a spread are taken as fine. Security rules (D-0076 §6), on only when their plugin is installed: `plain-password-compare` (an error, with @dokebi/auth) — a value whose name has the word password, passwd, passphrase, pass, pw or pwd compared with `===`, `!==`, `==` or `!=` (not with `''`, `null`, `undefined`, a boolean, a number or `typeof`, and not a password with its confirmation field such as `passwordConfirm` and not two values that both come from the request input, such as `next !== body.confirmPassword` where `next` was read from `body`: a field of `body`, `query`, `params` or a form, or a local made from one; a typed value against a stored one, such as `body.password !== user.passwordHash` (a hash, a field of a user, row, account or credentials object, or a local loaded from one) stays an error), or passed to node:crypto `timingSafeEqual`, `scrypt`, `pbkdf2`, `argon2`, the `update()` of `createHash`/`createHmac`, or a `bcrypt`/`argon2` package; fix: `request.auth.attempt` and `passwords.verify`/`passwords.hash`. `form-without-csrf` (a warning, with @dokebi/csrf) — an EJS `<form method="post">` (any case) without `csrf.field` (also `csrf?.field`) or a `_csrf` field up to its `</form>` (a multipart form may carry `?_csrf=` in its action); fix: `<%- data.csrf.field %>`; EJS is read as text, so a form split over includes is not seen as one. `csrf-exempt-unverified` (a warning, with @dokebi/csrf) — a route `config: { csrf: false }` whose registration call (and its handler functions named in the same file) shows no `rawBody`, signature check (`signature`, `createHmac`, `timingSafeEqual`, `.verify(`), `seal` or @dokebi/auth token refresh (`tokens.refresh(`), and whose `config` has no `oauth` and no `auth: { via: 'token' }` (Bearer only; `via: 'any'` or `'session'` does not count); fix: send the token, or verify the sender. `unknown-error-code` (a warning, [D-0077](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0077-app-self-description.md) D, only when `src/shared/errors.ts` exports a `defineErrors({ … })` result written as an object literal) — app code under `src/apps/` or `src/shared/modules/` that writes an error code as a string: `new DokebiError('CODE', …)`, `Object.assign(new Error(…), { code: 'CODE' })`, `throw { code: 'CODE' }` or `.send({ error: 'CODE' })`. A code missing from the list is unknown (fix: add it to the list and throw `errors.CODE()`), a listed one is written by hand (fix: `throw errors.CODE()`, with the import path from that file). The codes of web, auth and csrf answers (`VALIDATION_FAILED`, `NOT_FOUND`, `INVALID_REQUEST`, `INTERNAL_SERVER_ERROR`, `UNAUTHENTICATED`, `FORBIDDEN`, `CSRF_FAILED`) are fine. The list is read from the file's syntax tree, never by running it; a spread or a computed key turns the rule off. Background work ([D-0103](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0105-check-background-timers-and-structure.md) §1): `background-timer` (an error) — server code under `src/` (not `views/` or `public/`; tests are not read) that runs periodic work on its own timer instead of @dokebi/scheduler and @dokebi/job: any `setInterval` (global, `node:timers`, or the async iterator of `node:timers/promises`), and a `setTimeout` or `setImmediate` whose callback comes back to a function around the call through the functions and methods of the same file (`const tick = () => { …; setTimeout(tick, ms) }`, `#schedule() { setTimeout(() => this.#tick()) }` with `#tick` calling `#schedule`). Fine: one-shot delays and time limits (`setTimeout(() => controller.abort(), ms)`, `new Promise((resolve) => setTimeout(resolve, ms))`), awaited sleeps of `node:timers/promises` (`await setTimeout(ms, undefined, { signal })` between bounded batches of a job handler), and timers inside a function that takes a `request`, `req`, `reply`, `res`, `response`, `socket`, `ws`, `websocket` or `stream` parameter or is passed to a route method (`get`, `post`, …, `route`), unless the timer is stored where it outlives that function: `this.ticker = setInterval(…)` (also `??=`, `||=`) or a variable declared outside it is reported (one worker-wide timer the first request starts). Fix: a job handler registered in the setup of the module that owns the work (`queue(<queue>).handle(<type>, …)`) and an entry of `options.dokebi-scheduler.schedules`. Structure warnings (D-0103 §2–§3): `responsibility-size` — a model (`…/models/…`) with at least 400 code lines (blank and comment-only lines do not count) over at least 8 tables or collections (names after FROM, JOIN, INTO and UPDATE in SQL text, CTE names and upsert columns excluded; Mongo `.collection('x')` and a local helper that wraps it; Kysely `selectFrom`/`insertInto`/`updateTable`/`deleteFrom`), a controller with at least 20 route handlers (public methods and function-valued fields) or 300 code lines, and a service class with at least 5 methods that only pass their parameters on to one call on a field (`return this.model.list(user, filter)`) when they are at least 60% of its methods; files whose first lines say `@generated`, `generated by` or `do not edit` are not read. `memory-filtered-page` — in a model or service, rows an awaited query returned that are skipped by comparing a field of the row with an input of the function and then cut to a page (`for (const row of rows) { if (row.status !== filter.status) continue; …; if (page.length === size) break; }`, or `rows.filter((row) => row.org === input.org).slice(…)`); fix: the filter in the query's WHERE with an index that ends in the sort key, and LIMIT the page size + 1. A search that checks its other terms on a capped candidate set (@dokebi/db AI.md 6.10) compares no input and is not matched; the rule sees only these two shapes, so a clean result does not prove the lists are paged in the database. Dev files ([D-0129](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0129-inertia-dev-file-policy.md)): `vite-dev-files` (a warning, in a project with an Inertia app or @dokebi/template-inertia) — the `vite.config.*` does not use `dokebiInertia()` (a plain `vite` then serves the whole project root: dokebi.yaml, .env, the server code), sets `server.fs.strict: false`, sets `server.fs.deny` (a list of its own replaces Vite's defaults where the framework's policy does not run), or an `allow` list names the project root or server code (`'.'`, `'src'`, `'tests'`, `'scripts'`, `'tools'`, `process.cwd()`, `__dirname`, `searchForWorkspaceRoot(…)`); fix: keep `dokebiInertia()` and drop `server.fs`, add browser folders with `dokebiInertia({ allow: [...] })` and entries with `dokebiInertia({ deny: [...] })`. @dokebi/template-inertia enforces the policy anyway (strict on, its deny entries kept); `formatter-migrations` (a warning, D-0145, when the migrations folder `<dokebi-migrate directory>/migrations` exists) — a code formatter of the project would format it: prettier (a config, a `prettier` key or dependency in package.json) without the folder in `.prettierignore`, biome without `!<folder>` in `files.includes` (biome 1: the folder in `files.ignore`), ESLint with formatting rules (eslint-plugin-prettier, `@stylistic`) whose config does not name it; an applied migration must keep its contents (a reformat is warned as `MIGRATE_REFORMATTED` by @dokebi/migrate, an edit refused); fix: the ignore entry the problem names (`npx dokebi add` writes it for prettier and biome); the rule says that the config asks for less. `formatter-generated` (a warning, R1 measurement) — the same formatters would format `src/dokebi.generated.ts`, which the CLI writes and compares with its record: a reformatted copy is doctor `MODIFIED_REGISTRATION` and add, upgrade and remove refuse to run; fix: `src/dokebi.generated.ts` in `.prettierignore`, `"!src/dokebi.generated.ts"` in biome `files.includes` (`npx dokebi add` writes both). `shared-folder` (a warning, D-0226) — an entry right under `src/shared/` other than the folders `browser`, `locales`, `mail`, `models`, `modules`, `services`, `settings`, `views` and the file `errors.ts` (names that start with a dot are not read): server code of one feature goes into its module, code several features share into `src/shared/models/` or `services/`, browser code several apps or modules share into `src/shared/browser/`; it names a folder, so no marker silences it. `asset-in-views` (a warning, R1 measurement) — a browser file (a style sheet, an image, a font) in the views of an EJS app (`src/apps/<app>/views/`; an Inertia app with `views/app.js` is not read): move it to `src/apps/<app>/public/` and link `/assets/<path>`, which @dokebi/app serves through @dokebi/static. `asset-route` (a warning, R6 measurement) — a GET or HEAD route of server code (a `get` or `head` call with a path and a handler; a lookup by one key such as `manifest.get('main.css')` is none) for a browser file (`.css`, an image, a font): its path is a fixed file name (`/site.css`), or ends in such an extension and its handler reads a file itself (`createReadStream`, `readFile`, `readFileSync`); such a route sends the file without the validator, 304 and Range of `public/`; fix: put the file in `src/apps/<app>/public/` (a file a package ships, such as a font of @dokebi/font-noto-kr, is copied there with its licence file) and link `/assets/<path>`; a file the route makes per request takes `// dokebi-check: allow asset-route <reason>`. `seal-head-copied` (a warning, R7 measurement; only with @dokebi/app) — a file under `src/` (`.ts`, `.js`, `.mjs`, `.ejs`, `.html`; not in a comment) that loads `/dokebi/seal/forms.mjs` itself, a copied seal `<script>` or import map: write `<%- data.seal?.head ?? '' %>` in the layout of an app page, and for a page rendered outside an app route (an oauth consent page) take `context.getDependency(apps).seal(request).head` (`AppGroupApi` of @dokebi/app ^0.4.5, empty on a plain host); a page that is no app page takes `// dokebi-check: allow seal-head-copied <reason>`. `i18n-missing-key` (a warning, community request A2; only with @dokebi/i18n and `src/shared/locales/`) — a fixed translation key a page or server code asks for (`t('ns.a.b')`, `$t(…)`, `request.i18n.t(…)` in `.vue`, `.ts`, `.js`, `.ejs` under `src/`; the first part a namespace of the catalogs) that the catalogs of the default locale (`dokebi-i18n.defaultLocale` of dokebi.yaml, `en`) lack — the end of every fallback chain, so @dokebi/i18n throws `MISSING_MESSAGE` for it (everywhere but under `npx dokebi dev`) in each locale without it; a key only the default locale has falls back and is not reported; keys built at run time, keys with an explicit default (`t('k', 'Text')`) and lines in a comment are not read; locale folders and the default locale are read as @dokebi/i18n reads them (`Intl.Locale(name).baseName`: a folder `en-us` is the locale `en-US`), and a catalog that is not JSON or a folder that is no locale (or a second folder of one locale) is reported; fix: add the key to `src/shared/locales/<default locale>/<namespace>.json`; a key another catalog provides takes `// dokebi-check: allow i18n-missing-key <reason>`. With catalog layers (D-0181) code under `src/apps/<app>/` is checked against that app's layer, the modules and the shared catalogs, other code against the modules and the shared ones. `i18n-layer-override` (a warning) — one key in one language in two layers: an app's `src/apps/<app>/locales/` over a module's `src/shared/modules/<module>/locales/` or the shared `src/shared/locales/`, a module's over the shared ones, or two modules (the first by name wins, always reported); fix: list an intended override in the overriding file's top-level `"$overrides": ["key", …]` (keys inside the namespace), otherwise rename the key or remove it from one layer; a listed key that overrides nothing is reported too. `i18n-layer-missing` (a warning) — a layer gives keys in one language and lacks them in another language of the project, one problem per layer, language and namespace; fix: add them to that file or remove them from the layer's other languages. `shared-state-memory` (an error, [D-0161](https://git.nyx-zone.com/dokebi/framework/-/blob/main/docs/decisions/D-0161-shared-state-redis.md)) — `options.application-runtime.workers` above 1 while an installed plugin keeps the state its workers share in process memory: the dokebi-session store, dokebi-auth `tokens` or `throttle.store`, the dokebi-oauth store, the dokebi-rate-limit driver (`local`), dokebi-seal `nonces` that are not shared, or a dokebi-websocket-hub not in `mode: cluster`; the plugins refuse to start that way in a cluster worker and in production. Fix: `{ driver: redis, connection: <the project's dokebi-redis connection> }` for each (`npx dokebi add @dokebi/redis` first when there is none); the problem's line is that option in dokebi.yaml. `console-output` (a warning, D-0151) — server code under `src/` (not `views/` or `public/`) that calls `console.log`, `console.info`, `console.warn`, `console.error`, `console.debug`, `console.trace`, `process.stdout.write` or `process.stderr.write`: those lines skip the logger level, the redaction and the targets (the rotated files, the JSON lines `dokebi logs` reads); fix: `context.logger.log(level, 'Fixed message', { code, … })` in a plugin or module hook, `app.logger` in `src/main.ts`. A command line tool of the project that prints its results takes `// dokebi-check: allow console-output <reason>` before its first statement (it covers the whole file), or on or above one line. The framework's own sources pass the same rule as the `check:console` gate. `polling-loop` (an error no marker silences, AI-M35) — a loop that sleeps inside a task started in the background (an immediately invoked async function, or a function the file calls without awaiting or returning it), such as `(async () => { while (!stopped) { await step(); await sleep(ms); } })()` in a module's `start`: move it to an @dokebi/outbox handler (one coalesced item per owner and window) or a @dokebi/job handler with a schedule; per-process upkeep uses a timer (`background-timer` with a marker), never a sleeping loop. A `setInterval` or self-rescheduling timer whose callback reaches database work (a `query`, `execute` or `transaction` call, or a call on a model, repository, pool, client, transaction or outbox object, through the functions of the same file) is reported as `polling-loop` too, marker or not. `in-process-queue` (a warning, AI-M35) — the resolve of a `new Promise` stored in a collection (`.push`, `.unshift`, `.set`, `.add`), directly or through a variable that holds it (`const pending = { input, resolve }`), to be called later: callers wait in a queue of one worker without a bound or deadline; send the work at once and let the pool's `waitTimeoutMs` bound the wait (503 with Retry-After). `wait-count-refusal` (a warning, @dokebi/db AI.md 1.2 and 6.4) — server code under `src/` that compares how many callers wait for a pool connection with a number (pg `pool.waitingCount`, mariadb `pool.taskQueueSize()`, MongoDB `waitQueueSize`, mysql2 `pool._connectionQueue.length`): the count of waiters is not overload, so refusing on it refuses work the database can still do; fix: bound the wait by its deadline (`waitTimeoutMs`, then 503 with Retry-After) and shed a tenant by time, not by waiters; a metric or log line that only reports the number takes `// dokebi-check: allow wait-count-refusal <reason>`. `private-pool` (an error, AI-M37) — server code under `src/` outside `src/infra/db/` that makes a database pool or client with the driver itself (`new Pool`/`new Client` of `pg`, `createPool`/`createConnection`/`createPoolCluster` of `mysql2` and `mariadb`, `new MongoClient` of `mongodb`): it escapes dokebi.yaml (its size and `waitTimeoutMs`, past which the caller gets 503 with Retry-After), the connection sum and the cleanup at stop (M37: private pools with a 30 s wait held callers for 22–51 s); fix: the configured connection (`context.getDependency(db).connection(main)`), `derive('main', { purpose, overrides: { max } })` for a pool of one kind of work, or one more connection in dokebi.yaml; a connection that must stay outside (a LISTEN client) takes `// dokebi-check: allow private-pool <reason>`. `overload-off` (an error, AI-M37) — a route `config: { overload: false }`: under a burst its callers queue behind a stalled worker instead of getting 503 `OVERLOADED` with Retry-After (@dokebi/web AI.md 2.5); fix: remove it (raise `overload.maxEventLoopDelayMs` if it refuses too early); a metrics scrape or an operator status page takes `// dokebi-check: allow overload-off <reason>`. `readiness-off` (an error, M51) — a route `config: { readiness: false }`: it is served while a required dependency is down and while the app drains, so an API route runs its handler against a missing database or Redis; fix: remove it; a metrics scrape or status page that must answer during an outage takes `// dokebi-check: allow readiness-off <reason>`. `fixed-owner-cap` (a warning, AI-M37) — a per-owner count of requests in progress (a Map entry that goes up and down by one, read into a variable) compared with a fixed limit by an `if` that throws or returns, without a free or idle connection in the condition: it refuses work while the database is idle; fix: the owner share of @dokebi/db, `share(main).enter(owner)`, which refuses only while the pool is full (@dokebi/db AI.md 6.4, D-0156); a budget that bounds something else (the report CPU budget of db AI.md 6.9, a plan's quota) takes `// dokebi-check: allow fixed-owner-cap <reason>`. `undeclared-section` (a warning, D-0155) — a section of dokebi.yaml nothing declares (code reads `options.<name>` by hand); fix: `npx dokebi settings add <name>`. `template-fix-missing` (a warning) — doctor's `TEMPLATE_FIX_MISSING` and `RELOAD_NOT_WIRED`: a copied template file lacks a later fix, or an entry passes no `configFile`; fix: doctor's hint. `module-point-not-installed` (D-0130) — a point in `contributes` of `defineModule` imported from an `@dokebi/*` plugin package that is in node_modules but not installed in the project (`dokebi add`): nothing registers its collector, so the app drops the values (warn `POINT_NOT_COLLECTED`); fix: `npx dokebi add <package>` or remove the point (a plugin you register yourself takes the allow marker with a reason). When an empty catch, a background promise, a full-page form submit (a login) or one of the security cases is really intended, put `// dokebi-check: allow <rule> <reason>` on that line or the line above (EJS: `<%# dokebi-check: allow form-without-csrf <reason> %>` on the line above the form; only `empty-catch`, `missing-cause`, `floating-promise`, `inertia-form-only`, `unknown-error-code`, the three security rules, the two mail warnings, the three D-0103 rules, `untyped-browser-import`, `vite-dev-files`, `module-point-not-installed`, `asset-route`, `seal-head-copied`, `i18n-missing-key`, `console-output`, `wait-count-refusal`, `in-process-queue`, `fixed-owner-cap`, `private-pool` and `overload-off` — for example a per-process eviction of in-memory state that no job can reach; without a reason the marker is ignored). The sources are the program of `tsconfig.json` (generated files, `.d.ts` and node_modules excluded), read with the API of the TypeScript 7 installed in the project (`typescript/unstable/sync`). Browser code outside that program is read too (D-0120): the `<script>` and `<script setup>` blocks (`lang` ts or js) of every `.vue` file under `src/`, and the `.js`/`.mjs` files under a `views/` folder (files above 1 MiB are skipped). They get `empty-catch`, `missing-cause` and `floating-promise` only, typed by a second program that extends `tsconfig.json` but resolves imports as the bundler does (`moduleResolution: bundler`, `module: esnext`, the DOM in `lib`; relative imports resolve from the file's folder). An import whose bound names all have no type (the module did not resolve) is the warning `untyped-browser-import` on its line, since floating-promise cannot judge what comes from it; an import of a `.vue`, style, image or JSON file and `import type` are not judged; a module that really has no types takes `// dokebi-check: allow untyped-browser-import <reason>`, and the problems name the `.vue` or `.js` file and its line; the markers work the same inside a script block. A browser promise left floating is an unhandled rejection the page never handles: `await` it, or end it with `.catch(error => …)` that shows or reports the error. When it cannot be loaded `TYPESCRIPT_UNAVAILABLE` (`npm install`), when tsconfig cannot be opened `TSCONFIG_INVALID` |
|
|
88
88
|
| `dokebi upgrade <plugin id> [--to <version\|package\|tgz>] [--dry-run]` | Change the version. Do not use remove and add instead. Without `--to` it picks the highest version that fits the core and the installed packages, as `add` does (`NEWER_VERSION_HELD_BACK` names a newer one and what it waits for; the same version again changes nothing); an unreachable registry or a workspace package takes npm's `latest`. The copies of templates the project owns (the @dokebi/db adapters, `vite.config.ts` and `vite.ssr.config.ts`) are never rewritten: fixes of the new templates they lack are the warnings `TEMPLATE_FIX_MISSING` (`path`, `plugin`, `hint`: the change to make), as doctor reports them. With the same version and a changed manifest it applies the manifest again (D-0037, `reason: MANIFEST_CHANGED`); with the same version and manifest but other package content (an unpublished version rebuilt, given as `--to <tgz>`; the package-lock integrity differs) it installs the new code (`reason: PACKAGE_CHANGED`) — the way to replace a local snapshot. After package.json moved several plugins at once, upgrade them one by one, dependencies first: each result lists the ones still to do as `MANIFEST_CHANGED` warnings with their `hint`. A required plugin the new version needs and the project lacks is installed with it, as `add` would (`autoInstalled`, D-0116), when its manifest names the package and it needs no choice or settings; otherwise nothing is written and it is `MISSING_DEPENDENCY` (`mutation: none`) whose `details.fix` is the command to run first (`npx dokebi add <package>`, then the same upgrade again) |
|
|
89
89
|
| `dokebi remove <plugin id> [--dry-run]` | Remove a plugin. `REVERSE_DEPENDENCY` when a remaining plugin depends on it, `REQUIRED_PLUGIN` for a required part. An id that is not installed is no change; the package name of an installed plugin is `UNKNOWN_PLUGIN` (`details.fix`: `npx dokebi remove <id>`) |
|
|
90
90
|
| `dokebi migrate [--dry-run]` | Move a 0.1.x project with JSON settings to YAML |
|
|
@@ -182,11 +182,12 @@ One document on stdout: `{ schemaVersion, cliVersion, command, ok, result?, erro
|
|
|
182
182
|
| `src/apps/<app>/` | user | One app (app.ts, routes.ts or routes/, controllers, services, models, validation, views) |
|
|
183
183
|
| `src/shared/modules/<module>/` | user | Feature modules (module.ts, routes.ts and the same folders); job handlers and event subscriptions are registered in the owning module's setup |
|
|
184
184
|
| `src/shared/{models,services,views,locales,mail}/` · `src/shared/errors.ts` | user | Shared models and services, layouts and partials, translation catalogs (`locales/<locale>/<namespace>.json`), mail templates (`mail/<template>/<locale>/`) and the app error catalog |
|
|
185
|
+
| `src/shared/browser/` | user | Browser code several apps or modules share (D-0226): `components/` (a design system's UI components), `layouts/`, `composables/`, `styles/` (CSS, tokens) and `lib/` (browser modules that are not Vue: a socket client, formatters); a project with two looks puts one folder per look first (`browser/staff/components/`). Pages import it with a relative path and the dev server serves what they import; server code never imports it. Browser code — this folder and the `views/` of apps and modules — is checked by `tsconfig.vue.json` (vue-tsc, Vite's types), not `tsconfig.json`: a project made before cli 0.4.53 adds `"exclude": ["src/apps/*/views/**", "src/shared/modules/*/views/**", "src/shared/browser/**"]` to `tsconfig.json`, and to `tsconfig.vue.json` the include entries `"src/apps/*/views/**/*.ts"`, `"src/shared/modules/*/views/**/*.ts"`, `"src/shared/browser/**/*.ts"` with `"exclude": ["node_modules", "dist"]`. Code one app or module uses stays in its `views/` |
|
|
185
186
|
| `src/infra/<name>/` | user | Plugin connection and extension code (for example `db/connections.ts`, `auth/extension.ts`, `worker/tasks.ts`, `events/types.ts`, `runtime/application.ts`); migrations and seeds in `db/migrations/<connection>/` and `db/seeds/<connection>/` |
|
|
186
187
|
| `tests/{unit,integration,support}/` | user | Tests (`*.test.ts`, run by `npm test`: `node --test "tests/**/*.test.ts"`) and their helpers (never `*.test.ts`) |
|
|
187
188
|
| `scripts/` | user | Development tools, run with `node scripts/<name>.ts`, never imported by `src` |
|
|
188
189
|
|
|
189
|
-
The maintained form of these rules is the **Files and folders** integration rule in AGENTS.md (refreshed by `guide --sync`). A plugin manifest cannot write files outside `src/shared/{models,services,modules,views,mail,locales}/` and `src/infra/<name>/` (`INVALID_MANIFEST`). The exception is `src/apps/` for a plugin with `apps` in `dokebi.hosts`. Old paths are reported by doctor as `LEGACY_LAYOUT` (warning; they keep working). That includes a file an older recipe wrote where the layout no longer puts it, such as `src/site-worker.ts`; `details.moveTo` names its place now.
|
|
190
|
+
Nothing else sits right under `src/shared/`: `dokebi check` warns `shared-folder` for any other entry (D-0226). The maintained form of these rules is the **Files and folders** integration rule in AGENTS.md (refreshed by `guide --sync`). A plugin manifest cannot write files outside `src/shared/{models,services,modules,views,mail,locales}/` and `src/infra/<name>/` (`INVALID_MANIFEST`). The exception is `src/apps/` for a plugin with `apps` in `dokebi.hosts`. Old paths are reported by doctor as `LEGACY_LAYOUT` (warning; they keep working). That includes a file an older recipe wrote where the layout no longer puts it, such as `src/site-worker.ts`; `details.moveTo` names its place now.
|
|
190
191
|
|
|
191
192
|
## 5. Settings rules
|
|
192
193
|
|
package/catalog.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$comment": "Generated by scripts/catalog/build.ts from package.json dokebiCatalog fields and packages/cli/catalog-src (D-0065). Do not edit; run node scripts/catalog/build.ts.",
|
|
3
3
|
"schemaVersion": 1,
|
|
4
|
-
"cli": "0.4.
|
|
4
|
+
"cli": "0.4.53",
|
|
5
5
|
"core": {
|
|
6
6
|
"package": "@dokebi/core",
|
|
7
7
|
"version": "0.4.7"
|
|
@@ -446,7 +446,7 @@
|
|
|
446
446
|
{
|
|
447
447
|
"id": "dokebi-app",
|
|
448
448
|
"package": "@dokebi/app",
|
|
449
|
-
"version": "0.4.
|
|
449
|
+
"version": "0.4.12",
|
|
450
450
|
"kind": "plugin",
|
|
451
451
|
"summary": "Several apps chosen by request domain (src/apps/<app>) with a template each; installs web, controller and template-ejs with it",
|
|
452
452
|
"description": "Multiple apps per project for Dokebi: pick the app and template by request domain, with EJS and Inertia skeletons.",
|
|
@@ -825,7 +825,7 @@
|
|
|
825
825
|
{
|
|
826
826
|
"id": null,
|
|
827
827
|
"package": "@dokebi/cli",
|
|
828
|
-
"version": "0.4.
|
|
828
|
+
"version": "0.4.53",
|
|
829
829
|
"kind": "cli",
|
|
830
830
|
"summary": "Commands to create a project, browse the plugin catalog, run recipes, install plugins and verify (dokebi)",
|
|
831
831
|
"description": "Project scaffolding, plugin catalog, recipes, install and verification CLI for Dokebi.",
|
|
@@ -2143,7 +2143,7 @@
|
|
|
2143
2143
|
{
|
|
2144
2144
|
"id": "dokebi-module",
|
|
2145
2145
|
"package": "@dokebi/module",
|
|
2146
|
-
"version": "0.4.
|
|
2146
|
+
"version": "0.4.8",
|
|
2147
2147
|
"kind": "plugin",
|
|
2148
2148
|
"summary": "Modules that hold one feature each (src/shared/modules/<module>); an app attaches them under a prefix",
|
|
2149
2149
|
"description": "Feature modules for Dokebi apps: controllers, models, views and routes in one folder mounted under a prefix.",
|
|
@@ -2830,7 +2830,7 @@
|
|
|
2830
2830
|
{
|
|
2831
2831
|
"id": null,
|
|
2832
2832
|
"package": "@dokebi/rich-text",
|
|
2833
|
-
"version": "0.2.
|
|
2833
|
+
"version": "0.2.1",
|
|
2834
2834
|
"kind": "library",
|
|
2835
2835
|
"summary": "Editor documents (Tiptap or ProseMirror JSON) checked whole against a declared schema of nodes, marks, links, image sources, tables, colours and alignment, with coded 422 errors, then safe HTML, plain text and excerpts; editorConfig gives Tiptap its settings from the same schema",
|
|
2836
2836
|
"description": "Rich text documents for Dokebi: editor JSON (Tiptap, ProseMirror) checked whole against a declared schema with coded 422 errors, then safe HTML, plain text and excerpts; tables, colours and alignment; the editor settings from the same schema.",
|
|
@@ -3451,7 +3451,7 @@
|
|
|
3451
3451
|
{
|
|
3452
3452
|
"id": "dokebi-template-inertia",
|
|
3453
3453
|
"package": "@dokebi/template-inertia",
|
|
3454
|
-
"version": "0.4.
|
|
3454
|
+
"version": "0.4.9",
|
|
3455
3455
|
"kind": "plugin",
|
|
3456
3456
|
"summary": "Inertia (v3) server adapter: Vue 3 views, Vite build files and optional server-side rendering (SSR)",
|
|
3457
3457
|
"description": "Inertia v3 server adapter for Dokebi: page JSON, Vite manifest assets and optional server-side rendering.",
|
package/dist/capability-guide.js
CHANGED
|
@@ -28,7 +28,7 @@ export const INTEGRATION_RULES = [
|
|
|
28
28
|
'Scope: these are reusable engineering rules, not a product specification. Seal browser transport and Korean/English UI are explicit consumer conventions; other features remain conditional. Examples do not fix domain names, schemas, UI layout, worker count, retention duration, notification recipients or message-history policy for a new product. Apply feature-specific rules only when that feature is requested or installed; do not add uploads, hierarchies, notifications or other product features merely because they appear here. Keep domain entities, user roles, recipient rules and workflows in the project-specific requirements outside this maintained block.',
|
|
29
29
|
'',
|
|
30
30
|
'- Product planning before implementation: treat the result as a real service, not a demo. Map the intended user journeys and distinguish domain concepts before choosing tables, endpoints or screens. Define each domain concept by its purpose, ownership, lifecycle and discovery/editing flow; concepts sharing a persistence mechanism need not share a user flow. For hierarchical features, specify traversal order, sibling order and page boundaries before choosing hierarchy queries. A requested tree listing renders descendants beneath their parent in tree order; a globally time-sorted list with depth badges or parent links is not that tree. Retain parent context when a bounded page continues a branch, and test the actual rendered row order with multiple branches and interleaved creation times. Record acceptance checks for discovery/navigation, creation, editing, cancellation, deletion, permissions, empty/loading/error states and operator recovery. Validate those journeys in the actual UI (see Browser apps and the view: a service people use in a browser has screens); API tests and startup success cannot establish usable product behavior. Resolve material product ambiguity with the user, preserve existing requirements, and keep deployment claims limited to environments actually verified.',
|
|
31
|
-
"- Required browser transport (consumer convention; the core plugin remains optional): install @dokebi/seal in every browser-facing web app whose pages send data, and configure and verify seal-enabled domains. Which hosts: Seal a host whose pages send data (forms, sealedFetch, Inertia visits). A host that only shows public pages (no writes, no signed-in JSON) gains nothing from seal: leave its domain without `seal: true`. Its pages then need no seal files and no 'wasm-unsafe-eval', and may use Inertia SSR. If you do seal such a host, its read-only pages load only the two small modules (about 19 KB), never the wasm. Inertia + Vue is the default view unless the user chose another. Inertia: navigation/forms retain the official sealInertia(http) integration before createInertiaApp (the generated views/app.js imports @dokebi/seal/http when the first page is sealed, then the data-page and every visit, form post and validation error go sealed; a plain JSON body gets 415 SEAL_REQUIRED). The generated vite.config.ts has dokebiInertia() from @dokebi/template-inertia/vite: every import of @dokebi/seal/http in the app's browser code loads the module the app serves (/dokebi/seal/http.mjs), in the build and in dokebi dev, so Vue pages write a plain static import { sealedFetch } from '@dokebi/seal/http' and share the bootstrap's seal; keep that plugin in a vite config of your own (app add warns VITE_PLUGIN_MISSING without it). The plugin also limits what dokebi dev serves to the browser (D-0129): the views folders, node_modules and the files they import; dokebi.yaml, .env, keys and the server code answer 403. Never add server.fs to vite.config (strict: false, a deny list, allow: ['.']) to make a file load: put browser code under views/ or
|
|
31
|
+
"- Required browser transport (consumer convention; the core plugin remains optional): install @dokebi/seal in every browser-facing web app whose pages send data, and configure and verify seal-enabled domains. Which hosts: Seal a host whose pages send data (forms, sealedFetch, Inertia visits). A host that only shows public pages (no writes, no signed-in JSON) gains nothing from seal: leave its domain without `seal: true`. Its pages then need no seal files and no 'wasm-unsafe-eval', and may use Inertia SSR. If you do seal such a host, its read-only pages load only the two small modules (about 19 KB), never the wasm. Inertia + Vue is the default view unless the user chose another. Inertia: navigation/forms retain the official sealInertia(http) integration before createInertiaApp (the generated views/app.js imports @dokebi/seal/http when the first page is sealed, then the data-page and every visit, form post and validation error go sealed; a plain JSON body gets 415 SEAL_REQUIRED). The generated vite.config.ts has dokebiInertia() from @dokebi/template-inertia/vite: every import of @dokebi/seal/http in the app's browser code loads the module the app serves (/dokebi/seal/http.mjs), in the build and in dokebi dev, so Vue pages write a plain static import { sealedFetch } from '@dokebi/seal/http' and share the bootstrap's seal; keep that plugin in a vite config of your own (app add warns VITE_PLUGIN_MISSING without it). The plugin also limits what dokebi dev serves to the browser (D-0129): the views folders, node_modules and the files they import; dokebi.yaml, .env, keys and the server code answer 403. Never add server.fs to vite.config (strict: false, a deny list, allow: ['.']) to make a file load: put browser code under views/ or, when several apps or modules share it, in src/shared/browser/ (a page imports it, so it is served); dokebiInertia({ allow }) is only for files the browser loads by URL without an import (dokebi check warns vite-dev-files). EJS: write <%- data.seal?.head ?? '' %> in the shared layout <head> (the template-ejs layout has it), and in the <head> of every page rendered without that layout (it is empty on a domain without seal); when a layout has its own import map, the seal head comes first, before that map and every module script. It loads the browser module @dokebi/seal/forms (served as /dokebi/seal/forms.mjs), which seals every same-origin <form method=\"post\"> with no per-form code and sends it with the request header x-dokebi-form: 1, so the form keeps its <%- data.csrf.field %> and the handlers, validation and 303/422 form flow stay those of a plain HTML form. Sealed forms are form bodies: set dokebi-web.formBody: true (without it they get 415 FORM_BODY_DISABLED). A form with a chosen file goes as multipart (file bytes are not sealed) and the forms module moves its _csrf field into the x-csrf-token header itself; write no upload-specific CSRF code. To submit from a script call form.requestSubmit() or submitSealedForm(form) from @dokebi/seal/forms, never form.submit(): it fires no submit event and goes out plain (415). Page navigation (GET) stays plain HTML. Mark a form data-seal=\"off\" only for a deliberate exception, never to make a plain form post pass: a sealed domain refuses that unsealed post (415 SEAL_REQUIRED). Never turn sealing off, set seal: false on a form route or drop the layout head to make a plain form work. Both views: use sealedFetch from @dokebi/seal/http for all application-owned HTTP requests, including REST/JSON and multipart uploads. Do not call raw fetch, Axios or Inertia http.getClient().request from application API adapters. Import bootstrap and request helpers from the same module instance, the served /dokebi/seal/http.mjs: EJS pages reach it through the import map of the seal head, Inertia apps through dokebiInertia(), so both import @dokebi/seal/http by name; never load /dokebi/seal/http.mjs by URL next to a bundled copy of @dokebi/seal/http. Preserve generated template selection and hydration contracts. Server rendering on a seal host covers public pages only (D-0195): a route that renders with { public: true } gets a plain, server-rendered first HTML without the visitor's props (auth, csrf and the entry's shared arrive right after through a sealed visit), and every other page of that host stays sealed and is not server rendered. dokebi app add --inertia --ssr --seal makes such an app; mark the routes whose first HTML crawlers must read with { public: true } and head (title, description, canonical, alternates), put only public data in their props, keep values the same for every visitor in publicShared of src/infra/inertia/shared.ts, and draw the layout before the visitor's props arrive. The recipes leave SSR hosts unsealed and say so: ask the user whether those hosts send data, and if they do, seal them and mark their public pages (a read-only public host may stay unsealed with SSR). File multipart bytes and GET queries are outside sealing; verify sealed JSON responses and errors too. sealedFetch does not add CSRF headers automatically: follow the installed @dokebi/csrf guide in one shared adapter, read the current token for each request, keep credentials same-origin, and never disable CSRF to make uploads pass.",
|
|
32
32
|
`- Recipe answers (D-0095): a request often settles some choices (for example PostgreSQL, Docker, EJS) and leaves others open. Choices the request leaves open are still the user's: ask and end your turn, unless the user said to decide them. ${ANSWER_SOURCES} The recipe records who made each choice (answeredBy user, ai, default) and verify's tellUser tells the user; never present a choice you made as the user's answer.`,
|
|
33
33
|
`- Browser apps and the view (D-0098): ${BROWSER_APPS} Outside a recipe, npx dokebi app add records the view with --answers-from user or --ai-chose view --ai-reason view=<why>; an EJS app added without either (also the first app of add @dokebi/app) is reported to the user as not the default view with its chooser unrecorded. Validate the journeys of the screens in the actual UI (Product planning).`,
|
|
34
34
|
'- Processes and shared tools: stop a process by the PID you recorded or with npx dokebi stop, never by a pattern (pkill -f, killall): other apps on the machine run the same command lines (src/main.ts, the cluster worker). Check screens in a browser you start yourself with its own temporary profile (a headless or separate Playwright browser), never in the browser the person is using, through an extension or a computer-use tool: its tabs, cookies and signed-in sessions belong to them. Close only the tabs and contexts you opened; never navigate, reuse or close tabs you did not open. Keep downloaded browsers and package caches outside the project folder.',
|
|
@@ -37,7 +37,7 @@ export const INTEGRATION_RULES = [
|
|
|
37
37
|
'- Background work (D-0141): deliveries (webhooks, mail, notifications), exports, imports, copies, grace periods and cleanups are work items of @dokebi/outbox, not loops you write. Enqueue with outbox.enqueue(tx, { type, owner, destination, payload, dedupeKey, notBefore }) inside the business transaction and register outbox.handle(type, handler, { onDone }) in the setup of the module that owns the work; its runner claims fair batches across owners through one due-time index, retries with backoff, waits out a destination that is down (a breaker per destination, dead only after a horizon of days), keeps dead items for outbox.resend and removes finished rows after a retention. It derives its own small pool of the main connection (pool.max, default 4), so add nothing but run the migration that npx dokebi add @dokebi/outbox writes, keep handlers idempotent with item.key, query in handlers through context.db (the outbox handler pool, never the main pool: an owner whose handlers wait on a locked row then holds at most runner.maxInFlightPerOwner of them while the other owners keep flowing), and put the arrival and drain per second of npx dokebi-outbox stats in the section 6 table of the final report. Never hand-write a claim loop, a retry or dead-letter table or a timer for such work. A destination is one endpoint (one webhook id or URL, one mailbox provider), never a whole host or a shared name such as database: items of one failing endpoint must not pause the others. Database-only cleanup has no destination, and a batch handler records a failing row and skips it rather than failing the whole item. Best-effort signals after a commit (an SSE change notice, a cache invalidation) are not outbox work: send them directly.',
|
|
38
38
|
'- Recipe fit: pick the recipe whose scaffold matches the app (npx dokebi recipe list shows each recipe and its match); when you build on a scaffold made for something else, rename or remove its sample names (tables, option keys, routes, view titles) so none of them remains in the finished app.',
|
|
39
39
|
'- Responsibility boundaries: use Controller -> Service -> Model for application data. Controllers translate HTTP input/output and call services; models own SQL, services provide data and coordinate workflows, and jobs invoke those services. Put app-specific services in src/apps/<app>/services, cross-app services in src/shared/services, and feature-module services in src/shared/modules/<module>/services. Shared services must not import app-specific code. Services accept explicit inputs and return DTOs, never request/reply or template objects; do not expose models or SQL pools through a service for controllers/routes to bypass it. Compose dependencies once during setup. Periodic and background work runs only through the scheduler and job plugins, registered by the module that owns it; never start timers, intervals or background loops in controllers, services or setup code. Keep auth extension wiring separate from reusable member persistence. Audit the final route and registration graph after replacing scaffold flows; remove obsolete unreferenced implementations that duplicate the active behavior, while preserving required engine entries, mail templates and user-owned resources. Split by responsibility, not by arbitrary file counts. When a browser UI is present, keep views/runtime for browser integration and requested reusable editor/upload UI in the template components, and display helpers separate from transport. Use explicit DTO types through services, browser adapters and Vue props; a default any response or any page state defeats SFC checking. Keep readable formatting. Keep original TS/JS/Vue source formatted; minification belongs only to generated build output. Declare a formatter that supports the source formats, include its check in project verification, and inspect the final source rather than claiming readability from build success. Include Vue SFC scripts/templates in type checking; a successful Vite build or server-only tsc is not a Vue type check. dokebi app add --inertia prepares it: npm run typecheck runs tsc and then vue-tsc (typecheck-vue.mjs with tsconfig.vue.json), so keep that step, write pages as <script setup lang="ts">, and type the shared page props in src/infra/inertia/page.d.ts. Preserve the shared error catalog at src/shared/errors.ts.',
|
|
40
|
-
'- Files and folders (maintained layout; refreshed by guide --sync like every rule here): src holds only main.ts and dokebi.generated.ts at its root. One app per src/apps/<app>: app.ts, routes.ts (or routes/ for route groups), controllers/, services/, models/, validation/ and views/<template>/ (Inertia pages in views/<template>/Pages, components in components/, browser integration in views/runtime/). Shared code: src/shared/models, src/shared/services, src/shared/views (layouts, partials), src/shared/locales/<locale>/<namespace>.json, src/shared/mail/<template>/<locale
|
|
40
|
+
'- Files and folders (maintained layout; refreshed by guide --sync like every rule here): src holds only main.ts and dokebi.generated.ts at its root. One app per src/apps/<app>: app.ts, routes.ts (or routes/ for route groups), controllers/, services/, models/, validation/ and views/<template>/ (Inertia pages in views/<template>/Pages, components in components/, browser integration in views/runtime/). Shared code: src/shared/models, src/shared/services, src/shared/views (layouts, partials), src/shared/locales/<locale>/<namespace>.json, src/shared/mail/<template>/<locale>/, application settings in src/shared/settings and the error catalog src/shared/errors.ts. Browser code several apps or modules share (a design system, shared layouts, composables, a socket client) goes in src/shared/browser: components/, layouts/, composables/, styles/ and lib/ (a project with two looks, an operator console and a member site, puts one folder per look first, src/shared/browser/staff/components/); pages import it with a relative path, server code never imports it. Browser code (the views of apps and modules and src/shared/browser) is type-checked by tsconfig.vue.json with vue-tsc, not by tsconfig.json. Code one app or module uses stays in the views/ of that app or module. src/shared holds nothing else (dokebi check warns shared-folder). One feature per module in src/shared/modules/<module> (module.ts, routes.ts and the same controllers/services/models/validation/views folders; create it with npx dokebi module add). Plugin connection and extension code in src/infra/<name> (src/infra/db/connections.ts, src/infra/auth/extension.ts); your own plugins in src/plugins/<name>. Migrations in src/infra/db/migrations/<connection> and seeds in src/infra/db/seeds/<connection> (npx dokebi-migrate make writes the file). Job handlers and event subscriptions are registered in the setup of the module that owns the feature (src/shared/modules/<module>/module.ts) and call its services; schedules are entries of options.dokebi-scheduler.schedules in dokebi.yaml whose job type such a handler takes; CPU tasks go in src/infra/worker/tasks.ts, event payload types in src/infra/events/types.ts and the cluster worker factory in src/infra/runtime/application.ts. Input validation (route schemas and validators) lives in validation/ of the app or module that owns the route; a DTO type is exported by the service that returns it (cross-app DTOs with their service in src/shared/services). Tests: tests/unit (no external service), tests/integration (a real database, HTTP or broker) and tests/support (helpers and fixtures, never named *.test.ts); npm test runs node --test "tests/**/*.test.ts", which covers both test folders, and tsconfig.json includes tests/**/*.ts. Development tools (imports, measurements, one-off maintenance) go in scripts/ at the project root, run with node scripts/<name>.ts and never imported by src. Name .ts files and folders in kebab-case (Vue components and Inertia pages are PascalCase, as Pages/Posts/Show.vue), and give each file one responsibility.',
|
|
41
41
|
'- Apps split by host (D-0132): with several @dokebi/app apps on different hosts, routes that plugins add answer on every host unless they are bound to apps. Bind each plugin endpoint to its app in dokebi.yaml: dokebi-mcp.app: mcp (the MCP route), dokebi-oauth.app: studio (the authorization server: metadata, authorize with the consent page, token, revoke, register; the issuer origin is a domain of that app) and dokebi-oauth.resources.<id>.app: mcp (the protected resource metadata, on the app of the resource uri host). Every other host then answers the 404 of an unknown route. Put the sign-in page on the issuer app. A route of your own module or plugin on web takes app: <name> or app: [<name>, ...] the same way. Never write an onRequest hook that compares the Host header to hide an endpoint, and never answer 403 on the wrong host. Without @dokebi/app a bound route fails the start (ROUTE_APP_UNAVAILABLE), an unknown app name too (ROUTE_APP_UNKNOWN), and an issuer or resource uri on a domain of another app fails it with INVALID_OPTIONS naming the option to set; health routes stay on every host.',
|
|
42
42
|
'- Module contributions (D-0130): a feature module that offers values to a plugin point (MCP tools, prompts and resources of @dokebi/mcp, mail template folders) declares the points in defineModule({ contributes: [mcpTools] }) and calls module.contribute(point, value) in its own setup, after it builds its services; the contributed objects (an McpTool subclass) take those services in their constructors. Core sets the module up before the plugin that collects the point, so the services exist when the collector reads them, and contributions close when every setup has finished. A module never collects. Never rebuild module services in a separate definePlugin, and never register an app plugin by hand in src/main.ts or src/infra/runtime/application.ts to reach them: describe, the tests and the other entry do not see such a plugin, and doctor and check do not read it. A second module reaches the services through requires: [workspace] and module.get(workspace). Values that no registered plugin collects are dropped with warn POINT_NOT_COLLECTED, npx dokebi check reports module-point-not-installed when the plugin package of a point is not installed, and npx dokebi describe lists each module point and its collector. MCP tool names are unique across modules and plugins (INVALID_TOOL names both owners).',
|
|
43
43
|
"- What `npx dokebi check` enforces from these rules (D-0105), so a broken one fails before you report: background-timer (an error, so verify fails) is a setInterval, a setTimeout/setImmediate that reschedules itself, or a loop that sleeps inside a task started in the background (an immediately invoked async function or a function called without await, such as a polling loop in a module start), in server code under src/ (views and tests are not read): move the work to a @dokebi/job handler registered in the owning module's setup and an entry of options.dokebi-scheduler.schedules; one-shot delays, time limits, awaited sleeps of node:timers/promises and timers of one request or socket are fine (a timer a request stores on this or in an outer variable outlives it and is reported). polling-loop (an error no marker silences) is a loop that sleeps inside a task started in the background, or a timer whose callback does database work: move it to an @dokebi/outbox or @dokebi/job handler. private-pool (an error) is a database pool or client made with the driver outside src/infra/db (new pg.Pool, mysql2 createPool, new MongoClient): take connections from @dokebi/db (connection(main), derive('main', { purpose, overrides: { max } }) for a pool of one kind of work, or another connection in dokebi.yaml) so dokebi.yaml sets their size and waitTimeoutMs and a caller past the wait gets 503 with Retry-After. overload-off (an error) is a route config overload: false: keep the overload protection on every API route (a metrics scrape or status page takes a marker). readiness-off (an error) is a route config readiness: false: an API route keeps refusing with 503 NOT_READY while a required dependency is down (a metrics scrape or status page that must answer then takes a marker). Warnings: in-process-queue (the resolve of a new Promise stored in a collection to call later: a queue of one worker without bound or deadline), fixed-owner-cap (a per-owner count of requests in progress compared with a fixed limit: use the owner share of @dokebi/db, share(main).enter(owner), which refuses only while the pool is full, @dokebi/db AI.md 6.4), wait-count-refusal (a comparison of the callers waiting for a pool connection, such as pool.waitingCount, with a number: refuse by the wait deadline, never by how many wait), responsibility-size (a model of 400+ code lines over 8+ tables or collections, a controller with 20+ route handlers or 300+ code lines, a service whose methods mostly only pass their arguments to a model) and memory-filtered-page (rows a query returned, skipped in code by an input such as filter.status and then cut to a page). A warning is still a broken rule: fix it, or keep it with // dokebi-check: allow <rule> <reason> and say why in your final message. An allow marker on background-timer is only for per-process upkeep of in-memory state (a cache of this worker); a loop that reads or writes the database (claiming, folding, polling a queue table) is never a valid reason: move it to a job or an outbox handler. check lists every marker with a reason under allowed, and verify ok asks your final message to list them with their reasons. With @dokebi/db installed, verify ok lists finalReport: the section 6 table your final message must contain.",
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { VirtualSource } from './typescript.js';
|
|
2
2
|
/** The suffix of a virtual source; never a real file and never what an import resolves to. */
|
|
3
3
|
export declare const VIRTUAL_SUFFIX = ".dokebi-check";
|
|
4
|
+
/** The browser code several apps and modules share (D-0226). */
|
|
5
|
+
export declare const SHARED_BROWSER = "src/shared/browser/";
|
|
4
6
|
/**
|
|
5
7
|
* The script of a .vue file as one TypeScript or JavaScript text of the same length: the
|
|
6
8
|
* template, the styles and the tags blanked (newlines kept). Undefined without a script block.
|
|
@@ -11,10 +13,14 @@ export declare function vueScript(text: string): {
|
|
|
11
13
|
} | undefined;
|
|
12
14
|
/** The virtual source of one file (project-relative `path`), or undefined when there is none. */
|
|
13
15
|
export declare function browserSource(root: string, path: string, text: string): VirtualSource | undefined;
|
|
14
|
-
/**
|
|
16
|
+
/**
|
|
17
|
+
* Is `path` (project-relative) browser code check reads: a .vue file, .js/.mjs in views/, .ts/.mts
|
|
18
|
+
* in the views of an app or module, or a module of src/shared/browser/ (never a .d.ts)?
|
|
19
|
+
*/
|
|
15
20
|
export declare function isBrowserPath(path: string): boolean;
|
|
16
21
|
/**
|
|
17
|
-
* The browser code under `directory` (default `src/`) of a project: .vue files
|
|
18
|
-
* under views/ (node_modules, dist, .vite, .git and the
|
|
22
|
+
* The browser code under `directory` (default `src/`) of a project: .vue files, the .js/.mjs
|
|
23
|
+
* under views/ and the modules of src/shared/browser/ (node_modules, dist, .vite, .git and the
|
|
24
|
+
* .tmp scratch folder are not walked).
|
|
19
25
|
*/
|
|
20
26
|
export declare function browserSources(root: string, skip?: (path: string) => boolean, directory?: string): Promise<VirtualSource[]>;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// Browser code for `dokebi check` (D-0120): the `<script>` and `<script setup>` blocks of the
|
|
2
|
-
// project's .vue files
|
|
3
|
-
//
|
|
4
|
-
//
|
|
2
|
+
// project's .vue files, the .js/.mjs files under a views/ folder, and the .ts/.mts of the views of
|
|
3
|
+
// apps and modules and of src/shared/browser/ (D-0226: browser code, which tsconfig.json leaves to
|
|
4
|
+
// vue-tsc) are not in the tsconfig program, so empty-catch, missing-cause and
|
|
5
|
+
// floating-promise never saw them. Each such file becomes a virtual source next to the original (`<file>.dokebi-check.ts` or
|
|
5
6
|
// `.js`), which typescript.ts serves to tsgo through its virtual file system in a second project:
|
|
6
7
|
// relative imports resolve from the same folder and the checker gives real types. A .vue file
|
|
7
8
|
// keeps its length and its newlines, everything outside the script blocks blanked to spaces, so a
|
|
@@ -15,7 +16,9 @@ import { sources } from './form-rules.js';
|
|
|
15
16
|
export const VIRTUAL_SUFFIX = '.dokebi-check';
|
|
16
17
|
/** Files larger than this are not read (generated bundles), as in form-rules.ts. */
|
|
17
18
|
const MAX_BYTES = 1024 * 1024;
|
|
18
|
-
const BROWSER = /\.(?:vue|js|mjs)$/;
|
|
19
|
+
const BROWSER = /\.(?:vue|js|mjs|ts|mts)$/;
|
|
20
|
+
/** The browser code several apps and modules share (D-0226). */
|
|
21
|
+
export const SHARED_BROWSER = 'src/shared/browser/';
|
|
19
22
|
const SCRIPT = /<script\b([^>]*)>([\s\S]*?)<\/script\s*>/gi;
|
|
20
23
|
const LANG = /\blang\s*=\s*(["']?)([a-z]+)\1/i;
|
|
21
24
|
/**
|
|
@@ -57,17 +60,32 @@ export function browserSource(root, path, text) {
|
|
|
57
60
|
text: script.text,
|
|
58
61
|
};
|
|
59
62
|
}
|
|
60
|
-
|
|
63
|
+
const typescript = /\.m?ts$/.test(path);
|
|
64
|
+
return { path, fileName: `${absolute}${VIRTUAL_SUFFIX}.${typescript ? 'ts' : 'js'}`, text };
|
|
61
65
|
}
|
|
62
|
-
/**
|
|
66
|
+
/**
|
|
67
|
+
* Is `path` (project-relative) browser code check reads: a .vue file, .js/.mjs in views/, .ts/.mts
|
|
68
|
+
* in the views of an app or module, or a module of src/shared/browser/ (never a .d.ts)?
|
|
69
|
+
*/
|
|
63
70
|
export function isBrowserPath(path) {
|
|
64
71
|
if (!BROWSER.test(path))
|
|
65
72
|
return false;
|
|
66
|
-
|
|
73
|
+
if (path.endsWith('.vue'))
|
|
74
|
+
return true;
|
|
75
|
+
if (/\.d\.m?ts$/.test(path))
|
|
76
|
+
return false;
|
|
77
|
+
if (path.startsWith(SHARED_BROWSER))
|
|
78
|
+
return true;
|
|
79
|
+
// The views of apps and modules: .js/.mjs anywhere in a views/ folder (D-0120); .ts/.mts there
|
|
80
|
+
// since tsconfig.json leaves them to vue-tsc (D-0226). src/shared/views/ holds EJS (server).
|
|
81
|
+
if (/\.m?js$/.test(path))
|
|
82
|
+
return /(?:^|\/)views\//.test(path);
|
|
83
|
+
return /^src\/(?:apps\/[^/]+|shared\/modules\/[^/]+)\/views\//.test(path);
|
|
67
84
|
}
|
|
68
85
|
/**
|
|
69
|
-
* The browser code under `directory` (default `src/`) of a project: .vue files
|
|
70
|
-
* under views/ (node_modules, dist, .vite, .git and the
|
|
86
|
+
* The browser code under `directory` (default `src/`) of a project: .vue files, the .js/.mjs
|
|
87
|
+
* under views/ and the modules of src/shared/browser/ (node_modules, dist, .vite, .git and the
|
|
88
|
+
* .tmp scratch folder are not walked).
|
|
71
89
|
*/
|
|
72
90
|
export async function browserSources(root, skip = () => false, directory = 'src') {
|
|
73
91
|
const found = [];
|
package/dist/check/index.js
CHANGED
|
@@ -20,9 +20,10 @@ import { csrfFormsProblems, formProblems } from './form-rules.js';
|
|
|
20
20
|
import { formatterProblems } from './formatter-rules.js';
|
|
21
21
|
import { missingKeysProblems } from './i18n-rules.js';
|
|
22
22
|
import { DokebiImports } from './packages.js';
|
|
23
|
-
import { byPlace, MARKABLE, RULES } from './problems.js';
|
|
23
|
+
import { byPlace, MARKABLE, RULES, uniqueProblems, } from './problems.js';
|
|
24
24
|
import { projectProblems } from './project-rules.js';
|
|
25
25
|
import { sealHeadsProblems } from './seal-rules.js';
|
|
26
|
+
import { sharedFolderProblems } from './shared-folder-rules.js';
|
|
26
27
|
import { sharedStateProblems } from './shared-state-rules.js';
|
|
27
28
|
import { readMarkers, sourceProblems } from './source-rules.js';
|
|
28
29
|
import { openTypeScript } from './typescript.js';
|
|
@@ -54,29 +55,31 @@ export async function check(directory, options = {}) {
|
|
|
54
55
|
problems.push(...(await formatterProblems(root)));
|
|
55
56
|
problems.push(...(await sharedStateProblems(root, installed)));
|
|
56
57
|
problems.push(...(await assetProblems(root)));
|
|
58
|
+
problems.push(...(await sharedFolderProblems(root)));
|
|
57
59
|
if (installed.has('dokebi-app'))
|
|
58
60
|
problems.push(...(await sealHeadsProblems(root, skip)));
|
|
59
61
|
if (installed.has('dokebi-i18n'))
|
|
60
62
|
problems.push(...(await missingKeysProblems(root, skip)));
|
|
61
63
|
problems.sort(byPlace);
|
|
64
|
+
const reported = uniqueProblems(problems);
|
|
62
65
|
const allowed = await allowedMarkers(root, skip);
|
|
63
66
|
const ms = {
|
|
64
67
|
total: Math.round(performance.now() - began),
|
|
65
68
|
typescript: typescript.loadMs,
|
|
66
69
|
};
|
|
67
|
-
const errors =
|
|
70
|
+
const errors = reported.filter((problem) => problem.severity !== 'warning').length;
|
|
68
71
|
debug('check: finished', {
|
|
69
72
|
root,
|
|
70
|
-
problems:
|
|
73
|
+
problems: reported.length,
|
|
71
74
|
allowed: allowed.length,
|
|
72
|
-
warnings:
|
|
75
|
+
warnings: reported.length - errors,
|
|
73
76
|
files,
|
|
74
77
|
...ms,
|
|
75
78
|
});
|
|
76
79
|
return {
|
|
77
80
|
// Warnings (inertia-form-only, the CSRF ones) are reported but never fail check or verify.
|
|
78
81
|
ok: errors === 0,
|
|
79
|
-
problems,
|
|
82
|
+
problems: reported,
|
|
80
83
|
allowed,
|
|
81
84
|
files,
|
|
82
85
|
rules: RULES,
|
package/dist/check/problems.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const RULES: readonly ['empty-catch', 'missing-cause', 'floating-promise', 'non-erasable-syntax', 'private-import', 'generated-file', 'secret-in-config', 'missing-package', 'inertia-form-only', 'form-without-csrf', 'csrf-exempt-unverified', 'plain-password-compare', 'unknown-error-code', 'mail-send-in-request', 'mail-secret-in-data', 'background-timer', 'polling-loop', 'responsibility-size', 'memory-filtered-page', 'untyped-browser-import', 'vite-dev-files', 'module-point-not-installed', 'formatter-migrations', 'formatter-generated', 'shared-state-memory', 'asset-in-views', 'asset-route', 'seal-head-copied', 'i18n-missing-key', 'i18n-layer-override', 'i18n-layer-missing', 'console-output', 'undeclared-section', 'template-fix-missing', 'wait-count-refusal', 'in-process-queue', 'private-pool', 'overload-off', 'readiness-off', 'fixed-owner-cap'];
|
|
1
|
+
export declare const RULES: readonly ['empty-catch', 'missing-cause', 'floating-promise', 'non-erasable-syntax', 'private-import', 'generated-file', 'secret-in-config', 'missing-package', 'inertia-form-only', 'form-without-csrf', 'csrf-exempt-unverified', 'plain-password-compare', 'unknown-error-code', 'mail-send-in-request', 'mail-secret-in-data', 'background-timer', 'polling-loop', 'responsibility-size', 'memory-filtered-page', 'untyped-browser-import', 'vite-dev-files', 'module-point-not-installed', 'formatter-migrations', 'formatter-generated', 'shared-state-memory', 'asset-in-views', 'asset-route', 'seal-head-copied', 'i18n-missing-key', 'i18n-layer-override', 'i18n-layer-missing', 'console-output', 'undeclared-section', 'template-fix-missing', 'wait-count-refusal', 'in-process-queue', 'private-pool', 'overload-off', 'readiness-off', 'fixed-owner-cap', 'shared-folder'];
|
|
2
2
|
export type RuleName = (typeof RULES)[number];
|
|
3
3
|
/** Rules a `// dokebi-check: allow <rule> <reason>` comment may silence (D-0072 §4, markers). */
|
|
4
4
|
export declare const MARKABLE: ReadonlySet<RuleName>;
|
|
@@ -22,3 +22,9 @@ export interface Problem {
|
|
|
22
22
|
readonly fix: string;
|
|
23
23
|
}
|
|
24
24
|
export declare function byPlace(a: Problem, b: Problem): number;
|
|
25
|
+
/**
|
|
26
|
+
* Problems sorted by place, one per rule and line: a module of src/shared/browser/ that
|
|
27
|
+
* tsconfig.json still includes (a project from before D-0226) is read by both programs, whose
|
|
28
|
+
* messages may differ (floating-promise says "in the browser" there), D-0226 §3.
|
|
29
|
+
*/
|
|
30
|
+
export declare function uniqueProblems(sorted: readonly Problem[]): Problem[];
|
package/dist/check/problems.js
CHANGED
|
@@ -6,7 +6,8 @@
|
|
|
6
6
|
// undeclared-section D-0155; wait-count-refusal AI-M34, @dokebi/db AI.md 1.2 and 6.4; polling-loop
|
|
7
7
|
// AI-M35, not markable; in-process-queue AI-M35; private-pool, overload-off and fixed-owner-cap AI-M37; readiness-off M51;
|
|
8
8
|
// shared-state-memory D-0161; asset-in-views R1; asset-route R6; seal-head-copied R7;
|
|
9
|
-
// i18n-missing-key community request A2; i18n-layer-override and i18n-layer-missing D-0181
|
|
9
|
+
// i18n-missing-key community request A2; i18n-layer-override and i18n-layer-missing D-0181;
|
|
10
|
+
// shared-folder D-0226).
|
|
10
11
|
export const RULES = [
|
|
11
12
|
'empty-catch',
|
|
12
13
|
'missing-cause',
|
|
@@ -48,6 +49,7 @@ export const RULES = [
|
|
|
48
49
|
'overload-off',
|
|
49
50
|
'readiness-off',
|
|
50
51
|
'fixed-owner-cap',
|
|
52
|
+
'shared-folder',
|
|
51
53
|
];
|
|
52
54
|
/** Rules a `// dokebi-check: allow <rule> <reason>` comment may silence (D-0072 §4, markers). */
|
|
53
55
|
export const MARKABLE = new Set([
|
|
@@ -104,6 +106,7 @@ export const WARNING_RULES = new Set([
|
|
|
104
106
|
'wait-count-refusal',
|
|
105
107
|
'in-process-queue',
|
|
106
108
|
'fixed-owner-cap',
|
|
109
|
+
'shared-folder',
|
|
107
110
|
]);
|
|
108
111
|
/**
|
|
109
112
|
* The rules that read browser code outside the program — .vue scripts and the .js under views/
|
|
@@ -118,3 +121,21 @@ export const BROWSER_RULES = new Set([
|
|
|
118
121
|
export function byPlace(a, b) {
|
|
119
122
|
return a.file.localeCompare(b.file) || a.line - b.line || a.rule.localeCompare(b.rule);
|
|
120
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Problems sorted by place, one per rule and line: a module of src/shared/browser/ that
|
|
126
|
+
* tsconfig.json still includes (a project from before D-0226) is read by both programs, whose
|
|
127
|
+
* messages may differ (floating-promise says "in the browser" there), D-0226 §3.
|
|
128
|
+
*/
|
|
129
|
+
export function uniqueProblems(sorted) {
|
|
130
|
+
const kept = [];
|
|
131
|
+
for (const problem of sorted) {
|
|
132
|
+
const last = kept.at(-1);
|
|
133
|
+
if (last !== undefined &&
|
|
134
|
+
last.rule === problem.rule &&
|
|
135
|
+
last.file === problem.file &&
|
|
136
|
+
last.line === problem.line)
|
|
137
|
+
continue;
|
|
138
|
+
kept.push(problem);
|
|
139
|
+
}
|
|
140
|
+
return kept;
|
|
141
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// The shared-folder rule of `dokebi check` (a warning, D-0226):
|
|
2
|
+
// shared-folder an entry right under src/shared/ that the layout does not name. src/shared
|
|
3
|
+
// holds shared code by kind: the folders of SHARED_FOLDERS (models, services,
|
|
4
|
+
// views, locales, mail, settings, feature modules, and browser for the browser
|
|
5
|
+
// code several apps and modules share) and the app error catalog errors.ts.
|
|
6
|
+
// Server code of one feature belongs in its module, browser code in
|
|
7
|
+
// src/shared/browser/. The shop measured a project drifting into folders of
|
|
8
|
+
// its own (src/shared/shop/, src/shared/browser/ before it was named). Entries
|
|
9
|
+
// whose name starts with a dot (.DS_Store, .gitkeep) are not read.
|
|
10
|
+
import { readdir } from 'node:fs/promises';
|
|
11
|
+
import { join } from 'node:path';
|
|
12
|
+
import { debug, isMissing } from '../diagnostics.js';
|
|
13
|
+
import { CliError } from '../errors.js';
|
|
14
|
+
import { SHARED_FILES, SHARED_FOLDERS } from '../layout.js';
|
|
15
|
+
const RULE = 'shared-folder';
|
|
16
|
+
const FOLDERS = new Set(SHARED_FOLDERS);
|
|
17
|
+
const FILES = new Set(SHARED_FILES);
|
|
18
|
+
/** One warning per entry of src/shared/ the layout does not name. */
|
|
19
|
+
export async function sharedFolderProblems(root) {
|
|
20
|
+
let entries;
|
|
21
|
+
try {
|
|
22
|
+
entries = await readdir(join(root, 'src/shared'), { withFileTypes: true });
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
if (isMissing(error))
|
|
26
|
+
return [];
|
|
27
|
+
throw new CliError('READ_FAILED', 'Cannot read src/shared', { cause: error });
|
|
28
|
+
}
|
|
29
|
+
const problems = [];
|
|
30
|
+
const named = `${[...SHARED_FOLDERS].join(', ')} and ${[...SHARED_FILES].join(', ')}`;
|
|
31
|
+
for (const entry of entries) {
|
|
32
|
+
if (entry.name.startsWith('.'))
|
|
33
|
+
continue;
|
|
34
|
+
const folder = entry.isDirectory();
|
|
35
|
+
if (folder ? FOLDERS.has(entry.name) : FILES.has(entry.name))
|
|
36
|
+
continue;
|
|
37
|
+
const file = `src/shared/${entry.name}`;
|
|
38
|
+
problems.push({
|
|
39
|
+
rule: RULE,
|
|
40
|
+
severity: 'warning',
|
|
41
|
+
file,
|
|
42
|
+
line: 0,
|
|
43
|
+
message: `${file} is ${folder ? 'a folder' : 'a file'} the project layout does not name: src/shared/ holds only ${named}`,
|
|
44
|
+
fix: 'move server code of one feature into its module (src/shared/modules/<name>/: npx dokebi module add <name>), code several features share into src/shared/models/ or src/shared/services/, and browser code several apps or modules share into src/shared/browser/ (components, layouts, composables, styles, lib)',
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
debug('check: shared-folder rule done', { entries: entries.length, problems: problems.length });
|
|
48
|
+
return problems;
|
|
49
|
+
}
|
package/dist/check/vite-rules.js
CHANGED
|
@@ -129,7 +129,7 @@ export async function viteConfigProblems(root, installed) {
|
|
|
129
129
|
const open = (match.index ?? 0) + match[0].length - 1;
|
|
130
130
|
for (const [offset, item] of items(text, code, open))
|
|
131
131
|
if (WIDE_ALLOW.test(item))
|
|
132
|
-
report(offset, `allow: [${item.trim()}] lets the dev server serve the project root or server code (src/ outside views/, tests/, scripts/); through a devHosts tunnel that is public`, 'allow only
|
|
132
|
+
report(offset, `allow: [${item.trim()}] lets the dev server serve the project root or server code (src/ outside views/, tests/, scripts/); through a devHosts tunnel that is public`, 'allow only folders whose files the browser loads by URL without an import; the views folders and every file a served page imports (src/shared/browser/, D-0226) are allowed already');
|
|
133
133
|
}
|
|
134
134
|
debug('check: vite config read for the dev file rule', { file, problems: problems.length });
|
|
135
135
|
return problems;
|
package/dist/generator.d.ts
CHANGED
|
@@ -56,7 +56,8 @@ export declare const MAIN_SOURCE: string;
|
|
|
56
56
|
/**
|
|
57
57
|
* tsconfig.json written by init. `node src/main.ts` strips types without compiling, so the
|
|
58
58
|
* editor and `tsc` should reject syntax Node cannot run (erasableSyntaxOnly) and need explicit
|
|
59
|
-
* `.ts` imports and `import type` (allowImportingTsExtensions, verbatimModuleSyntax).
|
|
59
|
+
* `.ts` imports and `import type` (allowImportingTsExtensions, verbatimModuleSyntax). Browser code
|
|
60
|
+
* (BROWSER_CODE) is left to tsconfig.vue.json (D-0226).
|
|
60
61
|
*/
|
|
61
62
|
/**
|
|
62
63
|
* Development tools `dokebi init` pins in a new project (stage 3 §0). `@dokebi/cli` is the CLI
|
|
@@ -75,4 +76,10 @@ export declare const TYPECHECK_SCRIPT = "tsc -p tsconfig.json --noEmit";
|
|
|
75
76
|
* named *.test.ts (D-0092 §3, the "Files and folders" rule of capability-guide.ts).
|
|
76
77
|
*/
|
|
77
78
|
export declare const TEST_SCRIPT = "node --test \"tests/**/*.test.ts\"";
|
|
79
|
+
/**
|
|
80
|
+
* The browser code of a project (D-0226): the views folders of apps and modules (Vue pages and
|
|
81
|
+
* their .ts helpers) and the code they share. tsconfig.json leaves it out; tsconfig.vue.json of
|
|
82
|
+
* `app add --inertia` checks its .ts with vue-tsc.
|
|
83
|
+
*/
|
|
84
|
+
export declare const BROWSER_CODE: readonly string[];
|
|
78
85
|
export declare const TSCONFIG_SOURCE: string;
|
package/dist/generator.js
CHANGED
|
@@ -325,7 +325,8 @@ export const MAIN_SOURCE = MAIN_SOURCE_V5.replace('resolve(process.env.DOKEBI_CO
|
|
|
325
325
|
/**
|
|
326
326
|
* tsconfig.json written by init. `node src/main.ts` strips types without compiling, so the
|
|
327
327
|
* editor and `tsc` should reject syntax Node cannot run (erasableSyntaxOnly) and need explicit
|
|
328
|
-
* `.ts` imports and `import type` (allowImportingTsExtensions, verbatimModuleSyntax).
|
|
328
|
+
* `.ts` imports and `import type` (allowImportingTsExtensions, verbatimModuleSyntax). Browser code
|
|
329
|
+
* (BROWSER_CODE) is left to tsconfig.vue.json (D-0226).
|
|
329
330
|
*/
|
|
330
331
|
/**
|
|
331
332
|
* Development tools `dokebi init` pins in a new project (stage 3 §0). `@dokebi/cli` is the CLI
|
|
@@ -348,6 +349,16 @@ export const TYPECHECK_SCRIPT = 'tsc -p tsconfig.json --noEmit';
|
|
|
348
349
|
* named *.test.ts (D-0092 §3, the "Files and folders" rule of capability-guide.ts).
|
|
349
350
|
*/
|
|
350
351
|
export const TEST_SCRIPT = 'node --test "tests/**/*.test.ts"';
|
|
352
|
+
/**
|
|
353
|
+
* The browser code of a project (D-0226): the views folders of apps and modules (Vue pages and
|
|
354
|
+
* their .ts helpers) and the code they share. tsconfig.json leaves it out; tsconfig.vue.json of
|
|
355
|
+
* `app add --inertia` checks its .ts with vue-tsc.
|
|
356
|
+
*/
|
|
357
|
+
export const BROWSER_CODE = Object.freeze([
|
|
358
|
+
'src/apps/*/views/**',
|
|
359
|
+
'src/shared/modules/*/views/**',
|
|
360
|
+
'src/shared/browser/**',
|
|
361
|
+
]);
|
|
351
362
|
export const TSCONFIG_SOURCE = `${JSON.stringify({
|
|
352
363
|
compilerOptions: {
|
|
353
364
|
target: 'ES2023',
|
|
@@ -365,4 +376,7 @@ export const TSCONFIG_SOURCE = `${JSON.stringify({
|
|
|
365
376
|
types: ['node'],
|
|
366
377
|
},
|
|
367
378
|
include: ['src/**/*.ts', 'tests/**/*.ts'],
|
|
379
|
+
// D-0226: browser code — the views of apps and modules and what they share — is checked by
|
|
380
|
+
// vue-tsc (tsconfig.vue.json, with Vite's types), not as server code.
|
|
381
|
+
exclude: BROWSER_CODE,
|
|
368
382
|
}, null, 2)}\n`;
|
package/dist/layout.d.ts
CHANGED
|
@@ -10,6 +10,14 @@ import type { InstallPlan } from './install-plan.js';
|
|
|
10
10
|
* (each app's folder is made by `dokebi app add`).
|
|
11
11
|
*/
|
|
12
12
|
export declare function layoutAllowed(path: string, hosts?: readonly string[], kind?: 'file' | 'directory'): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* What the layout names right under src/shared/ (D-0031, D-0032, D-0155, D-0226): shared models
|
|
15
|
+
* and services, layouts and partials (views), translation catalogs, mail templates, application
|
|
16
|
+
* settings, feature modules, the browser code several apps and modules share, and the app error
|
|
17
|
+
* catalog. `dokebi check` warns about any other entry (shared-folder).
|
|
18
|
+
*/
|
|
19
|
+
export declare const SHARED_FOLDERS: readonly ["browser", "locales", "mail", "models", "modules", "services", "settings", "views"];
|
|
20
|
+
export declare const SHARED_FILES: readonly ["errors.ts"];
|
|
13
21
|
/** Rejects plugin files and folders outside the layout with INVALID_MANIFEST. */
|
|
14
22
|
export declare function assertLayout(plan: Pick<InstallPlan, 'files' | 'directories'> & {
|
|
15
23
|
entry?: {
|
package/dist/layout.js
CHANGED
|
@@ -21,6 +21,23 @@ export function layoutAllowed(path, hosts = [], kind = 'file') {
|
|
|
21
21
|
return true;
|
|
22
22
|
return hosts.includes('apps') && (key === 'src/apps' || key.startsWith('src/apps/'));
|
|
23
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* What the layout names right under src/shared/ (D-0031, D-0032, D-0155, D-0226): shared models
|
|
26
|
+
* and services, layouts and partials (views), translation catalogs, mail templates, application
|
|
27
|
+
* settings, feature modules, the browser code several apps and modules share, and the app error
|
|
28
|
+
* catalog. `dokebi check` warns about any other entry (shared-folder).
|
|
29
|
+
*/
|
|
30
|
+
export const SHARED_FOLDERS = Object.freeze([
|
|
31
|
+
'browser',
|
|
32
|
+
'locales',
|
|
33
|
+
'mail',
|
|
34
|
+
'models',
|
|
35
|
+
'modules',
|
|
36
|
+
'services',
|
|
37
|
+
'settings',
|
|
38
|
+
'views',
|
|
39
|
+
]);
|
|
40
|
+
export const SHARED_FILES = Object.freeze(['errors.ts']);
|
|
24
41
|
/** Rejects plugin files and folders outside the layout with INVALID_MANIFEST. */
|
|
25
42
|
export function assertLayout(plan, pluginId, hosts = []) {
|
|
26
43
|
const targets = [
|
package/dist/output.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export declare const CLI_VERSION = "0.4.
|
|
1
|
+
export declare const CLI_VERSION = "0.4.53";
|
|
2
2
|
export declare function envelope(command: string, result: unknown, ok?: boolean): object;
|
|
3
3
|
export declare function failure(command: string, error: unknown, mutationStarted: boolean): object;
|
package/dist/output.js
CHANGED