@trigger.dev/sdk 2.2.8 → 2.2.9

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
@@ -1,5 +1,5 @@
1
1
  import * as _trigger_dev_core from '@trigger.dev/core';
2
- import { AsyncMap, KeyValueStoreResponseBody, RunTaskBodyInput, CompleteTaskBodyV2Input, FailTaskBodyInput, SendEvent, SendEventOptions, StatusUpdate, UpdateTriggerSourceBodyV2, TriggerSource, UpdateWebhookBody, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, InvokeOptions, EphemeralEventDispatcherRequestBody, LogLevel, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, SuccessfulRunNotification, FailedRunNotification, HttpEndpointMetadata, RequestFilter, Prettify, HandleTriggerSource, Logger, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, IntervalOptions, CronOptions, ScheduledPayload, RegisterWebhookSource, DeserializedJson, ServerTask, CachedTask, InitialStatusUpdate, FetchRequestInit, FetchRetryOptions, FetchTimeoutOptions, FetchPollOperation, RunTaskOptions, IntegrationMetadata, QueueOptions, IntegrationConfig, JobMetadata, RunNotification, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
2
+ import { AsyncMap, KeyValueStoreResponseBody, RunTaskBodyInput, CompleteTaskBodyV2Input, FailTaskBodyInput, SendEvent, SendEventOptions, StatusUpdate, UpdateTriggerSourceBodyV2, TriggerSource, UpdateWebhookBody, RegisterTriggerBodyV2, RegisterSourceEventV2, ScheduleMetadata, GetRunOptionsWithTaskDetails, GetRunsOptions, InvokeOptions, EphemeralEventDispatcherRequestBody, LogLevel, RuntimeEnvironmentType, DisplayProperty, TriggerMetadata, EventFilter, SuccessfulRunNotification, FailedRunNotification, HttpEndpointMetadata, RequestFilter, Prettify, HandleTriggerSource, Logger, RegisterTriggerSource, SerializableJson, ConnectionAuth, NormalizedResponse, HttpSourceResponseMetadata, IntervalOptions, CronOptions, ScheduledPayload, RegisterWebhookSource, DeserializedJson, ServerTask, CachedTask, InitialStatusUpdate, FetchRequestInit, FetchRetryOptions, FetchTimeoutOptions, FetchPollOperation, RunTaskOptions, IntegrationMetadata, IntegrationConfig, JobMetadata, RunNotification, MissingConnectionNotificationPayload, MissingConnectionResolvedNotificationPayload, ErrorWithStack, ApiEventLog, RedactString } from '@trigger.dev/core';
3
3
  export { ConnectionAuth, DisplayProperty, EventFilter, Logger, NormalizedRequest, OverridableRunTaskOptions, Prettify, RedactString, RegisteredOptionsDiff, RunTaskOptions, SourceEventOption } from '@trigger.dev/core';
4
4
  import * as zod from 'zod';
5
5
  import { z, ZodType, TypeOf } from 'zod';
@@ -635,7 +635,7 @@ declare class ApiClient {
635
635
  updatedAt: Date;
636
636
  runs: {
637
637
  id: string;
638
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
638
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
639
639
  startedAt?: Date | null | undefined;
640
640
  completedAt?: Date | null | undefined;
641
641
  }[];
@@ -645,7 +645,7 @@ declare class ApiClient {
645
645
  id: string;
646
646
  startedAt: Date | null;
647
647
  completedAt: Date | null;
648
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
648
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
649
649
  updatedAt: Date | null;
650
650
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
651
651
  statuses: {
@@ -666,7 +666,7 @@ declare class ApiClient {
666
666
  id: string;
667
667
  startedAt: Date | null;
668
668
  completedAt: Date | null;
669
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
669
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
670
670
  updatedAt: Date | null;
671
671
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
672
672
  statuses: {
@@ -697,7 +697,7 @@ declare class ApiClient {
697
697
  }[];
698
698
  run: {
699
699
  id: string;
700
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
700
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
701
701
  output?: any;
702
702
  };
703
703
  }>;
@@ -706,7 +706,7 @@ declare class ApiClient {
706
706
  id: string;
707
707
  startedAt: Date | null;
708
708
  completedAt: Date | null;
709
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
709
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
710
710
  updatedAt: Date | null;
711
711
  }[];
712
712
  nextCursor?: string | undefined;
@@ -1415,6 +1415,17 @@ declare class DynamicSchedule implements Trigger<ScheduledEventSpecification> {
1415
1415
  toJSON(): TriggerMetadata;
1416
1416
  }
1417
1417
 
1418
+ type ConcurrencyLimitOptions = {
1419
+ id: string;
1420
+ limit: number;
1421
+ };
1422
+ declare class ConcurrencyLimit {
1423
+ private options;
1424
+ constructor(options: ConcurrencyLimitOptions);
1425
+ get id(): string;
1426
+ get limit(): number;
1427
+ }
1428
+
1418
1429
  type WebhookCRUDContext<TParams extends any, TConfig extends Record<string, string[]>> = {
1419
1430
  active: boolean;
1420
1431
  params: TParams;
@@ -1609,6 +1620,7 @@ declare class TriggerClient {
1609
1620
  * @link https://trigger.dev/docs/documentation/concepts/http-endpoints
1610
1621
  */
1611
1622
  defineHttpEndpoint(options: EndpointOptions, suppressWarnings?: boolean): HttpEndpoint<EventSpecification<Request, Request>>;
1623
+ defineConcurrencyLimit(options: ConcurrencyLimitOptions): ConcurrencyLimit;
1612
1624
  attach(job: Job<Trigger<any>, any>): void;
1613
1625
  attachDynamicTrigger(trigger: DynamicTrigger<any, any>): void;
1614
1626
  attachJobToDynamicTrigger(job: Job<Trigger<any>, any>, trigger: DynamicTrigger<any, any>): void;
@@ -1761,7 +1773,7 @@ declare class TriggerClient {
1761
1773
  updatedAt: Date;
1762
1774
  runs: {
1763
1775
  id: string;
1764
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1776
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1765
1777
  startedAt?: Date | null | undefined;
1766
1778
  completedAt?: Date | null | undefined;
1767
1779
  }[];
@@ -1771,7 +1783,7 @@ declare class TriggerClient {
1771
1783
  id: string;
1772
1784
  startedAt: Date | null;
1773
1785
  completedAt: Date | null;
1774
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1786
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1775
1787
  updatedAt: Date | null;
1776
1788
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1777
1789
  statuses: {
@@ -1792,7 +1804,7 @@ declare class TriggerClient {
1792
1804
  id: string;
1793
1805
  startedAt: Date | null;
1794
1806
  completedAt: Date | null;
1795
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1807
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1796
1808
  updatedAt: Date | null;
1797
1809
  tasks: _trigger_dev_core.RunTaskWithSubtasks[];
1798
1810
  statuses: {
@@ -1814,7 +1826,7 @@ declare class TriggerClient {
1814
1826
  id: string;
1815
1827
  startedAt: Date | null;
1816
1828
  completedAt: Date | null;
1817
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1829
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1818
1830
  updatedAt: Date | null;
1819
1831
  }[];
1820
1832
  nextCursor?: string | undefined;
@@ -1833,7 +1845,7 @@ declare class TriggerClient {
1833
1845
  }[];
1834
1846
  run: {
1835
1847
  id: string;
1836
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
1848
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
1837
1849
  output?: any;
1838
1850
  };
1839
1851
  }>;
@@ -2120,7 +2132,7 @@ declare class IO {
2120
2132
  updatedAt: Date;
2121
2133
  runs: {
2122
2134
  id: string;
2123
- status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD";
2135
+ status: "PENDING" | "CANCELED" | "QUEUED" | "WAITING_ON_CONNECTIONS" | "PREPROCESSING" | "STARTED" | "SUCCESS" | "FAILURE" | "TIMED_OUT" | "ABORTED" | "UNRESOLVED_AUTH" | "INVALID_PAYLOAD" | "EXECUTING" | "WAITING_TO_CONTINUE" | "WAITING_TO_EXECUTE";
2124
2136
  startedAt?: Date | null | undefined;
2125
2137
  completedAt?: Date | null | undefined;
2126
2138
  }[];
@@ -2335,9 +2347,15 @@ type JobOptions<TTrigger extends Trigger<EventSpecification<any>>, TIntegrations
2335
2347
  });
2336
2348
  ``` */
2337
2349
  integrations?: TIntegrations;
2338
- /** @deprecated This property is deprecated and no longer effects the execution of the Job
2339
- * */
2340
- queue?: QueueOptions | string;
2350
+ /**
2351
+ * The `concurrencyLimit` property is used to limit the number of concurrent run executions of a job.
2352
+ * Can be a number which represents the limit or a `ConcurrencyLimit` instance which can be used to
2353
+ * group together multiple jobs to share the same concurrency limit.
2354
+ *
2355
+ * If undefined the job will be limited only by the server's global concurrency limit, or if you are using the
2356
+ * Trigger.dev Cloud service, the concurrency limit of your plan.
2357
+ */
2358
+ concurrencyLimit?: number | ConcurrencyLimit;
2341
2359
  /** The `enabled` property is used to enable or disable the Job. If you disable a Job, it will not run. */
2342
2360
  enabled?: boolean;
2343
2361
  /** This function gets called automatically when a Run is Triggered.
package/dist/index.js CHANGED
@@ -166,7 +166,11 @@ var Job = class {
166
166
  startPosition: "latest",
167
167
  enabled: this.enabled,
168
168
  preprocessRuns: this.trigger.preprocessRuns,
169
- internal
169
+ internal,
170
+ concurrencyLimit: typeof this.options.concurrencyLimit === "number" ? this.options.concurrencyLimit : typeof this.options.concurrencyLimit === "object" ? {
171
+ id: this.options.concurrencyLimit.id,
172
+ limit: this.options.concurrencyLimit.limit
173
+ } : void 0
170
174
  };
171
175
  }
172
176
  async invoke(param1, param2 = void 0, param3 = void 0) {
@@ -2054,7 +2058,8 @@ queryKeyValueStore_fn = /* @__PURE__ */ __name(async function(action, data) {
2054
2058
  action,
2055
2059
  data
2056
2060
  });
2057
- const STORE_URL = `${__privateGet(this, _apiUrl)}/api/v1/store/${data.key}`;
2061
+ const encodedKey = encodeURIComponent(data.key);
2062
+ const STORE_URL = `${__privateGet(this, _apiUrl)}/api/v1/store/${encodedKey}`;
2058
2063
  const authHeader = {
2059
2064
  Authorization: `Bearer ${apiKey}`
2060
2065
  };
@@ -2080,7 +2085,7 @@ queryKeyValueStore_fn = /* @__PURE__ */ __name(async function(action, data) {
2080
2085
  });
2081
2086
  return {
2082
2087
  action: "HAS",
2083
- key: data.key,
2088
+ key: encodedKey,
2084
2089
  has: !!headResponse.ok
2085
2090
  };
2086
2091
  }
@@ -2756,7 +2761,21 @@ __name(DynamicSchedule, "DynamicSchedule");
2756
2761
  var import_node_events = __toESM(require("events"));
2757
2762
 
2758
2763
  // package.json
2759
- var version = "2.2.8";
2764
+ var version = "2.2.9";
2765
+
2766
+ // src/concurrencyLimit.ts
2767
+ var ConcurrencyLimit = class {
2768
+ constructor(options) {
2769
+ this.options = options;
2770
+ }
2771
+ get id() {
2772
+ return this.options.id;
2773
+ }
2774
+ get limit() {
2775
+ return this.options.limit;
2776
+ }
2777
+ };
2778
+ __name(ConcurrencyLimit, "ConcurrencyLimit");
2760
2779
 
2761
2780
  // src/triggerClient.ts
2762
2781
  var registerWebhookEvent = /* @__PURE__ */ __name((key) => ({
@@ -3225,6 +3244,9 @@ var TriggerClient = class {
3225
3244
  __privateGet(this, _registeredHttpEndpoints)[endpoint.id] = endpoint;
3226
3245
  return endpoint;
3227
3246
  }
3247
+ defineConcurrencyLimit(options) {
3248
+ return new ConcurrencyLimit(options);
3249
+ }
3228
3250
  attach(job) {
3229
3251
  __privateGet(this, _registeredJobs)[job.id] = job;
3230
3252
  job.trigger.attachToJob(this, job);
@@ -4040,7 +4062,11 @@ buildJobIndex_fn = /* @__PURE__ */ __name(function(job2) {
4040
4062
  startPosition: "latest",
4041
4063
  enabled: job2.enabled,
4042
4064
  preprocessRuns: job2.trigger.preprocessRuns,
4043
- internal
4065
+ internal,
4066
+ concurrencyLimit: typeof job2.options.concurrencyLimit === "number" ? job2.options.concurrencyLimit : typeof job2.options.concurrencyLimit === "object" ? {
4067
+ id: job2.options.concurrencyLimit.id,
4068
+ limit: job2.options.concurrencyLimit.limit
4069
+ } : void 0
4044
4070
  };
4045
4071
  }, "#buildJobIndex");
4046
4072
  _buildJobIntegrations = new WeakSet();