Plain: Added upsertCustomTimelineEntry Task and exported the components from the plain package

This commit is contained in:
Matt Aitken
2023-07-07 12:15:08 +01:00
parent 06c0cd5297
commit 2e84c6bbb2
4 changed files with 61 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@trigger.dev/plain": patch
---
Added upsertCustomTimelineEntry Task and exported the components from the plain package
+10
View File
@@ -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";
+38 -1
View File
@@ -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<T extends object>(
obj: T
@@ -101,4 +137,5 @@ function recursivelyRemoveTypenameProperties<T extends object>(
export const tasks = {
getCustomerById,
upsertCustomer,
upsertCustomTimelineEntry,
};
+8
View File
@@ -35,3 +35,11 @@ export type UpsertCustomerParams = Prettify<
export type UpsertCustomerResponse = GetPlainSuccessResponseData<
ReturnType<PlainSDK["upsertCustomer"]>
>;
export type UpsertCustomTimelineEntryParams = Prettify<
Parameters<PlainSDK["upsertCustomTimelineEntry"]>[0]
>;
export type UpsertCustomTimelineEntryResponse = GetPlainSuccessResponseData<
ReturnType<PlainSDK["upsertCustomTimelineEntry"]>
>;