@usejourney/core 0.1.3 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -28,6 +28,13 @@ declare const JourneyConfigSchema: z.ZodObject<{
28
28
  baseUrl: z.ZodOptional<z.ZodString>;
29
29
  runHistoryKeepCount: z.ZodDefault<z.ZodNumber>;
30
30
  tlsRejectUnauthorized: z.ZodDefault<z.ZodBoolean>;
31
+ /**
32
+ * Connect-phase budget (ms) covering DNS + TCP + TLS handshake. Distinct
33
+ * from the per-request timeout: that one wraps the whole fetch in an
34
+ * `AbortController`, while this one is an undici `Agent` option. Unset
35
+ * falls back to undici's 10s default; `0` disables the connect timeout.
36
+ */
37
+ connectTimeoutMs: z.ZodOptional<z.ZodNumber>;
31
38
  }, "strict", z.ZodTypeAny, {
32
39
  spec: string;
33
40
  generatedDir: string;
@@ -38,6 +45,7 @@ declare const JourneyConfigSchema: z.ZodObject<{
38
45
  name?: string | undefined;
39
46
  defaultEnvironment?: string | undefined;
40
47
  baseUrl?: string | undefined;
48
+ connectTimeoutMs?: number | undefined;
41
49
  }, {
42
50
  name?: string | undefined;
43
51
  spec?: string | undefined;
@@ -48,6 +56,7 @@ declare const JourneyConfigSchema: z.ZodObject<{
48
56
  baseUrl?: string | undefined;
49
57
  runHistoryKeepCount?: number | undefined;
50
58
  tlsRejectUnauthorized?: boolean | undefined;
59
+ connectTimeoutMs?: number | undefined;
51
60
  }>;
52
61
  type JourneyConfig = z.infer<typeof JourneyConfigSchema>;
53
62
  interface LoadedConfig {
@@ -400,7 +409,16 @@ interface HttpContext {
400
409
  subJourneyCache?: SubJourneyCache;
401
410
  /** Default TTL (ms) for sub-journey cache writes; per-call `cacheTtlMs` overrides. */
402
411
  subJourneyCacheTtlMs?: number;
412
+ /**
413
+ * Run-wide default request timeout (ms). Tri-state: `undefined` falls back
414
+ * to `DEFAULT_REQUEST_TIMEOUT_MS`; a number sets a custom default; `null`
415
+ * explicitly disables the default (no timeout). A step's own
416
+ * `timeoutMs` always overrides this.
417
+ */
418
+ defaultTimeoutMs?: number | null;
403
419
  }
420
+ /** Fallback request timeout (ms) when neither a step nor `HttpContext.defaultTimeoutMs` set one. */
421
+ declare const DEFAULT_REQUEST_TIMEOUT_MS = 60000;
404
422
  interface RequestSpec {
405
423
  method: HttpMethod;
406
424
  url: string;
@@ -697,4 +715,4 @@ type FetchResponse = Awaited<ReturnType<typeof globalThis.fetch>>;
697
715
  */
698
716
  declare function fetch$1(input: FetchInput, init?: FetchInit): Promise<FetchResponse>;
699
717
 
700
- export { AssertionError, type BuildRequestOptions, type CacheEntry, type CacheMode, type ConsoleLoggerOptions, DiskSubJourneyCache, type Endpoint, type EndpointDescriptor, type EndpointRef, type EntryJourneyOptions, type EnvValues, type Expectation, type GroupEndEvent, type GroupStartEvent, type HttpContext, type HttpMethod, type HttpResponse, type InvokeJourneyOptions, type JourneyConfig, JourneyConfigSchema, type JourneyDef, type JourneyHandle, type JourneyLogger, type JourneyOptions, type JourneyResult, type K6JourneyOptions, type LoadedConfig, type LogEvent, MemorySubJourneyCache, type PipelineNode, type PlannedNode, type RequestLog, type RequestSpec, type ResponseLog, type ResponseOf, type ReusableJourneyOptions, type RunEndEvent, type RunMeta, type RunPlannedEvent, type RunRecord, type RunStartEvent, type RunSummary, SECRET_HEADERS, type StepDef, type StepEndEvent, type StepOptions, type StepResult, type StepStartEvent, type SubJourneyCache, type SubJourneyCallDef, buildRequest, clearActiveEnvironment, clearRegistry, collectPipeline, collectSubPipeline, createConsoleLogger, createSubJourneyCache, describeError, env, execute, expect, fetch$1 as fetch, formatOpaqueBody, getCurrentCtx, getRegisteredJourneys, invokeJourney, isEndpointRef, isTextualContentType, journey, listEnvironments, listRuns, loadConfig, loadEnvironment, loggerFromEnv, maskHeaders, output, planJourney, pruneRuns, readRun, resolveBaseUrl, resolveConfigPaths, resolveUrl, runAllRegistered, runJourney, setActiveEnvironment, step, subJourneyCacheKey, tryEnv, writeRun };
718
+ export { AssertionError, type BuildRequestOptions, type CacheEntry, type CacheMode, type ConsoleLoggerOptions, DEFAULT_REQUEST_TIMEOUT_MS, DiskSubJourneyCache, type Endpoint, type EndpointDescriptor, type EndpointRef, type EntryJourneyOptions, type EnvValues, type Expectation, type GroupEndEvent, type GroupStartEvent, type HttpContext, type HttpMethod, type HttpResponse, type InvokeJourneyOptions, type JourneyConfig, JourneyConfigSchema, type JourneyDef, type JourneyHandle, type JourneyLogger, type JourneyOptions, type JourneyResult, type K6JourneyOptions, type LoadedConfig, type LogEvent, MemorySubJourneyCache, type PipelineNode, type PlannedNode, type RequestLog, type RequestSpec, type ResponseLog, type ResponseOf, type ReusableJourneyOptions, type RunEndEvent, type RunMeta, type RunPlannedEvent, type RunRecord, type RunStartEvent, type RunSummary, SECRET_HEADERS, type StepDef, type StepEndEvent, type StepOptions, type StepResult, type StepStartEvent, type SubJourneyCache, type SubJourneyCallDef, buildRequest, clearActiveEnvironment, clearRegistry, collectPipeline, collectSubPipeline, createConsoleLogger, createSubJourneyCache, describeError, env, execute, expect, fetch$1 as fetch, formatOpaqueBody, getCurrentCtx, getRegisteredJourneys, invokeJourney, isEndpointRef, isTextualContentType, journey, listEnvironments, listRuns, loadConfig, loadEnvironment, loggerFromEnv, maskHeaders, output, planJourney, pruneRuns, readRun, resolveBaseUrl, resolveConfigPaths, resolveUrl, runAllRegistered, runJourney, setActiveEnvironment, step, subJourneyCacheKey, tryEnv, writeRun };
package/dist/index.js CHANGED
@@ -78,7 +78,14 @@ var JourneyConfigSchema = z.object({
78
78
  defaultEnvironment: z.string().min(1).optional(),
79
79
  baseUrl: z.string().url().optional(),
80
80
  runHistoryKeepCount: z.number().int().min(0).default(20),
81
- tlsRejectUnauthorized: z.boolean().default(true)
81
+ tlsRejectUnauthorized: z.boolean().default(true),
82
+ /**
83
+ * Connect-phase budget (ms) covering DNS + TCP + TLS handshake. Distinct
84
+ * from the per-request timeout: that one wraps the whole fetch in an
85
+ * `AbortController`, while this one is an undici `Agent` option. Unset
86
+ * falls back to undici's 10s default; `0` disables the connect timeout.
87
+ */
88
+ connectTimeoutMs: z.number().int().min(0).optional()
82
89
  }).strict();
83
90
  function resolveRelative(projectDir, value) {
84
91
  return isAbsolute(value) ? value : join2(projectDir, value);
@@ -392,6 +399,7 @@ function loggerFromEnv(env2 = process.env) {
392
399
  }
393
400
 
394
401
  // src/http.ts
402
+ var DEFAULT_REQUEST_TIMEOUT_MS = 6e4;
395
403
  function resolveUrl(endpoint, ctx, params, query) {
396
404
  const base = isEndpointRef(endpoint) ? ctx.baseUrl : endpoint.baseUrl ?? ctx.baseUrl;
397
405
  if (!base) {
@@ -436,7 +444,8 @@ function buildRequest(opts, ctx) {
436
444
  }
437
445
  const spec = { method: opts.endpoint.method, url, headers };
438
446
  if (hasBody) spec.body = opts.body;
439
- if (opts.timeoutMs !== void 0) spec.timeoutMs = opts.timeoutMs;
447
+ const resolvedTimeout = opts.timeoutMs !== void 0 ? opts.timeoutMs : ctx.defaultTimeoutMs === null ? void 0 : ctx.defaultTimeoutMs ?? DEFAULT_REQUEST_TIMEOUT_MS;
448
+ if (resolvedTimeout !== void 0) spec.timeoutMs = resolvedTimeout;
440
449
  return spec;
441
450
  }
442
451
  function lower(h) {
@@ -1189,6 +1198,7 @@ function bodyForLog(body) {
1189
1198
  import { z as z2 } from "zod";
1190
1199
  export {
1191
1200
  AssertionError,
1201
+ DEFAULT_REQUEST_TIMEOUT_MS,
1192
1202
  DiskSubJourneyCache,
1193
1203
  JourneyConfigSchema,
1194
1204
  MemorySubJourneyCache,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usejourney/core",
3
- "version": "0.1.3",
3
+ "version": "0.1.5",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",