@trigger.dev/core 0.0.0-v3-prerelease-20240424094958 → 0.0.0-v3-decorators-20240424152300

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.
@@ -100,6 +100,10 @@ interface ProjectConfig {
100
100
  * Enable console logging while running the dev CLI. This will print out logs from console.log, console.warn, and console.error. By default all logs are sent to the trigger.dev backend, and not logged to the console.
101
101
  */
102
102
  enableConsoleLogging?: boolean;
103
+ /**
104
+ * Run before a task is executed, for all tasks. This is useful for setting up any global state that is needed for all tasks.
105
+ */
106
+ init?: (payload: unknown, params: InitFnParams) => void | Promise<void>;
103
107
  }
104
108
 
105
109
  type InitOutput = Record<string, any> | void | undefined;
@@ -100,6 +100,10 @@ interface ProjectConfig {
100
100
  * Enable console logging while running the dev CLI. This will print out logs from console.log, console.warn, and console.error. By default all logs are sent to the trigger.dev backend, and not logged to the console.
101
101
  */
102
102
  enableConsoleLogging?: boolean;
103
+ /**
104
+ * Run before a task is executed, for all tasks. This is useful for setting up any global state that is needed for all tasks.
105
+ */
106
+ init?: (payload: unknown, params: InitFnParams) => void | Promise<void>;
103
107
  }
104
108
 
105
109
  type InitOutput = Record<string, any> | void | undefined;
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import { T as TaskRunExecutionResult, B as BatchTaskRunExecutionResult, a as TaskRunError, b as TaskRunContext, R as RuntimeManager } from '../manager-M9GLDnhJ.mjs';
3
3
  export { h as TaskRun, c as TaskRunBuiltInError, d as TaskRunCustomErrorObject, f as TaskRunErrorCodes, p as TaskRunExecution, j as TaskRunExecutionAttempt, o as TaskRunExecutionBatch, k as TaskRunExecutionEnvironment, l as TaskRunExecutionOrganization, m as TaskRunExecutionProject, n as TaskRunExecutionQueue, q as TaskRunExecutionRetry, i as TaskRunExecutionTask, r as TaskRunFailedExecutionResult, g as TaskRunInternalError, e as TaskRunStringError, s as TaskRunSuccessfulExecutionResult } from '../manager-M9GLDnhJ.mjs';
4
- import { P as Prettify, C as Clock, a as ClockTime, T as TaskLogger, b as TaskCatalog, c as TaskMetadataWithFunctions, d as TriggerTracer } from '../catalog-A-D3UC6S.mjs';
5
- export { l as ClientToSharedQueueMessages, g as Config, r as Context, j as CoordinatorToPlatformMessages, n as CoordinatorToProdWorkerMessages, v as HandleErrorArgs, H as HandleErrorFnParams, w as HandleErrorFunction, t as HandleErrorModificationOptions, u as HandleErrorResult, q as InitFnParams, I as InitOutput, L as LogLevel, M as MiddlewareFnParams, k as PlatformToCoordinatorMessages, i as PlatformToProviderMessages, e as PostStartCauses, f as PreStopCauses, o as ProdWorkerSocketData, m as ProdWorkerToCoordinatorMessages, y as ProjectConfig, h as ProviderToPlatformMessages, x as RequireKeys, R as ResolvedConfig, p as RunFnParams, S as SharedQueueToClientMessages, s as SuccessFnParams, W as WaitReason } from '../catalog-A-D3UC6S.mjs';
4
+ import { P as Prettify, C as Clock, a as ClockTime, T as TaskLogger, b as TaskCatalog, c as TaskMetadataWithFunctions, d as TriggerTracer } from '../catalog-04wPlpvu.mjs';
5
+ export { l as ClientToSharedQueueMessages, g as Config, r as Context, j as CoordinatorToPlatformMessages, n as CoordinatorToProdWorkerMessages, v as HandleErrorArgs, H as HandleErrorFnParams, w as HandleErrorFunction, t as HandleErrorModificationOptions, u as HandleErrorResult, q as InitFnParams, I as InitOutput, L as LogLevel, M as MiddlewareFnParams, k as PlatformToCoordinatorMessages, i as PlatformToProviderMessages, e as PostStartCauses, f as PreStopCauses, o as ProdWorkerSocketData, m as ProdWorkerToCoordinatorMessages, y as ProjectConfig, h as ProviderToPlatformMessages, x as RequireKeys, R as ResolvedConfig, p as RunFnParams, S as SharedQueueToClientMessages, s as SuccessFnParams, W as WaitReason } from '../catalog-04wPlpvu.mjs';
6
6
  import { Attributes, Span } from '@opentelemetry/api';
7
7
  import { B as BackgroundWorkerProperties, T as TaskFileMetadata, a as TaskMetadataWithFilePath, R as RetryOptions } from '../messages-AriaDDm0.mjs';
8
8
  export { g as BackgroundWorkerClientMessages, f as BackgroundWorkerServerMessages, E as EnvironmentType, F as FixedWindowRateLimit, c as Machine, M as MachineCpu, b as MachineMemory, m as ProdChildToWorkerMessages, P as ProdTaskRunExecution, e as ProdTaskRunExecutionPayload, n as ProdWorkerToChildMessages, Q as QueueOptions, i as RateLimitOptions, S as SlidingWindowRateLimit, j as TaskMetadata, k as TaskMetadataFailedToParseData, d as TaskRunExecutionPayload, U as UncaughtExceptionMessage, l as childToWorkerMessages, h as clientWebsocketMessages, s as serverWebsocketMessages, w as workerToChildMessages } from '../messages-AriaDDm0.mjs';
@@ -1,8 +1,8 @@
1
1
  import { z } from 'zod';
2
2
  import { T as TaskRunExecutionResult, B as BatchTaskRunExecutionResult, a as TaskRunError, b as TaskRunContext, R as RuntimeManager } from '../manager-M9GLDnhJ.js';
3
3
  export { h as TaskRun, c as TaskRunBuiltInError, d as TaskRunCustomErrorObject, f as TaskRunErrorCodes, p as TaskRunExecution, j as TaskRunExecutionAttempt, o as TaskRunExecutionBatch, k as TaskRunExecutionEnvironment, l as TaskRunExecutionOrganization, m as TaskRunExecutionProject, n as TaskRunExecutionQueue, q as TaskRunExecutionRetry, i as TaskRunExecutionTask, r as TaskRunFailedExecutionResult, g as TaskRunInternalError, e as TaskRunStringError, s as TaskRunSuccessfulExecutionResult } from '../manager-M9GLDnhJ.js';
4
- import { P as Prettify, C as Clock, a as ClockTime, T as TaskLogger, b as TaskCatalog, c as TaskMetadataWithFunctions, d as TriggerTracer } from '../catalog-TAZd4-TP.js';
5
- export { l as ClientToSharedQueueMessages, g as Config, r as Context, j as CoordinatorToPlatformMessages, n as CoordinatorToProdWorkerMessages, v as HandleErrorArgs, H as HandleErrorFnParams, w as HandleErrorFunction, t as HandleErrorModificationOptions, u as HandleErrorResult, q as InitFnParams, I as InitOutput, L as LogLevel, M as MiddlewareFnParams, k as PlatformToCoordinatorMessages, i as PlatformToProviderMessages, e as PostStartCauses, f as PreStopCauses, o as ProdWorkerSocketData, m as ProdWorkerToCoordinatorMessages, y as ProjectConfig, h as ProviderToPlatformMessages, x as RequireKeys, R as ResolvedConfig, p as RunFnParams, S as SharedQueueToClientMessages, s as SuccessFnParams, W as WaitReason } from '../catalog-TAZd4-TP.js';
4
+ import { P as Prettify, C as Clock, a as ClockTime, T as TaskLogger, b as TaskCatalog, c as TaskMetadataWithFunctions, d as TriggerTracer } from '../catalog-huF1UvYY.js';
5
+ export { l as ClientToSharedQueueMessages, g as Config, r as Context, j as CoordinatorToPlatformMessages, n as CoordinatorToProdWorkerMessages, v as HandleErrorArgs, H as HandleErrorFnParams, w as HandleErrorFunction, t as HandleErrorModificationOptions, u as HandleErrorResult, q as InitFnParams, I as InitOutput, L as LogLevel, M as MiddlewareFnParams, k as PlatformToCoordinatorMessages, i as PlatformToProviderMessages, e as PostStartCauses, f as PreStopCauses, o as ProdWorkerSocketData, m as ProdWorkerToCoordinatorMessages, y as ProjectConfig, h as ProviderToPlatformMessages, x as RequireKeys, R as ResolvedConfig, p as RunFnParams, S as SharedQueueToClientMessages, s as SuccessFnParams, W as WaitReason } from '../catalog-huF1UvYY.js';
6
6
  import { Attributes, Span } from '@opentelemetry/api';
7
7
  import { B as BackgroundWorkerProperties, T as TaskFileMetadata, a as TaskMetadataWithFilePath, R as RetryOptions } from '../messages-AriaDDm0.js';
8
8
  export { g as BackgroundWorkerClientMessages, f as BackgroundWorkerServerMessages, E as EnvironmentType, F as FixedWindowRateLimit, c as Machine, M as MachineCpu, b as MachineMemory, m as ProdChildToWorkerMessages, P as ProdTaskRunExecution, e as ProdTaskRunExecutionPayload, n as ProdWorkerToChildMessages, Q as QueueOptions, i as RateLimitOptions, S as SlidingWindowRateLimit, j as TaskMetadata, k as TaskMetadataFailedToParseData, d as TaskRunExecutionPayload, U as UncaughtExceptionMessage, l as childToWorkerMessages, h as clientWebsocketMessages, s as serverWebsocketMessages, w as workerToChildMessages } from '../messages-AriaDDm0.js';
package/dist/v3/index.js CHANGED
@@ -5,13 +5,11 @@ var zodValidationError = require('zod-validation-error');
5
5
  var zod = require('zod');
6
6
  var async_hooks = require('async_hooks');
7
7
  var preciseDate = require('@google-cloud/precise-date');
8
- var nodePath = require('path');
9
8
  var apiLogs = require('@opentelemetry/api-logs');
10
9
  var humanizeDuration = require('humanize-duration');
11
10
 
12
11
  function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
13
12
 
14
- var nodePath__default = /*#__PURE__*/_interopDefault(nodePath);
15
13
  var humanizeDuration__default = /*#__PURE__*/_interopDefault(humanizeDuration);
16
14
 
17
15
  var __defProp = Object.defineProperty;
@@ -2291,6 +2289,8 @@ var ClockAPI = _ClockAPI;
2291
2289
 
2292
2290
  // src/v3/clock-api.ts
2293
2291
  var clock = ClockAPI.getInstance();
2292
+
2293
+ // src/v3/errors.ts
2294
2294
  function parseError(error) {
2295
2295
  if (error instanceof Error) {
2296
2296
  return {
@@ -2347,23 +2347,23 @@ function correctErrorStackTrace(stackTrace, projectDir, options) {
2347
2347
  ].filter(Boolean).join("\n");
2348
2348
  }
2349
2349
  __name(correctErrorStackTrace, "correctErrorStackTrace");
2350
+ var LINES_TO_IGNORE = [
2351
+ /ConsoleInterceptor/,
2352
+ /TriggerTracer/,
2353
+ /TaskExecutor/,
2354
+ /EXECUTE_TASK_RUN/,
2355
+ /@trigger.dev\/core/,
2356
+ /safeJsonProcess/,
2357
+ /__entryPoint.ts/
2358
+ ];
2350
2359
  function correctStackTraceLine(line, projectDir) {
2351
- const regex = /at (.*?) \(?file:\/\/(\/.*?\.ts):(\d+):(\d+)\)?/;
2352
- const match = regex.exec(line);
2353
- if (!match) {
2354
- return;
2355
- }
2356
- const [_, identifier, path, lineNum, colNum] = match;
2357
- if (!path) {
2358
- return;
2359
- }
2360
- if (nodePath__default.default.basename(path) === "__entryPoint.ts") {
2360
+ if (LINES_TO_IGNORE.some((regex) => regex.test(line))) {
2361
2361
  return;
2362
2362
  }
2363
- if (projectDir && !path.includes(projectDir)) {
2363
+ if (projectDir && !line.includes(projectDir)) {
2364
2364
  return;
2365
2365
  }
2366
- return line;
2366
+ return line.trim();
2367
2367
  }
2368
2368
  __name(correctStackTraceLine, "correctStackTraceLine");
2369
2369
  function groupTaskMetadataIssuesByTask(tasks, issues) {