@yak-io/prismic 0.1.1 → 0.1.2

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.
Files changed (2) hide show
  1. package/README.md +59 -28
  2. package/package.json +4 -2
package/README.md CHANGED
@@ -1,14 +1,10 @@
1
1
  # @yak-io/prismic
2
2
 
3
- Adapters that turn Prismic CMS documents into Yak routes, tools, and schema sources. This package plugs directly into `@yak-io/javascript` and works seamlessly with the Next.js and Nuxt helpers.
3
+ > 📚 **Full documentation:** https://docs.yak.io/docs/cms/prismic
4
+ >
5
+ > 🤖 **For LLMs / AI agents:** https://docs.yak.io/llms.txt
4
6
 
5
- ## What you get
6
-
7
- - `createPrismicRouteAdapter` – produces a `RouteSource` from Prismic documents. Use it when your routes live in Prismic instead of (or alongside) the filesystem.
8
- - `createPrismicToolAdapter` – produces a `ToolSource` exposing `prismic.getByUID`, `prismic.getAllByType`, and `prismic.search` as tools the LLM can invoke.
9
- - `createPrismicSchemaSource` – produces a `SchemaSource` describing the Prismic content model so the LLM understands document types and fields.
10
-
11
- ## Installation
7
+ Prismic CMS adapter for [Yak](https://docs.yak.io). It turns Prismic documents into Yak **routes** (so the assistant knows your pages), **tools** (so it can fetch content), and a **schema source** (so it understands your content model). Plugs into `@yak-io/javascript`'s `createYakHandler` or `@yak-io/nextjs`'s `createNextYakHandler`.
12
8
 
13
9
  ```bash
14
10
  pnpm add @yak-io/prismic @yak-io/javascript @prismicio/client
@@ -16,6 +12,14 @@ pnpm add @yak-io/prismic @yak-io/javascript @prismicio/client
16
12
 
17
13
  `@prismicio/client` is a peer dependency (v7+).
18
14
 
15
+ ## Exports
16
+
17
+ | Export | Returns | Purpose |
18
+ | --- | --- | --- |
19
+ | `createPrismicRouteAdapter(config)` | `RouteSource` | Routes from Prismic documents — when pages live in Prismic. |
20
+ | `createPrismicToolAdapter(config)` | `ToolSource` | Exposes `prismic.getByUID`, `prismic.getAllByType`, `prismic.search` as tools. |
21
+ | `createPrismicSchemaSource(config)` | `SchemaSource` | Describes your content model so the assistant understands document types + fields. |
22
+
19
23
  ## Usage
20
24
 
21
25
  ### 1. Create a Prismic client
@@ -28,14 +32,11 @@ const client = prismic.createClient("your-repo-name", {
28
32
  });
29
33
  ```
30
34
 
31
- ### 2. Use it with a Yak handler
35
+ ### 2. Wire adapters into a Yak handler (server)
32
36
 
33
37
  ```ts
34
38
  import { createNextYakHandler } from "@yak-io/nextjs/server";
35
- import {
36
- createPrismicRouteAdapter,
37
- createPrismicToolAdapter,
38
- } from "@yak-io/prismic";
39
+ import { createPrismicRouteAdapter, createPrismicToolAdapter } from "@yak-io/prismic";
39
40
 
40
41
  const prismicRoutes = createPrismicRouteAdapter({
41
42
  client,
@@ -58,11 +59,9 @@ export const { GET, POST } = createNextYakHandler({
58
59
  });
59
60
  ```
60
61
 
61
- The adapters return standard `RouteSource` / `ToolSource` shapes, so you can compose them with filesystem routes, tRPC tools, or any other source by passing arrays.
62
+ Both return standard `RouteSource` / `ToolSource` shapes, so you can compose them with filesystem routes, tRPC tools, or any other source by passing arrays.
62
63
 
63
- ### 3. Optionally expose the content model
64
-
65
- Inside your client-side `getConfig` provider:
64
+ ### 3. Optionally expose the content model (client `getConfig`)
66
65
 
67
66
  ```ts
68
67
  import { createPrismicSchemaSource } from "@yak-io/prismic";
@@ -70,27 +69,59 @@ import { createPrismicSchemaSource } from "@yak-io/prismic";
70
69
  const getConfig = async () => {
71
70
  const res = await fetch("/api/yak");
72
71
  const config = await res.json();
73
- const schemaSource = await createPrismicSchemaSource({
74
- client,
75
- mode: "graphql",
76
- });
72
+ const schemaSource = await createPrismicSchemaSource({ client, mode: "graphql" });
77
73
  return { ...config, schemaSources: [schemaSource] };
78
74
  };
79
75
  ```
80
76
 
77
+ ## API reference
78
+
79
+ ### `createPrismicRouteAdapter(config)`
80
+
81
+ | Option | Type | Default | Description |
82
+ | --- | --- | --- | --- |
83
+ | `client` | `Client` | — | Prismic client (required). |
84
+ | `documentTypes` | `string[]` | — | Document types to turn into routes (required). |
85
+ | `resolveRoute` | `(doc) => RouteInfo \| null` | — | Map a document to a route; return `null` to skip it (e.g. drafts) (required). |
86
+ | `filters` | `string[]` | — | Prismic query filters. |
87
+ | `id` | `string` | `"prismic"` | Source id. |
88
+
89
+ ### `createPrismicToolAdapter(config)`
90
+
91
+ | Option | Type | Default | Description |
92
+ | --- | --- | --- | --- |
93
+ | `client` | `Client` | — | Prismic client (required). |
94
+ | `allowedTypes` | `string[]` | — | Document types the assistant may fetch (required). |
95
+ | `fields` | `Record<string, string[]>` | — | Per-type field allowlist returned to the assistant. |
96
+ | `id` | `string` | `"prismic"` | Source id. |
97
+
98
+ ### `createPrismicSchemaSource(config)`
99
+
100
+ | Option | Type | Default | Description |
101
+ | --- | --- | --- | --- |
102
+ | `client` | `Client` | — | Prismic client (required). |
103
+ | `mode` | `"graphql"` | — | Schema introspection mode (required). |
104
+ | `name` | `string` | — | Schema source name. |
105
+ | `fetchFn` | `typeof fetch` | global `fetch` | Custom fetch implementation. |
106
+
107
+ ## Security
108
+
109
+ - Always set `allowedTypes` on the tool adapter — without it the assistant could fetch any document type in your repository.
110
+ - Return `null` from `resolveRoute` to keep drafts or hidden pages out of the route manifest.
111
+
81
112
  ## Types
82
113
 
83
- All route/tool/schema types are re-exported from `@yak-io/javascript/server`:
114
+ Route/tool/schema types are re-exported from `@yak-io/javascript/server`:
84
115
 
85
116
  ```ts
86
117
  import type { RouteSource, ToolSource, SchemaSource } from "@yak-io/prismic";
118
+ import type {
119
+ PrismicRouteAdapterConfig,
120
+ PrismicToolAdapterConfig,
121
+ PrismicSchemaSourceConfig,
122
+ } from "@yak-io/prismic";
87
123
  ```
88
124
 
89
- ## Security tips
90
-
91
- - Always set `allowedTypes` on the tool adapter — without it the LLM can fetch any document type in your repository.
92
- - `resolveRoute` returning `null` skips a document — use this to filter drafts or hidden pages out of the manifest.
93
-
94
125
  ## License
95
126
 
96
- Proprietary - see LICENSE file
127
+ Proprietary see [LICENSE](./LICENSE).
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yak-io/prismic",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Prismic CMS adapter for yak chatbot - exposes Prismic documents as routes, tools, and schema sources",
5
5
  "type": "module",
6
6
  "license": "SEE LICENSE IN LICENSE",
@@ -24,6 +24,7 @@
24
24
  "node": ">=18"
25
25
  },
26
26
  "files": [
27
+ "README.md",
27
28
  "dist",
28
29
  "LICENSE"
29
30
  ],
@@ -40,7 +41,7 @@
40
41
  "./package.json": "./package.json"
41
42
  },
42
43
  "dependencies": {
43
- "@yak-io/javascript": "0.8.0"
44
+ "@yak-io/javascript": "0.9.0"
44
45
  },
45
46
  "peerDependencies": {
46
47
  "@prismicio/client": "^7.0.0",
@@ -58,6 +59,7 @@
58
59
  "typescript": "^5.3.0",
59
60
  "@repo/typescript-config": "0.0.0"
60
61
  },
62
+ "homepage": "https://docs.yak.io/docs/cms/prismic",
61
63
  "scripts": {
62
64
  "build": "tsc",
63
65
  "check-types": "tsc --noEmit",