functions-capability
Apply and build the Universal App functions capability. Use for trusted server-side logic, secrets, external APIs, custom model endpoints, published Fabric data agents, webhooks, or privileged operations.
- License 许可
- MIT
- 所属仓库
- microsoft/rayfin
- 最近更新
- 2026-11-12
- Stars
- ★ 662
- Forks
- 77
01 前言 Front Matter
- name
- functions-capability
- description
- Apply and build the Universal App functions capability. Use for trusted server-side logic, secrets, external APIs, custom model endpoints, published Fabric data agents, webhooks, or privileged operations.
02 资源文件 10
- 参考文档kit/functions/host.json388 B
- 参考文档kit/functions/local.settings.json189 B
- 参考文档kit/functions/package.json592 B
- 脚本kit/functions/src/function_app.ts238 B
- 脚本kit/functions/src/types.ts303 B
- 参考文档kit/functions/tsconfig.json313 B
- 脚本kit/rayfin-client.ts2.8 KB
- 脚本kit/scripts/validate-functions.mjs25.2 KB
- 脚本kit/vite-env.d.ts664 B
- 参考文档pack.json4.1 KB
03 SKILL.md 正文
Rayfin functions
Use functions when code must be trusted, needs a secret, or must call a service without exposing credentials or access tokens to the browser.
Apply the capability first
Run this before customizing the app:
npm run pack:add -- functions
The pack enables services.functions, creates the @rayfin-app/functions
workspace package under packages/functions, installs all workspace
dependencies from the root, builds functions before the frontend, and wires
AppFunctionsSchema into the existing client.
The existing Vite adapter forwards the client's default
/functions/<name>/invoke route to the local Functions host selected by
rayfin dev; do not add a direct functionsBaseUrl override.
Do not copy these files by hand.
Reapplying the pack preserves authored functions and generated types unless
--force-seeds is explicitly used.
Install guidance and use the workspace-aware development session
Install or refresh the version-matched functions agent context separately:
npx rayfin init ai-files install --enable skill:rayfin-functions --non-interactive
The active session does not refresh its skill registry after installation, so
do not call the skill tool for rayfin-functions in the same turn.
Read .agents/skills/rayfin-functions/SKILL.md directly from disk, then read
the package documentation under node_modules/@microsoft/ before writing
Rayfin APIs.
Do not stop or restart.
For Functions authentication, read the Application authentication section in the installed @microsoft/rayfin-guide documentation at functions/index.md.
Do not run npx rayfin functions init in this workspace template.
The current command writes, installs, builds, and generates types under the
legacy rayfin/functions location instead of the configured
services.functions.path at packages/functions.
That would create a second functions project and leave the workspace package's
generated types stale.
Use the documented root npm run dev session for type generation and local
function development.
It resolves services.functions.path, performs the initial generation in
packages/functions, and watches registered function signature edits.
Before starting a Fabric-backed development session that may provision or reuse
a backend, read the installed local-development guide and obtain the user's
approval for the target workspace.
Satisfy its documented Node.js and Azure Functions Core Tools prerequisites.
Do not deploy only to obtain generated types. If the approved development session cannot start, report the prerequisite or target blocker and leave generated files unchanged. There is no standalone public type-generation command to substitute.
Authoring sequence
- Apply the functions pack.
- Install the version-matched agent context with
npx rayfin init ai-files install --enable skill:rayfin-functions --non-interactive. - Read the installed skill directly from disk and read the package docs relevant to the function.
- With the target approved and local prerequisites available, run
npm run devfrom the workspace root and wait for its initial type-generation pass. - Replace the starter registration in
packages/functions/src/function_app.ts. - Keep explicit input and output types on every registered function, and keep the development session running while registered signatures change. Wait for the watcher to refresh the generated schema after each signature edit.
- Never edit
packages/functions/src/types.tsby hand. Never castclient.functions, the Rayfin client, or a handwritten invoker to bypass a function missing fromAppFunctionsSchema. A green TypeScript build afteras anyoras unknown asis not a valid generated contract. - Run
npm run validate:functionsand confirm every authoredudf.func()registration is present inAppFunctionsSchemawith no Functions-client casts. - After generated types are current, run the root
npm run typecheckandnpm run buildgates. - Invoke the function through the typed client from the frontend.
- Preserve loading, empty, success, expected-failure, and unexpected-failure states.
- Run the normal app validation and deployment workflow.
Security boundary
- Keep secrets and access tokens inside the function.
- Never put secrets in chat, source, YAML values, frontend environment variables, command arguments, logs, or function output.
- Never log prompts, user content, authorization headers, access tokens, raw provider bodies, or sensitive exception details.
- Bound user input, outbound request duration, provider output, and the value returned to the browser.
- Return typed safe results for expected configuration, authentication, provider, and timeout outcomes.
- Surface unexpected failures without returning credentials or provider internals.
For a secret-backed service, continue with external-api-workflows.
For Fabric data-agent access, continue with fabric-data-agent.
What the pack validates
The template tests prove that applying the pack:
- Enables the functions service and its build command.
- Creates
packages/functionsas@rayfin-app/functions. - Wires the generated schema into the frontend client while preserving the Vite same-origin Functions route.
- Fails validation when authored function registrations and
AppFunctionsSchemadiffer. - Rejects frontend casts around the Functions client that hide a stale generated contract.
- Builds functions before the frontend in the root build scripts.
- Preserves authored functions and generated files when reapplied.
- Leaves existing authentication, data, and analytics pack behavior intact.
The pack does not prove that a deployment has its required secret values, resource permissions, or downstream endpoint access. Those checks require a deployed scenario. The template and CLI checks cover missing functions packages, type generation, generated-contract freshness, unsafe Functions-client casts, and workspace build failures separately.
04 同仓库更多 Skills
rayfin-getting-started
Use when starting or creating a NEW Rayfin app, or when a Rayfin task comes up and you are not yet inside a Rayfin project. Gets you into a project with the Rayfin CLI, then hands off to the authoritative, version-locked in-project rayfin skill/docs that own all in-project work. Triggers: build a Rayfin app, start a Rayfin project, create a new Rayfin app, create-rayfin, npm create @microsoft/rayfin, rayfin init, scaffold rayfin, rayfin CLI, rayfin template, universal app, awesome-rayfin gallery, get started with Rayfin
visuals
Use when user wants to incorporate charts, graphs, data grid, or other visual representations of data into their project. Use VegaVisual and DataGrid components to create these visuals, utilizing the shared DataTable input, formatting, theme, and interactivity. Covers the onInteraction selection/click events host apps consume, named multi-table data input for layered overlays and reference lines, and Vega-Lite native selections. Triggers: chart, graph, plot, dashboard, KPI, metric, trend, scorecard, data grid, visualize.
schema-discovery
Explore Power BI semantic model schemas using DAX INFO functions. Progressive metadata discovery strategy, scope estimation, and narrowing techniques for tables, columns, measures, and relationships.
query-design
Separates DAX data-fetching from TypeScript presentation. Guides when to use DAX vs. TypeScript vs. Vega-Lite for aggregation, total rows, FORMAT(), SELECTCOLUMNS, BLANK handling, filtering, multi-grain queries, cross-filtering and cross-highlight subset/overlay queries, and format strings.
fabric-sdk
How to query Fabric data from a running app through the Rayfin connectors client. Use getRayfinClient().connectors.<name>.executeQuery to run DAX against a semantic model, and toQueryResult to normalize the response.
fabric-data-agent
Call a published Fabric data agent from a Universal App through a Rayfin function using application auth and MCP streamable HTTP. Use when the request names a Fabric data agent, data-agent MCP endpoint, or asks to chat with governed Fabric data through an app.