@atscript/moost-db 0.1.77 → 0.1.79
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/index.cjs +2298 -3016
- package/dist/index.d.cts +66 -251
- package/dist/index.d.mts +66 -251
- package/dist/index.mjs +2274 -2841
- package/package.json +15 -15
package/dist/index.d.cts
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
1
|
import * as _$_uniqu_url0 from "@uniqu/url";
|
|
2
2
|
import { parseUrl } from "@uniqu/url";
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
TAtscriptDataType,
|
|
6
|
-
TSerializeOptions,
|
|
7
|
-
TSerializedAnnotatedType,
|
|
8
|
-
Validator,
|
|
9
|
-
} from "@atscript/typescript/utils";
|
|
10
|
-
import {
|
|
11
|
-
AtscriptDbReadable,
|
|
12
|
-
AtscriptDbTable,
|
|
13
|
-
FilterExpr,
|
|
14
|
-
FlatOf,
|
|
15
|
-
TCrudOp,
|
|
16
|
-
TCrudPermissions,
|
|
17
|
-
TCrudPermissions as TCrudPermissions$1,
|
|
18
|
-
TDbActionInfo,
|
|
19
|
-
TDbActionInfo as TDbActionInfo$1,
|
|
20
|
-
TDbActionIntent,
|
|
21
|
-
TDbActionIntent as TDbActionIntent$1,
|
|
22
|
-
TDbActionLevel,
|
|
23
|
-
TDbActionLevel as TDbActionLevel$1,
|
|
24
|
-
TDbActionProcessor,
|
|
25
|
-
TDbFieldMeta,
|
|
26
|
-
TIdentification,
|
|
27
|
-
TMetaResponse,
|
|
28
|
-
Uniquery,
|
|
29
|
-
UniqueryControls,
|
|
30
|
-
} from "@atscript/db";
|
|
3
|
+
import { TAtscriptAnnotatedType, TAtscriptDataType, TSerializeOptions, TSerializedAnnotatedType, Validator } from "@atscript/typescript/utils";
|
|
4
|
+
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";
|
|
31
5
|
import { HttpError } from "@moostjs/event-http";
|
|
32
6
|
import * as _$moost from "moost";
|
|
33
7
|
import { Mate, Moost, TConsoleBase, TMateParamMeta, TMoostMetadata } from "moost";
|
|
@@ -74,10 +48,7 @@ interface ReadableGates {
|
|
|
74
48
|
* handlers that match the data source's contract (DB readables route into
|
|
75
49
|
* aggregate/vector/search; value-help controllers just filter/sort/paginate).
|
|
76
50
|
*/
|
|
77
|
-
declare abstract class AsReadableController<
|
|
78
|
-
T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType,
|
|
79
|
-
DataType = TAtscriptDataType<T>,
|
|
80
|
-
> {
|
|
51
|
+
declare abstract class AsReadableController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> {
|
|
81
52
|
/** The Atscript interface this controller serves. */
|
|
82
53
|
protected readonly boundType: T;
|
|
83
54
|
/** Short human-readable name for logging (usually the table/source name). */
|
|
@@ -126,25 +97,15 @@ declare abstract class AsReadableController<
|
|
|
126
97
|
protected get queryControlsValidator(): Validator<any, unknown>;
|
|
127
98
|
protected get pagesControlsValidator(): Validator<any, unknown>;
|
|
128
99
|
protected get getOneControlsValidator(): Validator<any, unknown>;
|
|
129
|
-
protected validateControls(
|
|
130
|
-
controls: Record<string, unknown>,
|
|
131
|
-
type: "query" | "pages" | "getOne",
|
|
132
|
-
): string | undefined;
|
|
100
|
+
protected validateControls(controls: Record<string, unknown>, type: "query" | "pages" | "getOne"): string | undefined;
|
|
133
101
|
protected validateInsights(insights: Map<string, unknown>): string | undefined;
|
|
134
|
-
protected validateParsed(
|
|
135
|
-
parsed: Uniquery,
|
|
136
|
-
type: "query" | "pages" | "getOne",
|
|
137
|
-
): HttpError | undefined;
|
|
102
|
+
protected validateParsed(parsed: Uniquery, type: "query" | "pages" | "getOne"): HttpError | undefined;
|
|
138
103
|
/**
|
|
139
104
|
* Shared filter/sort/search gate check. Subclasses assemble a {@link ReadableGates}
|
|
140
105
|
* config per request (or once in the constructor when static) and call this to
|
|
141
106
|
* get a uniform HTTP 400 response for any offending field/control.
|
|
142
107
|
*/
|
|
143
|
-
protected checkGates(
|
|
144
|
-
filter: FilterExpr | undefined,
|
|
145
|
-
controls: Record<string, unknown>,
|
|
146
|
-
gates: ReadableGates,
|
|
147
|
-
): HttpError | undefined;
|
|
108
|
+
protected checkGates(filter: FilterExpr | undefined, controls: Record<string, unknown>, gates: ReadableGates): HttpError | undefined;
|
|
148
109
|
protected parseQueryString(url: string): _$_uniqu_url0.UrlQuery;
|
|
149
110
|
/**
|
|
150
111
|
* Parse a URL keeping only `$*` control keywords; report whether any
|
|
@@ -213,10 +174,7 @@ declare abstract class AsReadableController<
|
|
|
213
174
|
* For write operations (insert, replace, update, delete), use {@link AsDbController}.
|
|
214
175
|
* For views, use {@link AsDbViewController}.
|
|
215
176
|
*/
|
|
216
|
-
declare class AsDbReadableController<
|
|
217
|
-
T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType,
|
|
218
|
-
DataType = TAtscriptDataType<T>,
|
|
219
|
-
> extends AsReadableController<T, DataType> {
|
|
177
|
+
declare class AsDbReadableController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsReadableController<T, DataType> {
|
|
220
178
|
/** Reference to the underlying readable (table or view). */
|
|
221
179
|
protected readable: AtscriptDbReadable<T>;
|
|
222
180
|
private readonly _gates;
|
|
@@ -238,16 +196,9 @@ declare class AsDbReadableController<
|
|
|
238
196
|
* adapter, not an annotation the user could add to bypass it. Sort uses
|
|
239
197
|
* adapter capability differently and is enforced at the SQL builder layer.
|
|
240
198
|
*/
|
|
241
|
-
protected checkGates(
|
|
242
|
-
filter: FilterExpr | undefined,
|
|
243
|
-
controls: Record<string, unknown>,
|
|
244
|
-
gates: ReadableGates,
|
|
245
|
-
): HttpError | undefined;
|
|
199
|
+
protected checkGates(filter: FilterExpr | undefined, controls: Record<string, unknown>, gates: ReadableGates): HttpError | undefined;
|
|
246
200
|
/** Validates $with relations against the readable. */
|
|
247
|
-
protected validateParsed(
|
|
248
|
-
parsed: Uniquery,
|
|
249
|
-
type: "query" | "pages" | "getOne",
|
|
250
|
-
): HttpError | undefined;
|
|
201
|
+
protected validateParsed(parsed: Uniquery, type: "query" | "pages" | "getOne"): HttpError | undefined;
|
|
251
202
|
/**
|
|
252
203
|
* Compute an embedding vector from a search term.
|
|
253
204
|
* Override in subclass to integrate with your embedding provider (OpenAI, etc.).
|
|
@@ -270,9 +221,7 @@ declare class AsDbReadableController<
|
|
|
270
221
|
* Transform projection before querying.
|
|
271
222
|
* May return a Promise for async lookups.
|
|
272
223
|
*/
|
|
273
|
-
protected transformProjection(
|
|
274
|
-
projection?: UniqueryControls["$select"],
|
|
275
|
-
): UniqueryControls["$select"] | undefined | Promise<UniqueryControls["$select"] | undefined>;
|
|
224
|
+
protected transformProjection(projection?: UniqueryControls["$select"]): UniqueryControls["$select"] | undefined | Promise<UniqueryControls["$select"] | undefined>;
|
|
276
225
|
private widenPreferredIdProjection;
|
|
277
226
|
private _widenArrayProjection;
|
|
278
227
|
private _widenMapProjection;
|
|
@@ -311,16 +260,13 @@ declare class AsDbReadableController<
|
|
|
311
260
|
/**
|
|
312
261
|
* **GET /pages** — returns paginated records with metadata.
|
|
313
262
|
*/
|
|
314
|
-
pages(url: string): Promise<
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
}
|
|
322
|
-
| HttpError
|
|
323
|
-
>;
|
|
263
|
+
pages(url: string): Promise<{
|
|
264
|
+
data: DataType[];
|
|
265
|
+
page: number;
|
|
266
|
+
itemsPerPage: number;
|
|
267
|
+
pages: number;
|
|
268
|
+
count: number;
|
|
269
|
+
} | HttpError>;
|
|
324
270
|
/**
|
|
325
271
|
* **GET /one/:id** — retrieves a single record by ID or unique property.
|
|
326
272
|
* The id-filter is AND-combined with {@link transformOne} so row-level
|
|
@@ -356,10 +302,7 @@ declare class AsDbReadableController<
|
|
|
356
302
|
* export class UsersController extends AsDbController<typeof UserModel> {}
|
|
357
303
|
* ```
|
|
358
304
|
*/
|
|
359
|
-
declare class AsDbController<
|
|
360
|
-
T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType,
|
|
361
|
-
DataType = TAtscriptDataType<T>,
|
|
362
|
-
> extends AsDbReadableController<T, DataType> {
|
|
305
|
+
declare class AsDbController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsDbReadableController<T, DataType> {
|
|
363
306
|
/** Reference to the underlying table (typed for write access). */
|
|
364
307
|
protected get table(): AtscriptDbTable<T>;
|
|
365
308
|
constructor(table: AtscriptDbTable<T>, app: Moost);
|
|
@@ -368,10 +311,7 @@ declare class AsDbController<
|
|
|
368
311
|
* Intercepts write operations. Return `undefined` to abort.
|
|
369
312
|
* May be async (e.g. to enrich payloads from session / permissions).
|
|
370
313
|
*/
|
|
371
|
-
protected onWrite(
|
|
372
|
-
action: "insert" | "insertMany" | "replace" | "replaceMany" | "update" | "updateMany",
|
|
373
|
-
data: unknown,
|
|
374
|
-
): unknown;
|
|
314
|
+
protected onWrite(action: "insert" | "insertMany" | "replace" | "replaceMany" | "update" | "updateMany", data: unknown): unknown;
|
|
375
315
|
/**
|
|
376
316
|
* Intercepts delete operations. Return `undefined` to abort.
|
|
377
317
|
* May be async (e.g. to resolve composite ids from external state).
|
|
@@ -439,10 +379,7 @@ interface ValueHelpQuery<T> {
|
|
|
439
379
|
* Value-help is for FK pickers and dictionary surfaces — adding row/table
|
|
440
380
|
* actions there would muddy the contract.
|
|
441
381
|
*/
|
|
442
|
-
declare abstract class AsValueHelpController<
|
|
443
|
-
T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType,
|
|
444
|
-
DataType = TAtscriptDataType<T>,
|
|
445
|
-
> extends AsReadableController<T, DataType> {
|
|
382
|
+
declare abstract class AsValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsReadableController<T, DataType> {
|
|
446
383
|
/** Per-prop metadata map of the bound interface; eagerly built once. */
|
|
447
384
|
protected readonly fieldMeta: Map<string, Map<string, unknown>>;
|
|
448
385
|
/**
|
|
@@ -471,16 +408,13 @@ declare abstract class AsValueHelpController<
|
|
|
471
408
|
/**
|
|
472
409
|
* **GET /pages** — paginated row window plus total count.
|
|
473
410
|
*/
|
|
474
|
-
runPages(url: string): Promise<
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
}
|
|
482
|
-
| HttpError
|
|
483
|
-
>;
|
|
411
|
+
runPages(url: string): Promise<{
|
|
412
|
+
data: DataType[];
|
|
413
|
+
page: number;
|
|
414
|
+
itemsPerPage: number;
|
|
415
|
+
pages: number;
|
|
416
|
+
count: number;
|
|
417
|
+
} | HttpError>;
|
|
484
418
|
/**
|
|
485
419
|
* **GET /one/:id** — retrieves a single row by primary key.
|
|
486
420
|
*/
|
|
@@ -529,10 +463,7 @@ declare abstract class AsValueHelpController<
|
|
|
529
463
|
* Register under a Moost path with `@Controller('/api/dicts/status')` or the
|
|
530
464
|
* equivalent composition decorator.
|
|
531
465
|
*/
|
|
532
|
-
declare class AsJsonValueHelpController<
|
|
533
|
-
T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType,
|
|
534
|
-
DataType = TAtscriptDataType<T>,
|
|
535
|
-
> extends AsValueHelpController<T, DataType> {
|
|
466
|
+
declare class AsJsonValueHelpController<T extends TAtscriptAnnotatedType = TAtscriptAnnotatedType, DataType = TAtscriptDataType<T>> extends AsValueHelpController<T, DataType> {
|
|
536
467
|
protected rows: DataType[];
|
|
537
468
|
private _pkIndex?;
|
|
538
469
|
constructor(boundType: T, rows: DataType[], app: Moost, controllerName?: string);
|
|
@@ -575,10 +506,7 @@ declare const TABLE_DEF = "__atscript_db_readable_def";
|
|
|
575
506
|
* export class UsersController extends AsDbController<typeof UserModel> {}
|
|
576
507
|
* ```
|
|
577
508
|
*/
|
|
578
|
-
declare const TableController: (
|
|
579
|
-
table: AtscriptDbTable,
|
|
580
|
-
prefix?: string,
|
|
581
|
-
) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
509
|
+
declare const TableController: <Table extends AtscriptDbTable<any, any, any, any, any, any, any>>(table: Table, prefix?: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
582
510
|
/**
|
|
583
511
|
* Combines the boilerplate needed to turn an {@link AsDbReadableController}
|
|
584
512
|
* subclass into a fully wired HTTP controller for a given `@db.view` or `@db.table` model.
|
|
@@ -592,10 +520,7 @@ declare const TableController: (
|
|
|
592
520
|
* export class ActiveTasksController extends AsDbReadableController<typeof ActiveTasks> {}
|
|
593
521
|
* ```
|
|
594
522
|
*/
|
|
595
|
-
declare const ReadableController: (
|
|
596
|
-
readable: AtscriptDbReadable,
|
|
597
|
-
prefix?: string,
|
|
598
|
-
) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
523
|
+
declare const ReadableController: <Readable extends AtscriptDbReadable<any, any, any, any, any, any, any>>(readable: Readable, prefix?: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
599
524
|
/**
|
|
600
525
|
* Alias for {@link ReadableController} — use with view-backed controllers.
|
|
601
526
|
*
|
|
@@ -605,10 +530,7 @@ declare const ReadableController: (
|
|
|
605
530
|
* export class ActiveTasksController extends AsDbReadableController<typeof ActiveTasks> {}
|
|
606
531
|
* ```
|
|
607
532
|
*/
|
|
608
|
-
declare const ViewController: (
|
|
609
|
-
readable: AtscriptDbReadable,
|
|
610
|
-
prefix?: string,
|
|
611
|
-
) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
533
|
+
declare const ViewController: <Readable extends AtscriptDbReadable<any, any, any, any, any, any, any>>(readable: Readable, prefix?: string) => MethodDecorator & ClassDecorator & ParameterDecorator & PropertyDecorator;
|
|
612
534
|
//#endregion
|
|
613
535
|
//#region src/validation-interceptor.d.ts
|
|
614
536
|
declare const validationErrorTransform: () => _$moost.TInterceptorDef;
|
|
@@ -629,9 +551,7 @@ type TOnDisabledRows = "reject" | "skip";
|
|
|
629
551
|
*/
|
|
630
552
|
type FlatKey<TRow> = unknown extends TRow ? string : keyof FlatOf<TRow> & string;
|
|
631
553
|
/** Row-shape narrowing for the `disabled` predicate. Falls back to `any` when `TRow = unknown`. */
|
|
632
|
-
type DisabledRowsArg<TRow, R extends readonly FlatKey<TRow>[]> = unknown extends TRow
|
|
633
|
-
? any[]
|
|
634
|
-
: Pick<FlatOf<TRow>, R[number] & keyof FlatOf<TRow>>[];
|
|
554
|
+
type DisabledRowsArg<TRow, R extends readonly FlatKey<TRow>[]> = unknown extends TRow ? any[] : Pick<FlatOf<TRow>, R[number] & keyof FlatOf<TRow>>[];
|
|
635
555
|
interface NoGate {
|
|
636
556
|
requiredFields?: never;
|
|
637
557
|
disabled?: never;
|
|
@@ -676,12 +596,8 @@ interface LooseGate {
|
|
|
676
596
|
disabled?: (rows: any[]) => boolean[];
|
|
677
597
|
onDisabledRows?: TOnDisabledRows;
|
|
678
598
|
}
|
|
679
|
-
type GateOpts<TRow, R extends readonly FlatKey<TRow>[]> = unknown extends TRow
|
|
680
|
-
|
|
681
|
-
: NoGate | WithGate<TRow, R>;
|
|
682
|
-
interface BaseActionOpts extends Partial<
|
|
683
|
-
Omit<TDbActionInfo$1, "name" | "level" | "processor" | "value" | "disabled">
|
|
684
|
-
> {
|
|
599
|
+
type GateOpts<TRow, R extends readonly FlatKey<TRow>[]> = unknown extends TRow ? LooseGate : NoGate | WithGate<TRow, R>;
|
|
600
|
+
interface BaseActionOpts extends Partial<Omit<TDbActionInfo$1, "name" | "level" | "processor" | "value" | "disabled">> {
|
|
685
601
|
/**
|
|
686
602
|
* Bound table reference. REQUIRED on non-`AsDbReadableController` classes
|
|
687
603
|
* when `disabled` is set OR a `@DbActionRow*` parameter is declared.
|
|
@@ -697,8 +613,7 @@ interface BaseActionOpts extends Partial<
|
|
|
697
613
|
* tuple). Both are inferred at the call site via the decorator's `<TRow>`
|
|
698
614
|
* argument plus `const R` generic.
|
|
699
615
|
*/
|
|
700
|
-
type DbActionOpts<TRow = unknown, R extends readonly FlatKey<TRow>[] = []> = BaseActionOpts &
|
|
701
|
-
GateOpts<TRow, R>;
|
|
616
|
+
type DbActionOpts<TRow = unknown, R extends readonly FlatKey<TRow>[] = []> = BaseActionOpts & GateOpts<TRow, R>;
|
|
702
617
|
interface DbActionsEntryCommonBase {
|
|
703
618
|
label: string;
|
|
704
619
|
level: TDbActionLevel$1;
|
|
@@ -712,8 +627,7 @@ interface DbActionsEntryCommonBase {
|
|
|
712
627
|
/** Mirrors {@link TDbActionInfo.shortcut} — single-character UI hint. */
|
|
713
628
|
shortcut?: string;
|
|
714
629
|
}
|
|
715
|
-
type DbActionsEntryWithGate<TRow, R extends readonly FlatKey<TRow>[]> = DbActionsEntryCommonBase &
|
|
716
|
-
GateOpts<TRow, R>;
|
|
630
|
+
type DbActionsEntryWithGate<TRow, R extends readonly FlatKey<TRow>[]> = DbActionsEntryCommonBase & GateOpts<TRow, R>;
|
|
717
631
|
/**
|
|
718
632
|
* Class-level dict entry. `value` semantics by processor:
|
|
719
633
|
*
|
|
@@ -722,40 +636,26 @@ type DbActionsEntryWithGate<TRow, R extends readonly FlatKey<TRow>[]> = DbAction
|
|
|
722
636
|
* - `'custom'` — `value` is forbidden in the entry; the meta builder fills it
|
|
723
637
|
* with the dict key.
|
|
724
638
|
*/
|
|
725
|
-
type TDbActionsEntry<TRow = unknown, R extends readonly FlatKey<TRow>[] = []> =
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
processor: "backend";
|
|
736
|
-
value: string;
|
|
737
|
-
});
|
|
639
|
+
type TDbActionsEntry<TRow = unknown, R extends readonly FlatKey<TRow>[] = []> = (DbActionsEntryWithGate<TRow, R> & {
|
|
640
|
+
processor: "navigate";
|
|
641
|
+
value: string;
|
|
642
|
+
}) | (DbActionsEntryWithGate<TRow, R> & {
|
|
643
|
+
processor: "custom";
|
|
644
|
+
value?: never;
|
|
645
|
+
}) | (DbActionsEntryWithGate<TRow, R> & {
|
|
646
|
+
processor: "backend";
|
|
647
|
+
value: string;
|
|
648
|
+
});
|
|
738
649
|
/** Distributes `Omit` across the discriminated union members. */
|
|
739
650
|
type DistributiveOmit<T, K extends keyof T> = T extends T ? Omit<T, K> : never;
|
|
740
651
|
/** Same as {@link TDbActionsEntry} but without the `level` field — used by the level-pinned shortcuts. */
|
|
741
|
-
type TDbActionsEntryUnpinned<
|
|
742
|
-
TRow = unknown,
|
|
743
|
-
R extends readonly FlatKey<TRow>[] = [],
|
|
744
|
-
> = DistributiveOmit<TDbActionsEntry<TRow, R>, "level">;
|
|
652
|
+
type TDbActionsEntryUnpinned<TRow = unknown, R extends readonly FlatKey<TRow>[] = []> = DistributiveOmit<TDbActionsEntry<TRow, R>, "level">;
|
|
745
653
|
type DbActionsDictBase = Record<string, unknown>;
|
|
746
654
|
type EntryRequiredFields<E, TRow> = E extends {
|
|
747
655
|
requiredFields: infer R;
|
|
748
|
-
}
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
: []
|
|
752
|
-
: [];
|
|
753
|
-
type ValidatedDict<TRow, D extends DbActionsDictBase> = {
|
|
754
|
-
[K in keyof D]: TDbActionsEntry<TRow, EntryRequiredFields<D[K], TRow>>;
|
|
755
|
-
};
|
|
756
|
-
type ValidatedUnpinnedDict<TRow, D extends DbActionsDictBase> = {
|
|
757
|
-
[K in keyof D]: TDbActionsEntryUnpinned<TRow, EntryRequiredFields<D[K], TRow>>;
|
|
758
|
-
};
|
|
656
|
+
} ? R extends readonly FlatKey<TRow>[] ? R : [] : [];
|
|
657
|
+
type ValidatedDict<TRow, D extends DbActionsDictBase> = { [K in keyof D]: TDbActionsEntry<TRow, EntryRequiredFields<D[K], TRow>> };
|
|
658
|
+
type ValidatedUnpinnedDict<TRow, D extends DbActionsDictBase> = { [K in keyof D]: TDbActionsEntryUnpinned<TRow, EntryRequiredFields<D[K], TRow>> };
|
|
759
659
|
//#endregion
|
|
760
660
|
//#region src/actions/db-action.decorator.d.ts
|
|
761
661
|
/**
|
|
@@ -770,10 +670,7 @@ type ValidatedUnpinnedDict<TRow, D extends DbActionsDictBase> = {
|
|
|
770
670
|
* The `disabled` predicate's `rows` argument is type-narrowed to
|
|
771
671
|
* `Pick<FlatOf<TRow>, R[number]>[]`.
|
|
772
672
|
*/
|
|
773
|
-
declare function DbAction<TRow = unknown, const R extends readonly FlatKey<TRow>[] = []>(
|
|
774
|
-
name: string,
|
|
775
|
-
opts?: DbActionOpts<TRow, R>,
|
|
776
|
-
): MethodDecorator;
|
|
673
|
+
declare function DbAction<TRow = unknown, const R extends readonly FlatKey<TRow>[] = []>(name: string, opts?: DbActionOpts<TRow, R>): MethodDecorator;
|
|
777
674
|
//#endregion
|
|
778
675
|
//#region src/actions/db-action-default.decorator.d.ts
|
|
779
676
|
/**
|
|
@@ -866,21 +763,13 @@ declare function DbActionRows(): ParameterDecorator;
|
|
|
866
763
|
* Multiple `@DbActions` (and shortcut) decorators on the same class
|
|
867
764
|
* accumulate.
|
|
868
765
|
*/
|
|
869
|
-
declare function DbActions<TRow = unknown, const D extends Record<string, unknown> = {}>(
|
|
870
|
-
dict: D & ValidatedDict<TRow, D>,
|
|
871
|
-
): ClassDecorator;
|
|
766
|
+
declare function DbActions<TRow = unknown, const D extends Record<string, unknown> = {}>(dict: D & ValidatedDict<TRow, D>): ClassDecorator;
|
|
872
767
|
/** Sugar for `@DbActions` with `level: 'table'` injected into each entry. */
|
|
873
|
-
declare function DbTableActions<TRow = unknown, const D extends Record<string, unknown> = {}>(
|
|
874
|
-
dict: D & ValidatedUnpinnedDict<TRow, D>,
|
|
875
|
-
): ClassDecorator;
|
|
768
|
+
declare function DbTableActions<TRow = unknown, const D extends Record<string, unknown> = {}>(dict: D & ValidatedUnpinnedDict<TRow, D>): ClassDecorator;
|
|
876
769
|
/** Sugar for `@DbActions` with `level: 'row'` injected into each entry. */
|
|
877
|
-
declare function DbRowActions<TRow = unknown, const D extends Record<string, unknown> = {}>(
|
|
878
|
-
dict: D & ValidatedUnpinnedDict<TRow, D>,
|
|
879
|
-
): ClassDecorator;
|
|
770
|
+
declare function DbRowActions<TRow = unknown, const D extends Record<string, unknown> = {}>(dict: D & ValidatedUnpinnedDict<TRow, D>): ClassDecorator;
|
|
880
771
|
/** Sugar for `@DbActions` with `level: 'rows'` injected into each entry. */
|
|
881
|
-
declare function DbRowsActions<TRow = unknown, const D extends Record<string, unknown> = {}>(
|
|
882
|
-
dict: D & ValidatedUnpinnedDict<TRow, D>,
|
|
883
|
-
): ClassDecorator;
|
|
772
|
+
declare function DbRowsActions<TRow = unknown, const D extends Record<string, unknown> = {}>(dict: D & ValidatedUnpinnedDict<TRow, D>): ClassDecorator;
|
|
884
773
|
//#endregion
|
|
885
774
|
//#region src/actions/db-action-input-form.decorator.d.ts
|
|
886
775
|
/**
|
|
@@ -910,11 +799,9 @@ declare function DbRowsActions<TRow = unknown, const D extends Record<string, un
|
|
|
910
799
|
* @param formType A compiled `.as` interface class (carries `.validator()`,
|
|
911
800
|
* `.metadata`, etc.).
|
|
912
801
|
*/
|
|
913
|
-
declare function InputForm<
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
},
|
|
917
|
-
>(formType: T): ParameterDecorator;
|
|
802
|
+
declare function InputForm<T extends TAtscriptAnnotatedType & {
|
|
803
|
+
readonly name: string;
|
|
804
|
+
}>(formType: T): ParameterDecorator;
|
|
918
805
|
//#endregion
|
|
919
806
|
//#region src/actions/discover.d.ts
|
|
920
807
|
/**
|
|
@@ -927,16 +814,9 @@ interface TDbActionEnvelope {
|
|
|
927
814
|
raw: DbActionOpts | TDbActionsEntry;
|
|
928
815
|
}
|
|
929
816
|
/** Lookup helper for `AsReadableController.metaForm()`. */
|
|
930
|
-
declare function getControllerFormType(
|
|
931
|
-
ctor: Function,
|
|
932
|
-
name: string,
|
|
933
|
-
): TAtscriptAnnotatedType | undefined;
|
|
817
|
+
declare function getControllerFormType(ctor: Function, name: string): TAtscriptAnnotatedType | undefined;
|
|
934
818
|
/** Discover actions on a controller, memoized per ctor. `info`-only callers map `e => e.info`. */
|
|
935
|
-
declare function discoverActions(
|
|
936
|
-
controllerCtor: Function,
|
|
937
|
-
app: Moost,
|
|
938
|
-
logger: TConsoleBase,
|
|
939
|
-
): TDbActionEnvelope[];
|
|
819
|
+
declare function discoverActions(controllerCtor: Function, app: Moost, logger: TConsoleBase): TDbActionEnvelope[];
|
|
940
820
|
//#endregion
|
|
941
821
|
//#region src/actions/id-validation.d.ts
|
|
942
822
|
/** Duck-typed shape; matches `AtscriptDbReadable`'s public surface. */
|
|
@@ -1140,16 +1020,11 @@ interface AtscriptDbParamsMeta {
|
|
|
1140
1020
|
* Class- and prop-meta storage mirror the same shape; param-meta
|
|
1141
1021
|
* storage uses {@link AtscriptDbParamsMeta}.
|
|
1142
1022
|
*/
|
|
1143
|
-
type AtscriptDbMate = Mate<
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
TMoostMetadata &
|
|
1149
|
-
AtscriptDbMeta & {
|
|
1150
|
-
params: (TMateParamMeta & AtscriptDbParamsMeta)[];
|
|
1151
|
-
}
|
|
1152
|
-
>;
|
|
1023
|
+
type AtscriptDbMate = Mate<TMoostMetadata & AtscriptDbMeta & {
|
|
1024
|
+
params: (TMateParamMeta & AtscriptDbParamsMeta)[];
|
|
1025
|
+
}, TMoostMetadata & AtscriptDbMeta & {
|
|
1026
|
+
params: (TMateParamMeta & AtscriptDbParamsMeta)[];
|
|
1027
|
+
}>;
|
|
1153
1028
|
/**
|
|
1154
1029
|
* Returns the shared moost-mate instance, typed against every key that
|
|
1155
1030
|
* `@atscript/moost-db` writes (see {@link AtscriptDbMeta} +
|
|
@@ -1176,64 +1051,4 @@ declare const QUERY_CONTROLS: readonly string[];
|
|
|
1176
1051
|
declare const PAGES_CONTROLS: readonly string[];
|
|
1177
1052
|
declare const ONE_CONTROLS: readonly string[];
|
|
1178
1053
|
//#endregion
|
|
1179
|
-
export {
|
|
1180
|
-
ActionDisabledError,
|
|
1181
|
-
type ActionDisabledErrorBody,
|
|
1182
|
-
AsDbController,
|
|
1183
|
-
AsDbReadableController,
|
|
1184
|
-
AsJsonValueHelpController,
|
|
1185
|
-
AsReadableController,
|
|
1186
|
-
AsValueHelpController,
|
|
1187
|
-
type AtscriptDbMate,
|
|
1188
|
-
type AtscriptDbMeta,
|
|
1189
|
-
type AtscriptDbParamsMeta,
|
|
1190
|
-
DbAction,
|
|
1191
|
-
DbActionDefault,
|
|
1192
|
-
type DbActionEnvelope,
|
|
1193
|
-
DbActionID,
|
|
1194
|
-
DbActionIDs,
|
|
1195
|
-
type DbActionOpts,
|
|
1196
|
-
DbActionRow,
|
|
1197
|
-
DbActionRows,
|
|
1198
|
-
DbActions,
|
|
1199
|
-
DbRowActions,
|
|
1200
|
-
DbRowsActions,
|
|
1201
|
-
DbTableActions,
|
|
1202
|
-
type IdValidationSource,
|
|
1203
|
-
InputForm,
|
|
1204
|
-
ONE_CONTROLS,
|
|
1205
|
-
PAGES_CONTROLS,
|
|
1206
|
-
QUERY_CONTROLS,
|
|
1207
|
-
READABLE_DEF,
|
|
1208
|
-
ReadableController,
|
|
1209
|
-
ReadableGates,
|
|
1210
|
-
TABLE_DEF,
|
|
1211
|
-
type TCrudOp,
|
|
1212
|
-
type TCrudPermissions,
|
|
1213
|
-
type TDbActionInfo,
|
|
1214
|
-
type TDbActionInputFormMeta,
|
|
1215
|
-
type TDbActionIntent,
|
|
1216
|
-
type TDbActionLevel,
|
|
1217
|
-
type TDbActionMeta,
|
|
1218
|
-
type TDbActionParamKind,
|
|
1219
|
-
type TDbActionProcessor,
|
|
1220
|
-
type TDbActionsEntry,
|
|
1221
|
-
type TDbActionsEntryUnpinned,
|
|
1222
|
-
type TDbClassActionMeta,
|
|
1223
|
-
TableController,
|
|
1224
|
-
UseValidationErrorTransform,
|
|
1225
|
-
ValueHelpQuery,
|
|
1226
|
-
ViewController,
|
|
1227
|
-
dbActionBodySlot,
|
|
1228
|
-
dbActionInputSlot,
|
|
1229
|
-
discoverActions,
|
|
1230
|
-
getAtscriptDbMate,
|
|
1231
|
-
getControllerFormType,
|
|
1232
|
-
perRow,
|
|
1233
|
-
useDbActionId,
|
|
1234
|
-
useDbActionIds,
|
|
1235
|
-
useDbActionInput,
|
|
1236
|
-
useDbActionRow,
|
|
1237
|
-
useDbActionRows,
|
|
1238
|
-
validationErrorTransform,
|
|
1239
|
-
};
|
|
1054
|
+
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 };
|