@microsoft/rayfin-functions 1.36.0-alpha.1675 → 1.36.0-alpha.1756

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/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @microsoft/rayfin-functions
2
2
 
3
- > **Experimental** — this package is experimental and may change substantially in the near future.
3
+ See the [SDK reference overview](./assets/docs/index.md) for the public API.
4
4
 
5
5
  ## Getting started
6
6
 
@@ -0,0 +1,60 @@
1
+ ---
2
+ symbols:
3
+ - FunctionClient
4
+ - FunctionClient.invoke
5
+ - FunctionsError
6
+ - createFunctionsApi
7
+ - InvokeOptions
8
+ - FunctionInvocationResponse
9
+ - FunctionsSchema
10
+ - TypedFunctionClients
11
+ ---
12
+
13
+ # @microsoft/rayfin-functions
14
+
15
+ [![npm version](https://badge.fury.io/js/%40microsoft%2Frayfin-functions.svg)](https://badge.fury.io/js/%40microsoft%2Frayfin-functions)
16
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.2+-blue.svg)](https://www.typescriptlang.org/)
17
+
18
+ Type-safe client library for invoking Rayfin user-defined functions with strongly-typed inputs and outputs.
19
+ Most applications access it through `client.functions.<name>.invoke()` on `RayfinClient`.
20
+ This package invokes functions; server-side authoring belongs to `@microsoft/fabric-user-data-functions`.
21
+
22
+ ## Installation
23
+
24
+ ```bash
25
+ npm install @microsoft/rayfin-functions
26
+ ```
27
+
28
+ ## API summary
29
+
30
+ | Export | Purpose |
31
+ | --- | --- |
32
+ | `FunctionClient<TInput, TOutput>` | Client for one named function; constructed with `(apiClient, functionName)`. |
33
+ | `FunctionsError` | Invocation error extending `SdkError`, with a message and error code. |
34
+ | `createFunctionsApi<TSchema>(apiClient)` | Creates typed, lazily cached clients for the function names in a schema. |
35
+ | `InvokeOptions` | Per-call `headers` and `timeoutMs` options. |
36
+ | `FunctionInvocationResponse<TOutput>` | Transport envelope containing status, output, errors, and invocation ID; **not** the return type of `invoke()`. |
37
+ | `FunctionsSchema` | Maps each function name to its `input` and `output` types. |
38
+ | `TypedFunctionClients<TSchema>` | Maps a schema to its typed `FunctionClient` properties. |
39
+
40
+ ## Invocation contract
41
+
42
+ `invoke(params, options?)` returns `Promise<TOutput>`: the output value directly, not an object with an `output` property.
43
+ For a no-input function, use `invoke()` or `invoke(undefined, options)`.
44
+ Options always occupy the second argument.
45
+
46
+ `timeoutMs` defaults to 250,000 ms and is capped at that value.
47
+ A positive, finite value below the cap shortens the timeout; other invalid values use the default.
48
+ Extra request headers are supplied through `headers`.
49
+
50
+ A non-success response or a non-empty `errors` array throws `FunctionsError` with code `FUNCTION_EXECUTION_ERROR`.
51
+ Network and SDK errors propagate unchanged; unexpected errors use `UNKNOWN_FUNCTION_ERROR`.
52
+ Schemas provide compile-time types, not runtime validation.
53
+
54
+ ## Guides
55
+
56
+ See the [Functions guide](/docs/guide/functions/), [frontend invocation walkthrough](/docs/guide/functions/invoking-from-frontend), and [type generation guide](/docs/guide/functions/typegen) for how-to instructions.
57
+
58
+ ## License
59
+
60
+ Copyright (c) Microsoft Corporation. Licensed under the MIT License.
@@ -7,7 +7,8 @@
7
7
  */
8
8
  import { ApiClient } from '@microsoft/rayfin-lib';
9
9
  /**
10
- * Response from a function invocation.
10
+ * Transport response from a function invocation.
11
+ * `FunctionClient.invoke()` returns the output value, not this envelope.
11
12
  */
12
13
  export interface FunctionInvocationResponse<TOutput = any> {
13
14
  /** The name of the function that was invoked. */
@@ -75,10 +76,8 @@ export declare class FunctionClient<TInput = any, TOutput = any> {
75
76
  *
76
77
  * Failure modes throw — a non-empty `errors` array or a non-success
77
78
  * status on the wire response is surfaced as {@link FunctionsError}.
78
- * Network and unknown errors are wrapped in {@link NetworkError} and
79
- * {@link FunctionsError} respectively. By the time this method
80
- * resolves, the caller can use the value without defending against
81
- * `undefined`.
79
+ * Network and other SDK errors propagate unchanged.
80
+ * Unexpected errors are wrapped in {@link FunctionsError}.
82
81
  *
83
82
  * The server-side `invocationId` from the underlying envelope is
84
83
  * emitted via `console.debug` (along with the function name) so the
@@ -55,10 +55,8 @@ export class FunctionClient {
55
55
  *
56
56
  * Failure modes throw — a non-empty `errors` array or a non-success
57
57
  * status on the wire response is surfaced as {@link FunctionsError}.
58
- * Network and unknown errors are wrapped in {@link NetworkError} and
59
- * {@link FunctionsError} respectively. By the time this method
60
- * resolves, the caller can use the value without defending against
61
- * `undefined`.
58
+ * Network and other SDK errors propagate unchanged.
59
+ * Unexpected errors are wrapped in {@link FunctionsError}.
62
60
  *
63
61
  * The server-side `invocationId` from the underlying envelope is
64
62
  * emitted via `console.debug` (along with the function name) so the
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Maps function names to their input/output type pairs.
3
3
  *
4
- * Users define a concrete type that `satisfies FunctionsSchema` in their
5
- * `rayfin/functions/src/types.ts` file, then pass it as the third type
4
+ * Users define a concrete schema type in their
5
+ * `rayfin/functions/src/types.ts` file, then pass it as the second type
6
6
  * parameter of `RayfinClient` so that `client.functions.<name>.invoke()`
7
7
  * calls are fully type-checked.
8
8
  *
@@ -10,13 +10,11 @@
10
10
  *
11
11
  * @example
12
12
  * ```typescript
13
- * import type { FunctionsSchema } from '@microsoft/rayfin-functions';
14
- *
15
13
  * export type MyFunctionsSchema = {
16
14
  * helloWorld: { input: { firstName: string; lastName: string }; output: string };
17
15
  * add: { input: { a: number; b: number }; output: number };
18
16
  * noParams: { input: void; output: string }; // use void or {} for no-input functions
19
- * } satisfies FunctionsSchema;
17
+ * };
20
18
  * ```
21
19
  */
22
20
  export type FunctionsSchema = Record<string, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/rayfin-functions",
3
- "version": "1.36.0-alpha.1675",
3
+ "version": "1.36.0-alpha.1756",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -8,8 +8,15 @@
8
8
  "dist/**/*.js",
9
9
  "dist/**/*.d.ts",
10
10
  "!dist/**/__tests__/**",
11
- "LICENSE"
11
+ "LICENSE",
12
+ "assets/docs"
12
13
  ],
14
+ "rayfinDocs": {
15
+ "version": 1,
16
+ "dir": "assets/docs",
17
+ "module": "rayfin-functions",
18
+ "kind": "api-reference"
19
+ },
13
20
  "devDependencies": {
14
21
  "eslint": "^9.28.0",
15
22
  "prettier": "^3.5.3",
@@ -19,7 +26,7 @@
19
26
  "rimraf": "~6.0.1"
20
27
  },
21
28
  "dependencies": {
22
- "@microsoft/rayfin-lib": "1.36.0-alpha.1675"
29
+ "@microsoft/rayfin-lib": "1.36.0-alpha.1756"
23
30
  },
24
31
  "publishConfig": {
25
32
  "registry": "https://npm.pkg.github.com",