@platformatic/next 3.0.0-alpha.5 → 3.0.0-alpha.8
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 +8 -5
- package/index.js +3 -3
- package/lib/caching/valkey.js +3 -3
- package/lib/{stackable.js → capability.js} +9 -7
- package/lib/create-context-patch.js +2 -2
- package/package.json +11 -10
- package/schema.json +244 -8
package/config.d.ts
CHANGED
|
@@ -114,6 +114,9 @@ export interface PlatformaticNextJsConfig {
|
|
|
114
114
|
runtime?: {
|
|
115
115
|
preload?: string | string[];
|
|
116
116
|
basePath?: string;
|
|
117
|
+
services?: {
|
|
118
|
+
[k: string]: unknown;
|
|
119
|
+
}[];
|
|
117
120
|
workers?: number | string;
|
|
118
121
|
logger?: {
|
|
119
122
|
level: (
|
|
@@ -201,7 +204,7 @@ export interface PlatformaticNextJsConfig {
|
|
|
201
204
|
restartOnError?: boolean | number;
|
|
202
205
|
gracefulShutdown?: {
|
|
203
206
|
runtime: number | string;
|
|
204
|
-
|
|
207
|
+
application: number | string;
|
|
205
208
|
};
|
|
206
209
|
health?: {
|
|
207
210
|
enabled?: boolean | string;
|
|
@@ -320,11 +323,11 @@ export interface PlatformaticNextJsConfig {
|
|
|
320
323
|
telemetry?: {
|
|
321
324
|
enabled?: boolean | string;
|
|
322
325
|
/**
|
|
323
|
-
* The name of the
|
|
326
|
+
* The name of the application. Defaults to the folder name if not specified.
|
|
324
327
|
*/
|
|
325
|
-
|
|
328
|
+
applicationName: string;
|
|
326
329
|
/**
|
|
327
|
-
* The version of the
|
|
330
|
+
* The version of the application (optional)
|
|
328
331
|
*/
|
|
329
332
|
version?: string;
|
|
330
333
|
/**
|
|
@@ -400,7 +403,7 @@ export interface PlatformaticNextJsConfig {
|
|
|
400
403
|
watchDisabled?: boolean;
|
|
401
404
|
[k: string]: unknown;
|
|
402
405
|
};
|
|
403
|
-
|
|
406
|
+
applicationTimeout?: number | string;
|
|
404
407
|
messagingTimeout?: number | string;
|
|
405
408
|
env?: {
|
|
406
409
|
[k: string]: string;
|
package/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { transform as basicTransform, resolve, validationOptions } from '@platformatic/basic'
|
|
2
2
|
import { kMetadata, loadConfiguration as utilsLoadConfiguration } from '@platformatic/foundation'
|
|
3
|
+
import { NextCapability } from './lib/capability.js'
|
|
3
4
|
import { schema } from './lib/schema.js'
|
|
4
|
-
import { NextStackable } from './lib/stackable.js'
|
|
5
5
|
|
|
6
6
|
/* c8 ignore next 9 */
|
|
7
7
|
export async function transform (config, schema, options) {
|
|
@@ -29,9 +29,9 @@ export async function loadConfiguration (configOrRoot, sourceOrConfig, context)
|
|
|
29
29
|
|
|
30
30
|
export async function create (configOrRoot, sourceOrConfig, context) {
|
|
31
31
|
const config = await loadConfiguration(configOrRoot, sourceOrConfig, context)
|
|
32
|
-
return new
|
|
32
|
+
return new NextCapability(config[kMetadata].root, config, context)
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export * as cachingValkey from './lib/caching/valkey.js'
|
|
36
|
+
export * from './lib/capability.js'
|
|
36
37
|
export { packageJson, schema, schemaComponents, version } from './lib/schema.js'
|
|
37
|
-
export * from './lib/stackable.js'
|
package/lib/caching/valkey.js
CHANGED
|
@@ -313,8 +313,8 @@ export class CacheHandler {
|
|
|
313
313
|
pinoOptions.timestamp = buildPinoTimestamp(pinoOptions.timestamp)
|
|
314
314
|
}
|
|
315
315
|
|
|
316
|
-
if (this.
|
|
317
|
-
pinoOptions.name = `cache:${this.
|
|
316
|
+
if (this.applicationId) {
|
|
317
|
+
pinoOptions.name = `cache:${this.applicationId}`
|
|
318
318
|
}
|
|
319
319
|
|
|
320
320
|
if (pinoOptions.base !== null && typeof globalThis.platformatic.workerId !== 'undefined') {
|
|
@@ -341,7 +341,7 @@ export class CacheHandler {
|
|
|
341
341
|
|
|
342
342
|
#getPlatformaticMeta () {
|
|
343
343
|
return {
|
|
344
|
-
|
|
344
|
+
applicationId: globalThis.platformatic.applicationId,
|
|
345
345
|
workerId: globalThis.platformatic.workerId
|
|
346
346
|
}
|
|
347
347
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
2
|
+
BaseCapability,
|
|
3
3
|
ChildManager,
|
|
4
4
|
cleanBasePath,
|
|
5
5
|
createChildProcessListener,
|
|
@@ -19,7 +19,7 @@ import { version } from './schema.js'
|
|
|
19
19
|
|
|
20
20
|
const supportedVersions = ['^14.0.0', '^15.0.0']
|
|
21
21
|
|
|
22
|
-
export class
|
|
22
|
+
export class NextCapability extends BaseCapability {
|
|
23
23
|
#basePath
|
|
24
24
|
#next
|
|
25
25
|
#nextVersion
|
|
@@ -75,6 +75,8 @@ export class NextStackable extends BaseStackable {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
async stop () {
|
|
78
|
+
await super.stop()
|
|
79
|
+
|
|
78
80
|
if (this.subprocess) {
|
|
79
81
|
return this.stopCommand()
|
|
80
82
|
}
|
|
@@ -145,14 +147,14 @@ export class NextStackable extends BaseStackable {
|
|
|
145
147
|
}
|
|
146
148
|
|
|
147
149
|
getMeta () {
|
|
148
|
-
const
|
|
150
|
+
const gateway = { prefix: this.basePath ?? this.#basePath, wantsAbsoluteUrls: true, needsRootTrailingSlash: false }
|
|
149
151
|
|
|
150
152
|
if (this.url) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
gateway.tcp = true
|
|
154
|
+
gateway.url = this.url
|
|
153
155
|
}
|
|
154
156
|
|
|
155
|
-
return {
|
|
157
|
+
return { gateway }
|
|
156
158
|
}
|
|
157
159
|
|
|
158
160
|
async #startDevelopment () {
|
|
@@ -241,7 +243,7 @@ export class NextStackable extends BaseStackable {
|
|
|
241
243
|
loader: loaderUrl,
|
|
242
244
|
context: {
|
|
243
245
|
config: this.config,
|
|
244
|
-
|
|
246
|
+
applicationId: this.applicationId,
|
|
245
247
|
workerId: this.workerId,
|
|
246
248
|
// Always use URL to avoid serialization problem in Windows
|
|
247
249
|
root: pathToFileURL(this.root).toString(),
|
|
@@ -4,8 +4,8 @@ import { createRequire } from 'node:module'
|
|
|
4
4
|
import { getGlobalDispatcher } from 'undici'
|
|
5
5
|
|
|
6
6
|
// Next.js runs middlewares in it's own patched vm context. So the global dispatcher in
|
|
7
|
-
// the middleware context is different from
|
|
8
|
-
// method sets
|
|
7
|
+
// the middleware context is different from an application global dispatcher. This
|
|
8
|
+
// method sets an application global dispatcher after next.js defines it's own version of
|
|
9
9
|
// fetch function.
|
|
10
10
|
export function patchVmCreateContext () {
|
|
11
11
|
const _require = createRequire(process.cwd())
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/next",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
4
|
-
"description": "Platformatic Next.js
|
|
3
|
+
"version": "3.0.0-alpha.8",
|
|
4
|
+
"description": "Platformatic Next.js Capability",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"repository": {
|
|
@@ -23,13 +23,15 @@
|
|
|
23
23
|
"iovalkey": "^0.3.0",
|
|
24
24
|
"msgpackr": "^1.11.2",
|
|
25
25
|
"semver": "^7.6.3",
|
|
26
|
-
"@platformatic/basic": "3.0.0-alpha.
|
|
27
|
-
"@platformatic/foundation": "3.0.0-alpha.
|
|
26
|
+
"@platformatic/basic": "3.0.0-alpha.8",
|
|
27
|
+
"@platformatic/foundation": "3.0.0-alpha.8"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@fastify/reply-from": "^12.0.0",
|
|
31
31
|
"@types/node": "^22.5.0",
|
|
32
|
-
"
|
|
32
|
+
"@types/react": "^19.1.11",
|
|
33
|
+
"@types/react-dom": "^19.1.7",
|
|
34
|
+
"cleaner-spec-reporter": "^0.5.0",
|
|
33
35
|
"eslint": "9",
|
|
34
36
|
"execa": "^9.5.1",
|
|
35
37
|
"fastify": "^5.0.0",
|
|
@@ -38,18 +40,17 @@
|
|
|
38
40
|
"next": "^15.0.0",
|
|
39
41
|
"typescript": "^5.5.4",
|
|
40
42
|
"ws": "^8.18.0",
|
|
41
|
-
"@platformatic/
|
|
42
|
-
"@platformatic/service": "3.0.0-alpha.
|
|
43
|
+
"@platformatic/gateway": "3.0.0-alpha.8",
|
|
44
|
+
"@platformatic/service": "3.0.0-alpha.8"
|
|
43
45
|
},
|
|
44
46
|
"engines": {
|
|
45
47
|
"node": ">=22.18.0"
|
|
46
48
|
},
|
|
47
49
|
"scripts": {
|
|
48
|
-
"test": "
|
|
49
|
-
"coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --timeout 1200000",
|
|
50
|
+
"test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
|
50
51
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
51
52
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
52
|
-
"build": "
|
|
53
|
+
"build": "npm run gen-schema && npm run gen-types",
|
|
53
54
|
"lint": "eslint"
|
|
54
55
|
}
|
|
55
56
|
}
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/next/3.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/next/3.0.0-alpha.8.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Next.js Config",
|
|
5
5
|
"type": "object",
|
|
@@ -386,6 +386,242 @@
|
|
|
386
386
|
"basePath": {
|
|
387
387
|
"type": "string"
|
|
388
388
|
},
|
|
389
|
+
"services": {
|
|
390
|
+
"type": "array",
|
|
391
|
+
"items": {
|
|
392
|
+
"type": "object",
|
|
393
|
+
"anyOf": [
|
|
394
|
+
{
|
|
395
|
+
"required": [
|
|
396
|
+
"id",
|
|
397
|
+
"path"
|
|
398
|
+
]
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
"required": [
|
|
402
|
+
"id",
|
|
403
|
+
"url"
|
|
404
|
+
]
|
|
405
|
+
}
|
|
406
|
+
],
|
|
407
|
+
"properties": {
|
|
408
|
+
"id": {
|
|
409
|
+
"type": "string"
|
|
410
|
+
},
|
|
411
|
+
"path": {
|
|
412
|
+
"type": "string",
|
|
413
|
+
"allowEmptyPaths": true,
|
|
414
|
+
"resolvePath": true
|
|
415
|
+
},
|
|
416
|
+
"config": {
|
|
417
|
+
"type": "string"
|
|
418
|
+
},
|
|
419
|
+
"url": {
|
|
420
|
+
"type": "string"
|
|
421
|
+
},
|
|
422
|
+
"gitBranch": {
|
|
423
|
+
"type": "string",
|
|
424
|
+
"default": "main"
|
|
425
|
+
},
|
|
426
|
+
"useHttp": {
|
|
427
|
+
"type": "boolean"
|
|
428
|
+
},
|
|
429
|
+
"workers": {
|
|
430
|
+
"anyOf": [
|
|
431
|
+
{
|
|
432
|
+
"type": "number",
|
|
433
|
+
"minimum": 1
|
|
434
|
+
},
|
|
435
|
+
{
|
|
436
|
+
"type": "string"
|
|
437
|
+
}
|
|
438
|
+
]
|
|
439
|
+
},
|
|
440
|
+
"health": {
|
|
441
|
+
"type": "object",
|
|
442
|
+
"default": {},
|
|
443
|
+
"properties": {
|
|
444
|
+
"enabled": {
|
|
445
|
+
"anyOf": [
|
|
446
|
+
{
|
|
447
|
+
"type": "boolean"
|
|
448
|
+
},
|
|
449
|
+
{
|
|
450
|
+
"type": "string"
|
|
451
|
+
}
|
|
452
|
+
]
|
|
453
|
+
},
|
|
454
|
+
"interval": {
|
|
455
|
+
"anyOf": [
|
|
456
|
+
{
|
|
457
|
+
"type": "number",
|
|
458
|
+
"minimum": 0
|
|
459
|
+
},
|
|
460
|
+
{
|
|
461
|
+
"type": "string"
|
|
462
|
+
}
|
|
463
|
+
]
|
|
464
|
+
},
|
|
465
|
+
"gracePeriod": {
|
|
466
|
+
"anyOf": [
|
|
467
|
+
{
|
|
468
|
+
"type": "number",
|
|
469
|
+
"minimum": 0
|
|
470
|
+
},
|
|
471
|
+
{
|
|
472
|
+
"type": "string"
|
|
473
|
+
}
|
|
474
|
+
]
|
|
475
|
+
},
|
|
476
|
+
"maxUnhealthyChecks": {
|
|
477
|
+
"anyOf": [
|
|
478
|
+
{
|
|
479
|
+
"type": "number",
|
|
480
|
+
"minimum": 1
|
|
481
|
+
},
|
|
482
|
+
{
|
|
483
|
+
"type": "string"
|
|
484
|
+
}
|
|
485
|
+
]
|
|
486
|
+
},
|
|
487
|
+
"maxELU": {
|
|
488
|
+
"anyOf": [
|
|
489
|
+
{
|
|
490
|
+
"type": "number",
|
|
491
|
+
"minimum": 0,
|
|
492
|
+
"maximum": 1
|
|
493
|
+
},
|
|
494
|
+
{
|
|
495
|
+
"type": "string"
|
|
496
|
+
}
|
|
497
|
+
]
|
|
498
|
+
},
|
|
499
|
+
"maxHeapUsed": {
|
|
500
|
+
"anyOf": [
|
|
501
|
+
{
|
|
502
|
+
"type": "number",
|
|
503
|
+
"minimum": 0,
|
|
504
|
+
"maximum": 1
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
"type": "string"
|
|
508
|
+
}
|
|
509
|
+
]
|
|
510
|
+
},
|
|
511
|
+
"maxHeapTotal": {
|
|
512
|
+
"anyOf": [
|
|
513
|
+
{
|
|
514
|
+
"type": "number",
|
|
515
|
+
"minimum": 0
|
|
516
|
+
},
|
|
517
|
+
{
|
|
518
|
+
"type": "string"
|
|
519
|
+
}
|
|
520
|
+
]
|
|
521
|
+
},
|
|
522
|
+
"maxYoungGeneration": {
|
|
523
|
+
"anyOf": [
|
|
524
|
+
{
|
|
525
|
+
"type": "number",
|
|
526
|
+
"minimum": 0
|
|
527
|
+
},
|
|
528
|
+
{
|
|
529
|
+
"type": "string"
|
|
530
|
+
}
|
|
531
|
+
]
|
|
532
|
+
}
|
|
533
|
+
},
|
|
534
|
+
"additionalProperties": false
|
|
535
|
+
},
|
|
536
|
+
"dependencies": {
|
|
537
|
+
"type": "array",
|
|
538
|
+
"items": {
|
|
539
|
+
"type": "string"
|
|
540
|
+
},
|
|
541
|
+
"default": []
|
|
542
|
+
},
|
|
543
|
+
"arguments": {
|
|
544
|
+
"type": "array",
|
|
545
|
+
"items": {
|
|
546
|
+
"type": "string"
|
|
547
|
+
}
|
|
548
|
+
},
|
|
549
|
+
"env": {
|
|
550
|
+
"type": "object",
|
|
551
|
+
"additionalProperties": {
|
|
552
|
+
"type": "string"
|
|
553
|
+
}
|
|
554
|
+
},
|
|
555
|
+
"envfile": {
|
|
556
|
+
"type": "string"
|
|
557
|
+
},
|
|
558
|
+
"sourceMaps": {
|
|
559
|
+
"type": "boolean",
|
|
560
|
+
"default": false
|
|
561
|
+
},
|
|
562
|
+
"packageManager": {
|
|
563
|
+
"type": "string",
|
|
564
|
+
"enum": [
|
|
565
|
+
"npm",
|
|
566
|
+
"pnpm",
|
|
567
|
+
"yarn"
|
|
568
|
+
]
|
|
569
|
+
},
|
|
570
|
+
"preload": {
|
|
571
|
+
"anyOf": [
|
|
572
|
+
{
|
|
573
|
+
"type": "string",
|
|
574
|
+
"resolvePath": true
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"type": "array",
|
|
578
|
+
"items": {
|
|
579
|
+
"type": "string",
|
|
580
|
+
"resolvePath": true
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
]
|
|
584
|
+
},
|
|
585
|
+
"nodeOptions": {
|
|
586
|
+
"type": "string"
|
|
587
|
+
},
|
|
588
|
+
"telemetry": {
|
|
589
|
+
"type": "object",
|
|
590
|
+
"properties": {
|
|
591
|
+
"instrumentations": {
|
|
592
|
+
"type": "array",
|
|
593
|
+
"description": "An array of instrumentations loaded if telemetry is enabled",
|
|
594
|
+
"items": {
|
|
595
|
+
"oneOf": [
|
|
596
|
+
{
|
|
597
|
+
"type": "string"
|
|
598
|
+
},
|
|
599
|
+
{
|
|
600
|
+
"type": "object",
|
|
601
|
+
"properties": {
|
|
602
|
+
"package": {
|
|
603
|
+
"type": "string"
|
|
604
|
+
},
|
|
605
|
+
"exportName": {
|
|
606
|
+
"type": "string"
|
|
607
|
+
},
|
|
608
|
+
"options": {
|
|
609
|
+
"type": "object",
|
|
610
|
+
"additionalProperties": true
|
|
611
|
+
}
|
|
612
|
+
},
|
|
613
|
+
"required": [
|
|
614
|
+
"package"
|
|
615
|
+
]
|
|
616
|
+
}
|
|
617
|
+
]
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
}
|
|
624
|
+
},
|
|
389
625
|
"workers": {
|
|
390
626
|
"anyOf": [
|
|
391
627
|
{
|
|
@@ -700,7 +936,7 @@
|
|
|
700
936
|
],
|
|
701
937
|
"default": 10000
|
|
702
938
|
},
|
|
703
|
-
"
|
|
939
|
+
"application": {
|
|
704
940
|
"anyOf": [
|
|
705
941
|
{
|
|
706
942
|
"type": "number",
|
|
@@ -716,7 +952,7 @@
|
|
|
716
952
|
"default": {},
|
|
717
953
|
"required": [
|
|
718
954
|
"runtime",
|
|
719
|
-
"
|
|
955
|
+
"application"
|
|
720
956
|
],
|
|
721
957
|
"additionalProperties": false
|
|
722
958
|
},
|
|
@@ -1147,13 +1383,13 @@
|
|
|
1147
1383
|
}
|
|
1148
1384
|
]
|
|
1149
1385
|
},
|
|
1150
|
-
"
|
|
1386
|
+
"applicationName": {
|
|
1151
1387
|
"type": "string",
|
|
1152
|
-
"description": "The name of the
|
|
1388
|
+
"description": "The name of the application. Defaults to the folder name if not specified."
|
|
1153
1389
|
},
|
|
1154
1390
|
"version": {
|
|
1155
1391
|
"type": "string",
|
|
1156
|
-
"description": "The version of the
|
|
1392
|
+
"description": "The version of the application (optional)"
|
|
1157
1393
|
},
|
|
1158
1394
|
"skip": {
|
|
1159
1395
|
"type": "array",
|
|
@@ -1260,7 +1496,7 @@
|
|
|
1260
1496
|
}
|
|
1261
1497
|
},
|
|
1262
1498
|
"required": [
|
|
1263
|
-
"
|
|
1499
|
+
"applicationName"
|
|
1264
1500
|
],
|
|
1265
1501
|
"additionalProperties": false
|
|
1266
1502
|
},
|
|
@@ -1281,7 +1517,7 @@
|
|
|
1281
1517
|
}
|
|
1282
1518
|
}
|
|
1283
1519
|
},
|
|
1284
|
-
"
|
|
1520
|
+
"applicationTimeout": {
|
|
1285
1521
|
"anyOf": [
|
|
1286
1522
|
{
|
|
1287
1523
|
"type": "number",
|