tempest-express-sdk 0.23.0 → 0.25.0

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.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { z } from 'zod';
2
2
  export { z } from 'zod';
3
3
  import * as tempest_db_js from 'tempest-db-js';
4
- import { Model, ModelClass, BaseRepository, WhereInput, InferModel, InferInsert, PaginationFilter as PaginationFilter$1, PaginationResult, AsyncDriver, AsyncEngine, AsyncSession } from 'tempest-db-js';
4
+ import { Model, ModelClass, BaseRepository, WhereInput, InferModel, InferInsert, PaginationFilter as PaginationFilter$1, PaginationResult, AsyncDriver, AsyncSession, Column, AsyncEngine } from 'tempest-db-js';
5
5
  export { AsyncDriver, AsyncEngine, AsyncResult, AsyncSession, BaseRepository, BelongsTo, ColType, Column, ColumnFlags, CompiledQuery, CondNode, Condition, DeleteBuilder, DeleteNode, Dialect, EngineOptions, Executable, HasMany, InferInsert, InferModel, InsertBuilder, InsertNode, Model, ModelClass, NoResultError, NodeSqliteDriver, Operator, OrderTerm, PaginationResult, ParsedDatabaseUrl, PostgresDialect, QueryNode, RecordNotFound, Relation, RelationValue, PaginationFilter as RepositoryPaginationFilter, Returning, RowOf, SelectBuilder, SelectNode, SortDirection, SqliteDialect, SyncEngine, SyncSession, UpdateBuilder, UpdateNode, WhereArg, WhereInput, WithRelations, and, belongsTo, column, columnsOf, createEngine, createSyncEngine, del, detectDialect, getDialect, hasMany, insert, join, loadRelations, not, or, parseDatabaseUrl, select, sql, update } from 'tempest-db-js';
6
6
  import { Request, Response as Response$1, RequestHandler, Router, ErrorRequestHandler, Express } from 'express';
7
7
  import * as ws from 'ws';
@@ -3493,17 +3493,1313 @@ declare class MessagingHub {
3493
3493
  }
3494
3494
 
3495
3495
  /**
3496
- * Admin site + resource registry, mirroring `admin.site` / `admin.config`.
3496
+ * Signed-cookie sessions for the admin panel, mirroring `admin.session`.
3497
3497
  *
3498
- * The FastAPI SDK ships a server-rendered (jinja) admin UI. Here the admin is a
3499
- * typed **JSON API**: register one {@link AdminResource} per managed entity and
3500
- * {@link makeAdminRouter} exposes auto-derived CRUD + introspection endpoints a
3501
- * frontend (React, etc.) renders. Resources are callback-based, so they wire to
3502
- * a `BaseService` — or any store — in a few lines and stay ORM-agnostic.
3498
+ * The panel's session is **stateless**: the principal id, display name, CSRF
3499
+ * token and expiry travel in the cookie itself, signed with HMAC-SHA256 over
3500
+ * the caller's secret. Nothing is kept server-side, so the panel survives a
3501
+ * restart and works across replicas without a shared store — the property that
3502
+ * matters most for an operator tool that is used in bursts and left open.
3503
+ *
3504
+ * The CSRF token lives inside the session payload, so every write form can
3505
+ * carry it and the server compares it against the cookie it already trusts.
3506
+ */
3507
+
3508
+ /** The payload carried by the admin session cookie. */
3509
+ interface AdminSession {
3510
+ /** Stable id of the authenticated principal. */
3511
+ subject: string;
3512
+ /** Display name shown in the header. */
3513
+ displayName: string;
3514
+ /** Token every write form echoes back for CSRF validation. */
3515
+ csrfToken: string;
3516
+ /** Expiry, in epoch seconds. */
3517
+ expiresAt: number;
3518
+ /**
3519
+ * `true` once the second factor was accepted. Sessions issued for a
3520
+ * principal without MFA are complete from the start.
3521
+ */
3522
+ mfaPassed: boolean;
3523
+ }
3524
+ /** Options for {@link AdminSessionStore}. */
3525
+ interface AdminSessionStoreOptions {
3526
+ /** HMAC key signing the cookie. At least 32 characters. */
3527
+ secret: string;
3528
+ /** Cookie name. Default `tempest_admin_session`. */
3529
+ cookieName?: string;
3530
+ /** Session lifetime in seconds. Default `28800` (8 hours). */
3531
+ maxAgeSeconds?: number;
3532
+ /** Send the cookie with `Secure` (HTTPS only). Default `true`. */
3533
+ cookieSecure?: boolean;
3534
+ /** Cookie `Path`. Default `/`. */
3535
+ cookiePath?: string;
3536
+ }
3537
+ /**
3538
+ * Issues, verifies and clears the admin session cookie.
3539
+ *
3540
+ * The cookie value is `<base64url payload>.<base64url signature>`; a payload
3541
+ * whose signature does not verify, or whose expiry has passed, resolves to
3542
+ * `null` — an operator with a tampered or stale cookie is simply logged out.
3543
+ */
3544
+ declare class AdminSessionStore {
3545
+ private readonly secret;
3546
+ private readonly cookieName;
3547
+ private readonly maxAgeSeconds;
3548
+ private readonly cookieSecure;
3549
+ private readonly cookiePath;
3550
+ /**
3551
+ * Build the store.
3552
+ *
3553
+ * @param options - Secret, cookie name, lifetime and cookie flags.
3554
+ * @throws Error When the secret is shorter than 32 characters.
3555
+ */
3556
+ constructor(options: AdminSessionStoreOptions);
3557
+ /**
3558
+ * Sign a payload.
3559
+ *
3560
+ * @param payload - The base64url payload to sign.
3561
+ * @returns The base64url signature.
3562
+ */
3563
+ private sign;
3564
+ /**
3565
+ * Mint a fresh session for an authenticated principal.
3566
+ *
3567
+ * @param subject - The principal id.
3568
+ * @param displayName - The name shown in the header.
3569
+ * @param mfaPassed - Whether the second factor is already satisfied.
3570
+ * @returns The new session payload (not yet written to a response).
3571
+ */
3572
+ issue(subject: string, displayName: string, mfaPassed?: boolean): AdminSession;
3573
+ /**
3574
+ * Read and verify the session carried by a request.
3575
+ *
3576
+ * @param req - The inbound request.
3577
+ * @returns The session, or `null` when absent, tampered with or expired.
3578
+ */
3579
+ load(req: Request): AdminSession | null;
3580
+ /**
3581
+ * Write a session to the response as a signed cookie.
3582
+ *
3583
+ * @param res - The outbound response.
3584
+ * @param session - The session to persist.
3585
+ */
3586
+ save(res: Response$1, session: AdminSession): void;
3587
+ /**
3588
+ * Drop the session cookie.
3589
+ *
3590
+ * @param res - The outbound response.
3591
+ */
3592
+ clear(res: Response$1): void;
3593
+ /**
3594
+ * Render a `Set-Cookie` value with the configured flags.
3595
+ *
3596
+ * @param value - The cookie value.
3597
+ * @param maxAge - Lifetime in seconds (`0` expires it immediately).
3598
+ * @returns The header value.
3599
+ */
3600
+ private cookie;
3601
+ }
3602
+ /**
3603
+ * Compare a submitted CSRF token against the session's, in constant time.
3604
+ *
3605
+ * @param session - The active session.
3606
+ * @param submitted - The `csrf_token` field from the form body.
3607
+ * @returns `true` when the tokens match.
3608
+ */
3609
+ declare function csrfTokenMatches(session: AdminSession, submitted: unknown): boolean;
3610
+
3611
+ /**
3612
+ * Custom admin actions — operator-defined bulk operations, mirroring
3613
+ * `admin.actions`.
3614
+ *
3615
+ * The panel ships three built-in bulk operations (activate / deactivate /
3616
+ * delete). Anything domain-specific — "send welcome email", "mark as shipped",
3617
+ * "recalculate totals" — is a *custom action*: a handler registered on an
3618
+ * {@link AdminModel} through `actions`, which shows up in the list view's
3619
+ * bulk-action dropdown and runs against the checked rows.
3620
+ *
3621
+ * ```ts
3622
+ * const sendWelcome = adminAction(
3623
+ * { label: "Send welcome email" },
3624
+ * async ({ ids, repository }) => {
3625
+ * const users = await repository.list({ id: { in: ids } });
3626
+ * for (const user of users) await mailer.sendWelcome(user.email);
3627
+ * return { message: `Sent ${users.length} welcome emails.` };
3628
+ * },
3629
+ * );
3630
+ *
3631
+ * site.register(new AdminModel({ model: UserModel, actions: [sendWelcome] }));
3632
+ * ```
3633
+ *
3634
+ * The Python SDK attaches this metadata with an `@admin_action` decorator.
3635
+ * Here {@link adminAction} returns the descriptor instead: the handler stays a
3636
+ * plain function you can call and unit-test directly (`action.handler(ctx)`),
3637
+ * and there is no decorator syntax to enable in a consumer's build.
3638
+ */
3639
+
3640
+ /** Banner style a custom action's message is flashed with. */
3641
+ type AdminActionCategory = "success" | "error" | "warning";
3642
+ /** Everything a custom action handler needs to do its work. */
3643
+ interface AdminActionContext<C extends ModelClass = ModelClass> {
3644
+ /** Identity values of the rows the operator checked. */
3645
+ ids: string[];
3646
+ /** Repository for this admin's model, bound to the request's DB session. */
3647
+ repository: BaseRepository<C>;
3648
+ /** The request's DB session, for work beyond the repository. */
3649
+ dbSession: AsyncSession;
3650
+ /** The inbound request. */
3651
+ request: Request;
3652
+ /** The authenticated admin session. */
3653
+ session: AdminSession;
3654
+ /** The resolved admin principal that triggered the action. */
3655
+ principal: unknown;
3656
+ }
3657
+ /** The outcome of a custom action, flashed on the list view. */
3658
+ interface AdminActionResult {
3659
+ /** Human-readable result shown to the operator. */
3660
+ message: string;
3661
+ /** Banner style. Default `"success"`. */
3662
+ category?: AdminActionCategory;
3663
+ }
3664
+ /** The function a custom action runs. Return `null` to flash nothing. */
3665
+ type AdminActionHandler<C extends ModelClass = ModelClass> = (context: AdminActionContext<C>) => Promise<AdminActionResult | null>;
3666
+ /** A registered custom action: metadata plus handler. */
3667
+ interface AdminAction<C extends ModelClass = ModelClass> {
3668
+ /** Stable identifier (the submitted form value); unique per model. */
3669
+ name: string;
3670
+ /** Text shown in the bulk-action dropdown. */
3671
+ label: string;
3672
+ /** The handler to run against the checked rows. */
3673
+ handler: AdminActionHandler<C>;
3674
+ /** Whether the UI marks this as destructive (a stronger confirm prompt). */
3675
+ dangerous: boolean;
3676
+ }
3677
+ /** Metadata accepted by {@link adminAction}. */
3678
+ interface AdminActionOptions {
3679
+ /** Dropdown label shown to the operator. */
3680
+ label: string;
3681
+ /** Stable identifier (the submitted form value). Defaults to a slug of `label`. */
3682
+ name?: string;
3683
+ /** Flag a destructive action, for a stronger confirm prompt. */
3684
+ dangerous?: boolean;
3685
+ }
3686
+ /**
3687
+ * Describe a custom bulk action.
3688
+ *
3689
+ * @param options - Label, optional stable name and the destructive flag.
3690
+ * @param handler - The async function run against the checked rows.
3691
+ * @returns The action descriptor to pass to `AdminModel({ actions: [...] })`.
3692
+ * @throws Error When the resolved name is empty.
3693
+ */
3694
+ declare function adminAction<C extends ModelClass = ModelClass>(options: AdminActionOptions, handler: AdminActionHandler<C>): AdminAction<C>;
3695
+ /** A bulk-action option rendered in the list view's dropdown. */
3696
+ interface BulkActionOption {
3697
+ /** Submitted form value. Custom actions are namespaced `custom:<name>`. */
3698
+ value: string;
3699
+ /** Dropdown label. */
3700
+ label: string;
3701
+ /** Whether the action is destructive. */
3702
+ dangerous: boolean;
3703
+ }
3704
+
3705
+ /**
3706
+ * Column introspection for the admin panel, mirroring `admin.forms`' widget
3707
+ * derivation.
3708
+ *
3709
+ * `tempest-db-js` keeps rich runtime metadata on every column — the canonical
3710
+ * type kind, enum members, `varchar` length, the not-null/default/primary-key
3711
+ * flags and the foreign-key reference — so the admin derives its form widgets
3712
+ * and list filters from the model itself instead of asking the project to
3713
+ * restate them. Kept separate from the router so the (fiddly) type handling is
3714
+ * unit-testable in isolation.
3715
+ */
3716
+
3717
+ /** The set of form controls the admin knows how to render. */
3718
+ type AdminWidget = "text" | "textarea" | "number" | "checkbox" | "datetime" | "date" | "time" | "select" | "json";
3719
+ /** A `(value, label)` pair for a `select` widget. */
3720
+ interface AdminSelectOption {
3721
+ value: string;
3722
+ label: string;
3723
+ }
3724
+ /** The widget a column maps to, plus the attributes that render it. */
3725
+ interface WidgetSpec {
3726
+ /** The control to render. */
3727
+ widget: AdminWidget;
3728
+ /** `step` attribute for `number` widgets, or `null`. */
3729
+ step: string | null;
3730
+ /** Options for `select` widgets (empty otherwise). */
3731
+ options: AdminSelectOption[];
3732
+ }
3733
+ /** How a column is surfaced in the list view's filter bar. */
3734
+ type AdminFilterKind = "select" | "daterange" | "text";
3735
+ /**
3736
+ * Humanize a column key into a form label (`lastLoginAt` → `Last Login At`).
3737
+ *
3738
+ * @param name - The column key.
3739
+ * @returns A title-cased label.
3740
+ */
3741
+ declare function humanizeField(name: string): string;
3742
+ /**
3743
+ * Return every column of a model, keyed by field name in declaration order.
3744
+ *
3745
+ * @param model - The model class.
3746
+ * @returns The column map (do not mutate).
3747
+ */
3748
+ declare function adminColumns(model: ModelClass): Record<string, Column<unknown>>;
3749
+ /**
3750
+ * Map a column to the widget that edits it.
3751
+ *
3752
+ * `json` is matched before anything else because a JSON column carries no
3753
+ * useful scalar type, and `enum` is matched before the string kinds so its
3754
+ * members become a dropdown rather than a free-text input.
3755
+ *
3756
+ * @param column - The column to inspect.
3757
+ * @returns The widget, its `number` step (or `null`) and its `select` options.
3758
+ */
3759
+ declare function widgetForColumn(column: Column<unknown>): WidgetSpec;
3760
+ /**
3761
+ * Whether a column may be left blank on submit — it is nullable, carries a
3762
+ * default, or is the primary key the database fills in.
3763
+ *
3764
+ * @param column - The column to inspect.
3765
+ * @returns `true` when the field is optional.
3766
+ */
3767
+ declare function isColumnOptional(column: Column<unknown>): boolean;
3768
+ /**
3769
+ * Map a column to the filter control the list view shows for it.
3770
+ *
3771
+ * Booleans and enums become dropdowns, date-like columns become a from/to pair
3772
+ * of date inputs, and anything else falls back to an equality text input.
3773
+ *
3774
+ * @param column - The column to inspect.
3775
+ * @returns The filter kind and, for `select`, its options.
3776
+ */
3777
+ declare function filterForColumn(column: Column<unknown>): {
3778
+ kind: AdminFilterKind;
3779
+ options: AdminSelectOption[];
3780
+ };
3781
+ /**
3782
+ * Return the table a column points at, when it carries a foreign key.
3783
+ *
3784
+ * @param column - The column to inspect.
3785
+ * @returns The referenced table name, or `null` for a plain column.
3786
+ */
3787
+ declare function foreignKeyTable(column: Column<unknown>): string | null;
3788
+ /**
3789
+ * Whether a column holds free text a `LIKE '%…%'` search can match.
3790
+ *
3791
+ * @param column - The column to inspect.
3792
+ * @returns `true` for `varchar` / `text` / `char` columns.
3793
+ */
3794
+ declare function isSearchableColumn(column: Column<unknown>): boolean;
3795
+
3796
+ /**
3797
+ * Declarative admin configuration for one model, mirroring `admin.config`.
3798
+ *
3799
+ * Instantiate one {@link AdminModel} per managed model and hand it to
3800
+ * {@link AdminSite.register}. Unlike Django's class-based `ModelAdmin` this is
3801
+ * a plain typed instance — the constructor options are the contract, there is
3802
+ * no metaclass magic, and every default is derived from the model's own column
3803
+ * metadata so an unconfigured model is already browsable.
3804
+ */
3805
+
3806
+ /** Configuration accepted by {@link AdminModel}. */
3807
+ interface AdminModelOptions<C extends ModelClass> {
3808
+ /** The model class to manage. */
3809
+ model: C;
3810
+ /** URL slug. Defaults to the model's `tablename`, so URLs track tables. */
3811
+ slug?: string;
3812
+ /** Columns shown in the list view. Defaults to every column but the password hash. */
3813
+ listDisplay?: readonly string[];
3814
+ /** Columns surfaced as filter controls above the list. */
3815
+ listFilter?: readonly string[];
3816
+ /** Text columns searched with `LIKE '%value%'` by the search box. */
3817
+ searchFields?: readonly string[];
3818
+ /** Columns shown but never editable in the create/edit form. */
3819
+ readonlyFields?: readonly string[];
3820
+ /** Default ordering: a column key, or `-column` for descending. */
3821
+ ordering?: string;
3822
+ /** Rows per page in the list view. Default `25`. */
3823
+ pageSize?: number;
3824
+ /** Column used to look one row up from the detail URL. Default `"id"`. */
3825
+ identityField?: string;
3826
+ /** Singular display name. Defaults to the humanized class name. */
3827
+ verboseName?: string;
3828
+ /** Plural display name. Defaults to `verboseName` + `"s"`. */
3829
+ verboseNamePlural?: string;
3830
+ /** Whether the create form + POST endpoint are exposed. Default `true`. */
3831
+ canCreate?: boolean;
3832
+ /** Whether the edit form + POST endpoint are exposed. Default `true`. */
3833
+ canEdit?: boolean;
3834
+ /** Whether the delete action is exposed. Default `true`. */
3835
+ canDelete?: boolean;
3836
+ /**
3837
+ * Custom bulk actions, built with `adminAction`. Each one joins the list
3838
+ * view's action dropdown alongside the built-in activate / deactivate /
3839
+ * delete and runs against the checked rows.
3840
+ */
3841
+ actions?: readonly AdminAction<C>[];
3842
+ }
3843
+ /**
3844
+ * The admin configuration for one model.
3845
+ *
3846
+ * ```ts
3847
+ * new AdminModel({
3848
+ * model: UserModel,
3849
+ * listDisplay: ["email", "isAdmin", "isActive", "createdAt"],
3850
+ * listFilter: ["isActive", "isAdmin"],
3851
+ * searchFields: ["email"],
3852
+ * ordering: "-createdAt",
3853
+ * });
3854
+ * ```
3855
+ */
3856
+ declare class AdminModel<C extends ModelClass = ModelClass> {
3857
+ /** The managed model class. */
3858
+ readonly model: C;
3859
+ /** Columns surfaced as filter controls. */
3860
+ readonly listFilter: string[];
3861
+ /** Text columns the search box matches against. */
3862
+ readonly searchFields: string[];
3863
+ /** Columns locked in the create/edit form. */
3864
+ readonlyFields: string[];
3865
+ /** Default ordering column, or `null` to leave it to the repository. */
3866
+ readonly orderKey: string | null;
3867
+ /** Whether {@link AdminModel.orderKey} sorts ascending. */
3868
+ readonly orderAscending: boolean;
3869
+ /** Rows per page in the list view. */
3870
+ readonly pageSize: number;
3871
+ /** Column used to look a single row up from the detail URL. */
3872
+ readonly identityField: string;
3873
+ /** Whether the create form is exposed. */
3874
+ readonly canCreate: boolean;
3875
+ /** Whether the edit form is exposed. */
3876
+ readonly canEdit: boolean;
3877
+ /** Whether the delete action is exposed. */
3878
+ readonly canDelete: boolean;
3879
+ private readonly actions;
3880
+ private readonly slugOverride;
3881
+ private readonly listDisplayOverride;
3882
+ private readonly verboseNameOverride;
3883
+ private readonly verboseNamePluralOverride;
3884
+ /**
3885
+ * Build and validate the configuration.
3886
+ *
3887
+ * @param options - The declarative configuration. See {@link AdminModelOptions}.
3888
+ * @throws Error When a referenced column does not exist on the model.
3889
+ */
3890
+ constructor(options: AdminModelOptions<C>);
3891
+ /**
3892
+ * Return the URL slug the model is exposed under.
3893
+ *
3894
+ * @returns The configured slug, or the model's table name.
3895
+ */
3896
+ slug(): string;
3897
+ /**
3898
+ * Return the singular display name.
3899
+ *
3900
+ * @returns The configured name, or the humanized class name without its
3901
+ * trailing `Model`.
3902
+ */
3903
+ verboseName(): string;
3904
+ /**
3905
+ * Return the plural display name.
3906
+ *
3907
+ * @returns The configured plural, or the singular with an `s`.
3908
+ */
3909
+ verboseNamePlural(): string;
3910
+ /**
3911
+ * Return every column key on the model, in declaration order.
3912
+ *
3913
+ * @returns The column keys.
3914
+ */
3915
+ columnNames(): string[];
3916
+ /**
3917
+ * Return the columns the list view renders.
3918
+ *
3919
+ * @returns The configured `listDisplay`, or every column but the password hash.
3920
+ */
3921
+ listDisplayNames(): string[];
3922
+ /**
3923
+ * Return the columns the detail view renders.
3924
+ *
3925
+ * Unlike {@link AdminModel.listDisplayNames}, this is not narrowed by
3926
+ * `listDisplay`: the list view is a scannable summary, but the detail view is
3927
+ * where an operator goes to see the whole record, so trimming it there would
3928
+ * hide data with nowhere else to read it.
3929
+ *
3930
+ * @returns Every column but the password hash, in declaration order.
3931
+ */
3932
+ detailFieldNames(): string[];
3933
+ /**
3934
+ * Return the columns a create/edit form exposes.
3935
+ *
3936
+ * Excludes the primary key, the managed timestamps, the password hash and
3937
+ * anything listed in `readonlyFields` — none of which a user edits directly
3938
+ * through the generic form.
3939
+ *
3940
+ * @returns The editable column keys, in declaration order.
3941
+ */
3942
+ editableFieldNames(): string[];
3943
+ /**
3944
+ * Return the registered custom actions, in declaration order.
3945
+ *
3946
+ * @returns The actions passed via `actions` (empty when none). The model
3947
+ * type is erased here, the way {@link AdminSite} erases it when it stores a
3948
+ * configuration — a registry keyed by slug cannot stay generic.
3949
+ */
3950
+ customActions(): AdminAction[];
3951
+ /**
3952
+ * Look a custom action up by name.
3953
+ *
3954
+ * @param name - The action identifier (its submitted form value).
3955
+ * @returns The action, or `null` when nothing matches.
3956
+ */
3957
+ getAction(name: string): AdminAction | null;
3958
+ /**
3959
+ * Build a repository for this model bound to a session.
3960
+ *
3961
+ * @param session - The session the repository runs its statements on.
3962
+ * @returns A repository over {@link AdminModel.model}.
3963
+ */
3964
+ repository(session: AsyncSession): BaseRepository<C>;
3965
+ }
3966
+ /** The row type a configured {@link AdminModel} reads and writes. */
3967
+ type AdminRow<A> = A extends AdminModel<infer C> ? InferModel<C> : never;
3968
+
3969
+ /**
3970
+ * Form building and submission parsing for the admin CRUD views, mirroring
3971
+ * `admin.forms`.
3972
+ *
3973
+ * One direction turns a model's columns into typed widget descriptors the
3974
+ * templates render; the other reads a posted `application/x-www-form-urlencoded`
3975
+ * body back into coerced values ready for the repository. Both live here, away
3976
+ * from the router, so the fiddly per-type handling is unit-testable on its own.
3977
+ */
3978
+
3979
+ /** A single rendered form control. */
3980
+ interface AdminFormField {
3981
+ /** Column key, used as the form field name. */
3982
+ name: string;
3983
+ /** Human-readable label. */
3984
+ label: string;
3985
+ /** The control to render. */
3986
+ widget: AdminWidget;
3987
+ /** Pre-filled value, already stringified for the control. */
3988
+ value: string;
3989
+ /** Whether the field must be filled in. */
3990
+ required: boolean;
3991
+ /** Checkbox state (`checkbox` widget only). */
3992
+ checked: boolean;
3993
+ /** `step` attribute for `number` widgets. */
3994
+ step: string | null;
3995
+ /** `(value, label)` pairs for `select` widgets. */
3996
+ options: AdminSelectOption[];
3997
+ /** Per-field validation error, or `null`. */
3998
+ error: string | null;
3999
+ }
4000
+ /** The outcome of parsing a submitted create/edit form. */
4001
+ interface ParsedAdminForm {
4002
+ /** Coerced column values, ready to hand to the repository. */
4003
+ data: Record<string, unknown>;
4004
+ /** Per-field error messages, keyed by column. Empty when the form is valid. */
4005
+ errors: Record<string, string>;
4006
+ }
4007
+ /** Options for {@link buildFormFields}. */
4008
+ interface BuildFormFieldsOptions {
4009
+ /** Current values, keyed by column — a row on edit, a re-submission on error. */
4010
+ values?: Record<string, unknown>;
4011
+ /** Per-field errors to surface, keyed by column. */
4012
+ errors?: Record<string, string>;
4013
+ /**
4014
+ * Options for foreign-key columns whose target model is registered, keyed by
4015
+ * column. A field listed here renders as a `<select>` of related rows instead
4016
+ * of a raw identity text input.
4017
+ */
4018
+ foreignKeyOptions?: Record<string, AdminSelectOption[]>;
4019
+ }
4020
+ /**
4021
+ * Render a stored value into the string a control pre-fills with.
4022
+ *
4023
+ * @param widget - The control the value is rendered for.
4024
+ * @param value - The stored value.
4025
+ * @returns The control's `value` text (empty for `null`/`undefined`).
4026
+ */
4027
+ declare function formatFieldValue(widget: AdminWidget, value: unknown): string;
4028
+ /**
4029
+ * Build the controls a create/edit form renders.
4030
+ *
4031
+ * A field with no current value falls back to its column's literal default, so
4032
+ * a blank create form arrives pre-filled the way the database would fill it.
4033
+ * Without that, submitting the form untouched would write `false` over a
4034
+ * `default(true)` flag — the panel would silently deactivate every row it
4035
+ * creates.
4036
+ *
4037
+ * @param admin - The model configuration.
4038
+ * @param options - Current values and per-field errors.
4039
+ * @returns One {@link AdminFormField} per editable column, in declaration order.
4040
+ */
4041
+ declare function buildFormFields(admin: AdminModel, options?: BuildFormFieldsOptions): AdminFormField[];
4042
+ /**
4043
+ * Read a submitted create/edit form back into coerced column values.
4044
+ *
4045
+ * A checkbox that is absent from the body is `false` (that is how browsers
4046
+ * submit an unchecked box), and an empty text field on an optional column
4047
+ * becomes `null` rather than an empty string, so a cleared field really clears
4048
+ * the column.
4049
+ *
4050
+ * @param admin - The model configuration.
4051
+ * @param body - The parsed request body.
4052
+ * @returns The coerced values plus any per-field errors.
4053
+ */
4054
+ declare function parseFormBody(admin: AdminModel, body: Record<string, unknown>): ParsedAdminForm;
4055
+ /**
4056
+ * Render a stored value for a read-only list or detail cell.
4057
+ *
4058
+ * @param value - The stored value.
4059
+ * @returns A display string (empty for `null`/`undefined`).
4060
+ */
4061
+ declare function formatCellValue(value: unknown): string;
4062
+ /**
4063
+ * Return the editable foreign-key columns of an admin, as `field → table`.
4064
+ *
4065
+ * @param admin - The model configuration.
4066
+ * @returns One entry per editable column that references another table.
4067
+ */
4068
+ declare function foreignKeyFields(admin: AdminModel): Record<string, string>;
4069
+ /**
4070
+ * Build a human label for a referenced row — the analog of Django's `__str__`.
4071
+ *
4072
+ * Prefers the referenced admin's first search field, then a conventional
4073
+ * display attribute, then the row's identity, so a dropdown of related rows
4074
+ * reads as names rather than as a column of UUIDs.
4075
+ *
4076
+ * @param admin - The **referenced** model's configuration.
4077
+ * @param row - The referenced row.
4078
+ * @returns A label for the option.
4079
+ */
4080
+ declare function foreignKeyLabel(admin: AdminModel, row: Record<string, unknown>): string;
4081
+
4082
+ /**
4083
+ * Authentication backends for the admin panel, mirroring `admin.auth`.
4084
+ *
4085
+ * Operators sign in with a row from the project's own database — there is no
4086
+ * separate admin password store. {@link UserModelAuthBackend} covers the
4087
+ * conventional case (a {@link BaseUserModel} subclass gated on `isActive` and
4088
+ * `isAdmin`); anything else — LDAP, an upstream identity provider, a service
4089
+ * account table — implements {@link AdminAuthBackend} directly.
4090
+ */
4091
+
4092
+ /** The columns {@link UserModelAuthBackend} reads off a principal row. */
4093
+ interface UserPrincipalRow {
4094
+ id: string;
4095
+ email: string;
4096
+ hashedPassword: string;
4097
+ isActive: boolean;
4098
+ isAdmin: boolean;
4099
+ }
4100
+ /** Verifies a TOTP code for a principal that enrolled a second factor. */
4101
+ interface AdminMfaVerifier {
4102
+ /** Whether the principal has a confirmed second factor. */
4103
+ isEnabled(userId: string): Promise<boolean>;
4104
+ /** Whether `code` is a valid current TOTP for the principal. */
4105
+ verify(userId: string, code: string): Promise<boolean>;
4106
+ }
4107
+ /**
4108
+ * How the panel turns a login form into a principal.
4109
+ *
4110
+ * The interface is generic in the principal so a custom backend can hand its
4111
+ * own row type back to {@link AdminAuthBackend.displayName} and friends.
4112
+ */
4113
+ interface AdminAuthBackend<Principal = unknown> {
4114
+ /**
4115
+ * Verify credentials.
4116
+ *
4117
+ * @param session - A DB session for the current request.
4118
+ * @param identifier - The submitted login identifier (typically an email).
4119
+ * @param password - The submitted plaintext password.
4120
+ * @returns The principal, or `null` when the credentials are rejected.
4121
+ */
4122
+ authenticate(session: AsyncSession, identifier: string, password: string): Promise<Principal | null>;
4123
+ /**
4124
+ * Re-load the principal a session points at, so a deactivated operator loses
4125
+ * access on the next request rather than at cookie expiry.
4126
+ *
4127
+ * @param session - A DB session for the current request.
4128
+ * @param subject - The principal id stored in the session.
4129
+ * @returns The principal, or `null` when it no longer qualifies.
4130
+ */
4131
+ loadPrincipal(session: AsyncSession, subject: string): Promise<Principal | null>;
4132
+ /**
4133
+ * Return the stable id stored in the session cookie.
4134
+ *
4135
+ * @param principal - The authenticated principal.
4136
+ * @returns The principal id.
4137
+ */
4138
+ principalId(principal: Principal): string;
4139
+ /**
4140
+ * Return the name shown in the panel header.
4141
+ *
4142
+ * @param principal - The authenticated principal.
4143
+ * @returns A human-readable label.
4144
+ */
4145
+ displayName(principal: Principal): string;
4146
+ /**
4147
+ * Whether this principal must clear a second factor before entering.
4148
+ *
4149
+ * Omit to declare the backend has no MFA — the panel then treats every
4150
+ * successful password check as a complete login.
4151
+ *
4152
+ * @param principal - The authenticated principal.
4153
+ * @returns `true` when a TOTP challenge is required.
4154
+ */
4155
+ mfaEnabled?(principal: Principal): Promise<boolean>;
4156
+ /**
4157
+ * Verify the submitted TOTP code.
4158
+ *
4159
+ * @param principal - The authenticated principal.
4160
+ * @param code - The submitted code.
4161
+ * @returns `true` when the code is valid.
4162
+ */
4163
+ verifyMfa?(principal: Principal, code: string): Promise<boolean>;
4164
+ }
4165
+ /** Options for {@link UserModelAuthBackend}. */
4166
+ interface UserModelAuthBackendOptions {
4167
+ /** Password hasher. Defaults to a stock {@link PasswordUtils}. */
4168
+ passwords?: PasswordUtils;
4169
+ /**
4170
+ * TOTP verifier. When given, a principal with a confirmed secret is sent
4171
+ * through the panel's `/mfa` challenge after the password check, so the
4172
+ * admin panel can never be the weaker door into an MFA-protected account.
4173
+ */
4174
+ mfa?: AdminMfaVerifier;
4175
+ /** Column holding the login identifier. Default `"email"`. */
4176
+ identifierField?: string;
4177
+ /**
4178
+ * Require `isAdmin === true` on the row. Default `true`. Turn it off only
4179
+ * when the model expresses privilege some other way and the panel is already
4180
+ * gated elsewhere.
4181
+ */
4182
+ requireAdmin?: boolean;
4183
+ }
4184
+ /**
4185
+ * The conventional backend: authenticate against a {@link BaseUserModel}
4186
+ * subclass, admitting only rows that are both active and flagged as admins.
4187
+ *
4188
+ * ```ts
4189
+ * new UserModelAuthBackend(UserModel);
4190
+ * ```
4191
+ */
4192
+ declare class UserModelAuthBackend implements AdminAuthBackend<UserPrincipalRow> {
4193
+ private readonly model;
4194
+ private readonly passwords;
4195
+ private readonly mfa;
4196
+ private readonly identifierField;
4197
+ private readonly requireAdmin;
4198
+ /**
4199
+ * Build the backend.
4200
+ *
4201
+ * @param model - The user model class (a `BaseUserModel` subclass).
4202
+ * @param options - Hasher, MFA verifier and gating overrides.
4203
+ */
4204
+ constructor(model: ModelClass, options?: UserModelAuthBackendOptions);
4205
+ /**
4206
+ * Whether a row is allowed into the panel at all.
4207
+ *
4208
+ * @param row - The candidate row.
4209
+ * @returns `true` when the row is active and (when required) an admin.
4210
+ */
4211
+ private admits;
4212
+ /**
4213
+ * Verify an identifier/password pair.
4214
+ *
4215
+ * The identifier is lowercased and trimmed before lookup, matching the
4216
+ * normalization the auth service applies on signup.
4217
+ *
4218
+ * @param session - A DB session for the current request.
4219
+ * @param identifier - The submitted identifier.
4220
+ * @param password - The submitted plaintext password.
4221
+ * @returns The matching row, or `null` when it does not qualify.
4222
+ */
4223
+ authenticate(session: AsyncSession, identifier: string, password: string): Promise<UserPrincipalRow | null>;
4224
+ /**
4225
+ * Re-load the principal a session points at.
4226
+ *
4227
+ * @param session - A DB session for the current request.
4228
+ * @param subject - The principal id from the session cookie.
4229
+ * @returns The row, or `null` when it vanished or lost its privileges.
4230
+ */
4231
+ loadPrincipal(session: AsyncSession, subject: string): Promise<UserPrincipalRow | null>;
4232
+ /**
4233
+ * Return the row's primary key.
4234
+ *
4235
+ * @param principal - The authenticated row.
4236
+ * @returns The principal id.
4237
+ */
4238
+ principalId(principal: UserPrincipalRow): string;
4239
+ /**
4240
+ * Return the label shown in the panel header.
4241
+ *
4242
+ * @param principal - The authenticated row.
4243
+ * @returns The identifier column's value.
4244
+ */
4245
+ displayName(principal: UserPrincipalRow): string;
4246
+ /**
4247
+ * Whether the principal enrolled a second factor.
4248
+ *
4249
+ * @param principal - The authenticated row.
4250
+ * @returns `true` when an MFA verifier is configured and reports a secret.
4251
+ */
4252
+ mfaEnabled(principal: UserPrincipalRow): Promise<boolean>;
4253
+ /**
4254
+ * Verify a submitted TOTP code.
4255
+ *
4256
+ * @param principal - The authenticated row.
4257
+ * @param code - The submitted code.
4258
+ * @returns `true` when the code is valid.
4259
+ */
4260
+ verifyMfa(principal: UserPrincipalRow, code: string): Promise<boolean>;
4261
+ }
4262
+
4263
+ /**
4264
+ * Typed theming for the server-rendered admin panel, mirroring `admin.theme`.
4265
+ *
4266
+ * The bundled stylesheet is driven entirely by CSS custom properties declared
4267
+ * on `:root`. An {@link AdminTheme} overrides those properties — plus the logo,
4268
+ * favicon, font and footer — through typed, documented fields instead of
4269
+ * forking the stylesheet. The values are injected as a `<style>` block after
4270
+ * the stylesheet (so they win), which means there is no CSS file to maintain on
4271
+ * the project side and every knob is discoverable in the editor.
4272
+ *
4273
+ * For anything the fields do not cover, point `customCssUrl` at your own
4274
+ * stylesheet — it is linked last, so it overrides everything, including this.
4275
+ */
4276
+ /**
4277
+ * Appearance overrides for the admin panel. Every field is optional and
4278
+ * defaults to the stock look, so `{}` is a no-op.
4279
+ */
4280
+ interface AdminTheme {
4281
+ /** Primary accent — links, primary buttons, active sidebar item. Default `#2563eb`. */
4282
+ accent?: string;
4283
+ /** Hover/active shade of {@link AdminTheme.accent}. Default `#1d4ed8`. */
4284
+ accentHover?: string;
4285
+ /** Color for destructive actions and error messages. Default `#b91c1c`. */
4286
+ danger?: string;
4287
+ /** Background of the top header band. Default `#0f172a`. */
4288
+ headerBg?: string;
4289
+ /** Background of the left sidebar. Falls back to `headerBg` so the chrome reads as one surface. */
4290
+ sidebarBg?: string;
4291
+ /** Main content background. Omitted uses the mode default (light grey, or near-black in dark mode). */
4292
+ pageBg?: string;
4293
+ /** Border radius for buttons, inputs, cards and tables. Default `6px`. */
4294
+ radius?: string;
4295
+ /** CSS `font-family` for the whole panel. Omitted keeps the system stack. */
4296
+ fontFamily?: string;
4297
+ /** URL of an image shown in the header instead of the brand text. */
4298
+ logoUrl?: string;
4299
+ /** `alt` text for the logo image. Default `Logo`. */
4300
+ logoAlt?: string;
4301
+ /** URL of the browser-tab favicon. */
4302
+ faviconUrl?: string;
4303
+ /** Text shown in the page footer. Default `Powered by tempest-express-sdk`. */
4304
+ footerText?: string;
4305
+ /** Switch the content surfaces to a dark palette (the chrome is already dark). */
4306
+ darkMode?: boolean;
4307
+ /** URL of an extra stylesheet linked **after** the theme, so it overrides everything. */
4308
+ customCssUrl?: string;
4309
+ }
4310
+ /** An {@link AdminTheme} with every default filled in. */
4311
+ interface ResolvedAdminTheme {
4312
+ accent: string;
4313
+ accentHover: string;
4314
+ danger: string;
4315
+ headerBg: string;
4316
+ sidebarBg: string;
4317
+ pageBg: string | null;
4318
+ radius: string;
4319
+ fontFamily: string | null;
4320
+ logoUrl: string | null;
4321
+ logoAlt: string;
4322
+ faviconUrl: string | null;
4323
+ footerText: string;
4324
+ darkMode: boolean;
4325
+ customCssUrl: string | null;
4326
+ }
4327
+ /**
4328
+ * Fill a theme with its defaults, validating every string field.
4329
+ *
4330
+ * @param theme - The partial theme (or nothing, for the stock look).
4331
+ * @returns The theme with every field resolved.
4332
+ * @throws Error When a string field contains a character that would break the markup.
4333
+ */
4334
+ declare function resolveAdminTheme(theme?: AdminTheme): ResolvedAdminTheme;
4335
+ /**
4336
+ * Render the `<style>` body for a resolved theme.
4337
+ *
4338
+ * Dark mode only overrides the content-area surfaces — the header and sidebar
4339
+ * are already dark via `--tempest-bg` — and is skipped entirely when the
4340
+ * project pinned its own `pageBg`, since an explicit value always wins.
4341
+ *
4342
+ * @param theme - The resolved theme.
4343
+ * @returns CSS text, ready to inject verbatim inside a `<style>` element.
4344
+ */
4345
+ declare function adminThemeCss(theme: ResolvedAdminTheme): string;
4346
+
4347
+ /**
4348
+ * Admin site registry, mirroring `admin.site` — the analog of Django's
4349
+ * `AdminSite`.
4350
+ *
4351
+ * A project instantiates one site, registers its {@link AdminModel}
4352
+ * configurations (one at a time with {@link AdminSite.register}, or all at
4353
+ * once with {@link AdminSite.automap}), and hands the site to
4354
+ * `makeAdminRouter`.
4355
+ */
4356
+
4357
+ /** Branding and appearance options for an {@link AdminSite}. */
4358
+ interface AdminSiteOptions {
4359
+ /** Text used in the page `<title>` and the dashboard heading. Default `"Admin"`. */
4360
+ title?: string;
4361
+ /** Centered header brand. Falls back to `title`. */
4362
+ brand?: string;
4363
+ /** Dashboard subtitle. Default `"Site administration"`. */
4364
+ indexSubtitle?: string;
4365
+ /** Optional outbound "View site" link rendered in the header. */
4366
+ siteUrl?: string;
4367
+ /** Typed appearance overrides. Omitted keeps the stock look. */
4368
+ theme?: AdminTheme;
4369
+ }
4370
+ /** Options accepted by {@link AdminSite.automap}. */
4371
+ interface AdminAutomapOptions extends Omit<AdminModelOptions<ModelClass>, "model"> {
4372
+ /** Models to skip — each entry is the model class or its table name. */
4373
+ exclude?: readonly (ModelClass | string)[];
4374
+ /**
4375
+ * When `true` (default), a model whose slug is already registered is left
4376
+ * untouched, so a hand-tuned {@link AdminModel} can be registered first.
4377
+ * When `false`, a collision throws, as {@link AdminSite.register} does.
4378
+ */
4379
+ skipRegistered?: boolean;
4380
+ }
4381
+ /**
4382
+ * The registry of {@link AdminModel} configurations a panel exposes.
4383
+ *
4384
+ * ```ts
4385
+ * const site = new AdminSite({ title: "MyApp Admin", brand: "myapp-admin" });
4386
+ * site.register({ model: UserModel, searchFields: ["email"] });
4387
+ * site.automap(models);
4388
+ * ```
4389
+ */
4390
+ declare class AdminSite {
4391
+ /** Text used in the page `<title>` and the dashboard heading. */
4392
+ readonly title: string;
4393
+ /** Centered header brand, or `null` to fall back to {@link AdminSite.title}. */
4394
+ readonly brand: string | null;
4395
+ /** Dashboard subtitle. */
4396
+ readonly indexSubtitle: string;
4397
+ /** Outbound "View site" link, or `null`. */
4398
+ readonly siteUrl: string | null;
4399
+ /** Typed appearance overrides. */
4400
+ readonly theme: AdminTheme;
4401
+ private readonly registry;
4402
+ /**
4403
+ * Initialize the site.
4404
+ *
4405
+ * @param options - Branding and appearance. See {@link AdminSiteOptions}.
4406
+ */
4407
+ constructor(options?: AdminSiteOptions);
4408
+ /**
4409
+ * Return the centered header brand text.
4410
+ *
4411
+ * @returns {@link AdminSite.brand} when set, otherwise {@link AdminSite.title}.
4412
+ */
4413
+ brandText(): string;
4414
+ /**
4415
+ * Register a model configuration under its slug.
4416
+ *
4417
+ * @param admin - An {@link AdminModel} instance, or the options to build one.
4418
+ * @returns The registered instance, so the call can be chained or assigned.
4419
+ * @throws Error When another configuration already holds the same slug.
4420
+ */
4421
+ register<C extends ModelClass>(admin: AdminModel<C> | AdminModelOptions<C>): AdminModel<C>;
4422
+ /**
4423
+ * Remove a previously registered configuration.
4424
+ *
4425
+ * @param slug - The slug to drop.
4426
+ * @throws Error When no configuration is registered under the slug.
4427
+ */
4428
+ unregister(slug: string): void;
4429
+ /**
4430
+ * Look a configuration up by slug.
4431
+ *
4432
+ * @param slug - The admin slug.
4433
+ * @returns The configuration, or `null` when nothing matches.
4434
+ */
4435
+ get(slug: string): AdminModel | null;
4436
+ /**
4437
+ * Return every registered configuration, ordered by display name.
4438
+ *
4439
+ * @returns The configurations (empty when nothing is registered).
4440
+ */
4441
+ list(): AdminModel[];
4442
+ /**
4443
+ * Register every concrete model found in `source` at once.
4444
+ *
4445
+ * The batch counterpart to {@link AdminSite.register}: instead of one call
4446
+ * per table, hand it the models barrel and every model class declaring a
4447
+ * `tablename` is wrapped in a default {@link AdminModel}.
4448
+ *
4449
+ * ```ts
4450
+ * import * as models from "./db/models";
4451
+ *
4452
+ * site.automap(models);
4453
+ * site.automap([UserModel, OrderModel], { pageSize: 50 });
4454
+ * ```
4455
+ *
4456
+ * @param source - An array of model classes, or a module namespace object
4457
+ * whose values are swept (non-model entries are ignored).
4458
+ * @param options - `exclude`, `skipRegistered` and any {@link AdminModel}
4459
+ * option applied uniformly to every model discovered here.
4460
+ * @returns The configurations newly registered by this call.
4461
+ * @throws Error When `skipRegistered` is `false` and a slug collides.
4462
+ */
4463
+ automap(source: readonly unknown[] | Record<string, unknown>, options?: AdminAutomapOptions): AdminModel[];
4464
+ }
4465
+
4466
+ /**
4467
+ * The bundled admin stylesheet, served at `{prefix}/static/admin.css`.
4468
+ *
4469
+ * Ported verbatim from tempest-fastapi-sdk's `admin/static/admin.css` so both
4470
+ * SDKs render the same panel. Everything is driven by the `--tempest-*` custom
4471
+ * properties an `AdminTheme` overrides, so a project restyles the panel without
4472
+ * touching this file — see `@/admin/theme`.
4473
+ *
4474
+ * It ships as a string rather than an asset because the package publishes only
4475
+ * `dist`: a `.css` file on disk would not survive the build.
4476
+ */
4477
+ /** The stylesheet text. */
4478
+ declare const ADMIN_CSS: string;
4479
+
4480
+ /**
4481
+ * HTML rendering for the admin panel — the analog of the FastAPI SDK's jinja
4482
+ * templates, written as plain typed functions.
4483
+ *
4484
+ * There is no template engine and no external asset: every page is a string
4485
+ * built from a view model the router prepares, and the only stylesheet is the
4486
+ * one this package serves. That keeps the panel dependency-free (a template
4487
+ * engine would be a runtime dependency every consumer inherits) and keeps the
4488
+ * markup type-checked against the data that fills it.
4489
+ *
4490
+ * Every value interpolated into markup goes through {@link escapeHtml}.
4491
+ */
4492
+
4493
+ /**
4494
+ * Escape a value for safe interpolation into HTML text or an attribute.
4495
+ *
4496
+ * @param value - The value to escape.
4497
+ * @returns The escaped text.
4498
+ */
4499
+ declare function escapeHtml(value: unknown): string;
4500
+ /** One entry in the sidebar's model list. */
4501
+ interface AdminNavEntry {
4502
+ /** Display label. */
4503
+ label: string;
4504
+ /** Absolute URL of the model's list view. */
4505
+ url: string;
4506
+ }
4507
+ /** A banner shown above the page content. */
4508
+ interface AdminMessage {
4509
+ /** Message text. */
4510
+ text: string;
4511
+ /** Severity, driving the banner color: `success`, `error` or `warning`. */
4512
+ level: "success" | "error" | "warning";
4513
+ }
4514
+ /** Everything the chrome needs, shared by every page. */
4515
+ interface AdminRenderContext {
4516
+ /** The registered site (branding + models). */
4517
+ site: AdminSite;
4518
+ /** The site's theme, with defaults resolved. */
4519
+ theme: ResolvedAdminTheme;
4520
+ /** The router's mount prefix, without a trailing slash. */
4521
+ prefix: string;
4522
+ /** The active session, or `null` on the login and MFA pages. */
4523
+ session: AdminSession | null;
4524
+ /** The current request path, used to highlight the active sidebar item. */
4525
+ currentPath: string;
4526
+ /** Sidebar entries, one per registered model. */
4527
+ navModels: AdminNavEntry[];
4528
+ /** Banners rendered above the content. */
4529
+ messages: AdminMessage[];
4530
+ }
4531
+ /**
4532
+ * Wrap page content in the panel chrome: header, sidebar, footer and theme.
4533
+ *
4534
+ * The sidebar is off-canvas below 768px, opened by a checkbox the burger label
4535
+ * toggles — pure CSS, so the panel needs no JavaScript to be navigable.
4536
+ *
4537
+ * @param context - The shared chrome data.
4538
+ * @param title - The page `<title>`.
4539
+ * @param body - The already-escaped content markup.
4540
+ * @returns A complete HTML document.
4541
+ */
4542
+ declare function renderLayout(context: AdminRenderContext, title: string, body: string): string;
4543
+ /**
4544
+ * Render the sign-in page.
4545
+ *
4546
+ * @param context - The shared chrome data (with no session).
4547
+ * @param error - An error to show above the form, or `null`.
4548
+ * @returns The full page.
4549
+ */
4550
+ declare function renderLoginPage(context: AdminRenderContext, error: string | null): string;
4551
+ /**
4552
+ * Render the TOTP challenge shown between the password check and the panel.
4553
+ *
4554
+ * @param context - The shared chrome data (with no completed session).
4555
+ * @param error - An error to show above the form, or `null`.
4556
+ * @returns The full page.
4557
+ */
4558
+ declare function renderMfaPage(context: AdminRenderContext, error: string | null): string;
4559
+ /** One model card on the dashboard. */
4560
+ interface AdminDashboardCard {
4561
+ /** Plural display name. */
4562
+ label: string;
4563
+ /** Row count, or `null` when counting failed. */
4564
+ count: number | null;
4565
+ /** URL of the list view. */
4566
+ url: string;
4567
+ /** URL of the create form, or `null` when creation is disabled. */
4568
+ newUrl: string | null;
4569
+ }
4570
+ /** The system metrics panel on the dashboard. */
4571
+ interface AdminDashboardMetrics {
4572
+ /** CPU load as a percentage of available cores. */
4573
+ cpuPercent: number;
4574
+ /** Memory used, as a percentage. */
4575
+ memoryPercent: number;
4576
+ /** Memory used, in GB. */
4577
+ memoryUsedGb: string;
4578
+ /** Memory total, in GB. */
4579
+ memoryTotalGb: string;
4580
+ }
4581
+ /**
4582
+ * Render the dashboard: one card per registered model plus the optional system
4583
+ * metrics panel.
4584
+ *
4585
+ * @param context - The shared chrome data.
4586
+ * @param cards - One entry per registered model.
4587
+ * @param metrics - The system metrics panel, or `null` when disabled.
4588
+ * @returns The full page.
4589
+ */
4590
+ declare function renderDashboardPage(context: AdminRenderContext, cards: AdminDashboardCard[], metrics: AdminDashboardMetrics | null): string;
4591
+ /** A filter control rendered above the list view. */
4592
+ interface AdminFilterView {
4593
+ /** Column key the control filters on. */
4594
+ field: string;
4595
+ /** Human-readable label. */
4596
+ label: string;
4597
+ /** Which control to render. */
4598
+ kind: "select" | "daterange" | "text";
4599
+ /** Current value for `select` and `text` controls. */
4600
+ value: string;
4601
+ /** Lower bound for a `daterange` control. */
4602
+ valueFrom: string;
4603
+ /** Upper bound for a `daterange` control. */
4604
+ valueTo: string;
4605
+ /** Options for a `select` control. */
4606
+ options: {
4607
+ value: string;
4608
+ label: string;
4609
+ selected: boolean;
4610
+ }[];
4611
+ }
4612
+ /** A clickable column header's sort state. */
4613
+ interface AdminSortView {
4614
+ /** URL that applies (or flips) this column's ordering. */
4615
+ url: string;
4616
+ /** Whether the list is currently ordered by this column. */
4617
+ active: boolean;
4618
+ /** Whether the current ordering is ascending. */
4619
+ ascending: boolean;
4620
+ }
4621
+ /** The view model the list page renders. */
4622
+ interface AdminListView {
4623
+ /** Plural display name shown as the heading. */
4624
+ title: string;
4625
+ /** Column keys rendered as table columns. */
4626
+ columns: string[];
4627
+ /** One entry per row: its identity plus the formatted cells. */
4628
+ rows: {
4629
+ identity: string;
4630
+ cells: string[];
4631
+ url: string;
4632
+ }[];
4633
+ /** Total matching rows, across all pages. */
4634
+ total: number;
4635
+ /** Current page number, 1-based. */
4636
+ page: number;
4637
+ /** Total page count. */
4638
+ pages: number;
4639
+ /** URL of the previous page, or `null` on the first page. */
4640
+ prevUrl: string | null;
4641
+ /** URL of the next page, or `null` on the last page. */
4642
+ nextUrl: string | null;
4643
+ /** Whether a search box is rendered. */
4644
+ searchable: boolean;
4645
+ /** Current search text. */
4646
+ searchValue: string;
4647
+ /** Filter controls. */
4648
+ filters: AdminFilterView[];
4649
+ /** Sort state per column key. */
4650
+ sort: Record<string, AdminSortView>;
4651
+ /** URL of the create form, or `null` when creation is disabled. */
4652
+ newUrl: string | null;
4653
+ /** Bulk actions offered above the table. Empty hides the whole bulk UI. */
4654
+ bulkActions: BulkActionOption[];
4655
+ /** URL the bulk form posts to. */
4656
+ bulkUrl: string;
4657
+ /** URL exporting the current result set as CSV. */
4658
+ exportCsvUrl: string;
4659
+ /** URL exporting the current result set as JSON. */
4660
+ exportJsonUrl: string;
4661
+ }
4662
+ /**
4663
+ * Render the paginated list view, with its search box, filters and sortable
4664
+ * column headers.
4665
+ *
4666
+ * @param context - The shared chrome data.
4667
+ * @param view - The prepared list view model.
4668
+ * @returns The full page.
4669
+ */
4670
+ declare function renderListPage(context: AdminRenderContext, view: AdminListView): string;
4671
+ /** The view model the detail page renders. */
4672
+ interface AdminDetailView {
4673
+ /** Singular display name. */
4674
+ title: string;
4675
+ /** The row's identity, shown next to the title. */
4676
+ identity: string;
4677
+ /** One `(label, value)` pair per column. */
4678
+ fields: {
4679
+ label: string;
4680
+ value: string;
4681
+ }[];
4682
+ /** URL of the list view. */
4683
+ backUrl: string;
4684
+ /** URL of the edit form, or `null` when editing is disabled. */
4685
+ editUrl: string | null;
4686
+ /** URL the delete form posts to, or `null` when deletion is disabled. */
4687
+ deleteUrl: string | null;
4688
+ }
4689
+ /**
4690
+ * Render the single-record detail view.
4691
+ *
4692
+ * @param context - The shared chrome data (with an active session).
4693
+ * @param view - The prepared detail view model.
4694
+ * @returns The full page.
4695
+ * @throws Error When called without a session, since the write forms need a CSRF token.
4696
+ */
4697
+ declare function renderDetailPage(context: AdminRenderContext, view: AdminDetailView): string;
4698
+ /** The view model the create/edit form renders. */
4699
+ interface AdminFormView {
4700
+ /** Whether the form creates a new record or edits an existing one. */
4701
+ mode: "create" | "edit";
4702
+ /** Singular display name. */
4703
+ title: string;
4704
+ /** The controls to render. */
4705
+ fields: AdminFormField[];
4706
+ /** URL the form posts to. */
4707
+ actionUrl: string;
4708
+ /** URL of the page to return to. */
4709
+ backUrl: string;
4710
+ /** A form-level error shown above the fields, or `null`. */
4711
+ error: string | null;
4712
+ }
4713
+ /**
4714
+ * Render the create/edit form.
4715
+ *
4716
+ * @param context - The shared chrome data (with an active session).
4717
+ * @param view - The prepared form view model.
4718
+ * @returns The full page.
4719
+ * @throws Error When called without a session, since the form needs a CSRF token.
4720
+ */
4721
+ declare function renderFormPage(context: AdminRenderContext, view: AdminFormView): string;
4722
+
4723
+ /**
4724
+ * The server-rendered admin panel router, mirroring `admin.router`.
4725
+ *
4726
+ * Mounts a Django-style panel over an {@link AdminSite}: operators sign in with
4727
+ * a row from the project's own database, then browse, search, filter, sort,
4728
+ * create, edit and delete every registered model. Nothing here is JSON — the
4729
+ * responses are HTML pages built by `@/admin/templates` and styled by the one
4730
+ * stylesheet this package serves.
4731
+ *
4732
+ * ```text
4733
+ * GET {prefix}/static/admin.css the bundled stylesheet
4734
+ * GET {prefix}/login sign-in form
4735
+ * POST {prefix}/login credential check
4736
+ * GET {prefix}/mfa TOTP challenge (backends with MFA)
4737
+ * POST {prefix}/mfa TOTP verification
4738
+ * POST {prefix}/logout drop the session
4739
+ * GET {prefix}/ dashboard: row counts + system metrics
4740
+ * GET {prefix}/m/:slug list view: search, filters, sort, pages
4741
+ * GET {prefix}/m/:slug/new create form
4742
+ * POST {prefix}/m/:slug/new create
4743
+ * GET {prefix}/m/:slug/:identity detail view
4744
+ * GET {prefix}/m/:slug/:identity/edit edit form
4745
+ * POST {prefix}/m/:slug/:identity/edit update
4746
+ * POST {prefix}/m/:slug/:identity/delete delete
4747
+ * ```
4748
+ *
4749
+ * Every state-changing POST carries the session's CSRF token and is rejected
4750
+ * with `403` when it does not match.
4751
+ */
4752
+
4753
+ /** Options for {@link makeAdminRouter}. */
4754
+ interface AdminRouterOptions {
4755
+ /** The engine the panel opens a session on for each request. */
4756
+ engine: AsyncEngine;
4757
+ /** How the login form turns credentials into a principal. */
4758
+ authBackend: AdminAuthBackend;
4759
+ /** HMAC key signing the session cookie. At least 32 characters. */
4760
+ secretKey: string;
4761
+ /** Mount prefix. Default `/admin`. */
4762
+ prefix?: string;
4763
+ /** Send the session cookie with `Secure`. Default `true` — turn it off only in local HTTP dev. */
4764
+ cookieSecure?: boolean;
4765
+ /** Session cookie name. Default `tempest_admin_session`. */
4766
+ cookieName?: string;
4767
+ /** Session lifetime in seconds. Default `28800` (8 hours). */
4768
+ sessionMaxAgeSeconds?: number;
4769
+ /** Show the CPU/memory panel on the dashboard. Default `true`. */
4770
+ showMetrics?: boolean;
4771
+ /**
4772
+ * Hard cap on rows the CSV/JSON export writes. Default `5000`. An export is
4773
+ * a full table scan streamed to a browser, so the cap is what keeps a curious
4774
+ * click on a large table from becoming an outage.
4775
+ */
4776
+ exportMaxRows?: number;
4777
+ }
4778
+ /**
4779
+ * Build the admin panel router.
4780
+ *
4781
+ * @param site - The registered {@link AdminSite}.
4782
+ * @param options - Engine, auth backend, signing key and cookie/appearance flags.
4783
+ * @returns An Express router serving the whole panel under its prefix.
4784
+ * @throws Error When the signing key is shorter than 32 characters.
4785
+ */
4786
+ declare function makeAdminRouter(site: AdminSite, options: AdminRouterOptions): Router;
4787
+
4788
+ /**
4789
+ * Headless admin: resource registry for the JSON admin API.
4790
+ *
4791
+ * The counterpart to the server-rendered panel in `@/admin/site`. Register one
4792
+ * {@link AdminJsonResource} per managed entity and {@link makeAdminJsonRouter}
4793
+ * exposes auto-derived CRUD + introspection endpoints your own frontend
4794
+ * (React, etc.) renders. Resources are callback-based, so they wire to a
4795
+ * `BaseService` — or any store — in a few lines and stay ORM-agnostic.
4796
+ *
4797
+ * Reach for this when the UI is yours; reach for {@link AdminSite} +
4798
+ * `makeAdminRouter` when you want the batteries-included HTML panel.
3503
4799
  */
3504
4800
 
3505
4801
  /** A field descriptor a frontend uses to render list columns / form inputs. */
3506
- interface AdminField {
4802
+ interface AdminJsonField {
3507
4803
  /** Field name (property key). */
3508
4804
  name: string;
3509
4805
  /** Loose type hint for rendering (`string`, `number`, `boolean`, `date`, …). */
@@ -3513,16 +4809,16 @@ interface AdminField {
3513
4809
  /** Whether the field is read-only (shown, never submitted). */
3514
4810
  readOnly?: boolean;
3515
4811
  }
3516
- /** A paginated list result returned by {@link AdminResource.list}. */
3517
- interface AdminListResult<T = unknown> {
4812
+ /** A paginated list result returned by {@link AdminJsonResource.list}. */
4813
+ interface AdminJsonListResult<T = unknown> {
3518
4814
  items: T[];
3519
4815
  total: number;
3520
4816
  page: number;
3521
4817
  pageSize: number;
3522
4818
  pages: number;
3523
4819
  }
3524
- /** Query parameters passed to {@link AdminResource.list}. */
3525
- interface AdminListQuery {
4820
+ /** Query parameters passed to {@link AdminJsonResource.list}. */
4821
+ interface AdminJsonListQuery {
3526
4822
  page: number;
3527
4823
  pageSize: number;
3528
4824
  /** Remaining query-string entries (domain filters). */
@@ -3532,13 +4828,13 @@ interface AdminListQuery {
3532
4828
  * A managed resource. Only `name`, `fields` and `list`/`get` are required;
3533
4829
  * omit a write callback to make that operation unavailable (405).
3534
4830
  */
3535
- interface AdminResource<T = unknown> {
4831
+ interface AdminJsonResource<T = unknown> {
3536
4832
  /** URL-safe resource slug (e.g. `users`). */
3537
4833
  name: string;
3538
4834
  /** Field descriptors for list/detail/form rendering. */
3539
- fields: AdminField[];
4835
+ fields: AdminJsonField[];
3540
4836
  /** Return a page of records. */
3541
- list(query: AdminListQuery): Promise<AdminListResult<T>>;
4837
+ list(query: AdminJsonListQuery): Promise<AdminJsonListResult<T>>;
3542
4838
  /** Return one record by id, or `null` when absent. */
3543
4839
  get(id: string): Promise<T | null>;
3544
4840
  /** Create a record from validated input. */
@@ -3553,7 +4849,7 @@ interface AdminResource<T = unknown> {
3553
4849
  updateSchema?: z.ZodType;
3554
4850
  }
3555
4851
  /** A registry of admin resources. */
3556
- declare class AdminSite {
4852
+ declare class AdminJsonSite {
3557
4853
  readonly brand: string;
3558
4854
  private readonly resources;
3559
4855
  /**
@@ -3566,17 +4862,17 @@ declare class AdminSite {
3566
4862
  * @param resource - The resource config.
3567
4863
  * @returns The same resource (for chaining).
3568
4864
  */
3569
- register<T>(resource: AdminResource<T>): AdminResource<T>;
4865
+ register<T>(resource: AdminJsonResource<T>): AdminJsonResource<T>;
3570
4866
  /** Look up a resource by slug, or `null`. */
3571
- get(name: string): AdminResource | null;
4867
+ get(name: string): AdminJsonResource | null;
3572
4868
  /** Every registered resource. */
3573
- list(): AdminResource[];
4869
+ list(): AdminJsonResource[];
3574
4870
  }
3575
4871
 
3576
4872
  /**
3577
4873
  * Admin JSON router, mirroring `admin.router.make_admin_router`.
3578
4874
  *
3579
- * Exposes auto-derived CRUD + introspection over an {@link AdminSite}:
4875
+ * Exposes auto-derived CRUD + introspection over an {@link AdminJsonSite}:
3580
4876
  *
3581
4877
  * ```text
3582
4878
  * GET {prefix}/ site brand + resource list
@@ -3591,8 +4887,8 @@ declare class AdminSite {
3591
4887
  * Pass a `guard` middleware (e.g. JWT + `requireRoles("admin")`) to protect it.
3592
4888
  */
3593
4889
 
3594
- /** Options for {@link makeAdminRouter}. */
3595
- interface AdminRouterOptions {
4890
+ /** Options for {@link makeAdminJsonRouter}. */
4891
+ interface AdminJsonRouterOptions {
3596
4892
  /** Route prefix. Default `/admin`. */
3597
4893
  prefix?: string;
3598
4894
  /** Guard middleware applied to every admin route (auth). */
@@ -3601,11 +4897,11 @@ interface AdminRouterOptions {
3601
4897
  /**
3602
4898
  * Build the admin router.
3603
4899
  *
3604
- * @param site - The registered {@link AdminSite}.
4900
+ * @param site - The registered {@link AdminJsonSite}.
3605
4901
  * @param options - Prefix and guard middleware.
3606
4902
  * @returns An Express router with the admin endpoints mounted.
3607
4903
  */
3608
- declare function makeAdminRouter(site: AdminSite, options?: AdminRouterOptions): Router;
4904
+ declare function makeAdminJsonRouter(site: AdminJsonSite, options?: AdminJsonRouterOptions): Router;
3609
4905
 
3610
4906
  /**
3611
4907
  * Auth DTOs (Zod), mirroring `auth.schemas`.
@@ -5259,6 +6555,6 @@ declare function createTestDatabase(models: readonly ModelClass[]): TestDatabase
5259
6555
  declare function withTestDatabase<T>(models: readonly ModelClass[], fn: (db: TestDatabase) => Promise<T>): Promise<T>;
5260
6556
 
5261
6557
  /** The installed SDK version. Single source of truth for the barrel + CLI. */
5262
- declare const VERSION = "0.23.0";
6558
+ declare const VERSION = "0.25.0";
5263
6559
 
5264
- export { type ActivationInput, ActivationService, type ActivationServiceOptions, type ActivationStore, type AdminField, type AdminListQuery, type AdminListResult, type AdminResource, type AdminRouterOptions, AdminSite, AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, type AttachWebSocketOptions, AttemptThrottle, type AttemptThrottleOptions, AuditAction, type AuthResponse, type AuthResultPageOptions, type AuthRouterOptions, type AuthUser, type BackupOptions, type BaseAppSettings, BaseAuditLogModel, BaseController, BaseModel, BaseOAuthClient, BaseOutboxModel, type BaseResponse, BaseService, BaseUserModel, BaseUserRefreshTokenModel, BaseUserTokenModel, type BodySizeLimitOptions, type BroadcastOptions, type BroadcastResult, type BrokerManager, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CPUMetrics, CSRF_COOKIE_NAME, CSRF_HEADER_NAME, type CacheManager, type CachedOptions, type CachedResponse, type CatalogData, CircuitOpenError, type ClientIpOptions, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CsrfOptions, type CursorPaginationFilter, DEFAULT_DOCS_FAVICON, DEFAULT_LOCALE, type DownloadOptions, type EmailMessage, type EmailOptions, EmailProvider, type EmailProviderOptions, EmailUtils, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FieldChange, type FileLoggingHandle, type FileLoggingOptions, type FlagContext, ForbiddenException, type GPUMetrics, type GenerateOpenApiOptions, GitHubOAuthClient, GoogleOAuthClient, GracefulShutdown, type GracefulShutdownOptions, HTTPClient, type HTTPClientOptions, HTTP_500_LOG_FILE, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, HttpMetrics, IDEMPOTENCY_HEADER, type IdempotencyOptions, type IdempotencyRedisLike, type IdempotencyStore, type InboundHandler, type InboundMessage, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, type JwtDecoderLike, LEVEL_LOG_FILES, LocalUploadStorage, type LocalUploadStorageOptions, type LogEntry, type LogExtra, type LogLevel, type LogSink, type LogSource, type LoginInput, type LoginResult, type LogsRouterOptions, type MediaKind, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, MemoryIdempotencyStore, type MemoryMetrics, MemoryRateLimitStore, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, MessagingHub, type MessagingProvider, type MetricsRouterOptions, MetricsUtils, type MfaChallenge, type MfaChallengeInput, type MfaCodeInput, type MfaEnrollment, MfaService, type MfaServiceOptions, type MfaStore, NotFoundException, type OAuthClientOptions, OAuthError, type OAuthTokens, type OAuthUser, OIDCProvider, type OIDCProviderOptions, type OpenApiDocument, type OpenApiInfo, type OutboundMedia, type OutboundResult, type OutboxPublisher, OutboxRelay, type OutboxRelayOptions, OutboxStatus, PHONE_BR_PATTERN, type PaginationFilter, type PaginationLinkOptions, type PasswordResetConfirmInput, type PasswordResetFormOptions, type PasswordResetRequestInput, PasswordResetService, type PasswordResetServiceOptions, type PasswordResetStore, PasswordUtils, REDOC_CDN_URL, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, type RateLimitKeyFunc, type RateLimitOptions, type RateLimitRedisLike, type RateLimitResult, type RateLimitStore, RedisCacheManager, RedisIdempotencyStore, type RedisLike, type RedisPublisherLike, RedisRateLimitStore, RedisSSEBroker, type RedisSSEBrokerOptions, RedisSessionStore, type RedisSubscriberLike, type RedocBundleSource, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type RequestTracingOptions, type ResponseMapper, RetryPolicy, type RunServerOptions, type S3ClientLike, S3UploadStorage, type S3UploadStorageOptions, SSEBroker, type SaveOptions, type SendOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, type SessionRedisLike, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type SlowQueryOptions, type SpecProvider, type StateBR, type SwaggerOptions, type SyncFilter, type SystemMetrics, TOTPHelper, type TOTPOptions, type TaskHandler, TaskManager, type TaskManagerOptions, TelegramProvider, type TelegramProviderOptions, TenantScopedRepository, type TestDatabase, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, type ToolSpecOptions, TwilioSmsProvider, type TwilioSmsProviderOptions, type TwilioWebhookOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, type UserPublic, type UserStore, UserTokenPurpose, VERSION, ValidationException, type WSEnvelope, WebPushDispatcher, type WebPushDispatcherOptions, WebPushError, WebPushGoneError, type WebPushKeys, type WebPushPayload, type WebPushSubscription, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, type WebhookSignatureOptions, WebhookSignatureVerifier, WhatsAppProvider, type WhatsAppProviderOptions, type WhatsAppWebhookOptions, activationSchema, addLogSink, attachWebSocketHub, authResponseSchema, authSettingsShape, backupDatabase, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, bodySizeLimitMiddleware, broadcastText, buildContentDisposition, buildPaginationLinkHeader, cached, centsField, cepField, citiesByUf, cnpjField, coerceFlag, configureFileLogging, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createTestDatabase, createdByColumn, csrfMiddleware, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, diffSnapshots, emailSettingsShape, encodeCursor, looseBoolean as envBoolean, envList, generateCsrfToken, generateOAuthState, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, hexColorField, idempotencyMiddleware, inboundMessageSchema, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, jwtSettingsShape, keyByHeader, keyByIp, keyByJwtClaim, keyByJwtSubject, latitudeField, listStates, loadSettings, logEntrySchema, logSettingsShape, loginSchema, longitudeField, looseBoolean, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeLogsRouter, makeMetricsRouter, makeSessionMiddleware, makeToolSpecRouter, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaChallengeSchema, mfaCodeSchema, mfaEnrollResponseSchema, minioSettingsShape, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, nonEmptyStrField, nonNegativeFloatField, nonNegativeIntField, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, passwordResetConfirmSchema, passwordResetRequestSchema, percentField, phoneBrField, portField, positiveFloatField, positiveIntField, priceField, prometheusMiddleware, rabbitmqSettingsShape, rateLimitMiddleware, ratingField, ratioField, redisSettingsShape, refreshSchema, registerExceptionHandlers, renderAuthResultPage, renderPasswordResetFormPage, requestIdMiddleware, requestTracingMiddleware, requireRoles, resolveDownloadPath, resolveRedocBundle, runServer, runWithRequestContext, sendBytesDownload, sendFileDownload, serverSettingsShape, sessionCookie, sessionSettingsShape, setRequestId, signupSchema, slugField, snapshot, sseResponse, statesByRegion, syncFilterSchema, syncPaginationSchema, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, tokenSettingsShape, ufField, updatedByColumn, uploadSettingsShape, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSettingsShape, webPushSubscriptionSchema, webSocketSettingsShape, withTestDatabase, wrapWithSlowQueryLog, wsEnvelopeSchema };
6560
+ export { ADMIN_CSS, type ActivationInput, ActivationService, type ActivationServiceOptions, type ActivationStore, type AdminAction, type AdminActionCategory, type AdminActionContext, type AdminActionHandler, type AdminActionOptions, type AdminActionResult, type AdminAuthBackend, type AdminAutomapOptions, type AdminDashboardCard, type AdminDashboardMetrics, type AdminDetailView, type AdminFilterKind, type AdminFilterView, type AdminFormField, type AdminFormView, type AdminJsonField, type AdminJsonListQuery, type AdminJsonListResult, type AdminJsonResource, type AdminJsonRouterOptions, AdminJsonSite, type AdminListView, type AdminMessage, type AdminMfaVerifier, AdminModel, type AdminModelOptions, type AdminNavEntry, type AdminRenderContext, type AdminRouterOptions, type AdminRow, type AdminSelectOption, type AdminSession, AdminSessionStore, type AdminSessionStoreOptions, AdminSite, type AdminSiteOptions, type AdminSortView, type AdminTheme, type AdminWidget, AppException, type AppExceptionHandlerOptions, type AppExceptionOptions, type AttachWebSocketOptions, AttemptThrottle, type AttemptThrottleOptions, AuditAction, type AuthResponse, type AuthResultPageOptions, type AuthRouterOptions, type AuthUser, type BackupOptions, type BaseAppSettings, BaseAuditLogModel, BaseController, BaseModel, BaseOAuthClient, BaseOutboxModel, type BaseResponse, BaseService, BaseUserModel, BaseUserRefreshTokenModel, BaseUserTokenModel, type BodySizeLimitOptions, type BroadcastOptions, type BroadcastResult, type BrokerManager, type BuildFormFieldsOptions, type BulkActionOption, CEP_PATTERN, CNPJ_PATTERN, CPF_PATTERN, type CPUMetrics, CSRF_COOKIE_NAME, CSRF_HEADER_NAME, type CacheManager, type CachedOptions, type CachedResponse, type CatalogData, CircuitOpenError, type ClientIpOptions, CompositeFeatureFlagBackend, ConflictException, type CreateAppOpenApi, type CreateAppOptions, type CsrfOptions, type CursorPaginationFilter, DEFAULT_DOCS_FAVICON, DEFAULT_LOCALE, type DownloadOptions, type EmailMessage, type EmailOptions, EmailProvider, type EmailProviderOptions, EmailUtils, type Enum, type EnumHelpers, type EnumSpec, EnvFeatureFlagBackend, EventStream, type EventStreamOptions, type ExceptionDetails, ExpiredTokenException, type FeatureFlagBackend, FeatureFlags, type FieldChange, type FileLoggingHandle, type FileLoggingOptions, type FlagContext, ForbiddenException, type GPUMetrics, type GenerateOpenApiOptions, GitHubOAuthClient, GoogleOAuthClient, GracefulShutdown, type GracefulShutdownOptions, HTTPClient, type HTTPClientOptions, HTTP_500_LOG_FILE, HTTP_500_MARKER, type HandshakeInfo, type HealthCheck, type HealthRouterOptions, HttpMetrics, IDEMPOTENCY_HEADER, type IdempotencyOptions, type IdempotencyRedisLike, type IdempotencyStore, type InboundHandler, type InboundMessage, InvalidTokenException, type IssuedSession, JSONLogger, JWTUtils, type JWTUtilsOptions, type JwtAuthOptions, type JwtClaims, type JwtDecoderLike, LEVEL_LOG_FILES, LocalUploadStorage, type LocalUploadStorageOptions, type LogEntry, type LogExtra, type LogLevel, type LogSink, type LogSource, type LoginInput, type LoginResult, type LogsRouterOptions, type MediaKind, MemoryBroker, MemoryCacheManager, MemoryFeatureFlagBackend, MemoryIdempotencyStore, type MemoryMetrics, MemoryRateLimitStore, MemorySessionStore, MemoryThrottleBackend, MessageCatalog, type MessageHandler, MessagingHub, type MessagingProvider, type MetricsRouterOptions, MetricsUtils, type MfaChallenge, type MfaChallengeInput, type MfaCodeInput, type MfaEnrollment, MfaService, type MfaServiceOptions, type MfaStore, NotFoundException, type OAuthClientOptions, OAuthError, type OAuthTokens, type OAuthUser, OIDCProvider, type OIDCProviderOptions, type OpenApiDocument, type OpenApiInfo, type OutboundMedia, type OutboundResult, type OutboxPublisher, OutboxRelay, type OutboxRelayOptions, OutboxStatus, PHONE_BR_PATTERN, type PaginationFilter, type PaginationLinkOptions, type ParsedAdminForm, type PasswordResetConfirmInput, type PasswordResetFormOptions, type PasswordResetRequestInput, PasswordResetService, type PasswordResetServiceOptions, type PasswordResetStore, PasswordUtils, REDOC_CDN_URL, REQUEST_ID_HEADER, RabbitBroker, type RabbitBrokerOptions, type RateLimitKeyFunc, type RateLimitOptions, type RateLimitRedisLike, type RateLimitResult, type RateLimitStore, RedisCacheManager, RedisIdempotencyStore, type RedisLike, type RedisPublisherLike, RedisRateLimitStore, RedisSSEBroker, type RedisSSEBrokerOptions, RedisSessionStore, type RedisSubscriberLike, type RedocBundleSource, type RedocOptions, type RefreshInput, Region, type RegionValue, type RegisterExceptionHandlersOptions, type RequestContext, type RequestTracingOptions, type ResolvedAdminTheme, type ResponseMapper, RetryPolicy, type RunServerOptions, type S3ClientLike, S3UploadStorage, type S3UploadStorageOptions, SSEBroker, type SaveOptions, type SendOptions, ServerSentEvent, type ServerSentEventInit, type Session, type SessionMiddlewareOptions, type SessionRedisLike, SessionService, type SessionServiceOptions, type SessionStore, type SignupInput, type SlowQueryOptions, type SpecProvider, type StateBR, type SwaggerOptions, type SyncFilter, type SystemMetrics, TOTPHelper, type TOTPOptions, type TaskHandler, TaskManager, type TaskManagerOptions, TelegramProvider, type TelegramProviderOptions, TenantScopedRepository, type TestDatabase, type ThrottleBackend, type ThrottleStatus, type ToDictOptions, type TokenPair, TooManyRequestsException, type TooManyRequestsOptions, type ToolSpecOptions, TwilioSmsProvider, type TwilioSmsProviderOptions, type TwilioWebhookOptions, UF, type UFValue, UnauthorizedException, type UnhandledExceptionHandlerOptions, type UploadResult, type UploadStorage, UserAuthService, type UserAuthServiceOptions, UserModelAuthBackend, type UserModelAuthBackendOptions, type UserPublic, type UserStore, UserTokenPurpose, VERSION, ValidationException, type WSEnvelope, WebPushDispatcher, type WebPushDispatcherOptions, WebPushError, WebPushGoneError, type WebPushKeys, type WebPushPayload, type WebPushSubscription, type WebSocketConnection, WebSocketHub, type WebSocketHubOptions, type WebSocketLike, type WebhookSignatureOptions, WebhookSignatureVerifier, WhatsAppProvider, type WhatsAppProviderOptions, type WhatsAppWebhookOptions, type WidgetSpec, activationSchema, addLogSink, adminAction, adminColumns, adminThemeCss, attachWebSocketHub, authResponseSchema, authSettingsShape, backupDatabase, baseAppSettingsSchema, baseAppSettingsShape, baseResponseSchema, bearerToken, bodySizeLimitMiddleware, broadcastText, buildContentDisposition, buildFormFields, buildPaginationLinkHeader, cached, centsField, cepField, citiesByUf, cnpjField, coerceFlag, configureFileLogging, configureLogging, corsSettingsShape, cpfField, cpfOrCnpjField, createApp, createOpenApiRegistry, createTestDatabase, createdByColumn, csrfMiddleware, csrfTokenMatches, cursorPaginationFilterSchema, cursorPaginationSchema, databaseSettingsShape, decodeCursor, defaultMessageCatalog, defineEnum, deletedAtColumn, diffSnapshots, emailSettingsShape, encodeCursor, looseBoolean as envBoolean, envList, escapeHtml, filterForColumn, foreignKeyFields, foreignKeyLabel, foreignKeyTable, formatCellValue, formatFieldValue, generateCsrfToken, generateOAuthState, generateOpaqueToken, generateOpenApiDocument, getAuth, getClientIp, getConditions, getPaginationConditions, getRequestId, getState, hashOpaqueToken, hexColorField, humanizeField, idempotencyMiddleware, inboundMessageSchema, isColumnOptional, isSearchableColumn, isValidCep, isValidCity, isValidCnpj, isValidCpf, isValidCpfCnpj, isValidPhoneBr, isValidUf, jwtSettingsShape, keyByHeader, keyByIp, keyByJwtClaim, keyByJwtSubject, latitudeField, listStates, loadSettings, logEntrySchema, logSettingsShape, loginSchema, longitudeField, looseBoolean, makeAdminJsonRouter, makeAdminRouter, makeAppExceptionHandler, makeAuthRouter, makeFlagGuard, makeHealthRouter, makeJwtAuthMiddleware, makeLogsRouter, makeMetricsRouter, makeSessionMiddleware, makeToolSpecRouter, makeTwilioWebhookRouter, makeUnhandledExceptionHandler, makeWhatsAppWebhookRouter, mfaChallengeSchema, mfaCodeSchema, mfaEnrollResponseSchema, minioSettingsShape, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, nonEmptyStrField, nonNegativeFloatField, nonNegativeIntField, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, parseFormBody, passwordResetConfirmSchema, passwordResetRequestSchema, percentField, phoneBrField, portField, positiveFloatField, positiveIntField, priceField, prometheusMiddleware, rabbitmqSettingsShape, rateLimitMiddleware, ratingField, ratioField, redisSettingsShape, refreshSchema, registerExceptionHandlers, renderAuthResultPage, renderDashboardPage, renderDetailPage, renderFormPage, renderLayout, renderListPage, renderLoginPage, renderMfaPage, renderPasswordResetFormPage, requestIdMiddleware, requestTracingMiddleware, requireRoles, resolveAdminTheme, resolveDownloadPath, resolveRedocBundle, runServer, runWithRequestContext, sendBytesDownload, sendFileDownload, serverSettingsShape, sessionCookie, sessionSettingsShape, setRequestId, signupSchema, slugField, snapshot, sseResponse, statesByRegion, syncFilterSchema, syncPaginationSchema, tableNameFor, toDict, toUtc, tokenFromUrl, tokenPairSchema, tokenSettingsShape, ufField, updatedByColumn, uploadSettingsShape, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSettingsShape, webPushSubscriptionSchema, webSocketSettingsShape, widgetForColumn, withTestDatabase, wrapWithSlowQueryLog, wsEnvelopeSchema };