@platformatic/next 3.69.0 → 3.71.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
@@ -9,13 +9,10 @@ export interface PlatformaticNextJsConfig {
9
9
  $schema?: string;
10
10
  module?: string;
11
11
  logger?: {
12
- level?: (
13
- | ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
14
- | {
15
- [k: string]: unknown;
16
- }
17
- ) &
18
- string;
12
+ /**
13
+ * The log level. It must be one of the standard pino levels (fatal, error, warn, info, debug, trace, silent) or, when customLevels is set, one of the custom levels.
14
+ */
15
+ level?: string;
19
16
  transport?:
20
17
  | {
21
18
  target?: string;
@@ -48,6 +45,10 @@ export interface PlatformaticNextJsConfig {
48
45
  redact?: {
49
46
  paths: string[];
50
47
  censor?: string;
48
+ /**
49
+ * Remove the redacted keys entirely instead of replacing their values with the censor. Defaults to false.
50
+ */
51
+ remove?: boolean;
51
52
  };
52
53
  base?: {
53
54
  [k: string]: unknown;
@@ -56,6 +57,46 @@ export interface PlatformaticNextJsConfig {
56
57
  customLevels?: {
57
58
  [k: string]: unknown;
58
59
  };
60
+ /**
61
+ * The numeric value of the level defined in level, when it is not one of the standard pino levels.
62
+ */
63
+ levelVal?: number;
64
+ /**
65
+ * Only use the levels defined in customLevels and omit the standard pino ones.
66
+ */
67
+ useOnlyCustomLevels?: boolean;
68
+ /**
69
+ * How log levels are compared to the logger level. Use DESC when lower values are more severe. Defaults to ASC.
70
+ */
71
+ levelComparison?: "ASC" | "DESC";
72
+ /**
73
+ * A string prefixed to every message, including the ones of child loggers.
74
+ */
75
+ msgPrefix?: string;
76
+ /**
77
+ * The key under which any logged object is placed.
78
+ */
79
+ nestedKey?: string;
80
+ /**
81
+ * The key used for the serialized error in the log object. Defaults to err.
82
+ */
83
+ errorKey?: string;
84
+ /**
85
+ * The stringification limit at a specific nesting depth when logging circular objects. Defaults to 5.
86
+ */
87
+ depthLimit?: number;
88
+ /**
89
+ * The stringification limit of properties or elements when logging a circular object or array. Defaults to 100.
90
+ */
91
+ edgeLimit?: number;
92
+ /**
93
+ * Terminate each log line with \r\n instead of \n. Defaults to false.
94
+ */
95
+ crlf?: boolean;
96
+ /**
97
+ * Set to false to disable logging entirely. Defaults to true.
98
+ */
99
+ enabled?: boolean;
59
100
  openTelemetryExporter?: {
60
101
  protocol: "grpc" | "http";
61
102
  url: string;
@@ -171,13 +212,10 @@ export interface PlatformaticNextJsConfig {
171
212
  };
172
213
  workersRestartDelay?: number | string;
173
214
  logger?: {
174
- level?: (
175
- | ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
176
- | {
177
- [k: string]: unknown;
178
- }
179
- ) &
180
- string;
215
+ /**
216
+ * The log level. It must be one of the standard pino levels (fatal, error, warn, info, debug, trace, silent) or, when customLevels is set, one of the custom levels.
217
+ */
218
+ level?: string;
181
219
  transport?:
182
220
  | {
183
221
  target?: string;
@@ -210,6 +248,10 @@ export interface PlatformaticNextJsConfig {
210
248
  redact?: {
211
249
  paths: string[];
212
250
  censor?: string;
251
+ /**
252
+ * Remove the redacted keys entirely instead of replacing their values with the censor. Defaults to false.
253
+ */
254
+ remove?: boolean;
213
255
  };
214
256
  base?: {
215
257
  [k: string]: unknown;
@@ -218,6 +260,46 @@ export interface PlatformaticNextJsConfig {
218
260
  customLevels?: {
219
261
  [k: string]: unknown;
220
262
  };
263
+ /**
264
+ * The numeric value of the level defined in level, when it is not one of the standard pino levels.
265
+ */
266
+ levelVal?: number;
267
+ /**
268
+ * Only use the levels defined in customLevels and omit the standard pino ones.
269
+ */
270
+ useOnlyCustomLevels?: boolean;
271
+ /**
272
+ * How log levels are compared to the logger level. Use DESC when lower values are more severe. Defaults to ASC.
273
+ */
274
+ levelComparison?: "ASC" | "DESC";
275
+ /**
276
+ * A string prefixed to every message, including the ones of child loggers.
277
+ */
278
+ msgPrefix?: string;
279
+ /**
280
+ * The key under which any logged object is placed.
281
+ */
282
+ nestedKey?: string;
283
+ /**
284
+ * The key used for the serialized error in the log object. Defaults to err.
285
+ */
286
+ errorKey?: string;
287
+ /**
288
+ * The stringification limit at a specific nesting depth when logging circular objects. Defaults to 5.
289
+ */
290
+ depthLimit?: number;
291
+ /**
292
+ * The stringification limit of properties or elements when logging a circular object or array. Defaults to 100.
293
+ */
294
+ edgeLimit?: number;
295
+ /**
296
+ * Terminate each log line with \r\n instead of \n. Defaults to false.
297
+ */
298
+ crlf?: boolean;
299
+ /**
300
+ * Set to false to disable logging entirely. Defaults to true.
301
+ */
302
+ enabled?: boolean;
221
303
  openTelemetryExporter?: {
222
304
  protocol: "grpc" | "http";
223
305
  url: string;
@@ -16,6 +16,8 @@ export const CACHE_HIT_METRIC = { name: 'next_cache_valkey_hit_count', help: 'Ne
16
16
  export const CACHE_MISS_METRIC = { name: 'next_cache_valkey_miss_count', help: 'Next.js Cache (Valkey) Miss Count' }
17
17
  export const MAX_BATCH_SIZE = 100
18
18
 
19
+ const NEXT_CACHE_TAGS_HEADER = 'x-next-cache-tags'
20
+
19
21
  export const sections = {
20
22
  values: 'values',
21
23
  tags: 'tags'
@@ -99,7 +101,7 @@ export class CacheHandler {
99
101
  } catch (e) {
100
102
  this.#cacheMissMetric?.inc()
101
103
  this.#logger.error({ err: ensureLoggableError(e) }, 'Cannot read cache value from Valkey')
102
- throw new Error('Cannot read cache value from Valkey', { cause: e })
104
+ return
103
105
  }
104
106
 
105
107
  let value
@@ -132,7 +134,7 @@ export class CacheHandler {
132
134
  }
133
135
 
134
136
  async set (cacheKey, value, ctx, isRedisKey) {
135
- const tags = ctx.tags
137
+ const tags = this.#getTags(ctx.tags, value)
136
138
  const revalidate = ctx.revalidate ?? ctx.cacheControl?.revalidate ?? value.revalidate ?? 0
137
139
 
138
140
  this.#logger.trace({ key: cacheKey, value, tags, revalidate }, 'cache set')
@@ -267,6 +269,25 @@ export class CacheHandler {
267
269
  }
268
270
  }
269
271
 
272
+ #getTags (tags, value) {
273
+ // Next.js stores page and route tags in this header instead of ctx.tags.
274
+ const tagsHeader = value?.headers?.[NEXT_CACHE_TAGS_HEADER]
275
+
276
+ if (typeof tagsHeader !== 'string') {
277
+ return tags
278
+ }
279
+
280
+ const combinedTags = new Set(tags)
281
+
282
+ for (const tag of tagsHeader.split(',')) {
283
+ if (tag) {
284
+ combinedTags.add(tag)
285
+ }
286
+ }
287
+
288
+ return [...combinedTags]
289
+ }
290
+
270
291
  async #refreshKey (key, value) {
271
292
  const life = Math.round((Date.now() - value.lastModified) / 1000)
272
293
  const expire = Math.min(value.revalidate - life, this.#maxTTL)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/next",
3
- "version": "3.69.0",
3
+ "version": "3.71.0",
4
4
  "description": "Platformatic Next.js Capability",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,9 +25,9 @@
25
25
  "light-my-request": "^6.0.0",
26
26
  "msgpackr": "^1.11.2",
27
27
  "semver": "^7.6.3",
28
- "@platformatic/foundation": "3.69.0",
29
- "@platformatic/globals": "3.69.0",
30
- "@platformatic/basic": "3.69.0"
28
+ "@platformatic/basic": "3.71.0",
29
+ "@platformatic/foundation": "3.71.0",
30
+ "@platformatic/globals": "3.71.0"
31
31
  },
32
32
  "devDependencies": {
33
33
  "@fastify/reply-from": "^12.0.0",
@@ -44,8 +44,8 @@
44
44
  "next": "^16.1.0",
45
45
  "typescript": "~6.0.3",
46
46
  "ws": "^8.18.0",
47
- "@platformatic/gateway": "3.69.0",
48
- "@platformatic/service": "3.69.0"
47
+ "@platformatic/gateway": "3.71.0",
48
+ "@platformatic/service": "3.71.0"
49
49
  },
50
50
  "engines": {
51
51
  "node": ">=22.19.0"
package/schema.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/next/3.69.0.json",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/next/3.71.0.json",
3
3
  "$schema": "http://json-schema.org/draft-07/schema#",
4
4
  "title": "Platformatic Next.js Config",
5
5
  "type": "object",
@@ -15,22 +15,7 @@
15
15
  "properties": {
16
16
  "level": {
17
17
  "type": "string",
18
- "oneOf": [
19
- {
20
- "enum": [
21
- "fatal",
22
- "error",
23
- "warn",
24
- "info",
25
- "debug",
26
- "trace",
27
- "silent"
28
- ]
29
- },
30
- {
31
- "pattern": "^\\{.+\\}$"
32
- }
33
- ]
18
+ "description": "The log level. It must be one of the standard pino levels (fatal, error, warn, info, debug, trace, silent) or, when customLevels is set, one of the custom levels."
34
19
  },
35
20
  "transport": {
36
21
  "anyOf": [
@@ -131,6 +116,10 @@
131
116
  "censor": {
132
117
  "type": "string",
133
118
  "default": "[redacted]"
119
+ },
120
+ "remove": {
121
+ "type": "boolean",
122
+ "description": "Remove the redacted keys entirely instead of replacing their values with the censor. Defaults to false."
134
123
  }
135
124
  },
136
125
  "required": [
@@ -156,6 +145,50 @@
156
145
  "type": "object",
157
146
  "additionalProperties": true
158
147
  },
148
+ "levelVal": {
149
+ "type": "integer",
150
+ "description": "The numeric value of the level defined in level, when it is not one of the standard pino levels."
151
+ },
152
+ "useOnlyCustomLevels": {
153
+ "type": "boolean",
154
+ "description": "Only use the levels defined in customLevels and omit the standard pino ones."
155
+ },
156
+ "levelComparison": {
157
+ "type": "string",
158
+ "enum": [
159
+ "ASC",
160
+ "DESC"
161
+ ],
162
+ "description": "How log levels are compared to the logger level. Use DESC when lower values are more severe. Defaults to ASC."
163
+ },
164
+ "msgPrefix": {
165
+ "type": "string",
166
+ "description": "A string prefixed to every message, including the ones of child loggers."
167
+ },
168
+ "nestedKey": {
169
+ "type": "string",
170
+ "description": "The key under which any logged object is placed."
171
+ },
172
+ "errorKey": {
173
+ "type": "string",
174
+ "description": "The key used for the serialized error in the log object. Defaults to err."
175
+ },
176
+ "depthLimit": {
177
+ "type": "integer",
178
+ "description": "The stringification limit at a specific nesting depth when logging circular objects. Defaults to 5."
179
+ },
180
+ "edgeLimit": {
181
+ "type": "integer",
182
+ "description": "The stringification limit of properties or elements when logging a circular object or array. Defaults to 100."
183
+ },
184
+ "crlf": {
185
+ "type": "boolean",
186
+ "description": "Terminate each log line with \\r\\n instead of \\n. Defaults to false."
187
+ },
188
+ "enabled": {
189
+ "type": "boolean",
190
+ "description": "Set to false to disable logging entirely. Defaults to true."
191
+ },
159
192
  "openTelemetryExporter": {
160
193
  "type": "object",
161
194
  "properties": {
@@ -177,6 +210,35 @@
177
210
  "additionalProperties": false
178
211
  }
179
212
  },
213
+ "if": {
214
+ "not": {
215
+ "required": [
216
+ "customLevels"
217
+ ]
218
+ }
219
+ },
220
+ "then": {
221
+ "properties": {
222
+ "level": {
223
+ "oneOf": [
224
+ {
225
+ "enum": [
226
+ "fatal",
227
+ "error",
228
+ "warn",
229
+ "info",
230
+ "debug",
231
+ "trace",
232
+ "silent"
233
+ ]
234
+ },
235
+ {
236
+ "pattern": "^\\{.+\\}$"
237
+ }
238
+ ]
239
+ }
240
+ }
241
+ },
180
242
  "default": {},
181
243
  "additionalProperties": true
182
244
  },
@@ -999,22 +1061,7 @@
999
1061
  "properties": {
1000
1062
  "level": {
1001
1063
  "type": "string",
1002
- "oneOf": [
1003
- {
1004
- "enum": [
1005
- "fatal",
1006
- "error",
1007
- "warn",
1008
- "info",
1009
- "debug",
1010
- "trace",
1011
- "silent"
1012
- ]
1013
- },
1014
- {
1015
- "pattern": "^\\{.+\\}$"
1016
- }
1017
- ]
1064
+ "description": "The log level. It must be one of the standard pino levels (fatal, error, warn, info, debug, trace, silent) or, when customLevels is set, one of the custom levels."
1018
1065
  },
1019
1066
  "transport": {
1020
1067
  "anyOf": [
@@ -1115,6 +1162,10 @@
1115
1162
  "censor": {
1116
1163
  "type": "string",
1117
1164
  "default": "[redacted]"
1165
+ },
1166
+ "remove": {
1167
+ "type": "boolean",
1168
+ "description": "Remove the redacted keys entirely instead of replacing their values with the censor. Defaults to false."
1118
1169
  }
1119
1170
  },
1120
1171
  "required": [
@@ -1140,6 +1191,50 @@
1140
1191
  "type": "object",
1141
1192
  "additionalProperties": true
1142
1193
  },
1194
+ "levelVal": {
1195
+ "type": "integer",
1196
+ "description": "The numeric value of the level defined in level, when it is not one of the standard pino levels."
1197
+ },
1198
+ "useOnlyCustomLevels": {
1199
+ "type": "boolean",
1200
+ "description": "Only use the levels defined in customLevels and omit the standard pino ones."
1201
+ },
1202
+ "levelComparison": {
1203
+ "type": "string",
1204
+ "enum": [
1205
+ "ASC",
1206
+ "DESC"
1207
+ ],
1208
+ "description": "How log levels are compared to the logger level. Use DESC when lower values are more severe. Defaults to ASC."
1209
+ },
1210
+ "msgPrefix": {
1211
+ "type": "string",
1212
+ "description": "A string prefixed to every message, including the ones of child loggers."
1213
+ },
1214
+ "nestedKey": {
1215
+ "type": "string",
1216
+ "description": "The key under which any logged object is placed."
1217
+ },
1218
+ "errorKey": {
1219
+ "type": "string",
1220
+ "description": "The key used for the serialized error in the log object. Defaults to err."
1221
+ },
1222
+ "depthLimit": {
1223
+ "type": "integer",
1224
+ "description": "The stringification limit at a specific nesting depth when logging circular objects. Defaults to 5."
1225
+ },
1226
+ "edgeLimit": {
1227
+ "type": "integer",
1228
+ "description": "The stringification limit of properties or elements when logging a circular object or array. Defaults to 100."
1229
+ },
1230
+ "crlf": {
1231
+ "type": "boolean",
1232
+ "description": "Terminate each log line with \\r\\n instead of \\n. Defaults to false."
1233
+ },
1234
+ "enabled": {
1235
+ "type": "boolean",
1236
+ "description": "Set to false to disable logging entirely. Defaults to true."
1237
+ },
1143
1238
  "openTelemetryExporter": {
1144
1239
  "type": "object",
1145
1240
  "properties": {
@@ -1161,6 +1256,35 @@
1161
1256
  "additionalProperties": false
1162
1257
  }
1163
1258
  },
1259
+ "if": {
1260
+ "not": {
1261
+ "required": [
1262
+ "customLevels"
1263
+ ]
1264
+ }
1265
+ },
1266
+ "then": {
1267
+ "properties": {
1268
+ "level": {
1269
+ "oneOf": [
1270
+ {
1271
+ "enum": [
1272
+ "fatal",
1273
+ "error",
1274
+ "warn",
1275
+ "info",
1276
+ "debug",
1277
+ "trace",
1278
+ "silent"
1279
+ ]
1280
+ },
1281
+ {
1282
+ "pattern": "^\\{.+\\}$"
1283
+ }
1284
+ ]
1285
+ }
1286
+ }
1287
+ },
1164
1288
  "default": {},
1165
1289
  "additionalProperties": true
1166
1290
  },