@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
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
title: Getting Started
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Overview
|
|
7
|
+
|
|
8
|
+
Rayfin supports two development paths.
|
|
9
|
+
Choose the one that matches how you want to get started.
|
|
10
|
+
|
|
11
|
+
### Local development
|
|
12
|
+
|
|
13
|
+
Run the full Rayfin stack on your machine using Docker.
|
|
14
|
+
This path is ideal for building and testing your application before deploying.
|
|
15
|
+
|
|
16
|
+
1. Install prerequisites.
|
|
17
|
+
1. Scaffold a project with `npm create @microsoft/rayfin@latest` or [add Rayfin to an existing app](../cli/quickstart.md#add-rayfin-to-an-existing-project).
|
|
18
|
+
1. Start backend services with `npx rayfin up`.
|
|
19
|
+
1. Run your frontend with `npm run dev`.
|
|
20
|
+
|
|
21
|
+
**Start here:** [Build your first Rayfin app](./create-app-with-cli.md)
|
|
22
|
+
|
|
23
|
+
### Microsoft Fabric
|
|
24
|
+
|
|
25
|
+
Create a Fabric data app in the Fabric portal and deploy your application to the cloud.
|
|
26
|
+
This path requires a Microsoft account with Fabric access and tenant admin settings enabled.
|
|
27
|
+
|
|
28
|
+
1. Enable Fabric data app in your tenant admin settings.
|
|
29
|
+
1. Create a Fabric data app in a Fabric workspace.
|
|
30
|
+
1. Connect your local project and deploy with `npx rayfin up`.
|
|
31
|
+
|
|
32
|
+
**Start here:** [Create a Fabric data app in Fabric](./create-rayfin-item.md)
|
|
33
|
+
|
|
34
|
+
## Prerequisites
|
|
35
|
+
|
|
36
|
+
Install these tools before you begin with either path.
|
|
37
|
+
Rayfin requires Node.js 20 or later, Docker Desktop (or Docker Engine on Linux), and the GitHub CLI.
|
|
38
|
+
|
|
39
|
+
### Windows
|
|
40
|
+
|
|
41
|
+
- Install the latest LTS Node.js:
|
|
42
|
+
|
|
43
|
+
```powershell
|
|
44
|
+
winget install -e --id OpenJS.NodeJS.LTS
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
- Install Docker Desktop:
|
|
48
|
+
|
|
49
|
+
```powershell
|
|
50
|
+
winget install --id Docker.DockerDesktop -e
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
- Add Docker to PATH and start Docker Desktop:
|
|
54
|
+
|
|
55
|
+
```powershell
|
|
56
|
+
# Docker Desktop typically adds itself to PATH, verify with:
|
|
57
|
+
where docker
|
|
58
|
+
# If not found, add Docker to PATH:
|
|
59
|
+
$env:PATH += ";C:\Program Files\Docker\Docker\resources\bin"; [Environment]::SetEnvironmentVariable("PATH", $env:PATH, "User")
|
|
60
|
+
# Start Docker Desktop (required before using docker commands)
|
|
61
|
+
Start-Process "C:\Program Files\Docker\Docker\Docker Desktop.exe"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
- Install the GitHub CLI:
|
|
65
|
+
|
|
66
|
+
```powershell
|
|
67
|
+
winget install --id GitHub.cli -e
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
- Add GitHub CLI to PATH (if it does not exist):
|
|
71
|
+
|
|
72
|
+
```powershell
|
|
73
|
+
# To check if your terminal knows about gh CLI
|
|
74
|
+
where gh
|
|
75
|
+
# If there are no results, add github CLI to your PATH by running:
|
|
76
|
+
$env:PATH += ";C:\Program Files\GitHub CLI"; [Environment]::SetEnvironmentVariable("PATH", $env:PATH, "User")
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
- Sign in and verify versions:
|
|
80
|
+
|
|
81
|
+
```powershell
|
|
82
|
+
gh auth login
|
|
83
|
+
node --version
|
|
84
|
+
docker --version
|
|
85
|
+
gh --version
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Note: if prompted, authorize GitHub to access Microsoft.
|
|
89
|
+
|
|
90
|
+
### macOS
|
|
91
|
+
|
|
92
|
+
- Install latest LTS Node.js via Homebrew:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
brew install node@lts
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
- Install Docker Desktop:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
brew install --cask docker
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
- Start Docker Desktop and verify docker is in PATH:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
which docker
|
|
108
|
+
open -a Docker
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
- Install the GitHub CLI:
|
|
112
|
+
|
|
113
|
+
```bash
|
|
114
|
+
brew install gh
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
- Verify GitHub CLI is in PATH:
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
which gh
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
- Sign in and verify versions:
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
gh auth login
|
|
127
|
+
node --version
|
|
128
|
+
docker --version
|
|
129
|
+
gh --version
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
Note: if prompted, authorize GitHub to access Microsoft.
|
|
133
|
+
|
|
134
|
+
### Linux (Ubuntu or Debian)
|
|
135
|
+
|
|
136
|
+
- Install the latest LTS Node.js using the [official Node.js download instructions](https://nodejs.org/en/download)
|
|
137
|
+
|
|
138
|
+
- Install Docker Engine and enable non-root access:
|
|
139
|
+
|
|
140
|
+
```bash
|
|
141
|
+
sudo apt install -y docker.io docker-compose-plugin
|
|
142
|
+
sudo systemctl enable --now docker
|
|
143
|
+
sudo usermod -aG docker "$USER"
|
|
144
|
+
newgrp docker
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
- Verify docker is in PATH:
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
which docker
|
|
151
|
+
sudo systemctl status docker
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
- Install the GitHub CLI:
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
type -p curl >/dev/null || sudo apt install -y curl
|
|
158
|
+
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
159
|
+
sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
|
|
160
|
+
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
|
161
|
+
sudo apt update
|
|
162
|
+
sudo apt install -y gh
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
- Verify GitHub CLI is in PATH:
|
|
166
|
+
|
|
167
|
+
```bash
|
|
168
|
+
which gh
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
- Sign in and verify versions:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
gh auth login
|
|
175
|
+
node --version
|
|
176
|
+
docker --version
|
|
177
|
+
gh --version
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## Making Changes
|
|
181
|
+
|
|
182
|
+
- **Apply the database schema generated from `rayfin/data` entities**
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
npx rayfin up db apply [--force]
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
- Repeat this command whenever you change decorated entity classes under `rayfin/data`.
|
|
189
|
+
- If running `npx rayfin up db apply` errors because there might be a loss of data, include the `--force` option to confirm that the potential data loss is okay.
|
|
190
|
+
- Run this in a terminal from the same project directory.
|
|
191
|
+
- You should see `✔ Configuration applied successfully!`.
|
|
192
|
+
|
|
193
|
+
## Troubleshooting
|
|
194
|
+
|
|
195
|
+
- **Docker is not running**: Start Docker Desktop or `sudo systemctl start docker`, then rerun `npx rayfin up`.
|
|
196
|
+
- **Database apply fails**: Wait for services to be healthy and retry `npx rayfin up db apply`.
|
|
197
|
+
|
|
198
|
+
## Next Steps
|
|
199
|
+
|
|
200
|
+
- Continue with [Create app with CLI](./create-app-with-cli.md).
|
|
201
|
+
- Review [Project structure](./project-structure.md) to understand the `rayfin/` folder and schema files.
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 3
|
|
3
|
+
title: Project structure
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Rayfin templates follow a consistent layout so data models, backend configuration, and frontend code stay discoverable.
|
|
7
|
+
This page explains the important folders you will see after running `npm create @microsoft/rayfin@latest`.
|
|
8
|
+
|
|
9
|
+
## Folder layout
|
|
10
|
+
|
|
11
|
+
```text
|
|
12
|
+
your-project/
|
|
13
|
+
├── rayfin/
|
|
14
|
+
│ ├── data/
|
|
15
|
+
│ │ ├── schema.ts
|
|
16
|
+
│ │ └── *.ts
|
|
17
|
+
│ ├── .env
|
|
18
|
+
│ ├── rayfin.yml
|
|
19
|
+
│ └── tsconfig.json
|
|
20
|
+
├── src/
|
|
21
|
+
├── package.json
|
|
22
|
+
├── tsconfig.json
|
|
23
|
+
└── README.md
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Key files
|
|
27
|
+
|
|
28
|
+
### rayfin/rayfin.yml
|
|
29
|
+
|
|
30
|
+
`rayfin/rayfin.yml` is the entrypoint for the Rayfin backend configuration.
|
|
31
|
+
It controls which services run in `npx rayfin up`, and it supports environment variable interpolation.
|
|
32
|
+
|
|
33
|
+
Full example:
|
|
34
|
+
|
|
35
|
+
```yaml
|
|
36
|
+
id: my-app
|
|
37
|
+
name: my-app
|
|
38
|
+
version: 1.0.0
|
|
39
|
+
services:
|
|
40
|
+
auth:
|
|
41
|
+
enabled: true
|
|
42
|
+
expiryInMinutes: 60
|
|
43
|
+
refreshToken:
|
|
44
|
+
lifetimeInDays: 30
|
|
45
|
+
customClaims:
|
|
46
|
+
tenant: "default"
|
|
47
|
+
scopes:
|
|
48
|
+
- read:data
|
|
49
|
+
- write:data
|
|
50
|
+
allowedRedirectUris:
|
|
51
|
+
- http://localhost:5173
|
|
52
|
+
password:
|
|
53
|
+
enabled: true
|
|
54
|
+
fabric:
|
|
55
|
+
enabled: false
|
|
56
|
+
passwordless:
|
|
57
|
+
magicLink:
|
|
58
|
+
enabled: false
|
|
59
|
+
expiryMinutes: 15
|
|
60
|
+
smsOtp:
|
|
61
|
+
enabled: false
|
|
62
|
+
email:
|
|
63
|
+
enabled: false
|
|
64
|
+
provider: smtp
|
|
65
|
+
senderName: Rayfin Platform
|
|
66
|
+
verificationTokenExpirationHours: 24
|
|
67
|
+
passwordResetTokenExpirationMinutes: 30
|
|
68
|
+
smtp:
|
|
69
|
+
host: maildev
|
|
70
|
+
port: 1025
|
|
71
|
+
senderEmail: noreply@rayfin.local
|
|
72
|
+
username: ""
|
|
73
|
+
password: ""
|
|
74
|
+
useSsl: false
|
|
75
|
+
useStartTls: false
|
|
76
|
+
webPort: 1080
|
|
77
|
+
data:
|
|
78
|
+
enabled: true
|
|
79
|
+
dialect: mssql
|
|
80
|
+
storage:
|
|
81
|
+
enabled: false
|
|
82
|
+
staticHosting:
|
|
83
|
+
enabled: true
|
|
84
|
+
root: .
|
|
85
|
+
folder: dist
|
|
86
|
+
buildCommand: npm run build
|
|
87
|
+
indexDocument: index.html
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
#### Top-level fields
|
|
91
|
+
|
|
92
|
+
| Field | Type | Required | Description |
|
|
93
|
+
| --- | --- | --- | --- |
|
|
94
|
+
| `id` | `string` | Yes | Project slug used as the Docker Compose project name and Fabric item identifier. |
|
|
95
|
+
| `name` | `string` | Yes | Human-readable project display name. |
|
|
96
|
+
| `version` | `string` | Yes | Project version (semver). |
|
|
97
|
+
| `services` | `object` | Yes | Service configuration block (see below). |
|
|
98
|
+
|
|
99
|
+
#### `services.data`
|
|
100
|
+
|
|
101
|
+
| Field | Type | Default | Description |
|
|
102
|
+
| --- | --- | --- | --- |
|
|
103
|
+
| `enabled` | `boolean` | `false` | Enable the data service. |
|
|
104
|
+
| `dialect` | `"mssql"` \| `"postgresql"` | `"mssql"` | Database dialect. Fabric deployments support MSSQL only. |
|
|
105
|
+
|
|
106
|
+
#### `services.auth`
|
|
107
|
+
|
|
108
|
+
| Field | Type | Default | Description |
|
|
109
|
+
| --- | --- | --- | --- |
|
|
110
|
+
| `enabled` | `boolean` | `false` | Enable the auth service. |
|
|
111
|
+
| `expiryInMinutes` | `number` | — | JWT token expiry in minutes. |
|
|
112
|
+
| `customClaims` | `Record<string, string>` | — | Custom claims added to issued JWTs. |
|
|
113
|
+
| `scopes` | `string[]` | — | OAuth scopes (e.g. `["read:data", "write:data"]`). |
|
|
114
|
+
| `refreshToken.lifetimeInDays` | `number` | — | Refresh token lifetime in days. |
|
|
115
|
+
| `allowedRedirectUris` | `string[]` | `["http://localhost:5173"]` | Allowed redirect URIs for auth callbacks and Fabric brokered auth handoff. Must include the bare origin for Fabric auth. |
|
|
116
|
+
|
|
117
|
+
**`services.auth.password`**
|
|
118
|
+
|
|
119
|
+
| Field | Type | Default | Description |
|
|
120
|
+
| --- | --- | --- | --- |
|
|
121
|
+
| `enabled` | `boolean` | `true` | Enable email + password authentication. |
|
|
122
|
+
|
|
123
|
+
**`services.auth.fabric`**
|
|
124
|
+
|
|
125
|
+
| Field | Type | Default | Description |
|
|
126
|
+
| --- | --- | --- | --- |
|
|
127
|
+
| `enabled` | `boolean` | `false` | Enable Fabric brokered authentication (Entra ID SSO). |
|
|
128
|
+
|
|
129
|
+
**`services.auth.passwordless`**
|
|
130
|
+
|
|
131
|
+
| Field | Type | Default | Description |
|
|
132
|
+
| --- | --- | --- | --- |
|
|
133
|
+
| `magicLink.enabled` | `boolean` | `false` | Enable magic link authentication. |
|
|
134
|
+
| `magicLink.expiryMinutes` | `number` | `15` | Magic link expiration in minutes. |
|
|
135
|
+
| `smsOtp.enabled` | `boolean` | `false` | Enable SMS OTP authentication. |
|
|
136
|
+
|
|
137
|
+
**`services.auth.email`**
|
|
138
|
+
|
|
139
|
+
Configure an email provider for magic links, password resets, and email verification.
|
|
140
|
+
|
|
141
|
+
| Field | Type | Default | Description |
|
|
142
|
+
| --- | --- | --- | --- |
|
|
143
|
+
| `enabled` | `boolean` | `false` | Enable email service. Required for magic link auth. |
|
|
144
|
+
| `provider` | `string` | `"smtp"` | Email provider type. |
|
|
145
|
+
| `senderName` | `string` | `"Rayfin Platform"` | Display name for outgoing emails. |
|
|
146
|
+
| `verificationTokenExpirationHours` | `number` | `24` | Email verification token expiry in hours. |
|
|
147
|
+
| `passwordResetTokenExpirationMinutes` | `number` | `30` | Password reset token expiry in minutes. |
|
|
148
|
+
|
|
149
|
+
**`services.auth.email.smtp`**
|
|
150
|
+
|
|
151
|
+
| Field | Type | Default | Description |
|
|
152
|
+
| --- | --- | --- | --- |
|
|
153
|
+
| `host` | `string` | `"maildev"` | SMTP server hostname. |
|
|
154
|
+
| `port` | `number` | `1025` | SMTP server port. |
|
|
155
|
+
| `senderEmail` | `string` | `"noreply@rayfin.local"` | Sender email address. |
|
|
156
|
+
| `username` | `string` | `""` | SMTP username. |
|
|
157
|
+
| `password` | `string` | `""` | SMTP password. |
|
|
158
|
+
| `useSsl` | `boolean` | `false` | Use SSL for the SMTP connection. |
|
|
159
|
+
| `useStartTls` | `boolean` | `false` | Use STARTTLS for the SMTP connection. |
|
|
160
|
+
| `webPort` | `number` | `1080` | MailDev web UI port (local development only). |
|
|
161
|
+
|
|
162
|
+
#### `services.storage`
|
|
163
|
+
|
|
164
|
+
| Field | Type | Default | Description |
|
|
165
|
+
| --- | --- | --- | --- |
|
|
166
|
+
| `enabled` | `boolean` | `false` | Enable the storage service. |
|
|
167
|
+
|
|
168
|
+
#### `services.staticHosting`
|
|
169
|
+
|
|
170
|
+
| Field | Type | Default | Description |
|
|
171
|
+
| --- | --- | --- | --- |
|
|
172
|
+
| `enabled` | `boolean` | `false` | Enable static content hosting. |
|
|
173
|
+
| `root` | `string` | — | Root directory of the frontend project (relative to the project root). |
|
|
174
|
+
| `folder` | `string` | `"dist"` | Directory containing built static assets (relative to `root`). |
|
|
175
|
+
| `buildCommand` | `string` | — | Shell command to run before packaging (e.g. `npm run build`). |
|
|
176
|
+
| `indexDocument` | `string` | — | Default document served for the root path (e.g. `index.html`). |
|
|
177
|
+
|
|
178
|
+
> **Tip:** All string values support environment variable interpolation with `${VAR}` and `${VAR:-default}` syntax.
|
|
179
|
+
> Variables are resolved from `rayfin/.env` and the shell environment.
|
|
180
|
+
> See [Environment Variable Interpolation](../cli/env-interpolation.md) for details.
|
|
181
|
+
|
|
182
|
+
### rayfin/.env
|
|
183
|
+
|
|
184
|
+
`rayfin/.env` is an optional environment file used to supply values to `rayfin.yml` via interpolation.
|
|
185
|
+
Do not commit secrets, and prefer a `rayfin/.env.example` file for documentation.
|
|
186
|
+
|
|
187
|
+
### rayfin/data/*.ts
|
|
188
|
+
|
|
189
|
+
Files in `rayfin/data/` define your entities.
|
|
190
|
+
Entities are TypeScript classes decorated with `@entity()` plus field decorators like `@uuid()` and `@text()`.
|
|
191
|
+
|
|
192
|
+
### rayfin/data/schema.ts
|
|
193
|
+
|
|
194
|
+
`rayfin/data/schema.ts` maps entity names to their classes.
|
|
195
|
+
The Rayfin client uses this map to provide type-safe access to `client.data.<Entity>`.
|
|
196
|
+
|
|
197
|
+
### rayfin/tsconfig.json
|
|
198
|
+
|
|
199
|
+
`rayfin/tsconfig.json` is a project-reference tsconfig used by the Rayfin CLI to compile your entity definitions.
|
|
200
|
+
It extends your root `tsconfig.json` and overrides the settings Rayfin needs (for example, `composite: true` and Node.js module resolution).
|
|
201
|
+
You should not need to edit this file.
|
|
202
|
+
|
|
203
|
+
### rayfin/.temp/
|
|
204
|
+
|
|
205
|
+
`rayfin/.temp/` contains generated backend artifacts.
|
|
206
|
+
If the backend appears to be using stale schema or configuration, stop the dev stack and rerun `npx rayfin up` to regenerate.
|
|
207
|
+
|
|
208
|
+
### tsconfig.json (root)
|
|
209
|
+
|
|
210
|
+
Your root `tsconfig.json` must meet several requirements for Rayfin decorators and the `rayfin/` sub-project to work correctly.
|
|
211
|
+
|
|
212
|
+
**Project reference to `rayfin/`** — Add a `references` entry so TypeScript knows about the Rayfin sub-project:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"references": [{ "path": "./rayfin" }]
|
|
217
|
+
}
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
> **Note:** Do not set `emitDecoratorMetadata` to `true`.
|
|
221
|
+
> TypeScript only allows it alongside `experimentalDecorators`, which is incompatible with Rayfin's TC39 decorators.
|
|
222
|
+
|
|
223
|
+
**Minimal example:**
|
|
224
|
+
|
|
225
|
+
```json
|
|
226
|
+
{
|
|
227
|
+
"compilerOptions": {
|
|
228
|
+
"target": "ES2022",
|
|
229
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable", "ESNext.Decorators"],
|
|
230
|
+
"module": "ESNext",
|
|
231
|
+
"moduleResolution": "bundler",
|
|
232
|
+
"importHelpers": false,
|
|
233
|
+
"strict": true,
|
|
234
|
+
"skipLibCheck": true,
|
|
235
|
+
"isolatedModules": true,
|
|
236
|
+
"noEmit": true,
|
|
237
|
+
"jsx": "react-jsx"
|
|
238
|
+
},
|
|
239
|
+
"include": ["src"],
|
|
240
|
+
"references": [{ "path": "./rayfin" }]
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
> **Tip:** Templates created with `npm create @microsoft/rayfin@latest` already include these settings.
|
|
245
|
+
> If you are integrating Rayfin into an existing project, verify your `tsconfig.json` matches the requirements above.
|
|
246
|
+
|
|
247
|
+
## Frontend configuration
|
|
248
|
+
|
|
249
|
+
### Vite configuration
|
|
250
|
+
|
|
251
|
+
Rayfin decorators use the TC39 Stage 3 decorator specification, which requires an ES2022 or later compilation target.
|
|
252
|
+
Set the `target` to `es2022` in your `vite.config.ts` so Vite, esbuild, and dependency pre-bundling all use the correct language level.
|
|
253
|
+
|
|
254
|
+
```typescript
|
|
255
|
+
import { defineConfig } from 'vite';
|
|
256
|
+
import react from '@vitejs/plugin-react';
|
|
257
|
+
|
|
258
|
+
export default defineConfig({
|
|
259
|
+
plugins: [react()],
|
|
260
|
+
build: {
|
|
261
|
+
target: 'es2022',
|
|
262
|
+
},
|
|
263
|
+
esbuild: {
|
|
264
|
+
target: 'es2022',
|
|
265
|
+
},
|
|
266
|
+
optimizeDeps: {
|
|
267
|
+
esbuildOptions: {
|
|
268
|
+
target: 'es2022',
|
|
269
|
+
},
|
|
270
|
+
},
|
|
271
|
+
});
|
|
272
|
+
```
|
|
273
|
+
|
|
274
|
+
> **Tip:** Templates created with `npm create @microsoft/rayfin@latest` already include these settings.
|
|
275
|
+
> If you are integrating Rayfin into an existing Vite project, add the three `target` entries shown above.
|
|
276
|
+
|
|
277
|
+
### Environment variables
|
|
278
|
+
|
|
279
|
+
Rayfin manages environment variables through `rayfin/.env` using the `RAYFIN_PUBLIC_*` prefix convention.
|
|
280
|
+
When you run `npm run dev`, the `predev` hook calls `rayfin env --framework vite` to generate a `.env.local` file with framework-specific variable names.
|
|
281
|
+
When the CLI detects a Vite or Next.js project automatically, you can omit `--framework`.
|
|
282
|
+
|
|
283
|
+
The following Vite variables are available in your frontend code after generation:
|
|
284
|
+
|
|
285
|
+
- `VITE_RAYFIN_API_URL` — Base URL pointing the frontend at the Rayfin backend.
|
|
286
|
+
Sourced from `RAYFIN_PUBLIC_API_URL` in `rayfin/.env`.
|
|
287
|
+
- `VITE_RAYFIN_PUBLISHABLE_KEY` — Publishable key used for Rayfin client authentication.
|
|
288
|
+
Sourced from `RAYFIN_PUBLIC_PUBLISHABLE_KEY` in `rayfin/.env`.
|
|
289
|
+
|
|
290
|
+
To override values, edit `rayfin/.env` directly and re-run `rayfin env --framework vite` (or `npm run dev`, which triggers it automatically).
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
---
|
|
2
|
+
sidebar_position: 50
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
# Static Content Hosting
|
|
6
|
+
|
|
7
|
+
Rayfin can build, package, and serve your frontend application as static content alongside your backend APIs.
|
|
8
|
+
When static hosting is enabled, the CLI deploys your built assets to the Rayfin host, which serves them at a public URL.
|
|
9
|
+
|
|
10
|
+
## How it works
|
|
11
|
+
|
|
12
|
+
1. Rayfin runs your configured build command (for example, `npm run build`).
|
|
13
|
+
1. The CLI validates that the output folder exists and contains files.
|
|
14
|
+
1. All files are packaged into a compressed ZIP archive (100 MB maximum).
|
|
15
|
+
1. The archive is uploaded to the Rayfin host, which extracts and serves the content.
|
|
16
|
+
1. The host returns a public hosting URL where your site is accessible.
|
|
17
|
+
|
|
18
|
+
## Configuration
|
|
19
|
+
|
|
20
|
+
Add a `staticHosting` section under `services` in your `rayfin.yml` file:
|
|
21
|
+
|
|
22
|
+
```yaml
|
|
23
|
+
services:
|
|
24
|
+
staticHosting:
|
|
25
|
+
enabled: true
|
|
26
|
+
folder: dist
|
|
27
|
+
buildCommand: npm run build
|
|
28
|
+
indexDocument: index.html
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Configuration options
|
|
32
|
+
|
|
33
|
+
| Option | Required | Default | Description |
|
|
34
|
+
| --- | --- | --- | --- |
|
|
35
|
+
| `enabled` | Yes | — | Set to `true` to enable static hosting. |
|
|
36
|
+
| `folder` | Yes | — | Output folder containing built static files, relative to `root`. |
|
|
37
|
+
| `root` | No | Project root | Root directory of the frontend project, relative to the project root. |
|
|
38
|
+
| `buildCommand` | No | — | Shell command to run before packaging (for example, `npm run build`). |
|
|
39
|
+
| `indexDocument` | No | — | Default document to serve for directory requests (for example, `index.html`). |
|
|
40
|
+
|
|
41
|
+
### Example with a separate frontend directory
|
|
42
|
+
|
|
43
|
+
If your frontend lives in a subdirectory:
|
|
44
|
+
|
|
45
|
+
```yaml
|
|
46
|
+
services:
|
|
47
|
+
staticHosting:
|
|
48
|
+
enabled: true
|
|
49
|
+
root: frontend
|
|
50
|
+
folder: dist
|
|
51
|
+
buildCommand: npm run build
|
|
52
|
+
indexDocument: index.html
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
This resolves the output path to `<project-root>/frontend/dist`.
|
|
56
|
+
|
|
57
|
+
## Deploying static content
|
|
58
|
+
|
|
59
|
+
### Full deployment with `rayfin up`
|
|
60
|
+
|
|
61
|
+
When you run `rayfin up`, static content is deployed automatically as part of the full stack deployment.
|
|
62
|
+
The CLI builds your frontend, packages the output, and uploads it alongside your data and auth configuration.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
rayfin up
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
After deployment, the CLI prints the hosting URL and stores it in `rayfin/.deployments.json` for reference.
|
|
69
|
+
|
|
70
|
+
#### Skip static deployment during local dev
|
|
71
|
+
|
|
72
|
+
When iterating locally with `npm run dev` (Vite serves the frontend), pass `--exclude-services staticHosting` to deploy the backend without rebuilding and uploading the static bundle:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
rayfin up --exclude-services staticHosting
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
This skips only the static build/package/deploy phase — runtime settings are still posted, so previously deployed static content keeps serving from Fabric.
|
|
79
|
+
The scaffolded `npm run dev` script in every sample and template uses this flag.
|
|
80
|
+
|
|
81
|
+
### Standalone static deployment
|
|
82
|
+
|
|
83
|
+
Use the `staticapp deploy` subcommand to redeploy only your static content without rerunning the full `rayfin up` flow:
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
rayfin up staticapp deploy
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
This is useful when you have only changed frontend code and want a faster iteration cycle.
|
|
90
|
+
|
|
91
|
+
#### Skip the build step
|
|
92
|
+
|
|
93
|
+
If you have already built your frontend and want to deploy the existing output:
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
rayfin up staticapp deploy --skip-build
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
#### Verbose output
|
|
100
|
+
|
|
101
|
+
Enable detailed logging with the `-v, --verbose` flag:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
rayfin up staticapp deploy -v
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Redirect URI registration
|
|
108
|
+
|
|
109
|
+
When static hosting is enabled, Rayfin automatically registers the hosting URL's bare origin in `allowedRedirectUris` during deployment.
|
|
110
|
+
This is required for the postMessage-based Fabric brokered auth handoff, even when interactive auth is disabled.
|
|
111
|
+
|
|
112
|
+
For example, if your hosting URL is `https://bold-river-a3f1bc9d02-westus2.webapp.example.com`, the deploy tool adds:
|
|
113
|
+
|
|
114
|
+
```yaml
|
|
115
|
+
services:
|
|
116
|
+
auth:
|
|
117
|
+
allowedRedirectUris:
|
|
118
|
+
- http://localhost:5173
|
|
119
|
+
- https://bold-river-a3f1bc9d02-westus2.webapp.example.com
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
You do not need to configure this manually.
|
|
123
|
+
The deploy tool updates the configuration and pushes it to the backend during deployment.
|
|
124
|
+
|
|
125
|
+
## Deployment limits
|
|
126
|
+
|
|
127
|
+
- The compressed ZIP archive must not exceed **100 MB**.
|
|
128
|
+
- The CLI uses maximum compression to minimize upload size.
|
|
129
|
+
- If your build output exceeds the limit, consider excluding large assets or using the storage service for binary files.
|
|
130
|
+
|
|
131
|
+
## Complete example
|
|
132
|
+
|
|
133
|
+
A full `rayfin.yml` with static hosting, auth, and data enabled:
|
|
134
|
+
|
|
135
|
+
```yaml
|
|
136
|
+
id: my-app
|
|
137
|
+
name: my-app
|
|
138
|
+
version: 1.0.0
|
|
139
|
+
services:
|
|
140
|
+
auth:
|
|
141
|
+
enabled: true
|
|
142
|
+
allowedRedirectUris:
|
|
143
|
+
- http://localhost:5173
|
|
144
|
+
data:
|
|
145
|
+
enabled: true
|
|
146
|
+
dialect: postgresql
|
|
147
|
+
staticHosting:
|
|
148
|
+
enabled: true
|
|
149
|
+
folder: dist
|
|
150
|
+
buildCommand: npm run build
|
|
151
|
+
indexDocument: index.html
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Troubleshooting
|
|
155
|
+
|
|
156
|
+
### Static folder not found
|
|
157
|
+
|
|
158
|
+
If the CLI reports that the static folder does not exist, verify that:
|
|
159
|
+
|
|
160
|
+
- The `folder` path in `rayfin.yml` is correct and relative to `root` (or the project root if `root` is not set).
|
|
161
|
+
- Your build command has run successfully and produced output in the expected directory.
|
|
162
|
+
|
|
163
|
+
### Empty static folder
|
|
164
|
+
|
|
165
|
+
An empty output folder usually means the build command did not produce output.
|
|
166
|
+
Run the build command manually to check for errors:
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
npm run build
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Deployment too large
|
|
173
|
+
|
|
174
|
+
If the ZIP exceeds 100 MB:
|
|
175
|
+
|
|
176
|
+
- Review your build output for unnecessary files (source maps, unoptimized images).
|
|
177
|
+
- Configure your bundler to exclude development artifacts from the production build.
|
|
178
|
+
- Move large binary assets to Rayfin storage instead of bundling them as static content.
|
|
179
|
+
|
|
180
|
+
### No remote endpoint configured
|
|
181
|
+
|
|
182
|
+
The `rayfin up staticapp deploy` command requires an existing remote deployment.
|
|
183
|
+
Run `rayfin up` first to provision the remote endpoint, then use `staticapp deploy` for subsequent updates.
|