v3: Support triggering tasks with non-URL friendly characters in the ID
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/core": patch
|
||||
---
|
||||
|
||||
Support triggering tasks with non-URL friendly characters in the ID
|
||||
@@ -111,9 +111,11 @@ export class ApiClient {
|
||||
}
|
||||
|
||||
triggerTask(taskId: string, body: TriggerTaskRequestBody, options?: TriggerOptions) {
|
||||
const encodedTaskId = encodeURIComponent(taskId);
|
||||
|
||||
return zodfetch(
|
||||
TriggerTaskResponse,
|
||||
`${this.baseUrl}/api/v1/tasks/${taskId}/trigger`,
|
||||
`${this.baseUrl}/api/v1/tasks/${encodedTaskId}/trigger`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: this.#getHeaders(options?.spanParentAsLink ?? false),
|
||||
@@ -124,9 +126,11 @@ export class ApiClient {
|
||||
}
|
||||
|
||||
batchTriggerTask(taskId: string, body: BatchTriggerTaskRequestBody, options?: TriggerOptions) {
|
||||
const encodedTaskId = encodeURIComponent(taskId);
|
||||
|
||||
return zodfetch(
|
||||
BatchTriggerTaskResponse,
|
||||
`${this.baseUrl}/api/v1/tasks/${taskId}/batch`,
|
||||
`${this.baseUrl}/api/v1/tasks/${encodedTaskId}/batch`,
|
||||
{
|
||||
method: "POST",
|
||||
headers: this.#getHeaders(options?.spanParentAsLink ?? false),
|
||||
|
||||
@@ -4,6 +4,7 @@ import { createReadStream } from "node:fs";
|
||||
import { firstScheduledTask } from "./trigger/scheduled";
|
||||
import { simpleChildTask } from "./trigger/subtasks";
|
||||
import { taskThatErrors } from "./trigger/retries";
|
||||
import { unfriendlyIdTask } from "./trigger/other";
|
||||
|
||||
dotenv.config();
|
||||
|
||||
@@ -261,8 +262,19 @@ async function doScheduleLists() {
|
||||
}
|
||||
}
|
||||
|
||||
async function doTriggerUnfriendlyTaskId() {
|
||||
const run = await unfriendlyIdTask.trigger();
|
||||
|
||||
console.log("unfriendly id task run", run);
|
||||
|
||||
const completedRun = await waitForRunToComplete(run.id);
|
||||
|
||||
console.log("completed run", completedRun);
|
||||
}
|
||||
|
||||
// doRuns().catch(console.error);
|
||||
doListRuns().catch(console.error);
|
||||
// doListRuns().catch(console.error);
|
||||
// doScheduleLists().catch(console.error);
|
||||
// doSchedules().catch(console.error);
|
||||
// doEnvVars().catch(console.error);
|
||||
doTriggerUnfriendlyTaskId().catch(console.error);
|
||||
|
||||
@@ -75,3 +75,10 @@ export const consecutiveDependencyAndWait = task({
|
||||
logger.log("logs after");
|
||||
},
|
||||
});
|
||||
|
||||
export const unfriendlyIdTask = task({
|
||||
id: "hello/world:task-1",
|
||||
run: async () => {
|
||||
console.log("Hello world");
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user