@nilejs/cli 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 nile-js
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -107,7 +107,7 @@ Every registered action is included in `ServicePayloads`. Actions without a vali
107
107
 
108
108
  ## Current starter
109
109
 
110
- The starter uses Nile `^1.0.5`, Zod 4, TypeScript 7 and the Drizzle model helpers. The generated layout passes Nile’s strict boot checks. Database setup returns a Result and prevents startup on failure; shutdown drains Nile’s work before closing PGlite. Helpers are available as `utils.createModel`, and Result helpers come from `@nilejs/nile/fp`.
110
+ The starter uses Nile `^1.1.0`, Zod 4, TypeScript 7 and the Drizzle model helpers. The generated layout passes Nile’s strict boot checks. Database setup returns a Result and prevents startup on failure; shutdown drains Nile’s work before closing PGlite. Helpers are available as `utils.createModel`, and Result helpers come from `@nilejs/nile/fp`.
111
111
 
112
112
  Existing apps are not rewritten when the CLI updates. For an older starter, add a service entry point at `src/services/<domain>/index.ts`, register its actions there, and import that service from `services.config.ts`. [Nile’s migration notes](https://github.com/nile-js/nile/blob/main/packages/nile/docs/release-migration.md) describe the current error and startup behavior.
113
113
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nilejs/cli",
3
- "version": "1.0.3",
3
+ "version": "1.1.0",
4
4
  "description": "CLI for scaffolding and generating Nile backend projects",
5
5
  "type": "module",
6
6
  "bin": {
@@ -10,6 +10,31 @@
10
10
  "dist",
11
11
  "template"
12
12
  ],
13
+ "homepage": "https://nile-js.github.io/nile/",
14
+ "bugs": {
15
+ "url": "https://github.com/nile-js/nile/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/nile-js/nile.git",
20
+ "directory": "packages/cli"
21
+ },
22
+ "author": "Hussein Kizz",
23
+ "license": "MIT",
24
+ "keywords": [
25
+ "nile",
26
+ "cli",
27
+ "scaffolding",
28
+ "generator",
29
+ "codegen",
30
+ "backend",
31
+ "typescript",
32
+ "bun",
33
+ "zod"
34
+ ],
35
+ "publishConfig": {
36
+ "access": "public"
37
+ },
13
38
  "dependencies": {
14
39
  "commander": "^13.1.0",
15
40
  "json-schema-to-zod": "^2.7.0",
@@ -85,7 +85,7 @@ Responses have exactly `status`, `message` and `data`. The default success messa
85
85
 
86
86
  ## Optional features
87
87
 
88
- Keep business logic in actions and ordinary functions. Configure other features when the product needs them: [typed Socket.IO topics](https://nile-js.github.io/nile/guide/features/websockets/), [cron jobs](https://nile-js.github.io/nile/guide/features/cron-jobs/), [rate limits](https://nile-js.github.io/nile/guide/features/rate-limiting/), [queues](https://nile-js.github.io/nile/guide/features/queues-debounce-throttle/) and [telemetry](https://nile-js.github.io/nile/guide/features/telemetry/). The frontend package provides both `createNileClient` and a separate `createNileSocketClient`.
88
+ Keep business logic in actions and ordinary functions. Configure other features when the product needs them: [typed Socket.IO topics](https://nile-js.github.io/nile/guide/features/websockets/), [cron jobs](https://nile-js.github.io/nile/guide/features/cron-jobs/), [rate limits](https://nile-js.github.io/nile/guide/features/rate-limiting/), [queues](https://nile-js.github.io/nile/guide/features/queues-debounce-throttle/) and [telemetry](https://nile-js.github.io/nile/guide/features/telemetry/). On the frontend, `createNileClient` calls actions and sends and receives topics through `nile.socket`.
89
89
 
90
90
  ## Adding services
91
91
 
package/template/SKILL.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: nile
3
- description: Work in a Nile Js backend (@nilejs/nile 1.x). Organize business operations as services and actions with Zod validation, Result returns, hooks, JWT protection and typed clients. Use when adding or changing actions, services, hooks, uploads, topics, schedules or the @nilejs/client calls in a Nile Js project.
3
+ description: Work in a Nile Js backend (@nilejs/nile 2.x). Organize business operations as services and actions with Zod validation, Result returns, hooks, JWT protection and typed clients. Use when adding or changing actions, services, hooks, uploads, topics, schedules or the @nilejs/client calls in a Nile Js project.
4
4
  license: MIT
5
5
  ---
6
6
 
@@ -39,7 +39,6 @@ src/
39
39
  client.ts connection and driver
40
40
  models/ persistence operations
41
41
  hooks/ shared action policies
42
- business/ optional reusable domain functions
43
42
  generated/ client payload/schema contracts
44
43
  ```
45
44
 
@@ -258,7 +257,7 @@ This helper is internal: its failure still needs translation before being return
258
257
 
259
258
  - HTTP: `POST /api/services` with `{ "intent": "execute", "service": "projects", "action": "create", "payload": { ... } }`.
260
259
  - Client (`@nilejs/client`): `createNileClient<Payloads>({ baseUrl })`, then `await nile.invoke({ service, action, payload })`. Every method returns a Result: `if (result.isErr) { ... return; }`, then read `result.value`. On failure `result.error` is the message and `result.details` holds the server's `data`. `data` is a deprecated alias; do not use it.
261
- - Sockets: `createNileSocketClient<Actions, Topics>` owns its connection. Use `socket.invoke`, `socket.send` and `socket.receive`; check each Result and unsubscribe/close when finished. Declare backend topics and validate their data and scope; frontend types come from shared or generated definitions. Authorization is still a backend policy.
260
+ - Topics: define each with `createTopic({ name, data, scope?, canReceive?, canSend? })` and pass `createTopics([...])` to the server `socket` config. A missing `canReceive` or `canSend` denies clients. Connections verify the server `auth` JWT; `user` in the checks is `{ userId, organizationId, claims }` or `undefined`. In actions, `const { socket } = getContext({ topics })`, then `socket.send({ topic, scope?, to?: { userId } | { connectionId }, data })` after the write commits. On the frontend, `nile.socket.receive({ topic, scope, onMessage })` subscribes and returns a Result holding `unsubscribe()`; `nile.socket.send` sends. Sockets do not call actions; use `nile.invoke`.
262
261
  - Server code: `await server.invoke({ service, action, payload, credentials? })`. Protected actions need `credentials` with headers.
263
262
  - Uploads: `nile.upload({ service, action, files, fields })` for `isSpecial: { contentType: "multipart/form-data" }` actions. A JSON request to such an action returns HTTP 400.
264
263
 
@@ -267,7 +266,7 @@ This helper is internal: its failure still needs translation before being return
267
266
  1. Find the domain in `services.config.ts` and read its `index.ts`. Name the action for the business operation, then define its input schema and named handler.
268
267
  2. Keep a short, single-use rule in that handler. Extract ordinary domain functions when a rule is reused, complicated enough to test independently, or coordinates a transaction. Do not create a repository, class or service layer solely because a folder exists.
269
268
  3. Put data access in the project’s model convention. `utils.createModel` and `utils.getZodSchema` are optional Drizzle helpers; a handwritten model is also valid. Pass the database or transaction explicitly where transaction ownership matters.
270
- 4. For a growing action, move its private helpers under its action folder’s `modules/`. Put helpers shared by the domain in the service’s `modules/`. Cross-domain rules can use `business/` when useful. Do not expose a private helper as an action just to call it.
269
+ 4. For a growing action, move its private helpers under its action folder’s `modules/`. Put helpers shared by the domain in the service’s `modules/`. A rule another domain also needs stays in the domain that owns it; the other service imports it from there. Do not expose a private helper as an action just to call it.
271
270
  5. Register the action in the domain’s `actions` list. An export alone does not make it reachable. Register a new service in the root registry.
272
271
  6. Carry validated input into business functions and trusted identity into policy checks. Keep request identity in scoped sessions and execution state, not process-wide context values.
273
272
  7. Verify the registered operation through `server.invoke` or a transport when changing validation, permissions or registration. Test a transaction’s rollback and idempotency when those are part of the business guarantee.
@@ -311,7 +310,7 @@ Read the page for the feature you change before you write code:
311
310
  - [Cron jobs](https://nile-js.github.io/nile/guide/features/cron-jobs)
312
311
  - [Database models](https://nile-js.github.io/nile/guide/features/database-models)
313
312
  - [API discovery and schemas](https://nile-js.github.io/nile/guide/features/api-discovery)
314
- - [HTTP, WebSocket and direct calls](https://nile-js.github.io/nile/guide/features/calling-actions)
313
+ - [HTTP and direct calls](https://nile-js.github.io/nile/guide/features/calling-actions)
315
314
  - [Retries and utilities](https://nile-js.github.io/nile/guide/features/retries-and-utilities)
316
315
  - [Rate limiting](https://nile-js.github.io/nile/guide/features/rate-limiting)
317
316
  - [File uploads](https://nile-js.github.io/nile/guide/features/file-uploads)
@@ -337,7 +336,7 @@ Advanced pages cover handler context, composed hooks, execution options and test
337
336
  - A global before hook's returned value does not replace the payload. Use a local hook to transform input.
338
337
  - A local hook does not protect the parent action.
339
338
  - `context.set` values are shared by all requests. Never store the current user there.
340
- - A rate limit or topic policy that is missing denies or does not apply. Read the feature page for the default.
339
+ - A rate limit or topic permission (`canReceive`, `canSend`) that is missing denies or does not apply. Read the feature page for the default.
341
340
  - Multiple replicas each keep their own queues, schedules, rate-limit counters and WebSocket subscriptions.
342
341
  - JWT failures return fixed messages such as `JWT authentication failed: token expired` or `JWT authentication failed: invalid token`. They never include the token or its claims, so do not add them back in your own logs.
343
342
  - Import Results from `@nilejs/nile/fp`, not a separately installed `slang-ts`. Two copies of `slang-ts` produce type errors.
@@ -12,7 +12,7 @@
12
12
  "typecheck": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@nilejs/nile": "^1.0.5",
15
+ "@nilejs/nile": "^1.1.0",
16
16
  "@electric-sql/pglite": "^0.2.5",
17
17
  "drizzle-orm": "^0.45.4",
18
18
  "pino": "^10.4.0",