toilscript 0.1.26 → 0.1.28

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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "imports": {
3
- "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.26/dist/toilscript.js",
4
- "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.26/dist/cli.js",
3
+ "toilscript": "https://cdn.jsdelivr.net/npm/toilscript@0.1.28/dist/toilscript.js",
4
+ "toilscript/cli": "https://cdn.jsdelivr.net/npm/toilscript@0.1.28/dist/cli.js",
5
5
  "binaryen": "https://cdn.jsdelivr.net/npm/binaryen@129.0.0-nightly.20260428/index.js",
6
6
  "long": "https://cdn.jsdelivr.net/npm/long@5.3.2/index.js"
7
7
  }
@@ -2982,6 +2982,21 @@ declare module "types:toilscript/src/parser" {
2982
2982
  getDependee(dependent: string): string | null;
2983
2983
  /** Finishes parsing. */
2984
2984
  finish(): void;
2985
+ private checkToilDbKinds;
2986
+ /** Map every `@database` class (incl. inside namespaces) to its
2987
+ * collection-name -> handle-family-name. */
2988
+ private collectDbCollections;
2989
+ /** Check every kind-decorated function (top-level, namespaced, or a method). */
2990
+ private checkDbFunctions;
2991
+ /** The ToilDB kind decorator on a function, or -1. */
2992
+ private dbFunctionKind;
2993
+ private walkDbStmt;
2994
+ private walkDbStmtList;
2995
+ private walkDbExpr;
2996
+ /** If `call` is a direct `Db.collection.method(...)`, verify the kind permits
2997
+ * it. The receiver must be exactly `Identifier.Identifier` naming a known
2998
+ * `@database` + collection (an aliased handle is left to the runtime). */
2999
+ private checkDbCall;
2985
3000
  /** Parses a type name. */
2986
3001
  parseTypeName(tn: Tokenizer): TypeName | null;
2987
3002
  /** Parses a type. */
@@ -3004,6 +3019,14 @@ declare module "types:toilscript/src/parser" {
3004
3019
  parseFunctionExpression(tn: Tokenizer): FunctionExpression | null;
3005
3020
  private parseFunctionExpressionCommon;
3006
3021
  parseClassOrInterface(tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, startPos: number): ClassDeclaration | null;
3022
+ /**
3023
+ * Synthesize the ToilDB `@database` binding: for each `@collection` field
3024
+ * (typed as a `Record<V,K>`/... handle), add a STATIC handle to the class
3025
+ * initialized once at module init via `__toildbResolve("<Db>/<collection>")`.
3026
+ * The class name is used as the value: `App.users.get(...)` reads the static
3027
+ * handle. The instance field stays as the type carrier (vestigial).
3028
+ */
3029
+ private injectDatabaseBinding;
3007
3030
  /** Synthesize and append the binary codec members to a `@data` class. */
3008
3031
  private injectDataCodec;
3009
3032
  /** Parse a synthesized member from source text and append it to the class. */
@@ -3584,7 +3607,13 @@ declare module "types:toilscript/src/program" {
3584
3607
  /** Is a `@rest` HTTP controller class. */
3585
3608
  Rest = 65536,
3586
3609
  /** Is a `@route`/`@get`/`@post`/... HTTP route method. */
3587
- Route = 131072
3610
+ Route = 131072,
3611
+ /** Is a `@database` logical-database class (ToilDB). */
3612
+ Database = 262144,
3613
+ /** Is a `@collection` field within a `@database` class. */
3614
+ Collection = 524288,
3615
+ /** Is a `@query`/`@action`/`@job`/`@derive`/`@admin` function (ToilDB kind). */
3616
+ DbFunction = 1048576
3588
3617
  }
3589
3618
  export namespace DecoratorFlags {
3590
3619
  /** Translates a decorator kind to the respective decorator flag. */
@@ -4237,6 +4266,14 @@ declare module "types:toilscript/src/program" {
4237
4266
  /** Gets the cached default parameter name for the specified index. */
4238
4267
  export function getDefaultParameterName(index: number): string;
4239
4268
  }
4269
+ declare module "types:toilscript/src/dbcatalog" {
4270
+ import { Program } from "types:toilscript/src/program";
4271
+ /**
4272
+ * Build the `toildb.catalog` section bytes, or `null` if the program declares
4273
+ * no `@database`.
4274
+ */
4275
+ export function buildToilDbCatalog(program: Program): Uint8Array | null;
4276
+ }
4240
4277
  declare module "types:toilscript/src/passes/pass" {
4241
4278
  /**
4242
4279
  * @fileoverview Infrastructure for custom Binaryen passes.
@@ -7817,7 +7854,14 @@ declare module "types:toilscript/src/ast" {
7817
7854
  Cache = 27,
7818
7855
  Auth = 28,
7819
7856
  User = 29,
7820
- Ratelimit = 30
7857
+ Ratelimit = 30,
7858
+ Database = 31,
7859
+ Collection = 32,
7860
+ Query = 33,
7861
+ Action = 34,
7862
+ Job = 35,
7863
+ Derive = 36,
7864
+ Admin = 37
7821
7865
  }
7822
7866
  export namespace DecoratorKind {
7823
7867
  /** Returns the kind of the specified decorator name node. Defaults to {@link DecoratorKind.CUSTOM}. */