@microsoft/rayfin-guide 1.36.0-alpha.1756 → 1.36.0-alpha.1818
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 +36 -1
- package/assets/docs/cli/connectors/add.md +11 -1
- package/assets/docs/cli/connectors/index.md +1 -1
- package/assets/docs/cli/connectors/inspect.md +34 -1
- package/assets/docs/cli/functions/deploy.md +5 -1
- package/assets/docs/cli/functions/dev-apply.md +7 -1
- package/assets/docs/cli/functions/index.md +4 -2
- package/assets/docs/cli/functions/init.md +7 -1
- package/assets/docs/cli/index.md +19 -7
- package/assets/docs/cli/secrets.md +18 -8
- package/assets/docs/functions/connections/add-ado.md +8 -4
- package/assets/docs/functions/connections/add-azure-resource.md +17 -131
- package/assets/docs/functions/connections/add-fabric-resource.md +31 -61
- package/assets/docs/functions/connections/add-foundry.md +11 -4
- package/assets/docs/functions/connections/get-fabric-info.md +7 -25
- package/assets/docs/functions/connections/index.md +127 -22
- package/assets/docs/functions/index.md +39 -1
- package/assets/docs/functions/secrets.md +39 -11
- package/assets/docs/functions/writing-functions.md +27 -23
- package/assets/docs/getting-started/project-structure.md +3 -1
- package/package.json +1 -1
- package/assets/docs/functions/connections/add-work-iq.md +0 -39
|
@@ -26,11 +26,11 @@ udf.func(
|
|
|
26
26
|
|
|
27
27
|
`udf.func()` takes three arguments:
|
|
28
28
|
|
|
29
|
-
| Argument | Description
|
|
30
|
-
| ------------- |
|
|
31
|
-
| `name` | The function name. Becomes the invocation route and the key in your generated schema.
|
|
32
|
-
| `fn` | The handler. Its parameter and return types are read by [typegen](./typegen.md).
|
|
33
|
-
| `connections` | Optional array of connection bindings. Pass `[]`
|
|
29
|
+
| Argument | Description |
|
|
30
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `name` | The function name. Becomes the invocation route and the key in your generated schema. |
|
|
32
|
+
| `fn` | The handler. Its parameter and return types are read by [typegen](./typegen.md). |
|
|
33
|
+
| `connections` | Optional array of connection bindings. Pass `[]` — audience-scoped connections are declared in the context annotation instead. |
|
|
34
34
|
|
|
35
35
|
The handler's typed parameters and return type are extracted into `types.ts` so the frontend can call the function type-safely.
|
|
36
36
|
`Promise<T>` return types are unwrapped to `T` in the generated schema.
|
|
@@ -38,7 +38,8 @@ The handler's typed parameters and return type are extracted into `types.ts` so
|
|
|
38
38
|
## Accessing data and request context
|
|
39
39
|
|
|
40
40
|
To read your data, tokens, or logging from inside a function, declare a `RayfinContext` parameter.
|
|
41
|
-
Pass your app schema as
|
|
41
|
+
Pass your app schema as the first generic (`RayfinContext<AppSchema>`) — the same schema you use with `RayfinClient<AppSchema>` — for a fully typed data client.
|
|
42
|
+
A second, optional generic declares the external audiences the function may use; see [Connecting to external resources](./connections/index.md).
|
|
42
43
|
|
|
43
44
|
```ts
|
|
44
45
|
import {
|
|
@@ -67,14 +68,16 @@ udf.func(
|
|
|
67
68
|
|
|
68
69
|
### `RayfinContext` API
|
|
69
70
|
|
|
70
|
-
| Member
|
|
71
|
-
|
|
|
72
|
-
| `ctx.getDataClient()`
|
|
73
|
-
| `ctx.
|
|
74
|
-
| `ctx.
|
|
75
|
-
| `ctx.baseUrl`
|
|
76
|
-
| `ctx.accessToken`
|
|
77
|
-
| `ctx.publishableKey`
|
|
71
|
+
| Member | Description |
|
|
72
|
+
| --------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
73
|
+
| `ctx.getDataClient()` | Returns the Rayfin DB entity data client using the invocation's Rayfin token and the caller's identity and database permissions. Query with `.select([...]).where(...).execute()`, as with `client.data.<Entity>` on the frontend. Typed when a schema generic is supplied; otherwise untyped. |
|
|
74
|
+
| `ctx.Secrets` | Secret values keyed by the names declared in `rayfin.yml`, each typed `string`. Reading an undeclared name is a compile error. See [Secrets](./secrets.md). |
|
|
75
|
+
| `ctx.Tokens` | Resource access tokens keyed by audience, each typed `string`. Narrowed to the declared audiences; deployed Functions use the app identity. See [Connecting to external resources](./connections/index.md), including local development. |
|
|
76
|
+
| `ctx.baseUrl` | The Rayfin endpoint URL (readonly). |
|
|
77
|
+
| `ctx.accessToken` | The invocation's Rayfin token, used for caller-scoped Rayfin DB access (readonly). Not an external resource token from `ctx.Tokens`. |
|
|
78
|
+
| `ctx.publishableKey` | The Rayfin publishable key (readonly). |
|
|
79
|
+
|
|
80
|
+
`ctx.getSecret(name)` and `ctx.getToken(audienceType)` are the deprecated predecessors of `ctx.Secrets` and `ctx.Tokens`. They still work, but are flagged by `@typescript-eslint/no-deprecated`.
|
|
78
81
|
|
|
79
82
|
Use `console.log(...)` / `console.error(...)` for logging.
|
|
80
83
|
|
|
@@ -100,24 +103,25 @@ udf.func(
|
|
|
100
103
|
|
|
101
104
|
## Connecting to external resources
|
|
102
105
|
|
|
103
|
-
To call external Azure or Fabric resources (SQL, Storage,
|
|
106
|
+
To call external Azure or Fabric resources (SQL, Storage, the Fabric REST API, and more) from inside a function, declare the audience in the `RayfinContext` annotation and read the token from `ctx.Tokens`:
|
|
104
107
|
|
|
105
108
|
```ts
|
|
106
109
|
import { AudienceType } from "@microsoft/fabric-user-data-functions";
|
|
107
110
|
|
|
108
111
|
udf.func(
|
|
109
|
-
"
|
|
110
|
-
async (
|
|
111
|
-
|
|
112
|
+
"accessStorage",
|
|
113
|
+
async (
|
|
114
|
+
ctx: RayfinContext<AppSchema, AudienceType.Storage>,
|
|
115
|
+
): Promise<void> => {
|
|
116
|
+
const token = ctx.Tokens.Storage;
|
|
112
117
|
// Use `token` with the resource's SDK or REST API.
|
|
113
|
-
return secretName;
|
|
114
118
|
},
|
|
115
|
-
[
|
|
119
|
+
[],
|
|
116
120
|
);
|
|
117
121
|
```
|
|
118
122
|
|
|
119
|
-
The
|
|
120
|
-
See [Connecting to external resources](./connections/index.md) for
|
|
123
|
+
The annotation is the declaration — listing the audience is what registers the connection binding, so nothing goes in the third argument.
|
|
124
|
+
See [Application authentication](./index.md#application-authentication) for configuration and identities, and [Connecting to external resources](./connections/index.md) for supported audiences and per-resource guides.
|
|
121
125
|
|
|
122
126
|
## Importing data entities
|
|
123
127
|
|
|
@@ -135,6 +139,6 @@ import type { Entry } from "../../data/Entry.js";
|
|
|
135
139
|
|
|
136
140
|
- Always register functions with `udf.func(name, handler, [])` — do not export bare functions.
|
|
137
141
|
- Use `RayfinContext<AppSchema>` for type-safe data access. Bare `RayfinContext` still works but gives no type safety on `getDataClient()`.
|
|
138
|
-
-
|
|
142
|
+
- Declare external audiences in the context annotation (`RayfinContext<AppSchema, AudienceType.X>`) and read them with `ctx.Tokens.X` — an audience you did not declare is a compile error.
|
|
139
143
|
- A function must return a value or `void`. Throwing an error surfaces to the caller as an invocation failure carrying the error message.
|
|
140
144
|
- Use `import type` for data entity imports; never a runtime `import`.
|
|
@@ -76,7 +76,7 @@ The root build orders shared, data, and frontend work.
|
|
|
76
76
|
Focused package commands use npm's workspace selector, such as `npm run -w @rayfin-app/frontend test`.
|
|
77
77
|
|
|
78
78
|
The base workspace does not contain `packages/functions`, and `services.functions.enabled` is `false`.
|
|
79
|
-
Running `npm run pack:add -- functions` creates the stable functions package, enables its service
|
|
79
|
+
Running `npm run pack:add -- functions` creates the stable functions package, enables its service with `auth.type: application`, composes its build into root orchestration, and installs dependencies from the workspace root.
|
|
80
80
|
Capability packs do not use a nested functions lockfile or nested install.
|
|
81
81
|
|
|
82
82
|
### Universal App service paths
|
|
@@ -102,6 +102,8 @@ services:
|
|
|
102
102
|
Rayfin resolves each `path` from the application root, then runs that service's `buildCommand` with the service directory as its working directory.
|
|
103
103
|
The static-hosting folder is therefore `packages/frontend/dist`, not a root `dist` directory.
|
|
104
104
|
After the functions pack is applied, functions uses `path: packages/functions` with its package-local `npm run build`.
|
|
105
|
+
Enabled Functions require explicit `services.functions.auth.type: application`; the disabled base configuration above may omit `auth`.
|
|
106
|
+
See [Application authentication](../functions/index.md#application-authentication) for existing-app configuration and downstream permissions.
|
|
105
107
|
|
|
106
108
|
The Project Rayfin repository keeps this Builder-facing workspace under `samples/universal-app/template`.
|
|
107
109
|
Its parent `samples/universal-app` is only a Rush validation harness that generates an ephemeral target and links that target to repository-local SDK packages.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/rayfin-guide",
|
|
3
|
-
"version": "1.36.0-alpha.
|
|
3
|
+
"version": "1.36.0-alpha.1818",
|
|
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,39 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
sidebar_position: 6
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Add WorkIQ
|
|
6
|
-
|
|
7
|
-
Call the **WorkIQ** service from a function **as the signed-in user**, using `AudienceType.WorkIQ`.
|
|
8
|
-
|
|
9
|
-
Provide the **WorkIQ endpoint** you are calling. The token is a standard bearer token — send it with `fetch`:
|
|
10
|
-
|
|
11
|
-
```ts
|
|
12
|
-
import {
|
|
13
|
-
UserDataFunctions,
|
|
14
|
-
AudienceType,
|
|
15
|
-
type RayfinContext,
|
|
16
|
-
} from "@microsoft/fabric-user-data-functions";
|
|
17
|
-
|
|
18
|
-
const udf = new UserDataFunctions();
|
|
19
|
-
|
|
20
|
-
// Use your real WorkIQ endpoint.
|
|
21
|
-
const WORKIQ_ENDPOINT = "https://workiq.svc.cloud.microsoft/...";
|
|
22
|
-
|
|
23
|
-
udf.func(
|
|
24
|
-
"callWorkIq",
|
|
25
|
-
async (ctx: RayfinContext): Promise<unknown> => {
|
|
26
|
-
const token = ctx.getToken(AudienceType.WorkIQ);
|
|
27
|
-
const res = await fetch(WORKIQ_ENDPOINT, {
|
|
28
|
-
headers: { Authorization: `Bearer ${token}` },
|
|
29
|
-
});
|
|
30
|
-
if (!res.ok) {
|
|
31
|
-
throw new Error(`WorkIQ returned ${res.status}`);
|
|
32
|
-
}
|
|
33
|
-
return res.json();
|
|
34
|
-
},
|
|
35
|
-
[udf.connection({ audienceType: AudienceType.WorkIQ })],
|
|
36
|
-
);
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
See [Connecting to external resources](./index.md) for the shared connection model.
|