| 22 | }; |
| 23 | |
| 24 | export class InvokeTrigger<TSchema extends ZodType = z.ZodTypeAny> |
| 25 | implements Trigger<EventSpecification<TypeOf<TSchema>, z.input<TSchema>>> |
| 26 | { |
| 27 | #options: InvokeTriggerOptions<TSchema>; |
| 28 | |
| 29 | constructor(options: InvokeTriggerOptions<TSchema>) { |
| 30 | this.#options = options; |
| 31 | } |
| 32 | |
| 33 | toJSON(): TriggerMetadata { |
| 34 | return { |
| 35 | type: "invoke", |
| 36 | }; |
| 37 | } |
| 38 | |
| 39 | get event() { |
| 40 | return { |
| 41 | name: "invoke", |
| 42 | title: "Manual Invoke", |
| 43 | source: "trigger.dev", |
| 44 | examples: this.#options.examples ?? [], |
| 45 | icon: "trigger", |
| 46 | parsePayload: (rawPayload: unknown) => { |
| 47 | if (this.#options.schema) { |
| 48 | const results = this.#options.schema.safeParse(rawPayload); |
| 49 | |
| 50 | if (!results.success) { |
| 51 | throw new ParsedPayloadSchemaError(formatSchemaErrors(results.error.issues)); |
| 52 | } |
| 53 | |
| 54 | return results.data; |
| 55 | } |
| 56 | |
| 57 | return rawPayload as any; |
| 58 | }, |
| 59 | parseInvokePayload: (rawPayload: unknown) => { |
| 60 | if (this.#options.schema) { |
| 61 | const results = this.#options.schema.safeParse(rawPayload); |
| 62 | |
| 63 | if (!results.success) { |
| 64 | throw new ParsedPayloadSchemaError(formatSchemaErrors(results.error.issues)); |
| 65 | } |
| 66 | |
| 67 | return results.data; |
| 68 | } |
| 69 | |
| 70 | return rawPayload as any; |
| 71 | }, |
| 72 | }; |
| 73 | } |
| 74 | |
| 75 | attachToJob( |
| 76 | triggerClient: TriggerClient, |
| 77 | job: Job<Trigger<EventSpecification<ZodType<TSchema>>>, any> |
| 78 | ): void {} |
| 79 | |
| 80 | get preprocessRuns() { |
| 81 | return false; |
nothing calls this directly
no outgoing calls
no test coverage detected
searching dependent graphs…