@microsoft/rayfin-guide 1.1.0 → 1.33.0-beta.1
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.
- package/assets/docs/app-backend/deploy.md +256 -0
- package/assets/docs/app-backend/index.md +126 -0
- package/assets/docs/app-backend/pricing.md +66 -0
- package/assets/docs/auth/fabric.md +328 -0
- package/assets/docs/auth/index.md +33 -0
- package/assets/docs/auth/overview.md +130 -0
- package/assets/docs/cli/ai-files.md +146 -0
- package/assets/docs/cli/env-interpolation.md +187 -0
- package/assets/docs/cli/env-migration.md +135 -0
- package/assets/docs/cli/environment-variables.md +173 -0
- package/assets/docs/cli/index.md +84 -0
- package/assets/docs/cli/installation.md +107 -0
- package/assets/docs/cli/quickstart.md +88 -0
- package/assets/docs/data/graphql.md +267 -0
- package/assets/docs/data/index.md +20 -0
- package/assets/docs/data/overview.md +270 -0
- package/assets/docs/data/permissions.md +172 -0
- package/assets/docs/data/validation.md +165 -0
- package/assets/docs/getting-started/create-app-with-cli.md +118 -0
- package/assets/docs/getting-started/create-rayfin-item.md +73 -0
- package/assets/docs/getting-started/index.md +201 -0
- package/assets/docs/getting-started/project-structure.md +290 -0
- package/assets/docs/hosting/index.md +183 -0
- package/assets/docs/index.md +92 -45
- package/assets/docs/known-limitations.md +50 -0
- package/assets/docs/preview/local-dev-docker.md +124 -0
- package/package.json +1 -1
- package/assets/docs/quickstart.md +0 -81
package/assets/docs/index.md
CHANGED
|
@@ -1,52 +1,99 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
2
|
+
sidebar_position: 1
|
|
3
3
|
---
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
Rayfin is
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
- **A
|
|
20
|
-
|
|
21
|
-
- **
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
5
|
+
# Overview
|
|
6
|
+
|
|
7
|
+
Rayfin is a backend platform for TypeScript developers who want to model data once and receive production ready APIs, clients, and infrastructure.
|
|
8
|
+
It combines decorator driven schema generation, a batteries included CLI, and backend services you can run locally or in production.
|
|
9
|
+
|
|
10
|
+
> **TypeScript only** — Rayfin currently supports TypeScript as the only language for data models, client code, and application logic.
|
|
11
|
+
|
|
12
|
+
## Who is a Rayfin Builder?
|
|
13
|
+
|
|
14
|
+
A **Rayfin Builder** is an application developer who uses the Rayfin SDK to build modern TypeScript SaaS applications.
|
|
15
|
+
As a builder, you focus on creating great user experiences while Rayfin handles the backend infrastructure.
|
|
16
|
+
|
|
17
|
+
### Rayfin Platform vs Rayfin Applications
|
|
18
|
+
|
|
19
|
+
- **Rayfin Platform**: A modern Backend-as-a-Service (BaaS) platform built for the agentic era that provides ready-to-use backend infrastructure
|
|
20
|
+
- **Rayfin App/Project**: Applications built using the Rayfin SDK, leveraging the platform's capabilities
|
|
21
|
+
- **Rayfin Builder**: App developers (you!) who build applications using Rayfin
|
|
22
|
+
- **Rayfin Contributor**: Platform developers who work on Rayfin itself (see [contributor docs](https://github.com/microsoft/project-rayfin?tab=contributing-ov-file))
|
|
23
|
+
|
|
24
|
+
## How to run Rayfin
|
|
25
|
+
|
|
26
|
+
Rayfin is available in two modes.
|
|
27
|
+
Choose the one that fits your stage and requirements.
|
|
28
|
+
|
|
29
|
+
| | **Rayfin Local** | **Fabric Data App in Fabric** |
|
|
30
|
+
| --- | --- | --- |
|
|
31
|
+
| **What it is** | Open-source, self-hostable backend stack | Managed service for Rayfin on Microsoft Fabric |
|
|
32
|
+
| **Authentication** | Entra ID, Email password | Fabric SSO (Entra ID single sign-on only) |
|
|
33
|
+
| **Database** | MSSQL, PostgreSQL | MSSQL only |
|
|
34
|
+
| **Data models & APIs** | ✅ | ✅ |
|
|
35
|
+
| **Type-safe clients** | ✅ | ✅ |
|
|
36
|
+
| **Static hosting** | ✅ | ✅ |
|
|
37
|
+
| **CLI tooling** | ✅ | ✅ |
|
|
38
|
+
| **Infrastructure** | You host (Docker, VMs, or any cloud) | Fabric manages hosting, scaling, and networking |
|
|
39
|
+
|
|
40
|
+
Both modes share the same SDK, CLI, and data-modeling workflow.
|
|
41
|
+
Start locally, then deploy to Fabric when you need a managed service — or stay self-hosted.
|
|
42
|
+
|
|
43
|
+
## What Rayfin Provides
|
|
44
|
+
|
|
45
|
+
- **Data models to APIs**: Decorate TypeScript classes and Rayfin generates database schemas plus REST and GraphQL endpoints automatically.
|
|
46
|
+
- **Type safe clients**: Type-safe clients provide validation of queries and mutations before they ever hit the backend.
|
|
47
|
+
- **Infrastructure automation**: Use Rayfin CLI tooling to spin up Rayfin stack provisions Data API Builder, authentication, database, and more so you can focus on product code.
|
|
48
|
+
- **Opinionated security**: Permissions, row level filters, and per entity auth rules are configured next to your models.
|
|
49
|
+
|
|
50
|
+
## Fabric Data App (Managed Service) Architecture
|
|
51
|
+
|
|
52
|
+
```mermaid
|
|
53
|
+
flowchart TB
|
|
54
|
+
Dev[Developer] -->|rayfin up| CLI[Rayfin CLI]
|
|
55
|
+
CLI -->|deploy| Fabric
|
|
56
|
+
|
|
57
|
+
subgraph Fabric[Microsoft Fabric]
|
|
58
|
+
direction LR
|
|
59
|
+
StaticApp[Static Content]
|
|
60
|
+
WebService[WebService]
|
|
61
|
+
DataApi[Data API Builder]
|
|
62
|
+
MSSQL[(MSSQL)]
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
User[End User] --> StaticApp
|
|
66
|
+
StaticApp --> WebService
|
|
67
|
+
WebService --> DataApi
|
|
68
|
+
DataApi --> MSSQL
|
|
69
|
+
WebService -->|Fabric SSO| EntraID[Entra ID]
|
|
44
70
|
```
|
|
45
71
|
|
|
46
|
-
|
|
47
|
-
|
|
72
|
+
When you deploy with `rayfin up`, the CLI packages your project and provisions it as a Fabric data app.
|
|
73
|
+
Fabric manages hosting, networking, and scaling.
|
|
74
|
+
Authentication uses Fabric SSO (Entra ID single sign-on) exclusively — no other auth providers are available after deployment.
|
|
75
|
+
|
|
76
|
+
Learn more about [Fabric Data App in Fabric](./app-backend/index.md) including child services, deployment, and management.
|
|
77
|
+
|
|
78
|
+
## Key Components
|
|
79
|
+
|
|
80
|
+
### Rayfin CLI
|
|
81
|
+
|
|
82
|
+
The CLI installs via `npm create @microsoft/rayfin@latest`.
|
|
83
|
+
It can scaffold new projects, launch local infrastructure, sync schema changes, and bundle templates for distribution
|
|
84
|
+
|
|
85
|
+
### TypeScript SDKs
|
|
86
|
+
|
|
87
|
+
- `@microsoft/rayfin-core` hosts the decorator runtime and metadata analysis helpers.
|
|
88
|
+
- `@microsoft/rayfin-client` wires auth, data into a single facade for apps.
|
|
89
|
+
- `@microsoft/rayfin-data` exposes GraphQL fluent (`client.data.gql`) APIs.
|
|
48
90
|
|
|
49
|
-
##
|
|
91
|
+
## Next Steps
|
|
50
92
|
|
|
51
|
-
|
|
52
|
-
to
|
|
93
|
+
- Follow the [Quick Start Guide](./getting-started/index.md) to spin up your first Rayfin project in minutes.
|
|
94
|
+
- Dive into [Data Models & Decorators](./data/overview.md) to understand how entities map to DAB.
|
|
95
|
+
- Learn how to connect frontends with the [GraphQL guide](./data/graphql.md).
|
|
96
|
+
- Configure authentication with [Rayfin Auth](./auth/overview.md).
|
|
97
|
+
- Deploy frontends with [Static Content Hosting](./hosting/index.md).
|
|
98
|
+
- Explore CLI capabilities in [CLI Guide](./cli/index.md).
|
|
99
|
+
- Review [Known Limitations](./known-limitations.md) for current behaviors and workarounds.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 80
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Known Limitations
|
|
6
|
+
|
|
7
|
+
Current limitations and recommended workarounds for Rayfin Builders.
|
|
8
|
+
|
|
9
|
+
## Data Client
|
|
10
|
+
|
|
11
|
+
- `count()` is not available on the fluent GraphQL client.
|
|
12
|
+
Select minimal fields and compute `results.length` instead.
|
|
13
|
+
- Many-to-many relationships are not supported.
|
|
14
|
+
Use an explicit join entity with two `@one()` navigations instead.
|
|
15
|
+
|
|
16
|
+
## Data API Builder (DAB)
|
|
17
|
+
|
|
18
|
+
Some query limitations are imposed by Data API Builder.
|
|
19
|
+
See [Data known limitations](./data/index.md#known-limitations).
|
|
20
|
+
|
|
21
|
+
## Relationships
|
|
22
|
+
|
|
23
|
+
- Rayfin auto-generates foreign key columns when you define `@one()` or `@many()` navigation decorators.
|
|
24
|
+
Define foreign key fields only when you need them in application code.
|
|
25
|
+
- When you do define a foreign key field, it must follow the `{property}_id` naming convention.
|
|
26
|
+
Custom key names (`foreignKey`, `targetKey`) are not supported on relationship decorators.
|
|
27
|
+
- `@one()` and `@many()` accept `{ optional?, unique? }` options only.
|
|
28
|
+
|
|
29
|
+
## Auth
|
|
30
|
+
|
|
31
|
+
- The session change callback is `onSessionChange`.
|
|
32
|
+
`onAuthStateChange` does not exist on the Rayfin auth client.
|
|
33
|
+
- Session objects are opaque.
|
|
34
|
+
Gate UI logic on `isAuthenticated` or the presence of a `user` property.
|
|
35
|
+
- After enabling or disabling auth in `rayfin.yml`, restart the backend to expose the updated endpoints.
|
|
36
|
+
|
|
37
|
+
## Data
|
|
38
|
+
|
|
39
|
+
- `@entity()` does not accept composite field constraints; define constraints on individual fields via field decortor options.
|
|
40
|
+
- Prefer `@anonymous()` and `@authenticated()` shorthands over `@role('anonymous', ...)` and `@role('authenticated', ...)`.
|
|
41
|
+
|
|
42
|
+
## Database and Schema Apply
|
|
43
|
+
|
|
44
|
+
- Run `npx rayfin up` and wait for services to be created before running `npx rayfin up db apply`.
|
|
45
|
+
- If you see `unsupported UUID` errors, another service may be running on the default port with a different database dialect.
|
|
46
|
+
- Enabling `data: enabled: true` in `rayfin.yml` requires `dialect: mssql` (or `postgresql`).
|
|
47
|
+
- Omitting `dialect` causes a 400 error at deploy time: "Dialect is required when Data module is enabled."
|
|
48
|
+
- `@text()` without `max` generates `NVARCHAR(MAX)` columns on MSSQL.
|
|
49
|
+
- Rayfin's metadata provider may fail to build a GraphQL schema from these columns, resulting in "Internal server error" at runtime after an otherwise successful deploy.
|
|
50
|
+
- Use `@text({ max: N })` on all string fields to avoid this.
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
# Local development with Docker
|
|
2
|
+
|
|
3
|
+
> **Preview content** — this page is not published in the public docs.
|
|
4
|
+
> To enable Docker-based local development, set `RAYFIN_FEATURE_FLAGS=docker-local-dev`.
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
The `rayfin dev` command provides a Docker Compose–based local development environment.
|
|
9
|
+
It launches containers for enabled services, runs health checks, and auto-applies the database configuration.
|
|
10
|
+
|
|
11
|
+
Docker and Docker Compose must be installed and running before using this command.
|
|
12
|
+
|
|
13
|
+
## Starting the environment
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npx rayfin dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
This command:
|
|
20
|
+
|
|
21
|
+
- Validates that Docker and Docker Compose are available.
|
|
22
|
+
- Generates `rayfin/.temp/docker-compose.yml` from your project configuration.
|
|
23
|
+
- Allocates ports for each service.
|
|
24
|
+
- Starts containers for enabled services (WebService, database, and optional storage).
|
|
25
|
+
- Runs health checks and waits for all services to be healthy.
|
|
26
|
+
|
|
27
|
+
Wait for the `All services healthy` message before continuing.
|
|
28
|
+
|
|
29
|
+
## Stopping and resetting
|
|
30
|
+
|
|
31
|
+
| Flag | Behavior |
|
|
32
|
+
|------|----------|
|
|
33
|
+
| `--stop` | Stop running containers without removing them |
|
|
34
|
+
| `--down` | Stop and remove containers |
|
|
35
|
+
| `--purge` | Stop, remove containers, and delete volumes (full reset) |
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
npx rayfin dev --stop
|
|
39
|
+
npx rayfin dev --down
|
|
40
|
+
npx rayfin dev --purge
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Additional options
|
|
44
|
+
|
|
45
|
+
| Flag | Behavior |
|
|
46
|
+
|------|----------|
|
|
47
|
+
| `--detach` | Run containers in the background |
|
|
48
|
+
| `--pull` | Pull latest images before starting |
|
|
49
|
+
| `--verbose` | Show detailed Docker output |
|
|
50
|
+
| `--debug` | Enable debug logging |
|
|
51
|
+
| `--migrate` | Run database migrations on start |
|
|
52
|
+
| `--unsafe` | Skip safety checks (use with caution) |
|
|
53
|
+
|
|
54
|
+
## Subcommands
|
|
55
|
+
|
|
56
|
+
### `rayfin dev db apply`
|
|
57
|
+
|
|
58
|
+
Generate and apply DAB configuration to the local development server.
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
npx rayfin dev db apply
|
|
62
|
+
npx rayfin dev db apply --force
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Run this after making changes to entities in `rayfin/data/`.
|
|
66
|
+
Use `--force` to regenerate configuration even if no changes are detected.
|
|
67
|
+
|
|
68
|
+
### `rayfin dev storage apply`
|
|
69
|
+
|
|
70
|
+
Generate and apply storage configuration to the local development server.
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
npx rayfin dev storage apply
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### `rayfin dev status`
|
|
77
|
+
|
|
78
|
+
Display the status of the local development environment.
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
npx rayfin dev status
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Shows container health, port assignments, and service readiness.
|
|
85
|
+
|
|
86
|
+
### `rayfin dev watch`
|
|
87
|
+
|
|
88
|
+
Watch `./rayfin/data` or `./rayfin/storage` and auto-apply configuration changes.
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
npx rayfin dev watch
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## Configuration
|
|
95
|
+
|
|
96
|
+
The `rayfin/rayfin.yml` file controls which services run in the local environment.
|
|
97
|
+
Changes to `rayfin.yml` require restarting the environment:
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
npx rayfin dev --down
|
|
101
|
+
npx rayfin dev
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Troubleshooting
|
|
105
|
+
|
|
106
|
+
- **Docker not running** — ensure Docker Desktop or the Docker daemon is started.
|
|
107
|
+
- **`rayfin dev db apply` fails** — make sure services are healthy first (`npx rayfin dev status`).
|
|
108
|
+
- **Stale services** — stop stale containers with `npx rayfin dev --down`, then restart.
|
|
109
|
+
- **`unsupported UUID` errors** — stop stale services with `npx rayfin dev --down`.
|
|
110
|
+
- **Port conflicts** — use `npx rayfin dev --purge` for a full reset.
|
|
111
|
+
|
|
112
|
+
## Enabling this feature
|
|
113
|
+
|
|
114
|
+
Set the feature flag in your environment:
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
export RAYFIN_FEATURE_FLAGS=docker-local-dev
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
Or combine with other flags:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
export RAYFIN_FEATURE_FLAGS=docker-local-dev,storage
|
|
124
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/rayfin-guide",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.33.0-beta.1",
|
|
4
4
|
"description": "Cross-cutting Builder guides for the Rayfin platform — discovered by `@microsoft/rayfin-docs` via the `rayfinDocs` package.json field convention.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
symbols: []
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Quickstart
|
|
6
|
-
|
|
7
|
-
This quickstart walks you through scaffolding a new Rayfin project,
|
|
8
|
-
defining your first entity, running the project locally, and querying
|
|
9
|
-
via GraphQL.
|
|
10
|
-
|
|
11
|
-
## Prerequisites
|
|
12
|
-
|
|
13
|
-
- Node.js 20+
|
|
14
|
-
- A modern terminal (PowerShell, bash, zsh)
|
|
15
|
-
|
|
16
|
-
## 1. Scaffold a new project
|
|
17
|
-
|
|
18
|
-
```bash
|
|
19
|
-
npm create rayfin@latest my-app
|
|
20
|
-
cd my-app
|
|
21
|
-
npm install
|
|
22
|
-
```
|
|
23
|
-
|
|
24
|
-
The scaffold creates a Rayfin project with:
|
|
25
|
-
|
|
26
|
-
- `rayfin/data/` — your entity classes
|
|
27
|
-
- `rayfin.config.json` — project configuration
|
|
28
|
-
- `package.json` with `rayfin-cli`, `rayfin-core`, `rayfin-data`, and
|
|
29
|
-
`rayfin-auth` already wired
|
|
30
|
-
|
|
31
|
-
## 2. Define your first entity
|
|
32
|
-
|
|
33
|
-
Edit `rayfin/data/Todo.ts`:
|
|
34
|
-
|
|
35
|
-
```typescript
|
|
36
|
-
import { entity, uuid, text, int, anonymous, authenticated } from '@microsoft/rayfin-core';
|
|
37
|
-
|
|
38
|
-
@entity()
|
|
39
|
-
@anonymous('read')
|
|
40
|
-
@authenticated('*')
|
|
41
|
-
export class Todo {
|
|
42
|
-
@uuid() id!: string;
|
|
43
|
-
@text() title!: string;
|
|
44
|
-
@int() priority!: number;
|
|
45
|
-
@text({ optional: true }) notes?: string;
|
|
46
|
-
}
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## 3. Run locally
|
|
50
|
-
|
|
51
|
-
```bash
|
|
52
|
-
rayfin up
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
This generates a DAB-compliant configuration from your entity classes
|
|
56
|
-
and starts the Data API Builder server on
|
|
57
|
-
[http://localhost:5000](http://localhost:5000).
|
|
58
|
-
|
|
59
|
-
## 4. Query via GraphQL
|
|
60
|
-
|
|
61
|
-
Open [http://localhost:5000/graphql](http://localhost:5000/graphql) and try:
|
|
62
|
-
|
|
63
|
-
```graphql
|
|
64
|
-
query {
|
|
65
|
-
todos {
|
|
66
|
-
items {
|
|
67
|
-
id
|
|
68
|
-
title
|
|
69
|
-
priority
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
## Next steps
|
|
76
|
-
|
|
77
|
-
- [Auth overview](./index.md) — for sign-in flows beyond the
|
|
78
|
-
built-in `anonymous` role.
|
|
79
|
-
- Per-package reference via `rayfin docs list --module ts-sdk`.
|
|
80
|
-
- Deploy to Fabric: see the `rayfin up staticapp deploy` subcommand
|
|
81
|
-
(interactive scaffolding through Fabric workspace selection).
|