Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update js sdk doc links #1477

Merged
merged 1 commit into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions content/spin/v2/http-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ For a full Rust SDK reference, see the [Rust Spin SDK documentation](https://doc

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)

The user must a define a function named `handler` which the SDK attaches to the [`FetchEvent` listener](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent). Note that the incoming HTTP event is translated to a `FetchEvent`.

The handler function takes in two arguments a [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and a [ResponseBuilder](https://spinframework.github.io/spin-js-sdk/classes/ResponseBuilder.html)
The handler function takes in two arguments a [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and a [ResponseBuilder](https://spinframework.github.io/spin-js-sdk/v2.3/classes/ResponseBuilder.html)

```ts
import { ResponseBuilder } from "@fermyon/spin-sdk";
Expand Down
2 changes: 1 addition & 1 deletion content/spin/v2/javascript-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ With JavaScript being a very popular language, Spin provides an SDK to support b

> All examples from this page can be found in [the JavaScript SDK repository on GitHub](https://github.com/spinframework/spin-js-sdk/tree/sdk-v2/examples).

[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)

## Installing Templates

Expand Down
10 changes: 5 additions & 5 deletions content/spin/v2/kv-store-api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ fn handle_request(_req: Request) -> Result<impl IntoResponse> {

{{ startTab "Typescript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)

The key value functions can be accessed after opening a store using either [the `Kv.open` or the `Kv.openDefault` methods](https://spinframework.github.io/spin-js-sdk/modules/Kv.html) which returns a [handle to the store](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html). For example:
The key value functions can be accessed after opening a store using either [the `Kv.open` or the `Kv.openDefault` methods](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Kv.html) which returns a [handle to the store](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Kv.Store.html). For example:

```ts
import { ResponseBuilder , Kv} from "@fermyon/spin-sdk";
Expand All @@ -102,14 +102,14 @@ export async function handler(req: Request, res: ResponseBuilder) {
**General Notes**
- The SDK doesn't surface the `close` operation. It automatically closes all stores at the end of the request; there's no way to close them early.

[`get` **Operation**](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html#get)
[`get` **Operation**](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Kv.Store.html#get)
- The result is of the type `Uint8Array | null`
- If the key does not exist, `get` returns `null`

[`set` **Operation**](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html#set)
[`set` **Operation**](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Kv.Store.html#set)
- The value argument is of the type `Uint8Array | string | object`.

[`setJson`](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html#setJson) and [`getJson` **Operation**](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html#getJson)
[`setJson`](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Kv.Store.html#setJson) and [`getJson` **Operation**](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Kv.Store.html#getJson)
- Applications can store JavaScript objects using `setJson`; these are serialized within the store as JSON. These serialized objects can be retrieved and deserialized using `getJson`. If you call `getJson` on a key that doesn't exist then it returns an empty object.

{{ blockEnd }}
Expand Down
2 changes: 1 addition & 1 deletion content/spin/v2/language-support-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This page contains information about language support for Spin features:

{{ startTab "TypeScript"}}

**[📄 Visit the JS/TS Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/) to see specific modules, functions, variables and syntax relating to the following TS/JS features.**
**[📄 Visit the JS/TS Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/v2.3/) to see specific modules, functions, variables and syntax relating to the following TS/JS features.**

| Feature | SDK Supported? |
|-----|-----|
Expand Down
4 changes: 2 additions & 2 deletions content/spin/v2/mqtt-outbound.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can find a complete Rust code example for using outbound MQTT from an HTTP c

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Mqtt.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Mqtt.html)

To access an MQTT server, use the `Mqtt.open` function.

Expand All @@ -72,7 +72,7 @@ let catPicture = new Uint8Array(await req.arraybuffer());
connection.publish("pets", catPicture, QoS.AtleastOnce);
```

For full details of the MQTT API, see the [Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/modules/Mqtt.html)
For full details of the MQTT API, see the [Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Mqtt.html)

You can find a complete Rust code example for using outbound MQTT from an HTTP component in the [Spin Rust SDK repository on GitHub](https://github.com/spinframework/spin-js-sdk/tree/sdk-v2/examples/spin-host-apis/spin-mqtt).

Expand Down
2 changes: 1 addition & 1 deletion content/spin/v2/rdbms-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ For full information about the MySQL and PostgreSQL APIs, see [the Spin SDK refe

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)

The code below is an [Outbound MySQL example](https://github.com/spinframework/spin-js-sdk/tree/sdk-v2/examples/spin-host-apis/spin-mysql). There is also an outbound [PostgreSQL example](https://github.com/spinframework/spin-js-sdk/tree/sdk-v2/examples/spin-host-apis/spin-postgres) available.

Expand Down
4 changes: 2 additions & 2 deletions content/spin/v2/redis-outbound.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ You can find a complete Rust code example for using outbound Redis from an HTTP

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)

Redis functions are available on [the `Redis` module](https://spinframework.github.io/spin-js-sdk/modules/Redis.html). The function names match the operations above. For example:
Redis functions are available on [the `Redis` module](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Redis.html). The function names match the operations above. For example:

```javascript
import { Redis } from "@fermyon/spin-sdk"
Expand Down
14 changes: 7 additions & 7 deletions content/spin/v2/serverless-ai-api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,9 @@ The `infer_with_options` examples, operation:

{{ startTab "Typescript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Llm.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Llm.html)

To use Serverless AI functions, [the `Llm` module](https://spinframework.github.io/spin-js-sdk/modules/Llm.html) from the Spin SDK provides two methods: `infer` and `generateEmbeddings`. For example:
To use Serverless AI functions, [the `Llm` module](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Llm.html) from the Spin SDK provides two methods: `infer` and `generateEmbeddings`. For example:

```javascript
import { ResponseBuilder, Llm} from "@fermyon/spin-sdk"
Expand All @@ -134,15 +134,15 @@ export async function handler(req: Request, res: ResponseBuilder) {
`infer` operation:

- It takes in the following arguments - model name, prompt and a optional third parameter for inferencing options.
- The model name is a string. There are enums for the inbuilt models (llama2-chat and codellama) in [`InferencingModels`](https://spinframework.github.io/spin-js-sdk/enums/Llm.InferencingModels.html).
- The optional third parameter which is an [InferencingOptions](https://spinframework.github.io/spin-js-sdk/interfaces/Llm.InferencingOptions.html) interface allows you to specify parameters such as `maxTokens`, `repeatPenalty`, `repeatPenaltyLastNTokenCount`, `temperature`, `topK`, `topP`.
- The return value is an [`InferenceResult`](https://spinframework.github.io/spin-js-sdk/interfaces/Llm.EmbeddingResult.html).
- The model name is a string. There are enums for the inbuilt models (llama2-chat and codellama) in [`InferencingModels`](https://spinframework.github.io/spin-js-sdk/v2.3/enums/Llm.InferencingModels.html).
- The optional third parameter which is an [InferencingOptions](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Llm.InferencingOptions.html) interface allows you to specify parameters such as `maxTokens`, `repeatPenalty`, `repeatPenaltyLastNTokenCount`, `temperature`, `topK`, `topP`.
- The return value is an [`InferenceResult`](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Llm.EmbeddingResult.html).

`generateEmbeddings` operation:

- It takes two arguments - model name and list of strings to generate the embeddings for.
- The model name is a string. There are enums for the inbuilt models (AllMiniLmL6V2) in [`EmbeddingModels`](https://spinframework.github.io/spin-js-sdk/enums/Llm.EmbeddingModels.html).
- The return value is an [`EmbeddingResult`](https://spinframework.github.io/spin-js-sdk/interfaces/Llm.EmbeddingResult.html)
- The model name is a string. There are enums for the inbuilt models (AllMiniLmL6V2) in [`EmbeddingModels`](https://spinframework.github.io/spin-js-sdk/v2.3/enums/Llm.EmbeddingModels.html).
- The return value is an [`EmbeddingResult`](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Llm.EmbeddingResult.html)

{{ blockEnd }}

Expand Down
4 changes: 2 additions & 2 deletions content/spin/v2/sqlite-api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,9 @@ struct ToDo {

{{ startTab "Typescript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Sqlite.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Sqlite.html)

To use SQLite functions, use [the `Sqlite.open` or `Sqlite.openDefault` function](https://spinframework.github.io/spin-js-sdk/modules/Sqlite.html) to obtain [a `SqliteConnection` object](https://spinframework.github.io/spin-js-sdk/interfaces/Sqlite.SqliteConnection.html). `SqliteConnection` provides the `execute` method as described above. For example:
To use SQLite functions, use [the `Sqlite.open` or `Sqlite.openDefault` function](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Sqlite.html) to obtain [a `SqliteConnection` object](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Sqlite.SqliteConnection.html). `SqliteConnection` provides the `execute` method as described above. For example:

```javascript
import { ResponseBuilder, Sqlite } from "@fermyon/spin-sdk";
Expand Down
2 changes: 1 addition & 1 deletion content/spin/v2/variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ async fn handle_api_call_with_token(_req: Request) -> anyhow::Result<impl IntoRe

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Variables.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Variables.html)

```ts
import { ResponseBuilder, Variables } from "@fermyon/spin-sdk";
Expand Down
22 changes: 14 additions & 8 deletions content/spin/v3/http-trigger.md
Original file line number Diff line number Diff line change
Expand Up @@ -256,19 +256,25 @@ For a full Rust SDK reference, see the [Rust Spin SDK documentation](https://doc

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)

The user must a define a function named `handler` which the SDK attaches to the [`FetchEvent` listener](https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent). Note that the incoming HTTP event is translated to a `FetchEvent`.
Building a Spin HTTP component with the JavaScript/TypeScript SDK now involves adding an event listener for the `fetch` event. This event listener handles incoming HTTP requests and allows you to construct and return HTTP responses.

The handler function takes in two arguments a [Request](https://developer.mozilla.org/en-US/docs/Web/API/Request) and a [ResponseBuilder](https://spinframework.github.io/spin-js-sdk/classes/ResponseBuilder.html)
Below is a complete implementation for such a component in TypeScript:

```ts
import { ResponseBuilder } from "@fermyon/spin-sdk";
import { AutoRouter } from 'itty-router';

export async function handler(req: Request, res: ResponseBuilder) {
console.log(req);
res.send("hello universe");
}
let router = AutoRouter();

router
.get("/", () => new Response("hello universe"))
.get('/hello/:name', ({ name }) => `Hello, ${name}!`)

//@ts-ignore
addEventListener('fetch', async (event: FetchEvent) => {
event.respondWith(router.fetch(event.request));
});
```

{{ blockEnd }}
Expand Down
2 changes: 1 addition & 1 deletion content/spin/v3/javascript-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ With JavaScript being a very popular language, Spin provides an SDK to support b

> All examples from this page can be found in [the JavaScript SDK repository on GitHub](https://github.com/spinframework/spin-js-sdk/tree/main/examples).

[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)

## Installing Templates

Expand Down
10 changes: 5 additions & 5 deletions content/spin/v3/kv-store-api-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ fn handle_request(_req: Request) -> Result<impl IntoResponse> {

{{ startTab "Typescript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)

The key value functions can be accessed after opening a store using either [the `Kv.open` or the `Kv.openDefault` methods](https://spinframework.github.io/spin-js-sdk/modules/Kv.html) which returns a [handle to the store](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html). For example:
The key value functions can be accessed after opening a store using either [the `Kv.open` or the `Kv.openDefault` methods](https://spinframework.github.io/spin-js-sdk/stable/modules/Kv.html) which returns a [handle to the store](https://spinframework.github.io/spin-js-sdk/stable/interfaces/Kv.Store.html). For example:

```ts
import { AutoRouter } from 'itty-router';
Expand All @@ -109,14 +109,14 @@ addEventListener('fetch', async (event: FetchEvent) => {
**General Notes**
- The SDK doesn't surface the `close` operation. It automatically closes all stores at the end of the request; there's no way to close them early.

[`get` **Operation**](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html#get)
[`get` **Operation**](https://spinframework.github.io/spin-js-sdk/stable/interfaces/Kv.Store.html#get)
- The result is of the type `Uint8Array | null`
- If the key does not exist, `get` returns `null`

[`set` **Operation**](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html#set)
[`set` **Operation**](https://spinframework.github.io/spin-js-sdk/stable/interfaces/Kv.Store.html#set)
- The value argument is of the type `Uint8Array | string | object`.

[`setJson`](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html#setJson) and [`getJson` **Operation**](https://spinframework.github.io/spin-js-sdk/interfaces/Kv.Store.html#getJson)
[`setJson`](https://spinframework.github.io/spin-js-sdk/stable/interfaces/Kv.Store.html#setJson) and [`getJson` **Operation**](https://spinframework.github.io/spin-js-sdk/stable/interfaces/Kv.Store.html#getJson)
- Applications can store JavaScript objects using `setJson`; these are serialized within the store as JSON. These serialized objects can be retrieved and deserialized using `getJson`. If you call `getJson` on a key that doesn't exist then it returns an empty object.

{{ blockEnd }}
Expand Down
2 changes: 1 addition & 1 deletion content/spin/v3/language-support-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This page contains information about language support for Spin features:

{{ startTab "TypeScript"}}

**[📄 Visit the JS/TS Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/) to see specific modules, functions, variables and syntax relating to the following TS/JS features.**
**[📄 Visit the JS/TS Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/stable/) to see specific modules, functions, variables and syntax relating to the following TS/JS features.**

| Feature | SDK Supported? |
|-----|-----|
Expand Down
4 changes: 2 additions & 2 deletions content/spin/v3/mqtt-outbound.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ You can find a complete Rust code example for using outbound MQTT from an HTTP c

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Mqtt.html)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/modules/Mqtt.html)

To access an MQTT server, use the `Mqtt.open` function.

Expand All @@ -72,7 +72,7 @@ let catPicture = new Uint8Array(await req.arraybuffer());
connection.publish("pets", catPicture, QoS.AtleastOnce);
```

For full details of the MQTT API, see the [Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/modules/Mqtt.html)
For full details of the MQTT API, see the [Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/stable/modules/Mqtt.html)

You can find a complete Rust code example for using outbound MQTT from an HTTP component in the [Spin Rust SDK repository on GitHub](https://github.com/spinframework/spin-js-sdk/tree/main/examples/spin-host-apis/spin-mqtt).

Expand Down
2 changes: 1 addition & 1 deletion content/spin/v3/rdbms-storage.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ For full information about the MySQL and PostgreSQL APIs, see [the Spin SDK refe

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)

The code below is an [Outbound MySQL example](https://github.com/spinframework/spin-js-sdk/tree/main/examples/spin-host-apis/spin-mysql). There is also an outbound [PostgreSQL example](https://github.com/spinframework/spin-js-sdk/tree/main/examples/spin-host-apis/spin-postgres) available.

Expand Down
4 changes: 2 additions & 2 deletions content/spin/v3/redis-outbound.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ You can find a complete Rust code example for using outbound Redis from an HTTP

{{ startTab "TypeScript"}}

> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)

Redis functions are available on [the `Redis` module](https://spinframework.github.io/spin-js-sdk/modules/Redis.html). The function names match the operations above. For example:
Redis functions are available on [the `Redis` module](https://spinframework.github.io/spin-js-sdk/stable/modules/Redis.html). The function names match the operations above. For example:

```javascript
import { Redis } from "@fermyon/spin-sdk"
Expand Down
Loading