From fd6627cd65d83bbee7e27585a012d7bdd5252076 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Tue, 11 Nov 2025 20:28:00 -0800 Subject: [PATCH 1/3] update samples to use env config to configure clients --- .../package.json | 1 + .../src/client.ts | 4 +++- activities-dependency-injection/package.json | 1 + activities-dependency-injection/src/client.ts | 7 +++++-- activities-examples/package.json | 1 + activities-examples/src/client.ts | 7 +++++-- child-workflows/package.json | 1 + child-workflows/src/client.ts | 7 +++++-- continue-as-new/package.json | 1 + continue-as-new/src/client.ts | 7 +++++-- cron-workflows/package.json | 1 + cron-workflows/src/client.ts | 11 ++++++++--- custom-logger/package.json | 1 + custom-logger/src/client.ts | 12 ++++-------- dsl-interpreter/package.json | 1 + dsl-interpreter/src/client.ts | 7 +++++-- eager-workflow-start/package.json | 1 + eager-workflow-start/src/run.ts | 4 +++- early-return/package.json | 1 + early-return/src/run-workflow.ts | 4 +++- ejson/package.json | 1 + ejson/src/client.ts | 6 +++++- empty/package.json | 1 + empty/src/client.ts | 16 ++++------------ encryption/package.json | 1 + encryption/src/client.ts | 6 +++++- expense/package.json | 1 + expense/src/clients/approve.ts | 7 +++++-- expense/src/clients/timeout.ts | 7 +++++-- fetch-esm/package.json | 1 + fetch-esm/src/client.ts | 7 +++++-- grpc-calls/package.json | 1 + grpc-calls/src/client.ts | 4 +++- hello-world-js/package.json | 1 + hello-world-js/src/client.js | 11 +++-------- hello-world/package.json | 1 + hello-world/src/client.ts | 16 ++++------------ interceptors-opentelemetry/package.json | 1 + interceptors-opentelemetry/src/client.ts | 5 +++-- message-passing/execute-update/package.json | 1 + message-passing/execute-update/src/client.ts | 4 +++- message-passing/introduction/package.json | 1 + message-passing/introduction/src/client.ts | 4 +++- .../safe-message-handlers/package.json | 1 + .../safe-message-handlers/src/client.ts | 4 +++- mutex/package.json | 1 + mutex/src/start-test-workflow.ts | 5 +++-- nextjs-ecommerce-oneclick/package.json | 1 + .../temporal/src/client.ts | 7 +++---- nexus-cancellation/package.json | 1 + nexus-cancellation/src/starter.ts | 4 +++- nexus-hello/package.json | 1 + nexus-hello/src/starter.ts | 4 +++- patching-api/package.json | 1 + patching-api/src/client.ts | 7 +++++-- pnpm-lock.yaml | 18 ++++++++++++++++++ polling/infrequent/package.json | 1 + polling/infrequent/src/client.ts | 4 +++- production/package.json | 1 + production/src/client.ts | 12 ++++-------- protobufs/package.json | 1 + protobufs/src/client.ts | 6 +++++- query-subscriptions/package.json | 1 + query-subscriptions/src/subscribe.ts | 7 +++++-- saga/package.json | 1 + saga/src/client.ts | 9 ++++----- schedules/package.json | 1 + schedules/src/start-schedule.ts | 7 ++++--- scratchpad/package.json | 1 + scratchpad/scratchpad.ts | 4 +++- search-attributes/package.json | 1 + search-attributes/src/client.ts | 7 +++++-- signals-queries/package.json | 1 + signals-queries/src/cancel-workflow.ts | 7 +++++-- signals-queries/src/query-workflow.ts | 7 +++++-- signals-queries/src/signal-workflow.ts | 7 +++++-- signals-queries/src/start-workflow.ts | 7 +++++-- sinks/package.json | 1 + sinks/src/client.ts | 12 ++++-------- sleep-for-days/package.json | 1 + sleep-for-days/src/client.ts | 4 +++- snippets/package.json | 1 + snippets/src/client.ts | 11 ++++++++--- state/package.json | 1 + state/src/cancel-workflow.ts | 7 +++++-- state/src/query-workflow.ts | 7 +++++-- state/src/signal-workflow.ts | 7 +++++-- state/src/start-workflow.ts | 7 +++++-- timer-examples/package.json | 1 + timer-examples/src/clients/fast.ts | 7 +++++-- timer-examples/src/clients/slow.ts | 7 +++++-- timer-examples/src/clients/updating-timer.ts | 7 +++++-- timer-progress/package.json | 1 + timer-progress/src/client.ts | 7 +++++-- vscode-debugger/package.json | 1 + vscode-debugger/src/client.ts | 7 +++++-- worker-specific-task-queues/package.json | 1 + worker-specific-task-queues/src/client.ts | 4 +++- worker-versioning/package.json | 1 + worker-versioning/src/app.ts | 7 +++++-- 100 files changed, 298 insertions(+), 144 deletions(-) diff --git a/activities-cancellation-heartbeating/package.json b/activities-cancellation-heartbeating/package.json index 5e1e375e..092cbda0 100644 --- a/activities-cancellation-heartbeating/package.json +++ b/activities-cancellation-heartbeating/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/activities-cancellation-heartbeating/src/client.ts b/activities-cancellation-heartbeating/src/client.ts index b7146f52..1d97f3ab 100644 --- a/activities-cancellation-heartbeating/src/client.ts +++ b/activities-cancellation-heartbeating/src/client.ts @@ -1,9 +1,11 @@ import { Connection, Client, WorkflowFailedError, CancelledFailure } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { runCancellableActivity } from './workflows'; import { setTimeout } from 'timers/promises'; async function run() { - const connection = await Connection.connect(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); const handle = await client.workflow.start(runCancellableActivity, { diff --git a/activities-dependency-injection/package.json b/activities-dependency-injection/package.json index ee5f6137..30f8f15e 100644 --- a/activities-dependency-injection/package.json +++ b/activities-dependency-injection/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/activities-dependency-injection/src/client.ts b/activities-dependency-injection/src/client.ts index 75cf5531..c118b37d 100644 --- a/activities-dependency-injection/src/client.ts +++ b/activities-dependency-injection/src/client.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { dependencyWF } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const result = await client.workflow.execute(dependencyWF, { taskQueue: 'dependency-injection', diff --git a/activities-examples/package.json b/activities-examples/package.json index fcb4a601..a30b7222 100644 --- a/activities-examples/package.json +++ b/activities-examples/package.json @@ -29,6 +29,7 @@ "@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", "axios": "^0.28.0", diff --git a/activities-examples/src/client.ts b/activities-examples/src/client.ts index 18193f0e..2d054803 100644 --- a/activities-examples/src/client.ts +++ b/activities-examples/src/client.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { asyncActivityWorkflow, httpWorkflow } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); let result = await client.workflow.execute(httpWorkflow, { taskQueue: 'activities-examples', diff --git a/child-workflows/package.json b/child-workflows/package.json index dfafe234..8bbe77f6 100644 --- a/child-workflows/package.json +++ b/child-workflows/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/child-workflows/src/client.ts b/child-workflows/src/client.ts index 85b01d1f..acc5faf5 100644 --- a/child-workflows/src/client.ts +++ b/child-workflows/src/client.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { parentWorkflow } from './workflows'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const result = await client.workflow.execute(parentWorkflow, { taskQueue: 'child-workflows', diff --git a/continue-as-new/package.json b/continue-as-new/package.json index 88cc4bea..3bb93a25 100644 --- a/continue-as-new/package.json +++ b/continue-as-new/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/continue-as-new/src/client.ts b/continue-as-new/src/client.ts index 04b26b3b..d7426289 100644 --- a/continue-as-new/src/client.ts +++ b/continue-as-new/src/client.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { loopingWorkflow } from './workflows'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const result = await client.workflow.execute(loopingWorkflow, { taskQueue: 'continue-as-new', workflowId: 'loop-0' }); console.log(result); // Hello, Temporal! diff --git a/cron-workflows/package.json b/cron-workflows/package.json index e6875ccd..f4b6a573 100644 --- a/cron-workflows/package.json +++ b/cron-workflows/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/cron-workflows/src/client.ts b/cron-workflows/src/client.ts index 629e8b08..122c970c 100644 --- a/cron-workflows/src/client.ts +++ b/cron-workflows/src/client.ts @@ -1,11 +1,14 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { scheduledWorkflow } from './workflows'; // Save this to later terminate or cancel this schedule const workflowId = 'my-schedule'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = await client.workflow.start(scheduledWorkflow, { taskQueue: 'cron-workflows', @@ -24,7 +27,9 @@ async function run() { // just for this demo - cancel the workflow on Ctrl+C process.on('SIGINT', async () => { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = client.workflow.getHandle(workflowId); await handle.cancel(); diff --git a/custom-logger/package.json b/custom-logger/package.json index f0ea091d..804351d4 100644 --- a/custom-logger/package.json +++ b/custom-logger/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x", diff --git a/custom-logger/src/client.ts b/custom-logger/src/client.ts index 2a416eca..b6932a41 100644 --- a/custom-logger/src/client.ts +++ b/custom-logger/src/client.ts @@ -1,16 +1,12 @@ import { nanoid } from 'nanoid'; import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { logSampleWorkflow } from './workflows'; async function run() { - const connection = await Connection.connect(); // Connect to localhost with default ConnectionOptions. - // In production, pass options to the Connection constructor to configure TLS and other settings. - // This is optional but we leave this here to remind you there is a gRPC connection being established. - - const client = new Client({ - connection, - // In production you will likely specify `namespace` here; it is 'default' if omitted - }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); // Invoke the `logSampleWorkflow` Workflow, only resolved when the workflow completes await client.workflow.execute(logSampleWorkflow, { diff --git a/dsl-interpreter/package.json b/dsl-interpreter/package.json index 3be10bab..b81b54d3 100644 --- a/dsl-interpreter/package.json +++ b/dsl-interpreter/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "js-yaml": "^4.1.0" diff --git a/dsl-interpreter/src/client.ts b/dsl-interpreter/src/client.ts index cda4beab..4435cc26 100644 --- a/dsl-interpreter/src/client.ts +++ b/dsl-interpreter/src/client.ts @@ -1,4 +1,5 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { DSLInterpreter, DSL } from './workflows'; import yaml from 'js-yaml'; import fs from 'fs'; @@ -23,7 +24,9 @@ async function run() { if (path) { dslInput = yaml.load((await fs.promises.readFile(path)).toString()) as DSL; } - const client = new Client(); // remember to configure Connection for production + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); // Invoke the `DSLInterpreter` Workflow, only resolved when the workflow completes const result = await client.workflow.execute(DSLInterpreter, { diff --git a/eager-workflow-start/package.json b/eager-workflow-start/package.json index ebc71c56..9689016d 100644 --- a/eager-workflow-start/package.json +++ b/eager-workflow-start/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/eager-workflow-start/src/run.ts b/eager-workflow-start/src/run.ts index 983599a2..d0d751b9 100644 --- a/eager-workflow-start/src/run.ts +++ b/eager-workflow-start/src/run.ts @@ -1,12 +1,14 @@ import { Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { eagerWorkflow } from './workflows'; import { nanoid } from 'nanoid'; import { NativeConnection, Worker } from '@temporalio/worker'; import * as activities from './activities'; async function run() { + const config = loadClientConnectConfig(); // Note that the client and worker share the same native connection and run in the same process. - const sharedNativeConnection = await NativeConnection.connect({ address: 'localhost:7233' }); + const sharedNativeConnection = await NativeConnection.connect(config.connectionOptions); const client = new Client({ connection: sharedNativeConnection, diff --git a/early-return/package.json b/early-return/package.json index 65546acd..af72e721 100644 --- a/early-return/package.json +++ b/early-return/package.json @@ -23,6 +23,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/early-return/src/run-workflow.ts b/early-return/src/run-workflow.ts index e7bad5a6..200d5982 100644 --- a/early-return/src/run-workflow.ts +++ b/early-return/src/run-workflow.ts @@ -1,4 +1,5 @@ import { Connection, Client, WithStartWorkflowOperation } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { transactionWorkflow } from './workflows'; import { getTransactionConfirmation } from './shared'; @@ -21,7 +22,8 @@ async function runTransactionWorkflow(transactionID: string, client: Client) { } async function main() { - const connection = await Connection.connect(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); const transactionID = process.argv[2] || 'my-transaction-id'; await runTransactionWorkflow(transactionID, client); diff --git a/ejson/package.json b/ejson/package.json index 2b912a6c..0f781a14 100644 --- a/ejson/package.json +++ b/ejson/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/common": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", diff --git a/ejson/src/client.ts b/ejson/src/client.ts index 4a7ae184..a3d380a0 100644 --- a/ejson/src/client.ts +++ b/ejson/src/client.ts @@ -1,11 +1,15 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { v4 as uuid } from 'uuid'; import type { Result, User } from './types'; import { example } from './workflows'; async function run() { + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); // @@@SNIPSTART typescript-ejson-client-setup const client = new Client({ + connection, dataConverter: { payloadConverterPath: require.resolve('./payload-converter') }, }); // @@@SNIPEND diff --git a/empty/package.json b/empty/package.json index 36b5b40a..882de7ac 100644 --- a/empty/package.json +++ b/empty/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/empty/src/client.ts b/empty/src/client.ts index 189dea03..0a97f8fc 100644 --- a/empty/src/client.ts +++ b/empty/src/client.ts @@ -1,5 +1,6 @@ // @@@SNIPSTART typescript-hello-client import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { nanoid } from 'nanoid'; import { TASK_QUEUE_NAME } from './shared'; @@ -7,18 +8,9 @@ import { TASK_QUEUE_NAME } from './shared'; import { YOUR_WORKFLOW } from './workflows'; async function run() { - // Connect to the default Server location - const connection = await Connection.connect({ address: 'localhost:7233' }); - // In production, pass options to configure TLS and other settings: - // { - // address: 'foo.bar.tmprl.cloud', - // tls: {} - // } - - const client = new Client({ - connection, - // namespace: 'foo.bar', // connects to 'default' namespace if not specified - }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = await client.workflow.start(YOUR_WORKFLOW, { taskQueue: TASK_QUEUE_NAME, diff --git a/encryption/package.json b/encryption/package.json index 82409d5e..e6caa51f 100644 --- a/encryption/package.json +++ b/encryption/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/common": "^1.13.2", "@temporalio/proto": "^1.13.2", "@temporalio/worker": "^1.13.2", diff --git a/encryption/src/client.ts b/encryption/src/client.ts index 6f222634..6c8274ef 100644 --- a/encryption/src/client.ts +++ b/encryption/src/client.ts @@ -1,11 +1,15 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { v4 as uuid } from 'uuid'; import { getDataConverter } from './data-converter'; import { example } from './workflows'; async function run() { + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); // @@@SNIPSTART typescript-encryption-client const client = new Client({ + connection, dataConverter: await getDataConverter(), }); diff --git a/expense/package.json b/expense/package.json index 89e0b5f5..b411b0b7 100644 --- a/expense/package.json +++ b/expense/package.json @@ -27,6 +27,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "@temporalio/common": "^1.13.2", diff --git a/expense/src/clients/approve.ts b/expense/src/clients/approve.ts index 00217ad0..a8a3e40c 100644 --- a/expense/src/clients/approve.ts +++ b/expense/src/clients/approve.ts @@ -1,9 +1,12 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { expense, approveSignal } from '../workflows'; import { setTimeout } from 'timers/promises'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const expenseId = 'my-business-id'; const handle = await client.workflow.start(expense, { diff --git a/expense/src/clients/timeout.ts b/expense/src/clients/timeout.ts index 42d94584..36696870 100644 --- a/expense/src/clients/timeout.ts +++ b/expense/src/clients/timeout.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { expense } from '../workflows'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const expenseId = 'my-business-id'; const result = await client.workflow.execute(expense, { diff --git a/fetch-esm/package.json b/fetch-esm/package.json index 7867d334..91722bda 100644 --- a/fetch-esm/package.json +++ b/fetch-esm/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/fetch-esm/src/client.ts b/fetch-esm/src/client.ts index 60167c71..890b6a21 100644 --- a/fetch-esm/src/client.ts +++ b/fetch-esm/src/client.ts @@ -1,8 +1,11 @@ // @@@SNIPSTART typescript-esm-client -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { example } from './workflows.js'; -const client = new Client(); +const config = loadClientConnectConfig(); +const connection = await Connection.connect(config.connectionOptions); +const client = new Client({ connection }); const result = await client.workflow.execute(example, { taskQueue: 'fetch-esm', workflowId: 'my-business-id', diff --git a/grpc-calls/package.json b/grpc-calls/package.json index 7954d049..a7bed332 100644 --- a/grpc-calls/package.json +++ b/grpc-calls/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/common": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", diff --git a/grpc-calls/src/client.ts b/grpc-calls/src/client.ts index f95b7135..31ca19a8 100644 --- a/grpc-calls/src/client.ts +++ b/grpc-calls/src/client.ts @@ -1,4 +1,5 @@ import { Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { defaultPayloadConverter } from '@temporalio/common'; import { nanoid } from 'nanoid'; import { setTimeout } from 'timers/promises'; @@ -6,7 +7,8 @@ import { setTimeout } from 'timers/promises'; async function run() { const workflowId = 'workflow-' + nanoid(); const requestId = 'request-' + nanoid(); - const connection = await Connection.connect(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); // // normal way of starting a Workflow, with a Client // const client = new Client({ connection }); diff --git a/hello-world-js/package.json b/hello-world-js/package.json index 41252a4c..2db6fcf5 100644 --- a/hello-world-js/package.json +++ b/hello-world-js/package.json @@ -19,6 +19,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/hello-world-js/src/client.js b/hello-world-js/src/client.js index 1ef2dd88..3eac17f1 100644 --- a/hello-world-js/src/client.js +++ b/hello-world-js/src/client.js @@ -1,17 +1,12 @@ import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { example } from './workflows.js'; async function run() { - const connection = await Connection.connect({ - // // Connect to localhost with default ConnectionOptions. - // // In production, pass options to the Connection constructor to configure TLS and other settings: - // address: 'foo.bar.tmprl.cloud', // as provisioned - // tls: {} // as provisioned - }); - + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection, - // namespace: 'default', // change if you have a different namespace }); // Invoke the `example` Workflow, only resolved when the workflow completes diff --git a/hello-world/package.json b/hello-world/package.json index 782ddd41..89501052 100644 --- a/hello-world/package.json +++ b/hello-world/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/hello-world/src/client.ts b/hello-world/src/client.ts index 902504d9..551c887b 100644 --- a/hello-world/src/client.ts +++ b/hello-world/src/client.ts @@ -1,21 +1,13 @@ // @@@SNIPSTART typescript-hello-client import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { example } from './workflows'; import { nanoid } from 'nanoid'; async function run() { - // Connect to the default Server location - const connection = await Connection.connect({ address: 'localhost:7233' }); - // In production, pass options to configure TLS and other settings: - // { - // address: 'foo.bar.tmprl.cloud', - // tls: {} - // } - - const client = new Client({ - connection, - // namespace: 'foo.bar', // connects to 'default' namespace if not specified - }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = await client.workflow.start(example, { taskQueue: 'hello-world', diff --git a/interceptors-opentelemetry/package.json b/interceptors-opentelemetry/package.json index d470f3f3..0eca6b04 100644 --- a/interceptors-opentelemetry/package.json +++ b/interceptors-opentelemetry/package.json @@ -36,6 +36,7 @@ "@opentelemetry/semantic-conventions": "^1.28.0", "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/interceptors-opentelemetry": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" diff --git a/interceptors-opentelemetry/src/client.ts b/interceptors-opentelemetry/src/client.ts index 647a5a81..5203a072 100644 --- a/interceptors-opentelemetry/src/client.ts +++ b/interceptors-opentelemetry/src/client.ts @@ -1,11 +1,12 @@ import { randomUUID } from 'crypto'; import { OpenTelemetryWorkflowClientInterceptor } from '@temporalio/interceptors-opentelemetry'; import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { example } from './workflows'; async function run() { - // Connect to localhost with default ConnectionOptions. - const connection = await Connection.connect(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); // Attach the OpenTelemetryWorkflowClientInterceptor to the client. const client = new Client({ diff --git a/message-passing/execute-update/package.json b/message-passing/execute-update/package.json index d24f06ef..49d05d38 100644 --- a/message-passing/execute-update/package.json +++ b/message-passing/execute-update/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/message-passing/execute-update/src/client.ts b/message-passing/execute-update/src/client.ts index f0563856..58102164 100644 --- a/message-passing/execute-update/src/client.ts +++ b/message-passing/execute-update/src/client.ts @@ -1,10 +1,12 @@ // @@@SNIPSTART typescript-update-client import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { counter, fetchAndAdd, done } from './workflows'; import { nanoid } from 'nanoid'; async function run() { - const connection = await Connection.connect({ address: 'localhost:7233' }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); const handle = await client.workflow.start(counter, { diff --git a/message-passing/introduction/package.json b/message-passing/introduction/package.json index 495e8345..806b978c 100644 --- a/message-passing/introduction/package.json +++ b/message-passing/introduction/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "async-mutex": "^0.5.0", diff --git a/message-passing/introduction/src/client.ts b/message-passing/introduction/src/client.ts index 3f1a3d0b..3e132de5 100644 --- a/message-passing/introduction/src/client.ts +++ b/message-passing/introduction/src/client.ts @@ -1,11 +1,13 @@ // @@@SNIPSTART typescript-message-passing-introduction import * as cl from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import * as greetingWorkflow from './workflows'; import { Language } from './workflows'; import { nanoid } from 'nanoid'; export async function run() { - const connection = await cl.Connection.connect({ address: 'localhost:7233' }); + const config = loadClientConnectConfig(); + const connection = await cl.Connection.connect(config.connectionOptions); const client = new cl.Client({ connection }); const handle = await client.workflow.start(greetingWorkflow.greetingWorkflow, { taskQueue: 'my-task-queue', diff --git a/message-passing/safe-message-handlers/package.json b/message-passing/safe-message-handlers/package.json index 43cbdb16..d6c7fabc 100644 --- a/message-passing/safe-message-handlers/package.json +++ b/message-passing/safe-message-handlers/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "async-mutex": "^0.5.0", diff --git a/message-passing/safe-message-handlers/src/client.ts b/message-passing/safe-message-handlers/src/client.ts index 8ba05a6c..46717ebc 100644 --- a/message-passing/safe-message-handlers/src/client.ts +++ b/message-passing/safe-message-handlers/src/client.ts @@ -1,10 +1,12 @@ import { Connection, Client, WorkflowHandle } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { nanoid } from 'nanoid'; import { clusterManagerWorkflow } from './workflows'; export async function startClusterManager(): Promise> { - const connection = await Connection.connect({ address: 'localhost:7233' }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); return client.workflow.start(clusterManagerWorkflow, { taskQueue: 'safe-message-handlers-task-queue', diff --git a/mutex/package.json b/mutex/package.json index df421e67..44399e44 100644 --- a/mutex/package.json +++ b/mutex/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/mutex/src/start-test-workflow.ts b/mutex/src/start-test-workflow.ts index 6c7a5517..8213c1b0 100644 --- a/mutex/src/start-test-workflow.ts +++ b/mutex/src/start-test-workflow.ts @@ -1,4 +1,5 @@ import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { oneAtATimeWorkflow } from './workflows'; import { nanoid } from 'nanoid'; @@ -8,8 +9,8 @@ if (!resourceId) { } async function run() { - const connection = await Connection.connect(); - + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); const workflowId = 'test-' + nanoid(); diff --git a/nextjs-ecommerce-oneclick/package.json b/nextjs-ecommerce-oneclick/package.json index 764f00aa..b7815f6d 100644 --- a/nextjs-ecommerce-oneclick/package.json +++ b/nextjs-ecommerce-oneclick/package.json @@ -21,6 +21,7 @@ "@tailwindcss/forms": "^0.3.3", "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "next": "latest", diff --git a/nextjs-ecommerce-oneclick/temporal/src/client.ts b/nextjs-ecommerce-oneclick/temporal/src/client.ts index aa575d84..2ffb3538 100644 --- a/nextjs-ecommerce-oneclick/temporal/src/client.ts +++ b/nextjs-ecommerce-oneclick/temporal/src/client.ts @@ -1,12 +1,11 @@ import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; const client: Client = makeClient(); function makeClient(): Client { - const connection = Connection.lazy({ - address: 'localhost:7233', - // In production, pass options to configure TLS and other settings. - }); + const config = loadClientConnectConfig(); + const connection = Connection.lazy(config.connectionOptions); return new Client({ connection }); } diff --git a/nexus-cancellation/package.json b/nexus-cancellation/package.json index ad5b9e25..8b741c57 100644 --- a/nexus-cancellation/package.json +++ b/nexus-cancellation/package.json @@ -26,6 +26,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/nexus": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", diff --git a/nexus-cancellation/src/starter.ts b/nexus-cancellation/src/starter.ts index eafb63e0..21b6d3f4 100644 --- a/nexus-cancellation/src/starter.ts +++ b/nexus-cancellation/src/starter.ts @@ -1,12 +1,14 @@ import { nanoid } from 'nanoid'; import { Connection, Client, WorkflowFailedError } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { cancellableCallerWorkflow, cancellableCallerWorkflowCancel } from './caller/workflows'; import { isCancellation } from '@temporalio/workflow'; async function run() { const callerTaskQueue = 'nexus-cancellation-caller-task-queue'; - const connection = await Connection.connect({ address: 'localhost:7233' }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection, namespace: 'my-caller-namespace', diff --git a/nexus-hello/package.json b/nexus-hello/package.json index 1aaa1632..82547a2e 100644 --- a/nexus-hello/package.json +++ b/nexus-hello/package.json @@ -26,6 +26,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/nexus": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", diff --git a/nexus-hello/src/starter.ts b/nexus-hello/src/starter.ts index 847b00b1..21a33403 100644 --- a/nexus-hello/src/starter.ts +++ b/nexus-hello/src/starter.ts @@ -1,12 +1,14 @@ import { nanoid } from 'nanoid'; import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { echoCallerWorkflow, helloCallerWorkflow } from './caller/workflows'; async function run() { const namespace = 'my-caller-namespace'; const callerTaskQueue = 'nexus-hello-caller-task-queue'; - const connection = await Connection.connect({ address: 'localhost:7233' }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection, namespace, diff --git a/patching-api/package.json b/patching-api/package.json index a8535ced..872e8e36 100644 --- a/patching-api/package.json +++ b/patching-api/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "axios": "0.28.0", diff --git a/patching-api/src/client.ts b/patching-api/src/client.ts index caf29e7d..aa088c78 100644 --- a/patching-api/src/client.ts +++ b/patching-api/src/client.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { myWorkflow, workflowId } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); await client.workflow.start(myWorkflow, { taskQueue: 'patching', workflowId }); } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d7929061..86cf76d2 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -138,6 +138,9 @@ importers: '@temporalio/common': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -5982,6 +5985,10 @@ packages: resolution: {integrity: sha512-zwYZqeWypi1YHTeoYwBYgIVmWNg4+/T+CCcOwtyNUvA25wim85p9JOCB9tKgG4e8Hu1Nptd7yEjPaZtLPmJjjg==} engines: {node: '>= 18.0.0'} + '@temporalio/envconfig@1.13.2': + resolution: {integrity: sha512-jq5K8PBMgHKXtjk7c6zocg+XRbwbhivWBhRq7xMZlniNd2Cb06UxxN7EVQ246KSjQc/soQcPrOTj3Xc/tjXH/w==} + engines: {node: '>= 18.0.0'} + '@temporalio/interceptors-opentelemetry@1.13.2': resolution: {integrity: sha512-2MHMYQNJngpW/DIgc0JxIocASloLhzvTouE/QM90G0jCZjcWHZlcTs+HhBlKcD+Ipl2Zq2QSeI1GXl4v9cd3yA==} engines: {node: '>= 18.0.0'} @@ -12683,6 +12690,10 @@ packages: resolution: {integrity: sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==} engines: {node: '>= 6.0.0', npm: '>= 3.0.0'} + smol-toml@1.4.2: + resolution: {integrity: sha512-rInDH6lCNiEyn3+hH8KVGFdbjc099j47+OSgbMrfDYX1CmXLfdKd7qi6IfcWj2wFxvSVkuI46M+wPGYfEOEj6g==} + engines: {node: '>= 18'} + sockjs@0.3.24: resolution: {integrity: sha512-GJgLTZ7vYb/JtPSSZ10hsOYIvEYsjbNU+zPdIHcUaWVNUEPivzxku31865sSSud0Da0W4lEeOPlmw93zLQchuQ==} @@ -17218,6 +17229,11 @@ snapshots: cargo-cp-artifact: 0.1.9 which: 4.0.0 + '@temporalio/envconfig@1.13.2': + dependencies: + '@temporalio/common': 1.13.2 + smol-toml: 1.4.2 + '@temporalio/interceptors-opentelemetry@1.13.2(@temporalio/common@1.13.2)(@temporalio/workflow@1.13.2)': dependencies: '@opentelemetry/api': 1.9.0 @@ -26096,6 +26112,8 @@ snapshots: smart-buffer@4.2.0: {} + smol-toml@1.4.2: {} + sockjs@0.3.24: dependencies: faye-websocket: 0.11.4 diff --git a/polling/infrequent/package.json b/polling/infrequent/package.json index df3cc675..6d6eff71 100644 --- a/polling/infrequent/package.json +++ b/polling/infrequent/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/polling/infrequent/src/client.ts b/polling/infrequent/src/client.ts index 4e91192d..6b5d1075 100644 --- a/polling/infrequent/src/client.ts +++ b/polling/infrequent/src/client.ts @@ -1,10 +1,12 @@ // @@@SNIPSTART typescript-polling-infrequent import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { greetingWorkflow } from './workflows'; import { nanoid } from 'nanoid'; async function run() { - const connection = await Connection.connect({ address: 'localhost:7233' }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); const handle = await client.workflow.start(greetingWorkflow, { diff --git a/production/package.json b/production/package.json index f3e92cde..50db4ab2 100644 --- a/production/package.json +++ b/production/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/production/src/client.ts b/production/src/client.ts index dc8d18af..8d5a8f25 100644 --- a/production/src/client.ts +++ b/production/src/client.ts @@ -1,15 +1,11 @@ import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { example } from './workflows'; async function run() { - const connection = await Connection.connect(); // Connect to localhost with default ConnectionOptions. - // In production, pass options to the Connection constructor to configure TLS and other settings. - // This is optional but we leave this here to remind you there is a gRPC connection being established. - - const client = new Client({ - connection, - // In production you will likely specify `namespace` here; it is 'default' if omitted - }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const result = await client.workflow.execute(example, { taskQueue: 'production-sample', diff --git a/protobufs/package.json b/protobufs/package.json index f2260d39..c183960e 100644 --- a/protobufs/package.json +++ b/protobufs/package.json @@ -27,6 +27,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/common": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", diff --git a/protobufs/src/client.ts b/protobufs/src/client.ts index d1c97a3b..f3a2456e 100644 --- a/protobufs/src/client.ts +++ b/protobufs/src/client.ts @@ -1,11 +1,15 @@ // @@@SNIPSTART typescript-protobuf-client -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { v4 as uuid } from 'uuid'; import { foo, ProtoResult } from '../protos/root'; import { example } from './workflows'; async function run() { + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ + connection, dataConverter: { payloadConverterPath: require.resolve('./payload-converter') }, }); diff --git a/query-subscriptions/package.json b/query-subscriptions/package.json index 56507617..ec2eb098 100644 --- a/query-subscriptions/package.json +++ b/query-subscriptions/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "immer": "^9.0.6", diff --git a/query-subscriptions/src/subscribe.ts b/query-subscriptions/src/subscribe.ts index 4c6a9769..8a68c80f 100644 --- a/query-subscriptions/src/subscribe.ts +++ b/query-subscriptions/src/subscribe.ts @@ -1,6 +1,7 @@ import Redis from 'ioredis'; import { applyPatches } from 'immer'; -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { State, counter } from './workflows'; import { Versioned } from './workflows/subscriptions'; import { taskQueue } from './env'; @@ -85,7 +86,9 @@ export class SubscriptionClient { } export async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const subsClient = new SubscriptionClient(client); const { workflowId } = await client.workflow.start(counter, { taskQueue, diff --git a/saga/package.json b/saga/package.json index 14dbdd52..fd5af741 100644 --- a/saga/package.json +++ b/saga/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "cuid": "^2.1.8" diff --git a/saga/src/client.ts b/saga/src/client.ts index 9baa33eb..d3fa9b2f 100644 --- a/saga/src/client.ts +++ b/saga/src/client.ts @@ -1,13 +1,12 @@ import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import cuid from 'cuid'; import * as Workflows from './types/workflow-commands'; import { openAccount as openAccountWorkflow } from './workflows'; async function run() { - const connection = await Connection.connect(); - const client = new Client({ - connection, - // In production you will likely specify `namespace` here; it is 'default' if omitted - }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); // workflow params const openAccount: Workflows.OpenAccount = { accountId: cuid(), diff --git a/schedules/package.json b/schedules/package.json index 3e305695..acac9c97 100644 --- a/schedules/package.json +++ b/schedules/package.json @@ -33,6 +33,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/schedules/src/start-schedule.ts b/schedules/src/start-schedule.ts index 4b0270fa..8145ff41 100644 --- a/schedules/src/start-schedule.ts +++ b/schedules/src/start-schedule.ts @@ -1,11 +1,12 @@ import { Connection, Client, ScheduleOverlapPolicy } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { reminder } from './workflows'; // @@@SNIPSTART typescript-create-a-scheduled-workflow async function run() { - const client = new Client({ - connection: await Connection.connect(), - }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); // https://typescript.temporal.io/api/classes/client.ScheduleClient#create const schedule = await client.schedule.create({ diff --git a/scratchpad/package.json b/scratchpad/package.json index 1ce59946..e806be24 100644 --- a/scratchpad/package.json +++ b/scratchpad/package.json @@ -21,6 +21,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/scratchpad/scratchpad.ts b/scratchpad/scratchpad.ts index 1200acc2..bcadda9e 100644 --- a/scratchpad/scratchpad.ts +++ b/scratchpad/scratchpad.ts @@ -1,6 +1,7 @@ import { proxyActivities, inWorkflowContext } from '@temporalio/workflow'; import { Connection, Client } from '@temporalio/client'; import { Worker, DefaultLogger, Runtime } from '@temporalio/worker'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; const workflowId = 'scratchpad'; const taskQueue = 'scratchpad'; @@ -38,7 +39,8 @@ async function main(): Promise { ignoreModules: ['@temporalio/client', '@temporalio/worker'], }, }); - const connection = await Connection.connect(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); await worker.runUntil(starter(client)); } diff --git a/search-attributes/package.json b/search-attributes/package.json index 45067f9e..ae3526ed 100644 --- a/search-attributes/package.json +++ b/search-attributes/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/common": "^1.13.2", "@temporalio/proto": "^1.13.2", "@temporalio/worker": "^1.13.2", diff --git a/search-attributes/src/client.ts b/search-attributes/src/client.ts index c1421f43..47f18a71 100644 --- a/search-attributes/src/client.ts +++ b/search-attributes/src/client.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { example } from './workflows'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); // @@@SNIPSTART typescript-search-attributes-client const handle = await client.workflow.start(example, { diff --git a/signals-queries/package.json b/signals-queries/package.json index 6b95d4ed..22a0b44d 100644 --- a/signals-queries/package.json +++ b/signals-queries/package.json @@ -27,6 +27,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/signals-queries/src/cancel-workflow.ts b/signals-queries/src/cancel-workflow.ts index a6ef545b..b773a314 100644 --- a/signals-queries/src/cancel-workflow.ts +++ b/signals-queries/src/cancel-workflow.ts @@ -1,7 +1,10 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = client.workflow.getHandle('unblock-or-cancel-0'); diff --git a/signals-queries/src/query-workflow.ts b/signals-queries/src/query-workflow.ts index f9e56838..89788aa7 100644 --- a/signals-queries/src/query-workflow.ts +++ b/signals-queries/src/query-workflow.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { isBlockedQuery } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = client.workflow.getHandle('unblock-or-cancel-0'); diff --git a/signals-queries/src/signal-workflow.ts b/signals-queries/src/signal-workflow.ts index 26712fcd..fb363a07 100644 --- a/signals-queries/src/signal-workflow.ts +++ b/signals-queries/src/signal-workflow.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { unblockSignal } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = client.workflow.getHandle('unblock-or-cancel-0'); diff --git a/signals-queries/src/start-workflow.ts b/signals-queries/src/start-workflow.ts index 2f098423..7bab1483 100644 --- a/signals-queries/src/start-workflow.ts +++ b/signals-queries/src/start-workflow.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { unblockOrCancel } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const _handle = await client.workflow.start(unblockOrCancel, { taskQueue: 'signals-queries', diff --git a/sinks/package.json b/sinks/package.json index 2d524ea5..bf0ddb72 100644 --- a/sinks/package.json +++ b/sinks/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/sinks/src/client.ts b/sinks/src/client.ts index e49c114f..88902d9f 100644 --- a/sinks/src/client.ts +++ b/sinks/src/client.ts @@ -1,15 +1,11 @@ import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { sinkWorkflow } from './workflows'; async function run() { - const connection = await Connection.connect(); // Connect to localhost with default ConnectionOptions. - // In production, pass options to the Connection constructor to configure TLS and other settings. - // This is optional but we leave this here to remind you there is a gRPC connection being established. - - const client = new Client({ - connection, - // In production you will likely specify `namespace` here; it is 'default' if omitted - }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); // Invoke the `example` Workflow, only resolved when the workflow completes const result = await client.workflow.execute(sinkWorkflow, { diff --git a/sleep-for-days/package.json b/sleep-for-days/package.json index 458ab9c1..f99c1970 100644 --- a/sleep-for-days/package.json +++ b/sleep-for-days/package.json @@ -25,6 +25,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/sleep-for-days/src/client.ts b/sleep-for-days/src/client.ts index 4d3b765e..190d0085 100644 --- a/sleep-for-days/src/client.ts +++ b/sleep-for-days/src/client.ts @@ -1,10 +1,12 @@ // @@@SNIPSTART typescript-hello-client import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { sleepForDays } from './workflows'; import { nanoid } from 'nanoid'; async function run() { - const connection = await Connection.connect({ address: 'localhost:7233' }); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); const handle = await client.workflow.start(sleepForDays, { diff --git a/snippets/package.json b/snippets/package.json index 6cc4cc50..b4a04168 100644 --- a/snippets/package.json +++ b/snippets/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "nanoid": "3.x" diff --git a/snippets/src/client.ts b/snippets/src/client.ts index b11ee7d8..5cb5e5f0 100644 --- a/snippets/src/client.ts +++ b/snippets/src/client.ts @@ -1,9 +1,12 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { example } from './workflows'; import { nanoid } from 'nanoid'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const workflowId = 'workflow-' + nanoid(); const taskQueue = 'snippets'; @@ -28,7 +31,9 @@ run().catch((err) => { }); async function _snippets() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const workflowId = 'workflow-' + nanoid(); const taskQueue = 'snippets'; diff --git a/state/package.json b/state/package.json index 3b0a2a8c..342dbe21 100644 --- a/state/package.json +++ b/state/package.json @@ -27,6 +27,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/state/src/cancel-workflow.ts b/state/src/cancel-workflow.ts index 910285f4..093d9ddb 100644 --- a/state/src/cancel-workflow.ts +++ b/state/src/cancel-workflow.ts @@ -1,7 +1,10 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = client.workflow.getHandle('state-id-0'); diff --git a/state/src/query-workflow.ts b/state/src/query-workflow.ts index a1ba3bc7..d3769207 100644 --- a/state/src/query-workflow.ts +++ b/state/src/query-workflow.ts @@ -1,9 +1,12 @@ // @@@SNIPSTART typescript-send-query -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { getValueQuery } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = client.workflow.getHandle('state-id-0'); const meaning = await handle.query(getValueQuery, 'meaning-of-life'); console.log({ meaning }); diff --git a/state/src/signal-workflow.ts b/state/src/signal-workflow.ts index 4c76002f..861201a8 100644 --- a/state/src/signal-workflow.ts +++ b/state/src/signal-workflow.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { setValueSignal } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = client.workflow.getHandle('state-id-0'); diff --git a/state/src/start-workflow.ts b/state/src/start-workflow.ts index b2b8d7e2..5216e20b 100644 --- a/state/src/start-workflow.ts +++ b/state/src/start-workflow.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { trackState } from './workflows'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const _handle = await client.workflow.start(trackState, { taskQueue: 'state', diff --git a/timer-examples/package.json b/timer-examples/package.json index 8a0af721..c40bfca4 100644 --- a/timer-examples/package.json +++ b/timer-examples/package.json @@ -28,6 +28,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "axios": "0.28.0", diff --git a/timer-examples/src/clients/fast.ts b/timer-examples/src/clients/fast.ts index 573dfde9..36ea18fd 100644 --- a/timer-examples/src/clients/fast.ts +++ b/timer-examples/src/clients/fast.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; import { processOrderWorkflow } from '../workflows'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); // Does *not* send email to `process.env.ADMIN_EMAIL` that order processing is slow const result = await client.workflow.execute(processOrderWorkflow, { diff --git a/timer-examples/src/clients/slow.ts b/timer-examples/src/clients/slow.ts index 86e9f7e9..3dfa632e 100644 --- a/timer-examples/src/clients/slow.ts +++ b/timer-examples/src/clients/slow.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; import { processOrderWorkflow } from '../workflows'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); // Sends email to `process.env.ADMIN_EMAIL` that order processing is slow const result = await client.workflow.execute(processOrderWorkflow, { diff --git a/timer-examples/src/clients/updating-timer.ts b/timer-examples/src/clients/updating-timer.ts index 5a1174aa..586715c9 100644 --- a/timer-examples/src/clients/updating-timer.ts +++ b/timer-examples/src/clients/updating-timer.ts @@ -1,8 +1,11 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; import { countdownWorkflow, setDeadlineSignal, timeLeftQuery } from '../workflows'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; async function run(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = await client.workflow.start(countdownWorkflow, { taskQueue: 'timer-examples', diff --git a/timer-progress/package.json b/timer-progress/package.json index 4a02742e..b42a85f7 100644 --- a/timer-progress/package.json +++ b/timer-progress/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" }, diff --git a/timer-progress/src/client.ts b/timer-progress/src/client.ts index 5f9d45ad..47750f42 100644 --- a/timer-progress/src/client.ts +++ b/timer-progress/src/client.ts @@ -1,9 +1,12 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { progress, getProgress } from './workflows'; import { setTimeout } from 'timers/promises'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = await client.workflow.start(progress, { taskQueue: 'timer-progress', workflowId: 'progress-0' }); diff --git a/vscode-debugger/package.json b/vscode-debugger/package.json index e09fbb60..d9946540 100644 --- a/vscode-debugger/package.json +++ b/vscode-debugger/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "waait": "^1.0.5" diff --git a/vscode-debugger/src/client.ts b/vscode-debugger/src/client.ts index 37cdecca..45ba5958 100644 --- a/vscode-debugger/src/client.ts +++ b/vscode-debugger/src/client.ts @@ -1,10 +1,13 @@ -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import crypto from 'node:crypto'; import wait from 'waait'; import { humanVerificationWorkflow, verifySignal } from './workflows'; async function run() { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); const handle = await client.workflow.start(humanVerificationWorkflow, { args: ['4 + 20 = 420'], diff --git a/worker-specific-task-queues/package.json b/worker-specific-task-queues/package.json index 5f197a44..cc7d75df 100644 --- a/worker-specific-task-queues/package.json +++ b/worker-specific-task-queues/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2", "uuid": "^8.3.2" diff --git a/worker-specific-task-queues/src/client.ts b/worker-specific-task-queues/src/client.ts index ca96aa25..66af6c81 100644 --- a/worker-specific-task-queues/src/client.ts +++ b/worker-specific-task-queues/src/client.ts @@ -1,8 +1,10 @@ import { Connection, Client } from '@temporalio/client'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; import { fileProcessingWorkflow } from './workflows'; async function run() { - const connection = await Connection.connect(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection }); await client.workflow.execute(fileProcessingWorkflow, { taskQueue: 'normal-task-queue', diff --git a/worker-versioning/package.json b/worker-versioning/package.json index bbf9fe69..11f0ee92 100644 --- a/worker-versioning/package.json +++ b/worker-versioning/package.json @@ -24,6 +24,7 @@ "dependencies": { "@temporalio/activity": "^1.13.2", "@temporalio/client": "^1.13.2", + "@temporalio/envconfig": "^1.13.2", "@temporalio/common": "^1.13.2", "@temporalio/worker": "^1.13.2", "@temporalio/workflow": "^1.13.2" diff --git a/worker-versioning/src/app.ts b/worker-versioning/src/app.ts index dd7dfada..f665584b 100644 --- a/worker-versioning/src/app.ts +++ b/worker-versioning/src/app.ts @@ -1,14 +1,17 @@ import { randomUUID } from 'crypto'; import { setTimeout as delay } from 'timers/promises'; -import { Client } from '@temporalio/client'; +import { Client, Connection } from '@temporalio/client'; import type { WorkflowHandle } from '@temporalio/client'; import { toCanonicalString, WorkerDeploymentVersion } from '@temporalio/common'; import { DEPLOYMENT_NAME, TASK_QUEUE } from './constants'; import { doNextSignal } from './workflows-base'; +import { loadClientConnectConfig } from '@temporalio/envconfig'; async function main(): Promise { - const client = new Client(); + const config = loadClientConnectConfig(); + const connection = await Connection.connect(config.connectionOptions); + const client = new Client({ connection }); console.info('Waiting for v1 worker to appear. Run `npm run worker1` in another terminal.'); await waitForWorkerAndMakeCurrent(client, '1.0'); From 24353ee9a96f9f10402e6c15549938e40a0cd875 Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Tue, 11 Nov 2025 20:32:07 -0800 Subject: [PATCH 2/3] update pnpm lock file --- pnpm-lock.yaml | 129 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 86cf76d2..15e9cd49 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -37,6 +37,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -86,6 +89,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -241,6 +247,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -290,6 +299,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -339,6 +351,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -388,6 +403,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -449,6 +467,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -504,6 +525,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -568,6 +592,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -632,6 +659,9 @@ importers: '@temporalio/common': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -693,6 +723,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -757,6 +790,9 @@ importers: '@temporalio/common': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/proto': specifier: ^1.13.2 version: 1.13.2 @@ -842,6 +878,9 @@ importers: '@temporalio/common': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -906,6 +945,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -1333,6 +1375,9 @@ importers: '@temporalio/common': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -1385,6 +1430,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -1446,6 +1494,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -1562,6 +1613,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/interceptors-opentelemetry': specifier: ^1.13.2 version: 1.13.2(@temporalio/common@1.13.2)(@temporalio/workflow@1.13.2) @@ -1614,6 +1668,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -1675,6 +1732,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -1739,6 +1799,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -1958,6 +2021,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2146,6 +2212,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2228,6 +2297,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/nexus': specifier: ^1.13.2 version: 1.13.2 @@ -2286,6 +2358,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/nexus': specifier: ^1.13.2 version: 1.13.2 @@ -2344,6 +2419,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2411,6 +2489,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2463,6 +2544,9 @@ importers: '@temporalio/common': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2536,6 +2620,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2594,6 +2681,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2649,6 +2739,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2698,6 +2791,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2750,6 +2846,9 @@ importers: '@temporalio/common': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/proto': specifier: ^1.13.2 version: 1.13.2 @@ -2802,6 +2901,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2851,6 +2953,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2900,6 +3005,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -2967,6 +3075,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -3019,6 +3130,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -3068,6 +3182,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -3147,6 +3264,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -3196,6 +3316,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -3248,6 +3371,9 @@ importers: '@temporalio/client': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) @@ -3306,6 +3432,9 @@ importers: '@temporalio/common': specifier: ^1.13.2 version: 1.13.2 + '@temporalio/envconfig': + specifier: ^1.13.2 + version: 1.13.2 '@temporalio/worker': specifier: ^1.13.2 version: 1.13.2(@swc/helpers@0.5.15) From 0fbb5bed7bc1a9c75694739aa8f656865116718b Mon Sep 17 00:00:00 2001 From: Thomas Hardy Date: Wed, 12 Nov 2025 11:26:03 -0800 Subject: [PATCH 3/3] add small comment --- custom-logger/src/client.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/custom-logger/src/client.ts b/custom-logger/src/client.ts index b6932a41..dab7abc0 100644 --- a/custom-logger/src/client.ts +++ b/custom-logger/src/client.ts @@ -4,6 +4,9 @@ import { loadClientConnectConfig } from '@temporalio/envconfig'; import { logSampleWorkflow } from './workflows'; async function run() { + // Load client configuration from config file. + // (see: https://docs.temporal.io/develop/environment-configuration) + // In production, you can configure TLS and other settings in your config file. const config = loadClientConnectConfig(); const connection = await Connection.connect(config.connectionOptions); const client = new Client({ connection });