docyrus-app-dev by docyrus/agent-skills
npx skills add https://github.com/docyrus/agent-skills --skill docyrus-app-dev使用 Docyrus 作为后端构建 React TypeScript Web 应用。通过 OAuth2 PKCE 进行身份验证,使用强大的过滤/聚合功能查询数据源,并遵循既定模式。
@docyrus/api-client(REST 客户端) + @docyrus/signin(身份验证提供者)DocyrusAuthProvider 包装根组件:import { DocyrusAuthProvider } from '@docyrus/signin'
<DocyrusAuthProvider
apiUrl={import.meta.env.VITE_API_BASE_URL}
clientId={import.meta.env.VITE_OAUTH2_CLIENT_ID}
redirectUri={import.meta.env.VITE_OAUTH2_REDIRECT_URI}
scopes={['offline_access', 'Read.All', 'DS.ReadWrite.All', 'Users.Read']}
callbackPath="/auth/callback"
>
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
</QueryClientProvider>
</DocyrusAuthProvider>
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
2. 在 App.tsx 中,检查身份验证并使用集合钩子:
const { status } = useDocyrusAuth()
const { getMyInfo } = useUsersCollection()
if (status === 'loading') return <Spinner />
if (status === 'unauthenticated') return <SignInButton />
3. 在组件中使用集合钩子:
const { list } = useBaseProjectCollection()
const { data: projects } = useQuery({
queryKey: ['projects'],
queryFn: () => list({
columns: ['name', 'status', 'record_owner(firstname,lastname)'],
filters: { rules: [{ field: 'status', operator: '!=', value: 'archived' }] },
orderBy: 'created_on DESC',
limit: 50,
}),
})
.list() 和 .get() 调用中发送 columns。如果没有它,则只返回 id。useBaseProjectCollection()、useUsersCollection() 等。它们在内部使用 useDocyrusClient() 进行经过身份验证的 API 访问。count 计算使用 id 字段。对 sum、avg、min、max 使用实际的字段 slug。columns 中 — 例如,如果 childQuery 键是 orders,则在 columns 数组中包含 'orders'。columns 中 — 例如,如果公式键是 total,则在 columns 数组中包含 'total'。useUsersCollection().getMyInfo() 获取当前用户个人资料,而不是直接进行 API 调用。当通过 docyrus-architect MCP 工具创建、更新或删除数据源或字段时,应用的自动生成集合会变得过时。要重新同步:
调用 regenerate_openapi_spec(architect MCP)以重建并上传租户的 OpenAPI 规范
将新规范下载到仓库中,覆盖现有文件:
curl -o openapi.json "<publicUrl returned from step 1>"
重新生成集合:
pnpx @docyrus/tanstack-db-generator openapi.json
始终一起运行所有三个步骤 — 过时的 openapi.json 或过期的集合将在运行时导致端点缺失或不正确。
每个生成的集合都是一个返回 CRUD 方法的 React 钩子:
const { list, get, create, update, delete: deleteOne, deleteMany } = useBaseProjectCollection()
list(params?: ICollectionListParams) // 使用过滤器、排序、分页进行查询
get(id, { columns }) // 单条记录
create(data) // 创建
update(id, data) // 部分更新
deleteOne(id) // 删除一条
deleteMany({ recordIds }) // 删除多条
API 端点模式:/v1/apps/{appSlug}/data-sources/{slug}/items
.list() 方法支持:
| 功能 | 用途 |
|---|---|
columns | 选择字段、扩展关系 field(subfields)、别名 alias:field、展开 ...field() |
filters | 嵌套的 AND/OR 组,包含 50 多个操作符(比较、日期快捷方式、用户相关) |
filterKeyword | 全文搜索 |
orderBy | 按字段排序(带方向),包括相关字段 |
limit/offset | 分页(默认 100) |
fullCount | 返回结果的同时返回总计数 |
calculations | 聚合:带分组功能的 count、sum、avg、min、max |
formulas | 计算虚拟列(简单函数、块 AST、相关子查询) |
childQueries | 将相关的子记录作为嵌套的 JSON 数组获取 |
pivot | 带有日期范围序列的交叉表矩阵查询 |
expand | 返回关系/用户/枚举字段的完整对象,而不是 ID |
有关查询/公式的详细信息,请阅读:
references/data-source-query-guide.mdreferences/formula-design-guide-llm.md// 查询钩子 — 在组件内部调用集合钩子,将方法传递给 TanStack Query
function useProjects(params?: ICollectionListParams) {
const { list } = useBaseProjectCollection()
return useQuery({
queryKey: ['projects', 'list', params],
queryFn: () => list({ columns: PROJECT_COLUMNS, ...params }),
})
}
// 变更钩子
function useCreateProject() {
const { create } = useBaseProjectCollection()
const qc = useQueryClient()
return useMutation({
mutationFn: (data: Record<string, unknown>) => create(data),
onSuccess: () => { void qc.invalidateQueries({ queryKey: ['projects'] }) },
})
}
需要详细信息时请阅读这些文件:
references/api-client-and-auth.md — RestApiClient API、@docyrus/signin 钩子、身份验证提供者配置、拦截器、错误处理、SSE/流式传输、文件上传/下载references/data-source-query-guide.md — 最新的查询负载指南:columns、filters、orderBy、分页、calculations、formulas、child queries、pivots 以及操作符参考references/formula-design-guide-llm.md — 用于构建和验证 formulas 负载的最新公式设计指南references/collections-and-patterns.md — 生成的集合钩子、useUsersCollection、TanStack Query/变更钩子模式、查询键工厂、应用引导流程、路由设置、API 端点每周安装次数
83
代码仓库
GitHub 星标数
13
首次出现
2026年2月14日
安全审计
安装于
codex82
claude-code81
github-copilot80
gemini-cli80
opencode74
amp73
Build React TypeScript web apps with Docyrus as the backend. Authenticate via OAuth2 PKCE, query data sources with powerful filtering/aggregation, and follow established patterns.
@docyrus/api-client (REST client) + @docyrus/signin (auth provider)DocyrusAuthProvider:import { DocyrusAuthProvider } from '@docyrus/signin'
<DocyrusAuthProvider
apiUrl={import.meta.env.VITE_API_BASE_URL}
clientId={import.meta.env.VITE_OAUTH2_CLIENT_ID}
redirectUri={import.meta.env.VITE_OAUTH2_REDIRECT_URI}
scopes={['offline_access', 'Read.All', 'DS.ReadWrite.All', 'Users.Read']}
callbackPath="/auth/callback"
>
<QueryClientProvider client={queryClient}>
<RouterProvider router={router} />
</QueryClientProvider>
</DocyrusAuthProvider>
2. In App.tsx, check auth and use collection hooks:
const { status } = useDocyrusAuth()
const { getMyInfo } = useUsersCollection()
if (status === 'loading') return <Spinner />
if (status === 'unauthenticated') return <SignInButton />
3. Use collection hooks in components:
const { list } = useBaseProjectCollection()
const { data: projects } = useQuery({
queryKey: ['projects'],
queryFn: () => list({
columns: ['name', 'status', 'record_owner(firstname,lastname)'],
filters: { rules: [{ field: 'status', operator: '!=', value: 'archived' }] },
orderBy: 'created_on DESC',
limit: 50,
}),
})
columns in .list() and .get() calls. Without it, only id is returned.useBaseProjectCollection(), useUsersCollection(), etc. inside React components. They use useDocyrusClient() internally for authenticated API access.id field for count calculations. Use the actual field slug for , , , .When data sources or fields are created, updated, or deleted via the docyrus-architect MCP tools, the app's auto-generated collections become stale. To resync:
Call regenerate_openapi_spec (architect MCP) to rebuild and upload the tenant's OpenAPI spec
Download the new spec into the repo, overwriting the existing file:
curl -o openapi.json "<publicUrl returned from step 1>"
Regenerate collections:
pnpx @docyrus/tanstack-db-generator openapi.json
Always run all three steps together — a stale openapi.json or outdated collections will cause missing or incorrect endpoints at runtime.
Every generated collection is a React hook that returns CRUD methods:
const { list, get, create, update, delete: deleteOne, deleteMany } = useBaseProjectCollection()
list(params?: ICollectionListParams) // Query with filters, sort, pagination
get(id, { columns }) // Single record
create(data) // Create
update(id, data) // Partial update
deleteOne(id) // Delete one
deleteMany({ recordIds }) // Delete many
API endpoint pattern: /v1/apps/{appSlug}/data-sources/{slug}/items
The .list() method supports:
| Feature | Purpose |
|---|---|
columns | Select fields, expand relations field(subfields), alias alias:field, spread ...field() |
filters | Nested AND/OR groups with 50+ operators (comparison, date shortcuts, user-related) |
filterKeyword | Full-text search |
orderBy | Sort by fields with direction, including related fields |
For query/formula details, read :
references/data-source-query-guide.mdreferences/formula-design-guide-llm.md// Query hook — call collection hook inside the component, pass methods to TanStack Query
function useProjects(params?: ICollectionListParams) {
const { list } = useBaseProjectCollection()
return useQuery({
queryKey: ['projects', 'list', params],
queryFn: () => list({ columns: PROJECT_COLUMNS, ...params }),
})
}
// Mutation hook
function useCreateProject() {
const { create } = useBaseProjectCollection()
const qc = useQueryClient()
return useMutation({
mutationFn: (data: Record<string, unknown>) => create(data),
onSuccess: () => { void qc.invalidateQueries({ queryKey: ['projects'] }) },
})
}
Read these files when you need detailed information:
references/api-client-and-auth.md — RestApiClient API, @docyrus/signin hooks, auth provider config, interceptors, error handling, SSE/streaming, file upload/downloadreferences/data-source-query-guide.md — Up-to-date query payload guide: columns, filters, orderBy, pagination, calculations, formulas, child queries, pivots, and operator referencereferences/formula-design-guide-llm.md — Up-to-date formula design guide for building and validating formulas payloadsreferences/collections-and-patterns.md — Generated collection hooks, useUsersCollection, TanStack Query/mutation hook patterns, query key factories, app bootstrap flow, routing setup, API endpointsWeekly Installs
83
Repository
GitHub Stars
13
First Seen
Feb 14, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykWarn
Installed on
codex82
claude-code81
github-copilot80
gemini-cli80
opencode74
amp73
TanStack Query v5 完全指南:React 数据管理、乐观更新、离线支持
2,500 周安装
ULTRAQA 自主质量保证循环工具:自动化测试、构建、代码规范检查与修复
218 周安装
Vuetify0 无头组件库 - Vue 3 组合式函数与无样式UI构建块
219 周安装
AWS Serverless 开发指南:Lambda 函数与 API Gateway 集成模式最佳实践
216 周安装
Simplify代码简化工具 - 提升代码清晰度、一致性和可维护性的AI助手
222 周安装
GitHub CLI (gh) 使用指南:高效管理仓库、PR、议题与API调用
212 周安装
Cheerio HTML解析教程:Node.js网页抓取与DOM操作指南
214 周安装
sumavgminmaxcolumns — e.g., if childQuery key is orders, include 'orders' in the columns array.columns — e.g., if formula key is total, include 'total' in the columns array.useUsersCollection().getMyInfo() for current user profile, not a direct API call.limit/offset | Pagination (default 100) |
fullCount | Return total count alongside results |
calculations | Aggregations: count, sum, avg, min, max with grouping |
formulas | Computed virtual columns (simple functions, block AST, correlated subqueries) |
childQueries | Fetch related child records as nested JSON arrays |
pivot | Cross-tab matrix queries with date range series |
expand | Return full objects for relation/user/enum fields instead of IDs |