@restatedev/restate-sdk-zod 1.7.0 → 1.7.2

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.
Files changed (2) hide show
  1. package/README.md +29 -31
  2. package/package.json +2 -2
package/README.md CHANGED
@@ -3,30 +3,43 @@
3
3
  [![Discord](https://img.shields.io/discord/1128210118216007792?logo=discord)](https://discord.gg/skW3AZ6uGd)
4
4
  [![Twitter](https://img.shields.io/twitter/follow/restatedev.svg?style=social&label=Follow)](https://twitter.com/intent/follow?screen_name=restatedev)
5
5
 
6
- # Restate Typescript SDK
6
+ # Restate Typescript SDK Zod integration
7
7
 
8
- [Restate](https://restate.dev/) is a system for easily building resilient applications using *distributed durable async/await*. This repository contains the Restate SDK for writing services in **Node.js / Typescript**.
8
+ [Restate](https://restate.dev/) is a system for easily building resilient applications using *distributed durable async/await*.
9
9
 
10
- Restate applications are composed of *durably executed, stateful RPC handlers* that can run either
11
- as part of long-running processes, or as FaaS (AWS Lambda).
10
+ This package contains a zod integration, allowing to define input/output models of your handlers.
12
11
 
13
12
  ```typescript
14
13
  import * as restate from "@restatedev/restate-sdk";
14
+ import { serde } from "@restatedev/restate-sdk-zod";
15
+ import { z } from "zod";
16
+
17
+ const Greeting = z.object({
18
+ name: z.string(),
19
+ });
15
20
 
16
21
  const greeter = restate.service({
17
- name: "greeter",
18
- handlers: {
19
- greet: async (ctx: restate.Context, name: string) => {
20
- return `Hello ${name}!`;
21
- },
22
- },
22
+ name: "greeter",
23
+ handlers: {
24
+ greet: restate.handlers.handler(
25
+ {
26
+ input: serde.zod(Greeting),
27
+ output: serde.zod(z.string()),
28
+ },
29
+ async (ctx, greeting) => {
30
+ return `Hello ${greeting.name}!`;
31
+ }
32
+ ),
33
+ },
23
34
  });
24
35
 
25
- restate.endpoint()
26
- .bind(greeter)
27
- .listen(9080);
36
+ export type Greeter = typeof greeter;
37
+
38
+ restate.endpoint().bind(greeter).listen();
28
39
  ```
29
40
 
41
+ For the SDK main package, checkout https://www.npmjs.com/package/@restatedev/restate-sdk.
42
+
30
43
  ## Community
31
44
 
32
45
  * 🤗️ [Join our online community](https://discord.gg/skW3AZ6uGd) for help, sharing feedback and talking to the community.
@@ -35,29 +48,14 @@ restate.endpoint()
35
48
  * 🙋 [Create a GitHub issue](https://github.com/restatedev/sdk-typescript/issues) for requesting a new feature or reporting a problem.
36
49
  * 🏠 [Visit our GitHub org](https://github.com/restatedev) for exploring other repositories.
37
50
 
38
- ## Using the SDK
51
+ ## Using the library
39
52
 
40
- To use this SDK, add the dependency to your project:
41
- ```shell
42
- npm install @restatedev/restate-sdk
43
- ```
53
+ To use this library, add the dependency to your project:
44
54
 
45
- For brand-new projects, we recommend using the [Restate Node Template](https://github.com/restatedev/node-template-generator):
46
55
  ```shell
47
- npx -y @restatedev/create-app@latest
56
+ npm install --save-dev @restatedev/restate-sdk-zod
48
57
  ```
49
58
 
50
59
  ## Versions
51
60
 
52
61
  This library follows [Semantic Versioning](https://semver.org/).
53
-
54
- The compatibility with Restate is described in the following table:
55
-
56
- | Restate Server\sdk-typescript | 1.0/1.1/1.2/1.3 | 1.4 | 1.5 |
57
- |-------------------------------|------------------|-----|-----|
58
- | 1.0 | ✅ | ❌ | ❌ |
59
- | 1.1 | ✅ <sup>(1)</sup> | ✅ | ❌ |
60
- | 1.2 | ✅ | ✅ | ❌ |
61
- | 1.3 | ✅ | ✅ | ✅ |
62
-
63
- <sup>(1)</sup> **Only** when upgrading from 1.0 to 1.1 you MUST rediscover all the existing deployments using `restate dp register <address> --force`. You don't need to update the SDK, nor change the code.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@restatedev/restate-sdk-zod",
3
- "version": "1.7.0",
3
+ "version": "1.7.2",
4
4
  "description": "Restate Typescript SDK Zod",
5
5
  "author": "Restate Developers",
6
6
  "license": "MIT",
@@ -34,7 +34,7 @@
34
34
  "dist"
35
35
  ],
36
36
  "devDependencies": {
37
- "@restatedev/restate-sdk-core": "^1.7.0"
37
+ "@restatedev/restate-sdk-core": "^1.7.2"
38
38
  },
39
39
  "dependencies": {
40
40
  "zod": "^3.24.1",