Update plain (#762)

* updated the plain SDK

* Updated the action to support the new Threads SDK

* latest lock file

---------

Co-authored-by: James Ritchie <james@jamesritchie.co.uk>
This commit is contained in:
Eric Allam
2023-11-29 10:58:06 +00:00
committed by GitHub
parent ff540c9e4a
commit bd4bc51daa
3 changed files with 50 additions and 68 deletions
+38 -53
View File
@@ -1,12 +1,6 @@
import { parse } from "@conform-to/zod";
import { ActionFunctionArgs, json } from "@remix-run/server-runtime";
import {
ComponentDividerSpacingSize,
ComponentSpacerSize,
ComponentTextColor,
ComponentTextSize,
PlainClient,
} from "@team-plain/typescript-sdk";
import { PlainClient, uiComponent } from "@team-plain/typescript-sdk";
import { inspect } from "util";
import { z } from "zod";
import { env } from "~/env.server";
@@ -68,6 +62,8 @@ export async function action({ request }: ActionFunctionArgs) {
onCreate: {
externalId: user.id,
fullName: user.name ?? "",
// TODO - Optional: set 'first name' on user
// shortName: ''
email: {
email: user.email,
isVerified: true,
@@ -76,6 +72,8 @@ export async function action({ request }: ActionFunctionArgs) {
onUpdate: {
externalId: { value: user.id },
fullName: { value: user.name ?? "" },
// TODO - see above
// shortName: { value: "" },
email: {
email: user.email,
isVerified: true,
@@ -96,63 +94,50 @@ export async function action({ request }: ActionFunctionArgs) {
}
const title = feedbackTypeLabel[submission.value.feedbackType as FeedbackType];
const upsertTimelineEntryRes = await client.upsertCustomTimelineEntry({
customerId: upsertCustomerRes.data.customer.id,
const createThreadRes = await client.createThread({
customerIdentifier: {
customerId: upsertCustomerRes.data.customer.id,
},
title,
components: [
{
componentText: {
text: `New ${title} reported by ${user.name} (${user.email})`,
},
},
{
componentDivider: {
dividerSpacingSize: ComponentDividerSpacingSize.M,
},
},
{
componentText: {
textSize: ComponentTextSize.S,
textColor: ComponentTextColor.Muted,
text: "Page",
},
},
{
componentText: {
text: submission.value.path,
},
},
{
componentSpacer: {
spacerSize: ComponentSpacerSize.M,
},
},
{
componentText: {
textSize: ComponentTextSize.S,
textColor: ComponentTextColor.Muted,
text: "Message",
},
},
{
componentText: {
text: submission.value.message,
},
},
uiComponent.text({
text: `New ${title} reported by ${user.name} (${user.email})`,
}),
uiComponent.divider({ spacingSize: "M" }),
uiComponent.text({
size: "S",
color: "MUTED",
text: "Page",
}),
uiComponent.text({
text: submission.value.path,
}),
uiComponent.spacer({ size: "M" }),
uiComponent.text({
size: "S",
color: "MUTED",
text: "Message",
}),
uiComponent.text({
text: submission.value.message,
}),
],
changeCustomerStatusToActive: true,
sendCustomTimelineEntryCreatedNotification: true,
// TODO: Optional: set labels on threads here on creation
// labelTypeIds: [],
// TODO: Optional: set the priority (0 is urgent, 3 is low)
// priority: 0,
});
if (upsertTimelineEntryRes.error) {
if (createThreadRes.error) {
console.error(
inspect(upsertTimelineEntryRes.error, {
inspect(createThreadRes.error, {
showHidden: false,
depth: null,
colors: true,
})
);
submission.error.message = upsertTimelineEntryRes.error.message;
submission.error.message = createThreadRes.error.message;
return json(submission);
}
+2 -2
View File
@@ -62,7 +62,7 @@
"@remix-run/server-runtime": "2.1.0",
"@remix-run/v1-meta": "^0.1.3",
"@tabler/icons-react": "^2.39.0",
"@team-plain/typescript-sdk": "^2.2.0",
"@team-plain/typescript-sdk": "^3.5.0",
"@trigger.dev/companyicons": "^1.5.32",
"@trigger.dev/core": "workspace:*",
"@trigger.dev/core-backend": "workspace:*",
@@ -188,4 +188,4 @@
"engines": {
"node": ">=16.0.0"
}
}
}
+10 -13
View File
@@ -126,7 +126,7 @@ importers:
'@tabler/icons-react': ^2.39.0
'@tailwindcss/forms': ^0.5.3
'@tailwindcss/typography': ^0.5.9
'@team-plain/typescript-sdk': ^2.2.0
'@team-plain/typescript-sdk': ^3.5.0
'@total-typescript/ts-reset': ^0.4.2
'@trigger.dev/companyicons': ^1.5.32
'@trigger.dev/core': workspace:*
@@ -262,7 +262,7 @@ importers:
'@remix-run/server-runtime': 2.1.0_typescript@5.2.2
'@remix-run/v1-meta': 0.1.3_ybjp5xbtg4zthziheradfmei64
'@tabler/icons-react': 2.40.0_react@18.2.0
'@team-plain/typescript-sdk': 2.2.0
'@team-plain/typescript-sdk': 3.5.0
'@trigger.dev/companyicons': 1.5.32_biqbaboplfbrettd7655fr4n2y
'@trigger.dev/core': link:../../packages/core
'@trigger.dev/core-backend': link:../../packages/core-backend
@@ -14227,17 +14227,6 @@ packages:
react: 18.2.0
dev: false
/@team-plain/typescript-sdk/2.2.0:
resolution: {integrity: sha512-ZNRZJ1uhQYHqaAKNAMdcSvULxutDQldocJWEDxJ5CJX4QYyzD8adK7gB9szKQDsxHFA3sZgTjtSruFBOf+C2fw==}
dependencies:
'@graphql-typed-document-node/core': 3.2.0_graphql@16.6.0
axios: 1.4.0
graphql: 16.6.0
zod: 3.22.4
transitivePeerDependencies:
- debug
dev: false
/@team-plain/typescript-sdk/2.7.0:
resolution: {integrity: sha512-n5CRvOuGAUvuAIAL2/4jgr6dG1kW8pelbXyq4YObzGcvUcQRyJ69d93bBvduFAh5/1sQYMUle6BYT/3liwpcfQ==}
dependencies:
@@ -14249,6 +14238,14 @@ packages:
- debug
dev: false
/@team-plain/typescript-sdk/3.5.0:
resolution: {integrity: sha512-9kweiSlYAN31VI7yzILGxdlZqsGJ+FmCEfXyEZ/0/i3r6vOwq45FDqtjadnQJVtFm+rf/8vCFRN+wEYMIEv6Aw==}
dependencies:
'@graphql-typed-document-node/core': 3.2.0_graphql@16.6.0
graphql: 16.6.0
zod: 3.22.4
dev: false
/@testing-library/dom/8.19.1:
resolution: {integrity: sha512-P6iIPyYQ+qH8CvGauAqanhVnjrnRe0IZFSYCeGkSRW9q3u8bdVn2NPI+lasFyVsEQn1J/IFmp5Aax41+dAP9wg==}
engines: {node: '>=12'}