@atscript/moost-db 0.1.116 → 0.1.118
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/db-space-registry-CKR6G-hi.d.mts +27 -0
- package/dist/db-space-registry-CWpYwZ4R.d.cts +27 -0
- package/dist/db-space-registry-C_wft7kl.mjs +48 -0
- package/dist/db-space-registry-DqKr5Zdk.cjs +65 -0
- package/dist/index.cjs +159 -22
- package/dist/index.d.cts +285 -187
- package/dist/index.d.mts +285 -187
- package/dist/index.mjs +150 -25
- package/dist/testing.cjs +21 -0
- package/dist/testing.d.cts +22 -0
- package/dist/testing.d.mts +22 -0
- package/dist/testing.mjs +19 -0
- package/package.json +16 -11
package/dist/index.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { i as resolveDbSpace, n as clearDbSpaces, r as provideDbSpace, t as DEFAULT_DB_SPACE } from "./db-space-registry-CWpYwZ4R.cjs";
|
|
1
2
|
import { TAtscriptAnnotatedType, TAtscriptDataType, TSerializeOptions, TSerializedAnnotatedType, Validator } from "@atscript/typescript/utils";
|
|
2
3
|
import { AtscriptDbReadable, AtscriptDbTable, FilterExpr, FlatOf, TCrudOp, TCrudPermissions, TCrudPermissions as TCrudPermissions$1, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionIntent as TDbActionIntent$1, TDbActionLevel, TDbActionLevel as TDbActionLevel$1, TDbActionProcessor, TDbFieldMeta, TIdentification, TMetaResponse, Uniquery, UniqueryControls } from "@atscript/db";
|
|
3
4
|
import { HttpError } from "@moostjs/event-http";
|
|
@@ -180,7 +181,7 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
180
181
|
private readonly _quantityRefByPath;
|
|
181
182
|
/** Paths the adapter vetoes for filtering (e.g. JSON storage on SQL). Symmetric with `/meta` `filterable: false`. */
|
|
182
183
|
private readonly _adapterNonFilterable;
|
|
183
|
-
constructor(readable: AtscriptDbReadable<T
|
|
184
|
+
constructor(readable: AtscriptDbReadable<T> | undefined, app: Moost);
|
|
184
185
|
private _collectAdapterNonFilterable;
|
|
185
186
|
private _collectQuantityRefs;
|
|
186
187
|
private _buildGates;
|
|
@@ -322,7 +323,7 @@ declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscrip
|
|
|
322
323
|
declare class AsDbController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsDbReadableController<T, DataType> {
|
|
323
324
|
/** Reference to the underlying table (typed for write access). */
|
|
324
325
|
protected get table(): AtscriptDbTable<T>;
|
|
325
|
-
constructor(table: AtscriptDbTable<T
|
|
326
|
+
constructor(table: AtscriptDbTable<T> | undefined, app: Moost);
|
|
326
327
|
protected buildCrud(): TCrudPermissions$1;
|
|
327
328
|
/**
|
|
328
329
|
* Intercepts write operations. Return `undefined` to abort.
|
|
@@ -536,68 +537,6 @@ declare class AsJsonValueHelpController<T extends TAtscriptAnnotatedType = TAtsc
|
|
|
536
537
|
private normalizeSelect;
|
|
537
538
|
}
|
|
538
539
|
//#endregion
|
|
539
|
-
//#region src/decorators.d.ts
|
|
540
|
-
/**
|
|
541
|
-
* DI token under which the {@link AtscriptDbReadable} instance
|
|
542
|
-
* is exposed to the readable controller's constructor via `@Inject`.
|
|
543
|
-
*/
|
|
544
|
-
declare const READABLE_DEF = "__atscript_db_readable_def";
|
|
545
|
-
/**
|
|
546
|
-
* DI token under which the {@link AtscriptDbTable} instance
|
|
547
|
-
* is exposed to the controller's constructor via `@Inject`.
|
|
548
|
-
* Points to the same token as READABLE_DEF for backward compatibility.
|
|
549
|
-
*/
|
|
550
|
-
declare const TABLE_DEF = "__atscript_db_readable_def";
|
|
551
|
-
/**
|
|
552
|
-
* Combines the boilerplate needed to turn an {@link AsDbController}
|
|
553
|
-
* subclass into a fully wired HTTP controller for a given `@db.table` model.
|
|
554
|
-
*
|
|
555
|
-
* Internally applies three decorators:
|
|
556
|
-
* 1. **Provide** — registers the table instance under {@link TABLE_DEF}.
|
|
557
|
-
* 2. **Controller** — registers the class as a Moost HTTP controller
|
|
558
|
-
* with an optional route prefix. Defaults to `table.tableName`.
|
|
559
|
-
* 3. **Inherit** — copies metadata (routes, guards, etc.) from the
|
|
560
|
-
* parent class so they stay active in the derived controller.
|
|
561
|
-
*
|
|
562
|
-
* @param table The {@link AtscriptDbTable} instance for this controller.
|
|
563
|
-
* @param prefix Optional route prefix. Defaults to `table.tableName`.
|
|
564
|
-
*
|
|
565
|
-
* @example
|
|
566
|
-
* ```ts
|
|
567
|
-
* @TableController(usersTable)
|
|
568
|
-
* export class UsersController extends AsDbController<typeof UserModel> {}
|
|
569
|
-
* ```
|
|
570
|
-
*/
|
|
571
|
-
declare const TableController: <Table extends AtscriptDbTable<any, any, any, any, any, any, any>>(table: Table, prefix?: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
572
|
-
/**
|
|
573
|
-
* Combines the boilerplate needed to turn an {@link AsDbReadableController}
|
|
574
|
-
* subclass into a fully wired HTTP controller for a given `@db.view` or `@db.table` model.
|
|
575
|
-
*
|
|
576
|
-
* @param readable The {@link AtscriptDbReadable} instance (table or view).
|
|
577
|
-
* @param prefix Optional route prefix. Defaults to `readable.tableName`.
|
|
578
|
-
*
|
|
579
|
-
* @example
|
|
580
|
-
* ```ts
|
|
581
|
-
* @ReadableController(activeTasksView)
|
|
582
|
-
* export class ActiveTasksController extends AsDbReadableController<typeof ActiveTasks> {}
|
|
583
|
-
* ```
|
|
584
|
-
*/
|
|
585
|
-
declare const ReadableController: <Readable extends AtscriptDbReadable<any, any, any, any, any, any, any>>(readable: Readable, prefix?: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
586
|
-
/**
|
|
587
|
-
* Alias for {@link ReadableController} — use with view-backed controllers.
|
|
588
|
-
*
|
|
589
|
-
* @example
|
|
590
|
-
* ```ts
|
|
591
|
-
* @ViewController(activeTasksView)
|
|
592
|
-
* export class ActiveTasksController extends AsDbReadableController<typeof ActiveTasks> {}
|
|
593
|
-
* ```
|
|
594
|
-
*/
|
|
595
|
-
declare const ViewController: <Readable extends AtscriptDbReadable<any, any, any, any, any, any, any>>(readable: Readable, prefix?: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
596
|
-
//#endregion
|
|
597
|
-
//#region src/validation-interceptor.d.ts
|
|
598
|
-
declare const validationErrorTransform: () => import("moost").TInterceptorDef;
|
|
599
|
-
declare const UseValidationErrorTransform: () => ClassDecorator & MethodDecorator;
|
|
600
|
-
//#endregion
|
|
601
540
|
//#region src/actions/types.d.ts
|
|
602
541
|
/** `'rows'`-level batch policy — controls whether failing rows reject or are filtered out. */
|
|
603
542
|
type TOnDisabledRows = "reject" | "skip";
|
|
@@ -719,6 +658,287 @@ type EntryRequiredFields<E, TRow> = E extends {
|
|
|
719
658
|
type ValidatedDict<TRow, D extends DbActionsDictBase> = { [K in keyof D]: TDbActionsEntry<TRow, EntryRequiredFields<D[K], TRow>> };
|
|
720
659
|
type ValidatedUnpinnedDict<TRow, D extends DbActionsDictBase> = { [K in keyof D]: TDbActionsEntryUnpinned<TRow, EntryRequiredFields<D[K], TRow>> };
|
|
721
660
|
//#endregion
|
|
661
|
+
//#region src/actions/keys.d.ts
|
|
662
|
+
type TDbActionRowMarker = true;
|
|
663
|
+
/** Stamped by `@InputForm(FormType)` — the compiled `.as` class + the wire name (`FormType.name`). */
|
|
664
|
+
interface TDbActionInputFormMeta {
|
|
665
|
+
type: TAtscriptAnnotatedType;
|
|
666
|
+
name: string;
|
|
667
|
+
}
|
|
668
|
+
/** Method-level action metadata written by `@DbAction(name, opts)`. */
|
|
669
|
+
interface TDbActionMeta {
|
|
670
|
+
name: string;
|
|
671
|
+
opts: DbActionOpts;
|
|
672
|
+
}
|
|
673
|
+
/** Class-level entry — a `TDbActionsEntry` plus its dictionary key. */
|
|
674
|
+
interface TDbClassActionMeta {
|
|
675
|
+
name: string;
|
|
676
|
+
entry: TDbActionsEntry;
|
|
677
|
+
}
|
|
678
|
+
/** Param marker kind — informs level inference and ID-resolution shape. */
|
|
679
|
+
type TDbActionParamKind = "id" | "ids";
|
|
680
|
+
declare module "moost" {
|
|
681
|
+
interface TMoostMetadata {
|
|
682
|
+
atscript_db_action?: TDbActionMeta;
|
|
683
|
+
atscript_db_actions?: TDbClassActionMeta[];
|
|
684
|
+
atscript_db_action_param?: TDbActionParamKind;
|
|
685
|
+
atscript_db_action_row?: TDbActionRowMarker;
|
|
686
|
+
atscript_db_action_rows?: TDbActionRowMarker;
|
|
687
|
+
}
|
|
688
|
+
interface TMoostParamsMetadata {
|
|
689
|
+
atscript_db_action_param?: TDbActionParamKind;
|
|
690
|
+
atscript_db_action_row?: TDbActionRowMarker;
|
|
691
|
+
atscript_db_action_rows?: TDbActionRowMarker;
|
|
692
|
+
atscript_db_action_input_form?: TDbActionInputFormMeta;
|
|
693
|
+
atscript_type?: TAtscriptAnnotatedType;
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
//#endregion
|
|
697
|
+
//#region src/mate.d.ts
|
|
698
|
+
/**
|
|
699
|
+
* Class-level readable-binding descriptor written by `@TableController` /
|
|
700
|
+
* `@ReadableController` / `@ViewController`. One uniform `resolve()` backs
|
|
701
|
+
* both the DI provide factory and the base controller's
|
|
702
|
+
* `super(undefined, app)` fallback; `model` additionally feeds
|
|
703
|
+
* `assertExposed()`.
|
|
704
|
+
*/
|
|
705
|
+
interface TReadableBindingMeta {
|
|
706
|
+
/**
|
|
707
|
+
* The bound model token. Present for the token form (the token itself) and
|
|
708
|
+
* the instance form (`readable.type`); unknown for lazy factories until
|
|
709
|
+
* resolved.
|
|
710
|
+
*/
|
|
711
|
+
model?: TAtscriptAnnotatedType;
|
|
712
|
+
/** Resolves the readable — lazily for token/factory, identity for instance. */
|
|
713
|
+
resolve: () => AtscriptDbReadable<any>;
|
|
714
|
+
}
|
|
715
|
+
/**
|
|
716
|
+
* Class- and method-level metadata written by `@atscript/moost-db`'s
|
|
717
|
+
* decorators (`@DbAction`, `@DbActionDefault`, `@DbActions`,
|
|
718
|
+
* `@DbTableActions`, `@DbRowActions`, `@DbRowsActions`).
|
|
719
|
+
*
|
|
720
|
+
* The keys are intentionally kept identical to the underlying
|
|
721
|
+
* mate-storage keys (`atscript_db_*`) so the same shape applies whether
|
|
722
|
+
* the consumer reads via {@link getAtscriptDbMate} or pokes the raw
|
|
723
|
+
* `getMoostMate()` instance directly. End-users never need to type the
|
|
724
|
+
* magic strings — `mate.read(...)?.atscript_db_action` is fully typed.
|
|
725
|
+
*/
|
|
726
|
+
interface AtscriptDbMeta {
|
|
727
|
+
/** Method-level — written by `@DbAction(name, opts)` / `@DbActionDefault()`. */
|
|
728
|
+
atscript_db_action?: TDbActionMeta;
|
|
729
|
+
/** Class-level — written by `@DbActions` and the level-pinned shortcuts. Decorators accumulate into the array. */
|
|
730
|
+
atscript_db_actions?: TDbClassActionMeta[];
|
|
731
|
+
/** Param-level marker — written by `@DbActionID()` / `@DbActionIDs()`. Drives action-level inference. */
|
|
732
|
+
atscript_db_action_param?: TDbActionParamKind;
|
|
733
|
+
/** Param-level marker — written by `@DbActionRow()`. */
|
|
734
|
+
atscript_db_action_row?: true;
|
|
735
|
+
/** Param-level marker — written by `@DbActionRows()`. */
|
|
736
|
+
atscript_db_action_rows?: true;
|
|
737
|
+
/** Class-level — written by `@TableController` / `@ReadableController` / `@ViewController`. */
|
|
738
|
+
atscript_db_readable_binding?: TReadableBindingMeta;
|
|
739
|
+
}
|
|
740
|
+
/**
|
|
741
|
+
* Param-level metadata written by `@atscript/moost-db`'s param
|
|
742
|
+
* decorators. A superset of {@link AtscriptDbMeta}'s param-level keys
|
|
743
|
+
* plus the `@InputForm()`-specific entries.
|
|
744
|
+
*/
|
|
745
|
+
interface AtscriptDbParamsMeta {
|
|
746
|
+
/** Param-level — written by `@DbActionID()` / `@DbActionIDs()`. */
|
|
747
|
+
atscript_db_action_param?: TDbActionParamKind;
|
|
748
|
+
/** Param-level marker — written by `@DbActionRow()`. */
|
|
749
|
+
atscript_db_action_row?: true;
|
|
750
|
+
/** Param-level marker — written by `@DbActionRows()`. */
|
|
751
|
+
atscript_db_action_rows?: true;
|
|
752
|
+
/**
|
|
753
|
+
* Param-level — written by `@InputForm(FormType)`. Carries the
|
|
754
|
+
* compiled `.as` class plus its `.name` so `discoverActions` can both
|
|
755
|
+
* emit `inputForm` on `/meta` and register the type in the controller's
|
|
756
|
+
* form registry for `GET /meta/form/:name`.
|
|
757
|
+
*/
|
|
758
|
+
atscript_db_action_input_form?: TDbActionInputFormMeta;
|
|
759
|
+
/**
|
|
760
|
+
* Param-level — written by `@InputForm(FormType)` alongside
|
|
761
|
+
* `atscript_db_action_input_form`. Holds just the type ref so a generic
|
|
762
|
+
* atscript-aware Moost pipe (installed globally via
|
|
763
|
+
* `app.applyGlobalPipes(...)` or scoped via `@Pipe(...)`) can validate
|
|
764
|
+
* the resolved value without knowing about the moost-db-specific key.
|
|
765
|
+
*/
|
|
766
|
+
atscript_type?: TAtscriptAnnotatedType;
|
|
767
|
+
}
|
|
768
|
+
/**
|
|
769
|
+
* The fully-typed {@link Mate} instance shared across the moost
|
|
770
|
+
* metadata workspace, narrowed to the keys that
|
|
771
|
+
* `@atscript/moost-db` writes.
|
|
772
|
+
*
|
|
773
|
+
* Class- and prop-meta storage mirror the same shape; param-meta
|
|
774
|
+
* storage uses {@link AtscriptDbParamsMeta}.
|
|
775
|
+
*/
|
|
776
|
+
type AtscriptDbMate = Mate<TMoostMetadata & AtscriptDbMeta & {
|
|
777
|
+
params: (TMateParamMeta & AtscriptDbParamsMeta)[];
|
|
778
|
+
}, TMoostMetadata & AtscriptDbMeta & {
|
|
779
|
+
params: (TMateParamMeta & AtscriptDbParamsMeta)[];
|
|
780
|
+
}>;
|
|
781
|
+
/**
|
|
782
|
+
* Returns the shared moost-mate instance, typed against every key that
|
|
783
|
+
* `@atscript/moost-db` writes (see {@link AtscriptDbMeta} +
|
|
784
|
+
* {@link AtscriptDbParamsMeta}).
|
|
785
|
+
*
|
|
786
|
+
* Prefer this over `getMoostMate()` from `moost` whenever you need to
|
|
787
|
+
* read moost-db metadata — callers no longer have to retype the
|
|
788
|
+
* `atscript_db_*` magic strings or hand-cast the result.
|
|
789
|
+
*
|
|
790
|
+
* @example
|
|
791
|
+
* ```ts
|
|
792
|
+
* import { getAtscriptDbMate } from "@atscript/moost-db";
|
|
793
|
+
*
|
|
794
|
+
* const mate = getAtscriptDbMate();
|
|
795
|
+
* const meta = mate.read(controllerCtor.prototype, methodName);
|
|
796
|
+
* const dbAction = meta?.atscript_db_action; // TDbActionMeta | undefined
|
|
797
|
+
* const inputForm = meta?.params?.[0]?.atscript_db_action_input_form;
|
|
798
|
+
* ```
|
|
799
|
+
*/
|
|
800
|
+
declare function getAtscriptDbMate(): AtscriptDbMate;
|
|
801
|
+
//#endregion
|
|
802
|
+
//#region src/decorators.d.ts
|
|
803
|
+
/**
|
|
804
|
+
* DI token under which the {@link AtscriptDbReadable} instance
|
|
805
|
+
* is exposed to the readable controller's constructor via `@Inject`.
|
|
806
|
+
*/
|
|
807
|
+
declare const READABLE_DEF = "__atscript_db_readable_def";
|
|
808
|
+
/**
|
|
809
|
+
* DI token under which the {@link AtscriptDbTable} instance
|
|
810
|
+
* is exposed to the controller's constructor via `@Inject`.
|
|
811
|
+
* Points to the same token as READABLE_DEF for backward compatibility.
|
|
812
|
+
*/
|
|
813
|
+
declare const TABLE_DEF = "__atscript_db_readable_def";
|
|
814
|
+
/**
|
|
815
|
+
* Accepted binding forms for the controller decorators:
|
|
816
|
+
* - a readable **instance** (`db.getTable(Model)`) — resolved eagerly, legacy form;
|
|
817
|
+
* - a **lazy factory** (`() => db.getTable(Model)`) — resolved at first
|
|
818
|
+
* controller instantiation (during `app.init()`), so the space may be
|
|
819
|
+
* created after the controller module is imported;
|
|
820
|
+
* - a **model token** (the compiled `.as` class) — resolved at instantiation
|
|
821
|
+
* against the ambient space registry (see `provideDbSpace`), honoring the
|
|
822
|
+
* model's `@db.space` annotation unless overridden via `options.space`.
|
|
823
|
+
*/
|
|
824
|
+
type TReadableBinding<Readable> = Readable | (() => Readable) | TAtscriptAnnotatedType;
|
|
825
|
+
/** Options bag accepted as the decorators' second argument (or a plain prefix string). */
|
|
826
|
+
interface TControllerBindingOptions {
|
|
827
|
+
/** Route prefix override. Same meaning as the legacy string second argument. */
|
|
828
|
+
prefix?: string;
|
|
829
|
+
/**
|
|
830
|
+
* Space name for the model-token form — overrides the model's `@db.space`
|
|
831
|
+
* annotation. Ignored for instance/factory bindings.
|
|
832
|
+
*/
|
|
833
|
+
space?: string;
|
|
834
|
+
}
|
|
835
|
+
/**
|
|
836
|
+
* Combines the boilerplate needed to turn an {@link AsDbController}
|
|
837
|
+
* subclass into a fully wired HTTP controller for a given `@db.table` model.
|
|
838
|
+
*
|
|
839
|
+
* Internally applies three decorators:
|
|
840
|
+
* 1. **Provide** — registers the readable resolver under {@link TABLE_DEF}.
|
|
841
|
+
* 2. **Controller** — registers the class as a Moost HTTP controller
|
|
842
|
+
* with an optional route prefix (defaults to `@db.http.path`, then the
|
|
843
|
+
* table name).
|
|
844
|
+
* 3. **Inherit** — copies metadata (routes, guards, etc.) from the
|
|
845
|
+
* parent class so they stay active in the derived controller.
|
|
846
|
+
*
|
|
847
|
+
* All three binding forms are supported (see {@link TReadableBinding}):
|
|
848
|
+
*
|
|
849
|
+
* ```ts
|
|
850
|
+
* @TableController(User) // model token (preferred)
|
|
851
|
+
* @TableController(User, { space: "analytics" })
|
|
852
|
+
* @TableController(() => db.getTable(User), "users") // lazy factory
|
|
853
|
+
* @TableController(usersTable) // instance (legacy)
|
|
854
|
+
* export class UsersController extends AsDbController<typeof User> {}
|
|
855
|
+
* ```
|
|
856
|
+
*
|
|
857
|
+
* Token and factory forms resolve lazily at first controller instantiation
|
|
858
|
+
* (during `app.init()`), so the `DbSpace` does not have to exist when the
|
|
859
|
+
* controller module is imported. For the token form, register the space with
|
|
860
|
+
* `provideDbSpace(db)` before `app.init()`.
|
|
861
|
+
*
|
|
862
|
+
* @param binding Model token, lazy factory, or {@link AtscriptDbTable} instance.
|
|
863
|
+
* @param prefixOrOptions Route prefix string, or {@link TControllerBindingOptions}.
|
|
864
|
+
*/
|
|
865
|
+
declare const TableController: <Table extends AtscriptDbTable<any, any, any, any, any, any, any>>(binding: TReadableBinding<Table>, prefixOrOptions?: string | TControllerBindingOptions) => ClassDecorator;
|
|
866
|
+
/**
|
|
867
|
+
* Combines the boilerplate needed to turn an {@link AsDbReadableController}
|
|
868
|
+
* subclass into a fully wired HTTP controller for a given `@db.view` or `@db.table` model.
|
|
869
|
+
*
|
|
870
|
+
* Accepts the same three binding forms as {@link TableController}.
|
|
871
|
+
*
|
|
872
|
+
* @param binding Model token, lazy factory, or {@link AtscriptDbReadable} instance.
|
|
873
|
+
* @param prefixOrOptions Route prefix string, or {@link TControllerBindingOptions}.
|
|
874
|
+
*
|
|
875
|
+
* @example
|
|
876
|
+
* ```ts
|
|
877
|
+
* @ReadableController(ActiveTasks)
|
|
878
|
+
* export class ActiveTasksController extends AsDbReadableController<typeof ActiveTasks> {}
|
|
879
|
+
* ```
|
|
880
|
+
*/
|
|
881
|
+
declare const ReadableController: <Readable extends AtscriptDbReadable<any, any, any, any, any, any, any>>(binding: TReadableBinding<Readable>, prefixOrOptions?: string | TControllerBindingOptions) => ClassDecorator;
|
|
882
|
+
/**
|
|
883
|
+
* Alias for {@link ReadableController} — use with view-backed controllers.
|
|
884
|
+
*
|
|
885
|
+
* @example
|
|
886
|
+
* ```ts
|
|
887
|
+
* @ViewController(ActiveTasks)
|
|
888
|
+
* export class ActiveTasksController extends AsDbReadableController<typeof ActiveTasks> {}
|
|
889
|
+
* ```
|
|
890
|
+
*/
|
|
891
|
+
declare const ViewController: <Readable extends AtscriptDbReadable<any, any, any, any, any, any, any>>(binding: TReadableBinding<Readable>, prefixOrOptions?: string | TControllerBindingOptions) => ClassDecorator;
|
|
892
|
+
/**
|
|
893
|
+
* Finds the readable binding written by `@TableController` /
|
|
894
|
+
* `@ReadableController` / `@ViewController` on a controller class, walking the
|
|
895
|
+
* prototype chain so intermediate undecorated classes don't hide the binding
|
|
896
|
+
* (nearest decorated ancestor wins).
|
|
897
|
+
*/
|
|
898
|
+
declare function findReadableBinding(ctor: Function | undefined): TReadableBindingMeta | undefined;
|
|
899
|
+
/**
|
|
900
|
+
* Resolves the readable bound to a controller class via
|
|
901
|
+
* {@link findReadableBinding}, throwing with wiring guidance when none is
|
|
902
|
+
* found.
|
|
903
|
+
*
|
|
904
|
+
* Used by {@link AsDbReadableController}'s constructor when `readable` is
|
|
905
|
+
* `undefined` — i.e. a subclass with its own constructor called
|
|
906
|
+
* `super(undefined, app)` instead of forwarding an injected instance.
|
|
907
|
+
*/
|
|
908
|
+
declare function resolveBoundReadable(ctor: Function | undefined): AtscriptDbReadable<any>;
|
|
909
|
+
//#endregion
|
|
910
|
+
//#region src/assert-exposed.d.ts
|
|
911
|
+
/** Minimal logger surface for {@link assertExposed}. */
|
|
912
|
+
interface TAssertExposedOptions {
|
|
913
|
+
logger?: {
|
|
914
|
+
warn: (...args: unknown[]) => void;
|
|
915
|
+
};
|
|
916
|
+
}
|
|
917
|
+
/**
|
|
918
|
+
* Dev-mode wiring assertion: warns for every model annotated with
|
|
919
|
+
* `@db.http.path` that has no registered db controller.
|
|
920
|
+
*
|
|
921
|
+
* Call AFTER `await app.init()` (controller bindings are collected during
|
|
922
|
+
* init). Detection reads the binding metadata written by `@TableController` /
|
|
923
|
+
* `@ReadableController` / `@ViewController`, so it covers the model-token and
|
|
924
|
+
* instance forms; lazy-factory bindings can't name their model until resolved
|
|
925
|
+
* and are ignored.
|
|
926
|
+
*
|
|
927
|
+
* Returns the list of unexposed models so callers can escalate (e.g. throw in
|
|
928
|
+
* CI):
|
|
929
|
+
*
|
|
930
|
+
* ```ts
|
|
931
|
+
* await app.init()
|
|
932
|
+
* const missing = assertExposed(app, atscriptModels)
|
|
933
|
+
* if (missing.length && process.env.CI) throw new Error("unexposed models")
|
|
934
|
+
* ```
|
|
935
|
+
*/
|
|
936
|
+
declare function assertExposed(app: Moost, models: readonly TAtscriptAnnotatedType[], options?: TAssertExposedOptions): TAtscriptAnnotatedType[];
|
|
937
|
+
//#endregion
|
|
938
|
+
//#region src/validation-interceptor.d.ts
|
|
939
|
+
declare const validationErrorTransform: () => import("moost").TInterceptorDef;
|
|
940
|
+
declare const UseValidationErrorTransform: () => ClassDecorator & MethodDecorator;
|
|
941
|
+
//#endregion
|
|
722
942
|
//#region src/actions/db-action.decorator.d.ts
|
|
723
943
|
/**
|
|
724
944
|
* Mark a controller method as a database action surfaced via `/meta`. Writes
|
|
@@ -931,42 +1151,6 @@ declare const useDbActionInput: import("@wooksjs/event-core").WookComposable<{
|
|
|
931
1151
|
load: () => Promise<unknown>;
|
|
932
1152
|
}>;
|
|
933
1153
|
//#endregion
|
|
934
|
-
//#region src/actions/keys.d.ts
|
|
935
|
-
type TDbActionRowMarker = true;
|
|
936
|
-
/** Stamped by `@InputForm(FormType)` — the compiled `.as` class + the wire name (`FormType.name`). */
|
|
937
|
-
interface TDbActionInputFormMeta {
|
|
938
|
-
type: TAtscriptAnnotatedType;
|
|
939
|
-
name: string;
|
|
940
|
-
}
|
|
941
|
-
/** Method-level action metadata written by `@DbAction(name, opts)`. */
|
|
942
|
-
interface TDbActionMeta {
|
|
943
|
-
name: string;
|
|
944
|
-
opts: DbActionOpts;
|
|
945
|
-
}
|
|
946
|
-
/** Class-level entry — a `TDbActionsEntry` plus its dictionary key. */
|
|
947
|
-
interface TDbClassActionMeta {
|
|
948
|
-
name: string;
|
|
949
|
-
entry: TDbActionsEntry;
|
|
950
|
-
}
|
|
951
|
-
/** Param marker kind — informs level inference and ID-resolution shape. */
|
|
952
|
-
type TDbActionParamKind = "id" | "ids";
|
|
953
|
-
declare module "moost" {
|
|
954
|
-
interface TMoostMetadata {
|
|
955
|
-
atscript_db_action?: TDbActionMeta;
|
|
956
|
-
atscript_db_actions?: TDbClassActionMeta[];
|
|
957
|
-
atscript_db_action_param?: TDbActionParamKind;
|
|
958
|
-
atscript_db_action_row?: TDbActionRowMarker;
|
|
959
|
-
atscript_db_action_rows?: TDbActionRowMarker;
|
|
960
|
-
}
|
|
961
|
-
interface TMoostParamsMetadata {
|
|
962
|
-
atscript_db_action_param?: TDbActionParamKind;
|
|
963
|
-
atscript_db_action_row?: TDbActionRowMarker;
|
|
964
|
-
atscript_db_action_rows?: TDbActionRowMarker;
|
|
965
|
-
atscript_db_action_input_form?: TDbActionInputFormMeta;
|
|
966
|
-
atscript_type?: TAtscriptAnnotatedType;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
//#endregion
|
|
970
1154
|
//#region src/actions/action-disabled-error.d.ts
|
|
971
1155
|
/**
|
|
972
1156
|
* Wire-body shape for server-side gate rejections. The `name` discriminator
|
|
@@ -1022,95 +1206,9 @@ declare class ActionDisabledError extends HttpError<ActionDisabledErrorBody> {
|
|
|
1022
1206
|
*/
|
|
1023
1207
|
declare const perRow: <TRow>(fn: (row: TRow) => boolean) => (rows: TRow[]) => boolean[];
|
|
1024
1208
|
//#endregion
|
|
1025
|
-
//#region src/mate.d.ts
|
|
1026
|
-
/**
|
|
1027
|
-
* Class- and method-level metadata written by `@atscript/moost-db`'s
|
|
1028
|
-
* decorators (`@DbAction`, `@DbActionDefault`, `@DbActions`,
|
|
1029
|
-
* `@DbTableActions`, `@DbRowActions`, `@DbRowsActions`).
|
|
1030
|
-
*
|
|
1031
|
-
* The keys are intentionally kept identical to the underlying
|
|
1032
|
-
* mate-storage keys (`atscript_db_*`) so the same shape applies whether
|
|
1033
|
-
* the consumer reads via {@link getAtscriptDbMate} or pokes the raw
|
|
1034
|
-
* `getMoostMate()` instance directly. End-users never need to type the
|
|
1035
|
-
* magic strings — `mate.read(...)?.atscript_db_action` is fully typed.
|
|
1036
|
-
*/
|
|
1037
|
-
interface AtscriptDbMeta {
|
|
1038
|
-
/** Method-level — written by `@DbAction(name, opts)` / `@DbActionDefault()`. */
|
|
1039
|
-
atscript_db_action?: TDbActionMeta;
|
|
1040
|
-
/** Class-level — written by `@DbActions` and the level-pinned shortcuts. Decorators accumulate into the array. */
|
|
1041
|
-
atscript_db_actions?: TDbClassActionMeta[];
|
|
1042
|
-
/** Param-level marker — written by `@DbActionID()` / `@DbActionIDs()`. Drives action-level inference. */
|
|
1043
|
-
atscript_db_action_param?: TDbActionParamKind;
|
|
1044
|
-
/** Param-level marker — written by `@DbActionRow()`. */
|
|
1045
|
-
atscript_db_action_row?: true;
|
|
1046
|
-
/** Param-level marker — written by `@DbActionRows()`. */
|
|
1047
|
-
atscript_db_action_rows?: true;
|
|
1048
|
-
}
|
|
1049
|
-
/**
|
|
1050
|
-
* Param-level metadata written by `@atscript/moost-db`'s param
|
|
1051
|
-
* decorators. A superset of {@link AtscriptDbMeta}'s param-level keys
|
|
1052
|
-
* plus the `@InputForm()`-specific entries.
|
|
1053
|
-
*/
|
|
1054
|
-
interface AtscriptDbParamsMeta {
|
|
1055
|
-
/** Param-level — written by `@DbActionID()` / `@DbActionIDs()`. */
|
|
1056
|
-
atscript_db_action_param?: TDbActionParamKind;
|
|
1057
|
-
/** Param-level marker — written by `@DbActionRow()`. */
|
|
1058
|
-
atscript_db_action_row?: true;
|
|
1059
|
-
/** Param-level marker — written by `@DbActionRows()`. */
|
|
1060
|
-
atscript_db_action_rows?: true;
|
|
1061
|
-
/**
|
|
1062
|
-
* Param-level — written by `@InputForm(FormType)`. Carries the
|
|
1063
|
-
* compiled `.as` class plus its `.name` so `discoverActions` can both
|
|
1064
|
-
* emit `inputForm` on `/meta` and register the type in the controller's
|
|
1065
|
-
* form registry for `GET /meta/form/:name`.
|
|
1066
|
-
*/
|
|
1067
|
-
atscript_db_action_input_form?: TDbActionInputFormMeta;
|
|
1068
|
-
/**
|
|
1069
|
-
* Param-level — written by `@InputForm(FormType)` alongside
|
|
1070
|
-
* `atscript_db_action_input_form`. Holds just the type ref so a generic
|
|
1071
|
-
* atscript-aware Moost pipe (installed globally via
|
|
1072
|
-
* `app.applyGlobalPipes(...)` or scoped via `@Pipe(...)`) can validate
|
|
1073
|
-
* the resolved value without knowing about the moost-db-specific key.
|
|
1074
|
-
*/
|
|
1075
|
-
atscript_type?: TAtscriptAnnotatedType;
|
|
1076
|
-
}
|
|
1077
|
-
/**
|
|
1078
|
-
* The fully-typed {@link Mate} instance shared across the moost
|
|
1079
|
-
* metadata workspace, narrowed to the keys that
|
|
1080
|
-
* `@atscript/moost-db` writes.
|
|
1081
|
-
*
|
|
1082
|
-
* Class- and prop-meta storage mirror the same shape; param-meta
|
|
1083
|
-
* storage uses {@link AtscriptDbParamsMeta}.
|
|
1084
|
-
*/
|
|
1085
|
-
type AtscriptDbMate = Mate<TMoostMetadata & AtscriptDbMeta & {
|
|
1086
|
-
params: (TMateParamMeta & AtscriptDbParamsMeta)[];
|
|
1087
|
-
}, TMoostMetadata & AtscriptDbMeta & {
|
|
1088
|
-
params: (TMateParamMeta & AtscriptDbParamsMeta)[];
|
|
1089
|
-
}>;
|
|
1090
|
-
/**
|
|
1091
|
-
* Returns the shared moost-mate instance, typed against every key that
|
|
1092
|
-
* `@atscript/moost-db` writes (see {@link AtscriptDbMeta} +
|
|
1093
|
-
* {@link AtscriptDbParamsMeta}).
|
|
1094
|
-
*
|
|
1095
|
-
* Prefer this over `getMoostMate()` from `moost` whenever you need to
|
|
1096
|
-
* read moost-db metadata — callers no longer have to retype the
|
|
1097
|
-
* `atscript_db_*` magic strings or hand-cast the result.
|
|
1098
|
-
*
|
|
1099
|
-
* @example
|
|
1100
|
-
* ```ts
|
|
1101
|
-
* import { getAtscriptDbMate } from "@atscript/moost-db";
|
|
1102
|
-
*
|
|
1103
|
-
* const mate = getAtscriptDbMate();
|
|
1104
|
-
* const meta = mate.read(controllerCtor.prototype, methodName);
|
|
1105
|
-
* const dbAction = meta?.atscript_db_action; // TDbActionMeta | undefined
|
|
1106
|
-
* const inputForm = meta?.params?.[0]?.atscript_db_action_input_form;
|
|
1107
|
-
* ```
|
|
1108
|
-
*/
|
|
1109
|
-
declare function getAtscriptDbMate(): AtscriptDbMate;
|
|
1110
|
-
//#endregion
|
|
1111
1209
|
//#region src/permissions/crud-controls.d.ts
|
|
1112
1210
|
declare const QUERY_CONTROLS: readonly string[];
|
|
1113
1211
|
declare const PAGES_CONTROLS: readonly string[];
|
|
1114
1212
|
declare const ONE_CONTROLS: readonly string[];
|
|
1115
1213
|
//#endregion
|
|
1116
|
-
export { ActionDisabledError, type ActionDisabledErrorBody, AsDbController, AsDbReadableController, AsJsonValueHelpController, AsReadableController, AsValueHelpController, type AtscriptDbMate, type AtscriptDbMeta, type AtscriptDbParamsMeta, DbAction, DbActionDefault, type DbActionEnvelope, DbActionID, DbActionIDs, type DbActionOpts, DbActionRow, DbActionRows, DbActions, DbRowActions, DbRowsActions, DbTableActions, type IdValidationSource, InputForm, ONE_CONTROLS, PAGES_CONTROLS, QUERY_CONTROLS, READABLE_DEF, ReadableController, ReadableGates, TABLE_DEF, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionInputFormMeta, type TDbActionIntent, type TDbActionLevel, type TDbActionMeta, type TDbActionParamKind, type TDbActionProcessor, type TDbActionsEntry, type TDbActionsEntryUnpinned, type TDbClassActionMeta, TableController, UseValidationErrorTransform, ValueHelpQuery, ViewController, dbActionBodySlot, dbActionInputSlot, discoverActions, getAtscriptDbMate, getControllerFormType, perRow, useDbActionId, useDbActionIds, useDbActionInput, useDbActionRow, useDbActionRows, validationErrorTransform };
|
|
1214
|
+
export { ActionDisabledError, type ActionDisabledErrorBody, AsDbController, AsDbReadableController, AsJsonValueHelpController, AsReadableController, AsValueHelpController, type AtscriptDbMate, type AtscriptDbMeta, type AtscriptDbParamsMeta, DEFAULT_DB_SPACE, DbAction, DbActionDefault, type DbActionEnvelope, DbActionID, DbActionIDs, type DbActionOpts, DbActionRow, DbActionRows, DbActions, DbRowActions, DbRowsActions, DbTableActions, type IdValidationSource, InputForm, ONE_CONTROLS, PAGES_CONTROLS, QUERY_CONTROLS, READABLE_DEF, ReadableController, ReadableGates, TABLE_DEF, TAssertExposedOptions, TControllerBindingOptions, type TCrudOp, type TCrudPermissions, type TDbActionInfo, type TDbActionInputFormMeta, type TDbActionIntent, type TDbActionLevel, type TDbActionMeta, type TDbActionParamKind, type TDbActionProcessor, type TDbActionsEntry, type TDbActionsEntryUnpinned, type TDbClassActionMeta, TReadableBinding, type TReadableBindingMeta, TableController, UseValidationErrorTransform, ValueHelpQuery, ViewController, assertExposed, clearDbSpaces, dbActionBodySlot, dbActionInputSlot, discoverActions, findReadableBinding, getAtscriptDbMate, getControllerFormType, perRow, provideDbSpace, resolveBoundReadable, resolveDbSpace, useDbActionId, useDbActionIds, useDbActionInput, useDbActionRow, useDbActionRows, validationErrorTransform };
|