@platformatic/next 2.65.1 → 2.66.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
@@ -48,6 +48,13 @@ export interface PlatformaticNextJsStackable {
48
48
  paths: string[];
49
49
  censor?: string;
50
50
  };
51
+ base?: {
52
+ [k: string]: unknown;
53
+ } | null;
54
+ messageKey?: string;
55
+ customLevels?: {
56
+ [k: string]: unknown;
57
+ };
51
58
  [k: string]: unknown;
52
59
  };
53
60
  server?: {
@@ -104,6 +111,318 @@ export interface PlatformaticNextJsStackable {
104
111
  production?: string;
105
112
  };
106
113
  };
114
+ runtime?: {
115
+ preload?: string | string[];
116
+ basePath?: string;
117
+ workers?: number | string;
118
+ logger?: {
119
+ level: (
120
+ | ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
121
+ | {
122
+ [k: string]: unknown;
123
+ }
124
+ ) &
125
+ string;
126
+ transport?:
127
+ | {
128
+ target?: string;
129
+ options?: {
130
+ [k: string]: unknown;
131
+ };
132
+ }
133
+ | {
134
+ targets?: {
135
+ target?: string;
136
+ options?: {
137
+ [k: string]: unknown;
138
+ };
139
+ level?: string;
140
+ }[];
141
+ options?: {
142
+ [k: string]: unknown;
143
+ };
144
+ };
145
+ pipeline?: {
146
+ target?: string;
147
+ options?: {
148
+ [k: string]: unknown;
149
+ };
150
+ };
151
+ formatters?: {
152
+ path: string;
153
+ };
154
+ timestamp?: "epochTime" | "unixTime" | "nullTime" | "isoTime";
155
+ redact?: {
156
+ paths: string[];
157
+ censor?: string;
158
+ };
159
+ base?: {
160
+ [k: string]: unknown;
161
+ } | null;
162
+ messageKey?: string;
163
+ customLevels?: {
164
+ [k: string]: unknown;
165
+ };
166
+ [k: string]: unknown;
167
+ };
168
+ server?: {
169
+ hostname?: string;
170
+ port?: number | string;
171
+ http2?: boolean;
172
+ https?: {
173
+ allowHTTP1?: boolean;
174
+ key:
175
+ | string
176
+ | {
177
+ path?: string;
178
+ }
179
+ | (
180
+ | string
181
+ | {
182
+ path?: string;
183
+ }
184
+ )[];
185
+ cert:
186
+ | string
187
+ | {
188
+ path?: string;
189
+ }
190
+ | (
191
+ | string
192
+ | {
193
+ path?: string;
194
+ }
195
+ )[];
196
+ requestCert?: boolean;
197
+ rejectUnauthorized?: boolean;
198
+ };
199
+ };
200
+ startTimeout?: number;
201
+ restartOnError?: boolean | number;
202
+ gracefulShutdown?: {
203
+ runtime: number | string;
204
+ service: number | string;
205
+ };
206
+ health?: {
207
+ enabled?: boolean | string;
208
+ interval?: number | string;
209
+ gracePeriod?: number | string;
210
+ maxUnhealthyChecks?: number | string;
211
+ maxELU?: number | string;
212
+ maxHeapUsed?: number | string;
213
+ maxHeapTotal?: number | string;
214
+ maxYoungGeneration?: number;
215
+ };
216
+ undici?: {
217
+ agentOptions?: {
218
+ [k: string]: unknown;
219
+ };
220
+ interceptors?:
221
+ | {
222
+ module: string;
223
+ options: {
224
+ [k: string]: unknown;
225
+ };
226
+ [k: string]: unknown;
227
+ }[]
228
+ | {
229
+ Client?: {
230
+ module: string;
231
+ options: {
232
+ [k: string]: unknown;
233
+ };
234
+ [k: string]: unknown;
235
+ }[];
236
+ Pool?: {
237
+ module: string;
238
+ options: {
239
+ [k: string]: unknown;
240
+ };
241
+ [k: string]: unknown;
242
+ }[];
243
+ Agent?: {
244
+ module: string;
245
+ options: {
246
+ [k: string]: unknown;
247
+ };
248
+ [k: string]: unknown;
249
+ }[];
250
+ [k: string]: unknown;
251
+ };
252
+ [k: string]: unknown;
253
+ };
254
+ httpCache?:
255
+ | boolean
256
+ | {
257
+ store?: string;
258
+ /**
259
+ * @minItems 1
260
+ */
261
+ methods?: [string, ...string[]];
262
+ cacheTagsHeader?: string;
263
+ maxSize?: number;
264
+ maxEntrySize?: number;
265
+ maxCount?: number;
266
+ [k: string]: unknown;
267
+ };
268
+ watch?: boolean | string;
269
+ managementApi?:
270
+ | boolean
271
+ | string
272
+ | {
273
+ logs?: {
274
+ maxSize?: number;
275
+ };
276
+ };
277
+ metrics?:
278
+ | boolean
279
+ | {
280
+ port?: number | string;
281
+ enabled?: boolean | string;
282
+ hostname?: string;
283
+ endpoint?: string;
284
+ auth?: {
285
+ username: string;
286
+ password: string;
287
+ };
288
+ labels?: {
289
+ [k: string]: string;
290
+ };
291
+ readiness?:
292
+ | boolean
293
+ | {
294
+ endpoint?: string;
295
+ success?: {
296
+ statusCode?: number;
297
+ body?: string;
298
+ };
299
+ fail?: {
300
+ statusCode?: number;
301
+ body?: string;
302
+ };
303
+ };
304
+ liveness?:
305
+ | boolean
306
+ | {
307
+ endpoint?: string;
308
+ success?: {
309
+ statusCode?: number;
310
+ body?: string;
311
+ };
312
+ fail?: {
313
+ statusCode?: number;
314
+ body?: string;
315
+ };
316
+ };
317
+ additionalProperties?: never;
318
+ [k: string]: unknown;
319
+ };
320
+ telemetry?: {
321
+ enabled?: boolean | string;
322
+ /**
323
+ * The name of the service. Defaults to the folder name if not specified.
324
+ */
325
+ serviceName: string;
326
+ /**
327
+ * The version of the service (optional)
328
+ */
329
+ version?: string;
330
+ /**
331
+ * An array of paths to skip when creating spans. Useful for health checks and other endpoints that do not need to be traced.
332
+ */
333
+ skip?: {
334
+ /**
335
+ * The path to skip. Can be a string or a regex.
336
+ */
337
+ path?: string;
338
+ /**
339
+ * HTTP method to skip
340
+ */
341
+ method?: "GET" | "POST" | "PUT" | "DELETE" | "PATCH" | "HEAD" | "OPTIONS";
342
+ [k: string]: unknown;
343
+ }[];
344
+ exporter?:
345
+ | {
346
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
347
+ /**
348
+ * Options for the exporter. These are passed directly to the exporter.
349
+ */
350
+ options?: {
351
+ /**
352
+ * The URL to send the traces to. Not used for console or memory exporters.
353
+ */
354
+ url?: string;
355
+ /**
356
+ * Headers to send to the exporter. Not used for console or memory exporters.
357
+ */
358
+ headers?: {
359
+ [k: string]: unknown;
360
+ };
361
+ /**
362
+ * The path to write the traces to. Only for file exporter.
363
+ */
364
+ path?: string;
365
+ [k: string]: unknown;
366
+ };
367
+ additionalProperties?: never;
368
+ [k: string]: unknown;
369
+ }[]
370
+ | {
371
+ type?: "console" | "otlp" | "zipkin" | "memory" | "file";
372
+ /**
373
+ * Options for the exporter. These are passed directly to the exporter.
374
+ */
375
+ options?: {
376
+ /**
377
+ * The URL to send the traces to. Not used for console or memory exporters.
378
+ */
379
+ url?: string;
380
+ /**
381
+ * Headers to send to the exporter. Not used for console or memory exporters.
382
+ */
383
+ headers?: {
384
+ [k: string]: unknown;
385
+ };
386
+ /**
387
+ * The path to write the traces to. Only for file exporter.
388
+ */
389
+ path?: string;
390
+ [k: string]: unknown;
391
+ };
392
+ additionalProperties?: never;
393
+ [k: string]: unknown;
394
+ };
395
+ };
396
+ inspectorOptions?: {
397
+ host?: string;
398
+ port?: number;
399
+ breakFirstLine?: boolean;
400
+ watchDisabled?: boolean;
401
+ [k: string]: unknown;
402
+ };
403
+ serviceTimeout?: number | string;
404
+ env?: {
405
+ [k: string]: string;
406
+ };
407
+ sourceMaps?: boolean;
408
+ scheduler?: {
409
+ enabled?: boolean | string;
410
+ name: string;
411
+ cron: string;
412
+ callbackUrl: string;
413
+ method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
414
+ headers?: {
415
+ [k: string]: string;
416
+ };
417
+ body?:
418
+ | string
419
+ | {
420
+ [k: string]: unknown;
421
+ };
422
+ maxRetries?: number;
423
+ [k: string]: unknown;
424
+ }[];
425
+ };
107
426
  next?: {
108
427
  trailingSlash?: boolean;
109
428
  };
package/index.js CHANGED
@@ -36,6 +36,14 @@ export class NextStackable extends BaseStackable {
36
36
  }
37
37
 
38
38
  async init () {
39
+ // This is needed to avoid Next.js to throw an error when the lockfile is not correct
40
+ // and the user is using npm but has pnpm in its $PATH.
41
+ //
42
+ // See: https://github.com/platformatic/composer-next-node-fastify/pull/3
43
+ //
44
+ // PS by Paolo: Sob.
45
+ process.env.NEXT_IGNORE_INCORRECT_LOCKFILE = 'true'
46
+
39
47
  this.#next = pathResolve(dirname(resolvePackage(this.root, 'next')), '../..')
40
48
  const nextPackage = JSON.parse(await readFile(pathResolve(this.#next, 'package.json'), 'utf-8'))
41
49
  this.#nextVersion = parse(nextPackage.version)
@@ -317,8 +317,15 @@ export class CacheHandler {
317
317
  pinoOptions.name = `cache:${this.serviceId}`
318
318
  }
319
319
 
320
- if (typeof globalThis.platformatic.workerId !== 'undefined') {
321
- pinoOptions.base = { pid: process.pid, hostname: hostname(), worker: this.workerId }
320
+ if (pinoOptions.base !== null && typeof globalThis.platformatic.workerId !== 'undefined') {
321
+ pinoOptions.base = {
322
+ ...(pinoOptions.base ?? {}),
323
+ pid: process.pid,
324
+ hostname: hostname(),
325
+ worker: this.workerId
326
+ }
327
+ } else if (pinoOptions.base === null) {
328
+ pinoOptions.base = undefined
322
329
  }
323
330
 
324
331
  return pino(pinoOptions)
package/lib/schema.js CHANGED
@@ -59,6 +59,7 @@ export const schema = {
59
59
  server: utilsSchemaComponents.server,
60
60
  watch: schemaComponents.watch,
61
61
  application: schemaComponents.application,
62
+ runtime: utilsSchemaComponents.wrappedRuntime,
62
63
  next,
63
64
  cache
64
65
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/next",
3
- "version": "2.65.1",
3
+ "version": "2.66.0",
4
4
  "description": "Platformatic Next.js Stackable",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,9 +23,9 @@
23
23
  "iovalkey": "^0.3.0",
24
24
  "msgpackr": "^1.11.2",
25
25
  "semver": "^7.6.3",
26
- "@platformatic/config": "2.65.1",
27
- "@platformatic/utils": "2.65.1",
28
- "@platformatic/basic": "2.65.1"
26
+ "@platformatic/basic": "2.66.0",
27
+ "@platformatic/utils": "2.66.0",
28
+ "@platformatic/config": "2.66.0"
29
29
  },
30
30
  "devDependencies": {
31
31
  "@fastify/reply-from": "^12.0.0",
@@ -41,8 +41,8 @@
41
41
  "react-dom": "^18.3.1",
42
42
  "typescript": "^5.5.4",
43
43
  "ws": "^8.18.0",
44
- "@platformatic/composer": "2.65.1",
45
- "@platformatic/service": "2.65.1"
44
+ "@platformatic/composer": "2.66.0",
45
+ "@platformatic/service": "2.66.0"
46
46
  },
47
47
  "scripts": {
48
48
  "test": "npm run lint && borp --concurrency=1 --no-timeout",