Skip to content

Commit 81b71ab

Browse files
authored
update js sdk doc links (#1477)
Signed-off-by: karthik2804 <karthik.ganeshram@fermyon.com>
1 parent 78a978e commit 81b71ab

20 files changed

+60
-54
lines changed

content/spin/v2/http-trigger.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,11 @@ For a full Rust SDK reference, see the [Rust Spin SDK documentation](https://doc
265265

266266
{{ startTab "TypeScript"}}
267267

268-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
268+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)
269269
270270
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`.
271271

272-
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)
272+
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)
273273

274274
```ts
275275
import { ResponseBuilder } from "@fermyon/spin-sdk";

content/spin/v2/javascript-components.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ With JavaScript being a very popular language, Spin provides an SDK to support b
3131
3232
> 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).
3333
34-
[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
34+
[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)
3535

3636
## Installing Templates
3737

content/spin/v2/kv-store-api-guide.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ fn handle_request(_req: Request) -> Result<impl IntoResponse> {
8383

8484
{{ startTab "Typescript"}}
8585

86-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
86+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)
8787
88-
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:
88+
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:
8989

9090
```ts
9191
import { ResponseBuilder , Kv} from "@fermyon/spin-sdk";
@@ -102,14 +102,14 @@ export async function handler(req: Request, res: ResponseBuilder) {
102102
**General Notes**
103103
- 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.
104104

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

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

112-
[`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)
112+
[`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)
113113
- 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.
114114

115115
{{ blockEnd }}

content/spin/v2/language-support-overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ This page contains information about language support for Spin features:
3737

3838
{{ startTab "TypeScript"}}
3939

40-
**[📄 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.**
40+
**[📄 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.**
4141

4242
| Feature | SDK Supported? |
4343
|-----|-----|

content/spin/v2/mqtt-outbound.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ You can find a complete Rust code example for using outbound MQTT from an HTTP c
5757

5858
{{ startTab "TypeScript"}}
5959

60-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Mqtt.html)
60+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Mqtt.html)
6161
6262
To access an MQTT server, use the `Mqtt.open` function.
6363

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

75-
For full details of the MQTT API, see the [Spin SDK reference documentation](https://spinframework.github.io/spin-js-sdk/modules/Mqtt.html)
75+
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)
7676

7777
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).
7878

content/spin/v2/rdbms-storage.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ For full information about the MySQL and PostgreSQL APIs, see [the Spin SDK refe
7171

7272
{{ startTab "TypeScript"}}
7373

74-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
74+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)
7575
7676
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.
7777

content/spin/v2/redis-outbound.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ You can find a complete Rust code example for using outbound Redis from an HTTP
8989

9090
{{ startTab "TypeScript"}}
9191

92-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
92+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/)
9393
94-
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:
94+
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:
9595

9696
```javascript
9797
import { Redis } from "@fermyon/spin-sdk"

content/spin/v2/serverless-ai-api-guide.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,9 @@ The `infer_with_options` examples, operation:
112112

113113
{{ startTab "Typescript"}}
114114

115-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Llm.html)
115+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Llm.html)
116116
117-
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:
117+
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:
118118

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

136136
- It takes in the following arguments - model name, prompt and a optional third parameter for inferencing options.
137-
- 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).
138-
- 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`.
139-
- The return value is an [`InferenceResult`](https://spinframework.github.io/spin-js-sdk/interfaces/Llm.EmbeddingResult.html).
137+
- 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).
138+
- 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`.
139+
- The return value is an [`InferenceResult`](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Llm.EmbeddingResult.html).
140140

141141
`generateEmbeddings` operation:
142142

143143
- It takes two arguments - model name and list of strings to generate the embeddings for.
144-
- 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).
145-
- The return value is an [`EmbeddingResult`](https://spinframework.github.io/spin-js-sdk/interfaces/Llm.EmbeddingResult.html)
144+
- 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).
145+
- The return value is an [`EmbeddingResult`](https://spinframework.github.io/spin-js-sdk/v2.3/interfaces/Llm.EmbeddingResult.html)
146146

147147
{{ blockEnd }}
148148

content/spin/v2/sqlite-api-guide.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,9 @@ struct ToDo {
120120

121121
{{ startTab "Typescript"}}
122122

123-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Sqlite.html)
123+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Sqlite.html)
124124
125-
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:
125+
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:
126126

127127
```javascript
128128
import { ResponseBuilder, Sqlite } from "@fermyon/spin-sdk";

content/spin/v2/variables.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ async fn handle_api_call_with_token(_req: Request) -> anyhow::Result<impl IntoRe
133133

134134
{{ startTab "TypeScript"}}
135135

136-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Variables.html)
136+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/v2.3/modules/Variables.html)
137137
138138
```ts
139139
import { ResponseBuilder, Variables } from "@fermyon/spin-sdk";

content/spin/v3/http-trigger.md

+14-8
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,25 @@ For a full Rust SDK reference, see the [Rust Spin SDK documentation](https://doc
256256

257257
{{ startTab "TypeScript"}}
258258

259-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
259+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)
260260
261-
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`.
261+
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.
262262

263-
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)
263+
Below is a complete implementation for such a component in TypeScript:
264264

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

268-
export async function handler(req: Request, res: ResponseBuilder) {
269-
console.log(req);
270-
res.send("hello universe");
271-
}
268+
let router = AutoRouter();
269+
270+
router
271+
.get("/", () => new Response("hello universe"))
272+
.get('/hello/:name', ({ name }) => `Hello, ${name}!`)
273+
274+
//@ts-ignore
275+
addEventListener('fetch', async (event: FetchEvent) => {
276+
event.respondWith(router.fetch(event.request));
277+
});
272278
```
273279

274280
{{ blockEnd }}

content/spin/v3/javascript-components.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ With JavaScript being a very popular language, Spin provides an SDK to support b
3030
3131
> 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).
3232
33-
[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
33+
[**Want to go straight to the Spin SDK reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)
3434

3535
## Installing Templates
3636

content/spin/v3/kv-store-api-guide.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ fn handle_request(_req: Request) -> Result<impl IntoResponse> {
8383

8484
{{ startTab "Typescript"}}
8585

86-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
86+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)
8787
88-
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:
88+
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:
8989

9090
```ts
9191
import { AutoRouter } from 'itty-router';
@@ -109,14 +109,14 @@ addEventListener('fetch', async (event: FetchEvent) => {
109109
**General Notes**
110110
- 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.
111111

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

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

119-
[`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)
119+
[`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)
120120
- 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.
121121

122122
{{ blockEnd }}

content/spin/v3/language-support-overview.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ This page contains information about language support for Spin features:
3737

3838
{{ startTab "TypeScript"}}
3939

40-
**[📄 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.**
40+
**[📄 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.**
4141

4242
| Feature | SDK Supported? |
4343
|-----|-----|

content/spin/v3/mqtt-outbound.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ You can find a complete Rust code example for using outbound MQTT from an HTTP c
5757

5858
{{ startTab "TypeScript"}}
5959

60-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/modules/Mqtt.html)
60+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/modules/Mqtt.html)
6161
6262
To access an MQTT server, use the `Mqtt.open` function.
6363

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

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

7777
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).
7878

content/spin/v3/rdbms-storage.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ For full information about the MySQL and PostgreSQL APIs, see [the Spin SDK refe
7373

7474
{{ startTab "TypeScript"}}
7575

76-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
76+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)
7777
7878
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.
7979

content/spin/v3/redis-outbound.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ You can find a complete Rust code example for using outbound Redis from an HTTP
8989

9090
{{ startTab "TypeScript"}}
9191

92-
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/)
92+
> [**Want to go straight to the reference documentation?** Find it here.](https://spinframework.github.io/spin-js-sdk/stable/)
9393
94-
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:
94+
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:
9595

9696
```javascript
9797
import { Redis } from "@fermyon/spin-sdk"

0 commit comments

Comments
 (0)