@dyrected/core 2.9.0 → 2.10.1

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.
@@ -162,12 +162,24 @@ interface AdminDashboardComponentSlots {
162
162
  beforeDashboard?: string[];
163
163
  afterDashboard?: string[];
164
164
  }
165
+ /** Ordered custom component keys rendered around an operational view's content. */
166
+ interface CollectionViewComponentSlots {
167
+ beforeViewHeader?: string[];
168
+ afterViewHeader?: string[];
169
+ beforeViewContent?: string[];
170
+ afterViewContent?: string[];
171
+ }
165
172
  /** Ordered custom component keys rendered around a collection's list content. */
166
173
  interface CollectionListComponentSlots {
167
174
  beforeList?: string[];
168
175
  beforeListTable?: string[];
169
176
  afterListTable?: string[];
170
177
  afterList?: string[];
178
+ beforeViewHeader?: string[];
179
+ afterViewHeader?: string[];
180
+ beforeViewContent?: string[];
181
+ afterViewContent?: string[];
182
+ collectionView?: CollectionViewComponentSlots;
171
183
  }
172
184
  /**
173
185
  * Branding and metadata options for the Dyrected Admin UI.
@@ -870,6 +882,22 @@ interface CountOperation {
870
882
  count: "*";
871
883
  where?: Record<string, unknown>;
872
884
  }
885
+ /**
886
+ * A `countDistinct` aggregate operation that counts the number of unique
887
+ * non-null values for a specific field.
888
+ */
889
+ interface DistinctCountOperation {
890
+ countDistinct: string;
891
+ where?: Record<string, unknown>;
892
+ }
893
+ /**
894
+ * A `distinct` aggregate operation that retrieves the unique values
895
+ * (or unique values with item counts) for a specific field.
896
+ */
897
+ interface DistinctValuesOperation {
898
+ distinct: string;
899
+ where?: Record<string, unknown>;
900
+ }
873
901
  /**
874
902
  * A `sum`, `avg`, `min`, or `max` aggregate operation on a named field.
875
903
  *
@@ -886,9 +914,9 @@ interface NumericOperation {
886
914
  where?: Record<string, unknown>;
887
915
  }
888
916
  /**
889
- * A single named aggregate request — either a count or a numeric operation.
917
+ * A single named aggregate request — either a count, distinct count, distinct values, or numeric operation.
890
918
  */
891
- type AggregateOperation = CountOperation | NumericOperation;
919
+ type AggregateOperation = CountOperation | DistinctCountOperation | DistinctValuesOperation | NumericOperation;
892
920
  /**
893
921
  * The map of named aggregate operations sent in a single aggregate request.
894
922
  *
@@ -896,6 +924,8 @@ type AggregateOperation = CountOperation | NumericOperation;
896
924
  * ```ts
897
925
  * {
898
926
  * totalSubmitted: { count: "*" },
927
+ * uniqueGuests: { countDistinct: "email" },
928
+ * availableSizes: { distinct: "asoebiSize" },
899
929
  * totalAsoebiYards: { sum: "asoebiYards", cast: "number", where: { wantsAsoebi: { equals: true } } },
900
930
  * }
901
931
  * ```
@@ -909,153 +939,447 @@ interface AggregateArgs {
909
939
  collection: string;
910
940
  /** Named aggregate operations to compute. */
911
941
  aggregates: AggregateInput;
942
+ /** Optional field to group the aggregates by. */
943
+ groupBy?: string;
912
944
  }
913
945
  /**
914
946
  * The result returned by `DatabaseAdapter.aggregate`.
915
947
  *
916
- * Every named key maps to a `number | null`.
917
- * `null` is returned when no documents matched the aggregate's `where`
918
- * (applicable to `sum`, `avg`, `min`, `max`).
919
- * `count` also returns `null` only if the database errors — it normally
920
- * returns `0` for an empty match set.
948
+ * For scalar aggregates, every named key maps to a `number | null` or `any[]` (for distinct).
949
+ * When `groupBy` is used, returns a breakdown per group.
921
950
  */
922
- type AggregateResult = Record<string, number | null>;
951
+ type AggregateResult = Record<string, any>;
923
952
  /**
924
953
  * Derives the typed result shape from an `AggregateInput`.
925
- * Every named key maps to `number | null`.
926
- *
927
- * @example
928
- * ```ts
929
- * type Input = { totalSubmitted: CountOperation; totalYards: NumericOperation };
930
- * type Result = InferAggregateResult<Input>;
931
- * // => { totalSubmitted: number | null; totalYards: number | null }
932
- * ```
933
954
  */
934
955
  type InferAggregateResult<T extends AggregateInput> = {
935
- [K in keyof T]: number | null;
956
+ [K in keyof T]: any;
936
957
  };
937
958
 
959
+ /**
960
+ * Dyrected Where Clause DSL — shared query language across all database adapters.
961
+ *
962
+ * Adapters translate this DSL into their native format:
963
+ * - SQL adapters (SQLite, Postgres, MySQL): use parseSqlWhere()
964
+ * - MongoDB adapter: use parseMongoWhere()
965
+ * - Future adapters: implement their own translator against WhereClause
966
+ *
967
+ * Exhaustive operator handling is enforced at compile time via `assertNever`,
968
+ * so adding a new operator without handling it will produce a TypeScript error
969
+ * in every adapter translator.
970
+ */
971
+ type WhereOperatorName = 'equals' | 'not_equals' | 'in' | 'not_in' | 'gt' | 'greater_than' | 'gte' | 'greater_than_equal' | 'greater_than_or_equal' | 'lt' | 'less_than' | 'lte' | 'less_than_equal' | 'less_than_or_equal' | 'contains' | 'like' | 'starts_with' | 'exists';
972
+ type WhereOperator = {
973
+ equals: any;
974
+ } | {
975
+ not_equals: any;
976
+ } | {
977
+ in: any[];
978
+ } | {
979
+ not_in: any[];
980
+ } | {
981
+ gt: any;
982
+ } | {
983
+ greater_than: any;
984
+ } | {
985
+ gte: any;
986
+ } | {
987
+ greater_than_equal: any;
988
+ } | {
989
+ greater_than_or_equal: any;
990
+ } | {
991
+ lt: any;
992
+ } | {
993
+ less_than: any;
994
+ } | {
995
+ lte: any;
996
+ } | {
997
+ less_than_equal: any;
998
+ } | {
999
+ less_than_or_equal: any;
1000
+ } | {
1001
+ contains: string;
1002
+ } | {
1003
+ like: string;
1004
+ } | {
1005
+ starts_with: string;
1006
+ } | {
1007
+ exists: boolean;
1008
+ };
1009
+ /** Top-level where clause. Fields map to operator objects or shorthand scalar values. */
1010
+ type WhereClause = {
1011
+ [field: string]: WhereOperator | any;
1012
+ OR?: WhereClause[];
1013
+ or?: WhereClause[];
1014
+ AND?: WhereClause[];
1015
+ and?: WhereClause[];
1016
+ };
1017
+ interface SqlWhereResult {
1018
+ sql: string;
1019
+ params: any[];
1020
+ }
1021
+ /**
1022
+ * Translates a WhereClause into a parameterized SQL WHERE fragment.
1023
+ *
1024
+ * @param where The Dyrected where DSL object
1025
+ * @param getJsonField Returns the SQL expression for a JSON-stored field (dialect-specific):
1026
+ * SQLite: (f) => `json_extract(data, '$.${f}')`
1027
+ * Postgres: (f) => `data->>'${f}'`
1028
+ * MySQL: (f) => `JSON_UNQUOTE(JSON_EXTRACT(data, '$.${f}'))`
1029
+ * @param placeholder '?' for SQLite/MySQL, 'pg' for auto-incrementing Postgres $1/$2/…
1030
+ */
1031
+ declare function parseSqlWhere(where: WhereClause, getJsonField: (field: string) => string, placeholder?: '?' | 'pg',
1032
+ /**
1033
+ * SQL keyword used for `contains`/`starts_with`. Postgres `LIKE` is
1034
+ * case-sensitive, so the Postgres adapter defaults to `'ILIKE'` to keep substring
1035
+ * matching case-insensitive like SQLite and MySQL.
1036
+ */
1037
+ likeOperator?: 'LIKE' | 'ILIKE'): SqlWhereResult;
1038
+ /**
1039
+ * Translates a WhereClause into a MongoDB filter object.
1040
+ * Handles nested OR/AND via $or/$and, and all operators via $eq/$in/$gt etc.
1041
+ */
1042
+ declare function parseMongoWhere(where: WhereClause): Record<string, any>;
1043
+
1044
+ /**
1045
+ * Custom component slots rendered around an operational view's content.
1046
+ */
1047
+ type ViewComponentSlots = CollectionViewComponentSlots;
1048
+ /**
1049
+ * Supported layout engines for operational views in the Dyrected Admin UI:
1050
+ * - `'table'`: The workhorse — column sorting, search, faceted filters, and bulk actions.
1051
+ * - `'spreadsheet'`: Inline-editable matrix with batch saving (`Save changes` / `Discard`).
1052
+ * - `'kanban'`: Interactive card board grouped by status or category with drag-and-drop.
1053
+ * - `'calendar'`: Event schedule grid plotting records across month/week/day views by date.
1054
+ * - `'gantt'`: Timeline bars plotted across start and end dates.
1055
+ * - `'cards'`: Visual image/thumbnail gallery grid.
1056
+ */
938
1057
  type ViewLayout = 'table' | 'spreadsheet' | 'kanban' | 'calendar' | 'gantt' | 'cards';
1058
+ /**
1059
+ * Scope and placement for an operational view action:
1060
+ * - `'row'`: Renders as an inline action button on each document/row.
1061
+ * - `'bulk'`: Appears in the floating bulk action bar when one or more rows are selected.
1062
+ * - `'header'`: Renders as a primary action button in the view header.
1063
+ */
939
1064
  type ActionType = 'row' | 'bulk' | 'header';
940
1065
  /**
941
- * Toggles for the built-in document operations an operational view surfaces
942
- * (View/Edit/Duplicate/Delete/Export-selected). All default to enabled;
943
- * set any to `false` to hide that operation for the view.
1066
+ * Toggles for the built-in document operations an operational view surfaces.
1067
+ * All default to enabled (`true`). Set any to `false` to hide that operation.
1068
+ *
1069
+ * @example
1070
+ * ```ts
1071
+ * features: {
1072
+ * delete: false, // Prevent deleting records from this view
1073
+ * exportSelected: true, // Enable CSV export for checked rows
1074
+ * }
1075
+ * ```
944
1076
  */
945
1077
  interface ViewActionFeatures {
1078
+ /** Enables the "View" preview / read-only drawer button. Defaults to `true`. */
946
1079
  view?: boolean;
1080
+ /** Enables the "Edit" document form link. Defaults to `true`. */
947
1081
  edit?: boolean;
1082
+ /** Enables the "Duplicate" record action. Defaults to `true`. */
948
1083
  duplicate?: boolean;
1084
+ /** Enables the "Delete" record action. Defaults to `true`. */
949
1085
  delete?: boolean;
1086
+ /** Enables the "Export selected" CSV action in the bulk action bar. Defaults to `true`. */
950
1087
  exportSelected?: boolean;
951
1088
  }
1089
+ /**
1090
+ * Color palette options for metric cards:
1091
+ * `'purple' | 'emerald' | 'amber' | 'rose' | 'blue' | 'indigo' | 'cyan' | 'orange'`
1092
+ */
952
1093
  type MetricColor = 'purple' | 'emerald' | 'amber' | 'rose' | 'blue' | 'indigo' | 'cyan' | 'orange' | string;
1094
+ /**
1095
+ * A sub-metric breakdown item displayed in the compact footer of a metric card.
1096
+ *
1097
+ * @example
1098
+ * ```ts
1099
+ * {
1100
+ * label: "Pending",
1101
+ * aggregates: {
1102
+ * checkedIn: { count: "*", where: { checkedIn: { equals: true } } },
1103
+ * attending: { count: "*", where: { attending: { equals: true } } },
1104
+ * },
1105
+ * expression: "aggregates.attending - aggregates.checkedIn",
1106
+ * }
1107
+ * ```
1108
+ */
953
1109
  interface ViewSubMetric {
1110
+ /** Short label for the sub-metric (e.g. "Pending", "Collected"). */
954
1111
  label: string;
1112
+ /** Single database aggregate operation. */
955
1113
  aggregate?: AggregateOperation;
1114
+ /** Map of named aggregate operations referenced in `expression` as `aggregates.key`. */
956
1115
  aggregates?: Record<string, AggregateOperation>;
1116
+ /** JEXL math formula evaluated over `value` for a single aggregate (e.g. `"value * 100"`). */
957
1117
  transform?: string;
1118
+ /** JEXL math formula evaluated over `aggregates` (e.g. `"aggregates.a - aggregates.b"`). */
958
1119
  expression?: string;
1120
+ /** Display formatter: `'currency' | 'number' | 'percent'`. */
959
1121
  format?: 'currency' | 'number' | 'percent' | string;
1122
+ /** 3-letter currency code (e.g. `"USD"`, `"NGN"`, `"EUR"`) used when `format: "currency"`. */
960
1123
  currency?: string;
961
1124
  }
1125
+ /**
1126
+ * Configuration for a KPI summary card rendered at the top of an operational view.
1127
+ *
1128
+ * All aggregations run directly on the database engine for maximum performance.
1129
+ *
1130
+ * @example
1131
+ * ```ts
1132
+ * {
1133
+ * label: "Total Revenue",
1134
+ * color: "emerald",
1135
+ * aggregate: { sum: "amount", cast: "number", where: { status: "paid" } },
1136
+ * format: "currency",
1137
+ * currency: "USD",
1138
+ * }
1139
+ * ```
1140
+ */
962
1141
  interface ViewMetric {
1142
+ /** Title displayed on the metric card header. */
963
1143
  label: string;
1144
+ /** Accent color for the card's visual indicator. */
964
1145
  color?: MetricColor;
1146
+ /** Unit badge shown alongside the numeric value (e.g. `"Guests"`, `"Orders"`, `"Tables"`). */
965
1147
  unit?: string;
1148
+ /** Single database aggregate operation (`count`, `distinctCount`, `sum`, `avg`, `min`, `max`). */
966
1149
  aggregate?: AggregateOperation;
1150
+ /** Map of named aggregate operations referenced in `expression` as `aggregates.key`. */
967
1151
  aggregates?: Record<string, AggregateOperation>;
1152
+ /** JEXL math formula evaluated over `value` for a single aggregate (e.g. `"value * 25000"`). */
968
1153
  transform?: string;
1154
+ /** JEXL math formula evaluated over `aggregates` (e.g. `"(aggregates.paid / aggregates.total) * 100"`). */
969
1155
  expression?: string;
1156
+ /** Display formatter: `'currency' | 'number' | 'percent'`. */
970
1157
  format?: 'currency' | 'number' | 'percent' | string;
1158
+ /** 3-letter currency code (e.g. `"USD"`, `"NGN"`, `"EUR"`) used when `format: "currency"`. */
971
1159
  currency?: string;
1160
+ /** Optional secondary breakdown items shown in the card footer. */
972
1161
  subMetrics?: ViewSubMetric[];
973
1162
  }
1163
+ /**
1164
+ * Complete configuration for a tailored operational view.
1165
+ */
974
1166
  interface ViewConfig {
1167
+ /** Stable URL slug for the view (`/collections/:slug/views/:viewSlug`). */
975
1168
  slug: string;
1169
+ /** Human-readable title displayed in the sidebar navigation and view header. */
976
1170
  label: string;
1171
+ /** Lucide icon name (e.g. `"UserCheck"`, `"Calendar"`, `"Shirt"`, `"TableProperties"`). */
977
1172
  icon?: string;
1173
+ /** Layout engine to render: `'table' | 'spreadsheet' | 'kanban' | 'calendar' | 'gantt' | 'cards'`. Defaults to `'table'`. */
978
1174
  layout?: ViewLayout;
979
- filter?: Record<string, any> | string;
1175
+ /** Base query filter applied before user toolbar filters (e.g. `{ attending: { equals: true } }` or JEXL string). */
1176
+ filter?: WhereClause | string;
1177
+ /** Field name used to organize records into kanban columns or collapsible grouped sections in table, cards, and spreadsheet. */
980
1178
  groupBy?: string;
1179
+ /** Field name containing the ISO date string for calendar placement. Required when `layout: 'calendar'`. */
981
1180
  dateField?: string;
1181
+ /** Field name for the start date in timeline/gantt views. Required when `layout: 'gantt'`. */
982
1182
  startDateField?: string;
1183
+ /** Field name for the end date in timeline/gantt views. Required when `layout: 'gantt'`. */
983
1184
  endDateField?: string;
1185
+ /** Field names to show in this view, in order. If omitted, Dyrected infers default display fields. */
984
1186
  columns?: string[];
1187
+ /** Default sorting rule when entering the view. */
985
1188
  sort?: {
986
1189
  field: string;
987
1190
  direction: 'asc' | 'desc';
988
1191
  };
1192
+ /** Custom workflow actions available in this view. */
989
1193
  actions?: ActionConfig[];
990
1194
  /** Toggles built-in operations (view/edit/duplicate/delete/export). */
991
1195
  features?: ViewActionFeatures;
992
1196
  /**
993
- * Explicit display order for actions — built-in names ("view", "edit",
994
- * "duplicate", "delete") and/or custom action names. Unlisted actions
995
- * append in their default order.
1197
+ * Explicit display order for action buttons — mixing custom action names and built-in names
1198
+ * (`"view"`, `"edit"`, `"duplicate"`, `"delete"`). Unlisted actions append in default order.
996
1199
  */
997
1200
  actionOrder?: string[];
1201
+ /** KPI summary cards rendered in the hero row above the view. */
998
1202
  metrics?: ViewMetric[];
1203
+ /** Role-based access rules controlling who can see or use this view. */
999
1204
  access?: AccessConfig;
1000
1205
  }
1001
- interface ActionConfig {
1206
+ /**
1207
+ * An operational workflow action that can mutate data or trigger server logic.
1208
+ */
1209
+ interface ActionConfig<TDoc extends Record<string, unknown> = Record<string, unknown>> {
1210
+ /** Unique action identifier (e.g. `"checkIn"`, `"markPaid"`). */
1002
1211
  name: string;
1212
+ /** Button label displayed in the UI. */
1003
1213
  label: string;
1214
+ /** Optional custom label for the modal submit button (defaults to "Run" or "Confirm"). */
1215
+ submitLabel?: string;
1216
+ /** Lucide icon name for the button (e.g. `"UserCheck"`, `"CheckCircle"`). */
1004
1217
  icon?: string;
1218
+ /** Action placement: `'row'` (per-row), `'bulk'` (multi-row selection bar), or `'header'` (view header). Defaults to `'row'`. */
1005
1219
  type?: ActionType;
1220
+ /** Optional confirmation prompt shown before executing (e.g. `"Confirm guest check-in at the door?"`). */
1006
1221
  confirm?: string;
1222
+ /** Optional interactive modal form fields prompting the user for input before executing. */
1007
1223
  fields?: Field[];
1008
- mutation?: Record<string, any>;
1009
- handler?: (context: ActionContext) => Promise<any>;
1224
+ /** Declarative database mutation applied to targeted documents (e.g. `{ checkedIn: true, checkedInAt: "now()" }`). */
1225
+ mutation?: Partial<TDoc> | Record<string, unknown>;
1226
+ /** Self-hosted server handler function executed when the action is triggered. */
1227
+ handler?: (context: ActionContext<TDoc>) => Promise<unknown> | unknown;
1228
+ /** Role-based access rules controlling who can trigger this action. */
1010
1229
  access?: AccessConfig;
1011
1230
  }
1012
- interface ActionContext {
1013
- doc: Record<string, unknown>;
1014
- docs: Record<string, unknown>[];
1231
+ /**
1232
+ * Context passed to an action's server handler function.
1233
+ */
1234
+ interface ActionContext<TDoc extends Record<string, unknown> = Record<string, unknown>> {
1235
+ /** The target document (for row actions). */
1236
+ doc: TDoc;
1237
+ /** All targeted documents (for bulk actions). */
1238
+ docs: TDoc[];
1239
+ /** The authenticated acting user, if available. */
1015
1240
  user: Record<string, unknown> | null;
1241
+ /** User inputs submitted via the action's modal form fields. */
1016
1242
  input: Record<string, unknown>;
1243
+ /** The collection configuration object. */
1017
1244
  collection: Record<string, unknown>;
1018
1245
  }
1246
+ /**
1247
+ * Role-based access control rules for a view or action.
1248
+ */
1019
1249
  interface AccessConfig {
1020
1250
  read?: AccessRule<any>;
1021
1251
  create?: AccessRule<any>;
1022
1252
  update?: AccessRule<any>;
1023
1253
  delete?: AccessRule<any>;
1024
1254
  }
1255
+ /**
1256
+ * Options for defining an operational view with `defineView`.
1257
+ *
1258
+ * @example
1259
+ * ```ts
1260
+ * export const attendingGuests = defineView({
1261
+ * slug: "attending-guests",
1262
+ * label: "Attending Guests",
1263
+ * icon: "UserCheck",
1264
+ * layout: "table",
1265
+ * groupBy: "tableNumber",
1266
+ * filter: { attending: { equals: true } },
1267
+ * columns: ["name", "email", "guestCount", "checkedIn"],
1268
+ * sort: { field: "name", direction: "asc" },
1269
+ * });
1270
+ * ```
1271
+ */
1025
1272
  interface DefineViewOptions {
1273
+ /** Stable URL slug for the view (`/collections/:slug/views/:viewSlug`). */
1026
1274
  slug: string;
1275
+ /** Human-readable title displayed in the sidebar navigation and view header. */
1027
1276
  label: string;
1277
+ /** Lucide icon name (e.g. `"UserCheck"`, `"Calendar"`, `"Shirt"`, `"TableProperties"`). */
1028
1278
  icon?: string;
1279
+ /** Layout engine to render: `'table' | 'spreadsheet' | 'kanban' | 'calendar' | 'gantt' | 'cards'`. Defaults to `'table'`. */
1029
1280
  layout?: ViewLayout;
1281
+ /** Base query filter applied before user toolbar filters (e.g. `{ attending: { equals: true } }` or JEXL string). */
1030
1282
  filter?: Record<string, any> | string;
1283
+ /** Field name used to organize records into kanban columns or collapsible grouped sections in table, cards, and spreadsheet. */
1031
1284
  groupBy?: string;
1285
+ /** Field name containing the ISO date string for calendar placement. Required when `layout: 'calendar'`. */
1032
1286
  dateField?: string;
1287
+ /** Field name for the start date in timeline/gantt views. Required when `layout: 'gantt'`. */
1033
1288
  startDateField?: string;
1289
+ /** Field name for the end date in timeline/gantt views. Required when `layout: 'gantt'`. */
1034
1290
  endDateField?: string;
1291
+ /** Field names to show in this view, in order. If omitted, Dyrected infers default display fields. */
1035
1292
  columns?: string[];
1293
+ /** Default sorting rule when entering the view. */
1036
1294
  sort?: {
1037
1295
  field: string;
1038
1296
  direction: 'asc' | 'desc';
1039
1297
  };
1298
+ /** Custom workflow actions available in this view. */
1040
1299
  actions?: ActionConfig[];
1300
+ /** Toggles built-in operations (view/edit/duplicate/delete/export). */
1041
1301
  features?: ViewActionFeatures;
1302
+ /**
1303
+ * Explicit display order for action buttons — mixing custom action names and built-in names
1304
+ * (`"view"`, `"edit"`, `"duplicate"`, `"delete"`). Unlisted actions append in default order.
1305
+ */
1042
1306
  actionOrder?: string[];
1307
+ /** KPI summary cards rendered in the hero row above the view. */
1043
1308
  metrics?: ViewMetric[];
1309
+ /** Custom component slots rendered around this operational view. */
1310
+ components?: ViewComponentSlots;
1311
+ /** Role-based access rules controlling who can see or use this view. */
1044
1312
  access?: AccessConfig;
1045
1313
  }
1046
- interface DefineActionOptions {
1314
+ /**
1315
+ * Options for defining a custom workflow action with `defineAction`.
1316
+ *
1317
+ * @example
1318
+ * ```ts
1319
+ * export const checkInAction = defineAction({
1320
+ * name: "checkIn",
1321
+ * label: "Check In",
1322
+ * icon: "UserCheck",
1323
+ * type: "row",
1324
+ * confirm: "Confirm guest check-in at the door?",
1325
+ * mutation: { checkedIn: true, checkedInAt: "now()" },
1326
+ * });
1327
+ * ```
1328
+ */
1329
+ interface DefineActionOptions<TDoc extends Record<string, unknown> = Record<string, unknown>> {
1330
+ /** Unique action identifier (e.g. `"checkIn"`, `"markPaid"`). */
1047
1331
  name: string;
1332
+ /** Button label displayed in the UI. */
1048
1333
  label: string;
1334
+ /** Lucide icon name for the button (e.g. `"UserCheck"`, `"CheckCircle"`). */
1049
1335
  icon?: string;
1336
+ /** Action placement: `'row'` (per-row), `'bulk'` (multi-row selection bar), or `'header'` (view header). Defaults to `'row'`. */
1050
1337
  type?: ActionType;
1338
+ /** Optional confirmation prompt shown before executing (e.g. `"Confirm guest check-in at the door?"`). */
1051
1339
  confirm?: string;
1340
+ /** Optional interactive modal form fields prompting the user for input before executing. */
1052
1341
  fields?: Field[];
1053
- mutation?: Record<string, any>;
1054
- handler?: (context: ActionContext) => Promise<any>;
1342
+ /** Declarative database mutation applied to targeted documents (e.g. `{ checkedIn: true, checkedInAt: "now()" }`). */
1343
+ mutation?: Partial<TDoc> | Record<string, unknown>;
1344
+ /** Self-hosted server handler function executed when the action is triggered. */
1345
+ handler?: (context: ActionContext<TDoc>) => Promise<unknown> | unknown;
1346
+ /** Role-based access rules controlling who can trigger this action. */
1055
1347
  access?: AccessConfig;
1056
1348
  }
1057
- declare function defineView(config: DefineViewOptions): ViewConfig;
1058
- declare function defineAction(config: DefineActionOptions): ActionConfig;
1349
+ /**
1350
+ * Defines a typed operational view for a collection.
1351
+ *
1352
+ * @example
1353
+ * ```ts
1354
+ * export const attendingGuests = defineView({
1355
+ * slug: "attending-guests",
1356
+ * label: "Attending Guests",
1357
+ * icon: "UserCheck",
1358
+ * layout: "table",
1359
+ * groupBy: "tableNumber",
1360
+ * filter: { attending: { equals: true } },
1361
+ * columns: ["name", "email", "guestCount", "checkedIn"],
1362
+ * sort: { field: "name", direction: "asc" },
1363
+ * });
1364
+ * ```
1365
+ */
1366
+ declare function defineView<const T extends DefineViewOptions>(config: T): T;
1367
+ /**
1368
+ * Defines a custom workflow action for an operational view.
1369
+ *
1370
+ * @example
1371
+ * ```ts
1372
+ * export const markPaidAction = defineAction({
1373
+ * name: "markPaid",
1374
+ * label: "Mark Paid",
1375
+ * icon: "DollarSign",
1376
+ * type: "bulk",
1377
+ * confirm: "Mark selected orders as paid?",
1378
+ * mutation: { status: "paid" },
1379
+ * });
1380
+ * ```
1381
+ */
1382
+ declare function defineAction<const T extends DefineActionOptions>(config: T): T;
1059
1383
 
1060
1384
  /**
1061
1385
  * Configures account lockout behavior for an auth-enabled collection.
@@ -1357,6 +1681,11 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
1357
1681
  * Collections with the same `group` are visually grouped together.
1358
1682
  */
1359
1683
  group?: string;
1684
+ /**
1685
+ * Slug of the view to render by default when navigating to `/collections/:slug`.
1686
+ * If not specified, defaults to the view with `default: true` or the all-records table view.
1687
+ */
1688
+ defaultView?: string;
1360
1689
  /** If `true`, this collection is not shown in the Admin UI sidebar. */
1361
1690
  hidden?: boolean;
1362
1691
  /** If `false`, disables the filter UI entirely for this collection. Defaults to `true`. */
@@ -1411,12 +1740,70 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
1411
1740
  urlPattern?: string;
1412
1741
  };
1413
1742
  /**
1414
- * Custom detail view layout configuration for the Admin UI.
1415
- */
1416
- detail?: DetailSchema<TDoc> | false;
1417
- /**
1418
- * Operational views for this collection.
1419
- * Each view provides a tailored workspace for a specific job or workflow.
1743
+ * Detail view layout configuration for the Admin UI.
1744
+ *
1745
+ * By default, collections are **Edit-First** (`detail: false`). Clicking a record in the
1746
+ * table or cards view navigates directly to the editing form with Live Preview.
1747
+ *
1748
+ * Set to `true` to enable the automatic read-only summary layout, or provide a `DetailSchema`
1749
+ * array using display helpers (`displaySection`, `displayField`, `displayTabs`, etc.) for a
1750
+ * custom operational dashboard layout.
1751
+ *
1752
+ * @default false
1753
+ * @example
1754
+ * ```ts
1755
+ * // Enable automatic summary detail view
1756
+ * detail: true
1757
+ *
1758
+ * // Or define a custom operational detail view
1759
+ * detail: [
1760
+ * displaySection("Customer Overview", [
1761
+ * displayField("name", { span: 8 }),
1762
+ * displayField("status", { span: 4, display: "badge" }),
1763
+ * ]),
1764
+ * ]
1765
+ * ```
1766
+ */
1767
+ detail?: DetailSchema<TDoc> | boolean;
1768
+ /**
1769
+ * Slug of the operational view to render by default when navigating to `/collections/:slug`.
1770
+ *
1771
+ * When set:
1772
+ * 1. Navigating to `/collections/:slug` automatically redirects to `/collections/:slug/views/:defaultView`.
1773
+ * 2. The main collection link in the sidebar directly opens this default view.
1774
+ * 3. The sidebar submenu cleanly lists only your defined views without showing a generic `All [Collection]` item.
1775
+ *
1776
+ * @example
1777
+ * ```ts
1778
+ * export const GuestResponses = defineCollection({
1779
+ * slug: "guest-responses",
1780
+ * defaultView: "attending-guests",
1781
+ * views: [attendingGuests, seatingMatrix],
1782
+ * fields: [...],
1783
+ * });
1784
+ * ```
1785
+ */
1786
+ defaultView?: string;
1787
+ /**
1788
+ * Tailored operational workspaces for this collection (`table`, `spreadsheet`, `kanban`, `calendar`, `cards`, `gantt`).
1789
+ * Each view provides curated columns, filters, metrics, and workflow buttons for a specific job.
1790
+ *
1791
+ * @example
1792
+ * ```ts
1793
+ * views: [
1794
+ * defineView({
1795
+ * slug: "attending-guests",
1796
+ * label: "Attending Guests",
1797
+ * icon: "UserCheck",
1798
+ * layout: "table",
1799
+ * groupBy: "tableNumber",
1800
+ * filter: { attending: { equals: true } },
1801
+ * columns: ["name", "email", "guestCount", "checkedIn"],
1802
+ * }),
1803
+ * ]
1804
+ * ```
1805
+ *
1806
+ * @see {@link https://dyrected.com/docs/model-content/operational-views/overview Operational views overview}
1420
1807
  */
1421
1808
  views?: ViewConfig[];
1422
1809
  }
@@ -1503,9 +1890,17 @@ interface GlobalConfig<TDoc extends object = Record<string, unknown>> {
1503
1890
  */
1504
1891
  initialData?: Partial<TDoc>;
1505
1892
  /**
1506
- * Custom detail view layout configuration for the Admin UI.
1893
+ * Detail view layout configuration for the Admin UI.
1894
+ *
1895
+ * By default, globals are **Edit-First** (`detail: false`). Clicking the global in the
1896
+ * sidebar navigates directly to the editing form.
1897
+ *
1898
+ * Set to `true` to enable the automatic read-only summary layout, or provide a `DetailSchema`
1899
+ * array for a custom operational dashboard layout.
1900
+ *
1901
+ * @default false
1507
1902
  */
1508
- detail?: DetailSchema<TDoc> | false;
1903
+ detail?: DetailSchema<TDoc> | boolean;
1509
1904
  }
1510
1905
 
1511
1906
  /**
@@ -2695,4 +3090,4 @@ interface DyrectedConfig<TUser extends AuthenticatedUser = AuthenticatedUser> {
2695
3090
  }>;
2696
3091
  }
2697
3092
 
2698
- export { type RadioField as $, type AdminAuthConfig as A, type Block as B, type CollectionConfig as C, type DyrectedConfig as D, type DetailText as E, type Field as F, type GlobalConfig as G, type HookRequestContext as H, type DetailSchema as I, type ArrayField as J, type BlocksField as K, type LifecycleEventName as L, type BooleanField as M, type AuthConfig as N, type AccessPolicyResolver as O, type PublicAdminAuthConfig as P, type DateField as Q, type DateTimeField as R, type EmailField as S, type IconField as T, type ImageField as U, type JoinField as V, type WorkflowConfig as W, type JsonField as X, type MultiSelectField as Y, type NumberField as Z, type ObjectField as _, type DeclarativeHookExpression as a, type DynamicOptionsResolver as a$, type RelationshipField as a0, type RichTextField as a1, type RowField as a2, type SelectField as a3, type TextField as a4, type TextareaField as a5, type TimeField as a6, type UrlField as a7, type AccessConfig as a8, type AccessFunction as a9, type BooleanFormat as aA, type CharacterLimitFieldAdmin as aB, type CharacterLimitFieldConfig as aC, type CollectionAfterChangeHook as aD, type CollectionAfterDeleteHook as aE, type CollectionAfterReadHook as aF, type CollectionAfterReadHookEntry as aG, type CollectionAfterTransitionHook as aH, type CollectionBeforeChangeHook as aI, type CollectionBeforeChangeHookEntry as aJ, type CollectionBeforeDeleteHook as aK, type CollectionBeforeReadHook as aL, type CollectionBeforeReadHookEntry as aM, type CollectionBeforeTransitionHook as aN, type CollectionListComponentSlots as aO, type CountOperation as aP, type CustomAdminAuthProvider as aQ, type DatabaseAdapter as aR, type DateFieldAdmin as aS, type DateFormat as aT, type DefineActionOptions as aU, type DefineViewOptions as aV, type DetailSpan as aW, type DisplayTone as aX, type DisplayVariant as aY, type DynamicOptionItem as aZ, type DynamicOptionsConfig as a_, type AccessFunctionArgs as aa, type AccessResult as ab, type AccessRule as ac, type ActionConfig as ad, type ActionContext as ae, type ActionType as af, type AdminAuthAccessResolution as ag, type AdminAuthClaimMapping as ah, type AdminAuthMember as ai, type AdminAuthProvider as aj, type AdminAuthProviderMembersConfig as ak, type AdminAuthProvisioningMode as al, type AdminAuthResolveAccessArgs as am, type AdminAuthResolvedIdentity as an, type AdminConfig as ao, type AdminDashboardComponentSlots as ap, type AdminIconName as aq, type AggregateArgs as ar, type AggregateCastType as as, type AggregateInput as at, type AggregateOperation as au, type AggregateResult as av, type BaseAdminAuthProvider as aw, type BaseFieldAdmin as ax, type BlockVariant as ay, type BooleanFieldAdmin as az, type AuthenticatedUser as b, type UrlLinkValue as b$, type DynamicOptionsResolverArgs as b0, type DyrectedLoggerConfig as b1, type DyrectedObservabilityConfig as b2, type EmailFieldAdmin as b3, type FieldAdminHooks as b4, type FieldAdminOnChangeHook as b5, type FieldAdminOnChangeHookArgs as b6, type FieldAdminOptionsHook as b7, type FieldAdminOptionsHookArgs as b8, type FieldAdminOptionsHookResult as b9, type LinkFormat as bA, type MetricColor as bB, type MultiSelectFieldAdmin as bC, type NamedAccessPolicy as bD, type NumberFieldAdmin as bE, type NumberFormat as bF, type NumberLimitFieldAdmin as bG, type NumberLimitFieldConfig as bH, type NumericOperation as bI, type OIDCAdminAuthProvider as bJ, type OptionFormat as bK, type PaginatedResult as bL, type PublicAdminAuthProvider as bM, type RadioFieldAdmin as bN, type RateLimitConfig as bO, type ReadonlyDatabaseAdapter as bP, type RichTextFeature as bQ, type RichTextFieldConfig as bR, type SelectFieldAdmin as bS, type StorageAdapter as bT, type TextFieldAdmin as bU, type TextFormat as bV, type TextareaFieldAdmin as bW, type TrustProxyConfig as bX, type TypedField as bY, type UploadConfig as bZ, type UrlFieldAdmin as b_, type FieldAfterReadHook as ba, type FieldAfterReadHookArgs as bb, type FieldBase as bc, type FieldBeforeChangeHook as bd, type FieldBeforeChangeHookArgs as be, type FieldHook as bf, type FieldHooks as bg, type FieldType as bh, type FileData as bi, type GlobalAfterChangeHook as bj, type GlobalAfterReadHook as bk, type GlobalAfterReadHookEntry as bl, type GlobalBeforeChangeHook as bm, type GlobalBeforeChangeHookEntry as bn, type GlobalBeforeReadHook as bo, type GlobalBeforeReadHookEntry as bp, type HeadingLevel as bq, type HookFunction as br, type IconFieldAdmin as bs, type ImageService as bt, type InferAggregateResult as bu, type JoinFieldAdmin as bv, type JsonFieldAdmin as bw, type JsonFormat as bx, LIFECYCLE_EVENT_NAMES as by, type LifecycleEventHandler as bz, type WorkflowTransition as c, type ViewActionFeatures as c0, type ViewConfig as c1, type ViewLayout as c2, type ViewMetric as c3, type ViewSubMetric as c4, type WordLimitFieldAdmin as c5, type WordLimitFieldConfig as c6, type WorkflowMetadata as c7, type WorkflowRole as c8, type WorkflowState as c9, type WorkflowTransitionContext as ca, defineAction as cb, defineView as cc, type LifecycleEvent as d, type BaseDocument as e, type DetailComputedOptions as f, type ComputedHandler as g, type DetailComputed as h, type DetailCustomOptions as i, type DetailCustom as j, type DetailDividerOptions as k, type DetailDivider as l, type DisplayFieldOptions as m, type DetailField as n, type DetailItem as o, type DetailGridOptions as p, type DetailGrid as q, type DetailRepeatOptions as r, type DetailRepeat as s, type DetailSectionOptions as t, type DetailSection as u, type DetailTabOptions as v, type DetailTab as w, type DetailTabsOptions as x, type DetailTabs as y, type DetailTextOptions as z };
3093
+ export { type RadioField as $, type AdminAuthConfig as A, type Block as B, type CollectionConfig as C, type DyrectedConfig as D, type DetailText as E, type Field as F, type GlobalConfig as G, type HookRequestContext as H, type DetailSchema as I, type ArrayField as J, type BlocksField as K, type LifecycleEventName as L, type BooleanField as M, type AuthConfig as N, type AccessPolicyResolver as O, type PublicAdminAuthConfig as P, type DateField as Q, type DateTimeField as R, type EmailField as S, type IconField as T, type ImageField as U, type JoinField as V, type WorkflowConfig as W, type JsonField as X, type MultiSelectField as Y, type NumberField as Z, type ObjectField as _, type DeclarativeHookExpression as a, type DistinctValuesOperation as a$, type RelationshipField as a0, type RichTextField as a1, type RowField as a2, type SelectField as a3, type TextField as a4, type TextareaField as a5, type TimeField as a6, type UrlField as a7, type AccessConfig as a8, type AccessFunction as a9, type BooleanFormat as aA, type CharacterLimitFieldAdmin as aB, type CharacterLimitFieldConfig as aC, type CollectionAfterChangeHook as aD, type CollectionAfterDeleteHook as aE, type CollectionAfterReadHook as aF, type CollectionAfterReadHookEntry as aG, type CollectionAfterTransitionHook as aH, type CollectionBeforeChangeHook as aI, type CollectionBeforeChangeHookEntry as aJ, type CollectionBeforeDeleteHook as aK, type CollectionBeforeReadHook as aL, type CollectionBeforeReadHookEntry as aM, type CollectionBeforeTransitionHook as aN, type CollectionListComponentSlots as aO, type CollectionViewComponentSlots as aP, type CountOperation as aQ, type CustomAdminAuthProvider as aR, type DatabaseAdapter as aS, type DateFieldAdmin as aT, type DateFormat as aU, type DefineActionOptions as aV, type DefineViewOptions as aW, type DetailSpan as aX, type DisplayTone as aY, type DisplayVariant as aZ, type DistinctCountOperation as a_, type AccessFunctionArgs as aa, type AccessResult as ab, type AccessRule as ac, type ActionConfig as ad, type ActionContext as ae, type ActionType as af, type AdminAuthAccessResolution as ag, type AdminAuthClaimMapping as ah, type AdminAuthMember as ai, type AdminAuthProvider as aj, type AdminAuthProviderMembersConfig as ak, type AdminAuthProvisioningMode as al, type AdminAuthResolveAccessArgs as am, type AdminAuthResolvedIdentity as an, type AdminConfig as ao, type AdminDashboardComponentSlots as ap, type AdminIconName as aq, type AggregateArgs as ar, type AggregateCastType as as, type AggregateInput as at, type AggregateOperation as au, type AggregateResult as av, type BaseAdminAuthProvider as aw, type BaseFieldAdmin as ax, type BlockVariant as ay, type BooleanFieldAdmin as az, type AuthenticatedUser as b, type TrustProxyConfig as b$, type DynamicOptionItem as b0, type DynamicOptionsConfig as b1, type DynamicOptionsResolver as b2, type DynamicOptionsResolverArgs as b3, type DyrectedLoggerConfig as b4, type DyrectedObservabilityConfig as b5, type EmailFieldAdmin as b6, type FieldAdminHooks as b7, type FieldAdminOnChangeHook as b8, type FieldAdminOnChangeHookArgs as b9, type JsonFormat as bA, LIFECYCLE_EVENT_NAMES as bB, type LifecycleEventHandler as bC, type LinkFormat as bD, type MetricColor as bE, type MultiSelectFieldAdmin as bF, type NamedAccessPolicy as bG, type NumberFieldAdmin as bH, type NumberFormat as bI, type NumberLimitFieldAdmin as bJ, type NumberLimitFieldConfig as bK, type NumericOperation as bL, type OIDCAdminAuthProvider as bM, type OptionFormat as bN, type PaginatedResult as bO, type PublicAdminAuthProvider as bP, type RadioFieldAdmin as bQ, type RateLimitConfig as bR, type ReadonlyDatabaseAdapter as bS, type RichTextFeature as bT, type RichTextFieldConfig as bU, type SelectFieldAdmin as bV, type SqlWhereResult as bW, type StorageAdapter as bX, type TextFieldAdmin as bY, type TextFormat as bZ, type TextareaFieldAdmin as b_, type FieldAdminOptionsHook as ba, type FieldAdminOptionsHookArgs as bb, type FieldAdminOptionsHookResult as bc, type FieldAfterReadHook as bd, type FieldAfterReadHookArgs as be, type FieldBase as bf, type FieldBeforeChangeHook as bg, type FieldBeforeChangeHookArgs as bh, type FieldHook as bi, type FieldHooks as bj, type FieldType as bk, type FileData as bl, type GlobalAfterChangeHook as bm, type GlobalAfterReadHook as bn, type GlobalAfterReadHookEntry as bo, type GlobalBeforeChangeHook as bp, type GlobalBeforeChangeHookEntry as bq, type GlobalBeforeReadHook as br, type GlobalBeforeReadHookEntry as bs, type HeadingLevel as bt, type HookFunction as bu, type IconFieldAdmin as bv, type ImageService as bw, type InferAggregateResult as bx, type JoinFieldAdmin as by, type JsonFieldAdmin as bz, type WorkflowTransition as c, type TypedField as c0, type UploadConfig as c1, type UrlFieldAdmin as c2, type UrlLinkValue as c3, type ViewActionFeatures as c4, type ViewComponentSlots as c5, type ViewConfig as c6, type ViewLayout as c7, type ViewMetric as c8, type ViewSubMetric as c9, type WhereClause as ca, type WhereOperator as cb, type WhereOperatorName as cc, type WordLimitFieldAdmin as cd, type WordLimitFieldConfig as ce, type WorkflowMetadata as cf, type WorkflowRole as cg, type WorkflowState as ch, type WorkflowTransitionContext as ci, defineAction as cj, defineView as ck, parseMongoWhere as cl, parseSqlWhere as cm, type LifecycleEvent as d, type BaseDocument as e, type DetailComputedOptions as f, type ComputedHandler as g, type DetailComputed as h, type DetailCustomOptions as i, type DetailCustom as j, type DetailDividerOptions as k, type DetailDivider as l, type DisplayFieldOptions as m, type DetailField as n, type DetailItem as o, type DetailGridOptions as p, type DetailGrid as q, type DetailRepeatOptions as r, type DetailRepeat as s, type DetailSectionOptions as t, type DetailSection as u, type DetailTabOptions as v, type DetailTab as w, type DetailTabsOptions as x, type DetailTabs as y, type DetailTextOptions as z };