Skip to content

Commit beadaa9

Browse files
committed
Added samples for infrequent polling, frequent polling, and stateful activities
- added samples for - infrequent polling - frequent polling - stateful activities - removed husky from the nextjs ecommerce app - added vscode launch.json to gitignore [DSE Jira Ticket](https://temporalio.atlassian.net/browse/DSE-21) Regarding the stateful activities: I added this because i learned how to do it while trying to implement the polling We can consider [this PR](#410) finished when we merge this one. Thomas fixed the other parts of it when he merged [this](https://github.com/temporalio/samples-typescript/pull/412/files#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519L38) <!--- add/delete as needed ---> 1. How was this tested: I ran these three in my local and got expected behavior 2. Code cleanliness: ran linter and formatter ✅
1 parent 4f5a53f commit beadaa9

Some content is hidden

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

60 files changed

+1240
-9
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ lib/
109109
yarn.lock
110110
package-lock.json
111111
*/**/pnpm-lock.yaml
112+
113+
# vs code launch.json
114+
.vscode/launch.json

.scripts/list-of-samples.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"activities-cancellation-heartbeating",
44
"activities-dependency-injection",
55
"activities-examples",
6+
"activities-stateful",
67
"child-workflows",
78
"continue-as-new",
89
"cron-workflows",
@@ -26,6 +27,8 @@
2627
"nestjs-exchange-rates",
2728
"nextjs-ecommerce-oneclick",
2829
"patching-api",
30+
"polling-frequent",
31+
"polling-infrequent",
2932
"production",
3033
"protobufs",
3134
"query-subscriptions",

activities-stateful/.eslintignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
lib
3+
.eslintrc.js

activities-stateful/.eslintrc.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
const { builtinModules } = require('module');
2+
3+
const ALLOWED_NODE_BUILTINS = new Set(['assert']);
4+
5+
module.exports = {
6+
root: true,
7+
parser: '@typescript-eslint/parser',
8+
parserOptions: {
9+
project: './tsconfig.json',
10+
tsconfigRootDir: __dirname,
11+
},
12+
plugins: ['@typescript-eslint', 'deprecation'],
13+
extends: [
14+
'eslint:recommended',
15+
'plugin:@typescript-eslint/eslint-recommended',
16+
'plugin:@typescript-eslint/recommended',
17+
'prettier',
18+
],
19+
rules: {
20+
// recommended for safety
21+
'@typescript-eslint/no-floating-promises': 'error', // forgetting to await Activities and Workflow APIs is bad
22+
'deprecation/deprecation': 'warn',
23+
24+
// code style preference
25+
'object-shorthand': ['error', 'always'],
26+
27+
// relaxed rules, for convenience
28+
'@typescript-eslint/no-unused-vars': [
29+
'warn',
30+
{
31+
argsIgnorePattern: '^_',
32+
varsIgnorePattern: '^_',
33+
},
34+
],
35+
'@typescript-eslint/no-explicit-any': 'off',
36+
},
37+
overrides: [
38+
{
39+
files: ['src/workflows.ts', 'src/workflows-*.ts', 'src/workflows/*.ts'],
40+
rules: {
41+
'no-restricted-imports': [
42+
'error',
43+
...builtinModules.filter((m) => !ALLOWED_NODE_BUILTINS.has(m)).flatMap((m) => [m, `node:${m}`]),
44+
],
45+
},
46+
},
47+
],
48+
};

activities-stateful/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
lib
2+
node_modules

activities-stateful/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

activities-stateful/.nvmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
22

activities-stateful/.post-create

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
To begin development, install the Temporal CLI:
2+
3+
Mac: {cyan brew install temporal}
4+
Other: Download and extract the latest release from https://github.com/temporalio/cli/releases/latest
5+
6+
Start Temporal Server:
7+
8+
{cyan temporal server start-dev}
9+
10+
Use Node version 18+ (v22.x is recommended):
11+
12+
Mac: {cyan brew install node@22}
13+
Other: https://nodejs.org/en/download/
14+
15+
Then, in the project directory, using two other shells, run these commands:
16+
17+
{cyan npm run start.watch}
18+
{cyan npm run workflow}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib

activities-stateful/.prettierrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
printWidth: 120
2+
singleQuote: true

0 commit comments

Comments
 (0)