Skip to content

Commit 355ee59

Browse files
Bump typescript sdk
1 parent b34721d commit 355ee59

File tree

41 files changed

+706
-728
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+706
-728
lines changed

.tools/update_node_examples.sh

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ SELF_PATH=${BASH_SOURCE[0]:-"$(command -v -- "$0")"}
77
PROJECT_ROOT="$(dirname "$SELF_PATH")/.."
88

99
function bump_restate_sdk_deps() {
10+
pushd $1
1011
local project_dir=$1
11-
local package_json="$project_dir/package.json"
12+
local package_json="./package.json"
1213

1314
# Check if package.json exists
1415
if [ ! -f "$package_json" ]; then
@@ -28,18 +29,19 @@ function bump_restate_sdk_deps() {
2829
# Install each dependency with the new version
2930
for dep in $deps; do
3031
echo "Installing $dep@^$NEW_VERSION in $project_dir"
31-
npm --prefix $project_dir install $dep@^$NEW_VERSION
32+
npm install $dep@^$NEW_VERSION
3233
done
3334

3435
# If this is a template directory and has existing agents documentation, update it
35-
if [[ "$project_dir" == *"/templates/"* ]] && [ -f "$project_dir/.cursor/rules/AGENTS.md" ]; then
36+
if [[ "$project_dir" == *"/templates/"* ]] && [ -f "./.cursor/rules/AGENTS.md" ]; then
3637
echo "Updating agents documentation for template in $project_dir"
37-
wget -O "$project_dir/.cursor/rules/AGENTS.md" https://docs.restate.dev/develop/ts/agents.md
38+
wget -O "./.cursor/rules/AGENTS.md" https://docs.restate.dev/develop/ts/agents.md
3839
fi
39-
if [[ "$project_dir" == *"/templates/"* ]] && [ -f "$project_dir/.claude/CLAUDE.md" ]; then
40+
if [[ "$project_dir" == *"/templates/"* ]] && [ -f "./.claude/CLAUDE.md" ]; then
4041
echo "Updating agents documentation for template in $project_dir"
41-
wget -O "$project_dir/.claude/CLAUDE.md" https://docs.restate.dev/develop/ts/agents.md
42+
wget -O "./.claude/CLAUDE.md" https://docs.restate.dev/develop/ts/agents.md
4243
fi
44+
popd
4345
}
4446

4547
# Update all projects with package.json

typescript/basics/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
"example-3": "ts-node-dev --transpile-only src/3_workflows.ts"
1515
},
1616
"dependencies": {
17-
"@restatedev/restate-sdk": "^1.9.1",
18-
"@restatedev/restate-sdk-clients": "^1.9.1"
17+
"@restatedev/restate-sdk": "^1.10.0",
18+
"@restatedev/restate-sdk-clients": "^1.10.0"
1919
},
2020
"devDependencies": {
2121
"@types/node": "^20.12.12",

typescript/end-to-end-applications/ai-image-workflows/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"stable-diffusion-service": "ts-node-dev --watch ./src --respawn --transpile-only src/stable_diffusion.ts"
1313
},
1414
"dependencies": {
15-
"@restatedev/restate-sdk": "^1.9.1",
15+
"@restatedev/restate-sdk": "^1.10.0",
1616
"axios": "^1.6.7",
1717
"axios-retry": "^4.0.0",
1818
"jimp": "^0.22.10",

typescript/end-to-end-applications/chat-bot/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"flights-task": "RESTATE_LOGGING=INFO ts-node-dev --watch ./src --transpile-only ./src/tasks/flight_prices.ts"
1212
},
1313
"dependencies": {
14-
"@restatedev/restate-sdk": "^1.9.1",
14+
"@restatedev/restate-sdk": "^1.10.0",
1515
"@slack/bolt": "^3.19.0",
1616
"@slack/web-api": "^7.0.4"
1717
},

typescript/end-to-end-applications/food-ordering/app/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"dev": "RESTATE_DEBUG_LOGGING=JOURNAL ts-node-dev --watch src --respawn --transpile-only src/order-app/app.ts"
1717
},
1818
"dependencies": {
19-
"@restatedev/restate-sdk": "^1.9.1",
19+
"@restatedev/restate-sdk": "^1.10.0",
2020
"@types/node": "^20.6.3",
2121
"@types/uuid": "^9.0.0",
2222
"axios": "^1.4.0",

typescript/end-to-end-applications/food-ordering/webui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"node": "14.17.3"
77
},
88
"dependencies": {
9-
"@restatedev/restate-sdk-clients": "^1.9.1",
9+
"@restatedev/restate-sdk-clients": "^1.10.0",
1010
"axios": "^0.26.0",
1111
"react": "^18.0.0",
1212
"react-dom": "^18.0.0",

typescript/integrations/deployment-lambda-cdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"typescript": "^5.5.4"
2424
},
2525
"dependencies": {
26-
"@restatedev/restate-sdk": "^1.9.1",
26+
"@restatedev/restate-sdk": "^1.10.0",
2727
"aws-cdk-lib": "^2.155.0",
2828
"constructs": "^10.3.0",
2929
"source-map-support": "^0.5.21"

typescript/patterns-use-cases/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
"format": "prettier --ignore-path .eslintignore --write \"**/*.+(js|ts|json)\""
1010
},
1111
"dependencies": {
12-
"@restatedev/restate-sdk": "^1.9.1",
13-
"@restatedev/restate-sdk-clients": "^1.9.1",
12+
"@restatedev/restate-sdk": "^1.10.0",
13+
"@restatedev/restate-sdk-clients": "^1.10.0",
1414
"cron-parser": "^5.2.0",
1515
"express": "^5.0.0",
1616
"pg": "^8.10.0",

typescript/templates/bun/.claude/CLAUDE.md

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,9 @@ ctx.workflowSendClient(myWorkflow, "wf-id").run("Hi");
119119
#### Delayed Messages
120120

121121
```ts {"CODE_LOAD::ts/src/develop/agentsmd/agentsmd-actions.ts#delayed_messages"} theme={null}
122-
ctx.serviceSendClient(myService).myHandler(
123-
"Hi",
124-
restate.rpc.sendOpts({ delay: { hours: 5 } })
125-
);
122+
ctx
123+
.serviceSendClient(myService)
124+
.myHandler("Hi", restate.rpc.sendOpts({ delay: { hours: 5 } }));
126125
```
127126

128127
#### Generic Calls
@@ -169,17 +168,16 @@ const result = await ctx.run("my-side-effect", async () => {
169168
await ctx.sleep({ seconds: 30 });
170169

171170
// Schedule delayed call (different from sleep + send)
172-
ctx.serviceSendClient(myService).myHandler(
173-
"Hi",
174-
restate.rpc.sendOpts({ delay: { hours: 5 } })
175-
);
171+
ctx
172+
.serviceSendClient(myService)
173+
.myHandler("Hi", restate.rpc.sendOpts({ delay: { hours: 5 } }));
176174
```
177175

178176
### Awakeables (External Events)
179177

180178
```ts {"CODE_LOAD::ts/src/develop/agentsmd/agentsmd-actions.ts#awakeables"} theme={null}
181179
// Create awakeable
182-
const {id, promise} = ctx.awakeable<string>();
180+
const { id, promise } = ctx.awakeable<string>();
183181

184182
// Send ID to external system
185183
await ctx.run(() => requestHumanReview(name, id));
@@ -248,7 +246,7 @@ const result1 = await Promise.any([call1, call2]);
248246
// ✅ GOOD
249247
const result2 = await RestatePromise.any([
250248
ctx.run(() => callLLM("gpt-4", prompt)),
251-
ctx.run(() => callLLM("claude", prompt))
249+
ctx.run(() => callLLM("claude", prompt)),
252250
]);
253251
```
254252

@@ -263,7 +261,7 @@ const results1 = await Promise.allSettled([call1, call2]);
263261
// ✅ GOOD
264262
const results2 = await RestatePromise.allSettled([
265263
ctx.serviceClient(service1).call(),
266-
ctx.serviceClient(service2).call()
264+
ctx.serviceClient(service2).call(),
267265
]);
268266

269267
results2.forEach((result, i) => {
@@ -278,10 +276,9 @@ results2.forEach((result, i) => {
278276
### Invocation Management
279277

280278
```ts {"CODE_LOAD::ts/src/develop/agentsmd/agentsmd-actions.ts#cancel"} theme={null}
281-
const handle = ctx.serviceSendClient(myService).myHandler(
282-
"Hi",
283-
restate.rpc.sendOpts({ idempotencyKey: "my-key" })
284-
);
279+
const handle = ctx
280+
.serviceSendClient(myService)
281+
.myHandler("Hi", restate.rpc.sendOpts({ idempotencyKey: "my-key" }));
285282
const invocationId = await handle.invocationId;
286283
const response = await ctx.attach(invocationId);
287284

@@ -370,51 +367,58 @@ throw new Error("Temporary failure - will retry");
370367
import { RestateTestEnvironment } from "@restatedev/restate-sdk-testcontainers";
371368
import * as clients from "@restatedev/restate-sdk-clients";
372369
import { describe, it, beforeAll, afterAll, expect } from "vitest";
373-
import {greeter} from "./greeter-service";
370+
import { greeter } from "./greeter-service";
374371

375372
describe("MyService", () => {
376-
let restateTestEnvironment: RestateTestEnvironment;
377-
let restateIngress: clients.Ingress;
373+
let restateTestEnvironment: RestateTestEnvironment;
374+
let restateIngress: clients.Ingress;
378375

379-
beforeAll(async () => {
380-
restateTestEnvironment = await RestateTestEnvironment.start({services: [greeter]});
381-
restateIngress = clients.connect({ url: restateTestEnvironment.baseUrl() });
382-
}, 20_000);
383-
384-
afterAll(async () => {
385-
await restateTestEnvironment?.stop();
386-
});
387-
388-
it("Can call methods", async () => {
389-
const client = restateIngress.objectClient(greeter, "myKey");
390-
await client.greet("Test!");
391-
});
392-
393-
it("Can read/write state", async () => {
394-
const state = restateTestEnvironment.stateOf(greeter, "myKey");
395-
await state.set("count", 123);
396-
expect(await state.get("count")).toBe(123);
376+
beforeAll(async () => {
377+
restateTestEnvironment = await RestateTestEnvironment.start({
378+
services: [greeter],
397379
});
380+
restateIngress = clients.connect({ url: restateTestEnvironment.baseUrl() });
381+
}, 20_000);
382+
383+
afterAll(async () => {
384+
await restateTestEnvironment?.stop();
385+
});
386+
387+
it("Can call methods", async () => {
388+
const client = restateIngress.objectClient(greeter, "myKey");
389+
await client.greet("Test!");
390+
});
391+
392+
it("Can read/write state", async () => {
393+
const state = restateTestEnvironment.stateOf(greeter, "myKey");
394+
await state.set("count", 123);
395+
expect(await state.get("count")).toBe(123);
396+
});
398397
});
399398
```
400399

401400
## SDK Clients (External Invocations)
402401

403402
```typescript {"CODE_LOAD::ts/src/develop/agentsmd/agentsmd-clients.ts#here"} theme={null}
404-
const restateClient = clients.connect({url: "http://localhost:8080"});
403+
const restateClient = clients.connect({ url: "http://localhost:8080" });
405404

406405
// Request-response
407406
const result = await restateClient
408-
.serviceClient<MyService>({name: "MyService"})
409-
.myHandler("Hi");
407+
.serviceClient<MyService>({ name: "MyService" })
408+
.myHandler("Hi");
410409

411410
// One-way
412411
await restateClient
413-
.serviceSendClient<MyService>({name: "MyService"})
414-
.myHandler("Hi");
412+
.serviceSendClient<MyService>({ name: "MyService" })
413+
.myHandler("Hi");
415414

416415
// Delayed
417416
await restateClient
418-
.serviceSendClient<MyService>({name: "MyService"})
419-
.myHandler("Hi", clients.rpc.sendOpts({delay: {seconds: 1}}));
417+
.serviceSendClient<MyService>({ name: "MyService" })
418+
.myHandler("Hi", clients.rpc.sendOpts({ delay: { seconds: 1 } }));
420419
```
420+
421+
422+
---
423+
424+
> To find navigation and other pages in this documentation, fetch the llms.txt file at: https://docs.restate.dev/llms.txt

0 commit comments

Comments
 (0)