attio 0.0.1-experimental.20250512 → 0.0.1-experimental.20250513.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/template/package.json +10 -9
- package/lib/template/src/get-stoic-quote.server.ts +14 -0
- package/lib/template/src/hello-world-dialog.tsx +4 -4
- package/lib/template/src/stoic-quote.tsx +21 -0
- package/package.json +1 -1
- package/lib/template/src/cat-fact.tsx +0 -16
- package/lib/template/src/get-cat-fact.server.ts +0 -6
|
@@ -13,18 +13,19 @@
|
|
|
13
13
|
"lint": "ATTIO_LINT_MODE='exhaustive' eslint \"src/**/*.{ts,tsx,js,tsx}\""
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@types/react": "19.
|
|
17
|
-
"@typescript-eslint/eslint-plugin": "8.
|
|
18
|
-
"@typescript-eslint/parser": "8.
|
|
16
|
+
"@types/react": "19.1.4",
|
|
17
|
+
"@typescript-eslint/eslint-plugin": "8.32.1",
|
|
18
|
+
"@typescript-eslint/parser": "8.32.1",
|
|
19
19
|
"eslint": "8.57.1",
|
|
20
|
-
"eslint-plugin-react": "7.37.
|
|
21
|
-
"eslint-plugin-react-hooks": "5.
|
|
22
|
-
"typescript": "5.
|
|
20
|
+
"eslint-plugin-react": "7.37.5",
|
|
21
|
+
"eslint-plugin-react-hooks": "5.2.0",
|
|
22
|
+
"typescript": "5.8.3"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@eslint/eslintrc": "3.
|
|
26
|
-
"@eslint/js": "9.
|
|
25
|
+
"@eslint/eslintrc": "3.3.1",
|
|
26
|
+
"@eslint/js": "9.26.0",
|
|
27
27
|
"attio": "latest",
|
|
28
|
-
"react": "19.
|
|
28
|
+
"react": "19.1.0",
|
|
29
|
+
"zod": "3.24.4"
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {z} from "zod"
|
|
2
|
+
|
|
3
|
+
const quoteSchema = z.object({
|
|
4
|
+
text: z.string(),
|
|
5
|
+
author: z.string(),
|
|
6
|
+
})
|
|
7
|
+
export type Quote = z.infer<typeof quoteSchema>
|
|
8
|
+
|
|
9
|
+
export default async function getStoicQuote(recordId: string): Promise<Quote> {
|
|
10
|
+
// We don't really need the recordId for this API, but this is how we could use a parameter
|
|
11
|
+
const response = await fetch(`https://stoic-quotes.com/api/quote?${recordId}`)
|
|
12
|
+
const data = await response.json()
|
|
13
|
+
return quoteSchema.parse(data)
|
|
14
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react"
|
|
2
2
|
import {TextBlock} from "attio/client"
|
|
3
|
-
import {
|
|
3
|
+
import {StoicQuote} from "./stoic-quote"
|
|
4
4
|
|
|
5
|
-
const Loading = () => <TextBlock>Loading
|
|
5
|
+
const Loading = () => <TextBlock>Loading stoic quote...</TextBlock>
|
|
6
6
|
|
|
7
7
|
export function HelloWorldDialog({recordId}: {recordId: string}) {
|
|
8
8
|
// A simple counter to demonstrate that this is just regular React code.
|
|
@@ -17,9 +17,9 @@ export function HelloWorldDialog({recordId}: {recordId: string}) {
|
|
|
17
17
|
<TextBlock align="left">
|
|
18
18
|
I am a dialog. I have been open for: {seconds} second{seconds === 1 ? "" : "s"}
|
|
19
19
|
</TextBlock>
|
|
20
|
-
{/* The hook in
|
|
20
|
+
{/* The hook in StoicQuote will suspend until the stoic quote is loaded. */}
|
|
21
21
|
<React.Suspense fallback={<Loading />}>
|
|
22
|
-
<
|
|
22
|
+
<StoicQuote recordId={recordId} />
|
|
23
23
|
</React.Suspense>
|
|
24
24
|
</>
|
|
25
25
|
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react"
|
|
2
|
+
import {Column, TextBlock, useAsyncCache} from "attio/client"
|
|
3
|
+
import getStoicQuote from "./get-stoic-quote.server"
|
|
4
|
+
|
|
5
|
+
export function StoicQuote({recordId}: {recordId: string}) {
|
|
6
|
+
// By passing in the recordId, the result will be cached for each recordId
|
|
7
|
+
const {
|
|
8
|
+
values: {quote},
|
|
9
|
+
// ^^^^^– this key matches
|
|
10
|
+
// vvvvv– this key
|
|
11
|
+
} = useAsyncCache({quote: [getStoicQuote, recordId]})
|
|
12
|
+
// ^^^^^^^^^^^^^ ^^^^^^^^
|
|
13
|
+
// async fn parameter(s)
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<Column>
|
|
17
|
+
<TextBlock align="center">{quote.text}</TextBlock>
|
|
18
|
+
<TextBlock align="right">– {quote.author}</TextBlock>
|
|
19
|
+
</Column>
|
|
20
|
+
)
|
|
21
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react"
|
|
2
|
-
import {TextBlock, useAsyncCache} from "attio/client"
|
|
3
|
-
import getCatFact from "./get-cat-fact.server"
|
|
4
|
-
|
|
5
|
-
export function CatFact({recordId}: {recordId: string}) {
|
|
6
|
-
// By passing in the recordId, the result will be cached for each recordId
|
|
7
|
-
const {
|
|
8
|
-
values: {catFact},
|
|
9
|
-
// ^^^^^^^– this key matches
|
|
10
|
-
// vvvvvvv– this key
|
|
11
|
-
} = useAsyncCache({catFact: [getCatFact, recordId]})
|
|
12
|
-
// ^^^^^^^^^^ ^^^^^^^^
|
|
13
|
-
// async fn parameter(s)
|
|
14
|
-
|
|
15
|
-
return <TextBlock align="center">{`"${catFact}"`}</TextBlock>
|
|
16
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
export default async function getCatFact(recordId: string): Promise<string> {
|
|
2
|
-
// We don't really need the recordId for this API, but this is how we could use a parameter
|
|
3
|
-
const response = await fetch(`https://catfact.ninja/fact?${recordId}`)
|
|
4
|
-
const data = await response.json()
|
|
5
|
-
return data.fact
|
|
6
|
-
}
|