@usegraft/sdk-next 1.0.0-beta.2 → 1.0.0-beta.3

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/README.md CHANGED
@@ -62,14 +62,18 @@ Pass `trust="full"` only when every author of the repository has commit access,
62
62
  ```ts
63
63
  import { revalidateContent, updateContent } from "@usegraft/sdk-next";
64
64
 
65
- // in a route handler, after a compile webhook
65
+ // in your own route handler, called with a compile's change list
66
66
  revalidateContent(branch, changes);
67
67
 
68
- // in a Server Action, for read-your-own-writes
68
+ // in a Server Action, for read-your-own-writes (Next.js 16 only)
69
69
  updateContent(branch, changes);
70
70
  ```
71
71
 
72
- Both turn a compile's `ChangeSet` into the exact `revalidateTag` / `updateTag` calls that refresh the changed pages, and no others. A no-op unless your reads were cached with `'use cache'` and `cacheTag`, but always safe to call.
72
+ Both turn a compile's `ChangeSet` into the exact `revalidateTag` / `updateTag` calls that refresh the changed pages, and no others. A no-op unless your reads were tagged, but always safe to call. On Next.js 16, tag reads with `'use cache'` and `cacheTag`. On Next.js 15, wrap them in `unstable_cache` with `tags: tagsFor(...)`. `updateContent` needs Next.js 16 and throws on older versions. Use `revalidateContent` there.
73
+
74
+ ## Supported versions
75
+
76
+ Next.js 15.5.24 and later 15.x, and 16.3.3 and later, with the App Router and React 19. Those are the first releases with the fixes for the critical Next.js advisories published in 2026. CI builds and serves a real app on each major. Next.js 14 is not supported: it no longer gets security fixes, and it has open critical advisories.
73
77
 
74
78
  ---
75
79
 
package/dist/index.d.ts CHANGED
@@ -31,14 +31,16 @@ type RevalidateProfile = string | {
31
31
  };
32
32
  /**
33
33
  * Background-invalidate the Data Cache for everything a compile changed, on
34
- * `branch`. Call it from a **route handler** (a compile webhook): the next
35
- * request triggers a background refresh (stale-while-revalidate). Refreshes
36
- * only the changed pages — per-doc + per-collection tags — and returns them.
34
+ * `branch`. Call it from a **route handler** (your own route, called with a
35
+ * compile's change list): the next request triggers a background refresh
36
+ * (stale-while-revalidate). Refreshes only the changed pages — per-doc +
37
+ * per-collection tags — and returns them.
37
38
  *
38
39
  * `profile` is Next 16's required cache-life argument to `revalidateTag`
39
40
  * (a built-in name like `"max"`/`"hours"` or `{ expire }`); defaults to `"max"`.
40
- * A no-op unless the reads were cached with `'use cache'` + `cacheTag`, but
41
- * always safe to call.
41
+ * Next 15 takes the tag alone and ignores a second argument, so it is passed
42
+ * on every version. A no-op unless the reads were tagged (`'use cache'` +
43
+ * `cacheTag`, or `unstable_cache` with `tags`), but always safe to call.
42
44
  */
43
45
  declare function revalidateContent(branch: string, changes: ChangeSet, profile?: RevalidateProfile): string[];
44
46
  /**
@@ -47,6 +49,9 @@ declare function revalidateContent(branch: string, changes: ChangeSet, profile?:
47
49
  * in-app "publish" that compiles then updates): the same request sees fresh
48
50
  * content. Returns the tags it hit. Like `revalidateContent`, a no-op unless
49
51
  * the reads were cached with `'use cache'` + `cacheTag`.
52
+ *
53
+ * Needs Next 16, the release that added `updateTag`. On 15 it throws before
54
+ * touching any tag, and the error names `revalidateContent` as the fallback.
50
55
  */
51
56
  declare function updateContent(branch: string, changes: ChangeSet): string[];
52
57
 
package/dist/index.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/graft.ts
2
- import { revalidateTag, updateTag } from "next/cache";
2
+ import { GraftError } from "@usegraft/contracts";
3
+ import * as nextCache from "next/cache";
3
4
  import { cache } from "react";
4
5
  import { createDbClient } from "@usegraft/sdk-core/db";
5
6
  import {
@@ -28,12 +29,22 @@ function createGraft(options) {
28
29
  searchContent: (collection, query, opts) => cachedSearch(collection, query, opts?.branch, opts?.limit)
29
30
  };
30
31
  }
32
+ var nextCacheApi = nextCache;
31
33
  function revalidateContent(branch, changes, profile = "max") {
32
34
  const tags = tagsForChanges(branch, changes);
33
- for (const tag of tags) revalidateTag(tag, profile);
35
+ for (const tag of tags) nextCacheApi.revalidateTag(tag, profile);
34
36
  return tags;
35
37
  }
36
38
  function updateContent(branch, changes) {
39
+ const { updateTag } = nextCacheApi;
40
+ if (typeof updateTag !== "function") {
41
+ throw new GraftError({
42
+ code: "FRAMEWORK_VERSION_UNSUPPORTED",
43
+ message: "updateContent needs Next.js 16. This version of next/cache has no updateTag.",
44
+ fix: "Call revalidateContent(branch, changes) instead. It works on Next.js 15 and 16 and refreshes on the next request rather than this one. Or upgrade to Next.js 16.",
45
+ details: { missing: "next/cache updateTag", fallback: "revalidateContent" }
46
+ });
47
+ }
37
48
  const tags = tagsForChanges(branch, changes);
38
49
  for (const tag of tags) updateTag(tag);
39
50
  return tags;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usegraft/sdk-next",
3
- "version": "1.0.0-beta.2",
3
+ "version": "1.0.0-beta.3",
4
4
  "description": "Next.js App Router adapter: typed content reads in Server Components, cache-tag invalidation, and real MDX rendering.",
5
5
  "keywords": [
6
6
  "agent",
@@ -30,6 +30,13 @@
30
30
  "main": "./dist/index.js",
31
31
  "module": "./dist/index.js",
32
32
  "types": "./dist/index.d.ts",
33
+ "typesVersions": {
34
+ "*": {
35
+ "config": [
36
+ "./dist/next-config.d.ts"
37
+ ]
38
+ }
39
+ },
33
40
  "exports": {
34
41
  ".": {
35
42
  "types": "./dist/index.d.ts",
@@ -46,20 +53,23 @@
46
53
  },
47
54
  "dependencies": {
48
55
  "@mdx-js/mdx": "^3.1.1",
49
- "@usegraft/db": "1.0.0-beta.2",
50
- "@usegraft/mdx-safety": "1.0.0-beta.2",
51
- "@usegraft/sdk-core": "1.0.0-beta.2",
56
+ "@usegraft/contracts": "1.0.0-beta.3",
57
+ "@usegraft/db": "1.0.0-beta.3",
58
+ "@usegraft/mdx-safety": "1.0.0-beta.3",
59
+ "@usegraft/sdk-core": "1.0.0-beta.3",
52
60
  "remark-gfm": "^4.0.1"
53
61
  },
54
62
  "devDependencies": {
55
63
  "@types/mdx": "^2.0.14",
56
64
  "@types/react": "^19.2.18",
57
- "@usegraft/core": "1.0.0-beta.2",
58
- "next": "^16.3.3",
65
+ "@usegraft/auth": "1.0.0-beta.3",
66
+ "@usegraft/core": "1.0.0-beta.3",
67
+ "@usegraft/mcp": "1.0.0-beta.3",
68
+ "next": "^16.3.8",
59
69
  "react": "^19.2.8"
60
70
  },
61
71
  "peerDependencies": {
62
- "next": ">=15.0.0",
72
+ "next": "^15.5.24 || ^16.3.3",
63
73
  "react": "^19.0.0"
64
74
  },
65
75
  "engines": {
@@ -68,7 +78,7 @@
68
78
  "scripts": {
69
79
  "build": "tsup src/index.ts src/next-config.ts --format esm --dts --clean --external react --external react/jsx-runtime --external next",
70
80
  "dev": "tsup src/index.ts src/next-config.ts --format esm --watch --external react --external react/jsx-runtime --external next",
71
- "typecheck": "tsc --noEmit",
81
+ "typecheck": "tsc --noEmit && node scripts/typecheck-guide.mjs",
72
82
  "test": "vitest run --passWithNoTests"
73
83
  }
74
84
  }