AGENT SKILL

rayfin

Use when doing ANY task involving Rayfin — scaffolding, data models, decorators, auth, deployment, CLI commands, or client setup. Triggers: rayfin, rayfin init, rayfin up, rayfin login, RayfinClient, @entity, @role, @anonymous, @authenticated, @text, @uuid, @int, @decimal, @boolean, @date, @email, @set, @one, @many, DAB, Data API Builder, rayfin.yml, publishableKey, signUp, signIn, signOut, sendMagicLink, handleMagicLinkCallback, ensureSignedInWithFabric, Fabric SSO, Entra ID, rayfin up db apply, rayfin up staticapp deploy, schema.ts, OpaqueSession, onSessionChange, GraphQL select, GraphQL create, GraphQL update, GraphQL delete, findById, executePaginated, RLS policy, row-level security, claims.sub, claims.email, TC39 decorators, config generation, dialect, mssql, postgresql

License 许可
MIT
最近更新
2026-11-13
Stars
★ 112
Forks
70

01 前言 Front Matter

name
rayfin
metadata
{ "author": "microsoft", "version": "0.3.0" }
description
Use when doing ANY task involving Rayfin — scaffolding, data models, decorators, auth, deployment, CLI commands, or client setup. Triggers: rayfin, rayfin init, rayfin up, rayfin login, RayfinClient, @entity, @role, @anonymous, @authenticated, @text, @uuid, @int, @decimal, @boolean, @date, @email, @set, @one, @many, DAB, Data API Builder, rayfin.yml, publishableKey, signUp, signIn, signOut, sendMagicLink, handleMagicLinkCallback, ensureSignedInWithFabric, Fabric SSO, Entra ID, rayfin up db apply, rayfin up staticapp deploy, schema.ts, OpaqueSession, onSessionChange, GraphQL select, GraphQL create, GraphQL update, GraphQL delete, findById, executePaginated, RLS policy, row-level security, claims.sub, claims.email, TC39 decorators, config generation, dialect, mssql, postgresql
rayfin-managed
true

03 SKILL.md 正文

Rayfin

Rayfin Docs

Rayfin's documentation is available via MCP tools and the rayfin docs CLI. Use these for code examples, API details, and troubleshooting — not this skill. Docs are version-locked to the Rayfin packages installed in the user's project. Run MCP and CLI lookups from the project root so local node_modules wins whether the CLI/MCP package is installed locally, globally, or through npx.

MCP tools (if the rayfin MCP server is connected):

  • search_docs(query: '<topic>', module: 'guide') — builder guides and tutorials
  • search_docs(query: '<topic>', module: 'ts-sdk') — TypeScript SDK API reference
  • get_doc(symbol: '<decorator or class>') — resolve a symbol to its docs
  • discover_packages(query: '<topic>') — find missing or too-old Rayfin packages when installed docs do not cover the task

CLI fallback (when MCP is unavailable):

  • rayfin docs search '<topic>' --module guide — builder guides and tutorials
  • rayfin docs search '<topic>' --module ts-sdk — TypeScript SDK API reference
  • rayfin docs get --symbol '<decorator or class>' — resolve a symbol to its docs
  • rayfin docs discover '<topic>' — find a Rayfin package when installed docs do not cover the task

If rayfin is not on PATH, use npx -y @microsoft/rayfin-cli docs ... from the project root.

Key doc topics:

  • Known limitations — FK naming, constraint limits, relationship rules
  • Data permissions — @role decorator, policy DSL, field visibility
  • GraphQL data access — RayfinClient setup, query chain, mutations
  • Auth overview — auth methods, session handling
  • Fabric deployment — workspace and static app deployment workflow

Before creating entities or writing queries, check known limitations:

search_docs(query: 'known limitations', module: 'guide')
# or: npx -y @microsoft/rayfin-cli docs search 'known limitations' --module guide

Rules

Platform

  • Rayfin uses TC39 Stage 3 decorators — never enable experimentalDecorators or emitDecoratorMetadata.
  • Include ESNext.Decorators in the tsconfig lib array.
  • Two deployment targets: Rayfin Local (Docker, MSSQL or PostgreSQL) and Fabric Apps (managed, MSSQL only).
  • Prefer npm create @microsoft/rayfin@latest for new projects — it generates correct tsconfig and schema boilerplate.

Security

  • Every entity must have an explicit permission decorator (@role, @anonymous, @authenticated) — entities without one are inaccessible.
  • Add policy: (claims, item) => claims.sub.eq(item.user_id) for row-level filtering on user-scoped data.
  • Use exclude in role options to hide sensitive fields (e.g., exclude: ['secret']).
  • Publishable keys (pk-*) are safe for client-side code — never expose service secrets or connection strings.
  • Keep allowedRedirectUris in rayfin.yml tightly scoped to your app's origin.
  • Email/password auth is local development only — deployed Fabric apps support Fabric SSO (Entra ID) exclusively.
  • Fabric SSO only works inside the Fabric Portal — do not attempt it in local development.

Data Modeling

  • Define entities with @entity() in rayfin/data/ and register them in rayfin/data/schema.ts as type AppSchema = { Name: Name }.
  • Every field needs exactly one decorator: @uuid, @text, @int, @decimal, @boolean, @date, @email, @set.
  • Fields are required by default — use { optional: true } and ? together for nullable fields.
  • @text() length option is max (not maxLength) — e.g., @text({ max: 200 }).
  • Use @one(() => Target) with lazy arrow functions for relationships — Rayfin auto-generates FK columns named {property}_id.
  • Use import (not import type) for entity classes referenced in @one()/@many() arrow functions — decorators need the runtime class value.
  • FK columns referencing another entity ({property}_id) must use @uuid() to match the PK type. Auth-based fields like user_id from claims.sub use @text().
  • Many-to-many requires an explicit join entity with two @one() fields.
  • Use @many(() => Target) for the inverse side of relationships.

Querying

  • Query chain: .select() → .where() → .orderBy() → .execute().
  • Single record by ID: client.data.Entity.findById('uuid-here') — not findByPk.
  • Filter by FK columns using {property}_id (e.g., customer_id), not dot-path (e.g., customer.id).
  • Dot-paths are for .select() only (e.g., customer.companyName).
  • Use .first(n).executePaginated() for cursor-based pagination.
  • Sort directions must be lowercase: 'asc' or 'desc'.

Schema

  • For Fabric: rayfin up is the canonical command for "deploy this change," "apply this schema change," or "push my entity update" — it deploys the app and applies pending schema migrations in a single step. Recommend it on every deploy, including incremental schema changes after the initial deploy.
  • rayfin up db apply is a narrow advanced subcommand that applies schema-only without touching the static build — only recommend it when the user explicitly asks to skip the static deploy step.
  • --force permits destructive changes (drop table, drop column, alter type) — never use without review.
  • --gen-config-only generates the underlying API config without applying — use to inspect before applying.

Deployment

  • When the user asks to "build and deploy," "make it live," or "deploy this change" (including schema-only changes like adding a column), execute the full workflow — do not present steps as instructions for the user to run manually.
  • Workflow: rayfin login → rayfin up → rayfin up status. rayfin up builds the static app, deploys it, and applies any pending schema migrations.
  • rayfin up status checks endpoint health — run after deployment to verify.
  • Deployment metadata is written to rayfin/.deployments.json (per-workspace record: fabricItemId, hostingUrl, publishableKey, etc.). The deploy also appends the live hosting URL to allowedRedirectUris in rayfin.yml.

Anti-Patterns

  • Never use raw fetch() or hand-built GraphQL for data operations — always use client.data.<Entity> (provides type-safe queries and automatic auth).
  • Never omit permission decorators on entities — always add an explicit @permissions(...). Forgetting silently applies authenticated: * (full CRUD for any signed-in user), which is usually too permissive for production data.
  • Never use @text() without max on MSSQL — always set @text({ max: N }) (e.g. max: 200 for typical strings). NVARCHAR(MAX) breaks GraphQL schema generation and cannot be uniquely indexed.
  • Never use @text() for FK columns that reference another entity's @uuid() PK — use @uuid() to match types. (user_id from claims.sub is @text(), not a FK.)
  • Never skip search_docs('known limitations') before implementing entities — always run it first to surface platform constraints (text length caps, supported scalar types, MSSQL-specific gotchas) that affect entity design.

CLI Quick Reference

# Scaffold
npm create @microsoft/rayfin@latest <name>   # Create from template
npx rayfin init [directory]                   # Interactive setup

# Deploy to Fabric (default workflow)
npx rayfin login                              # Sign in with Entra ID
npx rayfin up                                 # Deploy app + apply schema (canonical)
npx rayfin up status                          # Check deployment health
npx rayfin up db apply                        # Schema-only, skip static deploy (advanced)
npx rayfin up staticapp deploy                # Redeploy static content

04 同仓库更多 Skills

microsoft
microsoft/awesome-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.

★ 112
microsoft
microsoft/awesome-rayfin

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.

★ 112
microsoft
microsoft/awesome-rayfin

rayfin

Use when doing ANY task involving Rayfin — scaffolding, data models, decorators, auth, deployment, CLI commands, or client setup. Triggers: rayfin, rayfin init, rayfin up, rayfin login, RayfinClient, @entity, @role, @anonymous, @authenticated, @text, @uuid, @int, @decimal, @boolean, @date, @email, @set, @one, @many, DAB, Data API Builder, rayfin.yml, publishableKey, signUp, signIn, signOut, sendMagicLink, handleMagicLinkCallback, ensureSignedInWithFabric, Fabric SSO, Entra ID, rayfin up db apply, rayfin up staticapp deploy, schema.ts, OpaqueSession, onSessionChange, GraphQL select, GraphQL create, GraphQL update, GraphQL delete, findById, executePaginated, RLS policy, row-level security, claims.sub, claims.email, TC39 decorators, config generation, dialect, mssql, postgresql

★ 112
microsoft
microsoft/awesome-rayfin

rayfin-connectors

Use for Rayfin connectors that wire existing Fabric SQL data sources (Lakehouse, Warehouse, SQL Database) into an app as GraphQL-backed entities. Triggers: rayfin connector, rayfin up connector apply, connectors:, fabric-sqlanalytics, fabric-warehouse, fabric-sqldatabase, kusto, kql, eventhouse, workspaceId, itemId, operations:, AppConnectorsSchema, ConnectorsSchema, rayfin/connectors/, metadata.json, connector @role policy, connector claims.sub filter, connector claims.email filter, ConnectorsRayfinClient, rayfin-client.ts, client.connectors, connectorConfig, GraphQLBackedConnector, RestrictedDataApi, schema.ts aggregate, generate entities from metadata, add a use case on specific entities, wire connector into client, call a connector from the SDK, rayfin connector inspect, inspect connector data, sample connector rows, fabric-semanticmodel, --entity, --query, DAX EVALUATE, read-only sample query, rayfin connector search, discover connectable sources, find fabric sources to add, --all-workspaces, --workspace-id, connector search interactive picker, rayfin connector invoke, invoke a connector operation, run executeQuery, --input, --file, RAYFIN_FEATURE_FLAGS, resultSetRowCountLimit, limit rows, row limit, cap rows, too many rows, overflow

数据分析师后端与接口
★ 112
microsoft
microsoft/awesome-rayfin

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.

设计师演示文稿视觉设计
★ 112
microsoft
microsoft/awesome-rayfin

playwright-cli

Automate browser interactions, test web pages and work with Playwright tests.

测试与质量
★ 112