diff --git a/.changeset/funny-elephants-sing.md b/.changeset/funny-elephants-sing.md new file mode 100644 index 000000000..91192543c --- /dev/null +++ b/.changeset/funny-elephants-sing.md @@ -0,0 +1,5 @@ +--- +"@trigger.dev/plain": patch +--- + +Added upsertCustomTimelineEntry Task and exported the components from the plain package diff --git a/integrations/plain/src/index.ts b/integrations/plain/src/index.ts index 36b333d78..51b50678b 100644 --- a/integrations/plain/src/index.ts +++ b/integrations/plain/src/index.ts @@ -39,3 +39,13 @@ export class Plain implements PlainIntegration { return { id: "plain", name: "Plain.com" }; } } + +export { + ComponentBadgeColor, + ComponentDividerSpacingSize, + ComponentPlainTextColor, + ComponentPlainTextSize, + ComponentSpacerSize, + ComponentTextColor, + ComponentTextSize, +} from "@team-plain/typescript-sdk"; diff --git a/integrations/plain/src/tasks.ts b/integrations/plain/src/tasks.ts index 4b99389d3..49bc3b46b 100644 --- a/integrations/plain/src/tasks.ts +++ b/integrations/plain/src/tasks.ts @@ -4,10 +4,15 @@ import { GetCustomerByIdResponse, PlainSDK, RemoveTypename, + UpsertCustomTimelineEntryParams, + UpsertCustomTimelineEntryResponse, UpsertCustomerParams, UpsertCustomerResponse, } from "./types"; -import { PlainSDKError } from "@team-plain/typescript-sdk"; +import { + PlainSDKError, + UpsertCustomTimelineEntryInput, +} from "@team-plain/typescript-sdk"; import { Prettify } from "@trigger.dev/integration-kit/prettify"; function isPlainError(error: unknown): error is PlainSDKError { @@ -86,6 +91,37 @@ const upsertCustomer: AuthenticatedTask< }, }; +const upsertCustomTimelineEntry: AuthenticatedTask< + PlainSDK, + UpsertCustomTimelineEntryParams, + UpsertCustomTimelineEntryResponse +> = { + run: async (params, client) => { + const response = await client.upsertCustomTimelineEntry(params); + + if (response.error) { + throw response.error; + } else { + return recursivelyRemoveTypenameProperties(response.data); + } + }, + init: (params) => { + return { + name: "Upsert Customer Timeline Entry", + params, + icon: "plain", + properties: [ + { label: "Customer ID", text: params.customerId }, + { label: "Title", text: params.title }, + { + label: "Components count", + text: params.components.length.toString(), + }, + ], + }; + }, +}; + // This function removes all the __typename properties from an object, recursively function recursivelyRemoveTypenameProperties( obj: T @@ -101,4 +137,5 @@ function recursivelyRemoveTypenameProperties( export const tasks = { getCustomerById, upsertCustomer, + upsertCustomTimelineEntry, }; diff --git a/integrations/plain/src/types.ts b/integrations/plain/src/types.ts index 8b0344a33..3f9359bfb 100644 --- a/integrations/plain/src/types.ts +++ b/integrations/plain/src/types.ts @@ -35,3 +35,11 @@ export type UpsertCustomerParams = Prettify< export type UpsertCustomerResponse = GetPlainSuccessResponseData< ReturnType >; + +export type UpsertCustomTimelineEntryParams = Prettify< + Parameters[0] +>; + +export type UpsertCustomTimelineEntryResponse = GetPlainSuccessResponseData< + ReturnType +>;