From 540547619d237b2193efb9c9617612f06bca05be Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Tue, 18 Nov 2025 11:14:36 -0500 Subject: [PATCH 1/3] fetch-esm: add a non-fetch variant + use tsx instead of ts-node --- fetch-esm/package.json | 24 +- fetch-esm/src/activities.ts | 13 +- fetch-esm/src/{client.ts => client-fetch.ts} | 6 +- fetch-esm/src/client-hello.ts | 15 + fetch-esm/src/worker.ts | 2 +- fetch-esm/src/workflows.ts | 24 +- fetch-esm/tsconfig.json | 4 +- pnpm-lock.yaml | 324 ++++++++++++++++++- 8 files changed, 370 insertions(+), 42 deletions(-) rename fetch-esm/src/{client.ts => client-fetch.ts} (73%) create mode 100644 fetch-esm/src/client-hello.ts diff --git a/fetch-esm/package.json b/fetch-esm/package.json index 91722bda..8efb5cd5 100644 --- a/fetch-esm/package.json +++ b/fetch-esm/package.json @@ -9,30 +9,24 @@ "format": "prettier --write .", "format:check": "prettier --check .", "lint": "eslint .", - "start": "node --loader ts-node/esm src/worker.ts", - "start.watch": "nodemon src/worker.ts", - "workflow": "node --loader ts-node/esm src/client.ts" - }, - "nodemonConfig": { - "execMap": { - "ts": "node --loader ts-node/esm" - }, - "ext": "ts", - "watch": [ - "src" - ] + "start": "tsx src/worker.ts", + "start.watch": "tsx watch src/worker.ts", + "workflow": "tsx src/client-hello.ts", + "workflow-fetch": "tsx src/client-fetch.ts" }, "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/common": "^1.13.2", "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", - "@temporalio/workflow": "^1.13.2" + "@temporalio/workflow": "^1.13.2", + "humanize-string": "^3.1.0", + "node-fetch": "^3.3.2" }, "devDependencies": { "@tsconfig/node18": "^18.2.4", "@types/node": "^22.9.1", - "@types/node-fetch": "^3.0.3", "@typescript-eslint/eslint-plugin": "^8.18.0", "@typescript-eslint/parser": "^8.18.0", "eslint": "^8.57.1", @@ -41,7 +35,7 @@ "node-fetch": "^3.0.0", "nodemon": "^3.1.7", "prettier": "^3.4.2", - "ts-node": "^10.9.2", + "tsx": "^4.20.6", "typescript": "^5.6.3" } } diff --git a/fetch-esm/src/activities.ts b/fetch-esm/src/activities.ts index cad27529..7ed85f88 100644 --- a/fetch-esm/src/activities.ts +++ b/fetch-esm/src/activities.ts @@ -1,7 +1,18 @@ +// humanize-string and node-fetch are ESM libraries +import humanizeString from 'humanize-string'; import fetch from 'node-fetch'; +import { ApplicationFailure } from '@temporalio/common'; + export async function greetHTTP(name: string): Promise { - const response = await fetch('http://httpbin.org/get?greeting=Hello'); + const response = await fetch('http://httpbin.org.notfound/get?greeting=Hello'); + if (!response.ok) { + throw ApplicationFailure.retryable(`HTTP error! status: ${response.status}`); + } const body: any = await response.json(); return `${body.args.greeting}, ${name}!`; } + +export async function greet(name: string): Promise { + return humanizeString(`Hello-World-And-Hello-${(name)}!`, { preserveCase: true }); +} diff --git a/fetch-esm/src/client.ts b/fetch-esm/src/client-fetch.ts similarity index 73% rename from fetch-esm/src/client.ts rename to fetch-esm/src/client-fetch.ts index 890b6a21..9a4e0bc8 100644 --- a/fetch-esm/src/client.ts +++ b/fetch-esm/src/client-fetch.ts @@ -1,14 +1,14 @@ // @@@SNIPSTART typescript-esm-client import { Client, Connection } from '@temporalio/client'; import { loadClientConnectConfig } from '@temporalio/envconfig'; -import { example } from './workflows.js'; +import { exampleFetch } from './workflows.ts'; const config = loadClientConnectConfig(); const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); -const result = await client.workflow.execute(example, { +const result = await client.workflow.execute(exampleFetch, { taskQueue: 'fetch-esm', - workflowId: 'my-business-id', + workflowId: `my-business-id-${Date.now()}`, args: ['Temporal'], }); console.log(result); // Hello, Temporal! diff --git a/fetch-esm/src/client-hello.ts b/fetch-esm/src/client-hello.ts new file mode 100644 index 00000000..3b0d1eda --- /dev/null +++ b/fetch-esm/src/client-hello.ts @@ -0,0 +1,15 @@ +// @@@SNIPSTART typescript-esm-client +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; +import { exampleHello } from './workflows.ts'; + +const config = loadClientConnectConfig(); +const connection = await Connection.connect(config.connectionOptions); +const client = new Client({ connection }); +const result = await client.workflow.execute(exampleHello, { + taskQueue: 'fetch-esm', + workflowId: `my-business-id-${Date.now()}`, + args: ['Wonderful-Temporal'], +}); +console.log(result); // Hello World And Hello Wonderful Temporal! +// @@@SNIPEND diff --git a/fetch-esm/src/worker.ts b/fetch-esm/src/worker.ts index ffc672cb..029920fc 100644 --- a/fetch-esm/src/worker.ts +++ b/fetch-esm/src/worker.ts @@ -2,7 +2,7 @@ import { Worker } from '@temporalio/worker'; import { URL, fileURLToPath } from 'url'; import path from 'path'; -import * as activities from './activities.js'; +import * as activities from './activities.ts'; // Support running both complied code and ts-node/esm loader const workflowsPathUrl = new URL(`./workflows${path.extname(import.meta.url)}`, import.meta.url); diff --git a/fetch-esm/src/workflows.ts b/fetch-esm/src/workflows.ts index 28aa6876..c9160900 100644 --- a/fetch-esm/src/workflows.ts +++ b/fetch-esm/src/workflows.ts @@ -1,13 +1,29 @@ // @@@SNIPSTART typescript-esm-workflow import { proxyActivities } from '@temporalio/workflow'; // Only import the activity types -import type * as activities from './activities.js'; +import type * as activities from './activities.ts'; +const { greet } = proxyActivities({ + scheduleToCloseTimeout: '5 seconds', +}); + +// A variant of the preceding workflow that does not perform any HTTP requests +export async function exampleHello(name: string): Promise { + return await greet(name); +} +// @@@SNIPEND + +// The sample `fetch` activity make requests to httpbin.org, which is sometime slow or flaky. +// In the case of this workflow, we prefer to fail the workflow than retry the HTTP request forever. const { greetHTTP } = proxyActivities({ - startToCloseTimeout: '1 minute', + startToCloseTimeout: '3 seconds', + retry: { + initialInterval: '500 ms', + maximumAttempts: 3, + backoffCoefficient: 1.5, + }, }); -export async function example(name: string): Promise { +export async function exampleFetch(name: string): Promise { return await greetHTTP(name); } -// @@@SNIPEND diff --git a/fetch-esm/tsconfig.json b/fetch-esm/tsconfig.json index 9e856ebc..c37a17ac 100644 --- a/fetch-esm/tsconfig.json +++ b/fetch-esm/tsconfig.json @@ -9,7 +9,9 @@ "declarationMap": true, "sourceMap": true, "rootDir": "./src", - "outDir": "./lib" + "outDir": "./lib", + "allowImportingTsExtensions": true, + "noEmit": true }, "include": ["src/**/*.ts"] } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 523a68d7..def30e18 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -985,6 +985,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/common': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/envconfig': specifier: ^1.13.2 version: 1.13.2 @@ -994,6 +997,12 @@ importers: '@temporalio/workflow': specifier: ^1.13.2 version: 1.13.2 + humanize-string: + specifier: ^3.1.0 + version: 3.1.0 + node-fetch: + specifier: ^3.3.2 + version: 3.3.2 devDependencies: '@tsconfig/node18': specifier: ^18.2.4 @@ -1001,9 +1010,6 @@ importers: '@types/node': specifier: ^22.9.1 version: 22.12.0 - '@types/node-fetch': - specifier: ^3.0.3 - version: 3.0.3 '@typescript-eslint/eslint-plugin': specifier: ^8.18.0 version: 8.22.0(@typescript-eslint/parser@8.22.0(eslint@8.57.1)(typescript@5.7.3))(eslint@8.57.1)(typescript@5.7.3) @@ -1019,18 +1025,15 @@ importers: eslint-plugin-deprecation: specifier: ^3.0.0 version: 3.0.0(eslint@8.57.1)(typescript@5.7.3) - node-fetch: - specifier: ^3.0.0 - version: 3.3.2 nodemon: specifier: ^3.1.7 version: 3.1.9 prettier: specifier: ^3.4.2 version: 3.4.2 - ts-node: - specifier: ^10.9.2 - version: 10.9.2(@swc/core@1.10.11(@swc/helpers@0.5.15))(@types/node@22.12.0)(typescript@5.7.3) + tsx: + specifier: ^4.20.6 + version: 4.20.6 typescript: specifier: ^5.6.3 version: 5.7.3 @@ -4398,6 +4401,12 @@ packages: cpu: [ppc64] os: [aix] + '@esbuild/aix-ppc64@0.25.12': + resolution: {integrity: sha512-Hhmwd6CInZ3dwpuGTF8fJG6yoWmsToE+vYgD4nytZVxcu1ulHpUQRAB1UJ8+N1Am3Mz4+xOByoQoSZf4D+CpkA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [aix] + '@esbuild/android-arm64@0.17.6': resolution: {integrity: sha512-YnYSCceN/dUzUr5kdtUzB+wZprCafuD89Hs0Aqv9QSdwhYQybhXTaSTcrl6X/aWThn1a/j0eEpUBGOE7269REg==} engines: {node: '>=12'} @@ -4410,6 +4419,12 @@ packages: cpu: [arm64] os: [android] + '@esbuild/android-arm64@0.25.12': + resolution: {integrity: sha512-6AAmLG7zwD1Z159jCKPvAxZd4y/VTO0VkprYy+3N2FtJ8+BQWFXU+OxARIwA46c5tdD9SsKGZ/1ocqBS/gAKHg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [android] + '@esbuild/android-arm@0.17.6': resolution: {integrity: sha512-bSC9YVUjADDy1gae8RrioINU6e1lCkg3VGVwm0QQ2E1CWcC4gnMce9+B6RpxuSsrsXsk1yojn7sp1fnG8erE2g==} engines: {node: '>=12'} @@ -4422,6 +4437,12 @@ packages: cpu: [arm] os: [android] + '@esbuild/android-arm@0.25.12': + resolution: {integrity: sha512-VJ+sKvNA/GE7Ccacc9Cha7bpS8nyzVv0jdVgwNDaR4gDMC/2TTRc33Ip8qrNYUcpkOHUT5OZ0bUcNNVZQ9RLlg==} + engines: {node: '>=18'} + cpu: [arm] + os: [android] + '@esbuild/android-x64@0.17.6': resolution: {integrity: sha512-MVcYcgSO7pfu/x34uX9u2QIZHmXAB7dEiLQC5bBl5Ryqtpj9lT2sg3gNDEsrPEmimSJW2FXIaxqSQ501YLDsZQ==} engines: {node: '>=12'} @@ -4434,6 +4455,12 @@ packages: cpu: [x64] os: [android] + '@esbuild/android-x64@0.25.12': + resolution: {integrity: sha512-5jbb+2hhDHx5phYR2By8GTWEzn6I9UqR11Kwf22iKbNpYrsmRB18aX/9ivc5cabcUiAT/wM+YIZ6SG9QO6a8kg==} + engines: {node: '>=18'} + cpu: [x64] + os: [android] + '@esbuild/darwin-arm64@0.17.6': resolution: {integrity: sha512-bsDRvlbKMQMt6Wl08nHtFz++yoZHsyTOxnjfB2Q95gato+Yi4WnRl13oC2/PJJA9yLCoRv9gqT/EYX0/zDsyMA==} engines: {node: '>=12'} @@ -4446,6 +4473,12 @@ packages: cpu: [arm64] os: [darwin] + '@esbuild/darwin-arm64@0.25.12': + resolution: {integrity: sha512-N3zl+lxHCifgIlcMUP5016ESkeQjLj/959RxxNYIthIg+CQHInujFuXeWbWMgnTo4cp5XVHqFPmpyu9J65C1Yg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [darwin] + '@esbuild/darwin-x64@0.17.6': resolution: {integrity: sha512-xh2A5oPrYRfMFz74QXIQTQo8uA+hYzGWJFoeTE8EvoZGHb+idyV4ATaukaUvnnxJiauhs/fPx3vYhU4wiGfosg==} engines: {node: '>=12'} @@ -4458,6 +4491,12 @@ packages: cpu: [x64] os: [darwin] + '@esbuild/darwin-x64@0.25.12': + resolution: {integrity: sha512-HQ9ka4Kx21qHXwtlTUVbKJOAnmG1ipXhdWTmNXiPzPfWKpXqASVcWdnf2bnL73wgjNrFXAa3yYvBSd9pzfEIpA==} + engines: {node: '>=18'} + cpu: [x64] + os: [darwin] + '@esbuild/freebsd-arm64@0.17.6': resolution: {integrity: sha512-EnUwjRc1inT4ccZh4pB3v1cIhohE2S4YXlt1OvI7sw/+pD+dIE4smwekZlEPIwY6PhU6oDWwITrQQm5S2/iZgg==} engines: {node: '>=12'} @@ -4470,6 +4509,12 @@ packages: cpu: [arm64] os: [freebsd] + '@esbuild/freebsd-arm64@0.25.12': + resolution: {integrity: sha512-gA0Bx759+7Jve03K1S0vkOu5Lg/85dou3EseOGUes8flVOGxbhDDh/iZaoek11Y8mtyKPGF3vP8XhnkDEAmzeg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [freebsd] + '@esbuild/freebsd-x64@0.17.6': resolution: {integrity: sha512-Uh3HLWGzH6FwpviUcLMKPCbZUAFzv67Wj5MTwK6jn89b576SR2IbEp+tqUHTr8DIl0iDmBAf51MVaP7pw6PY5Q==} engines: {node: '>=12'} @@ -4482,6 +4527,12 @@ packages: cpu: [x64] os: [freebsd] + '@esbuild/freebsd-x64@0.25.12': + resolution: {integrity: sha512-TGbO26Yw2xsHzxtbVFGEXBFH0FRAP7gtcPE7P5yP7wGy7cXK2oO7RyOhL5NLiqTlBh47XhmIUXuGciXEqYFfBQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [freebsd] + '@esbuild/linux-arm64@0.17.6': resolution: {integrity: sha512-bUR58IFOMJX523aDVozswnlp5yry7+0cRLCXDsxnUeQYJik1DukMY+apBsLOZJblpH+K7ox7YrKrHmJoWqVR9w==} engines: {node: '>=12'} @@ -4494,6 +4545,12 @@ packages: cpu: [arm64] os: [linux] + '@esbuild/linux-arm64@0.25.12': + resolution: {integrity: sha512-8bwX7a8FghIgrupcxb4aUmYDLp8pX06rGh5HqDT7bB+8Rdells6mHvrFHHW2JAOPZUbnjUpKTLg6ECyzvas2AQ==} + engines: {node: '>=18'} + cpu: [arm64] + os: [linux] + '@esbuild/linux-arm@0.17.6': resolution: {integrity: sha512-7YdGiurNt7lqO0Bf/U9/arrPWPqdPqcV6JCZda4LZgEn+PTQ5SMEI4MGR52Bfn3+d6bNEGcWFzlIxiQdS48YUw==} engines: {node: '>=12'} @@ -4506,6 +4563,12 @@ packages: cpu: [arm] os: [linux] + '@esbuild/linux-arm@0.25.12': + resolution: {integrity: sha512-lPDGyC1JPDou8kGcywY0YILzWlhhnRjdof3UlcoqYmS9El818LLfJJc3PXXgZHrHCAKs/Z2SeZtDJr5MrkxtOw==} + engines: {node: '>=18'} + cpu: [arm] + os: [linux] + '@esbuild/linux-ia32@0.17.6': resolution: {integrity: sha512-ujp8uoQCM9FRcbDfkqECoARsLnLfCUhKARTP56TFPog8ie9JG83D5GVKjQ6yVrEVdMie1djH86fm98eY3quQkQ==} engines: {node: '>=12'} @@ -4518,6 +4581,12 @@ packages: cpu: [ia32] os: [linux] + '@esbuild/linux-ia32@0.25.12': + resolution: {integrity: sha512-0y9KrdVnbMM2/vG8KfU0byhUN+EFCny9+8g202gYqSSVMonbsCfLjUO+rCci7pM0WBEtz+oK/PIwHkzxkyharA==} + engines: {node: '>=18'} + cpu: [ia32] + os: [linux] + '@esbuild/linux-loong64@0.17.6': resolution: {integrity: sha512-y2NX1+X/Nt+izj9bLoiaYB9YXT/LoaQFYvCkVD77G/4F+/yuVXYCWz4SE9yr5CBMbOxOfBcy/xFL4LlOeNlzYQ==} engines: {node: '>=12'} @@ -4530,6 +4599,12 @@ packages: cpu: [loong64] os: [linux] + '@esbuild/linux-loong64@0.25.12': + resolution: {integrity: sha512-h///Lr5a9rib/v1GGqXVGzjL4TMvVTv+s1DPoxQdz7l/AYv6LDSxdIwzxkrPW438oUXiDtwM10o9PmwS/6Z0Ng==} + engines: {node: '>=18'} + cpu: [loong64] + os: [linux] + '@esbuild/linux-mips64el@0.17.6': resolution: {integrity: sha512-09AXKB1HDOzXD+j3FdXCiL/MWmZP0Ex9eR8DLMBVcHorrWJxWmY8Nms2Nm41iRM64WVx7bA/JVHMv081iP2kUA==} engines: {node: '>=12'} @@ -4542,6 +4617,12 @@ packages: cpu: [mips64el] os: [linux] + '@esbuild/linux-mips64el@0.25.12': + resolution: {integrity: sha512-iyRrM1Pzy9GFMDLsXn1iHUm18nhKnNMWscjmp4+hpafcZjrr2WbT//d20xaGljXDBYHqRcl8HnxbX6uaA/eGVw==} + engines: {node: '>=18'} + cpu: [mips64el] + os: [linux] + '@esbuild/linux-ppc64@0.17.6': resolution: {integrity: sha512-AmLhMzkM8JuqTIOhxnX4ubh0XWJIznEynRnZAVdA2mMKE6FAfwT2TWKTwdqMG+qEaeyDPtfNoZRpJbD4ZBv0Tg==} engines: {node: '>=12'} @@ -4554,6 +4635,12 @@ packages: cpu: [ppc64] os: [linux] + '@esbuild/linux-ppc64@0.25.12': + resolution: {integrity: sha512-9meM/lRXxMi5PSUqEXRCtVjEZBGwB7P/D4yT8UG/mwIdze2aV4Vo6U5gD3+RsoHXKkHCfSxZKzmDssVlRj1QQA==} + engines: {node: '>=18'} + cpu: [ppc64] + os: [linux] + '@esbuild/linux-riscv64@0.17.6': resolution: {integrity: sha512-Y4Ri62PfavhLQhFbqucysHOmRamlTVK10zPWlqjNbj2XMea+BOs4w6ASKwQwAiqf9ZqcY9Ab7NOU4wIgpxwoSQ==} engines: {node: '>=12'} @@ -4566,6 +4653,12 @@ packages: cpu: [riscv64] os: [linux] + '@esbuild/linux-riscv64@0.25.12': + resolution: {integrity: sha512-Zr7KR4hgKUpWAwb1f3o5ygT04MzqVrGEGXGLnj15YQDJErYu/BGg+wmFlIDOdJp0PmB0lLvxFIOXZgFRrdjR0w==} + engines: {node: '>=18'} + cpu: [riscv64] + os: [linux] + '@esbuild/linux-s390x@0.17.6': resolution: {integrity: sha512-SPUiz4fDbnNEm3JSdUW8pBJ/vkop3M1YwZAVwvdwlFLoJwKEZ9L98l3tzeyMzq27CyepDQ3Qgoba44StgbiN5Q==} engines: {node: '>=12'} @@ -4578,6 +4671,12 @@ packages: cpu: [s390x] os: [linux] + '@esbuild/linux-s390x@0.25.12': + resolution: {integrity: sha512-MsKncOcgTNvdtiISc/jZs/Zf8d0cl/t3gYWX8J9ubBnVOwlk65UIEEvgBORTiljloIWnBzLs4qhzPkJcitIzIg==} + engines: {node: '>=18'} + cpu: [s390x] + os: [linux] + '@esbuild/linux-x64@0.17.6': resolution: {integrity: sha512-a3yHLmOodHrzuNgdpB7peFGPx1iJ2x6m+uDvhP2CKdr2CwOaqEFMeSqYAHU7hG+RjCq8r2NFujcd/YsEsFgTGw==} engines: {node: '>=12'} @@ -4590,6 +4689,18 @@ packages: cpu: [x64] os: [linux] + '@esbuild/linux-x64@0.25.12': + resolution: {integrity: sha512-uqZMTLr/zR/ed4jIGnwSLkaHmPjOjJvnm6TVVitAa08SLS9Z0VM8wIRx7gWbJB5/J54YuIMInDquWyYvQLZkgw==} + engines: {node: '>=18'} + cpu: [x64] + os: [linux] + + '@esbuild/netbsd-arm64@0.25.12': + resolution: {integrity: sha512-xXwcTq4GhRM7J9A8Gv5boanHhRa/Q9KLVmcyXHCTaM4wKfIpWkdXiMog/KsnxzJ0A1+nD+zoecuzqPmCRyBGjg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [netbsd] + '@esbuild/netbsd-x64@0.17.6': resolution: {integrity: sha512-EanJqcU/4uZIBreTrnbnre2DXgXSa+Gjap7ifRfllpmyAU7YMvaXmljdArptTHmjrkkKm9BK6GH5D5Yo+p6y5A==} engines: {node: '>=12'} @@ -4602,6 +4713,18 @@ packages: cpu: [x64] os: [netbsd] + '@esbuild/netbsd-x64@0.25.12': + resolution: {integrity: sha512-Ld5pTlzPy3YwGec4OuHh1aCVCRvOXdH8DgRjfDy/oumVovmuSzWfnSJg+VtakB9Cm0gxNO9BzWkj6mtO1FMXkQ==} + engines: {node: '>=18'} + cpu: [x64] + os: [netbsd] + + '@esbuild/openbsd-arm64@0.25.12': + resolution: {integrity: sha512-fF96T6KsBo/pkQI950FARU9apGNTSlZGsv1jZBAlcLL1MLjLNIWPBkj5NlSz8aAzYKg+eNqknrUJ24QBybeR5A==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openbsd] + '@esbuild/openbsd-x64@0.17.6': resolution: {integrity: sha512-xaxeSunhQRsTNGFanoOkkLtnmMn5QbA0qBhNet/XLVsc+OVkpIWPHcr3zTW2gxVU5YOHFbIHR9ODuaUdNza2Vw==} engines: {node: '>=12'} @@ -4614,6 +4737,18 @@ packages: cpu: [x64] os: [openbsd] + '@esbuild/openbsd-x64@0.25.12': + resolution: {integrity: sha512-MZyXUkZHjQxUvzK7rN8DJ3SRmrVrke8ZyRusHlP+kuwqTcfWLyqMOE3sScPPyeIXN/mDJIfGXvcMqCgYKekoQw==} + engines: {node: '>=18'} + cpu: [x64] + os: [openbsd] + + '@esbuild/openharmony-arm64@0.25.12': + resolution: {integrity: sha512-rm0YWsqUSRrjncSXGA7Zv78Nbnw4XL6/dzr20cyrQf7ZmRcsovpcRBdhD43Nuk3y7XIoW2OxMVvwuRvk9XdASg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [openharmony] + '@esbuild/sunos-x64@0.17.6': resolution: {integrity: sha512-gnMnMPg5pfMkZvhHee21KbKdc6W3GR8/JuE0Da1kjwpK6oiFU3nqfHuVPgUX2rsOx9N2SadSQTIYV1CIjYG+xw==} engines: {node: '>=12'} @@ -4626,6 +4761,12 @@ packages: cpu: [x64] os: [sunos] + '@esbuild/sunos-x64@0.25.12': + resolution: {integrity: sha512-3wGSCDyuTHQUzt0nV7bocDy72r2lI33QL3gkDNGkod22EsYl04sMf0qLb8luNKTOmgF/eDEDP5BFNwoBKH441w==} + engines: {node: '>=18'} + cpu: [x64] + os: [sunos] + '@esbuild/win32-arm64@0.17.6': resolution: {integrity: sha512-G95n7vP1UnGJPsVdKXllAJPtqjMvFYbN20e8RK8LVLhlTiSOH1sd7+Gt7rm70xiG+I5tM58nYgwWrLs6I1jHqg==} engines: {node: '>=12'} @@ -4638,6 +4779,12 @@ packages: cpu: [arm64] os: [win32] + '@esbuild/win32-arm64@0.25.12': + resolution: {integrity: sha512-rMmLrur64A7+DKlnSuwqUdRKyd3UE7oPJZmnljqEptesKM8wx9J8gx5u0+9Pq0fQQW8vqeKebwNXdfOyP+8Bsg==} + engines: {node: '>=18'} + cpu: [arm64] + os: [win32] + '@esbuild/win32-ia32@0.17.6': resolution: {integrity: sha512-96yEFzLhq5bv9jJo5JhTs1gI+1cKQ83cUpyxHuGqXVwQtY5Eq54ZEsKs8veKtiKwlrNimtckHEkj4mRh4pPjsg==} engines: {node: '>=12'} @@ -4650,6 +4797,12 @@ packages: cpu: [ia32] os: [win32] + '@esbuild/win32-ia32@0.25.12': + resolution: {integrity: sha512-HkqnmmBoCbCwxUKKNPBixiWDGCpQGVsrQfJoVGYLPT41XWF8lHuE5N6WhVia2n4o5QK5M4tYr21827fNhi4byQ==} + engines: {node: '>=18'} + cpu: [ia32] + os: [win32] + '@esbuild/win32-x64@0.17.6': resolution: {integrity: sha512-n6d8MOyUrNp6G4VSpRcgjs5xj4A91svJSaiwLIDWVWEsZtpN5FA9NlBbZHDmAJc2e8e6SF4tkBD3HAvPF+7igA==} engines: {node: '>=12'} @@ -4662,6 +4815,12 @@ packages: cpu: [x64] os: [win32] + '@esbuild/win32-x64@0.25.12': + resolution: {integrity: sha512-alJC0uCZpTFrSL0CCDjcgleBXPnCrEAhTBILpeAp7M/OFgoqtAetfBzX0xM00MUsVVPpVjlPuMbREqnZCXaTnA==} + engines: {node: '>=18'} + cpu: [x64] + os: [win32] + '@eslint-community/eslint-utils@4.4.1': resolution: {integrity: sha512-s3O3waFUrMV8P/XaF/+ZTp1X9XBZW1a4B97ZnjQF2KYWaFD2A8KyFBsrsfSjEmjn3RGWAIuvlneuZm3CUK3jbA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} @@ -6480,10 +6639,6 @@ packages: '@types/node-fetch@2.6.3': resolution: {integrity: sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==} - '@types/node-fetch@3.0.3': - resolution: {integrity: sha512-HhggYPH5N+AQe/OmN6fmhKmRRt2XuNJow+R3pQwJxOOF9GuwM7O2mheyGeIrs5MOIeNjDEdgdoyHBOrFeJBR3g==} - deprecated: This is a stub types definition. node-fetch provides its own type definitions, so you do not need this installed. - '@types/node-forge@1.3.11': resolution: {integrity: sha512-FQx220y22OKNTqaByeBGqHWYz4cl94tpcxeFdvBo3wjG6XPBuZ0BNgNZRV5J5TFmmcsJ4IzsLkmGRiQbnYsBEQ==} @@ -8066,6 +8221,10 @@ packages: resolution: {integrity: sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==} engines: {node: '>=10'} + decamelize@6.0.1: + resolution: {integrity: sha512-G7Cqgaelq68XHJNGlZ7lrNQyhZGsFqpwtGFexqUv4IQdjKoSYF7ipZ9UuTJZUSQXFj/XaoBLuEVIVqr8EJngEQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + decimal.js@10.5.0: resolution: {integrity: sha512-8vDa8Qxvr/+d94hSh5P3IJwI5t8/c0KsMp+g8bNw9cY2icONa5aPfvKeieW1WlG0WQYwwhJ7mjui2xtiePQSXw==} @@ -8577,6 +8736,11 @@ packages: engines: {node: '>=12'} hasBin: true + esbuild@0.25.12: + resolution: {integrity: sha512-bbPBYYrtZbkt6Os6FiTLCTFxvq4tt3JKall1vRwshA3fdVztsLAatFaZobhkBC8/BrPetoa0oksYoKXoG4ryJg==} + engines: {node: '>=18'} + hasBin: true + escalade@3.2.0: resolution: {integrity: sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==} engines: {node: '>=6'} @@ -9500,6 +9664,10 @@ packages: resolution: {integrity: sha512-B4FFZ6q/T2jhhksgkbEW3HBvWIfDW85snkQgawt07S7J5QXTk6BkNV+0yAeZrM5QpMAdYlocGoljn0sJ/WQkFw==} engines: {node: '>=10.17.0'} + humanize-string@3.1.0: + resolution: {integrity: sha512-wEtOOR3sT8nZ7W0WZwEXo68z2EA0kpcpjaN/ZXxpps9PDzZdX8+TAj+XOGKx2WkagP9mnhWtFpfMNSd2WAhiIQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + husky@7.0.4: resolution: {integrity: sha512-vbaCKN2QLtP/vD4yvs6iz6hBEo6wkSzs8HpRah1Z6aGmF2KW5PdYuAd7uX5a+OyBZHBhd+TFLqgjUgytQr4RvQ==} engines: {node: '>=12'} @@ -11159,6 +11327,7 @@ packages: node-domexception@1.0.0: resolution: {integrity: sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==} engines: {node: '>=10.5.0'} + deprecated: Use your platform's native DOMException instead node-emoji@1.11.0: resolution: {integrity: sha512-wo2DpQkQp7Sjm2A0cq+sN7EHKO6Sl0ctXeBdFZrL9T9+UywORbufTcTZxom8YqpLQt/FqNMUkOpkZrJVYSKD3A==} @@ -13520,6 +13689,11 @@ packages: peerDependencies: typescript: '>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta' + tsx@4.20.6: + resolution: {integrity: sha512-ytQKuwgmrrkDTFP4LjR0ToE2nqgy886GpvRSpU0JAnrdBYppuY5rLkRUYPU1yCryb24SsKBTL/hlDQAEFVwtZg==} + engines: {node: '>=18.0.0'} + hasBin: true + tunnel-agent@0.6.0: resolution: {integrity: sha512-McnNiV1l8RYeY8tBgEpuodCC1mLUdbSN+CYBL7kJsJNInOP8UjDDEwdk6Mw60vdLLrr5NHKZhMAOSrR2NZuQ+w==} @@ -15316,138 +15490,216 @@ snapshots: '@esbuild/aix-ppc64@0.21.5': optional: true + '@esbuild/aix-ppc64@0.25.12': + optional: true + '@esbuild/android-arm64@0.17.6': optional: true '@esbuild/android-arm64@0.21.5': optional: true + '@esbuild/android-arm64@0.25.12': + optional: true + '@esbuild/android-arm@0.17.6': optional: true '@esbuild/android-arm@0.21.5': optional: true + '@esbuild/android-arm@0.25.12': + optional: true + '@esbuild/android-x64@0.17.6': optional: true '@esbuild/android-x64@0.21.5': optional: true + '@esbuild/android-x64@0.25.12': + optional: true + '@esbuild/darwin-arm64@0.17.6': optional: true '@esbuild/darwin-arm64@0.21.5': optional: true + '@esbuild/darwin-arm64@0.25.12': + optional: true + '@esbuild/darwin-x64@0.17.6': optional: true '@esbuild/darwin-x64@0.21.5': optional: true + '@esbuild/darwin-x64@0.25.12': + optional: true + '@esbuild/freebsd-arm64@0.17.6': optional: true '@esbuild/freebsd-arm64@0.21.5': optional: true + '@esbuild/freebsd-arm64@0.25.12': + optional: true + '@esbuild/freebsd-x64@0.17.6': optional: true '@esbuild/freebsd-x64@0.21.5': optional: true + '@esbuild/freebsd-x64@0.25.12': + optional: true + '@esbuild/linux-arm64@0.17.6': optional: true '@esbuild/linux-arm64@0.21.5': optional: true + '@esbuild/linux-arm64@0.25.12': + optional: true + '@esbuild/linux-arm@0.17.6': optional: true '@esbuild/linux-arm@0.21.5': optional: true + '@esbuild/linux-arm@0.25.12': + optional: true + '@esbuild/linux-ia32@0.17.6': optional: true '@esbuild/linux-ia32@0.21.5': optional: true + '@esbuild/linux-ia32@0.25.12': + optional: true + '@esbuild/linux-loong64@0.17.6': optional: true '@esbuild/linux-loong64@0.21.5': optional: true + '@esbuild/linux-loong64@0.25.12': + optional: true + '@esbuild/linux-mips64el@0.17.6': optional: true '@esbuild/linux-mips64el@0.21.5': optional: true + '@esbuild/linux-mips64el@0.25.12': + optional: true + '@esbuild/linux-ppc64@0.17.6': optional: true '@esbuild/linux-ppc64@0.21.5': optional: true + '@esbuild/linux-ppc64@0.25.12': + optional: true + '@esbuild/linux-riscv64@0.17.6': optional: true '@esbuild/linux-riscv64@0.21.5': optional: true + '@esbuild/linux-riscv64@0.25.12': + optional: true + '@esbuild/linux-s390x@0.17.6': optional: true '@esbuild/linux-s390x@0.21.5': optional: true + '@esbuild/linux-s390x@0.25.12': + optional: true + '@esbuild/linux-x64@0.17.6': optional: true '@esbuild/linux-x64@0.21.5': optional: true + '@esbuild/linux-x64@0.25.12': + optional: true + + '@esbuild/netbsd-arm64@0.25.12': + optional: true + '@esbuild/netbsd-x64@0.17.6': optional: true '@esbuild/netbsd-x64@0.21.5': optional: true + '@esbuild/netbsd-x64@0.25.12': + optional: true + + '@esbuild/openbsd-arm64@0.25.12': + optional: true + '@esbuild/openbsd-x64@0.17.6': optional: true '@esbuild/openbsd-x64@0.21.5': optional: true + '@esbuild/openbsd-x64@0.25.12': + optional: true + + '@esbuild/openharmony-arm64@0.25.12': + optional: true + '@esbuild/sunos-x64@0.17.6': optional: true '@esbuild/sunos-x64@0.21.5': optional: true + '@esbuild/sunos-x64@0.25.12': + optional: true + '@esbuild/win32-arm64@0.17.6': optional: true '@esbuild/win32-arm64@0.21.5': optional: true + '@esbuild/win32-arm64@0.25.12': + optional: true + '@esbuild/win32-ia32@0.17.6': optional: true '@esbuild/win32-ia32@0.21.5': optional: true + '@esbuild/win32-ia32@0.25.12': + optional: true + '@esbuild/win32-x64@0.17.6': optional: true '@esbuild/win32-x64@0.21.5': optional: true + '@esbuild/win32-x64@0.25.12': + optional: true + '@eslint-community/eslint-utils@4.4.1(eslint@8.57.1)': dependencies: eslint: 8.57.1 @@ -17850,10 +18102,6 @@ snapshots: '@types/node': 22.12.0 form-data: 3.0.2 - '@types/node-fetch@3.0.3': - dependencies: - node-fetch: 3.3.2 - '@types/node-forge@1.3.11': dependencies: '@types/node': 22.12.0 @@ -19867,6 +20115,8 @@ snapshots: decamelize@4.0.0: {} + decamelize@6.0.1: {} + decimal.js@10.5.0: {} decode-named-character-reference@1.0.2: @@ -20427,6 +20677,35 @@ snapshots: '@esbuild/win32-ia32': 0.21.5 '@esbuild/win32-x64': 0.21.5 + esbuild@0.25.12: + optionalDependencies: + '@esbuild/aix-ppc64': 0.25.12 + '@esbuild/android-arm': 0.25.12 + '@esbuild/android-arm64': 0.25.12 + '@esbuild/android-x64': 0.25.12 + '@esbuild/darwin-arm64': 0.25.12 + '@esbuild/darwin-x64': 0.25.12 + '@esbuild/freebsd-arm64': 0.25.12 + '@esbuild/freebsd-x64': 0.25.12 + '@esbuild/linux-arm': 0.25.12 + '@esbuild/linux-arm64': 0.25.12 + '@esbuild/linux-ia32': 0.25.12 + '@esbuild/linux-loong64': 0.25.12 + '@esbuild/linux-mips64el': 0.25.12 + '@esbuild/linux-ppc64': 0.25.12 + '@esbuild/linux-riscv64': 0.25.12 + '@esbuild/linux-s390x': 0.25.12 + '@esbuild/linux-x64': 0.25.12 + '@esbuild/netbsd-arm64': 0.25.12 + '@esbuild/netbsd-x64': 0.25.12 + '@esbuild/openbsd-arm64': 0.25.12 + '@esbuild/openbsd-x64': 0.25.12 + '@esbuild/openharmony-arm64': 0.25.12 + '@esbuild/sunos-x64': 0.25.12 + '@esbuild/win32-arm64': 0.25.12 + '@esbuild/win32-ia32': 0.25.12 + '@esbuild/win32-x64': 0.25.12 + escalade@3.2.0: {} escape-html@1.0.3: {} @@ -21705,6 +21984,10 @@ snapshots: human-signals@2.1.0: {} + humanize-string@3.1.0: + dependencies: + decamelize: 6.0.1 + husky@7.0.4: {} hyperdyperid@1.2.0: {} @@ -27114,6 +27397,13 @@ snapshots: tslib: 1.14.1 typescript: 5.7.3 + tsx@4.20.6: + dependencies: + esbuild: 0.25.12 + get-tsconfig: 4.10.0 + optionalDependencies: + fsevents: 2.3.3 + tunnel-agent@0.6.0: dependencies: safe-buffer: 5.2.1 From f619a7db07bee843979ae0a5cf9a92d5d1f93fec Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Tue, 18 Nov 2025 11:28:20 -0500 Subject: [PATCH 2/3] update readme --- fetch-esm/README.md | 4 ++-- fetch-esm/package.json | 6 +++--- fetch-esm/src/activities.ts | 6 +++--- fetch-esm/src/{client-hello.ts => client-local.ts} | 4 ++-- fetch-esm/src/workflows.ts | 6 +++--- 5 files changed, 13 insertions(+), 13 deletions(-) rename fetch-esm/src/{client-hello.ts => client-local.ts} (82%) diff --git a/fetch-esm/README.md b/fetch-esm/README.md index 865c2695..67a55d9f 100644 --- a/fetch-esm/README.md +++ b/fetch-esm/README.md @@ -6,7 +6,7 @@ Fundamental difference from CommonJS: - [`package.json`](./package.json) has `"type": "module"` attribute. - [`tsconfig.json`](./tsconfig.json) outputs in `esnext` format. -- Imports [must](https://nodejs.org/api/esm.html#esm_mandatory_file_extensions) include the `.js` file extension. +- Imports [must](https://nodejs.org/api/esm.html#esm_mandatory_file_extensions) include the `.js` or `.ts` file extension. ### Running this sample @@ -18,5 +18,5 @@ Fundamental difference from CommonJS: The Workflow should return: ``` -Hello, Temporal! +Hello World! ``` diff --git a/fetch-esm/package.json b/fetch-esm/package.json index 8efb5cd5..ce02b13e 100644 --- a/fetch-esm/package.json +++ b/fetch-esm/package.json @@ -11,8 +11,9 @@ "lint": "eslint .", "start": "tsx src/worker.ts", "start.watch": "tsx watch src/worker.ts", - "workflow": "tsx src/client-hello.ts", - "workflow-fetch": "tsx src/client-fetch.ts" + "workflow": "tsx src/client-fetch.ts", + "workflow-fetch": "tsx src/client-fetch.ts", + "workflow-local": "tsx src/client-local.ts" }, "dependencies": { "@temporalio/activity": "^1.13.2", @@ -33,7 +34,6 @@ "eslint-config-prettier": "^9.1.0", "eslint-plugin-deprecation": "^3.0.0", "node-fetch": "^3.0.0", - "nodemon": "^3.1.7", "prettier": "^3.4.2", "tsx": "^4.20.6", "typescript": "^5.6.3" diff --git a/fetch-esm/src/activities.ts b/fetch-esm/src/activities.ts index 7ed85f88..378e5b69 100644 --- a/fetch-esm/src/activities.ts +++ b/fetch-esm/src/activities.ts @@ -5,7 +5,7 @@ import fetch from 'node-fetch'; import { ApplicationFailure } from '@temporalio/common'; export async function greetHTTP(name: string): Promise { - const response = await fetch('http://httpbin.org.notfound/get?greeting=Hello'); + const response = await fetch('http://httpbin.org/get?greeting=Hello'); if (!response.ok) { throw ApplicationFailure.retryable(`HTTP error! status: ${response.status}`); } @@ -13,6 +13,6 @@ export async function greetHTTP(name: string): Promise { return `${body.args.greeting}, ${name}!`; } -export async function greet(name: string): Promise { - return humanizeString(`Hello-World-And-Hello-${(name)}!`, { preserveCase: true }); +export async function greetLocal(name: string): Promise { + return humanizeString(`Hello-World-And-Hello-${name}!`, { preserveCase: true }); } diff --git a/fetch-esm/src/client-hello.ts b/fetch-esm/src/client-local.ts similarity index 82% rename from fetch-esm/src/client-hello.ts rename to fetch-esm/src/client-local.ts index 3b0d1eda..05997db1 100644 --- a/fetch-esm/src/client-hello.ts +++ b/fetch-esm/src/client-local.ts @@ -1,12 +1,12 @@ // @@@SNIPSTART typescript-esm-client import { Client, Connection } from '@temporalio/client'; import { loadClientConnectConfig } from '@temporalio/envconfig'; -import { exampleHello } from './workflows.ts'; +import { exampleLocal } from './workflows.ts'; const config = loadClientConnectConfig(); const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); -const result = await client.workflow.execute(exampleHello, { +const result = await client.workflow.execute(exampleLocal, { taskQueue: 'fetch-esm', workflowId: `my-business-id-${Date.now()}`, args: ['Wonderful-Temporal'], diff --git a/fetch-esm/src/workflows.ts b/fetch-esm/src/workflows.ts index c9160900..de1da517 100644 --- a/fetch-esm/src/workflows.ts +++ b/fetch-esm/src/workflows.ts @@ -3,13 +3,13 @@ import { proxyActivities } from '@temporalio/workflow'; // Only import the activity types import type * as activities from './activities.ts'; -const { greet } = proxyActivities({ +const { greetLocal } = proxyActivities({ scheduleToCloseTimeout: '5 seconds', }); // A variant of the preceding workflow that does not perform any HTTP requests -export async function exampleHello(name: string): Promise { - return await greet(name); +export async function exampleLocal(name: string): Promise { + return await greetLocal(name); } // @@@SNIPEND From 4fbdd0c33e3513c2aa1f1bb98c1cf2e38425c2bb Mon Sep 17 00:00:00 2001 From: James Watkins-Harvey Date: Tue, 18 Nov 2025 11:41:07 -0500 Subject: [PATCH 3/3] lock file --- pnpm-lock.yaml | 3 --- 1 file changed, 3 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index def30e18..9811508d 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1025,9 +1025,6 @@ importers: eslint-plugin-deprecation: specifier: ^3.0.0 version: 3.0.0(eslint@8.57.1)(typescript@5.7.3) - nodemon: - specifier: ^3.1.7 - version: 3.1.9 prettier: specifier: ^3.4.2 version: 3.4.2