@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.js CHANGED
@@ -259,6 +259,16 @@ function unkeyApiKeysUIFeature() {
259
259
  ]
260
260
  };
261
261
  }
262
+ function sanityContentUIFeature() {
263
+ return {
264
+ name: "sanity-content",
265
+ description: "Sanity content list UI",
266
+ components: ["badge", "card"],
267
+ needsApiClient: false,
268
+ notes: ["Open \"/integrations/sanity\" to check the Sanity connection."],
269
+ files: () => [componentFile("sanity-content-console.tsx", sanityContentTemplate()), integrationPageFile("sanity", "SanityContentConsole")]
270
+ };
271
+ }
262
272
  function billingUIFeature(input) {
263
273
  return {
264
274
  name: `${input.provider}-billing`,
@@ -1666,6 +1676,40 @@ export function UnkeyApiKeysConsole() {
1666
1676
  }
1667
1677
  `;
1668
1678
  }
1679
+ function sanityContentTemplate() {
1680
+ return `import { Badge } from "@/components/ui/badge";
1681
+ import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card";
1682
+
1683
+ export function SanityContentConsole() {
1684
+ return (
1685
+ <main className="min-h-screen bg-background px-6 py-12 text-foreground">
1686
+ <section className="mx-auto flex w-full max-w-3xl flex-col gap-6">
1687
+ <div className="space-y-3">
1688
+ <Badge variant="secondary">Sanity</Badge>
1689
+ <h1 className="text-3xl font-semibold tracking-normal">Content</h1>
1690
+ </div>
1691
+ <Card>
1692
+ <CardHeader>
1693
+ <CardTitle className="text-xl">Connected to Sanity</CardTitle>
1694
+ <CardDescription>
1695
+ Query documents with createServerQuery and invalidate them from the Sanity webhook.
1696
+ </CardDescription>
1697
+ </CardHeader>
1698
+ <CardContent className="space-y-3">
1699
+ <code className="block overflow-x-auto rounded-md border bg-muted/30 p-3 text-xs">
1700
+ cms.fetch(&apos;*[_type == &quot;post&quot;]{"{"} title {"}"}&apos;)
1701
+ </code>
1702
+ <p className="text-sm text-muted-foreground">
1703
+ Point a Sanity webhook at /api/sanity/webhook to keep cached pages fresh.
1704
+ </p>
1705
+ </CardContent>
1706
+ </Card>
1707
+ </section>
1708
+ </main>
1709
+ );
1710
+ }
1711
+ `;
1712
+ }
1669
1713
  function unkeyProtectedRouteTemplate() {
1670
1714
  return `export function GET() {
1671
1715
  return Response.json({
@@ -2208,6 +2252,43 @@ export const unkeyIntegration = unkey({
2208
2252
  console.log("[unkey]", event.phase, event.route?.path || "none");
2209
2253
  },
2210
2254
  });
2255
+ `
2256
+ },
2257
+ {
2258
+ provider: "sanity",
2259
+ aliases: ["cms", "sanity-cms"],
2260
+ defaultKey: "cms",
2261
+ packageName: "@farm.js/sanity",
2262
+ fileName: "sanity",
2263
+ exportName: "sanityIntegration",
2264
+ description: "Sanity content with server queries, CDN images, and webhook cache invalidation",
2265
+ env: [
2266
+ "SANITY_PROJECT_ID",
2267
+ "SANITY_DATASET",
2268
+ "SANITY_API_READ_TOKEN",
2269
+ "SANITY_WEBHOOK_SECRET"
2270
+ ],
2271
+ dependencies: { "@sanity/client": "^8.4.0" },
2272
+ ui: sanityContentUIFeature(),
2273
+ template: () => `import { sanity } from "@farm.js/sanity";
2274
+
2275
+ export const sanityIntegration = sanity({
2276
+ projectId: process.env.SANITY_PROJECT_ID,
2277
+ dataset: process.env.SANITY_DATASET,
2278
+ token: process.env.SANITY_API_READ_TOKEN,
2279
+ // The webhook fires before Sanity's CDN updates, so reads go through the API.
2280
+ useCdn: false,
2281
+ webhook: {
2282
+ secret: process.env.SANITY_WEBHOOK_SECRET,
2283
+ onChange(payload) {
2284
+ console.log("[sanity]", payload._type, payload._id);
2285
+ return undefined;
2286
+ },
2287
+ },
2288
+ log(event) {
2289
+ console.log("[sanity]", event.phase, event.route?.path || "none");
2290
+ },
2291
+ });
2211
2292
  `
2212
2293
  }
2213
2294
  ];
@@ -2547,6 +2628,7 @@ const FARM_TELEMETRY_TEMPLATES = [
2547
2628
  "jobs-trigger",
2548
2629
  "polar",
2549
2630
  "resend",
2631
+ "sanity",
2550
2632
  "stripe",
2551
2633
  "supabase",
2552
2634
  "unkey",