@trigger.dev/core 3.0.0-beta.24 → 3.0.0-beta.25

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/v3/index.mjs CHANGED
@@ -753,7 +753,8 @@ var Config = z.object({
753
753
  RegexSchema
754
754
  ])).optional(),
755
755
  logLevel: z.string().optional(),
756
- enableConsoleLogging: z.boolean().optional()
756
+ enableConsoleLogging: z.boolean().optional(),
757
+ postInstall: z.string().optional()
757
758
  });
758
759
  var WaitReason = z.enum([
759
760
  "WAIT_FOR_DURATION",
@@ -2468,9 +2469,14 @@ function calculateAttributeValueLength(value) {
2468
2469
  __name(calculateAttributeValueLength, "calculateAttributeValueLength");
2469
2470
 
2470
2471
  // src/v3/utils/flattenAttributes.ts
2472
+ var NULL_SENTINEL = "$@null((";
2471
2473
  function flattenAttributes(obj, prefix) {
2472
2474
  const result = {};
2473
- if (!obj) {
2475
+ if (obj === void 0) {
2476
+ return result;
2477
+ }
2478
+ if (obj === null) {
2479
+ result[prefix || ""] = NULL_SENTINEL;
2474
2480
  return result;
2475
2481
  }
2476
2482
  if (typeof obj === "string") {
@@ -2486,13 +2492,17 @@ function flattenAttributes(obj, prefix) {
2486
2492
  return result;
2487
2493
  }
2488
2494
  for (const [key, value] of Object.entries(obj)) {
2489
- const newPrefix = `${prefix ? `${prefix}.` : ""}${key}`;
2495
+ const newPrefix = `${prefix ? `${prefix}.` : ""}${Array.isArray(obj) ? `[${key}]` : key}`;
2490
2496
  if (Array.isArray(value)) {
2491
2497
  for (let i = 0; i < value.length; i++) {
2492
2498
  if (typeof value[i] === "object" && value[i] !== null) {
2493
2499
  Object.assign(result, flattenAttributes(value[i], `${newPrefix}.[${i}]`));
2494
2500
  } else {
2495
- result[`${newPrefix}.[${i}]`] = value[i];
2501
+ if (value[i] === null) {
2502
+ result[`${newPrefix}.[${i}]`] = NULL_SENTINEL;
2503
+ } else {
2504
+ result[`${newPrefix}.[${i}]`] = value[i];
2505
+ }
2496
2506
  }
2497
2507
  }
2498
2508
  } else if (isRecord(value)) {
@@ -2500,6 +2510,8 @@ function flattenAttributes(obj, prefix) {
2500
2510
  } else {
2501
2511
  if (typeof value === "number" || typeof value === "string" || typeof value === "boolean") {
2502
2512
  result[newPrefix] = value;
2513
+ } else if (value === null) {
2514
+ result[newPrefix] = NULL_SENTINEL;
2503
2515
  }
2504
2516
  }
2505
2517
  }
@@ -2514,42 +2526,49 @@ function unflattenAttributes(obj) {
2514
2526
  if (typeof obj !== "object" || obj === null || Array.isArray(obj)) {
2515
2527
  return obj;
2516
2528
  }
2529
+ if (typeof obj === "object" && obj !== null && Object.keys(obj).length === 1 && Object.keys(obj)[0] === "") {
2530
+ return rehydrateNull(obj[""]);
2531
+ }
2532
+ if (Object.keys(obj).length === 0) {
2533
+ return;
2534
+ }
2517
2535
  const result = {};
2518
2536
  for (const [key, value] of Object.entries(obj)) {
2519
2537
  const parts = key.split(".").reduce((acc, part) => {
2520
- if (detectIsArrayIndex(part)) {
2521
- acc.push(part);
2538
+ if (part.includes("[")) {
2539
+ const subparts = part.split(/\[|\]/).filter((p) => p !== "");
2540
+ acc.push(...subparts);
2522
2541
  } else {
2523
- acc.push(...part.split(/\.\[(.*?)\]/).filter(Boolean));
2542
+ acc.push(part);
2524
2543
  }
2525
2544
  return acc;
2526
2545
  }, []);
2527
2546
  let current = result;
2528
2547
  for (let i = 0; i < parts.length - 1; i++) {
2529
2548
  const part = parts[i];
2530
- const isArray = detectIsArrayIndex(part);
2531
- const cleanPart = isArray ? part.substring(1, part.length - 1) : part;
2532
- const nextIsArray = detectIsArrayIndex(parts[i + 1]);
2533
- if (!current[cleanPart]) {
2534
- current[cleanPart] = nextIsArray ? [] : {};
2549
+ const nextPart = parts[i + 1];
2550
+ const isArray = /^\d+$/.test(nextPart);
2551
+ if (isArray && !Array.isArray(current[part])) {
2552
+ current[part] = [];
2553
+ } else if (!isArray && current[part] === void 0) {
2554
+ current[part] = {};
2535
2555
  }
2536
- current = current[cleanPart];
2556
+ current = current[part];
2537
2557
  }
2538
2558
  const lastPart = parts[parts.length - 1];
2539
- const cleanLastPart = detectIsArrayIndex(lastPart) ? parseInt(lastPart.substring(1, lastPart.length - 1), 10) : lastPart;
2540
- current[cleanLastPart] = value;
2559
+ current[lastPart] = rehydrateNull(value);
2560
+ }
2561
+ if (Object.keys(result).every((k) => /^\d+$/.test(k))) {
2562
+ const maxIndex = Math.max(...Object.keys(result).map((k) => parseInt(k)));
2563
+ const arrayResult = Array(maxIndex + 1);
2564
+ for (const key in result) {
2565
+ arrayResult[parseInt(key)] = result[key];
2566
+ }
2567
+ return arrayResult;
2541
2568
  }
2542
2569
  return result;
2543
2570
  }
2544
2571
  __name(unflattenAttributes, "unflattenAttributes");
2545
- function detectIsArrayIndex(key) {
2546
- const match = key.match(/^\[(\d+)\]$/);
2547
- if (match) {
2548
- return true;
2549
- }
2550
- return false;
2551
- }
2552
- __name(detectIsArrayIndex, "detectIsArrayIndex");
2553
2572
  function primitiveValueOrflattenedAttributes(obj, prefix) {
2554
2573
  if (typeof obj === "string" || typeof obj === "number" || typeof obj === "boolean" || obj === null || obj === void 0) {
2555
2574
  return obj;
@@ -2561,6 +2580,13 @@ function primitiveValueOrflattenedAttributes(obj, prefix) {
2561
2580
  return attributes;
2562
2581
  }
2563
2582
  __name(primitiveValueOrflattenedAttributes, "primitiveValueOrflattenedAttributes");
2583
+ function rehydrateNull(value) {
2584
+ if (value === NULL_SENTINEL) {
2585
+ return null;
2586
+ }
2587
+ return value;
2588
+ }
2589
+ __name(rehydrateNull, "rehydrateNull");
2564
2590
 
2565
2591
  // src/v3/logger/taskLogger.ts
2566
2592
  var _NoopTaskLogger = class _NoopTaskLogger {
@@ -3289,11 +3315,12 @@ async function createPacketAttributes(packet, dataKey, dataTypeKey) {
3289
3315
  try {
3290
3316
  const parsed = parse(packet.data);
3291
3317
  const jsonified = JSON.parse(JSON.stringify(parsed, safeReplacer));
3292
- return {
3318
+ const result = {
3293
3319
  ...flattenAttributes(jsonified, dataKey),
3294
3320
  [dataTypeKey]: "application/json"
3295
3321
  };
3296
- } catch {
3322
+ return result;
3323
+ } catch (e) {
3297
3324
  return;
3298
3325
  }
3299
3326
  case "application/store":
@@ -3399,6 +3426,6 @@ function safeJsonParse2(value) {
3399
3426
  }
3400
3427
  __name(safeJsonParse2, "safeJsonParse");
3401
3428
 
3402
- export { APIConnectionError, APIError, ApiClient, ApiClientManager, AuthenticationError, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BadRequestError, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CanceledRunResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConflictError, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateScheduleOptions, CreateUploadPayloadUrlResponseBody, DeletedScheduleObject, DeploymentErrorData, EnvironmentType, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, InternalServerError, ListScheduleOptions, ListSchedulesResult, Machine, MachineCpu, MachineMemory, NotFoundError, OFFLOAD_IO_PACKET_LENGTH_LIMIT, OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, OTEL_ATTRIBUTE_PER_LINK_COUNT_LIMIT, OTEL_LINK_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_EVENT_COUNT_LIMIT, OtherSpanEvent, PRIMARY_VARIANT, PermissionDeniedError, PlatformToCoordinatorMessages, PlatformToProviderMessages, PostStartCauses, PreStopCauses, ProdChildToWorkerMessages, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitError, RateLimitOptions, ReplayRunResponse, RetryOptions, ScheduleObject, ScheduledTaskPayload, SemanticInternalAttributes, SharedQueueToClientMessages, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskEventStyle, TaskFileMetadata, TaskMetadata, TaskMetadataFailedToParseData, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, TriggerTaskRequestBody, TriggerTaskResponse, TriggerTracer, UncaughtExceptionMessage, UnprocessableEntityError, UpdateScheduleOptions, WaitReason, WhoAmIResponseSchema, accessoryAttributes, apiClientManager, calculateNextRetryDelay, calculateResetAt2 as calculateResetAt, childToWorkerMessages, clientWebsocketMessages, clock, conditionallyExportPacket, conditionallyImportPacket, correctErrorStackTrace, createErrorTaskError, createPacketAttributes, createPacketAttributesAsJson, defaultFetchRetryOptions, defaultRetryOptions, detectDependencyVersion, eventFilterMatches, flattenAttributes, formatDuration, formatDurationInDays, formatDurationMilliseconds, formatDurationNanoseconds, groupTaskMetadataIssuesByTask, imposeAttributeLimits, isCancellationSpanEvent, isExceptionSpanEvent, logger, millisecondsToNanoseconds, nanosecondsToMilliseconds, omit, packetRequiresOffloading, parseError, parsePacket, prettyPrintPacket, primitiveValueOrflattenedAttributes, runtime, serverWebsocketMessages, stringPatternMatchers, stringifyIO, taskCatalog, taskContext, unflattenAttributes, workerToChildMessages };
3429
+ export { APIConnectionError, APIError, ApiClient, ApiClientManager, AuthenticationError, BackgroundWorkerClientMessages, BackgroundWorkerMetadata, BackgroundWorkerProperties, BackgroundWorkerServerMessages, BadRequestError, BatchTaskRunExecutionResult, BatchTriggerTaskRequestBody, BatchTriggerTaskResponse, CanceledRunResponse, CancellationSpanEvent, ClientToSharedQueueMessages, Config, ConflictError, CoordinatorToPlatformMessages, CoordinatorToProdWorkerMessages, CreateAuthorizationCodeResponseSchema, CreateBackgroundWorkerRequestBody, CreateBackgroundWorkerResponse, CreateScheduleOptions, CreateUploadPayloadUrlResponseBody, DeletedScheduleObject, DeploymentErrorData, EnvironmentType, EventFilter, ExceptionEventProperties, ExceptionSpanEvent, ExternalBuildData, FetchRetryBackoffStrategy, FetchRetryByStatusOptions, FetchRetryHeadersStrategy, FetchRetryOptions, FetchRetryStrategy, FetchTimeoutOptions, FixedWindowRateLimit, GetBatchResponseBody, GetDeploymentResponseBody, GetEnvironmentVariablesResponseBody, GetPersonalAccessTokenRequestSchema, GetPersonalAccessTokenResponseSchema, GetProjectEnvResponse, GetProjectResponseBody, GetProjectsResponseBody, ImageDetailsMetadata, InitializeDeploymentRequestBody, InitializeDeploymentResponseBody, InternalServerError, ListScheduleOptions, ListSchedulesResult, Machine, MachineCpu, MachineMemory, NULL_SENTINEL, NotFoundError, OFFLOAD_IO_PACKET_LENGTH_LIMIT, OTEL_ATTRIBUTE_PER_EVENT_COUNT_LIMIT, OTEL_ATTRIBUTE_PER_LINK_COUNT_LIMIT, OTEL_LINK_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_COUNT_LIMIT, OTEL_LOG_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT, OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT, OTEL_SPAN_EVENT_COUNT_LIMIT, OtherSpanEvent, PRIMARY_VARIANT, PermissionDeniedError, PlatformToCoordinatorMessages, PlatformToProviderMessages, PostStartCauses, PreStopCauses, ProdChildToWorkerMessages, ProdTaskRunExecution, ProdTaskRunExecutionPayload, ProdWorkerSocketData, ProdWorkerToChildMessages, ProdWorkerToCoordinatorMessages, ProviderToPlatformMessages, QueueOptions, RateLimitError, RateLimitOptions, ReplayRunResponse, RetryOptions, ScheduleObject, ScheduledTaskPayload, SemanticInternalAttributes, SharedQueueToClientMessages, SlidingWindowRateLimit, SpanEvent, SpanEvents, SpanMessagingEvent, StartDeploymentIndexingRequestBody, StartDeploymentIndexingResponseBody, TaskEventStyle, TaskFileMetadata, TaskMetadata, TaskMetadataFailedToParseData, TaskMetadataWithFilePath, TaskResource, TaskRun, TaskRunBuiltInError, TaskRunContext, TaskRunCustomErrorObject, TaskRunError, TaskRunErrorCodes, TaskRunExecution, TaskRunExecutionAttempt, TaskRunExecutionBatch, TaskRunExecutionEnvironment, TaskRunExecutionOrganization, TaskRunExecutionPayload, TaskRunExecutionProject, TaskRunExecutionQueue, TaskRunExecutionResult, TaskRunExecutionRetry, TaskRunExecutionTask, TaskRunFailedExecutionResult, TaskRunInternalError, TaskRunStringError, TaskRunSuccessfulExecutionResult, TriggerTaskRequestBody, TriggerTaskResponse, TriggerTracer, UncaughtExceptionMessage, UnprocessableEntityError, UpdateScheduleOptions, WaitReason, WhoAmIResponseSchema, accessoryAttributes, apiClientManager, calculateNextRetryDelay, calculateResetAt2 as calculateResetAt, childToWorkerMessages, clientWebsocketMessages, clock, conditionallyExportPacket, conditionallyImportPacket, correctErrorStackTrace, createErrorTaskError, createPacketAttributes, createPacketAttributesAsJson, defaultFetchRetryOptions, defaultRetryOptions, detectDependencyVersion, eventFilterMatches, flattenAttributes, formatDuration, formatDurationInDays, formatDurationMilliseconds, formatDurationNanoseconds, groupTaskMetadataIssuesByTask, imposeAttributeLimits, isCancellationSpanEvent, isExceptionSpanEvent, logger, millisecondsToNanoseconds, nanosecondsToMilliseconds, omit, packetRequiresOffloading, parseError, parsePacket, prettyPrintPacket, primitiveValueOrflattenedAttributes, runtime, serverWebsocketMessages, stringPatternMatchers, stringifyIO, taskCatalog, taskContext, unflattenAttributes, workerToChildMessages };
3403
3430
  //# sourceMappingURL=out.js.map
3404
3431
  //# sourceMappingURL=index.mjs.map