Plain: Added upsertCustomTimelineEntry Task and exported the components from the plain package
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@trigger.dev/plain": patch
|
||||
---
|
||||
|
||||
Added upsertCustomTimelineEntry Task and exported the components from the plain package
|
||||
@@ -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";
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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"]>
|
||||
>;
|
||||
|
||||
Reference in New Issue
Block a user