@atscript/moost-db 0.1.55 → 0.1.56
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/README.md +3 -1
- package/dist/index.cjs +467 -3
- package/dist/index.d.cts +165 -2
- package/dist/index.d.mts +165 -2
- package/dist/index.mjs +460 -5
- package/package.json +4 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as _atscript_typescript_utils0 from "@atscript/typescript/utils";
|
|
2
2
|
import { TAtscriptAnnotatedType, TAtscriptDataType, TSerializeOptions, Validator } from "@atscript/typescript/utils";
|
|
3
3
|
import * as _uniqu_url0 from "@uniqu/url";
|
|
4
|
-
import { AtscriptDbReadable, AtscriptDbTable, FilterExpr, TMetaResponse, Uniquery, UniqueryControls } from "@atscript/db";
|
|
4
|
+
import { AtscriptDbReadable, AtscriptDbTable, FilterExpr, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionIntent as TDbActionIntent$1, TDbActionLevel, TDbActionLevel as TDbActionLevel$1, TDbActionProcessor, TDbFieldMeta, TMetaResponse, Uniquery, UniqueryControls } from "@atscript/db";
|
|
5
5
|
import { HttpError } from "@moostjs/event-http";
|
|
6
6
|
import * as moost from "moost";
|
|
7
7
|
import { Moost, TConsoleBase } from "moost";
|
|
@@ -123,8 +123,16 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
|
|
|
123
123
|
* Builds the `/meta` payload. Override in subclasses to populate source-specific
|
|
124
124
|
* fields. Defaults return a minimal envelope with the serialized type and the
|
|
125
125
|
* read-only flag; value-help dicts populate their capability hints here.
|
|
126
|
+
* Subclasses that fully replace the envelope must call {@link buildActions}
|
|
127
|
+
* directly so `@DbAction*` decorators still surface.
|
|
126
128
|
*/
|
|
127
129
|
protected buildMetaResponse(): Promise<TMetaResponse>;
|
|
130
|
+
/**
|
|
131
|
+
* Discovers `@DbAction*` and `@DbActions`-style class metadata on this
|
|
132
|
+
* controller and produces the `actions` array. Returns `[]` for value-help
|
|
133
|
+
* controllers — see {@link AsValueHelpController#buildMetaResponse}.
|
|
134
|
+
*/
|
|
135
|
+
protected buildActions(): TDbActionInfo$1[];
|
|
128
136
|
}
|
|
129
137
|
//#endregion
|
|
130
138
|
//#region src/as-db-readable.controller.d.ts
|
|
@@ -280,6 +288,12 @@ interface ValueHelpQuery<T> {
|
|
|
280
288
|
* requests against them. Subclasses that need a backend gate should compose
|
|
281
289
|
* one of their own (see {@link AsDbReadableController} for the
|
|
282
290
|
* `@db.column.filterable` / `@db.column.sortable` pattern).
|
|
291
|
+
*
|
|
292
|
+
* **Actions are intentionally NOT supported on value-help controllers.** The
|
|
293
|
+
* `/meta` payload still includes `actions: []` for shape uniformity, and any
|
|
294
|
+
* `@DbAction*` / `@DbActions*` decorators applied here are silently ignored.
|
|
295
|
+
* Value-help is for FK pickers and dictionary surfaces — adding row/table
|
|
296
|
+
* actions there would muddy the contract.
|
|
283
297
|
*/
|
|
284
298
|
declare abstract class AsValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsReadableController<T, DataType> {
|
|
285
299
|
/** Per-prop metadata map of the bound interface; eagerly built once. */
|
|
@@ -331,6 +345,7 @@ declare abstract class AsValueHelpController<T extends TAtscriptAnnotatedType =
|
|
|
331
345
|
* these flags at request time.
|
|
332
346
|
*/
|
|
333
347
|
protected buildMetaResponse(): Promise<TMetaResponse>;
|
|
348
|
+
protected buildActions(): never[];
|
|
334
349
|
}
|
|
335
350
|
//#endregion
|
|
336
351
|
//#region src/as-json-value-help.controller.d.ts
|
|
@@ -436,4 +451,152 @@ declare const ViewController: (readable: AtscriptDbReadable, prefix?: string) =>
|
|
|
436
451
|
declare const validationErrorTransform: () => moost.TInterceptorDef;
|
|
437
452
|
declare const UseValidationErrorTransform: () => ClassDecorator & MethodDecorator;
|
|
438
453
|
//#endregion
|
|
439
|
-
|
|
454
|
+
//#region src/actions/types.d.ts
|
|
455
|
+
/**
|
|
456
|
+
* Options accepted by `@DbAction(name, opts?)`. Structurally derived from
|
|
457
|
+
* {@link TDbActionInfo} so every addition to the wire shape automatically
|
|
458
|
+
* propagates here. Fields owned by the framework (`name`, `level`, `processor`,
|
|
459
|
+
* `value`) are excluded — `name` comes from the decorator argument, `level` is
|
|
460
|
+
* inferred from `@DbActionPK*` usage, `processor` is fixed to `'backend'` for
|
|
461
|
+
* method-decorator actions, and `value` is filled from the `@Post` path.
|
|
462
|
+
*/
|
|
463
|
+
type DbActionOpts = Partial<Omit<TDbActionInfo$1, "name" | "level" | "processor" | "value">>;
|
|
464
|
+
interface DbActionsEntryCommon {
|
|
465
|
+
label: string;
|
|
466
|
+
level: TDbActionLevel$1;
|
|
467
|
+
icon?: string;
|
|
468
|
+
intent?: TDbActionIntent$1;
|
|
469
|
+
description?: string;
|
|
470
|
+
order?: number;
|
|
471
|
+
default?: boolean;
|
|
472
|
+
promptText?: string;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Class-level dict entry. `value` semantics by processor:
|
|
476
|
+
*
|
|
477
|
+
* - `'navigate'` — REQUIRED, non-empty. The URL template (with `$1` substituted client-side).
|
|
478
|
+
* - `'backend'` — REQUIRED, non-empty. The full HTTP POST path the UI client should invoke.
|
|
479
|
+
* For row/rows entries the dev-supplied path MUST point to a `@Post`-bound
|
|
480
|
+
* handler accepting the PK-shaped JSON body (single PK scalar / composite
|
|
481
|
+
* object / array thereof) — typically a method using `@DbActionPK()` or
|
|
482
|
+
* `@DbActionPKs()`. The meta builder does NOT validate this.
|
|
483
|
+
* - `'custom'` — `value` is forbidden in the entry; the meta builder fills it
|
|
484
|
+
* with the dict key.
|
|
485
|
+
*/
|
|
486
|
+
type TDbActionsEntry = (DbActionsEntryCommon & {
|
|
487
|
+
processor: "navigate";
|
|
488
|
+
value: string;
|
|
489
|
+
}) | (DbActionsEntryCommon & {
|
|
490
|
+
processor: "custom";
|
|
491
|
+
value?: never;
|
|
492
|
+
}) | (DbActionsEntryCommon & {
|
|
493
|
+
processor: "backend";
|
|
494
|
+
value: string;
|
|
495
|
+
});
|
|
496
|
+
/** Distributes `Omit` across the discriminated union members. */
|
|
497
|
+
type DistributiveOmit<T, K extends keyof T> = T extends T ? Omit<T, K> : never;
|
|
498
|
+
/** Same as {@link TDbActionsEntry} but without the `level` field — used by the level-pinned shortcuts. */
|
|
499
|
+
type TDbActionsEntryUnpinned = DistributiveOmit<TDbActionsEntry, "level">;
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/actions/db-action.decorator.d.ts
|
|
502
|
+
/**
|
|
503
|
+
* Mark a controller method as a database action surfaced via `/meta`.
|
|
504
|
+
*
|
|
505
|
+
* Metadata-only — pair with `@Post(...)` for Moost to bind the route. The
|
|
506
|
+
* meta builder reads this metadata plus the bound POST path lazily and
|
|
507
|
+
* emits the action with `processor: 'backend'`. Order vs.
|
|
508
|
+
* `@DbActionDefault()` does not matter — both merge into the same slot.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```ts
|
|
512
|
+
* @Post('actions/block')
|
|
513
|
+
* @DbAction('block', { label: 'Block', icon: 'i-as-block', intent: 'negative' })
|
|
514
|
+
* async blockUser(@DbActionPK() id: string) { ... }
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
declare function DbAction(name: string, opts?: DbActionOpts): MethodDecorator;
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/actions/db-action-default.decorator.d.ts
|
|
520
|
+
/**
|
|
521
|
+
* Sugar that flips `default: true` on the same method's `@DbAction` metadata.
|
|
522
|
+
* Equivalent to passing `opts.default = true`. Decorator order does not matter.
|
|
523
|
+
*/
|
|
524
|
+
declare function DbActionDefault(): MethodDecorator;
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/actions/db-action-pk.decorator.d.ts
|
|
527
|
+
/**
|
|
528
|
+
* Parameter resolver that reads the primary key from the JSON request body
|
|
529
|
+
* and validates it against the bound table's PK schema.
|
|
530
|
+
*
|
|
531
|
+
* - Single-field PK → JSON-encoded scalar (`"abc"`, `42`, `true`).
|
|
532
|
+
* - Composite PK → JSON object with all PK fields.
|
|
533
|
+
*
|
|
534
|
+
* Validation is strict — no type coercion. Mismatches throw a
|
|
535
|
+
* `ValidatorError` which the existing validation interceptor surfaces as
|
|
536
|
+
* HTTP 400 with the same envelope as DTO failures.
|
|
537
|
+
*
|
|
538
|
+
* Marks the param so {@link discoverActions} can infer the action's `level`
|
|
539
|
+
* as `'row'`.
|
|
540
|
+
*/
|
|
541
|
+
declare function DbActionPK(): ParameterDecorator;
|
|
542
|
+
//#endregion
|
|
543
|
+
//#region src/actions/db-action-pks.decorator.d.ts
|
|
544
|
+
/**
|
|
545
|
+
* Parameter resolver that reads a JSON array of primary keys from the request
|
|
546
|
+
* body and validates each entry against the bound table's PK schema.
|
|
547
|
+
*
|
|
548
|
+
* - Scalar PK → JSON array of scalars (`["a","b","c"]`).
|
|
549
|
+
* - Composite PK → JSON array of objects.
|
|
550
|
+
*
|
|
551
|
+
* Validation is strict — no type coercion. Marks the param so
|
|
552
|
+
* {@link discoverActions} can infer the action's `level` as `'rows'`.
|
|
553
|
+
*/
|
|
554
|
+
declare function DbActionPKs(): ParameterDecorator;
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/actions/db-actions.decorator.d.ts
|
|
557
|
+
/**
|
|
558
|
+
* Declare class-level actions on a controller. Entries are flat dicts with
|
|
559
|
+
* `processor: 'navigate' | 'custom' | 'backend'` matching the `/meta` wire
|
|
560
|
+
* shape (see {@link TDbActionsEntry}). Each entry MUST specify `level`. Use
|
|
561
|
+
* the level-pinned shortcuts (`@DbTableActions`, `@DbRowActions`,
|
|
562
|
+
* `@DbRowsActions`) to avoid repeating `level`.
|
|
563
|
+
*
|
|
564
|
+
* The dictionary key serves as the action `name`. Entries do NOT bind any
|
|
565
|
+
* HTTP route — the meta builder surfaces them in `/meta` only. For
|
|
566
|
+
* `processor: 'backend'`, the dev-supplied `value` MUST point to a real
|
|
567
|
+
* `@Post`-bound endpoint accepting the level-determined body shape.
|
|
568
|
+
*
|
|
569
|
+
* Multiple `@DbActions` (and shortcut) decorators on the same class
|
|
570
|
+
* accumulate.
|
|
571
|
+
*/
|
|
572
|
+
declare function DbActions(dict: Record<string, TDbActionsEntry>): ClassDecorator;
|
|
573
|
+
/** Sugar for `@DbActions` with `level: 'table'` injected into each entry. */
|
|
574
|
+
declare function DbTableActions(dict: Record<string, TDbActionsEntryUnpinned>): ClassDecorator;
|
|
575
|
+
/** Sugar for `@DbActions` with `level: 'row'` injected into each entry. */
|
|
576
|
+
declare function DbRowActions(dict: Record<string, TDbActionsEntryUnpinned>): ClassDecorator;
|
|
577
|
+
/** Sugar for `@DbActions` with `level: 'rows'` injected into each entry. */
|
|
578
|
+
declare function DbRowsActions(dict: Record<string, TDbActionsEntryUnpinned>): ClassDecorator;
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/actions/discover.d.ts
|
|
581
|
+
/**
|
|
582
|
+
* Discover all actions declared on a controller and produce the `/meta` array.
|
|
583
|
+
* Reads class + method metadata via `getMoostMate()` and resolves bound POST
|
|
584
|
+
* paths through the Moost controller overview.
|
|
585
|
+
*
|
|
586
|
+
* Result is memoized per controller constructor — discovery walks every
|
|
587
|
+
* handler entry and reads decorator metadata, which is wasted work to repeat
|
|
588
|
+
* across instances.
|
|
589
|
+
*/
|
|
590
|
+
declare function discoverActions(controllerCtor: Function, app: Moost, logger: TConsoleBase): TDbActionInfo$1[];
|
|
591
|
+
//#endregion
|
|
592
|
+
//#region src/actions/pk-validation.d.ts
|
|
593
|
+
/**
|
|
594
|
+
* Minimal shape required to validate PKs against a table — supplied by the
|
|
595
|
+
* controller's underlying `AtscriptDbReadable`/`AtscriptDbTable`.
|
|
596
|
+
*/
|
|
597
|
+
interface PkValidationSource {
|
|
598
|
+
primaryKeys: readonly string[];
|
|
599
|
+
fieldDescriptors: readonly TDbFieldMeta[];
|
|
600
|
+
}
|
|
601
|
+
//#endregion
|
|
602
|
+
export { AsDbController, AsDbReadableController, AsJsonValueHelpController, AsReadableController, AsValueHelpController, DbAction, DbActionDefault, DbActionOpts, DbActionPK, DbActionPKs, DbActions, DbRowActions, DbRowsActions, DbTableActions, PkValidationSource, READABLE_DEF, ReadableController, ReadableGates, TABLE_DEF, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, TDbActionsEntry, TDbActionsEntryUnpinned, TableController, UseValidationErrorTransform, ValueHelpQuery, ViewController, discoverActions, validationErrorTransform };
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ import { HttpError } from "@moostjs/event-http";
|
|
|
4
4
|
import * as moost from "moost";
|
|
5
5
|
import { Moost, TConsoleBase } from "moost";
|
|
6
6
|
import * as _uniqu_url0 from "@uniqu/url";
|
|
7
|
-
import { AtscriptDbReadable, AtscriptDbTable, FilterExpr, TMetaResponse, Uniquery, UniqueryControls } from "@atscript/db";
|
|
7
|
+
import { AtscriptDbReadable, AtscriptDbTable, FilterExpr, TDbActionInfo, TDbActionInfo as TDbActionInfo$1, TDbActionIntent, TDbActionIntent as TDbActionIntent$1, TDbActionLevel, TDbActionLevel as TDbActionLevel$1, TDbActionProcessor, TDbFieldMeta, TMetaResponse, Uniquery, UniqueryControls } from "@atscript/db";
|
|
8
8
|
|
|
9
9
|
//#region src/as-readable.controller.d.ts
|
|
10
10
|
/**
|
|
@@ -123,8 +123,16 @@ declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = T
|
|
|
123
123
|
* Builds the `/meta` payload. Override in subclasses to populate source-specific
|
|
124
124
|
* fields. Defaults return a minimal envelope with the serialized type and the
|
|
125
125
|
* read-only flag; value-help dicts populate their capability hints here.
|
|
126
|
+
* Subclasses that fully replace the envelope must call {@link buildActions}
|
|
127
|
+
* directly so `@DbAction*` decorators still surface.
|
|
126
128
|
*/
|
|
127
129
|
protected buildMetaResponse(): Promise<TMetaResponse>;
|
|
130
|
+
/**
|
|
131
|
+
* Discovers `@DbAction*` and `@DbActions`-style class metadata on this
|
|
132
|
+
* controller and produces the `actions` array. Returns `[]` for value-help
|
|
133
|
+
* controllers — see {@link AsValueHelpController#buildMetaResponse}.
|
|
134
|
+
*/
|
|
135
|
+
protected buildActions(): TDbActionInfo$1[];
|
|
128
136
|
}
|
|
129
137
|
//#endregion
|
|
130
138
|
//#region src/as-db-readable.controller.d.ts
|
|
@@ -280,6 +288,12 @@ interface ValueHelpQuery<T> {
|
|
|
280
288
|
* requests against them. Subclasses that need a backend gate should compose
|
|
281
289
|
* one of their own (see {@link AsDbReadableController} for the
|
|
282
290
|
* `@db.column.filterable` / `@db.column.sortable` pattern).
|
|
291
|
+
*
|
|
292
|
+
* **Actions are intentionally NOT supported on value-help controllers.** The
|
|
293
|
+
* `/meta` payload still includes `actions: []` for shape uniformity, and any
|
|
294
|
+
* `@DbAction*` / `@DbActions*` decorators applied here are silently ignored.
|
|
295
|
+
* Value-help is for FK pickers and dictionary surfaces — adding row/table
|
|
296
|
+
* actions there would muddy the contract.
|
|
283
297
|
*/
|
|
284
298
|
declare abstract class AsValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsReadableController<T, DataType> {
|
|
285
299
|
/** Per-prop metadata map of the bound interface; eagerly built once. */
|
|
@@ -331,6 +345,7 @@ declare abstract class AsValueHelpController<T extends TAtscriptAnnotatedType =
|
|
|
331
345
|
* these flags at request time.
|
|
332
346
|
*/
|
|
333
347
|
protected buildMetaResponse(): Promise<TMetaResponse>;
|
|
348
|
+
protected buildActions(): never[];
|
|
334
349
|
}
|
|
335
350
|
//#endregion
|
|
336
351
|
//#region src/as-json-value-help.controller.d.ts
|
|
@@ -436,4 +451,152 @@ declare const ViewController: (readable: AtscriptDbReadable, prefix?: string) =>
|
|
|
436
451
|
declare const validationErrorTransform: () => moost.TInterceptorDef;
|
|
437
452
|
declare const UseValidationErrorTransform: () => ClassDecorator & MethodDecorator;
|
|
438
453
|
//#endregion
|
|
439
|
-
|
|
454
|
+
//#region src/actions/types.d.ts
|
|
455
|
+
/**
|
|
456
|
+
* Options accepted by `@DbAction(name, opts?)`. Structurally derived from
|
|
457
|
+
* {@link TDbActionInfo} so every addition to the wire shape automatically
|
|
458
|
+
* propagates here. Fields owned by the framework (`name`, `level`, `processor`,
|
|
459
|
+
* `value`) are excluded — `name` comes from the decorator argument, `level` is
|
|
460
|
+
* inferred from `@DbActionPK*` usage, `processor` is fixed to `'backend'` for
|
|
461
|
+
* method-decorator actions, and `value` is filled from the `@Post` path.
|
|
462
|
+
*/
|
|
463
|
+
type DbActionOpts = Partial<Omit<TDbActionInfo$1, "name" | "level" | "processor" | "value">>;
|
|
464
|
+
interface DbActionsEntryCommon {
|
|
465
|
+
label: string;
|
|
466
|
+
level: TDbActionLevel$1;
|
|
467
|
+
icon?: string;
|
|
468
|
+
intent?: TDbActionIntent$1;
|
|
469
|
+
description?: string;
|
|
470
|
+
order?: number;
|
|
471
|
+
default?: boolean;
|
|
472
|
+
promptText?: string;
|
|
473
|
+
}
|
|
474
|
+
/**
|
|
475
|
+
* Class-level dict entry. `value` semantics by processor:
|
|
476
|
+
*
|
|
477
|
+
* - `'navigate'` — REQUIRED, non-empty. The URL template (with `$1` substituted client-side).
|
|
478
|
+
* - `'backend'` — REQUIRED, non-empty. The full HTTP POST path the UI client should invoke.
|
|
479
|
+
* For row/rows entries the dev-supplied path MUST point to a `@Post`-bound
|
|
480
|
+
* handler accepting the PK-shaped JSON body (single PK scalar / composite
|
|
481
|
+
* object / array thereof) — typically a method using `@DbActionPK()` or
|
|
482
|
+
* `@DbActionPKs()`. The meta builder does NOT validate this.
|
|
483
|
+
* - `'custom'` — `value` is forbidden in the entry; the meta builder fills it
|
|
484
|
+
* with the dict key.
|
|
485
|
+
*/
|
|
486
|
+
type TDbActionsEntry = (DbActionsEntryCommon & {
|
|
487
|
+
processor: "navigate";
|
|
488
|
+
value: string;
|
|
489
|
+
}) | (DbActionsEntryCommon & {
|
|
490
|
+
processor: "custom";
|
|
491
|
+
value?: never;
|
|
492
|
+
}) | (DbActionsEntryCommon & {
|
|
493
|
+
processor: "backend";
|
|
494
|
+
value: string;
|
|
495
|
+
});
|
|
496
|
+
/** Distributes `Omit` across the discriminated union members. */
|
|
497
|
+
type DistributiveOmit<T, K extends keyof T> = T extends T ? Omit<T, K> : never;
|
|
498
|
+
/** Same as {@link TDbActionsEntry} but without the `level` field — used by the level-pinned shortcuts. */
|
|
499
|
+
type TDbActionsEntryUnpinned = DistributiveOmit<TDbActionsEntry, "level">;
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region src/actions/db-action.decorator.d.ts
|
|
502
|
+
/**
|
|
503
|
+
* Mark a controller method as a database action surfaced via `/meta`.
|
|
504
|
+
*
|
|
505
|
+
* Metadata-only — pair with `@Post(...)` for Moost to bind the route. The
|
|
506
|
+
* meta builder reads this metadata plus the bound POST path lazily and
|
|
507
|
+
* emits the action with `processor: 'backend'`. Order vs.
|
|
508
|
+
* `@DbActionDefault()` does not matter — both merge into the same slot.
|
|
509
|
+
*
|
|
510
|
+
* @example
|
|
511
|
+
* ```ts
|
|
512
|
+
* @Post('actions/block')
|
|
513
|
+
* @DbAction('block', { label: 'Block', icon: 'i-as-block', intent: 'negative' })
|
|
514
|
+
* async blockUser(@DbActionPK() id: string) { ... }
|
|
515
|
+
* ```
|
|
516
|
+
*/
|
|
517
|
+
declare function DbAction(name: string, opts?: DbActionOpts): MethodDecorator;
|
|
518
|
+
//#endregion
|
|
519
|
+
//#region src/actions/db-action-default.decorator.d.ts
|
|
520
|
+
/**
|
|
521
|
+
* Sugar that flips `default: true` on the same method's `@DbAction` metadata.
|
|
522
|
+
* Equivalent to passing `opts.default = true`. Decorator order does not matter.
|
|
523
|
+
*/
|
|
524
|
+
declare function DbActionDefault(): MethodDecorator;
|
|
525
|
+
//#endregion
|
|
526
|
+
//#region src/actions/db-action-pk.decorator.d.ts
|
|
527
|
+
/**
|
|
528
|
+
* Parameter resolver that reads the primary key from the JSON request body
|
|
529
|
+
* and validates it against the bound table's PK schema.
|
|
530
|
+
*
|
|
531
|
+
* - Single-field PK → JSON-encoded scalar (`"abc"`, `42`, `true`).
|
|
532
|
+
* - Composite PK → JSON object with all PK fields.
|
|
533
|
+
*
|
|
534
|
+
* Validation is strict — no type coercion. Mismatches throw a
|
|
535
|
+
* `ValidatorError` which the existing validation interceptor surfaces as
|
|
536
|
+
* HTTP 400 with the same envelope as DTO failures.
|
|
537
|
+
*
|
|
538
|
+
* Marks the param so {@link discoverActions} can infer the action's `level`
|
|
539
|
+
* as `'row'`.
|
|
540
|
+
*/
|
|
541
|
+
declare function DbActionPK(): ParameterDecorator;
|
|
542
|
+
//#endregion
|
|
543
|
+
//#region src/actions/db-action-pks.decorator.d.ts
|
|
544
|
+
/**
|
|
545
|
+
* Parameter resolver that reads a JSON array of primary keys from the request
|
|
546
|
+
* body and validates each entry against the bound table's PK schema.
|
|
547
|
+
*
|
|
548
|
+
* - Scalar PK → JSON array of scalars (`["a","b","c"]`).
|
|
549
|
+
* - Composite PK → JSON array of objects.
|
|
550
|
+
*
|
|
551
|
+
* Validation is strict — no type coercion. Marks the param so
|
|
552
|
+
* {@link discoverActions} can infer the action's `level` as `'rows'`.
|
|
553
|
+
*/
|
|
554
|
+
declare function DbActionPKs(): ParameterDecorator;
|
|
555
|
+
//#endregion
|
|
556
|
+
//#region src/actions/db-actions.decorator.d.ts
|
|
557
|
+
/**
|
|
558
|
+
* Declare class-level actions on a controller. Entries are flat dicts with
|
|
559
|
+
* `processor: 'navigate' | 'custom' | 'backend'` matching the `/meta` wire
|
|
560
|
+
* shape (see {@link TDbActionsEntry}). Each entry MUST specify `level`. Use
|
|
561
|
+
* the level-pinned shortcuts (`@DbTableActions`, `@DbRowActions`,
|
|
562
|
+
* `@DbRowsActions`) to avoid repeating `level`.
|
|
563
|
+
*
|
|
564
|
+
* The dictionary key serves as the action `name`. Entries do NOT bind any
|
|
565
|
+
* HTTP route — the meta builder surfaces them in `/meta` only. For
|
|
566
|
+
* `processor: 'backend'`, the dev-supplied `value` MUST point to a real
|
|
567
|
+
* `@Post`-bound endpoint accepting the level-determined body shape.
|
|
568
|
+
*
|
|
569
|
+
* Multiple `@DbActions` (and shortcut) decorators on the same class
|
|
570
|
+
* accumulate.
|
|
571
|
+
*/
|
|
572
|
+
declare function DbActions(dict: Record<string, TDbActionsEntry>): ClassDecorator;
|
|
573
|
+
/** Sugar for `@DbActions` with `level: 'table'` injected into each entry. */
|
|
574
|
+
declare function DbTableActions(dict: Record<string, TDbActionsEntryUnpinned>): ClassDecorator;
|
|
575
|
+
/** Sugar for `@DbActions` with `level: 'row'` injected into each entry. */
|
|
576
|
+
declare function DbRowActions(dict: Record<string, TDbActionsEntryUnpinned>): ClassDecorator;
|
|
577
|
+
/** Sugar for `@DbActions` with `level: 'rows'` injected into each entry. */
|
|
578
|
+
declare function DbRowsActions(dict: Record<string, TDbActionsEntryUnpinned>): ClassDecorator;
|
|
579
|
+
//#endregion
|
|
580
|
+
//#region src/actions/discover.d.ts
|
|
581
|
+
/**
|
|
582
|
+
* Discover all actions declared on a controller and produce the `/meta` array.
|
|
583
|
+
* Reads class + method metadata via `getMoostMate()` and resolves bound POST
|
|
584
|
+
* paths through the Moost controller overview.
|
|
585
|
+
*
|
|
586
|
+
* Result is memoized per controller constructor — discovery walks every
|
|
587
|
+
* handler entry and reads decorator metadata, which is wasted work to repeat
|
|
588
|
+
* across instances.
|
|
589
|
+
*/
|
|
590
|
+
declare function discoverActions(controllerCtor: Function, app: Moost, logger: TConsoleBase): TDbActionInfo$1[];
|
|
591
|
+
//#endregion
|
|
592
|
+
//#region src/actions/pk-validation.d.ts
|
|
593
|
+
/**
|
|
594
|
+
* Minimal shape required to validate PKs against a table — supplied by the
|
|
595
|
+
* controller's underlying `AtscriptDbReadable`/`AtscriptDbTable`.
|
|
596
|
+
*/
|
|
597
|
+
interface PkValidationSource {
|
|
598
|
+
primaryKeys: readonly string[];
|
|
599
|
+
fieldDescriptors: readonly TDbFieldMeta[];
|
|
600
|
+
}
|
|
601
|
+
//#endregion
|
|
602
|
+
export { AsDbController, AsDbReadableController, AsJsonValueHelpController, AsReadableController, AsValueHelpController, DbAction, DbActionDefault, type DbActionOpts, DbActionPK, DbActionPKs, DbActions, DbRowActions, DbRowsActions, DbTableActions, type PkValidationSource, READABLE_DEF, ReadableController, ReadableGates, TABLE_DEF, type TDbActionInfo, type TDbActionIntent, type TDbActionLevel, type TDbActionProcessor, type TDbActionsEntry, type TDbActionsEntryUnpinned, TableController, UseValidationErrorTransform, ValueHelpQuery, ViewController, discoverActions, validationErrorTransform };
|