@velarscript/node 0.11.1 → 0.12.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 +102 -14
- package/dist/compiler.d.ts +3 -0
- package/dist/compiler.d.ts.map +1 -1
- package/dist/compiler.js +300 -76
- package/dist/compiler.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/node-host-runtime.d.ts.map +1 -1
- package/dist/node-host-runtime.js +30 -14
- package/dist/node-host-runtime.js.map +1 -1
- package/dist/node-host-worker-runtime.d.ts.map +1 -1
- package/dist/node-host-worker-runtime.js +495 -93
- package/dist/node-host-worker-runtime.js.map +1 -1
- package/dist/project-config.d.ts +17 -0
- package/dist/project-config.d.ts.map +1 -0
- package/dist/project-config.js +66 -0
- package/dist/project-config.js.map +1 -0
- package/dist/serve-runtime.d.ts.map +1 -1
- package/dist/serve-runtime.js +2942 -158
- package/dist/serve-runtime.js.map +1 -1
- package/dist/server-analyzer.d.ts +35 -0
- package/dist/server-analyzer.d.ts.map +1 -0
- package/dist/server-analyzer.js +692 -0
- package/dist/server-analyzer.js.map +1 -0
- package/dist/server-ast.d.ts +54 -0
- package/dist/server-ast.d.ts.map +1 -0
- package/dist/server-ast.js +16 -0
- package/dist/server-ast.js.map +1 -0
- package/dist/server-emitter.d.ts +17 -0
- package/dist/server-emitter.d.ts.map +1 -0
- package/dist/server-emitter.js +177 -0
- package/dist/server-emitter.js.map +1 -0
- package/dist/server-inspection.d.ts +3 -0
- package/dist/server-inspection.d.ts.map +1 -0
- package/dist/server-inspection.js +12 -0
- package/dist/server-inspection.js.map +1 -0
- package/dist/server-lexer.d.ts +13 -0
- package/dist/server-lexer.d.ts.map +1 -0
- package/dist/server-lexer.js +65 -0
- package/dist/server-lexer.js.map +1 -0
- package/dist/server-parser.d.ts +18 -0
- package/dist/server-parser.d.ts.map +1 -0
- package/dist/server-parser.js +232 -0
- package/dist/server-parser.js.map +1 -0
- package/dist/server-semantic.d.ts +3 -0
- package/dist/server-semantic.d.ts.map +1 -0
- package/dist/server-semantic.js +31 -0
- package/dist/server-semantic.js.map +1 -0
- package/dist/server-types.d.ts +25 -0
- package/dist/server-types.d.ts.map +1 -0
- package/dist/server-types.js +60 -0
- package/dist/server-types.js.map +1 -0
- package/dist/websocket-runtime.d.ts.map +1 -1
- package/dist/websocket-runtime.js +169 -15
- package/dist/websocket-runtime.js.map +1 -1
- package/package.json +10 -2
- package/dist/sqlite-runtime.d.ts +0 -3
- package/dist/sqlite-runtime.d.ts.map +0 -1
- package/dist/sqlite-runtime.js +0 -92
- package/dist/sqlite-runtime.js.map +0 -1
package/README.md
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
The official Node.js runtime boundary for VelarScript. It owns the typed module
|
|
4
4
|
contracts and implementations for `velar/fs`, `velar/env`, `velar/host`,
|
|
5
5
|
`velar/serve`, `velar/path`, `velar/process`, `velar/terminal`,
|
|
6
|
-
`velar/
|
|
7
|
-
`velar/http`.
|
|
6
|
+
`velar/worker`, and `velar/websocket`, plus the Node target of `velar/http`.
|
|
8
7
|
|
|
9
8
|
The API exposes VelarScript contracts rather than Node objects. Filesystem
|
|
10
9
|
operations are bounded, process execution is shell-free and starts with a
|
|
@@ -19,6 +18,92 @@ non-2xx responses, owned cancel/deadline outcomes, and request/response network
|
|
|
19
18
|
transport failure. The transport phase is typed; retry and replay policy stays
|
|
20
19
|
with the provider or application.
|
|
21
20
|
|
|
21
|
+
The package also owns Node's native server syntax and application target. A
|
|
22
|
+
project activates `@velarscript/node`, configures its exported application once
|
|
23
|
+
in `velar.json`, then declares anonymous checked routes directly:
|
|
24
|
+
|
|
25
|
+
```velar
|
|
26
|
+
import {created} from "velar/serve"
|
|
27
|
+
|
|
28
|
+
type CreateArticle:
|
|
29
|
+
title: string
|
|
30
|
+
|
|
31
|
+
export server app:
|
|
32
|
+
@get(p"/health") => {ok: true}
|
|
33
|
+
@get(p"/articles/{id:string}") => {id}
|
|
34
|
+
@post(p"/articles", input: CreateArticle) => created(input)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"formatVersion": 2,
|
|
40
|
+
"entry": "src/main.vel",
|
|
41
|
+
"extensions": ["@velarscript/node"],
|
|
42
|
+
"node": {
|
|
43
|
+
"app": "app",
|
|
44
|
+
"host": "127.0.0.1",
|
|
45
|
+
"port": 3000,
|
|
46
|
+
"maxBodyBytes": 16777216,
|
|
47
|
+
"build": {"sourceMaps": false}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
`velar dev` checks, starts, watches, and restarts the last-good application;
|
|
53
|
+
`velar serve` checks and runs it with production behavior; `velar build` writes
|
|
54
|
+
a standalone production directory whose `.velar-node-entry.mjs` runs with
|
|
55
|
+
Node. Calling `serve(...)` directly remains available for tests, embedded
|
|
56
|
+
servers, and low-level protocol adapters, but it is not required at an
|
|
57
|
+
application entry point.
|
|
58
|
+
|
|
59
|
+
`p"..."` is scanned and checked only by this extension; Core does not acquire a
|
|
60
|
+
general `p` string prefix. Captures use `{name:type}` with a half-width `:` and
|
|
61
|
+
declare the route-scope name once. The five route verbs are compiler-owned
|
|
62
|
+
`@name` roles rather than decorators. The compiler lowers each `server` to an
|
|
63
|
+
immutable `ServeApp`; `velar/serve` owns runtime matching, checked input
|
|
64
|
+
decoding, automatic JSON, composition, static files, middleware, errors, and
|
|
65
|
+
OpenAPI generation. Middleware stays attached to the route table passed to
|
|
66
|
+
`use` when applications are composed; `bodyLimit` narrows inferred JSON input
|
|
67
|
+
per route group. Response helpers accept validated header Maps, and the host
|
|
68
|
+
accepts only final 200–599 statuses and enforces bodyless `HEAD`, 204, and 304
|
|
69
|
+
responses. OpenAPI parameter, request-body, response, content-type, and static
|
|
70
|
+
success-status schemas come from compiler-checked route types rather than
|
|
71
|
+
runtime reflection; applicable framework-generated 400, 401, 413, 415, and 422
|
|
72
|
+
responses are documented automatically. Unexpected handler or middleware failures are
|
|
73
|
+
reported on stderr while the client receives only an opaque 500 response.
|
|
74
|
+
|
|
75
|
+
The framework covers the ordinary service surface without adding controller or
|
|
76
|
+
decorator vocabulary. Route defaults may be explicit `input.query`,
|
|
77
|
+
`input.header`, `input.cookie`, `input.form`, `input.upload`, or
|
|
78
|
+
`input.dependency` values; `security` supplies API-key, Basic, Bearer, OAuth2,
|
|
79
|
+
and OpenID descriptors. `provide` owns request- and application-scoped values,
|
|
80
|
+
deduplicates them, detects cycles, and runs release callbacks at the end of the
|
|
81
|
+
owning scope. `lifecycle`, `background`, cookie helpers, SSE, bounded streaming,
|
|
82
|
+
multipart uploads, route-scoped middleware, offline `docs`, OpenAPI 3.1, and
|
|
83
|
+
the test-only `velar/server-test` client are part of the same checked runtime.
|
|
84
|
+
Repeated scalar query or form fields fail with 422, while checked
|
|
85
|
+
`List<scalar>` inputs preserve all repeated values. Request paths and queries
|
|
86
|
+
are decoded exactly once with invalid UTF-8, encoded separators, NULs, and dot
|
|
87
|
+
segments rejected before routing. Multiple cookies stay separate on the wire.
|
|
88
|
+
`velar/websocket.listen({http: app, ...})` composes the ServeApp lifecycle on
|
|
89
|
+
one HTTP/WebSocket port.
|
|
90
|
+
|
|
91
|
+
Memory limits compose instead of multiplying silently: HTTP owns a 128 MiB
|
|
92
|
+
aggregate host budget and at most 4,096 inbound requests; request bodies remain
|
|
93
|
+
at or below 16 MiB. Request/application providers, routes, unfinished timed-out
|
|
94
|
+
tasks, WebSocket connections, queued messages, pending sends, pending
|
|
95
|
+
connections, and their aggregate bytes all have hard ceilings. Request caches,
|
|
96
|
+
upload views, application provider caches, connection queues, and development
|
|
97
|
+
build sandboxes are released at their explicit lifecycle boundary.
|
|
98
|
+
|
|
99
|
+
Shutdown is drain-first and idempotent: concurrent `stop`/`close` calls join
|
|
100
|
+
one completion, new work is refused once draining starts, admitted requests
|
|
101
|
+
receive cooperative cancellation, and application providers are released only
|
|
102
|
+
after request and timed-out continuation ownership really finishes. Lifecycle
|
|
103
|
+
pairs unwind only for successful startups and in reverse order. These
|
|
104
|
+
guarantees protect framework-owned state; cross-request business invariants
|
|
105
|
+
still belong in transactions or another explicitly atomic capability.
|
|
106
|
+
|
|
22
107
|
Started processes expose pull-based, enum-tagged stdout/stderr chunks through
|
|
23
108
|
the ordinary VelarScript `async for` protocol. Each channel is decoded as one
|
|
24
109
|
incremental UTF-8 stream; only one pull may be active, output is consumed before
|
|
@@ -51,10 +136,11 @@ static-file reads, response writes, and backpressure. It imports only
|
|
|
51
136
|
compiler-owned source and static Node built-ins; npm dependencies and
|
|
52
137
|
VelarScript application code never execute in that Realm.
|
|
53
138
|
|
|
54
|
-
The shared proxy eagerly completes one readiness handshake
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
139
|
+
The shared proxy eagerly completes one readiness handshake and separates a
|
|
140
|
+
4,096-operation data lane from a 4,608-operation server lane, leaving control
|
|
141
|
+
capacity available while inbound requests are saturated. It is unreferenced
|
|
142
|
+
while idle. A pending filesystem, server, or HTTP operation and every active
|
|
143
|
+
server or unread HTTP response retain the process. Server and request
|
|
58
144
|
handles are bounded, wrap without colliding with live identities, and cap live
|
|
59
145
|
servers at 128, inbound requests at 4,096, and outbound HTTP requests at 1,024.
|
|
60
146
|
Every message is revalidated on both sides. In addition to each public request/file/stream limit, the Worker owns one
|
|
@@ -100,20 +186,22 @@ Binary filesystem and HTTP operations use the target-neutral `Bytes` contract:
|
|
|
100
186
|
`.bytes()`. Node `Buffer` is confined to the isolated implementation and never
|
|
101
187
|
becomes a VelarScript type or API.
|
|
102
188
|
|
|
103
|
-
|
|
104
|
-
`
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
on the
|
|
189
|
+
Database engines are not Node language capabilities. The independent
|
|
190
|
+
`@velarscript/database` source library defines portable model and execution
|
|
191
|
+
contracts; adapters such as `@velarscript/sqlite` own their concrete driver,
|
|
192
|
+
dialect, Worker isolation, queue and result budgets, streaming backpressure,
|
|
193
|
+
and raw escape hatches. The server framework may depend on the portable
|
|
194
|
+
contract, but must never acquire a concrete engine dependency.
|
|
108
195
|
|
|
109
196
|
`velar/worker` resolves only entries declared in `velar.json`, validates each
|
|
110
197
|
request and response, snapshots caller-owned transferable data, and transfers
|
|
111
198
|
the snapshot's nested `Bytes`/fixed numeric buffers through a bounded cycle-safe
|
|
112
199
|
data-graph scan without detaching the caller's values. It provides single-worker
|
|
113
200
|
and bounded pool owners with per-call cancellation and timeout.
|
|
114
|
-
`velar/websocket` provides pull connections bounded by
|
|
115
|
-
and aggregate bytes, preserves queued messages through
|
|
116
|
-
them on receive failure, plus a Node server;
|
|
201
|
+
`velar/websocket` provides pull connections bounded by unread message count,
|
|
202
|
+
pending operations, and aggregate bytes, preserves queued messages through
|
|
203
|
+
normal EOF, and discards them on receive failure, plus a Node server;
|
|
204
|
+
`listen({http: app, ...})` accepts either a `ServeApp` or low-level handler and
|
|
117
205
|
serves the same typed HTTP contract as `velar/serve` on the upgrade port. Its
|
|
118
206
|
only external transport dependency is the pinned `ws` package; native socket
|
|
119
207
|
objects remain private.
|
package/dist/compiler.d.ts
CHANGED
|
@@ -9,4 +9,7 @@ export declare function isNodeModule(source: string): boolean;
|
|
|
9
9
|
export declare function isNodeOnlyModule(source: string): boolean;
|
|
10
10
|
export declare function nodeModuleDiagnostic(source: string): string;
|
|
11
11
|
export declare const velarNodeCompilerExtension: CompilerExtension;
|
|
12
|
+
/** Conventional package entry used by the project extension loader. */
|
|
13
|
+
export declare const velarCompilerExtension: CompilerExtension;
|
|
14
|
+
export { velarProjectExtension, type VelarNodeConfig } from "./project-config.ts";
|
|
12
15
|
//# sourceMappingURL=compiler.d.ts.map
|
package/dist/compiler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,iBAAiB,EAAiB,KAAK,eAAe,EAAkB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"compiler.d.ts","sourceRoot":"","sources":["../src/compiler.ts"],"names":[],"mappings":"AAAA,OAAO,EAA0C,KAAK,iBAAiB,EAAiB,KAAK,eAAe,EAAkB,MAAM,uBAAuB,CAAC;AAoC5J,OAAO,EAAE,0BAA0B,EAAE,MAAM,sBAAsB,CAAC;AAElE,eAAO,MAAM,sBAAsB,SAAS,CAAC;AAC7C,eAAO,MAAM,sBAAsB,uBAAuB,CAAC;AAmX3D,eAAO,MAAM,oBAAoB,EAAE,WAAW,CAAC,MAAM,EAAE,eAAe,CA8NpE,CAAC;AAEH,eAAO,MAAM,iBAAiB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAgiBxD,CAAC;AAEH,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,EAAE,SAAS,MAAM,EAAE,CAUxE,CAAC;AAKH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAEpD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAExD;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAG3D;AAED,eAAO,MAAM,0BAA0B,EAAE,iBAyDvC,CAAC;AAEH,uEAAuE;AACvE,eAAO,MAAM,sBAAsB,mBAA6B,CAAC;AAEjE,OAAO,EAAE,qBAAqB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC"}
|