Skip to content

Commit fdb1702

Browse files
authored
chore: Update samples to SDK 1.5.2 (#213)
1 parent d23b289 commit fdb1702

File tree

86 files changed

+4161
-2436
lines changed

Some content is hidden

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

86 files changed

+4161
-2436
lines changed

.scripts/upgrade-versions.mjs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@ if (!versionToSet) {
1111
for (const sample of STORED_SAMPLES) {
1212
const packagePath = path.join(sample, 'package.json');
1313
const content = JSON.parse(await fs.readFile(packagePath));
14-
const changedDeps = replaceDeps({ content, sample, field: 'dependencies' });
15-
const changedDevDeps = replaceDeps({ content, field: 'devDependencies' });
16-
if (changedDeps || changedDevDeps) {
17-
await fs.writeFile(packagePath, JSON.stringify(content));
14+
const changed =
15+
replaceDeps({ content, sample, field: 'dependencies' }) ||
16+
replaceDeps({ content, sample, field: 'devDependencies' }) ||
17+
replaceDeps({ content, sample, field: 'resolutions' });
18+
if (changed) {
19+
await fs.writeFile(packagePath, JSON.stringify(content, null, 2));
1820
} else {
1921
console.log(`Version up to date for ${sample}`);
2022
}
2123
}
2224

2325
function replaceDeps({ content, sample, field }) {
2426
let changed = false;
25-
for (const [dep, version] of Object.entries(content[field])) {
27+
for (const [dep, version] of Object.entries(content[field] ?? {})) {
2628
if (dep.startsWith('@temporalio/')) {
2729
if (version !== versionToSet) {
2830
content[field][dep] = versionToSet;

activities-cancellation-heartbeating/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
]
2121
},
2222
"dependencies": {
23-
"@temporalio/activity": "^1.0.0",
24-
"@temporalio/client": "^1.0.0",
25-
"@temporalio/worker": "^1.0.0",
26-
"@temporalio/workflow": "^1.0.0"
23+
"@temporalio/activity": "^1.5.2",
24+
"@temporalio/client": "^1.5.2",
25+
"@temporalio/worker": "^1.5.2",
26+
"@temporalio/workflow": "^1.5.2"
2727
},
2828
"devDependencies": {
2929
"@tsconfig/node16": "^1.0.0",

activities-cancellation-heartbeating/src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import { Connection, WorkflowClient, WorkflowFailedError, CancelledFailure } from '@temporalio/client';
1+
import { Connection, Client, WorkflowFailedError, CancelledFailure } from '@temporalio/client';
22
import { runCancellableActivity } from './workflows';
33

44
async function run() {
55
const connection = await Connection.connect();
6-
const client = new WorkflowClient({ connection });
6+
const client = new Client({ connection });
77

8-
const handle = await client.start(runCancellableActivity, {
8+
const handle = await client.workflow.start(runCancellableActivity, {
99
taskQueue: 'cancellation-heartbeating',
1010
workflowId: 'cancellation-heartbeating-0',
1111
});

activities-dependency-injection/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
]
2121
},
2222
"dependencies": {
23-
"@temporalio/activity": "^1.0.0",
24-
"@temporalio/client": "^1.0.0",
25-
"@temporalio/worker": "^1.0.0",
26-
"@temporalio/workflow": "^1.0.0"
23+
"@temporalio/activity": "^1.5.2",
24+
"@temporalio/client": "^1.5.2",
25+
"@temporalio/worker": "^1.5.2",
26+
"@temporalio/workflow": "^1.5.2"
2727
},
2828
"devDependencies": {
2929
"@tsconfig/node16": "^1.0.0",

activities-dependency-injection/src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { WorkflowClient } from '@temporalio/client';
1+
import { Client } from '@temporalio/client';
22
import { dependencyWF } from './workflows';
33

44
async function run(): Promise<void> {
5-
const client = new WorkflowClient();
5+
const client = new Client();
66

7-
const result = await client.execute(dependencyWF, {
7+
const result = await client.workflow.execute(dependencyWF, {
88
taskQueue: 'dependency-injection',
99
workflowId: 'dependency-injection',
1010
});

activities-examples/package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,16 @@
2424
]
2525
},
2626
"dependencies": {
27-
"@temporalio/activity": "^1.4.0",
28-
"@temporalio/client": "^1.4.0",
29-
"@temporalio/worker": "^1.4.0",
30-
"@temporalio/workflow": "^1.4.0",
27+
"@temporalio/activity": "^1.5.2",
28+
"@temporalio/client": "^1.5.2",
29+
"@temporalio/worker": "^1.5.2",
30+
"@temporalio/workflow": "^1.5.2",
3131
"axios": "^0.26.0",
3232
"node-fetch": "2.x"
3333
},
3434
"devDependencies": {
35-
"@temporalio/nyc-test-coverage": "^1.4.0",
36-
"@temporalio/testing": "^1.4.0",
35+
"@temporalio/nyc-test-coverage": "^1.5.2",
36+
"@temporalio/testing": "^1.5.2",
3737
"@tsconfig/node16": "^1.0.0",
3838
"@types/jest": "^27.5.1",
3939
"@types/mocha": "8.x",

activities-examples/src/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import { WorkflowClient } from '@temporalio/client';
1+
import { Client } from '@temporalio/client';
22
import { asyncActivityWorkflow, httpWorkflow } from './workflows';
33

44
async function run(): Promise<void> {
5-
const client = new WorkflowClient();
5+
const client = new Client();
66

7-
let result = await client.execute(httpWorkflow, {
7+
let result = await client.workflow.execute(httpWorkflow, {
88
taskQueue: 'activities-examples',
99
workflowId: 'activities-examples',
1010
});
1111
console.log(result); // 'The answer is 42'
1212

13-
result = await client.execute(asyncActivityWorkflow, {
13+
result = await client.workflow.execute(asyncActivityWorkflow, {
1414
taskQueue: 'activities-examples',
1515
workflowId: 'activities-examples',
1616
});

activities-examples/src/mocha/workflows.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ActivityFailure, ApplicationFailure, WorkflowClient, WorkflowFailedError } from '@temporalio/client';
1+
import { ActivityFailure, ApplicationFailure, Client, WorkflowFailedError } from '@temporalio/client';
22
import { Runtime, DefaultLogger, Worker } from '@temporalio/worker';
33
import { TestWorkflowEnvironment } from '@temporalio/testing';
44
import assert from 'assert';
@@ -15,7 +15,7 @@ const workflowCoverage = new WorkflowCoverage();
1515
describe('example workflow', async function () {
1616
let shutdown: () => Promise<void>;
1717
let execute: () => ReturnType<typeof httpWorkflow>;
18-
let getClient: () => WorkflowClient;
18+
let getClient: () => Client;
1919

2020
this.slow(10_000);
2121
this.timeout(20_000);
@@ -40,14 +40,14 @@ describe('example workflow', async function () {
4040
await runPromise;
4141
await env.teardown();
4242
};
43-
getClient = () => env.client.workflow;
43+
getClient = () => env.client;
4444
});
4545

4646
beforeEach(() => {
4747
const client = getClient();
4848

4949
execute = () =>
50-
client.execute(httpWorkflow, {
50+
client.workflow.execute(httpWorkflow, {
5151
taskQueue: 'test-activities',
5252
workflowExecutionTimeout: 10_000,
5353
// Use random ID because ID is meaningless for this test

activities-sticky-queues/package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
]
2121
},
2222
"dependencies": {
23-
"@temporalio/activity": "^1.0.0",
24-
"@temporalio/client": "^1.0.0",
25-
"@temporalio/worker": "^1.0.0",
26-
"@temporalio/workflow": "^1.0.0",
23+
"@temporalio/activity": "^1.5.2",
24+
"@temporalio/client": "^1.5.2",
25+
"@temporalio/worker": "^1.5.2",
26+
"@temporalio/workflow": "^1.5.2",
2727
"uuid": "^8.3.2"
2828
},
2929
"devDependencies": {

activities-sticky-queues/src/client.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
import { Connection, WorkflowClient } from '@temporalio/client';
1+
import { Connection, Client } from '@temporalio/client';
22
import { fileProcessingWorkflow } from './workflows';
33

44
async function run() {
55
const connection = await Connection.connect();
6-
const client = new WorkflowClient({ connection });
7-
await client.execute(fileProcessingWorkflow, {
6+
const client = new Client({ connection });
7+
await client.workflow.execute(fileProcessingWorkflow, {
88
taskQueue: 'sticky-activity-tutorial',
99
workflowId: 'file-processing-0',
1010
});

0 commit comments

Comments
 (0)