toilscript 0.1.38 → 0.1.41
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/dist/cli.generated.d.ts +233 -3
- package/dist/cli.js +15 -11
- package/dist/cli.js.map +3 -3
- package/dist/importmap.json +2 -2
- package/dist/toilscript.generated.d.ts +233 -3
- package/dist/toilscript.js +205 -194
- package/dist/toilscript.js.map +3 -3
- package/dist/web.js +3 -3
- package/package.json +5 -2
- package/std/assembly/bindings/toildb.ts +6 -4
- package/std/assembly/toildb.ts +4 -2
- package/std/assembly/toilscript.d.ts +108 -0
package/dist/web.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var ASSEMBLYSCRIPT_VERSION = "0.1.
|
|
1
|
+
var ASSEMBLYSCRIPT_VERSION = "0.1.41";
|
|
2
2
|
var ASSEMBLYSCRIPT_IMPORTMAP = {
|
|
3
3
|
"imports": {
|
|
4
|
-
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
5
|
-
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.
|
|
4
|
+
"toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.41/dist/toilscript.js",
|
|
5
|
+
"toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.41/dist/cli.js",
|
|
6
6
|
"binaryen": "https://cdn.jsdelivr.net/npm/binaryen@130.0.0-nightly.20260609/index.js",
|
|
7
7
|
"long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
|
|
8
8
|
}
|
package/package.json
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"toilscript",
|
|
9
9
|
"wasm"
|
|
10
10
|
],
|
|
11
|
-
"version": "0.1.
|
|
11
|
+
"version": "0.1.41",
|
|
12
12
|
"author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>",
|
|
13
13
|
"license": "Apache-2.0",
|
|
14
14
|
"homepage": "https://github.com/dacely-cloud/toilscript",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"prepublishOnly": "node scripts/build",
|
|
81
81
|
"watch": "node scripts/build --watch",
|
|
82
82
|
"coverage": "npx c8 -- npm test",
|
|
83
|
-
"test": "npm run test:parser && npm run test:compiler -- --parallel && npm run test:browser && npm run test:toilconfig && npm run test:transform && npm run test:cli && npm run test:json && npm run test:data && npm run test:dbstatic",
|
|
83
|
+
"test": "npm run test:parser && npm run test:compiler -- --parallel && npm run test:browser && npm run test:toilconfig && npm run test:transform && npm run test:cli && npm run test:json && npm run test:data && npm run test:dbresolve && npm run test:dbstatic && npm run test:routekinds && npm run test:streams",
|
|
84
84
|
"test:parser": "node --enable-source-maps tests/parser",
|
|
85
85
|
"test:compiler": "node --enable-source-maps --no-warnings tests/compiler",
|
|
86
86
|
"test:browser": "node --enable-source-maps tests/browser",
|
|
@@ -91,7 +91,10 @@
|
|
|
91
91
|
"test:cli": "node tests/cli/options.js",
|
|
92
92
|
"test:json": "node tests/json/run.mjs",
|
|
93
93
|
"test:data": "node tests/data/run.mjs",
|
|
94
|
+
"test:dbresolve": "node tests/dbresolve/run.mjs",
|
|
94
95
|
"test:dbstatic": "node tests/dbstatic/run.mjs",
|
|
96
|
+
"test:routekinds": "node tests/routekinds/run.mjs",
|
|
97
|
+
"test:streams": "node tests/streams/run.mjs && node tests/streams/catalog.mjs && node tests/streams/codegen.mjs",
|
|
95
98
|
"asbuild": "npm run asbuild:debug && npm run asbuild:release",
|
|
96
99
|
"asbuild:debug": "node bin/toilscript --config src/toilconfig.json --target debug",
|
|
97
100
|
"asbuild:release": "node bin/toilscript --config src/toilconfig.json --target release",
|
|
@@ -35,8 +35,9 @@ export namespace toildbHost {
|
|
|
35
35
|
export declare function get(handle: u32, keyPtr: usize, keyLen: i32): i32;
|
|
36
36
|
|
|
37
37
|
// record bounded multi-get. Input at keysPtr: u32 count + per key (u32 len +
|
|
38
|
-
// bytes). Result (stashed): u32 count + per item u8 present
|
|
39
|
-
//
|
|
38
|
+
// bytes). Result (stashed): u32 count + per item u8 present, and when present
|
|
39
|
+
// `u32 schema_version + u32 len + bytes`, in request order. Returns the
|
|
40
|
+
// stashed length | negative error.
|
|
40
41
|
// @ts-ignore: decorator
|
|
41
42
|
@external("env", "data.get_many")
|
|
42
43
|
export declare function getMany(handle: u32, keysPtr: usize, keysLen: i32): i32;
|
|
@@ -148,7 +149,7 @@ export namespace toildbHost {
|
|
|
148
149
|
): i32;
|
|
149
150
|
|
|
150
151
|
// membership.list(limit) -> framed-list length (stashed) | negative error.
|
|
151
|
-
// The blob is `u32 count` then per member `u32 len + bytes`.
|
|
152
|
+
// The blob is `u32 count` then per member `u32 schema_version + u32 len + bytes`.
|
|
152
153
|
// @ts-ignore: decorator
|
|
153
154
|
@external("env", "data.membership_list")
|
|
154
155
|
export declare function membershipList(handle: u32, setPtr: usize, setLen: i32, limit: i32): i32;
|
|
@@ -216,7 +217,8 @@ export namespace toildbHost {
|
|
|
216
217
|
): i32;
|
|
217
218
|
|
|
218
219
|
// events.latest(limit) -> framed-list length (stashed) | negative error.
|
|
219
|
-
// The blob is `u32 count` then per event `u32 len + bytes`,
|
|
220
|
+
// The blob is `u32 count` then per event `u32 schema_version + u32 len + bytes`,
|
|
221
|
+
// newest first.
|
|
220
222
|
// @ts-ignore: decorator
|
|
221
223
|
@external("env", "data.latest")
|
|
222
224
|
export declare function latest(handle: u32, keyPtr: usize, keyLen: i32, limit: i32): i32;
|
package/std/assembly/toildb.ts
CHANGED
|
@@ -21,7 +21,8 @@ import { DataWriter } from "data";
|
|
|
21
21
|
export function __toildbResolve(name: string): u32 {
|
|
22
22
|
const nb = Uint8Array.wrap(String.UTF8.encode(name));
|
|
23
23
|
const out = new Uint8Array(4);
|
|
24
|
-
toildbHost.resolveCollection(nb.dataStart, nb.byteLength, out.dataStart);
|
|
24
|
+
const status = toildbHost.resolveCollection(nb.dataStart, nb.byteLength, out.dataStart);
|
|
25
|
+
if (status < 0) abort("ToilDB collection resolve failed", "toildb", 0, 0);
|
|
25
26
|
return load<u32>(out.dataStart);
|
|
26
27
|
}
|
|
27
28
|
|
|
@@ -470,7 +471,8 @@ export class Events<K, V> {
|
|
|
470
471
|
}
|
|
471
472
|
|
|
472
473
|
/// The newest `limit` events, newest first. Decodes each framed event into a
|
|
473
|
-
/// `V`. The host frames them as `u32 count` then per event
|
|
474
|
+
/// `V`. The host frames them as `u32 count` then per event
|
|
475
|
+
/// `u32 schema_version + u32 len + bytes`.
|
|
474
476
|
latest(key: K, limit: i32): V[] {
|
|
475
477
|
const kb = key.encode();
|
|
476
478
|
const status = toildbHost.latest(this.__handle, kb.dataStart, kb.byteLength, limit);
|
|
@@ -85,6 +85,106 @@ declare function auth(target: Object, propertyKey: string | symbol, descriptor:
|
|
|
85
85
|
/** Declare the authenticated-user type (`@user class User { ... }`); enables `AuthService.getUser()`. */
|
|
86
86
|
declare function user(target: Function): void;
|
|
87
87
|
|
|
88
|
+
// --- L4 daemon (@daemon / @scheduled) + streams (@stream + lifecycle hooks),
|
|
89
|
+
// handled natively by the compiler; typed here so editors accept the bare forms ---
|
|
90
|
+
|
|
91
|
+
/** Marks the single L4 daemon class: instantiated once on the global cold box,
|
|
92
|
+
* its instance fields preserved for the box lifetime. At most one `@daemon` per
|
|
93
|
+
* project. May declare a zero-arg `onStart(): void`, run once at boot. Cold
|
|
94
|
+
* artifact only (a `@daemon` is a compile error in the hot/request build). */
|
|
95
|
+
declare function daemon(target: Function): void;
|
|
96
|
+
|
|
97
|
+
/** Declares a `@daemon` method as a scheduled task fired on each due tick. `spec`
|
|
98
|
+
* is an interval (`"30s"` / `"5m"` / `"1h"` / `"1d"`) or a 5-field cron string
|
|
99
|
+
* (e.g. `"15 9 * * 1-5"`, weekdays 9:15). The handler must be `(): void` (no parameters, no return). */
|
|
100
|
+
declare function scheduled(spec: string): (target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>) => void;
|
|
101
|
+
|
|
102
|
+
/** Stream placement scope for `@stream({ scope })`: `Regional` (0, L2) or
|
|
103
|
+
* `Continental` (1, L3). Values match the runtime stream codec. */
|
|
104
|
+
declare enum StreamScope { Regional, Continental }
|
|
105
|
+
|
|
106
|
+
/** Optional `@stream` config object. Set `message` to a `@data` class to receive
|
|
107
|
+
* decoded packets; omit it for the raw-bytes default (`StreamPacket`). */
|
|
108
|
+
interface StreamOptions {
|
|
109
|
+
scope?: StreamScope;
|
|
110
|
+
message?: Function;
|
|
111
|
+
maxFrameBytes?: i32;
|
|
112
|
+
ingressRingBytes?: i32;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Marks a class as a stream protocol handler (runs on L2/L3 nodes). Its
|
|
116
|
+
* `@connect`/`@message`/`@close`/`@disconnect`/`@channel` methods are the
|
|
117
|
+
* lifecycle hooks. A project that uses `@stream` may NOT declare any `@service`
|
|
118
|
+
* or `@remote` anywhere (compiler-enforced). Hot/stream artifact only.
|
|
119
|
+
*
|
|
120
|
+
* Three forms (mirroring `@rest`): bare `@stream` (the routing name is the class
|
|
121
|
+
* name), `@stream("name")` (an explicit mount name / routing key, e.g. `/name`),
|
|
122
|
+
* or `@stream({ scope, message, ... })` for the full config object. */
|
|
123
|
+
declare function stream(target: Function): void;
|
|
124
|
+
declare function stream(name?: string): (target: Function) => void;
|
|
125
|
+
declare function stream(options: StreamOptions): (target: Function) => void;
|
|
126
|
+
|
|
127
|
+
/** Stream lifecycle-hook method decorators on a `@stream` class. `@connect` runs
|
|
128
|
+
* on open (returns `StreamOutbound`); `@message` handles an inbound packet;
|
|
129
|
+
* `@close` is a graceful close; `@disconnect` is an abrupt transport loss;
|
|
130
|
+
* `@channel` receives an opt-in fanned-out channel message. */
|
|
131
|
+
declare function connect(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): void;
|
|
132
|
+
declare function message(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): void;
|
|
133
|
+
declare function close(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): void;
|
|
134
|
+
declare function disconnect(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): void;
|
|
135
|
+
declare function channel(target: Object, propertyKey: string | symbol, descriptor: TypedPropertyDescriptor<any>): void;
|
|
136
|
+
|
|
137
|
+
// Stream handler argument/return types. Ambient (like the bignum natives below):
|
|
138
|
+
// the compiler/runtime provides the real classes; declared here so `@stream`
|
|
139
|
+
// handler signatures type-check in any editor.
|
|
140
|
+
|
|
141
|
+
/** The connection-open context passed to `@connect`. Read-only. */
|
|
142
|
+
declare class StreamInbound {
|
|
143
|
+
get connectionId(): u64;
|
|
144
|
+
get streamName(): string;
|
|
145
|
+
get remoteIp(): string;
|
|
146
|
+
get path(): string;
|
|
147
|
+
header(name: string): string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/** The accept/reject + optional first-frame decision returned by
|
|
151
|
+
* `@connect` / `@message`. */
|
|
152
|
+
declare class StreamOutbound {
|
|
153
|
+
static accept(): StreamOutbound;
|
|
154
|
+
static reply(body: Uint8Array): StreamOutbound;
|
|
155
|
+
static reject(reason: u16): StreamOutbound;
|
|
156
|
+
static empty(): StreamOutbound;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/** The close context passed to `@close` (a graceful or host-initiated close,
|
|
160
|
+
* distinct from `@disconnect`). */
|
|
161
|
+
declare class StreamConnectionEvent {
|
|
162
|
+
get connectionId(): u64;
|
|
163
|
+
get reason(): u16;
|
|
164
|
+
get durationMs(): u64;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** The default (raw-bytes) `@message` parameter: a thin view over the host
|
|
168
|
+
* ingress ring. The ring slot is reused after the hook returns, so copy via
|
|
169
|
+
* `bytes()` to retain. */
|
|
170
|
+
declare class StreamPacket {
|
|
171
|
+
get connectionId(): u64;
|
|
172
|
+
get length(): i32;
|
|
173
|
+
bytes(): Uint8Array;
|
|
174
|
+
at(i: i32): u8;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** The fanned-out channel message passed to `@channel`: the channel name plus
|
|
178
|
+
* the raw published bytes (no decode). */
|
|
179
|
+
declare class StreamChannelMessage {
|
|
180
|
+
get connectionId(): u64;
|
|
181
|
+
get channelHash(): u32;
|
|
182
|
+
get channelName(): string;
|
|
183
|
+
get length(): i32;
|
|
184
|
+
bytes(): Uint8Array;
|
|
185
|
+
at(i: i32): u8;
|
|
186
|
+
}
|
|
187
|
+
|
|
88
188
|
// --- ToilDB (@database / @collection + the @query/@action/... function kinds),
|
|
89
189
|
// handled natively by the compiler; typed here so editors accept the bare forms ---
|
|
90
190
|
|
|
@@ -92,6 +192,13 @@ declare function user(target: Function): void;
|
|
|
92
192
|
* lazily-resolved collection handle (`App.users.get(...)`). */
|
|
93
193
|
declare function database(target: Function): void;
|
|
94
194
|
|
|
195
|
+
declare interface CollectionOptions {
|
|
196
|
+
fillMaxWaitMs?: i32;
|
|
197
|
+
maxWaitMs?: i32;
|
|
198
|
+
fillStale?: string;
|
|
199
|
+
stale?: string;
|
|
200
|
+
}
|
|
201
|
+
|
|
95
202
|
/** Declares a `@database` field as a collection - a `Documents`/`View`/`Unique`/
|
|
96
203
|
* `Counter`/`Events`/`Membership`/`Capacity` handle. Prefer the `static` form,
|
|
97
204
|
* `@collection static users: Documents<UserId, User>` (no `!` - a definite
|
|
@@ -101,6 +208,7 @@ declare function database(target: Function): void;
|
|
|
101
208
|
* still works but needs the toilscript TS plugin to type the static `App.users`
|
|
102
209
|
* access. */
|
|
103
210
|
declare function collection(target: Object, propertyKey: string | symbol): void;
|
|
211
|
+
declare function collection(options: CollectionOptions): (target: Object, propertyKey: string | symbol) => void;
|
|
104
212
|
|
|
105
213
|
/** ToilDB function kinds (spec 6) - the data ops a function may issue. `@query`
|
|
106
214
|
* is read-only; `@action` adds bounded writes/claims; `@derive` publishes
|