@platformatic/next 3.36.0 → 3.38.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.
package/config.d.ts CHANGED
@@ -527,6 +527,7 @@ export interface PlatformaticNextJsConfig {
527
527
  [k: string]: unknown;
528
528
  };
529
529
  applicationTimeout?: number | string;
530
+ startupConcurrency?: number | string;
530
531
  messagingTimeout?: number | string;
531
532
  env?: {
532
533
  [k: string]: string;
@@ -649,10 +650,12 @@ export interface PlatformaticNextJsConfig {
649
650
  useExperimentalAdapter?: boolean;
650
651
  };
651
652
  cache?: {
653
+ enabled?: boolean | string;
652
654
  adapter: "redis" | "valkey";
653
655
  url: string;
654
656
  prefix?: string;
655
657
  cacheComponents?: boolean;
656
658
  maxTTL?: number | string;
659
+ ignoreNextConfig?: boolean | string;
657
660
  };
658
661
  }
package/index.js CHANGED
@@ -20,6 +20,43 @@ export function getAdapterPath () {
20
20
  return resolvePath(import.meta.dirname, 'lib', 'adapter.js')
21
21
  }
22
22
 
23
+ function enhanceNextCacheConfig (nextConfig, modifications) {
24
+ const { config, nextVersion, logger } = globalThis.platformatic
25
+
26
+ if (!config.cache?.adapter || config.cache?.enabled === false) return
27
+
28
+ const existingCacheHandlers = typeof nextConfig.cacheHandler !== 'undefined' || typeof nextConfig.cacheHandlers?.default !== 'undefined'
29
+ if (existingCacheHandlers) {
30
+ if (!config.cache.ignoreNextConfig) {
31
+ return logger.warn('Next.js cache handlers are already defined in next.config.js. Skipping cache configuration.')
32
+ }
33
+ }
34
+
35
+ const cacheComponentsConflict = typeof config.cache?.cacheComponents !== 'undefined' && typeof nextConfig.cacheComponents !== 'undefined' && config.cache?.cacheComponents !== nextConfig.cacheComponents
36
+ if (cacheComponentsConflict) {
37
+ if (!config.cache.ignoreNextConfig) {
38
+ return logger.warn('Platformatic and Next.js Cache Components configs are conflicting. Skipping cache configuration.')
39
+ }
40
+ nextConfig.cacheComponents = config.cache?.cacheComponents
41
+ }
42
+
43
+ if (config.cache?.cacheComponents || nextConfig.cacheComponents) {
44
+ if (nextVersion.major <= 15) {
45
+ return logger.warn('Next.js Cache Components are only supported in Next.js 16 and above. Skipping cache configuration.')
46
+ }
47
+ nextConfig.cacheComponents = true
48
+ nextConfig.cacheHandler = getCacheHandlerPath('null-isr')
49
+ nextConfig.cacheHandlers = { default: getCacheHandlerPath(`${config.cache.adapter}-components`) }
50
+ nextConfig.cacheMaxMemorySize = 0
51
+ modifications.push(['componentsCache', config.cache.adapter])
52
+ } else {
53
+ delete nextConfig.cacheHandlers
54
+ nextConfig.cacheHandler = getCacheHandlerPath(`${config.cache.adapter}-isr`)
55
+ nextConfig.cacheMaxMemorySize = 0
56
+ modifications.push(['isrCache', config.cache.adapter])
57
+ }
58
+ }
59
+
23
60
  export async function enhanceNextConfig (nextConfig, ...args) {
24
61
  // This is to avoid https://github.com/vercel/next.js/issues/76981
25
62
  Headers.prototype[Symbol.for('nodejs.util.inspect.custom')] = undefined
@@ -28,7 +65,7 @@ export async function enhanceNextConfig (nextConfig, ...args) {
28
65
  nextConfig = await nextConfig(...args)
29
66
  }
30
67
 
31
- const { basePath, config, nextVersion } = globalThis.platformatic
68
+ const { basePath, config } = globalThis.platformatic
32
69
 
33
70
  if (typeof nextConfig.basePath === 'undefined') {
34
71
  nextConfig.basePath = basePath
@@ -36,19 +73,7 @@ export async function enhanceNextConfig (nextConfig, ...args) {
36
73
 
37
74
  const modifications = []
38
75
 
39
- if (config.cache?.adapter) {
40
- if (nextVersion.major > 15 && config.cache?.cacheComponents && typeof nextConfig.cacheComponents === 'undefined') {
41
- nextConfig.cacheComponents = true
42
- nextConfig.cacheHandler = getCacheHandlerPath('null-isr')
43
- nextConfig.cacheHandlers = { default: getCacheHandlerPath(`${config.cache.adapter}-components`) }
44
- nextConfig.cacheMaxMemorySize = 0
45
- modifications.push(['componentsCache', config.cache.adapter])
46
- } else if (typeof nextConfig.cacheHandler === 'undefined') {
47
- nextConfig.cacheHandler = getCacheHandlerPath(`${config.cache.adapter}-isr`)
48
- nextConfig.cacheMaxMemorySize = 0
49
- modifications.push(['isrCache', config.cache.adapter])
50
- }
51
- }
76
+ enhanceNextCacheConfig(nextConfig, modifications)
52
77
 
53
78
  if (config.next?.trailingSlash && typeof nextConfig.trailingSlash === 'undefined') {
54
79
  nextConfig.trailingSlash = true
@@ -24,7 +24,7 @@ export function keyFor (prefix, subprefix, section, key) {
24
24
  }
25
25
 
26
26
  if (key?.length) {
27
- result += Buffer.from(key).toString('base64url')
27
+ result += ':' + Buffer.from(key).toString('base64url')
28
28
  }
29
29
 
30
30
  return result
package/lib/schema.js CHANGED
@@ -9,6 +9,16 @@ export const version = packageJson.version
9
9
  export const cache = {
10
10
  type: 'object',
11
11
  properties: {
12
+ enabled: {
13
+ anyOf: [
14
+ {
15
+ type: 'boolean'
16
+ },
17
+ {
18
+ type: 'string'
19
+ }
20
+ ]
21
+ },
12
22
  adapter: {
13
23
  type: 'string',
14
24
  enum: ['redis', 'valkey']
@@ -33,6 +43,16 @@ export const cache = {
33
43
  type: 'string'
34
44
  }
35
45
  ]
46
+ },
47
+ ignoreNextConfig: {
48
+ anyOf: [
49
+ {
50
+ type: 'boolean'
51
+ },
52
+ {
53
+ type: 'string'
54
+ }
55
+ ]
36
56
  }
37
57
  },
38
58
  required: ['adapter', 'url'],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/next",
3
- "version": "3.36.0",
3
+ "version": "3.38.0",
4
4
  "description": "Platformatic Next.js Capability",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,8 +23,8 @@
23
23
  "iovalkey": "^0.3.0",
24
24
  "msgpackr": "^1.11.2",
25
25
  "semver": "^7.6.3",
26
- "@platformatic/basic": "3.36.0",
27
- "@platformatic/foundation": "3.36.0"
26
+ "@platformatic/basic": "3.38.0",
27
+ "@platformatic/foundation": "3.38.0"
28
28
  },
29
29
  "devDependencies": {
30
30
  "@fastify/reply-from": "^12.0.0",
@@ -40,8 +40,8 @@
40
40
  "next": "^16.0.0",
41
41
  "typescript": "^5.5.4",
42
42
  "ws": "^8.18.0",
43
- "@platformatic/service": "3.36.0",
44
- "@platformatic/gateway": "3.36.0"
43
+ "@platformatic/service": "3.38.0",
44
+ "@platformatic/gateway": "3.38.0"
45
45
  },
46
46
  "engines": {
47
47
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/next/3.36.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/next/3.38.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Next.js Config",
5
5
  "type": "object",
@@ -1910,6 +1910,17 @@
1910
1910
  ],
1911
1911
  "default": 300000
1912
1912
  },
1913
+ "startupConcurrency": {
1914
+ "anyOf": [
1915
+ {
1916
+ "type": "number",
1917
+ "minimum": 1
1918
+ },
1919
+ {
1920
+ "type": "string"
1921
+ }
1922
+ ]
1923
+ },
1913
1924
  "messagingTimeout": {
1914
1925
  "anyOf": [
1915
1926
  {
@@ -2369,6 +2380,16 @@
2369
2380
  "cache": {
2370
2381
  "type": "object",
2371
2382
  "properties": {
2383
+ "enabled": {
2384
+ "anyOf": [
2385
+ {
2386
+ "type": "boolean"
2387
+ },
2388
+ {
2389
+ "type": "string"
2390
+ }
2391
+ ]
2392
+ },
2372
2393
  "adapter": {
2373
2394
  "type": "string",
2374
2395
  "enum": [
@@ -2396,6 +2417,16 @@
2396
2417
  "type": "string"
2397
2418
  }
2398
2419
  ]
2420
+ },
2421
+ "ignoreNextConfig": {
2422
+ "anyOf": [
2423
+ {
2424
+ "type": "boolean"
2425
+ },
2426
+ {
2427
+ "type": "string"
2428
+ }
2429
+ ]
2399
2430
  }
2400
2431
  },
2401
2432
  "required": [