lakutata 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -144,8 +144,8 @@ on. Each package's README lists its exceptions.
144
144
  `Entrypoint.md`, `Middlewares.md`, `HTTP.md`, `CLI.md`, `ServiceCalls.md`, `GRPC.md`, `NATS.md`, `Schedules.md`,
145
145
  `Queue.md`, `Database.md`, `DatabaseDrivers.md`, `MongoEmbedded.md`, `Entities.md`, `Migrations.md`, `Cache.md`,
146
146
  `Mutex.md`, `I18n.md`, `DockerIntegration.md`, `ContainerdIntegration.md`, `Monitor.md`, `Security.md`, `DBus.md`,
147
- `MCP.md`, `Command.md`, `Workspaces.md`, `NativeAddons.md`, `Packaging.md`, `Installers.md`; and the examples, in
148
- `doc/en/examples` and `doc/zh/examples`: whole applications built from the templates.
147
+ `MCP.md`, `WebRTC.md`, `Command.md`, `Workspaces.md`, `NativeAddons.md`, `Packaging.md`, `Installers.md`; and the
148
+ examples, in `doc/en/examples` and `doc/zh/examples`: whole applications built from the templates.
149
149
  - `@lakutata/cli`: creating, building and packaging applications.
150
150
  - The official Agent Skill for AI coding assistants that work on lakutata projects:
151
151
  [lakutata.com/skill](https://lakutata.com/skill/).
package/README.zh-CN.md CHANGED
@@ -121,7 +121,7 @@ Application
121
121
  ## 另见
122
122
 
123
123
  - 网站 <https://lakutata.com/zh/>:指南、示例和 API 参考,中英文都有。
124
- - 指南在这个包的 `doc/zh`(中文)和 `doc/en`(英文)中:`Overview.md`、`GettingStarted.md`、`ProjectStructure.md`、`UpgradingFrom2.md`、`UpgradingFrom1.md`、`Application.md`、`Objects.md`、`Injection.md`、`DTOValidation.md`、`Exceptions.md`、`Logger.md`、`Decorator.md`、`Time.md`、`HelperFunctions.md`、`Controllers.md`、`Entrypoint.md`、`Middlewares.md`、`HTTP.md`、`CLI.md`、`ServiceCalls.md`、`GRPC.md`、`NATS.md`、`Schedules.md`、`Queue.md`、`Database.md`、`DatabaseDrivers.md`、`MongoEmbedded.md`、`Entities.md`、`Migrations.md`、`Cache.md`、`Mutex.md`、`I18n.md`、`DockerIntegration.md`、`ContainerdIntegration.md`、`Monitor.md`、`Security.md`、`DBus.md`、`MCP.md`、`Command.md`、`Workspaces.md`、`NativeAddons.md`、`Packaging.md`、`Installers.md`;示例在 `doc/zh/examples` 和 `doc/en/examples` 中:从模板构建的完整应用。
124
+ - 指南在这个包的 `doc/zh`(中文)和 `doc/en`(英文)中:`Overview.md`、`GettingStarted.md`、`ProjectStructure.md`、`UpgradingFrom2.md`、`UpgradingFrom1.md`、`Application.md`、`Objects.md`、`Injection.md`、`DTOValidation.md`、`Exceptions.md`、`Logger.md`、`Decorator.md`、`Time.md`、`HelperFunctions.md`、`Controllers.md`、`Entrypoint.md`、`Middlewares.md`、`HTTP.md`、`CLI.md`、`ServiceCalls.md`、`GRPC.md`、`NATS.md`、`Schedules.md`、`Queue.md`、`Database.md`、`DatabaseDrivers.md`、`MongoEmbedded.md`、`Entities.md`、`Migrations.md`、`Cache.md`、`Mutex.md`、`I18n.md`、`DockerIntegration.md`、`ContainerdIntegration.md`、`Monitor.md`、`Security.md`、`DBus.md`、`MCP.md`、`WebRTC.md`、`Command.md`、`Workspaces.md`、`NativeAddons.md`、`Packaging.md`、`Installers.md`;示例在 `doc/zh/examples` 和 `doc/en/examples` 中:从模板构建的完整应用。
125
125
  - `@lakutata/cli`:创建、构建和打包应用。
126
126
  - 官方 Agent Skill(智能体技能),供 AI 编程助手在 lakutata 项目中使用:<https://lakutata.com/zh/skill/>。
127
127
 
package/doc/en/HTTP.md CHANGED
@@ -113,7 +113,7 @@ The options of `expressHTTPEntrypoint()`:
113
113
  | `port` | `80` | The port; `0` picks a free port. A port already in use fails the application's start |
114
114
  | `host` | all the interfaces | The address to listen on, such as `'127.0.0.1'` for the local machine only |
115
115
  | `name` | | The name of the adapter, to tell several adapters apart |
116
- | `body` | `{limit: '1mb'}` | The size limit of the JSON and URL-encoded bodies (`'5mb'`, or a number of bytes); `false` parses no body |
116
+ | `body` | `{limit: '1mb'}` | The size limit of the bodies (`'5mb'`, or a number of bytes); `text`: the content types read as text (section 4); `false` parses no body |
117
117
  | `server` | | The options of the Node.js HTTP server: `keepAliveTimeout`, `headersTimeout`, `requestTimeout`… |
118
118
  | `app` | a new application | An existing Express application to add the actions to |
119
119
  | `input` | the query and the body | Builds the input from the request (section 4) |
@@ -124,9 +124,10 @@ The options of `expressHTTPEntrypoint()`:
124
124
  | `stop` | | Called when the adapter stops, once its server is closed |
125
125
  | `heartbeat` | `15000` | How often a comment keeps the event streams alive, in milliseconds (section 5) |
126
126
 
127
- `fastifyHTTPEntrypoint()` takes the same options, except `body`, `server` and `app`, replaced by `fastify`: a Fastify
128
- instance, or the options of the instance to create (`bodyLimit`, 1 MiB by default; `trustProxy`; `connectionTimeout`,
129
- `keepAliveTimeout`, `requestTimeout`; `logger`…).
127
+ `fastifyHTTPEntrypoint()` takes the same options, except `server` and `app`, replaced by `fastify`: a Fastify instance,
128
+ or the options of the instance to create (`bodyLimit`, 1 MiB by default; `trustProxy`; `connectionTimeout`,
129
+ `keepAliveTimeout`, `requestTimeout`; `logger`…). Its `body` option has only `text`, the size limit being the
130
+ `bodyLimit` of the instance.
130
131
 
131
132
  Where they differ:
132
133
 
@@ -209,6 +210,9 @@ before the validation, without the route parameters.
209
210
  send a list inside an object (`{"items": [...]}`).
210
211
  - **Forms.** Express parses the URL-encoded bodies, the brackets nested (`a[b]=1` → `a: {b: '1'}`); Fastify refuses them
211
212
  with 415. Neither parses `multipart/form-data`, the file uploads (section 7).
213
+ - **Other text.** The content types listed in `body.text` (`['application/sdp']`, or `'text/*'` for a whole type) are
214
+ read as text, given to the action in the `body` property of its input. Fastify refuses the other types it does not
215
+ parse with 415.
212
216
  - **Limits.** A body over the limit is refused with 413, malformed JSON with 400.
213
217
 
214
218
  The `input` option builds the input from the request. For example, to give the actions the address of the client and
@@ -46,8 +46,8 @@ tool, a web and a desktop application, calls between services, background jobs,
46
46
 
47
47
  Not part of this package: `@lakutata/cli` (the `lakutata` command for creating projects, running migrations and packing
48
48
  applications, see [Command](Command.md)), `@lakutata/grpc` (a gRPC client, server and service transport),
49
- `@lakutata/nats` (a NATS component and service transport), `@lakutata/dbus` (D-Bus) and `@lakutata/mcp` (the Model
50
- Context Protocol).
49
+ `@lakutata/nats` (a NATS component and service transport), `@lakutata/dbus` (D-Bus), `@lakutata/mcp` (the Model
50
+ Context Protocol) and `@lakutata/webrtc` (WebRTC: the signaling, a TURN server, a media server, peer connections).
51
51
 
52
52
  ## The guides
53
53
 
@@ -90,6 +90,7 @@ Context Protocol).
90
90
  | [Security](Security.md) | Hashing, ciphers, signatures, passwords |
91
91
  | [DBus](DBus.md) | A D-Bus service and client (`@lakutata/dbus`): methods, objects, properties, signals |
92
92
  | [MCP](MCP.md) | The tools, resources and prompts of the Model Context Protocol (`@lakutata/mcp`), over stdio and HTTP |
93
+ | [WebRTC](WebRTC.md) | Peer-to-peer connections and a media server (`@lakutata/webrtc`): the signaling, the TURN server, browsers and applications, the actions of an application called through data channels, WHIP and WHEP |
93
94
  | [Command](Command.md) | The `lakutata` command: creating projects, migrations, translations, environment variables |
94
95
  | [Workspaces](Workspaces.md) | Projects of several packages: running their scripts, giving them a version, adding packages |
95
96
  | [NativeAddons](NativeAddons.md) | Native addons in C++ or Rust: creating them, linking libraries, shipping them |
@@ -3,8 +3,9 @@
3
3
  A service action (`@ServiceAction`) is called with a message rather than a URL: an object whose keys select the action,
4
4
  its **pattern**, and whose other keys are the input. The same actions can be served over several transports at once:
5
5
  plain HTTP, Socket.IO, JSON-RPC 2.0 (over HTTP, WebSocket or the standard input and output) and the IPC of Electron, as
6
- this guide describes, and gRPC and NATS, which have their own guides. The controllers and their actions are described
7
- in [Controllers](Controllers.md), the entrypoint and its adapters in [Entrypoint](Entrypoint.md).
6
+ this guide describes, and gRPC, NATS and the data channels of WebRTC, which have their own guides. The controllers and
7
+ their actions are described in [Controllers](Controllers.md), the entrypoint and its adapters in
8
+ [Entrypoint](Entrypoint.md).
8
9
 
9
10
  ## 1. A first service
10
11
 
@@ -180,6 +181,7 @@ export async function call<T>(message: Record<string, unknown>): Promise<T> {
180
181
  | `electronIPCServiceEntrypoint()` | `lakutata/adapter/electron` | (Electron) | `ipcRenderer.invoke()` | IPC messages |
181
182
  | `grpcServiceEntrypoint()` | `@lakutata/grpc/service` | `@lakutata/grpc` | See [GRPC](GRPC.md) | gRPC streams |
182
183
  | `natsServiceEntrypoint()` | `@lakutata/nats` | `@lakutata/nats` | See [NATS](NATS.md) | NATS messages |
184
+ | `webrtcServiceEntrypoint()` | `@lakutata/webrtc` | `@lakutata/webrtc` | A JSON-RPC 2.0 request on a data channel, see [WebRTC](WebRTC.md) | Notifications |
183
185
 
184
186
  Each adapter also takes `name`, to tell several adapters apart, and `middlewares`, run after those of the entrypoint
185
187
  (see [Middlewares](Middlewares.md)).
@@ -459,6 +461,7 @@ The transports that keep their clients connected can push events to them. A clie
459
461
  | JSON-RPC over WebSocket | The `id` header or `id` query parameter of the connection, else a random id |
460
462
  | JSON-RPC over stdio | `'stdio'` |
461
463
  | Electron | The id the page gives when it subscribes or invokes |
464
+ | WebRTC | The member id of the caller in its room |
462
465
 
463
466
  An action reads the id of its client in `this.context.clientId`. The `entrypoint` component pushes the events:
464
467
 
@@ -493,12 +496,13 @@ A client receives `notify(clientId, 'progress', 50, 'half')` as:
493
496
  | Socket.IO | `socket.on('progress', (percent, label) => …)` |
494
497
  | JSON-RPC (WebSocket, stdio) | `{"jsonrpc": "2.0", "method": "progress", "params": [50, "half"]}` |
495
498
  | Electron | `('progress', [50, 'half'])`, through the `subscribe` of the preload script above |
499
+ | WebRTC | `proxy.on('progress', (percent, label) => …)` of a `PeerServiceProxy` |
496
500
 
497
501
  ## 6. Stopping and leaving
498
502
 
499
503
  - When the application stops, the new requests fail with `EntrypointStoppedException` (`E_ENTRYPOINT_STOPPED`; the
500
504
  code `-32001` over JSON-RPC), and the requests in progress get the `shutdownTimeout` of the entrypoint (see
501
505
  [Entrypoint](Entrypoint.md), section 4).
502
- - When a client leaves before its response (a socket disconnected, a window closed, an HTTP connection closed), the
503
- `this.signal` of its request is aborted.
506
+ - When a client leaves before its response (a socket disconnected, a window closed, an HTTP connection closed, a data
507
+ channel closed), the `this.signal` of its request is aborted.
504
508
  - The transports set no time limit to the calls: a client sets its own, such as `socket.timeout(5000)` above.