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.
@@ -2922,6 +2922,21 @@ declare module "types:toilscript/src/parser" {
2922
2922
  getDependee(dependent: string): string | null;
2923
2923
  /** Finishes parsing. */
2924
2924
  finish(): void;
2925
+ private checkToilDbKinds;
2926
+ /** Map every `@database` class (incl. inside namespaces) to its
2927
+ * collection-name -> handle-family-name. */
2928
+ private collectDbCollections;
2929
+ /** Check every kind-decorated function (top-level, namespaced, or a method). */
2930
+ private checkDbFunctions;
2931
+ /** The ToilDB kind decorator on a function, or -1. */
2932
+ private dbFunctionKind;
2933
+ private walkDbStmt;
2934
+ private walkDbStmtList;
2935
+ private walkDbExpr;
2936
+ /** If `call` is a direct `Db.collection.method(...)`, verify the kind permits
2937
+ * it. The receiver must be exactly `Identifier.Identifier` naming a known
2938
+ * `@database` + collection (an aliased handle is left to the runtime). */
2939
+ private checkDbCall;
2925
2940
  /** Parses a type name. */
2926
2941
  parseTypeName(tn: Tokenizer): TypeName | null;
2927
2942
  /** Parses a type. */
@@ -2944,6 +2959,14 @@ declare module "types:toilscript/src/parser" {
2944
2959
  parseFunctionExpression(tn: Tokenizer): FunctionExpression | null;
2945
2960
  private parseFunctionExpressionCommon;
2946
2961
  parseClassOrInterface(tn: Tokenizer, flags: CommonFlags, decorators: DecoratorNode[] | null, startPos: number): ClassDeclaration | null;
2962
+ /**
2963
+ * Synthesize the ToilDB `@database` binding: for each `@collection` field
2964
+ * (typed as a `Record<V,K>`/... handle), add a STATIC handle to the class
2965
+ * initialized once at module init via `__toildbResolve("<Db>/<collection>")`.
2966
+ * The class name is used as the value: `App.users.get(...)` reads the static
2967
+ * handle. The instance field stays as the type carrier (vestigial).
2968
+ */
2969
+ private injectDatabaseBinding;
2947
2970
  /** Synthesize and append the binary codec members to a `@data` class. */
2948
2971
  private injectDataCodec;
2949
2972
  /** Parse a synthesized member from source text and append it to the class. */
@@ -3524,7 +3547,13 @@ declare module "types:toilscript/src/program" {
3524
3547
  /** Is a `@rest` HTTP controller class. */
3525
3548
  Rest = 65536,
3526
3549
  /** Is a `@route`/`@get`/`@post`/... HTTP route method. */
3527
- Route = 131072
3550
+ Route = 131072,
3551
+ /** Is a `@database` logical-database class (ToilDB). */
3552
+ Database = 262144,
3553
+ /** Is a `@collection` field within a `@database` class. */
3554
+ Collection = 524288,
3555
+ /** Is a `@query`/`@action`/`@job`/`@derive`/`@admin` function (ToilDB kind). */
3556
+ DbFunction = 1048576
3528
3557
  }
3529
3558
  export namespace DecoratorFlags {
3530
3559
  /** Translates a decorator kind to the respective decorator flag. */
@@ -6398,7 +6427,14 @@ declare module "types:toilscript/src/ast" {
6398
6427
  Cache = 27,
6399
6428
  Auth = 28,
6400
6429
  User = 29,
6401
- Ratelimit = 30
6430
+ Ratelimit = 30,
6431
+ Database = 31,
6432
+ Collection = 32,
6433
+ Query = 33,
6434
+ Action = 34,
6435
+ Job = 35,
6436
+ Derive = 36,
6437
+ Admin = 37
6402
6438
  }
6403
6439
  export namespace DecoratorKind {
6404
6440
  /** Returns the kind of the specified decorator name node. Defaults to {@link DecoratorKind.CUSTOM}. */
@@ -8546,6 +8582,14 @@ declare module "types:toilscript/src/builtins" {
8546
8582
  /** Compiles runtime type information for use by stdlib. */
8547
8583
  export function compileRTTI(compiler: Compiler): void;
8548
8584
  }
8585
+ declare module "types:toilscript/src/dbcatalog" {
8586
+ import { Program } from "types:toilscript/src/program";
8587
+ /**
8588
+ * Build the `toildb.catalog` section bytes, or `null` if the program declares
8589
+ * no `@database`.
8590
+ */
8591
+ export function buildToilDbCatalog(program: Program): Uint8Array | null;
8592
+ }
8549
8593
  declare module "types:toilscript/src/passes/pass" {
8550
8594
  /**
8551
8595
  * @fileoverview Infrastructure for custom Binaryen passes.