toilscript 0.1.30 → 0.1.31

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/web.js CHANGED
@@ -1,8 +1,8 @@
1
- var ASSEMBLYSCRIPT_VERSION = "0.1.30";
1
+ var ASSEMBLYSCRIPT_VERSION = "0.1.31";
2
2
  var ASSEMBLYSCRIPT_IMPORTMAP = {
3
3
  "imports": {
4
- "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.30/dist/toilscript.js",
5
- "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.30/dist/cli.js",
4
+ "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.31/dist/toilscript.js",
5
+ "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.31/dist/cli.js",
6
6
  "binaryen": "https://cdn.jsdelivr.net/npm/binaryen@129.0.0-nightly.20260428/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.30",
11
+ "version": "0.1.31",
12
12
  "author": "Daniel Wirtz <dcode+assemblyscript@dcode.io>",
13
13
  "license": "Apache-2.0",
14
14
  "homepage": "https://github.com/dacely-cloud/toilscript",
@@ -1,6 +1,6 @@
1
1
  // ToilDB: the developer-facing edge-database API.
2
2
  //
3
- // `@database class App { @collection(...) users!: Record<User, UserId>; ... }`
3
+ // `@database class App { @collection(...) users!: Documents<UserId, User>; ... }`
4
4
  // declares logical collections; the compiler (see parser `injectDatabaseBinding`)
5
5
  // synthesizes a `@global App` singleton whose fields are these typed handles,
6
6
  // resolved to numeric host handles once at module init.
@@ -49,7 +49,7 @@ function __toildbTakeGrow(): Uint8Array {
49
49
  /// A mutable keyed-entity collection (spec 7.1). `V` is the `@data` value type,
50
50
  /// `K` the `@data` key type.
51
51
  @global
52
- export class Record<V, K> {
52
+ export class Documents<K, V> {
53
53
  private __handle: u32;
54
54
 
55
55
  constructor(handle: u32) {
@@ -156,7 +156,7 @@ export class Record<V, K> {
156
156
  /// by a `@derive`/`@job` (the host kind gate enforces it). `V` is the `@data`
157
157
  /// value type, `K` the `@data` key type.
158
158
  @global
159
- export class View<V, K> {
159
+ export class View<K, V> {
160
160
  private __handle: u32;
161
161
 
162
162
  constructor(handle: u32) {
@@ -202,7 +202,7 @@ export class ClaimResult<V> {
202
202
  /// A globally-unique claim collection (spec 7.6): username, email, slug, ...
203
203
  /// `V` is the `@data` OWNER value type, `K` the `@data` claim-key type.
204
204
  @global
205
- export class Unique<V, K> {
205
+ export class Unique<K, V> {
206
206
  private __handle: u32;
207
207
 
208
208
  constructor(handle: u32) {
@@ -251,7 +251,7 @@ export class Unique<V, K> {
251
251
  /// An unordered set (spec 7.3): followers, tags, ACLs, room members. `M` is the
252
252
  /// `@data` member type, `K` the `@data` set-key type.
253
253
  @global
254
- export class Membership<M, K> {
254
+ export class Membership<K, M> {
255
255
  private __handle: u32;
256
256
 
257
257
  constructor(handle: u32) {
@@ -394,7 +394,7 @@ export class Counter<K> {
394
394
  /// fact stream a `@derive` consumes. `V` is the `@data` event type, `K` the
395
395
  /// `@data` stream-key type.
396
396
  @global
397
- export class Events<V, K> {
397
+ export class Events<K, V> {
398
398
  private __handle: u32;
399
399
 
400
400
  constructor(handle: u32) {
@@ -92,7 +92,7 @@ declare function user(target: Function): void;
92
92
  * lazily-resolved collection handle (`App.users.get(...)`). */
93
93
  declare function database(target: Function): void;
94
94
 
95
- /** Declares a `@database` field as a collection - a `Record`/`View`/`Unique`/
95
+ /** Declares a `@database` field as a collection - a `Documents`/`View`/`Unique`/
96
96
  * `Counter`/`Events`/`Membership`/`Capacity` handle. */
97
97
  declare function collection(target: Object, propertyKey: string | symbol): void;
98
98
 
@@ -107,13 +107,14 @@ declare function job(target: Function): void;
107
107
  declare function derive(target: Function): void;
108
108
  declare function admin(target: Function): void;
109
109
 
110
- // The ToilDB collection HANDLES are ambient globals (no import) - the compiler
111
- // provides them (`std/assembly/toildb`, `@global`); these typings let editors
112
- // recognize `@collection users!: Record<User, UserId>` and `App.users.get(...)`.
113
- // `K`/`V`/`M` are `@data` types (the binary codec the host marshals).
110
+ // The ToilDB collection HANDLES are ambient globals (NO import, like the bignum
111
+ // natives below) - the compiler provides them (`std/assembly/toildb`, `@global`);
112
+ // these typings let editors recognize `@collection users!: Documents<UserId,
113
+ // User>` and `App.users.get(...)`. Every handle is KEY-FIRST (`<K, V>`, matching
114
+ // `Map`/`Record`). `K`/`V`/`M` are `@data` types (the codec the host marshals).
114
115
 
115
116
  /** A mutable keyed-entity collection (spec 7.1): user profiles, items, sessions. */
116
- declare class Record<V, K> {
117
+ declare class Documents<K, V> {
117
118
  get(key: K): V | null;
118
119
  require(key: K): V;
119
120
  exists(key: K): bool;
@@ -125,7 +126,7 @@ declare class Record<V, K> {
125
126
  }
126
127
 
127
128
  /** A precomputed, read-optimized projection (spec 7.2): pages, leaderboards. */
128
- declare class View<V, K> {
129
+ declare class View<K, V> {
129
130
  get(key: K): V | null;
130
131
  require(key: K): V;
131
132
  publish(key: K, value: V): void;
@@ -139,14 +140,14 @@ declare class ClaimResult<V> {
139
140
  }
140
141
 
141
142
  /** A globally-unique claim collection (spec 7.6): usernames, emails, slugs. */
142
- declare class Unique<V, K> {
143
+ declare class Unique<K, V> {
143
144
  lookup(key: K): V | null;
144
145
  claim(key: K, value: V): ClaimResult<V>;
145
146
  release(key: K, value: V): void;
146
147
  }
147
148
 
148
149
  /** An unordered set (spec 7.3): followers, tags, ACLs, room members. */
149
- declare class Membership<M, K> {
150
+ declare class Membership<K, M> {
150
151
  contains(key: K, member: M): bool;
151
152
  add(key: K, member: M): void;
152
153
  remove(key: K, member: M): void;
@@ -169,18 +170,11 @@ declare class Counter<K> {
169
170
  }
170
171
 
171
172
  /** An append-only event log (spec 7.5): activity feeds, audit trails. */
172
- declare class Events<V, K> {
173
+ declare class Events<K, V> {
173
174
  append(key: K, event: V): void;
174
175
  latest(key: K, limit: i32): V[];
175
176
  }
176
177
 
177
- // The handles are ambient (no import needed), but `import { Counter } from
178
- // 'toildb'` is also accepted for editors that prefer explicit imports - it just
179
- // re-exports the same globals.
180
- declare module 'toildb' {
181
- export { Record, View, Unique, ClaimResult, Membership, Capacity, Counter, Events };
182
- }
183
-
184
178
  // Big integers, native globals implemented in std/assembly/bignum. The
185
179
  // arithmetic/bitwise/comparison operators
186
180
  // (+ - * / % & | ^ << >> == != < > <= >=) are operator overloads resolved by
package/std/ts-plugin.cjs CHANGED
@@ -212,7 +212,7 @@ function init(modules) {
212
212
  * instance type-carrier field, so stock TS reports `AuthDb.users` as
213
213
  * TS2339. Merge a `namespace` onto the class (the standard way to add typed
214
214
  * statics) with one `const` per collection, typed as the field's handle type
215
- * (`Record<User, UserId>`, `Capacity<DropId>`, ...). Returns "" when the file
215
+ * (`Documents<UserId, User>`, `Capacity<DropId>`, ...). Returns "" when the file
216
216
  * declares no `@database`.
217
217
  */
218
218
  function databaseAugmentation(text) {