Renamed elements to properties

This commit is contained in:
Eric Allam
2023-06-09 11:04:22 +01:00
parent ec4ef9ab7e
commit f430bcf54a
32 changed files with 1384 additions and 608 deletions
@@ -1,5 +1,5 @@
import {
DisplayElementSchema,
DisplayPropertySchema,
StyleSchema,
} from "@/../../packages/internal/src";
import { z } from "zod";
@@ -1,6 +1,6 @@
import {
DisplayElement,
DisplayElementSchema,
DisplayProperty,
DisplayPropertySchema,
EventSpecificationSchema,
IntegrationMetadataSchema,
} from "@/../../packages/internal/src";
@@ -41,7 +41,7 @@ export class ProjectPresenter {
select: {
version: true,
eventSpecification: true,
elements: true,
properties: true,
runs: {
select: {
createdAt: true,
@@ -158,17 +158,17 @@ export class ProjectPresenter {
)
);
let elements: DisplayElement[] = [];
let properties: DisplayProperty[] = [];
if (eventSpecification.elements) {
elements = [...elements, ...eventSpecification.elements];
if (eventSpecification.properties) {
properties = [...properties, ...eventSpecification.properties];
}
if (alias.version.elements) {
if (alias.version.properties) {
const versionElements = z
.array(DisplayElementSchema)
.parse(alias.version.elements);
elements = [...elements, ...versionElements];
.array(DisplayPropertySchema)
.parse(alias.version.properties);
properties = [...properties, ...versionElements];
}
return {
@@ -183,7 +183,7 @@ export class ProjectPresenter {
},
integrations,
lastRun,
elements,
properties,
};
})
.filter(Boolean),
@@ -1,6 +1,7 @@
import {
DisplayElement,
DisplayElementSchema,
DisplayPropertiesSchema,
DisplayProperty,
DisplayPropertySchema,
ErrorWithStack,
ErrorWithStackSchema,
StyleSchema,
@@ -24,8 +25,6 @@ type QueryTask = NonNullable<
Awaited<ReturnType<RunPresenter["query"]>>
>["tasks"][number];
const ElementsSchema = z.array(DisplayElementSchema);
const taskSelect = {
id: true,
displayKey: true,
@@ -34,7 +33,7 @@ const taskSelect = {
status: true,
delayUntil: true,
description: true,
elements: true,
properties: true,
error: true,
startedAt: true,
completedAt: true,
@@ -70,18 +69,18 @@ export class RunPresenter {
return undefined;
}
//merge the elements from the version and the run, with the run elements taking precedence
const mergedElements = new Map<string, DisplayElement>();
if (run.version.elements) {
const elements = ElementsSchema.parse(run.version.elements);
for (const element of elements) {
mergedElements.set(element.label, element);
//merge the properties from the version and the run, with the run properties taking precedence
const mergedElements = new Map<string, DisplayProperty>();
if (run.version.properties) {
const properties = DisplayPropertiesSchema.parse(run.version.properties);
for (const property of properties) {
mergedElements.set(property.label, property);
}
}
if (run.elements) {
const elements = ElementsSchema.parse(run.elements);
for (const element of elements) {
mergedElements.set(element.label, element);
if (run.properties) {
const properties = DisplayPropertiesSchema.parse(run.properties);
for (const property of properties) {
mergedElements.set(property.label, property);
}
}
@@ -90,10 +89,10 @@ export class RunPresenter {
return {
...t,
connection: t.runConnection,
elements:
t.elements == null
properties:
t.properties == null
? []
: z.array(DisplayElementSchema).parse(t.elements),
: z.array(DisplayPropertySchema).parse(t.properties),
style: t.style ? StyleSchema.parse(t.style) : undefined,
};
};
@@ -131,7 +130,7 @@ export class RunPresenter {
isTest: run.isTest,
version: run.version.version,
output: runOutput,
elements: Array.from(mergedElements.values()),
properties: Array.from(mergedElements.values()),
environment: {
type: run.environment.type,
slug: run.environment.slug,
@@ -153,12 +152,12 @@ export class RunPresenter {
startedAt: true,
completedAt: true,
isTest: true,
elements: true,
properties: true,
output: true,
version: {
select: {
version: true,
elements: true,
properties: true,
},
},
environment: {
@@ -1,5 +1,5 @@
import {
DisplayElementSchema,
DisplayPropertiesSchema,
StyleSchema,
} from "@/../../packages/internal/src";
import { z } from "zod";
@@ -54,7 +54,7 @@ export class TaskDetailsPresenter {
delayUntil: true,
noop: true,
description: true,
elements: true,
properties: true,
params: true,
output: true,
error: true,
@@ -76,10 +76,10 @@ export class TaskDetailsPresenter {
...task,
connection: task.runConnection,
params: task.params as Record<string, any>,
elements:
task.elements == null
properties:
task.properties == null
? []
: z.array(DisplayElementSchema).parse(task.elements),
: DisplayPropertiesSchema.parse(task.properties),
style: task.style ? StyleSchema.parse(task.style) : undefined,
};
}
@@ -1,6 +1,5 @@
import { JobSkeleton } from "~/components/jobs/JobSkeleton";
import { PageBody, PageContainer } from "~/components/layout/AppLayout";
import { Callout } from "~/components/primitives/Callout";
import { DateTime } from "~/components/primitives/DateTime";
import { Header2 } from "~/components/primitives/Headers";
import { Help, HelpContent, HelpTrigger } from "~/components/primitives/Help";
@@ -32,7 +31,6 @@ import { useOrganization } from "~/hooks/useOrganizations";
import { ProjectJob, useProject } from "~/hooks/useProject";
import { useTextFilter } from "~/hooks/useTextFilter";
import { JobRunStatus } from "~/models/job.server";
import { cn } from "~/utils/cn";
import { Handle } from "~/utils/handle";
import { jobPath } from "~/utils/pathBuilder";
@@ -60,9 +58,9 @@ export default function Page() {
)
return true;
if (
job.elements &&
job.elements.some((element) =>
element.text.toLowerCase().includes(text.toLowerCase())
job.properties &&
job.properties.some((property) =>
property.text.toLowerCase().includes(text.toLowerCase())
)
)
return true;
@@ -159,15 +157,15 @@ export default function Page() {
))}
</TableCell>
<TableCell to={path}>
{job.elements && (
{job.properties && (
<SimpleTooltip
button={
<div className="flex max-w-[200px] items-start justify-start gap-5 truncate">
{job.elements.map((element, index) => (
{job.properties.map((property, index) => (
<LabelValueStack
key={index}
label={element.label}
value={element.text}
label={property.label}
value={property.text}
className=" last:truncate"
/>
))}
@@ -175,11 +173,11 @@ export default function Page() {
}
content={
<div className="flex flex-col gap-2">
{job.elements.map((element, index) => (
{job.properties.map((property, index) => (
<LabelValueStack
key={index}
label={element.label}
value={element.text}
label={property.label}
value={property.text}
/>
))}
</div>
@@ -8,7 +8,7 @@ import { formatDateTime } from "~/utils";
import {
RunPanel,
RunPanelBody,
RunPanelElements,
RunPanelProperties,
RunPanelHeader,
RunPanelIconElement,
RunPanelIconSection,
@@ -70,10 +70,13 @@ export default function Page() {
</RunPanelIconSection>
</div>
<div className="mt-4 flex flex-col gap-2">
{run.elements.length > 0 && (
{run.properties.length > 0 && (
<div className="mb-2 flex flex-col gap-4">
<Header3>Properties</Header3>
<RunPanelElements elements={run.elements} layout="vertical" />
<RunPanelProperties
properties={run.properties}
layout="vertical"
/>
</div>
)}
<Header3>Payload</Header3>
@@ -12,7 +12,7 @@ import {
RunPanel,
RunPanelBody,
RunPanelDescription,
RunPanelElements,
RunPanelProperties,
RunPanelHeader,
RunPanelIconElement,
RunPanelIconSection,
@@ -56,7 +56,7 @@ export default function Page() {
status,
delayUntil,
params,
elements,
properties,
output,
style,
} = task;
@@ -111,10 +111,10 @@ export default function Page() {
{description && (
<RunPanelDescription text={description} variant={style?.variant} />
)}
{elements.length > 0 && (
{properties.length > 0 && (
<div className="mt-4 flex flex-col gap-2">
<Header3>Properties</Header3>
<RunPanelElements elements={elements} layout="vertical" />
<RunPanelProperties properties={properties} layout="vertical" />
</div>
)}
<div className="mt-4 flex flex-col gap-2">
@@ -1,5 +1,5 @@
import {
DisplayElement,
DisplayProperty,
Style,
StyleName,
} from "@/../../packages/internal/src";
@@ -184,12 +184,12 @@ export function RunPanelIconElement({
);
}
export function RunPanelElements({
elements,
export function RunPanelProperties({
properties,
className,
layout = "horizontal",
}: {
elements: DisplayElement[];
properties: DisplayProperty[];
className?: string;
layout?: "horizontal" | "vertical";
}) {
@@ -201,7 +201,7 @@ export function RunPanelElements({
className
)}
>
{elements.map(({ label, text, url }, index) => (
{properties.map(({ label, text, url }, index) => (
<LabelValueStack key={index} label={label} value={text} href={url} />
))}
</div>
@@ -6,7 +6,7 @@ import {
RunPanel,
RunPanelBody,
RunPanelDescription,
RunPanelElements,
RunPanelProperties,
RunPanelError,
RunPanelHeader,
RunPanelIconElement,
@@ -28,7 +28,7 @@ type TaskCardProps = Task & {
depth: number;
};
//todo add links to elements
//todo add links to properties
export function TaskCard({
selectedId,
selectedTask,
@@ -44,7 +44,7 @@ export function TaskCard({
description,
displayKey,
connection,
elements,
properties,
subtasks,
error,
}: TaskCardProps) {
@@ -111,8 +111,8 @@ export function TaskCard({
/>
)}
</RunPanelIconSection>
{elements.length > 0 && (
<RunPanelElements elements={elements} className="mt-4" />
{properties.length > 0 && (
<RunPanelProperties properties={properties} className="mt-4" />
)}
</RunPanelBody>
{subtasks && subtasks.length > 0 && (
@@ -39,7 +39,7 @@ import { jobPath } from "~/utils/pathBuilder";
import {
RunPanel,
RunPanelBody,
RunPanelElements,
RunPanelProperties,
RunPanelError,
RunPanelHeader,
RunPanelIconElement,
@@ -234,8 +234,8 @@ export default function Page() {
/>
)}
</RunPanelIconSection>*/}
{run.elements.length > 0 && (
<RunPanelElements elements={run.elements} />
{run.properties.length > 0 && (
<RunPanelProperties properties={run.properties} />
)}
</RunPanelBody>
</RunPanel>
@@ -88,13 +88,13 @@ export default function Job() {
value={job.event.title}
/>
<PageInfoProperty icon="id" label={"ID"} value={job.slug} />
{job.elements &&
job.elements.map((element, index) => (
{job.properties &&
job.properties.map((property, index) => (
<PageInfoProperty
key={index}
icon="property"
label={element.label}
value={element.text}
label={property.label}
value={property.text}
/>
))}
{job.integrations.length > 0 && (
@@ -224,7 +224,7 @@ export class RunTaskService {
noop: taskBody.noop,
delayUntil: taskBody.delayUntil,
params: taskBody.params ?? undefined,
elements: taskBody.elements ?? undefined,
properties: taskBody.properties ?? undefined,
redact: taskBody.redact ?? undefined,
style: taskBody.style ?? { style: "normal" },
},
@@ -337,13 +337,13 @@ export class RegisterJobService {
},
});
if (trigger.elements) {
if (trigger.properties) {
await this.#prismaClient.jobVersion.update({
where: {
id: jobVersion.id,
},
data: {
elements: trigger.elements,
properties: trigger.properties,
},
});
}
@@ -44,7 +44,7 @@ export class PerformRunExecutionService {
}
// Execute the preprocessing step of a run, which will send the payload to the endpoint and give the job
// an opportunity to generate run elements based on the payload.
// an opportunity to generate run properties based on the payload.
// If the endpoint is not available, or the response is not ok,
// the run execution will be marked as failed and the run will start
async #executePreprocessing(execution: FoundRunExecution) {
@@ -135,7 +135,7 @@ export class PerformRunExecutionService {
data: {
status: "STARTED",
startedAt: new Date(),
elements: safeBody.data.elements,
properties: safeBody.data.properties,
},
});
@@ -0,0 +1,19 @@
/*
Warnings:
- You are about to drop the column `elements` on the `JobRun` table. All the data in the column will be lost.
- You are about to drop the column `elements` on the `JobVersion` table. All the data in the column will be lost.
- You are about to drop the column `elements` on the `Task` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "JobRun" DROP COLUMN "elements",
ADD COLUMN "properties" JSONB;
-- AlterTable
ALTER TABLE "JobVersion" DROP COLUMN "elements",
ADD COLUMN "properties" JSONB;
-- AlterTable
ALTER TABLE "Task" DROP COLUMN "elements",
ADD COLUMN "properties" JSONB;
+3 -3
View File
@@ -326,7 +326,7 @@ model JobVersion {
version String
eventSpecification Json
elements Json?
properties Json?
job Job @relation(fields: [jobId], references: [id], onDelete: Cascade, onUpdate: Cascade)
jobId String
@@ -554,7 +554,7 @@ model JobRun {
startedAt DateTime?
completedAt DateTime?
elements Json?
properties Json?
status JobRunStatus @default(PENDING)
output Json?
@@ -631,7 +631,7 @@ model Task {
noop Boolean @default(false)
description String?
elements Json?
properties Json?
params Json?
output Json?
error String?
+3 -3
View File
@@ -93,7 +93,7 @@ const onIssueOpened: EventSpecification<IssuesOpenedEvent> = {
action: ["opened"],
},
parsePayload: (payload) => payload as IssuesOpenedEvent,
runElements: (payload) => [
runProperties: (payload) => [
{
label: "Issue",
text: `#${payload.issue.number}: ${payload.issue.title}`,
@@ -113,7 +113,7 @@ const onIssue: EventSpecification<IssuesEvent> = {
source: "github.com",
icon: "github",
parsePayload: (payload) => payload as IssuesEvent,
runElements: (payload) => [
runProperties: (payload) => [
{
label: "Issue",
text: `#${payload.issue.number}: ${payload.issue.title}`,
@@ -133,7 +133,7 @@ const onIssueComment: EventSpecification<IssueCommentEvent> = {
source: "github.com",
icon: "github",
parsePayload: (payload) => payload as IssueCommentEvent,
runElements: (payload) => [
runProperties: (payload) => [
{
label: "Issue",
text: `#${payload.issue.number}: ${payload.issue.title}`,
+2 -2
View File
@@ -37,7 +37,7 @@ export function createRepoEventSource(
schema: z.object({ repo: z.string() }),
integration,
key: (params) => params.repo,
elements: (params) => [
properties: (params) => [
{
label: "Repo",
text: params.repo,
@@ -124,7 +124,7 @@ export function createOrgEventSource(
integration,
schema: z.object({ org: z.string() }),
key: (params) => params.org,
elements: (params) => [
properties: (params) => [
{
label: "Org",
text: params.org,
+11 -11
View File
@@ -21,7 +21,7 @@ export const createIssue = authenticatedTask({
return {
name: "Create Issue",
params,
elements: [
properties: [
{
label: "Repo",
text: params.repo,
@@ -56,7 +56,7 @@ export const createIssueComment = authenticatedTask({
return {
name: "Create Issue Comment",
params,
elements: [
properties: [
{
label: "Repo",
text: params.repo,
@@ -89,7 +89,7 @@ export const getRepo = authenticatedTask({
return {
name: "Get Repo",
params,
elements: [
properties: [
{
label: "Repo",
text: params.repo,
@@ -163,7 +163,7 @@ export const addIssueCommentReaction = authenticatedTask({
return {
name: "Add Issue Reaction",
params,
elements: [
properties: [
{
label: "Repo",
text: params.repo,
@@ -225,7 +225,7 @@ export const createIssueCommentWithReaction = authenticatedTask({
return {
name: "Create Issue Comment",
params,
elements: [
properties: [
{
label: "Repo",
text: params.repo,
@@ -271,7 +271,7 @@ export const updateWebhook = authenticatedTask({
return {
name: "Update Webhook",
params,
elements: [
properties: [
{
label: "Repo",
text: params.repo,
@@ -314,7 +314,7 @@ export const updateOrgWebhook = authenticatedTask({
return {
name: "Update Org Webhook",
params,
elements: [
properties: [
{
label: "Org",
text: params.org,
@@ -358,7 +358,7 @@ export const createWebhook = authenticatedTask({
return {
name: "Create Webhook",
params,
elements: [
properties: [
{
label: "Repo",
text: params.repo,
@@ -400,7 +400,7 @@ export const createOrgWebhook = authenticatedTask({
return {
name: "Create Org Webhook",
params,
elements: [
properties: [
{
label: "Org",
text: params.org,
@@ -435,7 +435,7 @@ export const listWebhooks = authenticatedTask({
return {
name: "List Webhooks",
params,
elements: [
properties: [
{
label: "Repo",
text: params.repo,
@@ -463,7 +463,7 @@ export const listOrgWebhooks = authenticatedTask({
return {
name: "List Org Webhooks",
params,
elements: [
properties: [
{
label: "Org",
text: params.org,
+1 -1
View File
@@ -19,7 +19,7 @@ export const postMessage = authenticatedTask({
name: "Post Message",
params,
icon: "slack",
elements: [
properties: [
{
label: "Channel ID",
text: params.channel,
+5 -5
View File
@@ -1,7 +1,7 @@
import { ulid } from "ulid";
import { z } from "zod";
import { ConnectionAuthSchema, IntegrationConfigSchema } from "./integrations";
import { DisplayElementSchema, StyleSchema } from "./elements";
import { DisplayPropertySchema, StyleSchema } from "./properties";
import { DeserializedJsonSchema, SerializableJsonSchema } from "./json";
import { CachedTaskSchema, ServerTaskSchema, TaskSchema } from "./tasks";
import {
@@ -306,7 +306,7 @@ export type PreprocessRunBody = z.infer<typeof PreprocessRunBodySchema>;
export const PreprocessRunResponseSchema = z.object({
abort: z.boolean(),
elements: z.array(DisplayElementSchema).optional(),
properties: z.array(DisplayPropertySchema).optional(),
});
export type PreprocessRunResponse = z.infer<typeof PreprocessRunResponseSchema>;
@@ -315,7 +315,7 @@ export const CreateRunBodySchema = z.object({
client: z.string(),
job: JobMetadataSchema,
event: ApiEventLogSchema,
elements: z.array(DisplayElementSchema).optional(),
properties: z.array(DisplayPropertySchema).optional(),
});
export type CreateRunBody = z.infer<typeof CreateRunBodySchema>;
@@ -370,7 +370,7 @@ export const RunTaskOptionsSchema = z.object({
noop: z.boolean().default(false),
delayUntil: z.coerce.date().optional(),
description: z.string().optional(),
elements: z.array(DisplayElementSchema).optional(),
properties: z.array(DisplayPropertySchema).optional(),
params: SerializableJsonSchema.optional(),
trigger: TriggerMetadataSchema.optional(),
redact: RedactSchema.optional(),
@@ -394,7 +394,7 @@ export const RunTaskBodyOutputSchema = RunTaskBodyInputSchema.extend({
export type RunTaskBodyOutput = z.infer<typeof RunTaskBodyOutputSchema>;
export const CompleteTaskBodyInputSchema = RunTaskBodyInputSchema.pick({
elements: true,
properties: true,
description: true,
params: true,
}).extend({
+1 -1
View File
@@ -4,7 +4,7 @@ export * from "./triggers";
export * from "./eventFilter";
export * from "./errors";
export * from "./tasks";
export * from "./elements";
export * from "./properties";
export * from "./integrations";
export * from "./schedules";
export * from "./notifications";
@@ -1,14 +1,14 @@
import { z } from "zod";
export const DisplayElementSchema = z.object({
export const DisplayPropertySchema = z.object({
label: z.string(),
text: z.string(),
url: z.string().optional(),
});
export const DisplayElementsSchema = z.array(DisplayElementSchema);
export const DisplayPropertiesSchema = z.array(DisplayPropertySchema);
export type DisplayElement = z.infer<typeof DisplayElementSchema>;
export type DisplayProperty = z.infer<typeof DisplayPropertySchema>;
export const StyleSchema = z.object({
style: z.enum(["normal", "minimal"]),
+2 -2
View File
@@ -1,5 +1,5 @@
import { z } from "zod";
import { DisplayElementSchema, StyleSchema } from "./elements";
import { DisplayPropertySchema, StyleSchema } from "./properties";
import { DeserializedJsonSchema } from "./json";
export const TaskStatusSchema = z.enum([
@@ -22,7 +22,7 @@ export const TaskSchema = z.object({
delayUntil: z.coerce.date().optional().nullable(),
status: TaskStatusSchema,
description: z.string().optional().nullable(),
elements: z.array(DisplayElementSchema).optional().nullable(),
properties: z.array(DisplayPropertySchema).optional().nullable(),
params: DeserializedJsonSchema.optional().nullable(),
output: DeserializedJsonSchema.optional().nullable(),
error: z.string().optional().nullable(),
+3 -3
View File
@@ -1,6 +1,6 @@
import { z } from "zod";
import { EventFilterSchema, EventRuleSchema } from "./eventFilter";
import { DisplayElementSchema } from "./elements";
import { DisplayPropertySchema } from "./properties";
import { ScheduleMetadataSchema } from "./schedules";
export const EventSpecificationSchema = z.object({
@@ -9,7 +9,7 @@ export const EventSpecificationSchema = z.object({
source: z.string(),
icon: z.string(),
filter: EventFilterSchema.optional(),
elements: z.array(DisplayElementSchema).optional(),
properties: z.array(DisplayPropertySchema).optional(),
schema: z.any().optional(),
examples: z.array(z.any()).optional(),
});
@@ -22,7 +22,7 @@ export const DynamicTriggerMetadataSchema = z.object({
export const StaticTriggerMetadataSchema = z.object({
type: z.literal("static"),
title: z.string(),
elements: z.array(DisplayElementSchema).optional(),
properties: z.array(DisplayPropertySchema).optional(),
rule: EventRuleSchema,
});
+7 -7
View File
@@ -96,7 +96,7 @@ export class IO {
icon: "log",
description: message,
params: data,
elements: [{ label: "Level", text: level }],
properties: [{ label: "Level", text: level }],
style: { style: "minimal", variant: level.toLowerCase() },
noop: true,
},
@@ -146,7 +146,7 @@ export class IO {
{
name: "Update Source",
description: `Update Source ${options.key}`,
elements: [
properties: [
{
label: "key",
text: options.key,
@@ -176,7 +176,7 @@ export class IO {
key,
{
name: "register-interval",
elements: [
properties: [
{ label: "schedule", text: dynamicSchedule.id },
{ label: "id", text: id },
{ label: "seconds", text: options.seconds.toString() },
@@ -201,7 +201,7 @@ export class IO {
key,
{
name: "unregister-interval",
elements: [
properties: [
{ label: "schedule", text: dynamicSchedule.id },
{ label: "id", text: id },
],
@@ -222,7 +222,7 @@ export class IO {
key,
{
name: "register-cron",
elements: [
properties: [
{ label: "schedule", text: dynamicSchedule.id },
{ label: "id", text: id },
{ label: "cron", text: options.cron },
@@ -247,7 +247,7 @@ export class IO {
key,
{
name: "unregister-cron",
elements: [
properties: [
{ label: "schedule", text: dynamicSchedule.id },
{ label: "id", text: id },
],
@@ -273,7 +273,7 @@ export class IO {
key,
{
name: "register-trigger",
elements: [
properties: [
{ label: "trigger", text: trigger.id },
{ label: "id", text: id },
],
+3 -3
View File
@@ -307,7 +307,7 @@ export class TriggerClient {
status: 200,
body: {
abort: results.abort,
elements: results.elements,
properties: results.properties,
},
};
}
@@ -558,11 +558,11 @@ export class TriggerClient {
body.event.payload ?? {}
);
const elements = job.trigger.event.runElements?.(parsedPayload) ?? [];
const properties = job.trigger.event.runProperties?.(parsedPayload) ?? [];
return {
abort: false,
elements,
properties,
};
}
@@ -1,7 +1,7 @@
import { z } from "zod";
import {
DisplayElement,
DisplayProperty,
EventFilter,
HandleTriggerSource,
Logger,
@@ -114,7 +114,7 @@ type ExternalSourceOptions<
filter: FilterFunction<TParams>;
handler: HandlerFunction<TChannel, TParams>;
key: KeyFunction<TParams>;
elements?: (params: TParams) => DisplayElement[];
properties?: (params: TParams) => DisplayProperty[];
};
export class ExternalSource<
@@ -149,8 +149,8 @@ export class ExternalSource<
return this.options.filter(params);
}
elements(params: TParams): DisplayElement[] {
return this.options.elements?.(params) ?? [];
properties(params: TParams): DisplayProperty[] {
return this.options.properties?.(params) ?? [];
}
async register(
@@ -251,7 +251,7 @@ export class ExternalSourceTrigger<
),
source: this.event.source,
},
elements: this.options.source.elements(this.options.params),
properties: this.options.source.properties(this.options.params),
};
}
@@ -43,7 +43,7 @@ export class MissingConnectionNotification
source: "trigger.dev",
icon: "connection-alert",
parsePayload: MissingConnectionNotificationPayloadSchema.parse,
elements: [
properties: [
{
label: "Integrations",
text: this.options.integrations.map((i) => i.id).join(", "),
@@ -93,7 +93,7 @@ export class MissingConnectionResolvedNotification
source: "trigger.dev",
icon: "connection-alert",
parsePayload: MissingConnectionResolvedNotificationPayloadSchema.parse,
elements: [
properties: [
{
label: "Integrations",
text: this.options.integrations.map((i) => i.id).join(", "),
@@ -22,7 +22,7 @@ export class IntervalTrigger implements Trigger<ScheduledEventSpecification> {
source: "trigger.dev",
icon: "schedule-interval",
parsePayload: ScheduledPayloadSchema.parse,
elements: [
properties: [
{
label: "Interval",
text: `${this.options.seconds}s`,
@@ -67,7 +67,7 @@ export class CronTrigger implements Trigger<ScheduledEventSpecification> {
source: "trigger.dev",
icon: "schedule-cron",
parsePayload: ScheduledPayloadSchema.parse,
elements: [
properties: [
{
label: "Expression",
text: this.options.cron,
+4 -4
View File
@@ -5,7 +5,7 @@ import type {
SecureString,
TriggerMetadata,
} from "@trigger.dev/internal";
import { DisplayElement } from "@trigger.dev/internal";
import { DisplayProperty } from "@trigger.dev/internal";
import { Job } from "./job";
import { TriggerClient } from "./triggerClient";
@@ -38,7 +38,7 @@ export interface TaskLogger {
export type PreprocessResults = {
abort: boolean;
elements: DisplayElement[];
properties: DisplayProperty[];
};
export type TriggerEventType<TTrigger extends Trigger<any>> =
@@ -64,12 +64,12 @@ export interface EventSpecification<TEvent extends any> {
title: string;
source: string;
icon: string;
elements?: DisplayElement[];
properties?: DisplayProperty[];
schema?: any;
examples?: Array<TEvent>;
filter?: EventFilter;
parsePayload: (payload: unknown) => TEvent;
runElements?: (payload: TEvent) => DisplayElement[];
runProperties?: (payload: TEvent) => DisplayProperty[];
}
export type EventTypeFromSpecification<
+1229 -472
View File
File diff suppressed because it is too large Load Diff