@pantheon-systems/nextjs-cache-handler 0.1.0 → 0.2.0

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 (58) hide show
  1. package/README.md +110 -0
  2. package/dist/handlers/base.d.ts +9 -0
  3. package/dist/handlers/base.d.ts.map +1 -1
  4. package/dist/handlers/base.js +22 -0
  5. package/dist/handlers/base.js.map +1 -1
  6. package/dist/index.d.ts +5 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +15 -0
  9. package/dist/index.js.map +1 -1
  10. package/dist/middleware/index.d.ts +2 -0
  11. package/dist/middleware/index.d.ts.map +1 -0
  12. package/dist/middleware/index.js +2 -0
  13. package/dist/middleware/index.js.map +1 -0
  14. package/dist/middleware/surrogate-key.d.ts +29 -0
  15. package/dist/middleware/surrogate-key.d.ts.map +1 -0
  16. package/dist/middleware/surrogate-key.js +66 -0
  17. package/dist/middleware/surrogate-key.js.map +1 -0
  18. package/dist/use-cache/file-handler.d.ts +71 -0
  19. package/dist/use-cache/file-handler.d.ts.map +1 -0
  20. package/dist/use-cache/file-handler.js +366 -0
  21. package/dist/use-cache/file-handler.js.map +1 -0
  22. package/dist/use-cache/gcs-handler.d.ts +64 -0
  23. package/dist/use-cache/gcs-handler.d.ts.map +1 -0
  24. package/dist/use-cache/gcs-handler.js +406 -0
  25. package/dist/use-cache/gcs-handler.js.map +1 -0
  26. package/dist/use-cache/index.d.ts +58 -0
  27. package/dist/use-cache/index.d.ts.map +1 -0
  28. package/dist/use-cache/index.js +87 -0
  29. package/dist/use-cache/index.js.map +1 -0
  30. package/dist/use-cache/stream-serialization.d.ts +34 -0
  31. package/dist/use-cache/stream-serialization.d.ts.map +1 -0
  32. package/dist/use-cache/stream-serialization.js +96 -0
  33. package/dist/use-cache/stream-serialization.js.map +1 -0
  34. package/dist/use-cache/types.d.ts +202 -0
  35. package/dist/use-cache/types.d.ts.map +1 -0
  36. package/dist/use-cache/types.js +9 -0
  37. package/dist/use-cache/types.js.map +1 -0
  38. package/dist/utils/cache-tag-context.d.ts +66 -0
  39. package/dist/utils/cache-tag-context.d.ts.map +1 -0
  40. package/dist/utils/cache-tag-context.js +126 -0
  41. package/dist/utils/cache-tag-context.js.map +1 -0
  42. package/dist/utils/index.d.ts +3 -0
  43. package/dist/utils/index.d.ts.map +1 -1
  44. package/dist/utils/index.js +3 -0
  45. package/dist/utils/index.js.map +1 -1
  46. package/dist/utils/request-context.d.ts +28 -0
  47. package/dist/utils/request-context.d.ts.map +1 -0
  48. package/dist/utils/request-context.js +54 -0
  49. package/dist/utils/request-context.js.map +1 -0
  50. package/dist/utils/request-context.test.d.ts +2 -0
  51. package/dist/utils/request-context.test.d.ts.map +1 -0
  52. package/dist/utils/request-context.test.js +65 -0
  53. package/dist/utils/request-context.test.js.map +1 -0
  54. package/dist/utils/with-surrogate-key.d.ts +32 -0
  55. package/dist/utils/with-surrogate-key.d.ts.map +1 -0
  56. package/dist/utils/with-surrogate-key.js +113 -0
  57. package/dist/utils/with-surrogate-key.js.map +1 -0
  58. package/package.json +15 -1
@@ -0,0 +1,65 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { RequestContext } from './request-context';
3
+ describe('RequestContext', () => {
4
+ it('should isolate tags between contexts', () => {
5
+ RequestContext.run(() => {
6
+ RequestContext.addTags(['tag1', 'tag2']);
7
+ expect(RequestContext.getTags()).toEqual(['tag1', 'tag2']);
8
+ });
9
+ // Outside context, should be empty
10
+ expect(RequestContext.getTags()).toEqual([]);
11
+ });
12
+ it('should deduplicate tags', () => {
13
+ RequestContext.run(() => {
14
+ RequestContext.addTags(['tag1', 'tag2']);
15
+ RequestContext.addTags(['tag2', 'tag3']);
16
+ expect(RequestContext.getTags()).toEqual(['tag1', 'tag2', 'tag3']);
17
+ });
18
+ });
19
+ it('should handle nested contexts independently', async () => {
20
+ const results = [];
21
+ await Promise.all([
22
+ RequestContext.run(async () => {
23
+ RequestContext.addTags(['context1']);
24
+ await new Promise(resolve => setTimeout(resolve, 10));
25
+ results.push(RequestContext.getTags());
26
+ }),
27
+ RequestContext.run(async () => {
28
+ RequestContext.addTags(['context2']);
29
+ await new Promise(resolve => setTimeout(resolve, 5));
30
+ results.push(RequestContext.getTags());
31
+ }),
32
+ ]);
33
+ expect(results).toContainEqual(['context1']);
34
+ expect(results).toContainEqual(['context2']);
35
+ });
36
+ it('should detect when context is active', () => {
37
+ expect(RequestContext.isActive()).toBe(false);
38
+ RequestContext.run(() => {
39
+ expect(RequestContext.isActive()).toBe(true);
40
+ });
41
+ expect(RequestContext.isActive()).toBe(false);
42
+ });
43
+ it('should handle empty tag arrays', () => {
44
+ RequestContext.run(() => {
45
+ RequestContext.addTags([]);
46
+ expect(RequestContext.getTags()).toEqual([]);
47
+ });
48
+ });
49
+ it('should accumulate multiple tag additions', () => {
50
+ RequestContext.run(() => {
51
+ RequestContext.addTags(['tag1']);
52
+ RequestContext.addTags(['tag2']);
53
+ RequestContext.addTags(['tag3', 'tag4']);
54
+ expect(RequestContext.getTags()).toEqual(['tag1', 'tag2', 'tag3', 'tag4']);
55
+ });
56
+ });
57
+ it('should warn when adding tags outside context', () => {
58
+ // This test verifies that adding tags outside a context doesn't throw
59
+ // The actual warning is logged, but we can't easily test console output
60
+ expect(() => {
61
+ RequestContext.addTags(['tag1']);
62
+ }).not.toThrow();
63
+ });
64
+ });
65
+ //# sourceMappingURL=request-context.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"request-context.test.js","sourceRoot":"","sources":["../../src/utils/request-context.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD,QAAQ,CAAC,gBAAgB,EAAE,GAAG,EAAE;IAC9B,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,cAAc,CAAC,GAAG,CAAC,GAAG,EA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YACjC,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;YACjC,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;YACzC,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;QAC7E,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8CAA8C,EAAE,GAAG,EAAE;QACtD,sEAAsE;QACtE,wEAAwE;QACxE,MAAM,CAAC,GAAG,EAAE;YACV,cAAc,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,32 @@
1
+ import { NextRequest, NextResponse } from 'next/server.js';
2
+ export interface SurrogateKeyOptions {
3
+ /** Fallback Surrogate-Key when no tags are captured */
4
+ fallbackKey?: string;
5
+ /** Enable debug logging */
6
+ debug?: boolean;
7
+ }
8
+ type RouteHandler = (request: NextRequest, context?: {
9
+ params?: Promise<Record<string, string>>;
10
+ }) => Promise<NextResponse> | NextResponse;
11
+ /**
12
+ * Wraps a route handler to automatically set Surrogate-Key headers.
13
+ *
14
+ * Tags are captured from cache hits during request processing and
15
+ * added to the response as a Surrogate-Key header for CDN integration.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // app/api/posts/route.ts
20
+ * import { withSurrogateKey } from '@pantheon-systems/nextjs-cache-handler';
21
+ *
22
+ * async function handler(request: NextRequest) {
23
+ * const posts = await getCachedPosts(); // Tags captured from cache hits
24
+ * return NextResponse.json(posts);
25
+ * }
26
+ *
27
+ * export const GET = withSurrogateKey(handler);
28
+ * ```
29
+ */
30
+ export declare function withSurrogateKey(handler: RouteHandler, options?: SurrogateKeyOptions): RouteHandler;
31
+ export {};
32
+ //# sourceMappingURL=with-surrogate-key.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-surrogate-key.d.ts","sourceRoot":"","sources":["../../src/utils/with-surrogate-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAa3D,MAAM,WAAW,mBAAmB;IAClC,uDAAuD;IACvD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,2BAA2B;IAC3B,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,KAAK,YAAY,GAAG,CAClB,OAAO,EAAE,WAAW,EACpB,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAA;CAAE,KACnD,OAAO,CAAC,YAAY,CAAC,GAAG,YAAY,CAAC;AAE1C;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAC9B,OAAO,EAAE,YAAY,EACrB,OAAO,GAAE,mBAAwB,GAChC,YAAY,CAoGd"}
@@ -0,0 +1,113 @@
1
+ import { NextResponse } from 'next/server.js';
2
+ import { CacheTagContext } from './cache-tag-context.js';
3
+ import { createLogger } from './logger.js';
4
+ const log = createLogger('withSurrogateKey');
5
+ /**
6
+ * Symbol for registering path→surrogate-key mappings with the use-cache handler.
7
+ * When withSurrogateKey captures tags, it registers them so revalidatePath
8
+ * can resolve _N_T_ path tags to the correct CDN surrogate keys.
9
+ */
10
+ const PATH_TAGS_REGISTRY_SYMBOL = Symbol.for('@nextjs-cache-handler/path-tags-registry');
11
+ /**
12
+ * Wraps a route handler to automatically set Surrogate-Key headers.
13
+ *
14
+ * Tags are captured from cache hits during request processing and
15
+ * added to the response as a Surrogate-Key header for CDN integration.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * // app/api/posts/route.ts
20
+ * import { withSurrogateKey } from '@pantheon-systems/nextjs-cache-handler';
21
+ *
22
+ * async function handler(request: NextRequest) {
23
+ * const posts = await getCachedPosts(); // Tags captured from cache hits
24
+ * return NextResponse.json(posts);
25
+ * }
26
+ *
27
+ * export const GET = withSurrogateKey(handler);
28
+ * ```
29
+ */
30
+ export function withSurrogateKey(handler, options = {}) {
31
+ const { fallbackKey = 'page-content', debug = false } = options;
32
+ return async (request, context) => {
33
+ // Clear any stale global tags before starting request
34
+ // This is kept as a last-resort fallback for environments where Symbol.for doesn't propagate
35
+ const globalTags = globalThis.__pantheonSurrogateKeyTags;
36
+ if (globalTags) {
37
+ globalTags.length = 0;
38
+ }
39
+ // Run handler within CacheTagContext (uses Symbol.for pattern for cross-context propagation)
40
+ return CacheTagContext.run(async () => {
41
+ const requestId = CacheTagContext.getRequestId();
42
+ if (debug) {
43
+ log.debug(`Starting request ${requestId}`);
44
+ }
45
+ // Execute the original handler
46
+ const response = await handler(request, context);
47
+ // Primary: Get captured tags from CacheTagContext (Symbol.for pattern)
48
+ let capturedTags = CacheTagContext.getTags();
49
+ let tagSource = 'CacheTagContext';
50
+ if (debug && capturedTags.length > 0) {
51
+ log.debug(`CacheTagContext captured ${capturedTags.length} tags: ${capturedTags.join(', ')}`);
52
+ }
53
+ // Fallback: check global store for cross-context tag propagation
54
+ // This handles cases where even the Symbol.for pattern doesn't propagate
55
+ if (capturedTags.length === 0) {
56
+ const globalStoreTags = globalThis.__pantheonSurrogateKeyTags;
57
+ if (globalStoreTags && globalStoreTags.length > 0) {
58
+ capturedTags = [...new Set(globalStoreTags)];
59
+ tagSource = 'globalStore';
60
+ if (debug) {
61
+ log.debug(`Using global store fallback: ${capturedTags.length} tags`);
62
+ }
63
+ // Clear global tags after reading
64
+ globalStoreTags.length = 0;
65
+ }
66
+ }
67
+ if (debug) {
68
+ log.debug(`Captured ${capturedTags.length} tags from ${tagSource}: ${capturedTags.join(', ')}`);
69
+ }
70
+ // Register path→surrogate-key mapping for revalidatePath CDN clearing
71
+ if (capturedTags.length > 0) {
72
+ const requestPath = new URL(request.url).pathname;
73
+ const registerFn = globalThis[PATH_TAGS_REGISTRY_SYMBOL];
74
+ if (registerFn) {
75
+ registerFn(requestPath, capturedTags);
76
+ if (debug) {
77
+ log.debug(`Registered path tags: ${requestPath} → [${capturedTags.join(', ')}]`);
78
+ }
79
+ }
80
+ }
81
+ // Clone response to modify headers
82
+ const newResponse = new NextResponse(response.body, {
83
+ status: response.status,
84
+ statusText: response.statusText,
85
+ headers: new Headers(response.headers),
86
+ });
87
+ // Set Surrogate-Key header
88
+ if (capturedTags.length > 0) {
89
+ const surrogateKey = capturedTags.join(' ');
90
+ newResponse.headers.set('Surrogate-Key', surrogateKey);
91
+ if (debug) {
92
+ log.debug(`Set Surrogate-Key: ${surrogateKey}`);
93
+ // TODO: Remove these debug headers before production release
94
+ // These are temporary headers to validate tag capture while Surrogate-Key
95
+ // is being stripped by the proxy layer. Remove once proxy issue is resolved.
96
+ newResponse.headers.set('x-cache-tags-count', String(capturedTags.length));
97
+ newResponse.headers.set('x-cache-tags-source', tagSource);
98
+ newResponse.headers.set('x-surrogate-key-debug', surrogateKey);
99
+ }
100
+ }
101
+ else if (fallbackKey) {
102
+ newResponse.headers.set('Surrogate-Key', fallbackKey);
103
+ if (debug) {
104
+ log.debug(`No tags captured, using fallback: ${fallbackKey}`);
105
+ // TODO: Remove this debug header before production release
106
+ newResponse.headers.set('x-surrogate-key-debug', fallbackKey);
107
+ }
108
+ }
109
+ return newResponse;
110
+ });
111
+ };
112
+ }
113
+ //# sourceMappingURL=with-surrogate-key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"with-surrogate-key.js","sourceRoot":"","sources":["../../src/utils/with-surrogate-key.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,MAAM,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": "Custom cache handler for Next.js with support for Google Cloud Storage and file-based caching",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -9,6 +9,18 @@
9
9
  ".": {
10
10
  "import": "./dist/index.js",
11
11
  "types": "./dist/index.d.ts"
12
+ },
13
+ "./use-cache": {
14
+ "import": "./dist/use-cache/index.js",
15
+ "types": "./dist/use-cache/index.d.ts"
16
+ },
17
+ "./utils": {
18
+ "import": "./dist/utils/index.js",
19
+ "types": "./dist/utils/index.d.ts"
20
+ },
21
+ "./middleware": {
22
+ "import": "./dist/middleware/index.js",
23
+ "types": "./dist/middleware/index.d.ts"
12
24
  }
13
25
  },
14
26
  "files": [
@@ -16,6 +28,7 @@
16
28
  ],
17
29
  "scripts": {
18
30
  "build": "tsc",
31
+ "prepare": "npm run build",
19
32
  "prepublishOnly": "npm run build",
20
33
  "clean": "rm -rf dist",
21
34
  "test": "vitest run",
@@ -41,6 +54,7 @@
41
54
  "devDependencies": {
42
55
  "@types/node": "^20",
43
56
  "@vitest/coverage-v8": "^4.0.18",
57
+ "next": "^16.1.6",
44
58
  "typescript": "^5.0.0",
45
59
  "vitest": "^4.0.18"
46
60
  },