-
Notifications
You must be signed in to change notification settings - Fork 116
/
client.ts
39 lines (33 loc) · 981 Bytes
/
client.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import { Client } from '@temporalio/client';
import { v4 as uuid } from 'uuid';
import type { Result, User } from './types';
import { example } from './workflows';
async function run() {
// @@@SNIPSTART typescript-ejson-client-setup
const client = new Client({
dataConverter: { payloadConverterPath: require.resolve('./payload-converter') },
});
// @@@SNIPEND
// @@@SNIPSTART typescript-ejson-client
const user: User = {
id: uuid(),
// age: 1000n, BigInt isn't supported
hp: Infinity,
matcher: /.*Stormblessed/,
token: Uint8Array.from([1, 2, 3]),
createdAt: new Date(),
};
const handle = await client.workflow.start(example, {
args: [user],
taskQueue: 'ejson',
workflowId: `example-user-${user.id}`,
});
// @@@SNIPEND
console.log(`Started workflow ${handle.workflowId}`);
const result: Result = await handle.result();
console.log(result);
}
run().catch((err) => {
console.error(err);
process.exit(1);
});