@platformatic/next 3.73.0-alpha.0 → 3.74.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 +16 -0
- package/lib/caching/valkey-common.js +20 -3
- package/lib/caching/valkey-components.js +2 -5
- package/lib/caching/valkey-isr.js +3 -3
- package/package.json +6 -6
- package/schema.json +21 -1
package/config.d.ts
CHANGED
|
@@ -54,6 +54,14 @@ export interface PlatformaticNextJsConfig {
|
|
|
54
54
|
[k: string]: unknown;
|
|
55
55
|
} | null;
|
|
56
56
|
messageKey?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The key used for the timestamp in emitted logs. Defaults to time.
|
|
59
|
+
*/
|
|
60
|
+
timestampKey?: string;
|
|
61
|
+
/**
|
|
62
|
+
* The key used for the level in emitted logs. Defaults to level.
|
|
63
|
+
*/
|
|
64
|
+
levelKey?: string;
|
|
57
65
|
customLevels?: {
|
|
58
66
|
[k: string]: unknown;
|
|
59
67
|
};
|
|
@@ -257,6 +265,14 @@ export interface PlatformaticNextJsConfig {
|
|
|
257
265
|
[k: string]: unknown;
|
|
258
266
|
} | null;
|
|
259
267
|
messageKey?: string;
|
|
268
|
+
/**
|
|
269
|
+
* The key used for the timestamp in emitted logs. Defaults to time.
|
|
270
|
+
*/
|
|
271
|
+
timestampKey?: string;
|
|
272
|
+
/**
|
|
273
|
+
* The key used for the level in emitted logs. Defaults to level.
|
|
274
|
+
*/
|
|
275
|
+
levelKey?: string;
|
|
260
276
|
customLevels?: {
|
|
261
277
|
[k: string]: unknown;
|
|
262
278
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { buildPinoFormatters, buildPinoTimestamp } from '@platformatic/foundation'
|
|
1
|
+
import { buildPinoFormatters, buildPinoTimestamp, setPinoLogKeys } from '@platformatic/foundation'
|
|
2
2
|
import {
|
|
3
3
|
getApplicationId,
|
|
4
4
|
getConfig,
|
|
@@ -91,9 +91,10 @@ export function createPlatformaticLogger () {
|
|
|
91
91
|
if (pinoOptions.formatters) {
|
|
92
92
|
pinoOptions.formatters = buildPinoFormatters(pinoOptions.formatters)
|
|
93
93
|
}
|
|
94
|
-
if (pinoOptions.timestamp) {
|
|
95
|
-
pinoOptions.timestamp = buildPinoTimestamp(pinoOptions.timestamp)
|
|
94
|
+
if (pinoOptions.timestamp || pinoOptions.timestampKey !== undefined) {
|
|
95
|
+
pinoOptions.timestamp = buildPinoTimestamp(pinoOptions.timestamp, pinoOptions.timestampKey)
|
|
96
96
|
}
|
|
97
|
+
setPinoLogKeys(pinoOptions)
|
|
97
98
|
|
|
98
99
|
const applicationId = getApplicationId()
|
|
99
100
|
if (applicationId) {
|
|
@@ -170,6 +171,22 @@ export function getCacheFunctionId (cacheKey) {
|
|
|
170
171
|
return cacheKey.match(/"([0-9a-f]{42})"/)?.[1]
|
|
171
172
|
}
|
|
172
173
|
|
|
174
|
+
// How long an entry is usable, in seconds. Past its revalidate time, Next.js serves it as stale
|
|
175
|
+
// while it regenerates it, until its expire time. Without one, keep the entry as long again
|
|
176
|
+
// after revalidate, as the HTTP cache does.
|
|
177
|
+
export function getEntryLifetime (revalidate, expire, maxTTL) {
|
|
178
|
+
if (typeof expire === 'number') {
|
|
179
|
+
return expire
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
// false means "cache forever" in Next.js
|
|
183
|
+
if (expire === false || revalidate === false) {
|
|
184
|
+
return maxTTL
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
return revalidate * 2
|
|
188
|
+
}
|
|
189
|
+
|
|
173
190
|
export function getPlatformaticMeta () {
|
|
174
191
|
return {
|
|
175
192
|
applicationId: getApplicationId(),
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
ensureRedis,
|
|
9
9
|
getCacheFunctionId,
|
|
10
10
|
getConnection,
|
|
11
|
+
getEntryLifetime,
|
|
11
12
|
getPlatformaticMeta,
|
|
12
13
|
getPlatformaticSubprefix,
|
|
13
14
|
keyFor,
|
|
@@ -180,11 +181,7 @@ export class CacheHandler {
|
|
|
180
181
|
value: Buffer.concat(chunks),
|
|
181
182
|
...data
|
|
182
183
|
})
|
|
183
|
-
|
|
184
|
-
// Use maxTTL as the expiration in that case.
|
|
185
|
-
const effectiveRevalidate = revalidate === false ? this.#maxTTL : revalidate
|
|
186
|
-
const effectiveExpire = expireSec === false ? this.#maxTTL : expireSec
|
|
187
|
-
const expire = Math.min(effectiveRevalidate, effectiveExpire, this.#maxTTL)
|
|
184
|
+
const expire = Math.min(getEntryLifetime(revalidate, expireSec, this.#maxTTL), this.#maxTTL)
|
|
188
185
|
|
|
189
186
|
if (expire < 1) {
|
|
190
187
|
return
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
ensureMsgpackr,
|
|
7
7
|
ensureRedis,
|
|
8
8
|
getConnection,
|
|
9
|
+
getEntryLifetime,
|
|
9
10
|
getPlatformaticMeta,
|
|
10
11
|
getPlatformaticSubprefix,
|
|
11
12
|
keyFor,
|
|
@@ -148,6 +149,7 @@ export class CacheHandler {
|
|
|
148
149
|
this.#logger.trace({ key: cacheKey, value, tags, revalidate }, 'cache set')
|
|
149
150
|
|
|
150
151
|
const key = this.#standalone || isRedisKey ? cacheKey : this.#keyFor(cacheKey, sections.values)
|
|
152
|
+
const lifetime = getEntryLifetime(revalidate, ctx.cacheControl?.expire, this.#maxTTL)
|
|
151
153
|
|
|
152
154
|
try {
|
|
153
155
|
// Compute the parameters to save
|
|
@@ -159,9 +161,7 @@ export class CacheHandler {
|
|
|
159
161
|
maxTTL: this.#maxTTL,
|
|
160
162
|
...this.#meta
|
|
161
163
|
})
|
|
162
|
-
|
|
163
|
-
// Use maxTTL as the expiration in that case.
|
|
164
|
-
const expire = revalidate === false ? this.#maxTTL : Math.min(revalidate, this.#maxTTL)
|
|
164
|
+
const expire = Math.min(lifetime, this.#maxTTL)
|
|
165
165
|
|
|
166
166
|
if (expire < 1) {
|
|
167
167
|
return
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/next",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.74.0",
|
|
4
4
|
"description": "Platformatic Next.js Capability",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
"@babel/parser": "^7.25.3",
|
|
20
20
|
"@babel/traverse": "^7.25.3",
|
|
21
21
|
"@babel/types": "^7.25.2",
|
|
22
|
-
"@platformatic/basic": "3.
|
|
23
|
-
"@platformatic/foundation": "3.
|
|
24
|
-
"@platformatic/globals": "3.
|
|
22
|
+
"@platformatic/basic": "3.74.0",
|
|
23
|
+
"@platformatic/foundation": "3.74.0",
|
|
24
|
+
"@platformatic/globals": "3.74.0",
|
|
25
25
|
"@platformatic/image-optimizer": "^0.2.1",
|
|
26
26
|
"amaro": "^1.0.0",
|
|
27
27
|
"iovalkey": "^0.4.0",
|
|
@@ -31,8 +31,8 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@fastify/reply-from": "^12.0.0",
|
|
34
|
-
"@platformatic/gateway": "3.
|
|
35
|
-
"@platformatic/service": "3.
|
|
34
|
+
"@platformatic/gateway": "3.74.0",
|
|
35
|
+
"@platformatic/service": "3.74.0",
|
|
36
36
|
"@types/node": "^22.5.0",
|
|
37
37
|
"@types/react": "^19.1.11",
|
|
38
38
|
"@types/react-dom": "^19.1.7",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/next/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/next/3.74.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Next.js Config",
|
|
5
5
|
"type": "object",
|
|
@@ -141,6 +141,16 @@
|
|
|
141
141
|
"messageKey": {
|
|
142
142
|
"type": "string"
|
|
143
143
|
},
|
|
144
|
+
"timestampKey": {
|
|
145
|
+
"type": "string",
|
|
146
|
+
"minLength": 1,
|
|
147
|
+
"description": "The key used for the timestamp in emitted logs. Defaults to time."
|
|
148
|
+
},
|
|
149
|
+
"levelKey": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"minLength": 1,
|
|
152
|
+
"description": "The key used for the level in emitted logs. Defaults to level."
|
|
153
|
+
},
|
|
144
154
|
"customLevels": {
|
|
145
155
|
"type": "object",
|
|
146
156
|
"additionalProperties": true
|
|
@@ -1187,6 +1197,16 @@
|
|
|
1187
1197
|
"messageKey": {
|
|
1188
1198
|
"type": "string"
|
|
1189
1199
|
},
|
|
1200
|
+
"timestampKey": {
|
|
1201
|
+
"type": "string",
|
|
1202
|
+
"minLength": 1,
|
|
1203
|
+
"description": "The key used for the timestamp in emitted logs. Defaults to time."
|
|
1204
|
+
},
|
|
1205
|
+
"levelKey": {
|
|
1206
|
+
"type": "string",
|
|
1207
|
+
"minLength": 1,
|
|
1208
|
+
"description": "The key used for the level in emitted logs. Defaults to level."
|
|
1209
|
+
},
|
|
1190
1210
|
"customLevels": {
|
|
1191
1211
|
"type": "object",
|
|
1192
1212
|
"additionalProperties": true
|