@docyrus/docyrus 0.0.18 → 0.0.20

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 (52) hide show
  1. package/agent-loader.js +5 -2
  2. package/agent-loader.js.map +2 -2
  3. package/main.js +185 -31
  4. package/main.js.map +2 -2
  5. package/package.json +3 -3
  6. package/resources/pi-agent/prompts/coder-system.md +106 -0
  7. package/resources/pi-agent/skills/docyrus-platform/SKILL.md +71 -0
  8. package/resources/pi-agent/skills/docyrus-platform/references/ai-capabilities.md +43 -0
  9. package/resources/pi-agent/skills/docyrus-platform/references/auth-and-multi-tenancy.md +35 -0
  10. package/resources/pi-agent/skills/docyrus-platform/references/automation-and-workflows.md +30 -0
  11. package/resources/pi-agent/skills/docyrus-platform/references/core-building-blocks.md +53 -0
  12. package/resources/pi-agent/skills/{docyrus-api-dev → docyrus-platform}/references/data-source-query-guide.md +32 -28
  13. package/resources/pi-agent/skills/docyrus-platform/references/developer-tools.md +28 -0
  14. package/resources/pi-agent/skills/docyrus-platform/references/docyrus-cli-usage.md +503 -0
  15. package/resources/pi-agent/skills/{docyrus-api-dev → docyrus-platform}/references/formula-design-guide-llm.md +15 -23
  16. package/resources/pi-agent/skills/docyrus-platform/references/integrations-and-events.md +60 -0
  17. package/resources/pi-agent/skills/docyrus-platform/references/platform-services.md +58 -0
  18. package/resources/pi-agent/skills/docyrus-platform/references/querying-and-data-operations.md +27 -0
  19. package/resources/pi-agent/prompts/coder-append-system.md +0 -19
  20. package/resources/pi-agent/skills/docyrus-ai/SKILL.md +0 -28
  21. package/resources/pi-agent/skills/docyrus-api-dev/SKILL.md +0 -161
  22. package/resources/pi-agent/skills/docyrus-api-dev/references/api-client.md +0 -349
  23. package/resources/pi-agent/skills/docyrus-api-dev/references/authentication.md +0 -238
  24. package/resources/pi-agent/skills/docyrus-api-dev/references/query-and-formulas.md +0 -592
  25. package/resources/pi-agent/skills/docyrus-api-doctor/SKILL.md +0 -70
  26. package/resources/pi-agent/skills/docyrus-api-doctor/references/checklist-details.md +0 -588
  27. package/resources/pi-agent/skills/docyrus-app-dev/SKILL.md +0 -159
  28. package/resources/pi-agent/skills/docyrus-app-dev/references/api-client-and-auth.md +0 -275
  29. package/resources/pi-agent/skills/docyrus-app-dev/references/collections-and-patterns.md +0 -352
  30. package/resources/pi-agent/skills/docyrus-app-dev/references/data-source-query-guide.md +0 -2059
  31. package/resources/pi-agent/skills/docyrus-app-dev/references/formula-design-guide-llm.md +0 -320
  32. package/resources/pi-agent/skills/docyrus-app-dev/references/query-guide.md +0 -525
  33. package/resources/pi-agent/skills/docyrus-app-ui-design/SKILL.md +0 -466
  34. package/resources/pi-agent/skills/docyrus-app-ui-design/references/component-selection-guide.md +0 -602
  35. package/resources/pi-agent/skills/docyrus-app-ui-design/references/icon-usage-guide.md +0 -463
  36. package/resources/pi-agent/skills/docyrus-app-ui-design/references/preferred-components-catalog.md +0 -242
  37. package/resources/pi-agent/skills/docyrus-apps/SKILL.md +0 -54
  38. package/resources/pi-agent/skills/docyrus-architect/SKILL.md +0 -174
  39. package/resources/pi-agent/skills/docyrus-architect/references/custom-query-guide.md +0 -410
  40. package/resources/pi-agent/skills/docyrus-architect/references/data-source-query-guide.md +0 -2059
  41. package/resources/pi-agent/skills/docyrus-architect/references/formula-design-guide-llm.md +0 -320
  42. package/resources/pi-agent/skills/docyrus-architect/references/formula-reference.md +0 -145
  43. package/resources/pi-agent/skills/docyrus-auth/SKILL.md +0 -100
  44. package/resources/pi-agent/skills/docyrus-cli-app/SKILL.md +0 -279
  45. package/resources/pi-agent/skills/docyrus-cli-app/references/cli-manifest.md +0 -532
  46. package/resources/pi-agent/skills/docyrus-cli-app/references/list-query-examples.md +0 -248
  47. package/resources/pi-agent/skills/docyrus-curl/SKILL.md +0 -32
  48. package/resources/pi-agent/skills/docyrus-discover/SKILL.md +0 -63
  49. package/resources/pi-agent/skills/docyrus-ds/SKILL.md +0 -95
  50. package/resources/pi-agent/skills/docyrus-env/SKILL.md +0 -21
  51. package/resources/pi-agent/skills/docyrus-studio/SKILL.md +0 -369
  52. package/resources/pi-agent/skills/docyrus-tui/SKILL.md +0 -15
@@ -1,352 +0,0 @@
1
- # Collections & App Patterns Reference
2
-
3
- ## Table of Contents
4
-
5
- 1. [Collection Architecture](#collection-architecture)
6
- 2. [Generated Collection Structure](#generated-collection-structure)
7
- 3. [Collection Types](#collection-types)
8
- 4. [useUsersCollection](#useuserscollection)
9
- 5. [TanStack Query Hooks Pattern](#tanstack-query-hooks-pattern)
10
- 6. [Query Key Factory Pattern](#query-key-factory-pattern)
11
- 7. [Mutation Pattern](#mutation-pattern)
12
- 8. [App Bootstrap Flow](#app-bootstrap-flow)
13
- 9. [Routing Setup](#routing-setup)
14
- 10. [API Endpoints](#api-endpoints)
15
-
16
- ---
17
-
18
- ## Collection Architecture
19
-
20
- Collections are auto-generated from `openapi.json` using `@docyrus/tanstack-db-generator`. They provide type-safe CRUD operations for each data source.
21
-
22
- **Generate command**: `pnpm generate-orm` (runs `@docyrus/tanstack-db-generator openapi.json`)
23
-
24
- **Key files:**
25
- - `src/collections/<app>-<entity>.collection.ts` — generated React hooks with CRUD methods + entity types
26
- - `src/collections/types.ts` — shared query types (filters, calculations, formulas, etc.)
27
- - `src/collections/users.collection.ts` — special system users collection hook
28
-
29
- ---
30
-
31
- ## Generated Collection Structure
32
-
33
- Each collection exports an entity interface and a React hook that returns CRUD methods:
34
-
35
- ```typescript
36
- // Generated collection for base/project
37
- import { useDocyrusClient } from '@docyrus/signin'
38
- import type { ICollectionListParams } from './types'
39
-
40
- export interface BaseProjectEntity {
41
- id?: string
42
- record_owner?: string
43
- created_on?: string
44
- created_by?: string
45
- last_modified_on?: string
46
- last_modified_by?: string
47
- name: string
48
- description?: Record<string, any>
49
- status?: { id: string; name: string } | any
50
- organization?: { id: string; name: string } | string
51
- }
52
-
53
- export function useBaseProjectCollection() {
54
- const client = useDocyrusClient()
55
-
56
- return {
57
- list: (params?: ICollectionListParams): Promise<Array<BaseProjectEntity>> =>
58
- client!.get('/v1/apps/base/data-sources/project/items', params as any),
59
-
60
- get: (recordId: string, params?: { columns?: Array<string> }): Promise<BaseProjectEntity> =>
61
- client!.get(`/v1/apps/base/data-sources/project/items/${recordId}`, params),
62
-
63
- create: (data: Record<string, any>): Promise<BaseProjectEntity> =>
64
- client!.post('/v1/apps/base/data-sources/project/items', data),
65
-
66
- update: (recordId: string, data: Record<string, any>): Promise<BaseProjectEntity> =>
67
- client!.patch(`/v1/apps/base/data-sources/project/items/${recordId}`, data),
68
-
69
- delete: (recordId: string): Promise<void> =>
70
- client!.delete(`/v1/apps/base/data-sources/project/items/${recordId}`),
71
-
72
- deleteMany: (data: { recordIds: Array<string> }): Promise<void> =>
73
- client!.delete('/v1/apps/base/data-sources/project/items', data),
74
- }
75
- }
76
- ```
77
-
78
- Collections are hooks because they use `useDocyrusClient()` internally, which provides the authenticated `RestApiClient` from `DocyrusAuthProvider`. This means collections must be called inside React components.
79
-
80
- ### Default Fields (always present)
81
- Every data source entity includes: `id`, `record_owner`, `created_on`, `created_by`, `last_modified_on`, `last_modified_by`, `name`
82
-
83
- ---
84
-
85
- ## Collection Types
86
-
87
- Shared query parameter types in `src/collections/types.ts`:
88
-
89
- - `ICollectionListParams` — full query payload with columns, filters, calculations, formulas, childQueries, pivot, orderBy, limit, offset, fullCount, expand
90
- - `ICollectionFilterRule` — single filter rule
91
- - `ICollectionFilterGroup` — nested filter group
92
- - `ICollectionCalculation` — aggregation rule
93
- - `ICollectionFormula` — simple formula
94
- - `ICollectionBlockFormula` — block/subquery formula
95
- - `ICollectionChildQuery` — child query definition
96
- - `ICollectionPivot` / `ICollectionPivotMatrix` — pivot configuration
97
- - `ICollectionOrderBy` — sort specification
98
-
99
- ---
100
-
101
- ## useUsersCollection
102
-
103
- System users collection hook with special methods:
104
-
105
- ```typescript
106
- export function useUsersCollection() {
107
- const client = useDocyrusClient()
108
-
109
- return {
110
- getUsers: (): Promise<Array<UserEntity>> =>
111
- client!.get('/v1/users'),
112
-
113
- getMyInfo: (): Promise<UserEntity> =>
114
- client!.get('/v1/users/me'),
115
-
116
- createUser: (data: UserCreateParams): Promise<UserEntity> =>
117
- client!.post('/v1/users', data),
118
-
119
- updateMe: (data: UserUpdateParams): Promise<UserEntity> =>
120
- client!.patch('/v1/users/me', data),
121
-
122
- updateUser: (userId: string, data: UserUpdateParams): Promise<UserEntity> =>
123
- client!.patch(`/v1/users/${userId}`, data),
124
-
125
- changeUserStatus: (userId: string, status: number) =>
126
- client!.put(`/v1/users/${userId}/status/${status}`),
127
-
128
- saveUserDevice: (data: UserDeviceDto) =>
129
- client!.post('/v1/users/device', data),
130
-
131
- getMyTenants: () =>
132
- client!.get('/v1/users/me/tenants'),
133
- }
134
- }
135
- ```
136
-
137
- Use `useUsersCollection().getMyInfo()` for current user profile.
138
-
139
- ---
140
-
141
- ## TanStack Query Hooks Pattern
142
-
143
- Wrap collection hook methods in TanStack Query hooks. Since collections are themselves hooks, call them inside the component/hook, then pass the returned methods to TanStack Query:
144
-
145
- ```typescript
146
- import { useQuery } from '@tanstack/react-query'
147
- import { useBaseProjectCollection } from '@/collections/base-project.collection'
148
- import { queryKeys } from '@/lib/query-keys'
149
-
150
- const PROJECT_COLUMNS = ['name', 'status', 'description', 'record_owner(id,firstname,lastname)']
151
-
152
- export function useProjects(params?: ICollectionListParams) {
153
- const { list } = useBaseProjectCollection()
154
- return useQuery({
155
- queryKey: queryKeys.projects.list(params ?? {}),
156
- queryFn: () =>
157
- list({
158
- columns: PROJECT_COLUMNS, // ALWAYS specify columns
159
- ...params,
160
- }),
161
- })
162
- }
163
-
164
- export function useProject(projectId: string) {
165
- const { get } = useBaseProjectCollection()
166
- return useQuery({
167
- queryKey: queryKeys.projects.detail(projectId),
168
- queryFn: () =>
169
- get(projectId, {
170
- columns: PROJECT_COLUMNS,
171
- }),
172
- enabled: !!projectId,
173
- })
174
- }
175
- ```
176
-
177
- ---
178
-
179
- ## Query Key Factory Pattern
180
-
181
- ```typescript
182
- export const queryKeys = {
183
- projects: {
184
- all: ['projects'] as const,
185
- lists: () => [...queryKeys.projects.all, 'list'] as const,
186
- list: (params: object) => [...queryKeys.projects.lists(), params] as const,
187
- detail: (id: string) => [...queryKeys.projects.all, 'detail', id] as const,
188
- },
189
- tasks: {
190
- all: ['tasks'] as const,
191
- lists: () => [...queryKeys.tasks.all, 'list'] as const,
192
- list: (params: object) => [...queryKeys.tasks.lists(), params] as const,
193
- detail: (id: string) => [...queryKeys.tasks.all, 'detail', id] as const,
194
- },
195
- }
196
- ```
197
-
198
- ---
199
-
200
- ## Mutation Pattern
201
-
202
- ```typescript
203
- import { useMutation, useQueryClient } from '@tanstack/react-query'
204
- import { useBaseProjectCollection } from '@/collections/base-project.collection'
205
-
206
- export function useCreateProject() {
207
- const { create } = useBaseProjectCollection()
208
- const queryClient = useQueryClient()
209
- return useMutation({
210
- mutationFn: (data: Record<string, unknown>) => create(data),
211
- onSuccess: () => {
212
- void queryClient.invalidateQueries({
213
- queryKey: queryKeys.projects.all,
214
- })
215
- },
216
- })
217
- }
218
-
219
- export function useUpdateProject() {
220
- const { update } = useBaseProjectCollection()
221
- const queryClient = useQueryClient()
222
- return useMutation({
223
- mutationFn: ({ id, data }: { id: string; data: Record<string, unknown> }) =>
224
- update(id, data),
225
- onSuccess: (_data, { id }) => {
226
- void queryClient.invalidateQueries({ queryKey: queryKeys.projects.detail(id) })
227
- void queryClient.invalidateQueries({ queryKey: queryKeys.projects.lists() })
228
- },
229
- })
230
- }
231
-
232
- export function useDeleteProject() {
233
- const { delete: deleteProject } = useBaseProjectCollection()
234
- const queryClient = useQueryClient()
235
- return useMutation({
236
- mutationFn: (id: string) => deleteProject(id),
237
- onSuccess: () => {
238
- void queryClient.invalidateQueries({ queryKey: queryKeys.projects.all })
239
- },
240
- })
241
- }
242
- ```
243
-
244
- ---
245
-
246
- ## App Bootstrap Flow
247
-
248
- 1. `main.tsx`: Mount `DocyrusAuthProvider` → `QueryClientProvider` → `RouterProvider`
249
- 2. `App.tsx`: Check `useDocyrusAuth()` status
250
- 3. Use collection hooks (e.g., `useUsersCollection()`) for data access — they get the authenticated client via `useDocyrusClient()` internally
251
- 4. Fetch user profile via `useUsersCollection().getMyInfo()`
252
- 5. Render protected routes
253
-
254
- ```typescript
255
- // App.tsx
256
- function App() {
257
- const { status, signOut } = useDocyrusAuth()
258
- const { getMyInfo } = useUsersCollection()
259
-
260
- if (status === 'loading') return <LoadingSpinner />
261
- if (status === 'unauthenticated') return <LoginPage />
262
- return <AppLayout />
263
- }
264
- ```
265
-
266
- ---
267
-
268
- ## Routing Setup
269
-
270
- TanStack Router with code-based routes:
271
-
272
- ```typescript
273
- import { createRouter, createRoute, createRootRoute } from '@tanstack/react-router'
274
-
275
- const rootRoute = createRootRoute({ component: () => <Outlet /> })
276
-
277
- const layoutRoute = createRoute({
278
- getParentRoute: () => rootRoute,
279
- id: 'layout',
280
- component: AppLayout,
281
- })
282
-
283
- const indexRoute = createRoute({
284
- getParentRoute: () => layoutRoute,
285
- path: '/',
286
- component: DashboardPage,
287
- })
288
-
289
- const projectsRoute = createRoute({
290
- getParentRoute: () => layoutRoute,
291
- path: '/projects',
292
- component: ProjectsPage,
293
- })
294
-
295
- const projectDetailRoute = createRoute({
296
- getParentRoute: () => layoutRoute,
297
- path: '/projects/$projectId',
298
- component: ProjectDetailPage,
299
- })
300
-
301
- // Auth routes (public)
302
- const authCallbackRoute = createRoute({
303
- getParentRoute: () => rootRoute,
304
- path: '/auth/callback',
305
- component: () => <div>Processing login...</div>,
306
- })
307
-
308
- const routeTree = rootRoute.addChildren([
309
- layoutRoute.addChildren([indexRoute, projectsRoute, projectDetailRoute]),
310
- authCallbackRoute,
311
- ])
312
-
313
- const router = createRouter({
314
- routeTree,
315
- defaultPreload: 'intent',
316
- scrollRestoration: true,
317
- })
318
- ```
319
-
320
- ---
321
-
322
- ## API Endpoints
323
-
324
- ### Data Source Items (Dynamic)
325
- ```
326
- GET /v1/apps/{appSlug}/data-sources/{slug}/items — List (with query payload)
327
- GET /v1/apps/{appSlug}/data-sources/{slug}/items/{id} — Get one
328
- POST /v1/apps/{appSlug}/data-sources/{slug}/items — Create
329
- PATCH /v1/apps/{appSlug}/data-sources/{slug}/items/{id} — Update
330
- DELETE /v1/apps/{appSlug}/data-sources/{slug}/items/{id} — Delete one
331
- DELETE /v1/apps/{appSlug}/data-sources/{slug}/items — Delete many
332
- ```
333
-
334
- Endpoints are **dynamic** — they exist only if a data source is defined in the tenant. The `openapi.json` spec enumerates all available data sources.
335
-
336
- ### System Endpoints (Always Available)
337
- ```
338
- GET /v1/users — List users
339
- POST /v1/users — Create user
340
- GET /v1/users/me — Current user profile
341
- PATCH /v1/users/me — Update current user
342
- PATCH /v1/users/{userId} — Update user
343
- PUT /v1/users/{userId}/status/{s} — Change user status
344
- POST /v1/users/device — Save push notification device
345
- ```
346
-
347
- ### Other Standard Endpoints
348
- ```
349
- GET /v1/api/openapi.json — Generate OpenAPI spec
350
- HEAD /v1/oauth2 — Check rate limits
351
- PUT reports/runCustomQuery/{id} — Run custom query/report
352
- ```