@docyrus/docyrus 0.0.30 → 0.0.32

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 (30) hide show
  1. package/agent-loader.js +36 -25
  2. package/agent-loader.js.map +4 -4
  3. package/main.js +4 -4
  4. package/main.js.map +1 -1
  5. package/package.json +3 -3
  6. package/resources/pi-agent/extensions/docyrus-web-browser.ts +31 -0
  7. package/resources/pi-agent/shared/docyrusWebBrowserProtocol.ts +169 -0
  8. package/resources/pi-agent/skills/diffity-diff/SKILL.md +1 -1
  9. package/resources/pi-agent/skills/diffity-resolve/SKILL.md +4 -4
  10. package/resources/pi-agent/skills/diffity-review/SKILL.md +5 -4
  11. package/resources/pi-agent/skills/docyrus-api-dev/SKILL.md +197 -0
  12. package/resources/pi-agent/skills/docyrus-api-dev/references/acl-endpoints-frontend.md +295 -0
  13. package/resources/pi-agent/skills/docyrus-api-dev/references/api-client.md +349 -0
  14. package/resources/pi-agent/skills/docyrus-api-dev/references/authentication.md +298 -0
  15. package/resources/pi-agent/skills/docyrus-api-dev/references/data-source-query-guide.md +2063 -0
  16. package/resources/pi-agent/skills/docyrus-api-dev/references/formula-design-guide-llm.md +312 -0
  17. package/resources/pi-agent/skills/docyrus-api-dev/references/query-and-formulas.md +592 -0
  18. package/resources/pi-agent/skills/docyrus-app-dev-react/SKILL.md +361 -0
  19. package/resources/pi-agent/skills/docyrus-app-dev-react/references/README.md +29 -0
  20. package/resources/pi-agent/skills/docyrus-app-dev-react/references/api-client-and-auth.md +326 -0
  21. package/resources/pi-agent/skills/docyrus-app-dev-react/references/collections-and-patterns.md +353 -0
  22. package/resources/pi-agent/skills/docyrus-app-dev-react/references/component-selection-guide.md +619 -0
  23. package/resources/pi-agent/skills/docyrus-app-dev-react/references/icon-usage-guide.md +463 -0
  24. package/resources/pi-agent/skills/docyrus-app-dev-react/references/preferred-components-catalog.md +242 -0
  25. package/resources/pi-agent/skills/docyrus-platform/SKILL.md +2 -2
  26. package/resources/pi-agent/skills/docyrus-platform/references/auth-and-multi-tenancy.md +9 -1
  27. package/resources/pi-agent/skills/docyrus-platform/references/developer-tools.md +3 -2
  28. package/server-loader.js +328 -87
  29. package/server-loader.js.map +4 -4
  30. package/resources/pi-agent/extensions/multi-edit.ts +0 -835
@@ -0,0 +1,361 @@
1
+ ---
2
+ name: docyrus-app-dev-react
3
+ description: Build Docyrus React TypeScript web applications end-to-end, combining authentication, API access, @docyrus/app-utils runtime helpers, generated collections, TanStack Query/Form patterns, and production-grade UI implementation with preferred component libraries. Use when creating or modifying Docyrus-backed apps that use @docyrus/api-client, @docyrus/signin, @docyrus/app-utils, Docyrus collections, queries, dashboards, forms, tables, layouts, or Docyrus UI components.
4
+ ---
5
+
6
+ # Docyrus App Dev React
7
+
8
+ Build Docyrus React TypeScript applications end-to-end. This skill combines app architecture, authentication, data access, query patterns, and production-grade UI guidance in one place.
9
+
10
+ ## Tech Stack
11
+
12
+ - React 19 + TypeScript + Vite
13
+ - TanStack Router (code-based), TanStack Query (server state), TanStack Form
14
+ - Tailwind CSS v4, shadcn/ui components
15
+ - `@docyrus/api-client` + `@docyrus/signin` + `@docyrus/app-utils`
16
+ - Auto-generated collections from OpenAPI spec
17
+ - Preferred UI libraries: shadcn, diceui, animate-ui, docyrus-ui, reui
18
+
19
+ ## When to Use This Skill
20
+
21
+ Use this skill when you are:
22
+
23
+ - Building or modifying a Docyrus-backed React app
24
+ - Setting up authentication with `@docyrus/signin`
25
+ - Bootstrapping tenant-aware runtime utilities with `@docyrus/app-utils`
26
+ - Fetching or mutating data with generated collections or `@docyrus/api-client`
27
+ - Persisting app-level config or saved grid views with `AppConfig` and `DataViews`
28
+ - Building record sharing, role management, or ACL-driven UI flows
29
+ - Designing feature UIs such as dashboards, forms, tables, layouts, dialogs, analytics, or detail pages
30
+ - Selecting between shadcn, diceui, animate-ui, docyrus-ui, and reui components
31
+ - Implementing complete feature flows that combine data access and polished UI
32
+
33
+ ## End-to-End Feature Workflow
34
+
35
+ 1. Set up app auth, routing, and query providers.
36
+ 2. Bootstrap `TenantPreferences`, date/number utilities, and shared app runtime helpers from `@docyrus/app-utils`.
37
+ 3. Use generated Docyrus collection hooks or the REST client for data access.
38
+ 4. Define `columns`, filters, formulas, child queries, and mutations correctly.
39
+ 5. Use `AppConfig` for per-app persisted settings and `DataViews` for saved grid views.
40
+ 6. Check preferred UI components before building anything custom.
41
+ 7. Use Docyrus form and detail patterns for create, edit, item detail, and editable grid flows.
42
+ 8. Connect UI actions to TanStack Query mutations and invalidate relevant queries.
43
+
44
+ ## Quick Start: App Bootstrap
45
+
46
+ ### Root provider setup
47
+
48
+ ```tsx
49
+ import { DocyrusAuthProvider } from '@docyrus/signin'
50
+
51
+ <DocyrusAuthProvider
52
+ apiUrl={import.meta.env.VITE_API_BASE_URL}
53
+ clientId={import.meta.env.VITE_OAUTH2_CLIENT_ID}
54
+ redirectUri={import.meta.env.VITE_OAUTH2_REDIRECT_URI}
55
+ scopes={['offline_access', 'Read.All', 'DS.ReadWrite.All', 'Users.Read']}
56
+ callbackPath="/auth/callback"
57
+ >
58
+ <QueryClientProvider client={queryClient}>
59
+ <RouterProvider router={router} />
60
+ </QueryClientProvider>
61
+ </DocyrusAuthProvider>
62
+ ```
63
+
64
+ ### Auth gate and current-user access
65
+
66
+ ```tsx
67
+ const { status, user, hasRole, hasPermission } = useDocyrusAuth()
68
+
69
+ if (status === 'loading') return <Spinner />
70
+ if (status === 'unauthenticated') return <SignInButton />
71
+
72
+ // user is auto-fetched from /v1/users/me after authentication
73
+ // hasRole('super_admin') — check role by slug or uid
74
+ // hasPermission('edit', dataSourceId) — check ACL permission on a data source
75
+ ```
76
+
77
+ ### Tenant-aware app utilities
78
+
79
+ Use `@docyrus/app-utils` as the default runtime layer for tenant-level formatting and persisted app/grid preferences.
80
+
81
+ ```tsx
82
+ import {
83
+ createAppConfigClient,
84
+ createDataViewClient,
85
+ createDateUtils,
86
+ createNumberUtils,
87
+ getTenantPreferences,
88
+ } from '@docyrus/app-utils'
89
+
90
+ function useAppRuntime(appId: string) {
91
+ const client = useDocyrusClient()
92
+ const { getMyInfo } = useUsersCollection()
93
+
94
+ return useQuery({
95
+ queryKey: ['app-runtime', appId],
96
+ enabled: !!client && !!appId,
97
+ queryFn: async () => {
98
+ const [preferences, me] = await Promise.all([
99
+ getTenantPreferences(client!),
100
+ getMyInfo(),
101
+ ])
102
+
103
+ return {
104
+ preferences,
105
+ me,
106
+ dateUtils: createDateUtils({
107
+ preferences,
108
+ userTimezone: me.timeZone?.id,
109
+ }),
110
+ numberUtils: createNumberUtils({ preferences }),
111
+ appConfig: createAppConfigClient(client!, appId),
112
+ dataViews: createDataViewClient(client!, appId),
113
+ }
114
+ },
115
+ })
116
+ }
117
+ ```
118
+
119
+ Use this runtime to:
120
+
121
+ - Format dates and datetimes with tenant format strings and the user's timezone.
122
+ - Format numbers, currency-like values, and decimals using tenant separators and precision.
123
+ - Read and upsert the app's single persisted `AppConfig` document.
124
+ - Read and persist saved grid views through `DataViews`.
125
+
126
+ ### Data fetching with generated collections
127
+
128
+ ```tsx
129
+ const { list } = useBaseProjectCollection()
130
+
131
+ const { data: projects } = useQuery({
132
+ queryKey: ['projects'],
133
+ queryFn: () =>
134
+ list({
135
+ columns: ['name', 'status', 'record_owner(firstname,lastname)'],
136
+ filters: { rules: [{ field: 'status', operator: '!=', value: 'archived' }] },
137
+ orderBy: 'created_on DESC',
138
+ limit: 50,
139
+ }),
140
+ })
141
+ ```
142
+
143
+ ### ACL, roles, and record sharing
144
+
145
+ Use direct `useDocyrusClient()` calls for ACL features. These routes may be hidden from generated OpenAPI output, so they are typically not available through generated collection hooks.
146
+
147
+ ```tsx
148
+ const client = useDocyrusClient()
149
+
150
+ const { data: roles } = useQuery({
151
+ queryKey: ['acl', 'roles'],
152
+ queryFn: () => client!.get('/v1/users/acl/roles'),
153
+ })
154
+
155
+ const replaceUserRoles = useMutation({
156
+ mutationFn: ({ userId, roleIds }: { userId: string; roleIds: string[] }) =>
157
+ client!.put(`/v1/users/acl/users/${userId}/roles`, { roleIds }),
158
+ })
159
+
160
+ const createRoleQuery = useMutation({
161
+ mutationFn: (payload: Record<string, unknown>) =>
162
+ client!.post('/v1/users/acl/role-queries', payload),
163
+ })
164
+ ```
165
+
166
+ Prefer role `uid` values returned by the API when sending `roleIds` for user-role updates or role-query payloads.
167
+
168
+ ### Saved data grid views
169
+
170
+ Use `DataGridViewSelect` as the default saved-view UI for Docyrus grids, and persist those views with `createDataViewClient(client, appId)`.
171
+
172
+ - `DataGridViewSelect` is the default component for showing and editing saved grid views.
173
+ - Pass the TanStack table instance via `table` so the selector/editor can read column definitions.
174
+ - Pass `fields` when you want the built-in filter builder enabled in the editor.
175
+ - Back `views`, `onViewCreate`, `onViewSave`, `onViewDelete`, `onViewHide`, and `onViewUnhide` with `DataViews` CRUD.
176
+ - Use `DataGridViewEditor` separately only when you need a standalone editor outside the selector.
177
+
178
+ ## Critical App/Data Rules
179
+
180
+ 1. **Always send `columns`** in `.list()` and `.get()` calls. Without it, only `id` is returned.
181
+ 2. **Collections are React hooks** — call `useBaseProjectCollection()`, `useUsersCollection()`, and similar hooks inside React components.
182
+ 3. **Data source endpoints are dynamic** — they only exist if the data source is defined in the tenant OpenAPI spec.
183
+ 4. **Use `id` for `count` calculations**. Use actual field slugs for `sum`, `avg`, `min`, and `max`.
184
+ 5. **Child query keys must appear in `columns`**.
185
+ 6. **Formula keys must appear in `columns`**.
186
+ 7. **Use `useUsersCollection().getMyInfo()`** for current user profile instead of making a direct profile call.
187
+ 8. **Initialize `TenantPreferences` once per app runtime** and create shared `dateUtils` / `numberUtils` instances from `@docyrus/app-utils`.
188
+ 9. **Formatting functions from `@docyrus/app-utils` are regionalized** — do not hardcode locale, date format, decimal separator, thousand separator, or decimal precision when tenant preferences should drive them.
189
+ 10. **Use `createAppConfigClient(client, appId)`** for the app's single persisted config document; `upsert` is the default write path.
190
+ 11. **Use `createDataViewClient(client, appId)`** for saved grid-view CRUD.
191
+ 12. **Use `DataViews` with `DataGridViewSelect`** to show, create, edit, reorder, hide, unhide, soft-delete, and hard-delete saved data grid views.
192
+ 13. **`DataGridViewSelect` needs a TanStack table instance** and should receive `fields` when you want the built-in filter builder/editor experience.
193
+ 14. **Data view creation requires `name` and `tenant_data_source_id`**.
194
+ 15. **Use `dataViews.update(viewId, { archived: true })` for soft-delete** and `dataViews.remove(viewId)` only for irreversible hard-delete.
195
+ 16. **Regenerate collections after schema changes** by rebuilding the tenant OpenAPI spec, downloading the latest `openapi.json`, and re-running the collection generator.
196
+ 17. **ACL endpoints are usually raw-client integrations** — use `useDocyrusClient()` or `RestApiClient` for roles, user-role assignments, role queries, record sharing, and ownership transfer.
197
+ 18. **Prefer role `uid` values** for ACL role writes, user-role `roleIds`, and role-query `roleIds`.
198
+ 19. **Treat `PUT /v1/users/acl/users/:userId/roles` as full replacement** and `POST /v1/users/acl/users/:userId/roles` as additive.
199
+ 20. **Send role-query `query` as raw JSON** and omit `tenantAppId` when `dataSourceId` is present; backend derives it.
200
+ 21. **After deleting a role, invalidate dependent app queries** for role lists, user-role lists, role-query lists, and any UI that renders primary-role labels.
201
+
202
+ ## Critical UI/UX Rules
203
+
204
+ 1. **Always check preferred components first** before creating anything custom.
205
+ 2. **Use `AwesomeCard` for dashboards** unless the user explicitly wants a different card style.
206
+ 3. **Use animate-ui `Sidebar` for app layouts** unless another layout is requested.
207
+ 4. **Prefer Recharts for charts**. shadcn chart primitives are the default wrapper.
208
+ 5. **Use icons in this order**: hugeicons, then fontawesome light, then lucide.
209
+ 6. **Use `AwesomeDialog` for item create forms**.
210
+ - Small/simple forms: `container="sheet"` with `side="right"`
211
+ - Long/complex forms: `container="modal"` or `container="drawer"`
212
+ 7. **Choose detail containers based on item complexity**.
213
+ - Large items: dedicated page
214
+ - Small items: `AwesomeDialog` right sheet
215
+ 8. **All forms must use TanStack Form + the Docyrus form system**. Do not build feature forms with plain HTML forms or React Hook Form directly.
216
+ 9. **Use `EditableRecordDetail` for inline editing** in item detail views.
217
+ 10. **Always enable `trackChanges`** for editable detail and grid experiences.
218
+ 11. **Use `DataGridViewSelect` for saved grid views** and back it with `DataViews` from `@docyrus/app-utils`.
219
+ 12. **Prefer `DataGridViewEditor` only when you need a standalone grid-view editor** outside the selector component.
220
+
221
+ ## Default UI Choices
222
+
223
+ | Use Case | Default Component | Library |
224
+ |----------|-------------------|---------|
225
+ | Item create form | `AwesomeDialog` | docyrus |
226
+ | Quick record create | `CreateRecordDialog` | docyrus |
227
+ | Item detail (small) | `AwesomeDialog` sheet right | docyrus |
228
+ | Item detail (large) | Dedicated page | — |
229
+ | Inline editing | `EditableRecordDetail` | docyrus |
230
+ | Dashboard card | `AwesomeCard` | docyrus |
231
+ | Stat dashboards | `AwesomeStats` | docyrus |
232
+ | App navigation | `Sidebar` | animate-ui |
233
+ | Data table | `DataTable` | diceui |
234
+ | Editable grid | `Data Grid` | docyrus |
235
+ | Grid saved views | `DataGridViewSelect` + `DataViews` | docyrus + `@docyrus/app-utils` |
236
+ | Forms | Docyrus form fields + TanStack Form | docyrus |
237
+ | Charts | shadcn chart + Recharts | shadcn |
238
+ | File upload | File Upload | diceui |
239
+ | Gantt/project scheduling | `Gantt` | docyrus |
240
+ | Resource scheduling | `ResourceSchedulerPanel` | docyrus |
241
+ | Team chat | `TeamChatChannel` | docyrus |
242
+ | AI interface | `DocyrusAgent` | docyrus |
243
+ | Pricing / quoting | `PricingEnginePanel` | docyrus |
244
+ | Analytics / pivot | `PivotGrid` | docyrus |
245
+
246
+ ## Quick UI Patterns
247
+
248
+ ### Item create form
249
+
250
+ ```tsx
251
+ <AwesomeDialog open={open} onOpenChange={setOpen} container="sheet" side="right" size="default">
252
+ <AwesomeDialogHeader title="Create Task" icon="far-plus" />
253
+ <AwesomeDialogBody>
254
+ <form.Field name="title">{(field) => <TextFormField field={field} label="Title" />}</form.Field>
255
+ <form.Field name="status">{(field) => <SelectFormField field={field} label="Status" />}</form.Field>
256
+ </AwesomeDialogBody>
257
+ <AwesomeDialogFooter>
258
+ <Button variant="outline" onClick={() => setOpen(false)}>Cancel</Button>
259
+ <Button onClick={handleSubmit}>Create</Button>
260
+ </AwesomeDialogFooter>
261
+ </AwesomeDialog>
262
+ ```
263
+
264
+ ### Item detail with inline editing
265
+
266
+ ```tsx
267
+ <AwesomeDialog open={open} onOpenChange={setOpen} container="sheet" side="right" size="lg" fullscreenable>
268
+ <AwesomeDialogHeader
269
+ title="Task Detail"
270
+ description="Review and edit task fields inline"
271
+ headerButtons={<Button variant="outline" size="sm" onClick={switchToFullForm}>Edit All</Button>}
272
+ />
273
+ <AwesomeDialogBody>
274
+ <EditableRecordDetail fields={fields} record={record} onSave={handleSave} trackChanges>
275
+ <EditableRecordDetailField slug="title" />
276
+ <EditableRecordDetailField slug="status" />
277
+ <EditableRecordDetailField slug="assignee" />
278
+ <EditableRecordDetailField slug="due_date" />
279
+ </EditableRecordDetail>
280
+ </AwesomeDialogBody>
281
+ </AwesomeDialog>
282
+ ```
283
+
284
+ ## TanStack Query Pattern
285
+
286
+ ```typescript
287
+ function useProjects(params?: ICollectionListParams) {
288
+ const { list } = useBaseProjectCollection()
289
+ return useQuery({
290
+ queryKey: ['projects', 'list', params],
291
+ queryFn: () => list({ columns: PROJECT_COLUMNS, ...params }),
292
+ })
293
+ }
294
+
295
+ function useCreateProject() {
296
+ const { create } = useBaseProjectCollection()
297
+ const qc = useQueryClient()
298
+ return useMutation({
299
+ mutationFn: (data: Record<string, unknown>) => create(data),
300
+ onSuccess: () => {
301
+ void qc.invalidateQueries({ queryKey: ['projects'] })
302
+ },
303
+ })
304
+ }
305
+ ```
306
+
307
+ ## Collection CRUD Methods
308
+
309
+ ```typescript
310
+ const { list, get, create, update, delete: deleteOne, deleteMany } = useBaseProjectCollection()
311
+
312
+ list(params?: ICollectionListParams)
313
+ get(id, { columns })
314
+ create(data)
315
+ update(id, data)
316
+ deleteOne(id)
317
+ deleteMany({ recordIds })
318
+ ```
319
+
320
+ API endpoint pattern: `/v1/apps/{appSlug}/data-sources/{slug}/items`
321
+
322
+ ## Query Capabilities Summary
323
+
324
+ The `.list()` method supports:
325
+
326
+ - `columns`
327
+ - `filters`
328
+ - `filterKeyword`
329
+ - `orderBy`
330
+ - `limit` and `offset`
331
+ - `fullCount`
332
+ - `calculations`
333
+ - `formulas`
334
+ - `childQueries`
335
+ - `pivot`
336
+ - `expand`
337
+
338
+ ## Component Installation Pattern
339
+
340
+ ```bash
341
+ pnpm dlx shadcn@latest add button
342
+ pnpm dlx shadcn@latest add @diceui/data-table
343
+ pnpm dlx shadcn@latest add @animate-ui/sidebar
344
+ pnpm dlx @docyrus/cli add @docyrus/ui-awesome-card
345
+ pnpm dlx shadcn@latest add @reui/file-upload-default
346
+ ```
347
+
348
+ ## References
349
+
350
+ For deep dives, read:
351
+
352
+ - `references/README.md` — merged reference map for app development and UI design
353
+ - `references/api-client-and-auth.md`
354
+ - `references/collections-and-patterns.md`
355
+ - `../docyrus-api-dev/references/acl-endpoints-frontend.md`
356
+ - `../docyrus-api-dev/references/data-source-query-guide.md`
357
+ - `../docyrus-api-dev/references/formula-design-guide-llm.md`
358
+ - `../docyrus-api-dev/references/query-guide.md`
359
+ - `references/preferred-components-catalog.md`
360
+ - `references/component-selection-guide.md`
361
+ - `references/icon-usage-guide.md`
@@ -0,0 +1,29 @@
1
+ # Docyrus App Dev React Reference Map
2
+
3
+ This directory contains the full reference set for `docyrus-app-dev-react`.
4
+
5
+ ## App Development References
6
+
7
+ Read these files for data access, auth, query design, and collection patterns:
8
+
9
+ - `api-client-and-auth.md`
10
+ - `collections-and-patterns.md`
11
+ - `../../docyrus-api-dev/references/acl-endpoints-frontend.md`
12
+ - `../../docyrus-api-dev/references/data-source-query-guide.md`
13
+ - `../../docyrus-api-dev/references/formula-design-guide-llm.md`
14
+ - `../../docyrus-api-dev/references/query-guide.md`
15
+
16
+ ## UI Design References
17
+
18
+ Read these files for component selection, design patterns, and UI library guidance:
19
+
20
+ - `preferred-components-catalog.md`
21
+ - `component-selection-guide.md`
22
+ - `icon-usage-guide.md`
23
+
24
+ ## How to Use This Skill
25
+
26
+ 1. Start with `../SKILL.md` for the merged operating guidance.
27
+ 2. Use the app-development references when working on auth, queries, collections, routing, and mutations.
28
+ 3. Use the UI-design references when selecting components, designing layouts, or implementing polished feature flows.
29
+ 4. Combine both when building end-to-end Docyrus React features.