@dyrected/core 2.9.0 → 2.10.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/{app-config-gEQJFvnN.d.cts → app-config-DQhcrGDE.d.cts} +297 -37
- package/dist/{app-config-gEQJFvnN.d.ts → app-config-DQhcrGDE.d.ts} +297 -37
- package/dist/{chunk-XRIONGRY.js → chunk-TYPDQTE2.js} +110 -30
- package/dist/index.cjs +173 -67
- package/dist/index.d.cts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +64 -38
- package/dist/server.cjs +130 -32
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +21 -3
- package/package.json +1 -1
|
@@ -870,6 +870,22 @@ interface CountOperation {
|
|
|
870
870
|
count: "*";
|
|
871
871
|
where?: Record<string, unknown>;
|
|
872
872
|
}
|
|
873
|
+
/**
|
|
874
|
+
* A `countDistinct` aggregate operation that counts the number of unique
|
|
875
|
+
* non-null values for a specific field.
|
|
876
|
+
*/
|
|
877
|
+
interface DistinctCountOperation {
|
|
878
|
+
countDistinct: string;
|
|
879
|
+
where?: Record<string, unknown>;
|
|
880
|
+
}
|
|
881
|
+
/**
|
|
882
|
+
* A `distinct` aggregate operation that retrieves the unique values
|
|
883
|
+
* (or unique values with item counts) for a specific field.
|
|
884
|
+
*/
|
|
885
|
+
interface DistinctValuesOperation {
|
|
886
|
+
distinct: string;
|
|
887
|
+
where?: Record<string, unknown>;
|
|
888
|
+
}
|
|
873
889
|
/**
|
|
874
890
|
* A `sum`, `avg`, `min`, or `max` aggregate operation on a named field.
|
|
875
891
|
*
|
|
@@ -886,9 +902,9 @@ interface NumericOperation {
|
|
|
886
902
|
where?: Record<string, unknown>;
|
|
887
903
|
}
|
|
888
904
|
/**
|
|
889
|
-
* A single named aggregate request — either a count or
|
|
905
|
+
* A single named aggregate request — either a count, distinct count, distinct values, or numeric operation.
|
|
890
906
|
*/
|
|
891
|
-
type AggregateOperation = CountOperation | NumericOperation;
|
|
907
|
+
type AggregateOperation = CountOperation | DistinctCountOperation | DistinctValuesOperation | NumericOperation;
|
|
892
908
|
/**
|
|
893
909
|
* The map of named aggregate operations sent in a single aggregate request.
|
|
894
910
|
*
|
|
@@ -896,6 +912,8 @@ type AggregateOperation = CountOperation | NumericOperation;
|
|
|
896
912
|
* ```ts
|
|
897
913
|
* {
|
|
898
914
|
* totalSubmitted: { count: "*" },
|
|
915
|
+
* uniqueGuests: { countDistinct: "email" },
|
|
916
|
+
* availableSizes: { distinct: "asoebiSize" },
|
|
899
917
|
* totalAsoebiYards: { sum: "asoebiYards", cast: "number", where: { wantsAsoebi: { equals: true } } },
|
|
900
918
|
* }
|
|
901
919
|
* ```
|
|
@@ -909,153 +927,354 @@ interface AggregateArgs {
|
|
|
909
927
|
collection: string;
|
|
910
928
|
/** Named aggregate operations to compute. */
|
|
911
929
|
aggregates: AggregateInput;
|
|
930
|
+
/** Optional field to group the aggregates by. */
|
|
931
|
+
groupBy?: string;
|
|
912
932
|
}
|
|
913
933
|
/**
|
|
914
934
|
* The result returned by `DatabaseAdapter.aggregate`.
|
|
915
935
|
*
|
|
916
|
-
*
|
|
917
|
-
* `
|
|
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.
|
|
936
|
+
* For scalar aggregates, every named key maps to a `number | null` or `any[]` (for distinct).
|
|
937
|
+
* When `groupBy` is used, returns a breakdown per group.
|
|
921
938
|
*/
|
|
922
|
-
type AggregateResult = Record<string,
|
|
939
|
+
type AggregateResult = Record<string, any>;
|
|
923
940
|
/**
|
|
924
941
|
* 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
942
|
*/
|
|
934
943
|
type InferAggregateResult<T extends AggregateInput> = {
|
|
935
|
-
[K in keyof T]:
|
|
944
|
+
[K in keyof T]: any;
|
|
936
945
|
};
|
|
937
946
|
|
|
947
|
+
/**
|
|
948
|
+
* Supported layout engines for operational views in the Dyrected Admin UI:
|
|
949
|
+
* - `'table'`: The workhorse — column sorting, search, faceted filters, and bulk actions.
|
|
950
|
+
* - `'spreadsheet'`: Inline-editable matrix with batch saving (`Save changes` / `Discard`).
|
|
951
|
+
* - `'kanban'`: Interactive card board grouped by status or category with drag-and-drop.
|
|
952
|
+
* - `'calendar'`: Event schedule grid plotting records across month/week/day views by date.
|
|
953
|
+
* - `'gantt'`: Timeline bars plotted across start and end dates.
|
|
954
|
+
* - `'cards'`: Visual image/thumbnail gallery grid.
|
|
955
|
+
*/
|
|
938
956
|
type ViewLayout = 'table' | 'spreadsheet' | 'kanban' | 'calendar' | 'gantt' | 'cards';
|
|
957
|
+
/**
|
|
958
|
+
* Scope and placement for an operational view action:
|
|
959
|
+
* - `'row'`: Renders as an inline action button on each document/row.
|
|
960
|
+
* - `'bulk'`: Appears in the floating bulk action bar when one or more rows are selected.
|
|
961
|
+
* - `'header'`: Renders as a primary action button in the view header.
|
|
962
|
+
*/
|
|
939
963
|
type ActionType = 'row' | 'bulk' | 'header';
|
|
940
964
|
/**
|
|
941
|
-
* Toggles for the built-in document operations an operational view surfaces
|
|
942
|
-
* (
|
|
943
|
-
*
|
|
965
|
+
* Toggles for the built-in document operations an operational view surfaces.
|
|
966
|
+
* All default to enabled (`true`). Set any to `false` to hide that operation.
|
|
967
|
+
*
|
|
968
|
+
* @example
|
|
969
|
+
* ```ts
|
|
970
|
+
* features: {
|
|
971
|
+
* delete: false, // Prevent deleting records from this view
|
|
972
|
+
* exportSelected: true, // Enable CSV export for checked rows
|
|
973
|
+
* }
|
|
974
|
+
* ```
|
|
944
975
|
*/
|
|
945
976
|
interface ViewActionFeatures {
|
|
977
|
+
/** Enables the "View" preview / read-only drawer button. Defaults to `true`. */
|
|
946
978
|
view?: boolean;
|
|
979
|
+
/** Enables the "Edit" document form link. Defaults to `true`. */
|
|
947
980
|
edit?: boolean;
|
|
981
|
+
/** Enables the "Duplicate" record action. Defaults to `true`. */
|
|
948
982
|
duplicate?: boolean;
|
|
983
|
+
/** Enables the "Delete" record action. Defaults to `true`. */
|
|
949
984
|
delete?: boolean;
|
|
985
|
+
/** Enables the "Export selected" CSV action in the bulk action bar. Defaults to `true`. */
|
|
950
986
|
exportSelected?: boolean;
|
|
951
987
|
}
|
|
988
|
+
/**
|
|
989
|
+
* Color palette options for metric cards:
|
|
990
|
+
* `'purple' | 'emerald' | 'amber' | 'rose' | 'blue' | 'indigo' | 'cyan' | 'orange'`
|
|
991
|
+
*/
|
|
952
992
|
type MetricColor = 'purple' | 'emerald' | 'amber' | 'rose' | 'blue' | 'indigo' | 'cyan' | 'orange' | string;
|
|
993
|
+
/**
|
|
994
|
+
* A sub-metric breakdown item displayed in the compact footer of a metric card.
|
|
995
|
+
*
|
|
996
|
+
* @example
|
|
997
|
+
* ```ts
|
|
998
|
+
* {
|
|
999
|
+
* label: "Pending",
|
|
1000
|
+
* aggregates: {
|
|
1001
|
+
* checkedIn: { count: "*", where: { checkedIn: { equals: true } } },
|
|
1002
|
+
* attending: { count: "*", where: { attending: { equals: true } } },
|
|
1003
|
+
* },
|
|
1004
|
+
* expression: "aggregates.attending - aggregates.checkedIn",
|
|
1005
|
+
* }
|
|
1006
|
+
* ```
|
|
1007
|
+
*/
|
|
953
1008
|
interface ViewSubMetric {
|
|
1009
|
+
/** Short label for the sub-metric (e.g. "Pending", "Collected"). */
|
|
954
1010
|
label: string;
|
|
1011
|
+
/** Single database aggregate operation. */
|
|
955
1012
|
aggregate?: AggregateOperation;
|
|
1013
|
+
/** Map of named aggregate operations referenced in `expression` as `aggregates.key`. */
|
|
956
1014
|
aggregates?: Record<string, AggregateOperation>;
|
|
1015
|
+
/** JEXL math formula evaluated over `value` for a single aggregate (e.g. `"value * 100"`). */
|
|
957
1016
|
transform?: string;
|
|
1017
|
+
/** JEXL math formula evaluated over `aggregates` (e.g. `"aggregates.a - aggregates.b"`). */
|
|
958
1018
|
expression?: string;
|
|
1019
|
+
/** Display formatter: `'currency' | 'number' | 'percent'`. */
|
|
959
1020
|
format?: 'currency' | 'number' | 'percent' | string;
|
|
1021
|
+
/** 3-letter currency code (e.g. `"USD"`, `"NGN"`, `"EUR"`) used when `format: "currency"`. */
|
|
960
1022
|
currency?: string;
|
|
961
1023
|
}
|
|
1024
|
+
/**
|
|
1025
|
+
* Configuration for a KPI summary card rendered at the top of an operational view.
|
|
1026
|
+
*
|
|
1027
|
+
* All aggregations run directly on the database engine for maximum performance.
|
|
1028
|
+
*
|
|
1029
|
+
* @example
|
|
1030
|
+
* ```ts
|
|
1031
|
+
* {
|
|
1032
|
+
* label: "Total Revenue",
|
|
1033
|
+
* color: "emerald",
|
|
1034
|
+
* aggregate: { sum: "amount", cast: "number", where: { status: "paid" } },
|
|
1035
|
+
* format: "currency",
|
|
1036
|
+
* currency: "USD",
|
|
1037
|
+
* }
|
|
1038
|
+
* ```
|
|
1039
|
+
*/
|
|
962
1040
|
interface ViewMetric {
|
|
1041
|
+
/** Title displayed on the metric card header. */
|
|
963
1042
|
label: string;
|
|
1043
|
+
/** Accent color for the card's visual indicator. */
|
|
964
1044
|
color?: MetricColor;
|
|
1045
|
+
/** Unit badge shown alongside the numeric value (e.g. `"Guests"`, `"Orders"`, `"Tables"`). */
|
|
965
1046
|
unit?: string;
|
|
1047
|
+
/** Single database aggregate operation (`count`, `distinctCount`, `sum`, `avg`, `min`, `max`). */
|
|
966
1048
|
aggregate?: AggregateOperation;
|
|
1049
|
+
/** Map of named aggregate operations referenced in `expression` as `aggregates.key`. */
|
|
967
1050
|
aggregates?: Record<string, AggregateOperation>;
|
|
1051
|
+
/** JEXL math formula evaluated over `value` for a single aggregate (e.g. `"value * 25000"`). */
|
|
968
1052
|
transform?: string;
|
|
1053
|
+
/** JEXL math formula evaluated over `aggregates` (e.g. `"(aggregates.paid / aggregates.total) * 100"`). */
|
|
969
1054
|
expression?: string;
|
|
1055
|
+
/** Display formatter: `'currency' | 'number' | 'percent'`. */
|
|
970
1056
|
format?: 'currency' | 'number' | 'percent' | string;
|
|
1057
|
+
/** 3-letter currency code (e.g. `"USD"`, `"NGN"`, `"EUR"`) used when `format: "currency"`. */
|
|
971
1058
|
currency?: string;
|
|
1059
|
+
/** Optional secondary breakdown items shown in the card footer. */
|
|
972
1060
|
subMetrics?: ViewSubMetric[];
|
|
973
1061
|
}
|
|
1062
|
+
/**
|
|
1063
|
+
* Complete configuration for a tailored operational view.
|
|
1064
|
+
*/
|
|
974
1065
|
interface ViewConfig {
|
|
1066
|
+
/** Stable URL slug for the view (`/collections/:slug/views/:viewSlug`). */
|
|
975
1067
|
slug: string;
|
|
1068
|
+
/** Human-readable title displayed in the sidebar navigation and view header. */
|
|
976
1069
|
label: string;
|
|
1070
|
+
/** Lucide icon name (e.g. `"UserCheck"`, `"Calendar"`, `"Shirt"`, `"TableProperties"`). */
|
|
977
1071
|
icon?: string;
|
|
1072
|
+
/** Layout engine to render: `'table' | 'spreadsheet' | 'kanban' | 'calendar' | 'gantt' | 'cards'`. Defaults to `'table'`. */
|
|
978
1073
|
layout?: ViewLayout;
|
|
1074
|
+
/** Base query filter applied before user toolbar filters (e.g. `{ attending: { equals: true } }` or JEXL string). */
|
|
979
1075
|
filter?: Record<string, any> | string;
|
|
1076
|
+
/** Field name used to organize records into kanban columns or collapsible grouped sections in table, cards, and spreadsheet. */
|
|
980
1077
|
groupBy?: string;
|
|
1078
|
+
/** Field name containing the ISO date string for calendar placement. Required when `layout: 'calendar'`. */
|
|
981
1079
|
dateField?: string;
|
|
1080
|
+
/** Field name for the start date in timeline/gantt views. Required when `layout: 'gantt'`. */
|
|
982
1081
|
startDateField?: string;
|
|
1082
|
+
/** Field name for the end date in timeline/gantt views. Required when `layout: 'gantt'`. */
|
|
983
1083
|
endDateField?: string;
|
|
1084
|
+
/** Field names to show in this view, in order. If omitted, Dyrected infers default display fields. */
|
|
984
1085
|
columns?: string[];
|
|
1086
|
+
/** Default sorting rule when entering the view. */
|
|
985
1087
|
sort?: {
|
|
986
1088
|
field: string;
|
|
987
1089
|
direction: 'asc' | 'desc';
|
|
988
1090
|
};
|
|
1091
|
+
/** Custom workflow actions available in this view. */
|
|
989
1092
|
actions?: ActionConfig[];
|
|
990
1093
|
/** Toggles built-in operations (view/edit/duplicate/delete/export). */
|
|
991
1094
|
features?: ViewActionFeatures;
|
|
992
1095
|
/**
|
|
993
|
-
* Explicit display order for
|
|
994
|
-
* "duplicate"
|
|
995
|
-
* append in their default order.
|
|
1096
|
+
* Explicit display order for action buttons — mixing custom action names and built-in names
|
|
1097
|
+
* (`"view"`, `"edit"`, `"duplicate"`, `"delete"`). Unlisted actions append in default order.
|
|
996
1098
|
*/
|
|
997
1099
|
actionOrder?: string[];
|
|
1100
|
+
/** KPI summary cards rendered in the hero row above the view. */
|
|
998
1101
|
metrics?: ViewMetric[];
|
|
1102
|
+
/** Role-based access rules controlling who can see or use this view. */
|
|
999
1103
|
access?: AccessConfig;
|
|
1000
1104
|
}
|
|
1001
|
-
|
|
1105
|
+
/**
|
|
1106
|
+
* An operational workflow action that can mutate data or trigger server logic.
|
|
1107
|
+
*/
|
|
1108
|
+
interface ActionConfig<TDoc extends Record<string, unknown> = Record<string, unknown>> {
|
|
1109
|
+
/** Unique action identifier (e.g. `"checkIn"`, `"markPaid"`). */
|
|
1002
1110
|
name: string;
|
|
1111
|
+
/** Button label displayed in the UI. */
|
|
1003
1112
|
label: string;
|
|
1113
|
+
/** Lucide icon name for the button (e.g. `"UserCheck"`, `"CheckCircle"`). */
|
|
1004
1114
|
icon?: string;
|
|
1115
|
+
/** Action placement: `'row'` (per-row), `'bulk'` (multi-row selection bar), or `'header'` (view header). Defaults to `'row'`. */
|
|
1005
1116
|
type?: ActionType;
|
|
1117
|
+
/** Optional confirmation prompt shown before executing (e.g. `"Confirm guest check-in at the door?"`). */
|
|
1006
1118
|
confirm?: string;
|
|
1119
|
+
/** Optional interactive modal form fields prompting the user for input before executing. */
|
|
1007
1120
|
fields?: Field[];
|
|
1008
|
-
mutation
|
|
1009
|
-
|
|
1121
|
+
/** Declarative database mutation applied to targeted documents (e.g. `{ checkedIn: true, checkedInAt: "now()" }`). */
|
|
1122
|
+
mutation?: Partial<TDoc> | Record<string, unknown>;
|
|
1123
|
+
/** Self-hosted server handler function executed when the action is triggered. */
|
|
1124
|
+
handler?: (context: ActionContext<TDoc>) => Promise<unknown> | unknown;
|
|
1125
|
+
/** Role-based access rules controlling who can trigger this action. */
|
|
1010
1126
|
access?: AccessConfig;
|
|
1011
1127
|
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1128
|
+
/**
|
|
1129
|
+
* Context passed to an action's server handler function.
|
|
1130
|
+
*/
|
|
1131
|
+
interface ActionContext<TDoc extends Record<string, unknown> = Record<string, unknown>> {
|
|
1132
|
+
/** The target document (for row actions). */
|
|
1133
|
+
doc: TDoc;
|
|
1134
|
+
/** All targeted documents (for bulk actions). */
|
|
1135
|
+
docs: TDoc[];
|
|
1136
|
+
/** The authenticated acting user, if available. */
|
|
1015
1137
|
user: Record<string, unknown> | null;
|
|
1138
|
+
/** User inputs submitted via the action's modal form fields. */
|
|
1016
1139
|
input: Record<string, unknown>;
|
|
1140
|
+
/** The collection configuration object. */
|
|
1017
1141
|
collection: Record<string, unknown>;
|
|
1018
1142
|
}
|
|
1143
|
+
/**
|
|
1144
|
+
* Role-based access control rules for a view or action.
|
|
1145
|
+
*/
|
|
1019
1146
|
interface AccessConfig {
|
|
1020
1147
|
read?: AccessRule<any>;
|
|
1021
1148
|
create?: AccessRule<any>;
|
|
1022
1149
|
update?: AccessRule<any>;
|
|
1023
1150
|
delete?: AccessRule<any>;
|
|
1024
1151
|
}
|
|
1152
|
+
/**
|
|
1153
|
+
* Options for defining an operational view with `defineView`.
|
|
1154
|
+
*
|
|
1155
|
+
* @example
|
|
1156
|
+
* ```ts
|
|
1157
|
+
* export const attendingGuests = defineView({
|
|
1158
|
+
* slug: "attending-guests",
|
|
1159
|
+
* label: "Attending Guests",
|
|
1160
|
+
* icon: "UserCheck",
|
|
1161
|
+
* layout: "table",
|
|
1162
|
+
* groupBy: "tableNumber",
|
|
1163
|
+
* filter: { attending: { equals: true } },
|
|
1164
|
+
* columns: ["name", "email", "guestCount", "checkedIn"],
|
|
1165
|
+
* sort: { field: "name", direction: "asc" },
|
|
1166
|
+
* });
|
|
1167
|
+
* ```
|
|
1168
|
+
*/
|
|
1025
1169
|
interface DefineViewOptions {
|
|
1170
|
+
/** Stable URL slug for the view (`/collections/:slug/views/:viewSlug`). */
|
|
1026
1171
|
slug: string;
|
|
1172
|
+
/** Human-readable title displayed in the sidebar navigation and view header. */
|
|
1027
1173
|
label: string;
|
|
1174
|
+
/** Lucide icon name (e.g. `"UserCheck"`, `"Calendar"`, `"Shirt"`, `"TableProperties"`). */
|
|
1028
1175
|
icon?: string;
|
|
1176
|
+
/** Layout engine to render: `'table' | 'spreadsheet' | 'kanban' | 'calendar' | 'gantt' | 'cards'`. Defaults to `'table'`. */
|
|
1029
1177
|
layout?: ViewLayout;
|
|
1178
|
+
/** Base query filter applied before user toolbar filters (e.g. `{ attending: { equals: true } }` or JEXL string). */
|
|
1030
1179
|
filter?: Record<string, any> | string;
|
|
1180
|
+
/** Field name used to organize records into kanban columns or collapsible grouped sections in table, cards, and spreadsheet. */
|
|
1031
1181
|
groupBy?: string;
|
|
1182
|
+
/** Field name containing the ISO date string for calendar placement. Required when `layout: 'calendar'`. */
|
|
1032
1183
|
dateField?: string;
|
|
1184
|
+
/** Field name for the start date in timeline/gantt views. Required when `layout: 'gantt'`. */
|
|
1033
1185
|
startDateField?: string;
|
|
1186
|
+
/** Field name for the end date in timeline/gantt views. Required when `layout: 'gantt'`. */
|
|
1034
1187
|
endDateField?: string;
|
|
1188
|
+
/** Field names to show in this view, in order. If omitted, Dyrected infers default display fields. */
|
|
1035
1189
|
columns?: string[];
|
|
1190
|
+
/** Default sorting rule when entering the view. */
|
|
1036
1191
|
sort?: {
|
|
1037
1192
|
field: string;
|
|
1038
1193
|
direction: 'asc' | 'desc';
|
|
1039
1194
|
};
|
|
1195
|
+
/** Custom workflow actions available in this view. */
|
|
1040
1196
|
actions?: ActionConfig[];
|
|
1197
|
+
/** Toggles built-in operations (view/edit/duplicate/delete/export). */
|
|
1041
1198
|
features?: ViewActionFeatures;
|
|
1199
|
+
/**
|
|
1200
|
+
* Explicit display order for action buttons — mixing custom action names and built-in names
|
|
1201
|
+
* (`"view"`, `"edit"`, `"duplicate"`, `"delete"`). Unlisted actions append in default order.
|
|
1202
|
+
*/
|
|
1042
1203
|
actionOrder?: string[];
|
|
1204
|
+
/** KPI summary cards rendered in the hero row above the view. */
|
|
1043
1205
|
metrics?: ViewMetric[];
|
|
1206
|
+
/** Role-based access rules controlling who can see or use this view. */
|
|
1044
1207
|
access?: AccessConfig;
|
|
1045
1208
|
}
|
|
1046
|
-
|
|
1209
|
+
/**
|
|
1210
|
+
* Options for defining a custom workflow action with `defineAction`.
|
|
1211
|
+
*
|
|
1212
|
+
* @example
|
|
1213
|
+
* ```ts
|
|
1214
|
+
* export const checkInAction = defineAction({
|
|
1215
|
+
* name: "checkIn",
|
|
1216
|
+
* label: "Check In",
|
|
1217
|
+
* icon: "UserCheck",
|
|
1218
|
+
* type: "row",
|
|
1219
|
+
* confirm: "Confirm guest check-in at the door?",
|
|
1220
|
+
* mutation: { checkedIn: true, checkedInAt: "now()" },
|
|
1221
|
+
* });
|
|
1222
|
+
* ```
|
|
1223
|
+
*/
|
|
1224
|
+
interface DefineActionOptions<TDoc extends Record<string, unknown> = Record<string, unknown>> {
|
|
1225
|
+
/** Unique action identifier (e.g. `"checkIn"`, `"markPaid"`). */
|
|
1047
1226
|
name: string;
|
|
1227
|
+
/** Button label displayed in the UI. */
|
|
1048
1228
|
label: string;
|
|
1229
|
+
/** Lucide icon name for the button (e.g. `"UserCheck"`, `"CheckCircle"`). */
|
|
1049
1230
|
icon?: string;
|
|
1231
|
+
/** Action placement: `'row'` (per-row), `'bulk'` (multi-row selection bar), or `'header'` (view header). Defaults to `'row'`. */
|
|
1050
1232
|
type?: ActionType;
|
|
1233
|
+
/** Optional confirmation prompt shown before executing (e.g. `"Confirm guest check-in at the door?"`). */
|
|
1051
1234
|
confirm?: string;
|
|
1235
|
+
/** Optional interactive modal form fields prompting the user for input before executing. */
|
|
1052
1236
|
fields?: Field[];
|
|
1053
|
-
mutation
|
|
1054
|
-
|
|
1237
|
+
/** Declarative database mutation applied to targeted documents (e.g. `{ checkedIn: true, checkedInAt: "now()" }`). */
|
|
1238
|
+
mutation?: Partial<TDoc> | Record<string, unknown>;
|
|
1239
|
+
/** Self-hosted server handler function executed when the action is triggered. */
|
|
1240
|
+
handler?: (context: ActionContext<TDoc>) => Promise<unknown> | unknown;
|
|
1241
|
+
/** Role-based access rules controlling who can trigger this action. */
|
|
1055
1242
|
access?: AccessConfig;
|
|
1056
1243
|
}
|
|
1057
|
-
|
|
1058
|
-
|
|
1244
|
+
/**
|
|
1245
|
+
* Defines a typed operational view for a collection.
|
|
1246
|
+
*
|
|
1247
|
+
* @example
|
|
1248
|
+
* ```ts
|
|
1249
|
+
* export const attendingGuests = defineView({
|
|
1250
|
+
* slug: "attending-guests",
|
|
1251
|
+
* label: "Attending Guests",
|
|
1252
|
+
* icon: "UserCheck",
|
|
1253
|
+
* layout: "table",
|
|
1254
|
+
* groupBy: "tableNumber",
|
|
1255
|
+
* filter: { attending: { equals: true } },
|
|
1256
|
+
* columns: ["name", "email", "guestCount", "checkedIn"],
|
|
1257
|
+
* sort: { field: "name", direction: "asc" },
|
|
1258
|
+
* });
|
|
1259
|
+
* ```
|
|
1260
|
+
*/
|
|
1261
|
+
declare function defineView<const T extends DefineViewOptions>(config: T): T;
|
|
1262
|
+
/**
|
|
1263
|
+
* Defines a custom workflow action for an operational view.
|
|
1264
|
+
*
|
|
1265
|
+
* @example
|
|
1266
|
+
* ```ts
|
|
1267
|
+
* export const markPaidAction = defineAction({
|
|
1268
|
+
* name: "markPaid",
|
|
1269
|
+
* label: "Mark Paid",
|
|
1270
|
+
* icon: "DollarSign",
|
|
1271
|
+
* type: "bulk",
|
|
1272
|
+
* confirm: "Mark selected orders as paid?",
|
|
1273
|
+
* mutation: { status: "paid" },
|
|
1274
|
+
* });
|
|
1275
|
+
* ```
|
|
1276
|
+
*/
|
|
1277
|
+
declare function defineAction<const T extends DefineActionOptions>(config: T): T;
|
|
1059
1278
|
|
|
1060
1279
|
/**
|
|
1061
1280
|
* Configures account lockout behavior for an auth-enabled collection.
|
|
@@ -1357,6 +1576,11 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
|
|
|
1357
1576
|
* Collections with the same `group` are visually grouped together.
|
|
1358
1577
|
*/
|
|
1359
1578
|
group?: string;
|
|
1579
|
+
/**
|
|
1580
|
+
* Slug of the view to render by default when navigating to `/collections/:slug`.
|
|
1581
|
+
* If not specified, defaults to the view with `default: true` or the all-records table view.
|
|
1582
|
+
*/
|
|
1583
|
+
defaultView?: string;
|
|
1360
1584
|
/** If `true`, this collection is not shown in the Admin UI sidebar. */
|
|
1361
1585
|
hidden?: boolean;
|
|
1362
1586
|
/** If `false`, disables the filter UI entirely for this collection. Defaults to `true`. */
|
|
@@ -1415,8 +1639,44 @@ interface CollectionConfig<TDoc extends object = Record<string, unknown>> {
|
|
|
1415
1639
|
*/
|
|
1416
1640
|
detail?: DetailSchema<TDoc> | false;
|
|
1417
1641
|
/**
|
|
1418
|
-
*
|
|
1419
|
-
*
|
|
1642
|
+
* Slug of the operational view to render by default when navigating to `/collections/:slug`.
|
|
1643
|
+
*
|
|
1644
|
+
* When set:
|
|
1645
|
+
* 1. Navigating to `/collections/:slug` automatically redirects to `/collections/:slug/views/:defaultView`.
|
|
1646
|
+
* 2. The main collection link in the sidebar directly opens this default view.
|
|
1647
|
+
* 3. The sidebar submenu cleanly lists only your defined views without showing a generic `All [Collection]` item.
|
|
1648
|
+
*
|
|
1649
|
+
* @example
|
|
1650
|
+
* ```ts
|
|
1651
|
+
* export const GuestResponses = defineCollection({
|
|
1652
|
+
* slug: "guest-responses",
|
|
1653
|
+
* defaultView: "attending-guests",
|
|
1654
|
+
* views: [attendingGuests, seatingMatrix],
|
|
1655
|
+
* fields: [...],
|
|
1656
|
+
* });
|
|
1657
|
+
* ```
|
|
1658
|
+
*/
|
|
1659
|
+
defaultView?: string;
|
|
1660
|
+
/**
|
|
1661
|
+
* Tailored operational workspaces for this collection (`table`, `spreadsheet`, `kanban`, `calendar`, `cards`, `gantt`).
|
|
1662
|
+
* Each view provides curated columns, filters, metrics, and workflow buttons for a specific job.
|
|
1663
|
+
*
|
|
1664
|
+
* @example
|
|
1665
|
+
* ```ts
|
|
1666
|
+
* views: [
|
|
1667
|
+
* defineView({
|
|
1668
|
+
* slug: "attending-guests",
|
|
1669
|
+
* label: "Attending Guests",
|
|
1670
|
+
* icon: "UserCheck",
|
|
1671
|
+
* layout: "table",
|
|
1672
|
+
* groupBy: "tableNumber",
|
|
1673
|
+
* filter: { attending: { equals: true } },
|
|
1674
|
+
* columns: ["name", "email", "guestCount", "checkedIn"],
|
|
1675
|
+
* }),
|
|
1676
|
+
* ]
|
|
1677
|
+
* ```
|
|
1678
|
+
*
|
|
1679
|
+
* @see {@link https://dyrected.com/docs/model-content/operational-views/overview Operational views overview}
|
|
1420
1680
|
*/
|
|
1421
1681
|
views?: ViewConfig[];
|
|
1422
1682
|
}
|
|
@@ -2695,4 +2955,4 @@ interface DyrectedConfig<TUser extends AuthenticatedUser = AuthenticatedUser> {
|
|
|
2695
2955
|
}>;
|
|
2696
2956
|
}
|
|
2697
2957
|
|
|
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
|
|
2958
|
+
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 DynamicOptionItem 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 DistinctCountOperation as aZ, type DistinctValuesOperation 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 UploadConfig as b$, type DynamicOptionsConfig as b0, type DynamicOptionsResolver as b1, type DynamicOptionsResolverArgs as b2, type DyrectedLoggerConfig as b3, type DyrectedObservabilityConfig as b4, type EmailFieldAdmin as b5, type FieldAdminHooks as b6, type FieldAdminOnChangeHook as b7, type FieldAdminOnChangeHookArgs as b8, type FieldAdminOptionsHook as b9, LIFECYCLE_EVENT_NAMES as bA, type LifecycleEventHandler as bB, type LinkFormat as bC, type MetricColor as bD, type MultiSelectFieldAdmin as bE, type NamedAccessPolicy as bF, type NumberFieldAdmin as bG, type NumberFormat as bH, type NumberLimitFieldAdmin as bI, type NumberLimitFieldConfig as bJ, type NumericOperation as bK, type OIDCAdminAuthProvider as bL, type OptionFormat as bM, type PaginatedResult as bN, type PublicAdminAuthProvider as bO, type RadioFieldAdmin as bP, type RateLimitConfig as bQ, type ReadonlyDatabaseAdapter as bR, type RichTextFeature as bS, type RichTextFieldConfig as bT, type SelectFieldAdmin as bU, type StorageAdapter as bV, type TextFieldAdmin as bW, type TextFormat as bX, type TextareaFieldAdmin as bY, type TrustProxyConfig as bZ, type TypedField as b_, type FieldAdminOptionsHookArgs as ba, type FieldAdminOptionsHookResult as bb, type FieldAfterReadHook as bc, type FieldAfterReadHookArgs as bd, type FieldBase as be, type FieldBeforeChangeHook as bf, type FieldBeforeChangeHookArgs as bg, type FieldHook as bh, type FieldHooks as bi, type FieldType as bj, type FileData as bk, type GlobalAfterChangeHook as bl, type GlobalAfterReadHook as bm, type GlobalAfterReadHookEntry as bn, type GlobalBeforeChangeHook as bo, type GlobalBeforeChangeHookEntry as bp, type GlobalBeforeReadHook as bq, type GlobalBeforeReadHookEntry as br, type HeadingLevel as bs, type HookFunction as bt, type IconFieldAdmin as bu, type ImageService as bv, type InferAggregateResult as bw, type JoinFieldAdmin as bx, type JsonFieldAdmin as by, type JsonFormat as bz, type WorkflowTransition as c, type UrlFieldAdmin as c0, type UrlLinkValue as c1, type ViewActionFeatures as c2, type ViewConfig as c3, type ViewLayout as c4, type ViewMetric as c5, type ViewSubMetric as c6, type WordLimitFieldAdmin as c7, type WordLimitFieldConfig as c8, type WorkflowMetadata as c9, type WorkflowRole as ca, type WorkflowState as cb, type WorkflowTransitionContext as cc, defineAction as cd, defineView as ce, 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 };
|