@docyrus/docyrus 0.0.68 → 0.0.70

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.
@@ -0,0 +1,248 @@
1
+ # List Query Examples
2
+
3
+ Practical examples for `docyrus ds list` with columns, filters, sorting, and pagination.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Basic Listing](#basic-listing)
10
+ 2. [Column Selection](#column-selection)
11
+ 3. [Filtering](#filtering)
12
+ 4. [Sorting](#sorting)
13
+ 5. [Pagination](#pagination)
14
+ 6. [Combined Examples](#combined-examples)
15
+
16
+ ---
17
+
18
+ ## Basic Listing
19
+
20
+ List all records with default columns:
21
+
22
+ ```bash
23
+ docyrus ds list crm contacts
24
+ ```
25
+
26
+ List with JSON output:
27
+
28
+ ```bash
29
+ docyrus ds list crm contacts --format json
30
+ ```
31
+
32
+ ---
33
+
34
+ ## Column Selection
35
+
36
+ Select specific fields:
37
+
38
+ ```bash
39
+ docyrus ds list crm contacts --columns "name, email, phone"
40
+ ```
41
+
42
+ Select with relation expansion (get related account's name):
43
+
44
+ ```bash
45
+ docyrus ds list crm contacts --columns "name, email, related_account(account_name)"
46
+ ```
47
+
48
+ Spread related fields into root object:
49
+
50
+ ```bash
51
+ docyrus ds list crm contacts --columns "name, ...related_account(account_name, account_phone)"
52
+ ```
53
+
54
+ Alias columns:
55
+
56
+ ```bash
57
+ docyrus ds list crm contacts --columns "n:name, e:email, p:phone"
58
+ ```
59
+
60
+ ---
61
+
62
+ ## Filtering
63
+
64
+ ### Single field equals
65
+
66
+ ```bash
67
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"status","operator":"=","value":"active"}]}'
68
+ ```
69
+
70
+ ### Multiple conditions (AND)
71
+
72
+ ```bash
73
+ docyrus ds list crm contacts --filters '{"combinator":"and","rules":[{"field":"status","operator":"=","value":"active"},{"field":"priority","operator":">=","value":3}]}'
74
+ ```
75
+
76
+ ### OR conditions
77
+
78
+ ```bash
79
+ docyrus ds list crm contacts --filters '{"combinator":"or","rules":[{"field":"city","operator":"=","value":"Istanbul"},{"field":"city","operator":"=","value":"Ankara"}]}'
80
+ ```
81
+
82
+ ### IN operator (match any value in list)
83
+
84
+ ```bash
85
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"status","operator":"in","value":[1,2,3]}]}'
86
+ ```
87
+
88
+ ### Not equal
89
+
90
+ ```bash
91
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"status","operator":"!=","value":"archived"}]}'
92
+ ```
93
+
94
+ ### Text search with LIKE
95
+
96
+ ```bash
97
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"name","operator":"like","value":"John"}]}'
98
+ ```
99
+
100
+ ### Empty / not empty
101
+
102
+ ```bash
103
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"email","operator":"not empty"}]}'
104
+ ```
105
+
106
+ ```bash
107
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"phone","operator":"empty"}]}'
108
+ ```
109
+
110
+ ### Date shortcuts
111
+
112
+ Records created this month:
113
+
114
+ ```bash
115
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"created_on","operator":"this_month"}]}'
116
+ ```
117
+
118
+ Records created today:
119
+
120
+ ```bash
121
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"created_on","operator":"today"}]}'
122
+ ```
123
+
124
+ Records from last 30 days:
125
+
126
+ ```bash
127
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"created_on","operator":"last_30_days"}]}'
128
+ ```
129
+
130
+ ### Date range with between
131
+
132
+ ```bash
133
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"created_on","operator":"between","value":["2025-01-01","2025-06-30"]}]}'
134
+ ```
135
+
136
+ ### Filter on related field
137
+
138
+ Filter by related account's status:
139
+
140
+ ```bash
141
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"rel_related_account/account_status","operator":"=","value":1}]}'
142
+ ```
143
+
144
+ ### Current user filter
145
+
146
+ Records owned by current user:
147
+
148
+ ```bash
149
+ docyrus ds list crm contacts --filters '{"rules":[{"field":"record_owner","operator":"active_user"}]}'
150
+ ```
151
+
152
+ ### Nested AND + OR
153
+
154
+ Active contacts created this month OR contacts with high priority:
155
+
156
+ ```bash
157
+ docyrus ds list crm contacts --filters '{"combinator":"or","rules":[{"combinator":"and","rules":[{"field":"status","operator":"=","value":"active"},{"field":"created_on","operator":"this_month"}]},{"field":"priority","operator":">=","value":5}]}'
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Sorting
163
+
164
+ Sort by name ascending (default):
165
+
166
+ ```bash
167
+ docyrus ds list crm contacts --orderBy "name"
168
+ ```
169
+
170
+ Sort by created date descending:
171
+
172
+ ```bash
173
+ docyrus ds list crm contacts --orderBy "created_on DESC"
174
+ ```
175
+
176
+ ---
177
+
178
+ ## Pagination
179
+
180
+ First 10 records:
181
+
182
+ ```bash
183
+ docyrus ds list crm contacts --limit 10
184
+ ```
185
+
186
+ Next 10 records (page 2):
187
+
188
+ ```bash
189
+ docyrus ds list crm contacts --limit 10 --offset 10
190
+ ```
191
+
192
+ Get total count alongside results:
193
+
194
+ ```bash
195
+ docyrus ds list crm contacts --limit 10 --fullCount true
196
+ ```
197
+
198
+ ---
199
+
200
+ ## Combined Examples
201
+
202
+ ### Active contacts with email, sorted by name, paginated
203
+
204
+ ```bash
205
+ docyrus ds list crm contacts \
206
+ --columns "name, email, phone, created_on" \
207
+ --filters '{"rules":[{"field":"status","operator":"=","value":"active"},{"field":"email","operator":"not empty"}]}' \
208
+ --orderBy "name" \
209
+ --limit 25 \
210
+ --fullCount true
211
+ ```
212
+
213
+ ### Recent high-priority deals with account info
214
+
215
+ ```bash
216
+ docyrus ds list crm deals \
217
+ --columns "name, amount, stage, ...related_account(account_name)" \
218
+ --filters '{"combinator":"and","rules":[{"field":"priority","operator":">=","value":4},{"field":"created_on","operator":"last_30_days"}]}' \
219
+ --orderBy "amount DESC" \
220
+ --limit 20
221
+ ```
222
+
223
+ ### Search for records by keyword
224
+
225
+ ```bash
226
+ docyrus ds list crm contacts \
227
+ --columns "name, email, phone" \
228
+ --filters '{"rules":[{"field":"name","operator":"like","value":"Smith"}]}' \
229
+ --format json
230
+ ```
231
+
232
+ ### Export all records as JSON lines
233
+
234
+ ```bash
235
+ docyrus ds list crm contacts \
236
+ --columns "id, name, email, phone, status, created_on" \
237
+ --format jsonl
238
+ ```
239
+
240
+ ### Records owned by current user, created this quarter
241
+
242
+ ```bash
243
+ docyrus ds list crm tasks \
244
+ --columns "name, status, priority, due_date" \
245
+ --filters '{"combinator":"and","rules":[{"field":"record_owner","operator":"active_user"},{"field":"created_on","operator":"this_quarter"}]}' \
246
+ --orderBy "due_date" \
247
+ --limit 50
248
+ ```
@@ -13,6 +13,9 @@ Build full Docyrus list pages around the web `DataGrid` stack.
13
13
  - Best when rows come from a Docyrus data source or generated collection.
14
14
  - Gives you metadata-driven columns, saved views, toolbar wiring, search, filters (with async option search for relation/user fields), grouping, sorting, row-height, display mode, paging, and reload.
15
15
  - Auto-wires reference field expansion, tenant-aware formatters, and a shared users list when supplied.
16
+ - Built-in inline change tracking + save banner (`trackChanges`, `onSaveChanges`).
17
+ - Built-in selection-bar bulk actions (`bulkActions`: `update`, `delete`, `export`) with `BulkUpdateDialog` + `RecordDeleteConfirmDialog`.
18
+ - Built-in server-side export menu (`enableServerExportMenu`, `exportColumns`, `exportFileName`, `serverExportLimit`).
16
19
  - Read `references/hook-pages.md`.
17
20
 
18
21
  2. **Custom layout or custom row-query lifecycle** → use `useDocyrusDataViewSelect` + `useDataGrid`.
@@ -88,15 +88,45 @@ Use `onReload` when you use `data` mode, because the hook cannot refetch rows on
88
88
 
89
89
  - `actionsColumn`: add per-row actions right after the select column.
90
90
  - `extraColumns`: prepend custom columns before metadata-generated Docyrus fields.
91
- - `mapColumn`: override or skip generated field columns.
91
+ - `mapColumn`: override or skip generated field columns (`(field, defaultColumn) => ColumnDef | null`).
92
92
  - `defaultRowGroupingColumn`: seed a default grouping for views that do not define one.
93
93
  - `systemViews`: add static developer-defined views before saved backend views.
94
- - `enableViewSelect`, `enableSearchInput`, `enableFilterMenu`, `enableGroupMenu`, `enableSortMenu`, `enableRowHeightMenu`, `enableDisplayMenu`, `enableReloadButton`: trim the standard toolbar.
95
- - `showSelectColumn`, `enableRowMarkers`: control the left-most reserved column.
94
+ - `enableViewSelect`, `enableSearchInput`, `enableFilterMenu`, `enableGroupMenu`, `enableSortMenu`, `enableRowHeightMenu`, `enableDisplayMenu`, `enableReloadButton`, `enableServerExportMenu`: trim the standard toolbar (all default `true`).
95
+ - `showSelectColumn` (default `true`), `enableRowMarkers` (default `true`): control the left-most reserved column.
96
+ - `selectColumn`: override `getDataGridSelectColumn` entirely.
97
+ - `searchPlaceholder` (default `"Search…"`), `searchDebounceMs` (default `300`), `toolbarClassName`.
98
+ - `enableSearch` (default `false`), `enableGrouping` (default `true`), `readOnly` (default `true`) — forwarded to `useDataGrid`.
96
99
 
97
100
  ### Query shape
98
101
 
99
102
  - `listParams`: append query params like `limit`, `fullCount`, `expand`, or custom backend flags. `listParams` overrides win against the hook's defaults, so use this to pin paging or add tenant-specific flags.
103
+ - `defaultLimit` (default `100`): page size used when no `limit` is supplied via `listParams`.
104
+ - `enableItemsQuery` (default `true` when no `data` prop is given): set `false` to wire the toolbar without fetching rows.
105
+
106
+ ### Inline change tracking
107
+
108
+ - `trackChanges` (default `true`): enables the save/discard banner above the grid for inline cell edits.
109
+ - `onSaveChanges?: (changes: Array<RowChange>, data: Array<TData>) => void | Promise<void>`: custom save handler. By default the hook batches changes into a single `PATCH /items/bulk` call (with `enableAutomation: false`, `enableChangeLogging: false`) using `collection.updateMany` when supplied, otherwise the direct items endpoint.
110
+
111
+ ### Bulk actions (selection bar)
112
+
113
+ - `bulkActions` (default `['update', 'delete', 'export']`): array of built-in bulk actions to surface when rows are selected. Pass `false` or `[]` to hide the selection bar entirely.
114
+ - `update` → opens the `BulkUpdateDialog`. Calls `collection.updateMany` when present, otherwise the direct items endpoint.
115
+ - `delete` → opens `RecordDeleteConfirmDialog`. Calls `collection.deleteMany` when present, otherwise the direct items endpoint.
116
+ - `export` → opens the export menu for the selection (subset of the toolbar export).
117
+
118
+ ### Server export
119
+
120
+ - `enableServerExportMenu` (default `true`): toolbar export dropdown that pulls all rows matching the active view's filters/keyword from `POST /v1/edge/run/query-export`.
121
+ - `serverExportLimit` (default `10000`): row cap forwarded to the server export endpoint.
122
+ - `serverExportExcludedFieldTypes`: field types to skip when picking export columns. Defaults to virtual / non-stored types like `field-action`.
123
+ - `serverExportExcludedSlugs`: field slugs to skip when picking export columns. Defaults to internal metadata columns mirroring the legacy Vue exporter (`data`, `document`, `parent_data_source_id`, `parent_record_id`, `icon`, `color`, `mentions`, `followers`, `type`, `tenant_view_id`, `tenant_data_source_id`, `sort_order`, `editor_view_id`).
124
+ - `exportColumns` (default `'visible'`): `'visible'` uses the table's currently-visible columns; `'all'` includes every data-source field; an explicit `Array<string>` of slugs picks specific fields in order.
125
+ - `exportFileName`: file name (without extension) for exports. Defaults to `dataSourceSlug`.
126
+
127
+ ### Lifecycle hooks
128
+
129
+ - `onReload?: () => void`: called after the reload button's internal `refetch` (data source + views + items) runs.
100
130
 
101
131
  ### Tenant-aware formatters
102
132
 
@@ -169,12 +199,26 @@ Out of the box (no `mapColumn` needed):
169
199
 
170
200
  Use `mapColumn` only when you need to override these defaults.
171
201
 
202
+ ## Hook result
203
+
204
+ `useDocyrusDataGrid<TData>` returns:
205
+
206
+ - `table` — TanStack Table instance. Pass to `<DataGrid>` and any toolbar building blocks.
207
+ - `gridProps` — spread onto `<DataGrid table={table} {...gridProps} />`. Includes `actions: Array<DataGridAction<TData>>` so the floating selection bar lights up automatically when `bulkActions` are enabled.
208
+ - `toolbar` — pre-wired toolbar `ReactNode` ready to render above the grid.
209
+ - `items: Array<TData>` — resolved rows from `data`, `collection.list()`, or the direct items fetch.
210
+ - `resolvedListParams: DocyrusDataGridListParams` — final params sent to the backend (after merging view state, search, and `listParams`). Use for export/analytics/copy-query.
211
+ - `pagingMode: 'standard' | 'virtual-scroll' | undefined` — resolved paging mode for the active view. Pass to `<DataGrid pagingMode>` so the standard footer renders only when the view enables it.
212
+ - `reload: () => void` — triggers `refetch()` (data source + views + items) and the optional `onReload` callback.
213
+ - Plus everything from `useDocyrusDataViewSelect` except `gridViewSelectProps`: `views`, `fields`, `dataSource`, `activeViewId`, `setActiveViewId`, `isLoading`, `error`, `refetch`.
214
+
172
215
  ## Important behavior
173
216
 
174
217
  - `gridProps` already carries the active view's paging settings. Usually you should just spread it into `<DataGrid>`.
175
218
  - Backend-saved views store field slugs, not reserved columns like `select` or `actions`. The hook re-prepends and re-pins those reserved columns for you.
176
219
  - In `data` mode the search box becomes client-side global filtering. In backend modes it becomes `filterKeyword`.
177
220
  - The hook controls TanStack `columnFilters` state. If you build a manual page, replicate this so toolbar filter changes can drive your row query.
221
+ - `collection.updateMany` / `collection.deleteMany` are required for bulk update/delete to use the collection layer; otherwise the hook falls back to the direct items endpoints.
178
222
 
179
223
  ## Default recommendation
180
224