tempest-express-sdk 0.25.0 → 0.26.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
@@ -3492,6 +3492,144 @@ declare class MessagingHub {
3492
3492
  broadcast(channel: string, recipients: string[], text: string, options?: BroadcastOptions): Promise<BroadcastResult[]>;
3493
3493
  }
3494
3494
 
3495
+ /**
3496
+ * Business-metric cards for the admin dashboard, mirroring `admin.dashboard`.
3497
+ *
3498
+ * Distinct from the system panel (CPU/memory): these are value / trend /
3499
+ * partition cards computed from the application's own data — "orders today",
3500
+ * "revenue vs last week", "users by plan". Register them on the
3501
+ * {@link AdminSite} and they render above the model cards.
3502
+ *
3503
+ * ```ts
3504
+ * const site = new AdminSite({
3505
+ * title: "Shop",
3506
+ * dashboardCards: [
3507
+ * metricCard("Orders today", async (session) => ({
3508
+ * kind: "value",
3509
+ * value: await new BaseRepository(OrderModel, session).count(),
3510
+ * unit: "orders",
3511
+ * })),
3512
+ * ],
3513
+ * });
3514
+ * ```
3515
+ */
3516
+
3517
+ /** A single headline number. */
3518
+ interface MetricValue {
3519
+ kind: "value";
3520
+ /** The value to show — a number, or a preformatted string. */
3521
+ value: number | string;
3522
+ /** Optional unit suffix (`"orders"`, `"BRL"`). */
3523
+ unit?: string;
3524
+ }
3525
+ /** A number compared against a previous period. */
3526
+ interface MetricTrend {
3527
+ kind: "trend";
3528
+ /** The current value. */
3529
+ value: number;
3530
+ /** The value for the comparison period. */
3531
+ previous: number;
3532
+ /** Optional unit suffix. */
3533
+ unit?: string;
3534
+ }
3535
+ /** A breakdown of a total across labeled segments. */
3536
+ interface MetricPartition {
3537
+ kind: "partition";
3538
+ /** `(label, value)` pairs. */
3539
+ segments: {
3540
+ label: string;
3541
+ value: number;
3542
+ }[];
3543
+ }
3544
+ /** What a card's `compute` returns. */
3545
+ type CardData = MetricValue | MetricTrend | MetricPartition;
3546
+ /** Async function computing one card from a DB session. */
3547
+ type CardCompute = (session: AsyncSession) => Promise<CardData>;
3548
+ /** A dashboard business-metric card. */
3549
+ interface MetricCard {
3550
+ /** The card heading. */
3551
+ label: string;
3552
+ /** Async function returning the card data. */
3553
+ compute: CardCompute;
3554
+ /** Optional sub-label shown under the value. */
3555
+ helpText?: string;
3556
+ }
3557
+ /**
3558
+ * Describe a dashboard card.
3559
+ *
3560
+ * @param label - The card heading.
3561
+ * @param compute - Async function returning the card data.
3562
+ * @param helpText - Optional sub-label.
3563
+ * @returns The card descriptor to pass to `new AdminSite({ dashboardCards })`.
3564
+ */
3565
+ declare function metricCard(label: string, compute: CardCompute, helpText?: string): MetricCard;
3566
+ /**
3567
+ * Return the percentage change a trend represents.
3568
+ *
3569
+ * @param trend - The computed trend.
3570
+ * @returns `delta / previous * 100`, or `null` when there is no baseline to
3571
+ * divide by — a percentage against zero is undefined, not infinite.
3572
+ */
3573
+ declare function trendPercent(trend: MetricTrend): number | null;
3574
+ /**
3575
+ * Return which way a trend moved.
3576
+ *
3577
+ * @param trend - The computed trend.
3578
+ * @returns `"up"`, `"down"` or `"flat"`.
3579
+ */
3580
+ declare function trendDirection(trend: MetricTrend): "up" | "down" | "flat";
3581
+ /**
3582
+ * Return the sum of a partition's segment values.
3583
+ *
3584
+ * @param partition - The computed partition.
3585
+ * @returns The total across segments.
3586
+ */
3587
+ declare function partitionTotal(partition: MetricPartition): number;
3588
+
3589
+ /**
3590
+ * Named, saved list-view presets — Laravel Nova's "lenses", mirroring
3591
+ * `admin.config.Lens`.
3592
+ *
3593
+ * A lens bundles a set of filters and an optional ordering under a label. On
3594
+ * the list view lenses render as tabs; clicking one applies its filters (ANDed
3595
+ * with whatever the operator typed) and its ordering. A "support triage" lens
3596
+ * pinning `{ status: "open", priority: { gte: 3 } }` sorted oldest-first gets
3597
+ * an operator to the working set in one click instead of re-entering filters
3598
+ * every morning.
3599
+ */
3600
+
3601
+ /** Options accepted by {@link adminLens}. */
3602
+ interface AdminLensOptions {
3603
+ /** Lens identifier; its slug is the `?lens=` value. */
3604
+ name: string;
3605
+ /** Conditions merged into the query, in repository `where` shape. */
3606
+ filters?: WhereInput<Record<string, unknown>>;
3607
+ /** Ordering column; prefix with `-` for descending. */
3608
+ orderBy?: string;
3609
+ /** Tab label. Defaults to `name`. */
3610
+ label?: string;
3611
+ }
3612
+ /** A registered lens. */
3613
+ interface AdminLens {
3614
+ /** Lens identifier. */
3615
+ name: string;
3616
+ /** URL slug — the `?lens=` value. */
3617
+ slug: string;
3618
+ /** Tab label. */
3619
+ label: string;
3620
+ /** Conditions merged into the query. */
3621
+ filters: WhereInput<Record<string, unknown>>;
3622
+ /** Ordering column, or `null`. `-column` means descending. */
3623
+ orderBy: string | null;
3624
+ }
3625
+ /**
3626
+ * Describe a saved list-view preset.
3627
+ *
3628
+ * @param options - Name, filters, ordering and label.
3629
+ * @returns The lens descriptor to pass to `AdminModel({ lenses: [...] })`.
3630
+ */
3631
+ declare function adminLens(options: AdminLensOptions): AdminLens;
3632
+
3495
3633
  /**
3496
3634
  * Signed-cookie sessions for the admin panel, mirroring `admin.session`.
3497
3635
  *
@@ -3702,97 +3840,6 @@ interface BulkActionOption {
3702
3840
  dangerous: boolean;
3703
3841
  }
3704
3842
 
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
3843
  /**
3797
3844
  * Declarative admin configuration for one model, mirroring `admin.config`.
3798
3845
  *
@@ -3839,6 +3886,16 @@ interface AdminModelOptions<C extends ModelClass> {
3839
3886
  * delete and runs against the checked rows.
3840
3887
  */
3841
3888
  actions?: readonly AdminAction<C>[];
3889
+ /**
3890
+ * Audit-log model backing the detail view's change timeline. Pair it with a
3891
+ * repository that actually writes the rows — the panel only reads them.
3892
+ */
3893
+ auditModel?: ModelClass;
3894
+ /**
3895
+ * Saved list-view presets rendered as tabs above the table, each applying
3896
+ * its filters and ordering through `?lens=<slug>`.
3897
+ */
3898
+ lenses?: readonly AdminLens[];
3842
3899
  }
3843
3900
  /**
3844
3901
  * The admin configuration for one model.
@@ -3876,6 +3933,10 @@ declare class AdminModel<C extends ModelClass = ModelClass> {
3876
3933
  readonly canEdit: boolean;
3877
3934
  /** Whether the delete action is exposed. */
3878
3935
  readonly canDelete: boolean;
3936
+ /** Audit-log model backing the detail timeline, or `null`. */
3937
+ readonly auditModel: ModelClass | null;
3938
+ /** Saved list-view presets, in declaration order. */
3939
+ readonly lenses: AdminLens[];
3879
3940
  private readonly actions;
3880
3941
  private readonly slugOverride;
3881
3942
  private readonly listDisplayOverride;
@@ -3919,6 +3980,20 @@ declare class AdminModel<C extends ModelClass = ModelClass> {
3919
3980
  * @returns The configured `listDisplay`, or every column but the password hash.
3920
3981
  */
3921
3982
  listDisplayNames(): string[];
3983
+ /**
3984
+ * Look a lens up by its slug.
3985
+ *
3986
+ * @param slug - The `?lens=` value.
3987
+ * @returns The lens, or `null` when nothing matches.
3988
+ */
3989
+ getLens(slug: string): AdminLens | null;
3990
+ /**
3991
+ * Return the audit/timestamp columns the model actually declares.
3992
+ *
3993
+ * @returns The subset of `createdAt` / `updatedAt` / `createdBy` /
3994
+ * `updatedBy` present on the model, in that order.
3995
+ */
3996
+ auditFieldNames(): string[];
3922
3997
  /**
3923
3998
  * Return the columns the detail view renders.
3924
3999
  *
@@ -3927,7 +4002,11 @@ declare class AdminModel<C extends ModelClass = ModelClass> {
3927
4002
  * where an operator goes to see the whole record, so trimming it there would
3928
4003
  * hide data with nowhere else to read it.
3929
4004
  *
3930
- * @returns Every column but the password hash, in declaration order.
4005
+ * The audit/timestamp columns are held back too — they render in the detail
4006
+ * view's own audit panel, next to the change history, rather than scattered
4007
+ * among the domain fields.
4008
+ *
4009
+ * @returns Every domain column, in declaration order.
3931
4010
  */
3932
4011
  detailFieldNames(): string[];
3933
4012
  /**
@@ -3966,6 +4045,138 @@ declare class AdminModel<C extends ModelClass = ModelClass> {
3966
4045
  /** The row type a configured {@link AdminModel} reads and writes. */
3967
4046
  type AdminRow<A> = A extends AdminModel<infer C> ? InferModel<C> : never;
3968
4047
 
4048
+ /**
4049
+ * Granular per-model, per-action access control, mirroring
4050
+ * `admin.permissions`.
4051
+ *
4052
+ * Out of the box every operator who can sign in (`isAdmin`) can do everything
4053
+ * the {@link AdminModel} flags allow. To narrow a principal to a subset of
4054
+ * models or actions — a "support" role that may view orders but never delete
4055
+ * them, an "editor" who may touch content models only — hand an
4056
+ * {@link AdminAccessPolicy} to `makeAdminRouter`.
4057
+ *
4058
+ * ```ts
4059
+ * const policy: AdminAccessPolicy = (user, admin, action) => {
4060
+ * if (user.role === "superadmin") return true;
4061
+ * if (user.role === "support") return action === AdminPermission.VIEW;
4062
+ * return false;
4063
+ * };
4064
+ *
4065
+ * makeAdminRouter(site, { ..., accessPolicy: policy });
4066
+ * ```
4067
+ *
4068
+ * The policy **composes with** the `canCreate` / `canEdit` / `canDelete` flags
4069
+ * rather than replacing them: both have to allow an action. A denied `VIEW`
4070
+ * also hides the model from the dashboard and the sidebar, so an operator is
4071
+ * never shown a door that will answer `403`.
4072
+ */
4073
+
4074
+ /** An admin action gated by an {@link AdminAccessPolicy}. */
4075
+ declare const AdminPermission: {
4076
+ readonly VIEW: "view";
4077
+ readonly CREATE: "create";
4078
+ readonly EDIT: "edit";
4079
+ readonly DELETE: "delete";
4080
+ };
4081
+ /** An {@link AdminPermission} value. */
4082
+ type AdminPermission = (typeof AdminPermission)[keyof typeof AdminPermission];
4083
+ /**
4084
+ * Decides whether `principal` may perform `action` on the model behind
4085
+ * `admin`. Sync or async; return truthy to allow.
4086
+ */
4087
+ type AdminAccessPolicy = (principal: unknown, admin: AdminModel, action: AdminPermission) => boolean | Promise<boolean>;
4088
+
4089
+ /**
4090
+ * Column introspection for the admin panel, mirroring `admin.forms`' widget
4091
+ * derivation.
4092
+ *
4093
+ * `tempest-db-js` keeps rich runtime metadata on every column — the canonical
4094
+ * type kind, enum members, `varchar` length, the not-null/default/primary-key
4095
+ * flags and the foreign-key reference — so the admin derives its form widgets
4096
+ * and list filters from the model itself instead of asking the project to
4097
+ * restate them. Kept separate from the router so the (fiddly) type handling is
4098
+ * unit-testable in isolation.
4099
+ */
4100
+
4101
+ /** The set of form controls the admin knows how to render. */
4102
+ type AdminWidget = "text" | "textarea" | "number" | "checkbox" | "datetime" | "date" | "time" | "select" | "json";
4103
+ /** A `(value, label)` pair for a `select` widget. */
4104
+ interface AdminSelectOption {
4105
+ value: string;
4106
+ label: string;
4107
+ }
4108
+ /** The widget a column maps to, plus the attributes that render it. */
4109
+ interface WidgetSpec {
4110
+ /** The control to render. */
4111
+ widget: AdminWidget;
4112
+ /** `step` attribute for `number` widgets, or `null`. */
4113
+ step: string | null;
4114
+ /** Options for `select` widgets (empty otherwise). */
4115
+ options: AdminSelectOption[];
4116
+ }
4117
+ /** How a column is surfaced in the list view's filter bar. */
4118
+ type AdminFilterKind = "select" | "daterange" | "text";
4119
+ /**
4120
+ * Humanize a column key into a form label (`lastLoginAt` → `Last Login At`).
4121
+ *
4122
+ * @param name - The column key.
4123
+ * @returns A title-cased label.
4124
+ */
4125
+ declare function humanizeField(name: string): string;
4126
+ /**
4127
+ * Return every column of a model, keyed by field name in declaration order.
4128
+ *
4129
+ * @param model - The model class.
4130
+ * @returns The column map (do not mutate).
4131
+ */
4132
+ declare function adminColumns(model: ModelClass): Record<string, Column<unknown>>;
4133
+ /**
4134
+ * Map a column to the widget that edits it.
4135
+ *
4136
+ * `json` is matched before anything else because a JSON column carries no
4137
+ * useful scalar type, and `enum` is matched before the string kinds so its
4138
+ * members become a dropdown rather than a free-text input.
4139
+ *
4140
+ * @param column - The column to inspect.
4141
+ * @returns The widget, its `number` step (or `null`) and its `select` options.
4142
+ */
4143
+ declare function widgetForColumn(column: Column<unknown>): WidgetSpec;
4144
+ /**
4145
+ * Whether a column may be left blank on submit — it is nullable, carries a
4146
+ * default, or is the primary key the database fills in.
4147
+ *
4148
+ * @param column - The column to inspect.
4149
+ * @returns `true` when the field is optional.
4150
+ */
4151
+ declare function isColumnOptional(column: Column<unknown>): boolean;
4152
+ /**
4153
+ * Map a column to the filter control the list view shows for it.
4154
+ *
4155
+ * Booleans and enums become dropdowns, date-like columns become a from/to pair
4156
+ * of date inputs, and anything else falls back to an equality text input.
4157
+ *
4158
+ * @param column - The column to inspect.
4159
+ * @returns The filter kind and, for `select`, its options.
4160
+ */
4161
+ declare function filterForColumn(column: Column<unknown>): {
4162
+ kind: AdminFilterKind;
4163
+ options: AdminSelectOption[];
4164
+ };
4165
+ /**
4166
+ * Return the table a column points at, when it carries a foreign key.
4167
+ *
4168
+ * @param column - The column to inspect.
4169
+ * @returns The referenced table name, or `null` for a plain column.
4170
+ */
4171
+ declare function foreignKeyTable(column: Column<unknown>): string | null;
4172
+ /**
4173
+ * Whether a column holds free text a `LIKE '%…%'` search can match.
4174
+ *
4175
+ * @param column - The column to inspect.
4176
+ * @returns `true` for `varchar` / `text` / `char` columns.
4177
+ */
4178
+ declare function isSearchableColumn(column: Column<unknown>): boolean;
4179
+
3969
4180
  /**
3970
4181
  * Form building and submission parsing for the admin CRUD views, mirroring
3971
4182
  * `admin.forms`.
@@ -4366,6 +4577,11 @@ interface AdminSiteOptions {
4366
4577
  siteUrl?: string;
4367
4578
  /** Typed appearance overrides. Omitted keeps the stock look. */
4368
4579
  theme?: AdminTheme;
4580
+ /**
4581
+ * Business-metric cards rendered at the top of the dashboard, each computed
4582
+ * from the database on load. Distinct from the system CPU/memory panel.
4583
+ */
4584
+ dashboardCards?: readonly MetricCard[];
4369
4585
  }
4370
4586
  /** Options accepted by {@link AdminSite.automap}. */
4371
4587
  interface AdminAutomapOptions extends Omit<AdminModelOptions<ModelClass>, "model"> {
@@ -4398,6 +4614,8 @@ declare class AdminSite {
4398
4614
  readonly siteUrl: string | null;
4399
4615
  /** Typed appearance overrides. */
4400
4616
  readonly theme: AdminTheme;
4617
+ /** Business-metric cards rendered at the top of the dashboard. */
4618
+ readonly dashboardCards: MetricCard[];
4401
4619
  private readonly registry;
4402
4620
  /**
4403
4621
  * Initialize the site.
@@ -4567,6 +4785,33 @@ interface AdminDashboardCard {
4567
4785
  /** URL of the create form, or `null` when creation is disabled. */
4568
4786
  newUrl: string | null;
4569
4787
  }
4788
+ /** One business-metric card, already computed and formatted for rendering. */
4789
+ interface AdminBusinessCardView {
4790
+ /** The card heading. */
4791
+ label: string;
4792
+ /** Which shape to render. */
4793
+ kind: "value" | "trend" | "partition";
4794
+ /** Headline value (`value` and `trend` cards). */
4795
+ value: string;
4796
+ /** Optional unit suffix. */
4797
+ unit: string | null;
4798
+ /** Trend direction (`trend` cards). */
4799
+ direction: "up" | "down" | "flat";
4800
+ /** Formatted percentage change, or `null` when there is no baseline. */
4801
+ percent: string | null;
4802
+ /** Previous-period value, as text (`trend` cards). */
4803
+ previous: string;
4804
+ /** Segments with their share of the total (`partition` cards). */
4805
+ segments: {
4806
+ label: string;
4807
+ value: string;
4808
+ percent: number;
4809
+ }[];
4810
+ /** Optional sub-label. */
4811
+ helpText: string | null;
4812
+ /** Set when the card's compute threw, so the dashboard still renders. */
4813
+ error: string | null;
4814
+ }
4570
4815
  /** The system metrics panel on the dashboard. */
4571
4816
  interface AdminDashboardMetrics {
4572
4817
  /** CPU load as a percentage of available cores. */
@@ -4587,7 +4832,7 @@ interface AdminDashboardMetrics {
4587
4832
  * @param metrics - The system metrics panel, or `null` when disabled.
4588
4833
  * @returns The full page.
4589
4834
  */
4590
- declare function renderDashboardPage(context: AdminRenderContext, cards: AdminDashboardCard[], metrics: AdminDashboardMetrics | null): string;
4835
+ declare function renderDashboardPage(context: AdminRenderContext, cards: AdminDashboardCard[], metrics: AdminDashboardMetrics | null, businessCards?: AdminBusinessCardView[]): string;
4591
4836
  /** A filter control rendered above the list view. */
4592
4837
  interface AdminFilterView {
4593
4838
  /** Column key the control filters on. */
@@ -4658,6 +4903,12 @@ interface AdminListView {
4658
4903
  exportCsvUrl: string;
4659
4904
  /** URL exporting the current result set as JSON. */
4660
4905
  exportJsonUrl: string;
4906
+ /** Saved-preset tabs rendered above the table. Empty hides the strip. */
4907
+ lenses: {
4908
+ label: string;
4909
+ url: string;
4910
+ active: boolean;
4911
+ }[];
4661
4912
  }
4662
4913
  /**
4663
4914
  * Render the paginated list view, with its search box, filters and sortable
@@ -4668,6 +4919,33 @@ interface AdminListView {
4668
4919
  * @returns The full page.
4669
4920
  */
4670
4921
  declare function renderListPage(context: AdminRenderContext, view: AdminListView): string;
4922
+ /** One entry in the detail view's change timeline. */
4923
+ interface AdminAuditEntryView {
4924
+ /** The mutation kind (`create` / `update` / `delete`). */
4925
+ action: string;
4926
+ /** When it happened, already formatted. */
4927
+ at: string;
4928
+ /** Who did it — a resolved display name, or the raw actor id. */
4929
+ actor: string;
4930
+ /** The per-field diff. */
4931
+ changes: {
4932
+ field: string;
4933
+ before: string;
4934
+ after: string;
4935
+ }[];
4936
+ /** Extra metadata the writer recorded, as JSON text, or `null`. */
4937
+ context: string | null;
4938
+ }
4939
+ /** The "who and when" panel below a record's fields. */
4940
+ interface AdminAuditView {
4941
+ /** Timestamp and actor rows, already resolved and formatted. */
4942
+ fields: {
4943
+ label: string;
4944
+ value: string;
4945
+ }[];
4946
+ /** The change timeline, newest first. Empty when there is none to show. */
4947
+ history: AdminAuditEntryView[];
4948
+ }
4671
4949
  /** The view model the detail page renders. */
4672
4950
  interface AdminDetailView {
4673
4951
  /** Singular display name. */
@@ -4685,6 +4963,8 @@ interface AdminDetailView {
4685
4963
  editUrl: string | null;
4686
4964
  /** URL the delete form posts to, or `null` when deletion is disabled. */
4687
4965
  deleteUrl: string | null;
4966
+ /** The audit panel, or `null` when the model carries no audit columns. */
4967
+ audit: AdminAuditView | null;
4688
4968
  }
4689
4969
  /**
4690
4970
  * Render the single-record detail view.
@@ -4774,6 +5054,11 @@ interface AdminRouterOptions {
4774
5054
  * click on a large table from becoming an outage.
4775
5055
  */
4776
5056
  exportMaxRows?: number;
5057
+ /**
5058
+ * Granular access control layered on top of the `AdminModel` flags. Omitted
5059
+ * lets every signed-in operator do whatever those flags allow.
5060
+ */
5061
+ accessPolicy?: AdminAccessPolicy;
4777
5062
  }
4778
5063
  /**
4779
5064
  * Build the admin panel router.
@@ -6555,6 +6840,6 @@ declare function createTestDatabase(models: readonly ModelClass[]): TestDatabase
6555
6840
  declare function withTestDatabase<T>(models: readonly ModelClass[], fn: (db: TestDatabase) => Promise<T>): Promise<T>;
6556
6841
 
6557
6842
  /** The installed SDK version. Single source of truth for the barrel + CLI. */
6558
- declare const VERSION = "0.25.0";
6843
+ declare const VERSION = "0.26.0";
6559
6844
 
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 };
6845
+ export { ADMIN_CSS, type ActivationInput, ActivationService, type ActivationServiceOptions, type ActivationStore, type AdminAccessPolicy, type AdminAction, type AdminActionCategory, type AdminActionContext, type AdminActionHandler, type AdminActionOptions, type AdminActionResult, type AdminAuditEntryView, type AdminAuditView, type AdminAuthBackend, type AdminAutomapOptions, type AdminBusinessCardView, 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 AdminLens, type AdminLensOptions, type AdminListView, type AdminMessage, type AdminMfaVerifier, AdminModel, type AdminModelOptions, type AdminNavEntry, AdminPermission, 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 CardCompute, type CardData, 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 MetricCard, type MetricPartition, type MetricTrend, type MetricValue, 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, adminLens, 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, metricCard, mfaChallengeSchema, mfaCodeSchema, mfaEnrollResponseSchema, minioSettingsShape, modifyDict, mountOpenApiJson, mountRedoc, mountSwaggerUi, nonEmptyStrField, nonNegativeFloatField, nonNegativeIntField, normalizeCep, normalizeCnpj, normalizeCpf, normalizeCpfCnpj, normalizePhoneBr, normalizeUf, notFoundHandler, onlyDigits, paginationFilterSchema, paginationSchema, parseAcceptLanguage, parseCookies, parseFormBody, partitionTotal, 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, trendDirection, trendPercent, ufField, updatedByColumn, uploadSettingsShape, userPublicSchema, utcnow, validateTwilioSignature, verifyOpaqueToken, webPushKeysSchema, webPushPayloadSchema, webPushSettingsShape, webPushSubscriptionSchema, webSocketSettingsShape, widgetForColumn, withTestDatabase, wrapWithSlowQueryLog, wsEnvelopeSchema };