@docyrus/docyrus 0.0.67 → 0.0.69

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.
Files changed (22) hide show
  1. package/main.js +136 -136
  2. package/main.js.map +3 -3
  3. package/package.json +3 -3
  4. package/resources/pi-agent/extensions/pi-bash-live-view/widget.ts +2 -17
  5. package/resources/pi-agent/skills/docyrus-api-dev/SKILL.md +36 -1
  6. package/resources/pi-agent/skills/docyrus-api-doctor/SKILL.md +70 -0
  7. package/resources/pi-agent/skills/docyrus-api-doctor/references/checklist-details.md +588 -0
  8. package/resources/pi-agent/skills/docyrus-app-dev-react/SKILL.md +1 -1
  9. package/resources/pi-agent/skills/docyrus-app-dev-react/references/collections-and-patterns.md +0 -22
  10. package/resources/pi-agent/skills/docyrus-cli-app/SKILL.md +360 -0
  11. package/resources/pi-agent/skills/docyrus-cli-app/references/cli-manifest.md +627 -0
  12. package/resources/pi-agent/skills/docyrus-cli-app/references/list-query-examples.md +248 -0
  13. package/resources/pi-agent/skills/docyrus-data-grid-page-design/SKILL.md +61 -0
  14. package/resources/pi-agent/skills/docyrus-data-grid-page-design/references/advanced-saved-view-query-patterns.md +158 -0
  15. package/resources/pi-agent/skills/docyrus-data-grid-page-design/references/hook-pages.md +227 -0
  16. package/resources/pi-agent/skills/docyrus-data-grid-page-design/references/manual-pages.md +145 -0
  17. package/resources/pi-agent/skills/docyrus-data-grid-page-design/references/tenant-and-users-providers.md +290 -0
  18. package/resources/pi-agent/skills/docyrus-record-detail-form-design/SKILL.md +54 -0
  19. package/resources/pi-agent/skills/docyrus-record-detail-form-design/references/advanced-inline-edit-and-renderers.md +140 -0
  20. package/resources/pi-agent/skills/docyrus-record-detail-form-design/references/field-type-mapping-and-fallbacks.md +150 -0
  21. package/resources/pi-agent/skills/docyrus-record-detail-form-design/references/hook-form-view.md +127 -0
  22. package/resources/pi-agent/skills/docyrus-record-detail-form-design/references/manual-form-detail-patterns.md +125 -0
@@ -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
+ ```
@@ -0,0 +1,61 @@
1
+ ---
2
+ name: docyrus-data-grid-page-design
3
+ description: Build Docyrus React data-grid and record-list pages with `DataGrid`, `DataGridViewSelect`, `useDataGrid`, `useDocyrusDataViewSelect`, and `useDocyrusDataGrid`. Use when asked to build or refactor a list page, records table, CRM or ERP grid, saved-view tabs, row actions, manual DataGrid toolbar composition, or Docyrus data-source grid queries with filtering, sorting, grouping, search, display modes, paging, and reload behavior.
4
+ ---
5
+
6
+ # Docyrus Data Grid Page Design
7
+
8
+ Build full Docyrus list pages around the web `DataGrid` stack.
9
+
10
+ ## Choose the build mode
11
+
12
+ 1. **Standard Docyrus page** → use `useDocyrusDataGrid`.
13
+ - Best when rows come from a Docyrus data source or generated collection.
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
+ - 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`).
19
+ - Read `references/hook-pages.md`.
20
+
21
+ 2. **Custom layout or custom row-query lifecycle** → use `useDocyrusDataViewSelect` + `useDataGrid`.
22
+ - Best when you need a custom toolbar arrangement, local/demo data, or a non-standard fetch cycle.
23
+ - Read `references/manual-pages.md`.
24
+
25
+ 3. **No backend saved views** → use `useDataGrid` with local `SavedDataGridView[]` or `DataGridViewMenu`.
26
+ - Also covered in `references/manual-pages.md`.
27
+
28
+ 4. **Complex Docyrus query payloads** → also load the `docyrus-api-dev` skill.
29
+ 5. **Advanced saved-view persistence or manual view-driven queries** → read `references/advanced-saved-view-query-patterns.md`.
30
+ 6. **Tenant-aware formatters and shared users list** → read `references/tenant-and-users-providers.md`.
31
+
32
+ ## Default page workflow
33
+
34
+ 1. Confirm the `appSlug`, `dataSourceSlug`, and whether a generated collection already exists.
35
+ 2. Pick hook mode or manual mode.
36
+ 3. App-level: ensure a `TenantProvider` (preferences → date/number utils) and `UsersProvider` (`/v1/users` cache) wrap the route, and pull `formatDate` / `formatDateTime` / `formatNumber` / `users` into the grid hook from those contexts.
37
+ 4. Add reserved columns in this order: select first, actions second. They are pinned left automatically by `useDocyrusDataGrid`.
38
+ 5. Keep the page in a flex column layout with the grid body wrapped in `min-h-0 flex-1`.
39
+ 6. Add create/edit/view/delete dialogs around row actions.
40
+ 7. Verify initial saved view, search, filters, grouping, sorting, paging, and reload behavior.
41
+
42
+ ## Non-negotiables
43
+
44
+ - Render page-sized grids with the toolbar in a shrink-0 row and the grid inside `min-h-0 flex-1`.
45
+ - Prefer `<DataGrid table={table} {...gridProps} height="auto" />` for full-page layouts.
46
+ - Pass the TanStack `table` instance to every grid menu and to `DataGridViewSelect`.
47
+ - `useDocyrusDataViewSelect` manages view metadata only. It does **not** fetch rows and does **not** accept `table`.
48
+ - Manual Docyrus item queries must always send `columns`. Reference fields (`field-userSelect`, `field-userMultiSelect`, `field-relation`, `field-relatedField`, `field-select`, `field-radioGroup`, `field-enum`, `field-systemEnum`, `field-multiSelect`, `field-tagSelect`, `field-status`, `field-approvalStatus`) must also be added to the `expand` array so the API returns `{ id, name, ... }` payloads instead of bare IDs.
49
+ - Backend saved-view filters need enum options; `useDocyrusDataViewSelect` already fetches the data source with `expand=enums`.
50
+ - Manual pages must apply the initial active view with `applyViewToTable(table, activeView)` after views and columns are ready. User-triggered view switches through `DataGridViewSelect` are applied automatically.
51
+ - Prefer `useDocyrusDataGrid` unless you truly need custom row fetching or custom toolbar composition. The hook handles auto-expand, async filter options, formatters, and reserved-column pinning for you.
52
+ - When you wire manual view CRUD into `DataGridViewSelect`, pass `isSaving` and `isLoading` so the editor UX stays correct during saves and background fetches.
53
+ - For tenant-aware date/datetime/number formatting, fetch `getTenantPreferences(client)` once at app boot and pass the resulting `formatDate` / `formatDateTime` / `formatNumber` callbacks into `useDocyrusDataGrid`.
54
+ - For instant avatar + label rendering on user-typed cells, fetch `/v1/users` once at app boot and pass the resulting `CellUserOption[]` into `useDocyrusDataGrid` via the `users` option.
55
+
56
+ ## References
57
+
58
+ - `references/hook-pages.md` — one-call Docyrus grid pages with direct API mode, collection mode, extension points, formatters, and shared-users wiring.
59
+ - `references/manual-pages.md` — local/manual grid composition, local views, backend view-select wiring, and initial-view handling.
60
+ - `references/advanced-saved-view-query-patterns.md` — saved-view persistence, system views, hidden views, paging ownership, and translating active views into manual server queries.
61
+ - `references/tenant-and-users-providers.md` — app-level providers for tenant preferences and the shared users list, plus how to plug them into `useDocyrusDataGrid`.
@@ -0,0 +1,158 @@
1
+ # Advanced Saved-View and Query Patterns
2
+
3
+ ## Read this when
4
+
5
+ - You need backend-saved views but do not want `useDocyrusDataGrid` to own row fetching.
6
+ - You want system views plus user-saved views in one selector.
7
+ - You need to debug why a saved view, grouping rule, or paging setting is not reflected in the grid.
8
+ - You need to translate `SavedDataGridView` into a custom Docyrus items query.
9
+
10
+ ## Saved-view ownership model
11
+
12
+ - `DataGridViewSelect` applies the selected view to the TanStack table when the user clicks a tab or dropdown item.
13
+ - `useDocyrusDataGrid` also reapplies the active view on mount and whenever the active view changes, so the initial view works without extra code.
14
+ - Manual pages using `useDocyrusDataViewSelect` plus `useDataGrid` must still apply the initial active view with `applyViewToTable(table, activeView)`.
15
+
16
+ ## System views, hidden views, and persistence
17
+
18
+ `useDocyrusDataViewSelect` supports three useful layers of view state:
19
+
20
+ 1. `systemViews`
21
+ - Developer-defined static views.
22
+ - Automatically marked `isSystem: true`.
23
+ - Render before saved backend views.
24
+ - Cannot be edited or deleted through `DataGridViewSelect`, but can still be hidden.
25
+
26
+ 2. active-view persistence
27
+ - Controlled by `persistActiveView` and `persistKey`.
28
+ - Default storage namespace: `docyrus:data-grid-view:appSlug:dataSourceSlug[:appId]`.
29
+ - Initial resolution order: current in-memory value, stored value, backend `is_default`, then first available view.
30
+
31
+ 3. hidden-view persistence
32
+ - Managed through `hiddenViewIds`, `onViewHide`, and `onViewUnhide` in `gridViewSelectProps`.
33
+ - Stored separately from the active-view key.
34
+ - Useful when system views should exist but not always stay visible in the tab strip.
35
+
36
+ ## Manual server-query translation from a saved view
37
+
38
+ If you keep custom row fetching, derive request params from the active view yourself. Don't forget the toolbar filter merge — `DataGridFilterMenu` writes to TanStack `columnFilters`, and a manual page must AND-merge those into the saved-view filter payload.
39
+
40
+ ```ts
41
+ const activeView = views.find(view => view.id === activeViewId);
42
+
43
+ const columns = buildColumnsFromView(fields, activeView);
44
+ const orderBy = (activeView?.sorting ?? []).map(sort => ({
45
+ field: sort.id,
46
+ direction: sort.desc ? 'desc' : 'asc'
47
+ }));
48
+
49
+ // Auto-expand reference-type fields so the API returns `{ id, name, ... }` payloads.
50
+ const EXPANDABLE_FIELD_TYPES = new Set([
51
+ 'field-userSelect', 'field-userMultiSelect',
52
+ 'field-relation', 'field-relatedField',
53
+ 'field-select', 'field-radioGroup',
54
+ 'field-enum', 'field-systemEnum',
55
+ 'field-multiSelect', 'field-tagSelect',
56
+ 'field-status', 'field-approvalStatus'
57
+ ]);
58
+ const expand = fields
59
+ .filter(field => columns.includes(field.slug) && EXPANDABLE_FIELD_TYPES.has(field.type))
60
+ .map(field => field.slug);
61
+
62
+ // Merge saved-view filters with toolbar filter state.
63
+ const viewFilter = activeView?.filterQuery?.rules?.length ? activeView.filterQuery : undefined;
64
+ const toolbarRules = (table.getState().columnFilters ?? [])
65
+ .map(filter => toServerRule(filter)) // import from @docyrus/ui/components/data-grid/lib/data-grid-server
66
+ .filter(Boolean);
67
+
68
+ let filters;
69
+
70
+ if (viewFilter && toolbarRules.length > 0) {
71
+ filters = { combinator: 'and', rules: [viewFilter, ...toolbarRules] };
72
+ } else if (viewFilter) {
73
+ filters = viewFilter;
74
+ } else if (toolbarRules.length > 0) {
75
+ filters = { combinator: 'and', rules: toolbarRules };
76
+ }
77
+
78
+ const params = {
79
+ columns,
80
+ orderBy: orderBy.length > 0 ? orderBy : undefined,
81
+ filters,
82
+ filterKeyword: keyword || undefined,
83
+ expand: expand.length > 0 ? expand : undefined,
84
+ limit: 50,
85
+ offset: 0
86
+ };
87
+ ```
88
+
89
+ Rules to preserve from the built-in hook behavior:
90
+
91
+ - Always include `id` in `columns`.
92
+ - When `columnOrder` is present, treat it as the ordered whitelist of visible field slugs.
93
+ - Otherwise use `columnVisibility` entries with `true` values.
94
+ - With no explicit saved-view visibility config, fetch all field slugs.
95
+ - If the active view groups by a field, make sure that field stays in `columns` even if the saved view hides it.
96
+ - Add reference-type field slugs to `expand` so user / relation / status / select / multi-select cells render with full data.
97
+ - AND-merge `view.filterQuery` with the toolbar filter rules; reset `pageIndex` to 0 when the merged filter changes.
98
+ - If you merge app-specific overrides, apply them last so they win.
99
+
100
+ ## Reserved columns versus backend field slugs
101
+
102
+ There are two different conventions:
103
+
104
+ - Local/manual views can include reserved table columns like `select` and `actions` inside `columnOrder`.
105
+ - Backend Docyrus-saved views only know real data-source field slugs.
106
+
107
+ That difference matters when you build a hybrid page. If you manually persist local views, reserved columns are safe. If you round-trip views through Docyrus backend APIs, assume only real field slugs are persisted and prepend reserved UI columns in the page code.
108
+
109
+ ## Paging ownership
110
+
111
+ Saved views can carry:
112
+
113
+ - `pagingEnabled`
114
+ - `pagingMode`
115
+ - `pageSize`
116
+
117
+ `useDocyrusDataGrid` reads those values and forwards them into `useDataGrid`, and `gridProps` then carries the resolved paging mode.
118
+
119
+ If you build the page manually and want the active view to own paging:
120
+
121
+ - read the values from `activeView`
122
+ - pass `pagingMode` and `pageSize` into `useDataGrid`
123
+ - ensure your own row query or pagination model stays compatible with that page size
124
+
125
+ If you ignore these properties in manual mode, the view editor can save paging settings that never affect the rendered grid.
126
+
127
+ ## Good advanced combinations
128
+
129
+ ### System starter views + backend user views
130
+
131
+ Use `systemViews` for non-editable defaults like:
132
+
133
+ - All records
134
+ - My records
135
+ - Needs attention
136
+ - Recently updated
137
+
138
+ Then let users create their own backend-saved views beside them.
139
+
140
+ ### Hook-owned metadata + app-owned data fetching
141
+
142
+ Use `useDocyrusDataViewSelect` when you want:
143
+
144
+ - backend view CRUD
145
+ - field metadata for the filter editor
146
+ - active-view persistence
147
+ - hidden-view persistence
148
+
149
+ but you still want the page's existing query hook, export pipeline, or analytics request builder to own row fetching.
150
+
151
+ ## Debug checklist
152
+
153
+ - **Wrong initial view?** Check `persistActiveView`, `persistKey`, and whether a stale value is still in local storage.
154
+ - **Grouping not working?** Make sure the grouping field is included in fetched `columns` and remains visible enough for the row model.
155
+ - **Filter builder missing?** Pass `fields` into `DataGridViewSelect`.
156
+ - **View tabs empty during loading?** Pass `isLoading` so the selector can render its loading state.
157
+ - **Editor closes too early on save?** Pass `isSaving` when the host owns async create or update.
158
+ - **Backend returns incomplete rows?** You probably forgot `columns`.