Skip to content

Commit

Permalink
Add prettier, dependencies and various other clean-up
Browse files Browse the repository at this point in the history
  • Loading branch information
mattvagni committed Nov 17, 2023
1 parent b631805 commit f7ee9aa
Show file tree
Hide file tree
Showing 84 changed files with 3,732 additions and 480 deletions.
48 changes: 48 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Lint

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- uses: actions/setup-node@v3
with:
node-version: '18'

- uses: pnpm/action-setup@v2
name: Install pnpm
with:
version: 8
run_install: false

- name: Get pnpm store directory
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV
- uses: actions/cache@v3
name: Setup pnpm cache
with:
path: ${{ env.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
- name: Install dependencies
run: pnpm install

- name: Install deps
run: pnpm i

- name: Lint
run: pnpm run lint
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
6 changes: 6 additions & 0 deletions .perttierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 100,
"trailingComma": "es5",
"singleQuote": true,
"tabWidth": 2
}
11 changes: 7 additions & 4 deletions _snippets/browser/upload-attachment.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ function uploadAttachment(fileBlob, uploadFormUrl, uploadFormData) {
form.append(key, value);
});

const file = new File([fileBlob], 'file');
form.append('file', file);
const file = new File([fileBlob], "file");
form.append("file", file);

console.log(`Uploading attachment to ${uploadFormUrl}`);

fetch(uploadFormUrl, {
method: 'POST',
method: "POST",
body: form,
})
.then((res) => {
Expand All @@ -28,7 +28,10 @@ function uploadAttachment(fileBlob, uploadFormUrl, uploadFormData) {
console.log(`File successfully uploaded! (code=${res.status})`);
})
.catch((err) => {
console.log(`There was an error uploading the file: %s`, err.message ? err.message : err);
console.log(
`There was an error uploading the file: %s`,
err.message ? err.message : err,
);
});
}
```
5 changes: 4 additions & 1 deletion _snippets/graphql/add-labels.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@ mutation addLabels($input: AddLabelsInput!) {
```json filename="Variables"
{
"input": {
"labelTypeIds": ["lt_01HB8BTNTZ58730MX8H5VMKFD5", "lt_01HB8BTNKSCF1FK5ETFVRSDC6G"],
"labelTypeIds": [
"lt_01HB8BTNTZ58730MX8H5VMKFD5",
"lt_01HB8BTNKSCF1FK5ETFVRSDC6G"
],
"threadId": "th_01H8H46YPB2S4MAJM382FG9423"
}
}
Expand Down
4 changes: 3 additions & 1 deletion _snippets/graphql/remove-customer-from-groups.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
```graphql filename="Mutation"
mutation removeCustomerFromCustomerGroup($input: RemoveCustomerFromCustomerGroupsInput!) {
mutation removeCustomerFromCustomerGroup(
$input: RemoveCustomerFromCustomerGroupsInput!
) {
removeCustomerFromCustomerGroups(input: $input) {
error {
message
Expand Down
10 changes: 5 additions & 5 deletions _snippets/node/upload-attachment.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
```js
const axios = require('axios');
const FormData = require('form-data');
const axios = require("axios");
const FormData = require("form-data");

/**
* Upload an attachment.
Expand All @@ -15,15 +15,15 @@ function uploadAttachment(fileBuffer, uploadFormUrl, uploadFormData) {
form.append(key, value);
});

form.append('file', fileBuffer, { filename: 'file' });
form.append("file", fileBuffer, { filename: "file" });

console.log(`Uploading attachment to ${uploadFormUrl}`);

axios
.post(uploadFormUrl, form, {
headers: {
...form.getHeaders(),
'Content-Length': form.getLengthSync(),
"Content-Length": form.getLengthSync(),
},
})
.then((res) => {
Expand All @@ -32,7 +32,7 @@ function uploadAttachment(fileBuffer, uploadFormUrl, uploadFormData) {
.catch((err) => {
console.log(
`There was an error uploading the file: %s`,
err.response ? err.response.data : err
err.response ? err.response.data : err,
);
});
}
Expand Down
60 changes: 30 additions & 30 deletions _snippets/typescript-sdk/add-customer-to-group-response.mdx
Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@
```js
[
{
customerId: 'c_01GTC6ZHCMAGR06FMPN9VY5J95',
customerId: "c_01GTC6ZHCMAGR06FMPN9VY5J95",
createdAt: {
__typename: 'DateTime',
iso8601: '2023-06-21T14:20:12.014Z',
unixTimestamp: '1687357212014',
__typename: "DateTime",
iso8601: "2023-06-21T14:20:12.014Z",
unixTimestamp: "1687357212014",
},
createdBy: {
__typename: 'MachineUserActor',
machineUserId: 'mu_01H1P0P0PHA2BJRRS7EC02XKCF',
__typename: "MachineUserActor",
machineUserId: "mu_01H1P0P0PHA2BJRRS7EC02XKCF",
},
updatedAt: {
__typename: 'DateTime',
iso8601: '2023-06-21T14:20:12.014Z',
unixTimestamp: '1687357212014',
__typename: "DateTime",
iso8601: "2023-06-21T14:20:12.014Z",
unixTimestamp: "1687357212014",
},
updatedBy: {
__typename: 'MachineUserActor',
machineUserId: 'mu_01H1P0P0PHA2BJRRS7EC02XKCF',
__typename: "MachineUserActor",
machineUserId: "mu_01H1P0P0PHA2BJRRS7EC02XKCF",
},
customerGroup: {
id: 'cg_01H1P1RK22WTVMFRY8BX6S6VJX',
name: 'free tier',
key: 'free-tier',
color: '#E78450',
id: "cg_01H1P1RK22WTVMFRY8BX6S6VJX",
name: "free tier",
key: "free-tier",
color: "#E78450",
},
},
{
customerId: 'c_01GTC6ZHCMAGR06FMPN9VY5J95',
customerId: "c_01GTC6ZHCMAGR06FMPN9VY5J95",
createdAt: {
__typename: 'DateTime',
iso8601: '2023-06-21T14:20:12.014Z',
unixTimestamp: '1687357212014',
__typename: "DateTime",
iso8601: "2023-06-21T14:20:12.014Z",
unixTimestamp: "1687357212014",
},
createdBy: {
__typename: 'MachineUserActor',
machineUserId: 'mu_01H1P0P0PHA2BJRRS7EC02XKCF',
__typename: "MachineUserActor",
machineUserId: "mu_01H1P0P0PHA2BJRRS7EC02XKCF",
},
updatedAt: {
__typename: 'DateTime',
iso8601: '2023-06-21T14:20:12.014Z',
unixTimestamp: '1687357212014',
__typename: "DateTime",
iso8601: "2023-06-21T14:20:12.014Z",
unixTimestamp: "1687357212014",
},
updatedBy: {
__typename: 'MachineUserActor',
machineUserId: 'mu_01H1P0P0PHA2BJRRS7EC02XKCF',
__typename: "MachineUserActor",
machineUserId: "mu_01H1P0P0PHA2BJRRS7EC02XKCF",
},
customerGroup: {
id: 'cg_01H1P1S2HD9PERNNS591ZT28ZZ',
name: 'design partner',
key: 'design-partner',
color: '#FBBF24',
id: "cg_01H1P1S2HD9PERNNS591ZT28ZZ",
name: "design partner",
key: "design-partner",
color: "#FBBF24",
},
},
];
Expand Down
10 changes: 5 additions & 5 deletions _snippets/typescript-sdk/add-customer-to-group.mdx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
```tsx
import { PlainClient } from '@team-plain/typescript-sdk';
import { PlainClient } from "@team-plain/typescript-sdk";

const client = new PlainClient({ apiKey: 'plainApiKey_xxx' });
const client = new PlainClient({ apiKey: "plainApiKey_xxx" });

const res = await client.addCustomerToCustomerGroups({
customerId: 'c_01GTC6ZHCMAGR06FMPN9VY5J95',
customerId: "c_01GTC6ZHCMAGR06FMPN9VY5J95",
customerGroupIdentifiers: [
{
customerGroupKey: 'free-tier',
customerGroupKey: "free-tier",
},
{
customerGroupKey: 'design-partner',
customerGroupKey: "design-partner",
},
],
});
Expand Down
8 changes: 4 additions & 4 deletions _snippets/typescript-sdk/add-labels.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
```tsx
import { PlainClient } from '@team-plain/typescript-sdk';
import { PlainClient } from "@team-plain/typescript-sdk";

const client = new PlainClient({ apiKey: 'plainApiKey_xxx' });
const client = new PlainClient({ apiKey: "plainApiKey_xxx" });

const res = await client.addLabels({
labelTypeIds: ['lt_01HB8BTNVM7GEBKBEDNC2K8ST7'],
threadId: 'th_01HD1G6649R1DK061W27VBT7QB',
labelTypeIds: ["lt_01HB8BTNVM7GEBKBEDNC2K8ST7"],
threadId: "th_01HD1G6649R1DK061W27VBT7QB",
});

if (res.error) {
Expand Down
8 changes: 4 additions & 4 deletions _snippets/typescript-sdk/assign-thread.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
```tsx
import { PlainClient } from '@team-plain/typescript-sdk';
import { PlainClient } from "@team-plain/typescript-sdk";

const client = new PlainClient({
apiKey: 'XXX',
apiKey: "XXX",
});

const res = await client.assignThread({
threadId: 'th_01H8H46YPB2S4MAJM382FG9423',
userId: 'u_01FSVKMHFDHJ3H5XFM20EMCBQN',
threadId: "th_01H8H46YPB2S4MAJM382FG9423",
userId: "u_01FSVKMHFDHJ3H5XFM20EMCBQN",

// You could instead assign to a machine user by doing:
// machineUserId: 'XXX'
Expand Down
6 changes: 5 additions & 1 deletion _snippets/typescript-sdk/create-attachment-url-response.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@
"__typename": "Attachment",
"id": "att_01H3970W7XG1716AVNGQ6FWYGD",
"fileName": "the-filename.jpeg",
"fileSize": { "__typename": "FileSize", "kiloBytes": 32.32, "megaBytes": 0.03 },
"fileSize": {
"__typename": "FileSize",
"kiloBytes": 32.32,
"megaBytes": 0.03
},
"fileExtension": null,
"updatedAt": {
"__typename": "DateTime",
Expand Down
10 changes: 5 additions & 5 deletions _snippets/typescript-sdk/create-attachment-url.mdx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
```ts /c_XXXXXXXXXXXXXXXXXXXXXXXXXX/
import { AttachmentType, PlainClient } from '@team-plain/typescript-sdk';
import { AttachmentType, PlainClient } from "@team-plain/typescript-sdk";

const client = new PlainClient({ apiKey: 'XXX' });
const client = new PlainClient({ apiKey: "XXX" });

const res = await client.createAttachmentUploadUrl({
customerId: 'c_XXXXXXXXXXXXXXXXXXXXXXXXXX',
fileName: 'the-filename.jpeg',
customerId: "c_XXXXXXXXXXXXXXXXXXXXXXXXXX",
fileName: "the-filename.jpeg",
fileSizeBytes: 32318,
attachmentType: AttachmentType.CustomTimelineEntry,
});

if (res.error) {
console.error(res.error);
} else {
console.log('Attachment upload url created');
console.log("Attachment upload url created");
console.log(res.data);
}
```
20 changes: 10 additions & 10 deletions _snippets/typescript-sdk/create-customer-event.mdx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
```tsx
import { PlainClient, uiComponent } from '@team-plain/typescript-sdk';
import { PlainClient, uiComponent } from "@team-plain/typescript-sdk";

const client = new PlainClient({
apiKey: 'XXX',
apiKey: "XXX",
debug: true,
});

const res = await client.createCustomerEvent({
title: 'API key generated',
title: "API key generated",

customerIdentifier: {
// You can use the email:
email: '[email protected]',
email: "[email protected]",

// ...or if you set external id on customers:
// externalId: 'YOUR_ID',
Expand All @@ -22,26 +22,26 @@ const res = await client.createCustomerEvent({

components: [
uiComponent.text({
text: 'New API key was added with the fingerprint **3b7896975ee9fd15eeb7** with 4 associated roles.',
text: "New API key was added with the fingerprint **3b7896975ee9fd15eeb7** with 4 associated roles.",
}),
uiComponent.spacer({
size: 'M',
size: "M",
}),
uiComponent.linkButton({
label: 'View in admin',
url: 'https://admin.your-app.com',
label: "View in admin",
url: "https://admin.your-app.com",
}),
],

// Optional - if provided, this will ensure that this event can only
// be created once and fail on the second time. This external id acts
// as an idempotency key while also letting you correlate an event to
// something your systems.
externalId: 'XXX',
externalId: "XXX",

// Optional - if provided then the event will only be shown
// in a single thread vs all threads from a customer
threadId: 'th_01HB924RWAW8H3Q8KZDFWYBJHZ',
threadId: "th_01HB924RWAW8H3Q8KZDFWYBJHZ",
});

if (res.error) {
Expand Down
Loading

0 comments on commit f7ee9aa

Please sign in to comment.