@trigger.dev/sdk 3.0.0-beta.49 → 3.0.0-beta.50

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.
@@ -812,7 +812,30 @@ declare const usage: {
812
812
  }>;
813
813
  };
814
814
 
815
- declare function task<TIdentifier extends string, TOutput, TInitOutput extends InitOutput>(params: TaskOptions<TIdentifier, ScheduledTaskPayload, TOutput, TInitOutput>): Task<TIdentifier, ScheduledTaskPayload, TOutput>;
815
+ type ScheduleOptions<TIdentifier extends string, TOutput, TInitOutput extends InitOutput> = TaskOptions<TIdentifier, ScheduledTaskPayload, TOutput, TInitOutput> & {
816
+ /** You can optionally specify a CRON schedule on your task. You can also dynamically add a schedule in the dashboard or using the SDK functions.
817
+ *
818
+ * 1. Pass a CRON pattern string
819
+ * ```ts
820
+ * "0 0 * * *"
821
+ * ```
822
+ *
823
+ * 2. Or an object with a pattern and an optional timezone (default is "UTC")
824
+ * ```ts
825
+ * {
826
+ * pattern: "0 0 * * *",
827
+ * timezone: "America/Los_Angeles"
828
+ * }
829
+ * ```
830
+ *
831
+ * @link https://trigger.dev/docs/v3/tasks-scheduled
832
+ */
833
+ cron?: string | {
834
+ pattern: string;
835
+ timezone?: string;
836
+ };
837
+ };
838
+ declare function task<TIdentifier extends string, TOutput, TInitOutput extends InitOutput>(params: ScheduleOptions<TIdentifier, TOutput, TInitOutput>): Task<TIdentifier, ScheduledTaskPayload, TOutput>;
816
839
  /**
817
840
  * Creates a new schedule
818
841
  * @param options
@@ -874,12 +897,13 @@ declare function timezones(options?: {
874
897
  timezones: string[];
875
898
  }>;
876
899
 
900
+ type index_ScheduleOptions<TIdentifier extends string, TOutput, TInitOutput extends InitOutput> = ScheduleOptions<TIdentifier, TOutput, TInitOutput>;
877
901
  declare const index_activate: typeof activate;
878
902
  declare const index_deactivate: typeof deactivate;
879
903
  declare const index_task: typeof task;
880
904
  declare const index_timezones: typeof timezones;
881
905
  declare namespace index {
882
- export { index_activate as activate, create$1 as create, index_deactivate as deactivate, del$1 as del, list$1 as list, retrieve$1 as retrieve, index_task as task, index_timezones as timezones, update$1 as update };
906
+ export { type index_ScheduleOptions as ScheduleOptions, index_activate as activate, create$1 as create, index_deactivate as deactivate, del$1 as del, list$1 as list, retrieve$1 as retrieve, index_task as task, index_timezones as timezones, update$1 as update };
883
907
  }
884
908
 
885
909
  declare function upload(projectRef: string, slug: string, params: ImportEnvironmentVariablesParams, requestOptions?: ApiRequestOptions): ApiPromise<EnvironmentVariableResponseBody>;
@@ -812,7 +812,30 @@ declare const usage: {
812
812
  }>;
813
813
  };
814
814
 
815
- declare function task<TIdentifier extends string, TOutput, TInitOutput extends InitOutput>(params: TaskOptions<TIdentifier, ScheduledTaskPayload, TOutput, TInitOutput>): Task<TIdentifier, ScheduledTaskPayload, TOutput>;
815
+ type ScheduleOptions<TIdentifier extends string, TOutput, TInitOutput extends InitOutput> = TaskOptions<TIdentifier, ScheduledTaskPayload, TOutput, TInitOutput> & {
816
+ /** You can optionally specify a CRON schedule on your task. You can also dynamically add a schedule in the dashboard or using the SDK functions.
817
+ *
818
+ * 1. Pass a CRON pattern string
819
+ * ```ts
820
+ * "0 0 * * *"
821
+ * ```
822
+ *
823
+ * 2. Or an object with a pattern and an optional timezone (default is "UTC")
824
+ * ```ts
825
+ * {
826
+ * pattern: "0 0 * * *",
827
+ * timezone: "America/Los_Angeles"
828
+ * }
829
+ * ```
830
+ *
831
+ * @link https://trigger.dev/docs/v3/tasks-scheduled
832
+ */
833
+ cron?: string | {
834
+ pattern: string;
835
+ timezone?: string;
836
+ };
837
+ };
838
+ declare function task<TIdentifier extends string, TOutput, TInitOutput extends InitOutput>(params: ScheduleOptions<TIdentifier, TOutput, TInitOutput>): Task<TIdentifier, ScheduledTaskPayload, TOutput>;
816
839
  /**
817
840
  * Creates a new schedule
818
841
  * @param options
@@ -874,12 +897,13 @@ declare function timezones(options?: {
874
897
  timezones: string[];
875
898
  }>;
876
899
 
900
+ type index_ScheduleOptions<TIdentifier extends string, TOutput, TInitOutput extends InitOutput> = ScheduleOptions<TIdentifier, TOutput, TInitOutput>;
877
901
  declare const index_activate: typeof activate;
878
902
  declare const index_deactivate: typeof deactivate;
879
903
  declare const index_task: typeof task;
880
904
  declare const index_timezones: typeof timezones;
881
905
  declare namespace index {
882
- export { index_activate as activate, create$1 as create, index_deactivate as deactivate, del$1 as del, list$1 as list, retrieve$1 as retrieve, index_task as task, index_timezones as timezones, update$1 as update };
906
+ export { type index_ScheduleOptions as ScheduleOptions, index_activate as activate, create$1 as create, index_deactivate as deactivate, del$1 as del, list$1 as list, retrieve$1 as retrieve, index_task as task, index_timezones as timezones, update$1 as update };
883
907
  }
884
908
 
885
909
  declare function upload(projectRef: string, slug: string, params: ImportEnvironmentVariablesParams, requestOptions?: ApiRequestOptions): ApiPromise<EnvironmentVariableResponseBody>;
package/dist/v3/index.js CHANGED
@@ -19,7 +19,7 @@ var __publicField = (obj, key, value) => {
19
19
  };
20
20
 
21
21
  // package.json
22
- var version = "3.0.0-beta.49";
22
+ var version = "3.0.0-beta.50";
23
23
 
24
24
  // src/v3/tracer.ts
25
25
  var tracer = new v3.TriggerTracer({
@@ -1497,8 +1497,14 @@ __export(schedules_exports, {
1497
1497
  });
1498
1498
  function task2(params) {
1499
1499
  const task3 = createTask(params);
1500
+ const cron = params.cron ? typeof params.cron === "string" ? params.cron : params.cron.pattern : void 0;
1501
+ const timezone = (params.cron && typeof params.cron !== "string" ? params.cron.timezone : "UTC") ?? "UTC";
1500
1502
  v3.taskCatalog.updateTaskMetadata(task3.id, {
1501
- triggerSource: "schedule"
1503
+ triggerSource: "schedule",
1504
+ schedule: cron ? {
1505
+ cron,
1506
+ timezone
1507
+ } : void 0
1502
1508
  });
1503
1509
  return task3;
1504
1510
  }