@farm.js/create-app 0.1.0-beta.102 → 0.1.0-beta.104

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/dist/index.mjs CHANGED
@@ -252,6 +252,16 @@ function unkeyApiKeysUIFeature() {
252
252
  ]
253
253
  };
254
254
  }
255
+ function sanityContentUIFeature() {
256
+ return {
257
+ name: "sanity-content",
258
+ description: "Sanity content list UI",
259
+ components: ["badge", "card"],
260
+ needsApiClient: false,
261
+ notes: ["Open \"/integrations/sanity\" to check the Sanity connection."],
262
+ files: () => [componentFile("sanity-content-console.tsx", sanityContentTemplate()), integrationPageFile("sanity", "SanityContentConsole")]
263
+ };
264
+ }
255
265
  function billingUIFeature(input) {
256
266
  return {
257
267
  name: `${input.provider}-billing`,
@@ -1659,6 +1669,40 @@ export function UnkeyApiKeysConsole() {
1659
1669
  }
1660
1670
  `;
1661
1671
  }
1672
+ function sanityContentTemplate() {
1673
+ return `import { Badge } from "@/components/ui/badge";
1674
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
1675
+
1676
+ export function SanityContentConsole() {
1677
+ return (
1678
+ <main className="min-h-screen bg-background px-6 py-12 text-foreground">
1679
+ <section className="mx-auto flex w-full max-w-3xl flex-col gap-6">
1680
+ <div className="space-y-3">
1681
+ <Badge variant="secondary">Sanity</Badge>
1682
+ <h1 className="text-3xl font-semibold tracking-normal">Content</h1>
1683
+ </div>
1684
+ <Card>
1685
+ <CardHeader>
1686
+ <CardTitle className="text-xl">Connected to Sanity</CardTitle>
1687
+ <CardDescription>
1688
+ Query documents with createServerQuery and invalidate them from the Sanity webhook.
1689
+ </CardDescription>
1690
+ </CardHeader>
1691
+ <CardContent className="space-y-3">
1692
+ <code className="block overflow-x-auto rounded-md border bg-muted/30 p-3 text-xs">
1693
+ cms.fetch(&apos;*[_type == &quot;post&quot;]{"{"} title {"}"}&apos;)
1694
+ </code>
1695
+ <p className="text-sm text-muted-foreground">
1696
+ Point a Sanity webhook at /api/sanity/webhook to keep cached pages fresh.
1697
+ </p>
1698
+ </CardContent>
1699
+ </Card>
1700
+ </section>
1701
+ </main>
1702
+ );
1703
+ }
1704
+ `;
1705
+ }
1662
1706
  function unkeyProtectedRouteTemplate() {
1663
1707
  return `export function GET() {
1664
1708
  return Response.json({
@@ -2201,6 +2245,43 @@ export const unkeyIntegration = unkey({
2201
2245
  console.log("[unkey]", event.phase, event.route?.path || "none");
2202
2246
  },
2203
2247
  });
2248
+ `
2249
+ },
2250
+ {
2251
+ provider: "sanity",
2252
+ aliases: ["cms", "sanity-cms"],
2253
+ defaultKey: "cms",
2254
+ packageName: "@farm.js/sanity",
2255
+ fileName: "sanity",
2256
+ exportName: "sanityIntegration",
2257
+ description: "Sanity content with server queries, CDN images, and webhook cache invalidation",
2258
+ env: [
2259
+ "SANITY_PROJECT_ID",
2260
+ "SANITY_DATASET",
2261
+ "SANITY_API_READ_TOKEN",
2262
+ "SANITY_WEBHOOK_SECRET"
2263
+ ],
2264
+ dependencies: { "@sanity/client": "^8.4.0" },
2265
+ ui: sanityContentUIFeature(),
2266
+ template: () => `import { sanity } from "@farm.js/sanity";
2267
+
2268
+ export const sanityIntegration = sanity({
2269
+ projectId: process.env.SANITY_PROJECT_ID,
2270
+ dataset: process.env.SANITY_DATASET,
2271
+ token: process.env.SANITY_API_READ_TOKEN,
2272
+ // The webhook fires before Sanity's CDN updates, so reads go through the API.
2273
+ useCdn: false,
2274
+ webhook: {
2275
+ secret: process.env.SANITY_WEBHOOK_SECRET,
2276
+ onChange(payload) {
2277
+ console.log("[sanity]", payload._type, payload._id);
2278
+ return undefined;
2279
+ },
2280
+ },
2281
+ log(event) {
2282
+ console.log("[sanity]", event.phase, event.route?.path || "none");
2283
+ },
2284
+ });
2204
2285
  `
2205
2286
  }
2206
2287
  ];
@@ -2540,6 +2621,7 @@ const FARM_TELEMETRY_TEMPLATES = [
2540
2621
  "jobs-trigger",
2541
2622
  "polar",
2542
2623
  "resend",
2624
+ "sanity",
2543
2625
  "stripe",
2544
2626
  "supabase",
2545
2627
  "unkey",