@microsoft/rayfin-guide 1.35.0-alpha.1315 → 1.35.0-alpha.1331
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 +21 -2
- package/assets/docs/auth/fabric.md +5 -3
- package/assets/docs/cli/environment-variables.md +38 -4
- package/assets/docs/cli/index.md +11 -2
- package/assets/docs/cli/installation.md +4 -11
- package/assets/docs/cli/quickstart.md +16 -2
- package/assets/docs/data/permissions.md +13 -12
- package/assets/docs/getting-started/create-app-with-cli.md +6 -4
- package/assets/docs/getting-started/index.md +9 -6
- package/assets/docs/getting-started/project-structure.md +15 -2
- package/assets/docs/hosting/index.md +9 -2
- package/assets/docs/preview/local-dev-docker.md +49 -12
- package/package.json +1 -1
|
@@ -149,13 +149,14 @@ Use `--exclude-services <names>` to skip the build/package/deploy phase for supp
|
|
|
149
149
|
The runtime settings POST still reflects your `rayfin.yml`, so the backend is never silently reconfigured.
|
|
150
150
|
The only currently supported value is `staticHosting`; other names fail with a clear error.
|
|
151
151
|
|
|
152
|
-
|
|
152
|
+
Use `rayfin dev` for the normal local-development workflow; it never publishes the static bundle.
|
|
153
|
+
The exclude flag remains useful for existing scripts and automation that intentionally run the deployment workflow while Vite serves the frontend:
|
|
153
154
|
|
|
154
155
|
```bash
|
|
155
156
|
npx rayfin up --exclude-services staticHosting
|
|
156
157
|
```
|
|
157
158
|
|
|
158
|
-
|
|
159
|
+
Rayfin's bundled samples and templates use `rayfin dev` for their `npm run dev` script.
|
|
159
160
|
|
|
160
161
|
## Apply database changes remotely
|
|
161
162
|
|
|
@@ -202,6 +203,24 @@ Add `--json` for machine-readable output:
|
|
|
202
203
|
npx rayfin up status --json
|
|
203
204
|
```
|
|
204
205
|
|
|
206
|
+
When static content is deployed, the human-readable output includes its public URL:
|
|
207
|
+
|
|
208
|
+
```text
|
|
209
|
+
Static app: https://silky-sand-4924b3ad1f-centraluseuap.webapp.rayfingwdev.com
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
The JSON output exposes the same value as `deployment.hostingUrl`:
|
|
213
|
+
|
|
214
|
+
```json
|
|
215
|
+
{
|
|
216
|
+
"deployment": {
|
|
217
|
+
"hostingUrl": "https://silky-sand-4924b3ad1f-centraluseuap.webapp.rayfingwdev.com"
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
When no static app URL is recorded, the human-readable output omits the line and `deployment.hostingUrl` is `null` in JSON.
|
|
223
|
+
|
|
205
224
|
## Sign out
|
|
206
225
|
|
|
207
226
|
Clear cached credentials when you are done or need to switch accounts:
|
|
@@ -273,7 +273,8 @@ Most apps should use `ensureSignedInWithFabric` instead.
|
|
|
273
273
|
## Environment variables
|
|
274
274
|
|
|
275
275
|
Fabric auth requires three Vite environment variables so your frontend can build the `FabricAuthOptions` at runtime.
|
|
276
|
-
`npx rayfin
|
|
276
|
+
`npx rayfin dev` writes the underlying `RAYFIN_PUBLIC_*` values to `rayfin/.env` and maps them to Vite-compatible names in `.env.local` before starting the frontend.
|
|
277
|
+
Production builds retain the scaffolded `prebuild` hook to refresh those values before bundling.
|
|
277
278
|
|
|
278
279
|
| Source variable (`rayfin/.env`) | Vite variable (`.env.local`) | Description | Example |
|
|
279
280
|
| --- | --- | --- | --- |
|
|
@@ -302,7 +303,7 @@ const fabricOptions = {
|
|
|
302
303
|
|
|
303
304
|
## Deployment values
|
|
304
305
|
|
|
305
|
-
After running `npx rayfin up`, the CLI records deployment metadata in `rayfin/.deployments.json` and merges the corresponding `RAYFIN_PUBLIC_*` variables into `rayfin/.env`:
|
|
306
|
+
After running `npx rayfin dev` or `npx rayfin up`, the CLI records deployment metadata in `rayfin/.deployments.json` and merges the corresponding `RAYFIN_PUBLIC_*` variables into `rayfin/.env`:
|
|
306
307
|
|
|
307
308
|
```text
|
|
308
309
|
RAYFIN_PUBLIC_ITEM_ID=<guid>
|
|
@@ -310,7 +311,8 @@ RAYFIN_PUBLIC_WORKSPACE_ID=<guid>
|
|
|
310
311
|
RAYFIN_PUBLIC_PORTAL_URL=https://app.fabric.microsoft.com/
|
|
311
312
|
```
|
|
312
313
|
|
|
313
|
-
|
|
314
|
+
`rayfin dev` generates `.env.local` with Vite-compatible names before starting the frontend.
|
|
315
|
+
Use `RAYFIN_PUBLIC_ITEM_ID` as the `projectId` and `RAYFIN_PUBLIC_WORKSPACE_ID` as the `workspaceId` in your `FabricAuthOptions`.
|
|
314
316
|
|
|
315
317
|
## Troubleshooting
|
|
316
318
|
|
|
@@ -10,8 +10,9 @@ The `rayfin env` command (or the auto-emit built into `rayfin up`) maps them to
|
|
|
10
10
|
|
|
11
11
|
| Variable | Description | Populated by |
|
|
12
12
|
| --- | --- | --- |
|
|
13
|
-
| `RAYFIN_PUBLIC_API_URL` | Rayfin backend URL
|
|
14
|
-
| `RAYFIN_PUBLIC_PUBLISHABLE_KEY` | Public key for Rayfin SDK initialization. | `rayfin up` |
|
|
13
|
+
| `RAYFIN_PUBLIC_API_URL` | Rayfin backend URL selected for the development or deployed environment. | `rayfin dev` / `rayfin up` |
|
|
14
|
+
| `RAYFIN_PUBLIC_PUBLISHABLE_KEY` | Public key for Rayfin SDK initialization. | `rayfin dev` / `rayfin up` |
|
|
15
|
+
| `RAYFIN_PUBLIC_FUNCTIONS_URL` | URL of the local Functions host started by `rayfin dev`. Removed when functions are disabled so local clients do not retain a stale host. | `rayfin dev` |
|
|
15
16
|
| `RAYFIN_PUBLIC_ITEM_ID` | Fabric AppBackend item ID. Used for Fabric brokered auth. | `rayfin up` |
|
|
16
17
|
| `RAYFIN_PUBLIC_WORKSPACE_ID` | Fabric workspace ID. Used for Fabric brokered auth. | `rayfin up` |
|
|
17
18
|
| `RAYFIN_PUBLIC_TENANT_ID` | Entra ID tenant for workspace disambiguation. | `rayfin up` |
|
|
@@ -27,6 +28,7 @@ The `rayfin env` command (or the auto-emit built into `rayfin up`) maps them to
|
|
|
27
28
|
| --- | --- | --- | --- |
|
|
28
29
|
| `RAYFIN_PUBLIC_API_URL` | `VITE_RAYFIN_API_URL` | `NEXT_PUBLIC_RAYFIN_API_URL` | `API_URL` |
|
|
29
30
|
| `RAYFIN_PUBLIC_PUBLISHABLE_KEY` | `VITE_RAYFIN_PUBLISHABLE_KEY` | `NEXT_PUBLIC_RAYFIN_PUBLISHABLE_KEY` | `PUBLISHABLE_KEY` |
|
|
31
|
+
| `RAYFIN_PUBLIC_FUNCTIONS_URL` | `VITE_RAYFIN_FUNCTIONS_URL` | `NEXT_PUBLIC_RAYFIN_FUNCTIONS_URL` | `FUNCTIONS_URL` |
|
|
30
32
|
| `RAYFIN_PUBLIC_ITEM_ID` | `VITE_FABRIC_ITEM_ID` | `NEXT_PUBLIC_FABRIC_ITEM_ID` | `ITEM_ID` |
|
|
31
33
|
| `RAYFIN_PUBLIC_WORKSPACE_ID` | `VITE_FABRIC_WORKSPACE_ID` | `NEXT_PUBLIC_FABRIC_WORKSPACE_ID` | `WORKSPACE_ID` |
|
|
32
34
|
| `RAYFIN_PUBLIC_TENANT_ID` | `VITE_FABRIC_TENANT_ID` | `NEXT_PUBLIC_FABRIC_TENANT_ID` | `TENANT_ID` |
|
|
@@ -40,6 +42,37 @@ Custom `RAYFIN_PUBLIC_*` variables you add follow a generic pattern: `RAYFIN_PUB
|
|
|
40
42
|
The sample `vite.config.ts` files pin the server to it with `strictPort`, so if the assigned port is already taken the dev server fails fast instead of silently drifting to another port.
|
|
41
43
|
To run on a different port, set `RAYFIN_PUBLIC_FRONTEND_PORT` in `rayfin/.env` (then re-run `rayfin env`); `rayfin up` registers whatever value is assigned in the deployed redirect allow-list.
|
|
42
44
|
|
|
45
|
+
### Bare development runtime wiring
|
|
46
|
+
|
|
47
|
+
`npx rayfin dev` runs the local frontend against the Fabric backend by default.
|
|
48
|
+
Use `npx rayfin dev --provider fabric` to select the same provider explicitly.
|
|
49
|
+
The CLI reuses a registered deployment or provisions and records a missing AppBackend.
|
|
50
|
+
Set `RAYFIN_WORKSPACE_ID` to target a specific workspace; otherwise the active registered deployment or My workspace is used.
|
|
51
|
+
|
|
52
|
+
The CLI starts `npm run dev:frontend` when that script exists and falls back to `npm run dev` for existing projects.
|
|
53
|
+
This lets bundled templates expose `npm run dev` as the complete session without recursively starting the CLI.
|
|
54
|
+
When migrating an existing project to `"dev": "rayfin dev"`, also add a non-recursive child such as `"dev:frontend": "vite"`; otherwise the CLI fails with an actionable recursion error.
|
|
55
|
+
Scripts are resolved from `services.staticHosting.path` when configured, otherwise from the project root.
|
|
56
|
+
For a nested frontend package, declare `dev:frontend` (or the legacy `dev` fallback) in that package's `package.json`.
|
|
57
|
+
|
|
58
|
+
When `services.functions.enabled` is `true`, the same command builds and starts the configured functions package with Azure Functions Core Tools.
|
|
59
|
+
The CLI reserves the nearest available Functions port starting at `7071` and writes its URL to `RAYFIN_PUBLIC_FUNCTIONS_URL` before starting the frontend.
|
|
60
|
+
When functions are disabled, the CLI removes any stale `RAYFIN_PUBLIC_FUNCTIONS_URL` from `rayfin/.env` and regenerates the framework environment file without it.
|
|
61
|
+
|
|
62
|
+
The local functions setup makes these workspace changes:
|
|
63
|
+
|
|
64
|
+
- Merges backend coordinates and the Node inspector argument into the configured functions package's `local.settings.json`.
|
|
65
|
+
- Adds a `Functions: Attach` configuration to the root `.vscode/launch.json` after the Functions host becomes ready.
|
|
66
|
+
- Leaves JSON-with-comments launch files unchanged and reports that the attach configuration must be added manually.
|
|
67
|
+
- Patches recognized `src/services/rayfinClient.ts` and `src/services/bootstrap.ts` template files once so `functionsBaseUrl` reads `VITE_RAYFIN_FUNCTIONS_URL`.
|
|
68
|
+
- Regenerates the framework `.env.local` file unless `--no-emit-env` is set.
|
|
69
|
+
|
|
70
|
+
The Node inspector defaults to port `9229` and slides to the nearest available port when needed.
|
|
71
|
+
Use the `Functions: Attach` launch configuration after the host is ready to debug local function code.
|
|
72
|
+
|
|
73
|
+
To run the managed backend locally instead, enable the Docker preview and use `npx rayfin dev --provider docker`.
|
|
74
|
+
Frontend and functions code still run as local processes; only the managed Rayfin backend moves from Fabric to Docker.
|
|
75
|
+
|
|
43
76
|
## Tooling overrides
|
|
44
77
|
|
|
45
78
|
These variables configure CLI and extension behavior.
|
|
@@ -146,14 +179,15 @@ These variables are read from the shell environment and are never written to fil
|
|
|
146
179
|
| `RAYFIN_WORKSPACE_ID` | Fabric workspace ID for non-interactive setup. Used with `RAYFIN_TOKEN`. |
|
|
147
180
|
| `RAYFIN_TENANT_ID` | Entra ID tenant used by `rayfin up` for portal URLs and the `ctid` query parameter. Equivalent to the `-t, --tenant <id>` flag (precedence: flag > env var > signed-in tenant). |
|
|
148
181
|
| `RAYFIN_ENCRYPTION_FALLBACK_ENABLED` | Set to `true` to allow plaintext token cache on systems without OS credential storage. Development only. |
|
|
149
|
-
| `RAYFIN_FEATURE_FLAGS` | Comma-separated list of experimental feature names to enable (case-insensitive). Recognized values include `storage`, `functions`, and `postgresql`. |
|
|
150
|
-
| `RAYFIN_WEBSERVICE_IMAGE_NAME` | **Experimental.** Override the webservice container image used by `rayfin dev
|
|
182
|
+
| `RAYFIN_FEATURE_FLAGS` | Comma-separated list of experimental feature names to enable (case-insensitive). Recognized values include `docker-local-dev`, `storage`, `functions`, and `postgresql`. |
|
|
183
|
+
| `RAYFIN_WEBSERVICE_IMAGE_NAME` | **Experimental.** Override the webservice container image used by `rayfin dev --provider docker` and Docker Compose. Defaults to `ghcr.io/microsoft/project-rayfin/webservice:cli-<version>`. |
|
|
151
184
|
| `RAYFIN_APPINSIGHTS_CONNECTION_STRING` | Override the telemetry endpoint for the CLI and VS Code extension. |
|
|
152
185
|
|
|
153
186
|
### Recognized `RAYFIN_FEATURE_FLAGS` values
|
|
154
187
|
|
|
155
188
|
| Flag | Effect |
|
|
156
189
|
| --- | --- |
|
|
190
|
+
| `docker-local-dev` | Allows `rayfin dev --provider docker` and the Docker maintenance commands. Bare `rayfin dev` remains available without this flag and defaults to Fabric. |
|
|
157
191
|
| `storage` | Exposes storage commands (`rayfin dev storage *`) and storage prompts during `rayfin init`. |
|
|
158
192
|
| `functions` | Exposes Functions service prompts during `rayfin init`. |
|
|
159
193
|
| `postgresql` | Adds PostgreSQL as a selectable dialect during `rayfin init` and `rayfin init` with bundled templates. |
|
package/assets/docs/cli/index.md
CHANGED
|
@@ -16,10 +16,12 @@ see [CLI Installation](./installation.md).
|
|
|
16
16
|
```bash
|
|
17
17
|
npm create @microsoft/rayfin@latest my-app # 1. Create a project from a template
|
|
18
18
|
cd my-app
|
|
19
|
-
|
|
20
|
-
npm run dev # 3. Run the frontend dev server
|
|
19
|
+
npm run dev # 2. Start the complete development session
|
|
21
20
|
```
|
|
22
21
|
|
|
22
|
+
The scaffolded `dev` script runs `rayfin dev`.
|
|
23
|
+
It provisions or reuses a Fabric backend, applies the declared services and schema, and starts the frontend and enabled Functions locally.
|
|
24
|
+
|
|
23
25
|
> **Existing or empty projects:** Use `npx rayfin init` instead of `npm create` to add Rayfin to a project that already has source code or an empty directory.
|
|
24
26
|
> The init command walks you through enabling services, choosing a database dialect, and configuring static hosting without scaffolding a new template.
|
|
25
27
|
|
|
@@ -41,6 +43,13 @@ For the full walkthrough, see the [CLI Quickstart](./quickstart.md) or the [Buil
|
|
|
41
43
|
> Use this to enable or disable services, switch the database dialect, or toggle static hosting without editing `rayfin.yml` by hand.
|
|
42
44
|
> The CLI preserves your data model files under `rayfin/data/` during reconfiguration.
|
|
43
45
|
|
|
46
|
+
### Development
|
|
47
|
+
|
|
48
|
+
| Command | Description |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `npx rayfin dev` | Start the development session. Uses the Fabric backend provider by default, provisions a missing AppBackend, applies declared state, and starts frontend and Functions code locally. |
|
|
51
|
+
| `npx rayfin dev --provider docker` | Run the managed backend through the preview Docker provider while keeping frontend and Functions code local. |
|
|
52
|
+
|
|
44
53
|
### Deployment
|
|
45
54
|
|
|
46
55
|
| Command | Description |
|
|
@@ -60,15 +60,14 @@ npx rayfin --help
|
|
|
60
60
|
|
|
61
61
|
## First steps
|
|
62
62
|
|
|
63
|
-
Start the
|
|
63
|
+
Start the complete development session:
|
|
64
64
|
|
|
65
65
|
```bash
|
|
66
|
-
|
|
66
|
+
npm run dev
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
Wait for the deployment to complete before continuing.
|
|
69
|
+
The bundled templates' script runs `rayfin dev`.
|
|
70
|
+
It provisions or reuses the Fabric backend, applies declared state, generates framework environment variables, and starts the frontend and enabled Functions locally.
|
|
72
71
|
|
|
73
72
|
Apply schema changes after updating your data models:
|
|
74
73
|
|
|
@@ -76,12 +75,6 @@ Apply schema changes after updating your data models:
|
|
|
76
75
|
npx rayfin up db apply
|
|
77
76
|
```
|
|
78
77
|
|
|
79
|
-
Run your frontend dev server in a separate terminal:
|
|
80
|
-
|
|
81
|
-
```bash
|
|
82
|
-
npm run dev
|
|
83
|
-
```
|
|
84
|
-
|
|
85
78
|
## Update the CLI
|
|
86
79
|
|
|
87
80
|
To get the latest version:
|
|
@@ -34,6 +34,19 @@ npx rayfin init
|
|
|
34
34
|
|
|
35
35
|
This installs the CLI and runs the interactive setup to create the `rayfin/` directory with starter configuration files.
|
|
36
36
|
|
|
37
|
+
## Develop locally
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
npx rayfin dev
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
- Uses the Fabric backend provider by default and provisions a missing AppBackend.
|
|
44
|
+
- Applies runtime settings and database schema before starting user code.
|
|
45
|
+
- Starts the frontend and enabled Functions as local processes.
|
|
46
|
+
- Press `Ctrl+C` to end the session.
|
|
47
|
+
|
|
48
|
+
Bundled templates expose the same workflow as `npm run dev`.
|
|
49
|
+
|
|
37
50
|
## Deploy to Fabric
|
|
38
51
|
|
|
39
52
|
```bash
|
|
@@ -69,8 +82,9 @@ npx rayfin up db apply [--force]
|
|
|
69
82
|
|
|
70
83
|
If `staticHosting` is enabled in `rayfin/rayfin.yml`, `npx rayfin up` automatically builds, packages, and deploys your static assets.
|
|
71
84
|
|
|
72
|
-
|
|
73
|
-
|
|
85
|
+
`rayfin dev` never publishes static content, so Vite can serve the frontend without a static deployment.
|
|
86
|
+
|
|
87
|
+
The lower-level `npx rayfin up --exclude-services staticHosting` command remains available for existing scripts and automation that need to run the deployment workflow while skipping only static content.
|
|
74
88
|
|
|
75
89
|
To redeploy static content independently without running the full `rayfin up` flow:
|
|
76
90
|
|
|
@@ -26,7 +26,7 @@ Apply `@role` at the class level to control which roles can perform which action
|
|
|
26
26
|
| --- | --- |
|
|
27
27
|
| `roleName` | The role name (`'anonymous'` or `'authenticated'`). |
|
|
28
28
|
| `actions` | A single action or array of actions: `'create'`, `'read'`, `'update'`, `'delete'`, or `'*'` for all. |
|
|
29
|
-
| `options` | Optional object with `
|
|
29
|
+
| `options` | Optional object with `policy`, `include`, and `exclude` properties. |
|
|
30
30
|
|
|
31
31
|
## Basic example
|
|
32
32
|
|
|
@@ -38,7 +38,7 @@ import { entity, role, uuid, text } from '@microsoft/rayfin-core';
|
|
|
38
38
|
@entity()
|
|
39
39
|
@role('anonymous', 'read')
|
|
40
40
|
@role('authenticated', ['create', 'read', 'update', 'delete'], {
|
|
41
|
-
|
|
41
|
+
policy: (claims, item) => claims.sub.eq(item.user_id),
|
|
42
42
|
})
|
|
43
43
|
export class Todo {
|
|
44
44
|
@uuid() id!: string;
|
|
@@ -52,11 +52,11 @@ In this example, authenticated users can only access Todo items where `user_id`
|
|
|
52
52
|
|
|
53
53
|
## Type-safe policy expressions
|
|
54
54
|
|
|
55
|
-
The `
|
|
55
|
+
The `policy` callback provides typed access to both claims and entity fields.
|
|
56
56
|
TypeScript infers the entity type from the decorated class, so you get autocompletion and refactor safety with no extra configuration.
|
|
57
57
|
|
|
58
58
|
```typescript
|
|
59
|
-
|
|
59
|
+
policy: (claims, item) => claims.sub.eq(item.user_id)
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
### Supported claims
|
|
@@ -78,7 +78,7 @@ check: (claims, item) => claims.sub.eq(item.user_id)
|
|
|
78
78
|
Combine expressions with `.and()` and `.or()`:
|
|
79
79
|
|
|
80
80
|
```typescript
|
|
81
|
-
|
|
81
|
+
policy: (claims, item) =>
|
|
82
82
|
claims.sub.eq(item.user_id).and(item.isActive.eq(true))
|
|
83
83
|
```
|
|
84
84
|
|
|
@@ -86,7 +86,7 @@ Both sides are parenthesized automatically, so grouping is always explicit:
|
|
|
86
86
|
|
|
87
87
|
```typescript
|
|
88
88
|
// (claims.role eq 'admin') or (claims.sub eq @item.owner_id)
|
|
89
|
-
|
|
89
|
+
policy: (claims, item) =>
|
|
90
90
|
claims.role.eq('admin').or(claims.sub.eq(item.owner_id))
|
|
91
91
|
```
|
|
92
92
|
|
|
@@ -100,7 +100,7 @@ Only allow the `Title` field during create:
|
|
|
100
100
|
|
|
101
101
|
```typescript
|
|
102
102
|
@role('authenticated', 'create', {
|
|
103
|
-
|
|
103
|
+
policy: (claims, item) => claims.sub.eq(item.createdBy),
|
|
104
104
|
include: ['Title'],
|
|
105
105
|
})
|
|
106
106
|
```
|
|
@@ -111,7 +111,7 @@ Hide sensitive fields from read operations:
|
|
|
111
111
|
|
|
112
112
|
```typescript
|
|
113
113
|
@role('authenticated', 'read', {
|
|
114
|
-
|
|
114
|
+
policy: (_claims, item) => item.IsAdmin.eq(false),
|
|
115
115
|
exclude: ['last_login'],
|
|
116
116
|
})
|
|
117
117
|
```
|
|
@@ -127,14 +127,14 @@ Apply different rules per action by using multiple `@role` decorators with singl
|
|
|
127
127
|
@entity()
|
|
128
128
|
@role('anonymous', 'read')
|
|
129
129
|
@role('authenticated', 'create', {
|
|
130
|
-
|
|
130
|
+
policy: (claims, item) => claims.sub.eq(item.createdBy),
|
|
131
131
|
include: ['Title'],
|
|
132
132
|
})
|
|
133
133
|
@role('authenticated', 'read', {
|
|
134
|
-
|
|
134
|
+
policy: (claims, item) => claims.sub.eq(item.createdBy),
|
|
135
135
|
})
|
|
136
136
|
@role('authenticated', 'update', {
|
|
137
|
-
|
|
137
|
+
policy: (claims, item) => claims.sub.eq(item.createdBy),
|
|
138
138
|
exclude: ['adminContent'],
|
|
139
139
|
})
|
|
140
140
|
export class SecureDocument {
|
|
@@ -155,7 +155,7 @@ import { blob, role } from '@microsoft/rayfin-core';
|
|
|
155
155
|
|
|
156
156
|
@blob()
|
|
157
157
|
@role('authenticated', '*', {
|
|
158
|
-
|
|
158
|
+
policy: (claims, item) => claims.sub.eq(item.owner_id),
|
|
159
159
|
})
|
|
160
160
|
export class ProfileImage {
|
|
161
161
|
owner_id!: string;
|
|
@@ -167,6 +167,7 @@ export class ProfileImage {
|
|
|
167
167
|
- The `@role` decorator collects permission metadata at class definition time.
|
|
168
168
|
- When you run `npx rayfin up db apply`, the CLI reads that metadata and generates DAB-compliant permission entries in the configuration.
|
|
169
169
|
- Policy callbacks are compiled into DAB OData-style policy strings (for example `@claims.sub eq @item.user_id`).
|
|
170
|
+
In the generated DAB configuration the compiled expression appears under a `check` key; `policy` is the name you author with.
|
|
170
171
|
- Field `include`/`exclude` arrays map directly to DAB field permission configuration.
|
|
171
172
|
- Multiple `@role` decorators on the same class are aggregated per role.
|
|
172
173
|
Conflicting declarations produce a warning at generation time.
|
|
@@ -14,13 +14,15 @@ Run `npm create @microsoft/rayfin@latest` in a terminal window and select welcom
|
|
|
14
14
|
|
|
15
15
|
## Run the app
|
|
16
16
|
|
|
17
|
-
1.
|
|
18
|
-
|
|
17
|
+
1. Sign in to Fabric with `npx rayfin login`.
|
|
18
|
+
In an environment without OS credential storage, use `npx rayfin login --encryption-fallback-enabled` only if you accept plaintext token caching for development.
|
|
19
|
+
2. In the same terminal window, run `npm run dev`.
|
|
20
|
+
The command provisions or reuses the Fabric backend, applies declared state, and starts the frontend locally.
|
|
19
21
|
3. When the frontend starts, it will output the page to visit.
|
|
20
22
|
Visit and ensure you can view the Timestamp Tracker.
|
|
21
23
|
4. Click **Send Timestamp** to POST the current time to `/api/graphql/Timestamp`, then use **Refresh list** to pull back the newest 100 entries.
|
|
22
24
|
5. All UI plus data-fetching logic lives in a single file: `src/main.ts`.
|
|
23
|
-
6. To
|
|
25
|
+
6. To target a specific Fabric workspace, set `RAYFIN_WORKSPACE_ID` and re-run `npm run dev`.
|
|
24
26
|
|
|
25
27
|
## Update the data model
|
|
26
28
|
|
|
@@ -94,7 +96,7 @@ After updating your data models, test your app.
|
|
|
94
96
|
npm run dev
|
|
95
97
|
```
|
|
96
98
|
|
|
97
|
-
> NOTE:
|
|
99
|
+
> NOTE: Restart `npm run dev` after changing `rayfin.yml` so the backend receives the updated declared state.
|
|
98
100
|
|
|
99
101
|
## View your local database
|
|
100
102
|
|
|
@@ -8,15 +8,15 @@ title: Getting Started
|
|
|
8
8
|
Rayfin supports two development paths.
|
|
9
9
|
Choose the one that matches how you want to get started.
|
|
10
10
|
|
|
11
|
-
###
|
|
11
|
+
### Inner-loop development
|
|
12
12
|
|
|
13
|
-
Run
|
|
14
|
-
|
|
13
|
+
Run frontend and Functions code locally against a managed Rayfin backend.
|
|
14
|
+
Fabric is the default backend provider; the Docker provider is available separately as a preview.
|
|
15
|
+
The default path requires a Microsoft account with Fabric access, an accessible workspace, and the tenant settings needed to create an AppBackend.
|
|
15
16
|
|
|
16
17
|
1. Install prerequisites.
|
|
17
18
|
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
|
|
19
|
-
1. Run your frontend with `npm run dev`.
|
|
19
|
+
1. Start the complete development session with `npm run dev` or `npx rayfin dev`.
|
|
20
20
|
|
|
21
21
|
**Start here:** [Build your first Rayfin app](./create-app-with-cli.md)
|
|
22
22
|
|
|
@@ -34,7 +34,10 @@ This path requires a Microsoft account with Fabric access and tenant admin setti
|
|
|
34
34
|
## Prerequisites
|
|
35
35
|
|
|
36
36
|
Install these tools before you begin with either path.
|
|
37
|
-
Rayfin requires Node.js 20 or later
|
|
37
|
+
Rayfin requires Node.js 20 or later and the GitHub CLI.
|
|
38
|
+
Docker Desktop or Docker Engine is required only for `rayfin dev --provider docker`.
|
|
39
|
+
Fabric development also requires OS credential storage for the token cache.
|
|
40
|
+
In dev containers, Codespaces, or Linux environments without a keychain, run `npx rayfin login --encryption-fallback-enabled` to explicitly allow the development-only plaintext fallback.
|
|
38
41
|
|
|
39
42
|
### Windows
|
|
40
43
|
|
|
@@ -15,6 +15,7 @@ your-project/
|
|
|
15
15
|
│ │ ├── schema.ts
|
|
16
16
|
│ │ └── *.ts
|
|
17
17
|
│ ├── .env
|
|
18
|
+
│ ├── .project.json
|
|
18
19
|
│ ├── rayfin.yml
|
|
19
20
|
│ └── tsconfig.json
|
|
20
21
|
├── src/
|
|
@@ -184,6 +185,16 @@ Configure an email provider for magic links, password resets, and email verifica
|
|
|
184
185
|
`rayfin/.env` is an optional environment file used to supply values to `rayfin.yml` via interpolation.
|
|
185
186
|
Do not commit secrets, and prefer a `rayfin/.env.example` file for documentation.
|
|
186
187
|
|
|
188
|
+
### rayfin/.project.json
|
|
189
|
+
|
|
190
|
+
`rayfin/.project.json` contains a random project-origin identifier created by `create-rayfin` when anonymous telemetry is enabled.
|
|
191
|
+
The CLI uses it to correlate the original scaffold event with later `rayfin up` deployment events without storing user, machine, workspace, or project names.
|
|
192
|
+
Commit this file so the project keeps the same scaffold lineage across machines, clones, and CI environments.
|
|
193
|
+
You should not need to edit it.
|
|
194
|
+
If you do not want deployments to share the scaffold lineage, you can safely delete `rayfin/.project.json`.
|
|
195
|
+
Deployments continue to work and stop reporting the origin correlation.
|
|
196
|
+
To keep the marker local, add it to `.gitignore` before committing it; if it is already tracked, remove it from source control.
|
|
197
|
+
|
|
187
198
|
### rayfin/data/*.ts
|
|
188
199
|
|
|
189
200
|
Files in `rayfin/data/` define your entities.
|
|
@@ -280,7 +291,8 @@ export default defineConfig({
|
|
|
280
291
|
### Environment variables
|
|
281
292
|
|
|
282
293
|
Rayfin manages environment variables through `rayfin/.env` using the `RAYFIN_PUBLIC_*` prefix convention.
|
|
283
|
-
When you run `
|
|
294
|
+
When you run `rayfin dev` (or the scaffolded `npm run dev` wrapper), the CLI prepares backend wiring and generates a `.env.local` file with framework-specific variable names before starting the frontend child script.
|
|
295
|
+
The file is written under `services.staticHosting.path` for nested frontends, or at the project root when no path is configured.
|
|
284
296
|
When the CLI detects a Vite or Next.js project automatically, you can omit `--framework`.
|
|
285
297
|
|
|
286
298
|
The following Vite variables are available in your frontend code after generation:
|
|
@@ -290,4 +302,5 @@ The following Vite variables are available in your frontend code after generatio
|
|
|
290
302
|
- `VITE_RAYFIN_PUBLISHABLE_KEY` — Publishable key used for Rayfin client authentication.
|
|
291
303
|
Sourced from `RAYFIN_PUBLIC_PUBLISHABLE_KEY` in `rayfin/.env`.
|
|
292
304
|
|
|
293
|
-
To override values, edit `rayfin/.env` directly and
|
|
305
|
+
To override values, edit `rayfin/.env` directly and restart `rayfin dev`.
|
|
306
|
+
You can also run `rayfin env --framework vite` directly when you only need to regenerate the framework file.
|
|
@@ -69,14 +69,21 @@ After deployment, the CLI prints the hosting URL and stores it in `rayfin/.deplo
|
|
|
69
69
|
|
|
70
70
|
#### Skip static deployment during local dev
|
|
71
71
|
|
|
72
|
-
|
|
72
|
+
Use `rayfin dev` for the normal inner loop.
|
|
73
|
+
It provisions or reuses the backend and starts Vite locally without publishing static content:
|
|
74
|
+
|
|
75
|
+
```bash
|
|
76
|
+
rayfin dev
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Existing scripts and automation can still run `up` while skipping the static build/package/deploy phase:
|
|
73
80
|
|
|
74
81
|
```bash
|
|
75
82
|
rayfin up --exclude-services staticHosting
|
|
76
83
|
```
|
|
77
84
|
|
|
78
85
|
This skips only the static build/package/deploy phase — runtime settings are still posted, so previously deployed static content keeps serving from Fabric.
|
|
79
|
-
|
|
86
|
+
Rayfin's bundled samples and templates use `rayfin dev` instead.
|
|
80
87
|
|
|
81
88
|
### Standalone static deployment
|
|
82
89
|
|
|
@@ -5,15 +5,18 @@
|
|
|
5
5
|
|
|
6
6
|
## Overview
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
Bare `rayfin dev` uses the Fabric provider by default.
|
|
9
|
+
Pass `--provider docker` to run the managed Rayfin backend and its services through Docker Compose instead.
|
|
10
|
+
|
|
11
|
+
The provider changes only the backend location.
|
|
12
|
+
The frontend and enabled functions always run as local processes during `rayfin dev`.
|
|
10
13
|
|
|
11
14
|
Docker and Docker Compose must be installed and running before using this command.
|
|
12
15
|
|
|
13
16
|
## Starting the environment
|
|
14
17
|
|
|
15
18
|
```bash
|
|
16
|
-
npx rayfin dev
|
|
19
|
+
npx rayfin dev --provider docker
|
|
17
20
|
```
|
|
18
21
|
|
|
19
22
|
This command:
|
|
@@ -23,8 +26,29 @@ This command:
|
|
|
23
26
|
- Allocates ports for each service.
|
|
24
27
|
- Starts containers for enabled services (WebService, database, and optional storage).
|
|
25
28
|
- Runs health checks and waits for all services to be healthy.
|
|
29
|
+
- Applies the project's declared data and storage configuration to the local backend.
|
|
30
|
+
- Starts the frontend with `npm run dev:frontend` when that script exists, falling back to `npm run dev` for existing projects.
|
|
31
|
+
- Resolves that script from `services.staticHosting.path` when the frontend lives in a nested package, otherwise from the project root.
|
|
32
|
+
- Builds and starts the configured local Functions host when `services.functions.enabled` is `true`.
|
|
33
|
+
|
|
34
|
+
The command remains attached to the frontend and Functions processes.
|
|
35
|
+
Press `Ctrl+C` to stop the session and tear down the provider-owned containers.
|
|
36
|
+
|
|
37
|
+
## Local functions and debugger
|
|
38
|
+
|
|
39
|
+
When functions are enabled, `rayfin dev --provider docker` reserves the nearest free Functions port starting at `7071` and starts Azure Functions Core Tools.
|
|
40
|
+
It writes the selected URL to `RAYFIN_PUBLIC_FUNCTIONS_URL` in `rayfin/.env` and regenerates the framework `.env.local` file.
|
|
41
|
+
When functions are disabled, it removes a stale Functions URL instead.
|
|
26
42
|
|
|
27
|
-
|
|
43
|
+
The command also:
|
|
44
|
+
|
|
45
|
+
- Merges local backend settings into the configured functions package's `local.settings.json`.
|
|
46
|
+
- Reserves a Node inspector port starting at `9229`.
|
|
47
|
+
- Adds `Functions: Attach` to the root `.vscode/launch.json` after the Functions host is ready.
|
|
48
|
+
- Patches recognized `src/services/rayfinClient.ts` and `src/services/bootstrap.ts` files to pass `VITE_RAYFIN_FUNCTIONS_URL` as `functionsBaseUrl`.
|
|
49
|
+
|
|
50
|
+
If `.vscode/launch.json` contains JSON with comments, Rayfin leaves it unchanged to avoid losing those comments and asks you to add the attach configuration manually.
|
|
51
|
+
Use `--no-emit-env` to leave a hand-managed `.env.local` file unchanged.
|
|
28
52
|
|
|
29
53
|
## Stopping and resetting
|
|
30
54
|
|
|
@@ -32,22 +56,31 @@ Wait for the `All services healthy` message before continuing.
|
|
|
32
56
|
|------|----------|
|
|
33
57
|
| `--stop` | Stop running containers without removing them |
|
|
34
58
|
| `--down` | Stop and remove containers |
|
|
35
|
-
| `--purge` |
|
|
59
|
+
| `--provider docker --purge` | Confirm deletion of provider-owned Docker volumes when the attached session ends |
|
|
60
|
+
| `--down --purge` | Confirm immediate container and volume deletion without starting a session |
|
|
61
|
+
| `--export-env` | Print the retained Docker provider environment in `.env` format |
|
|
36
62
|
|
|
37
63
|
```bash
|
|
38
64
|
npx rayfin dev --stop
|
|
39
65
|
npx rayfin dev --down
|
|
40
|
-
npx rayfin dev --purge
|
|
66
|
+
npx rayfin dev --down --purge
|
|
67
|
+
npx rayfin dev --export-env
|
|
68
|
+
npx rayfin dev --provider docker --purge
|
|
41
69
|
```
|
|
42
70
|
|
|
71
|
+
The retained `--stop`, `--down`, and `--export-env` maintenance actions operate only on Docker state.
|
|
72
|
+
They do not start a workflow session or contact Fabric.
|
|
73
|
+
Purge always requires interactive confirmation or global `--yes` in automation.
|
|
74
|
+
It cannot be combined with `--stop` or `--export-env`.
|
|
75
|
+
|
|
43
76
|
## Additional options
|
|
44
77
|
|
|
45
78
|
| Flag | Behavior |
|
|
46
79
|
|------|----------|
|
|
47
|
-
| `--
|
|
48
|
-
| `--
|
|
49
|
-
| `--
|
|
50
|
-
| `--
|
|
80
|
+
| `--provider docker` | Select the Docker backend instead of the default Fabric backend |
|
|
81
|
+
| `--skip-db-apply` | Skip automatic data configuration apply |
|
|
82
|
+
| `--no-emit-env` | Leave the existing framework `.env.local` file unchanged |
|
|
83
|
+
| `--verbose` | Show detailed diagnostic output |
|
|
51
84
|
|
|
52
85
|
## Subcommands
|
|
53
86
|
|
|
@@ -96,7 +129,7 @@ Changes to `rayfin.yml` require restarting the environment:
|
|
|
96
129
|
|
|
97
130
|
```bash
|
|
98
131
|
npx rayfin dev --down
|
|
99
|
-
npx rayfin dev
|
|
132
|
+
npx rayfin dev --provider docker
|
|
100
133
|
```
|
|
101
134
|
|
|
102
135
|
## Troubleshooting
|
|
@@ -105,7 +138,8 @@ npx rayfin dev
|
|
|
105
138
|
- **`rayfin dev db apply` fails** — make sure services are healthy first (`npx rayfin dev status`).
|
|
106
139
|
- **Stale services** — stop stale containers with `npx rayfin dev --down`, then restart.
|
|
107
140
|
- **`unsupported UUID` errors** — stop stale services with `npx rayfin dev --down`.
|
|
108
|
-
- **Port conflicts** —
|
|
141
|
+
- **Port conflicts** — stop the process using the reported port; Rayfin automatically slides the frontend, Functions, and inspector ports within bounded ranges.
|
|
142
|
+
- **Functions host missing** — install Azure Functions Core Tools by running `npx rayfin dev functions apply`, then retry.
|
|
109
143
|
|
|
110
144
|
## Enabling this feature
|
|
111
145
|
|
|
@@ -120,3 +154,6 @@ Or combine with other flags:
|
|
|
120
154
|
```bash
|
|
121
155
|
export RAYFIN_FEATURE_FLAGS=docker-local-dev,storage
|
|
122
156
|
```
|
|
157
|
+
|
|
158
|
+
This feature flag gates only Docker provider selection and Docker maintenance commands.
|
|
159
|
+
Bare `rayfin dev` is available without preview flags and uses Fabric.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/rayfin-guide",
|
|
3
|
-
"version": "1.35.0-alpha.
|
|
3
|
+
"version": "1.35.0-alpha.1331",
|
|
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": [
|