@temporal-contract/testing@7.0.0
Minor Changes
-
dc4a0cd: Cross-project DNA alignment with amqp-contract (#301, #302, #303, #304).
Breaking — AsyncResult-returning creation (#301). The runtime factories now model creation failures on the
Errchannel instead of throwing, matching the org-wideTyped*.create()shape:TypedClient.create({ contract, client, interceptors? })→AsyncResult<TypedClient, TechnicalError>(single options object; surfaces a missing Schedule API and eager-connection failures viaconnection.ensureConnected).createWorker(options)→AsyncResult<Worker, TechnicalError>(bundling/connection failures modeled).TechnicalError(tag@temporal-contract/TechnicalError) is exported from@temporal-contract/contract/errorsand re-exported by client and worker.- Migration: deprecated throwing aliases
TypedClient.createOrThrow(contract, client)andcreateWorkerOrThrow(options)preserve the old behavior and will be removed in a future major.
Breaking — unified context model (#302).
declareActivitiesHandler's middleware option now takes a single middleware (compose chains withcomposeActivityMiddleware(...), outermost-first) instead of an array, andnexttakes an object patch:next({ context })extends the typed context flowing downstream (shallow-merged; bounded genericsTContextOut extends TContextInaccumulate acrosscomposeActivityMiddleware's overloads — amqp-contract's model).defineActivityMiddlewarepins a middleware's context types;EmptyContextis the empty seed.next({ input })replaces the positionalnext(input)substitution (still re-validated against the contract schema).createContextnow seeds the accumulated context;helpers.contextis the seed plus every middleware injection (an empty object when unconfigured, no longerundefined).- Client interceptors:
TypedClient.create({ interceptors })wrapsstartWorkflow/executeWorkflow/signalWithStartand handle-levelsignal/query/update, outermost-first, outside validation — patch args vianext({ input }), retry by callingnextagain, short-circuit by returning without callingnext. - The demesne
Layer.forkScoperecipe is documented as the recommendedcreateContextengine for scoped, resource-releasing contexts.
Testing — in-process story (#303). New
@temporal-contract/testing/time-skippingentry point: a Vitest fixture (itwith a worker-scopedtestEnv) pluscreateTimeSkippingEnvironment()wrapping Temporal's time-skippingTestWorkflowEnvironment— full contract-pipeline tests (validation, middleware, typed errors, rehydration) without Docker.@temporalio/testing ^1is a new peer dependency of the testing package.Consistency cleanup (#304).
activityOptionsondeclareWorkflowis now optional when every reachable activity carries contract-leveldefaultOptions(or anactivityOptionsByNameentry) — a descriptive declaration-time error lists uncovered activities otherwise. The direction-aware inference primitives (ClientInferInput/ClientInferOutput/WorkerInferInput/WorkerInferOutput) are centralized in@temporal-contract/contract(worker/client re-export them unchanged). The obsoletemigrating-to-neverthrowguide is removed, stale JSDoc fixed, and docs/examples adopt the composition-first rule (define resources first, then reference them indefineContract).