@platformatic/basic 3.0.0-alpha.5 → 3.0.0-alpha.6
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/eslint.config.js +1 -3
- package/index.d.ts +2 -3
- package/index.js +1 -1
- package/lib/{base.js → capability.js} +13 -13
- package/lib/config.js +1 -1
- package/lib/creation.js +3 -3
- package/lib/errors.js +1 -1
- package/lib/modules.js +16 -16
- package/lib/schema.js +1 -1
- package/lib/worker/child-manager.js +2 -2
- package/lib/worker/child-process.js +7 -7
- package/lib/worker/child-transport.js +2 -2
- package/package.json +7 -8
- package/schema.json +237 -8
package/config.d.ts
CHANGED
|
@@ -10,6 +10,9 @@ export interface PlatformaticBasicConfig {
|
|
|
10
10
|
runtime?: {
|
|
11
11
|
preload?: string | string[];
|
|
12
12
|
basePath?: string;
|
|
13
|
+
services?: {
|
|
14
|
+
[k: string]: unknown;
|
|
15
|
+
}[];
|
|
13
16
|
workers?: number | string;
|
|
14
17
|
logger?: {
|
|
15
18
|
level: (
|
|
@@ -97,7 +100,7 @@ export interface PlatformaticBasicConfig {
|
|
|
97
100
|
restartOnError?: boolean | number;
|
|
98
101
|
gracefulShutdown?: {
|
|
99
102
|
runtime: number | string;
|
|
100
|
-
|
|
103
|
+
application: number | string;
|
|
101
104
|
};
|
|
102
105
|
health?: {
|
|
103
106
|
enabled?: boolean | string;
|
|
@@ -216,11 +219,11 @@ export interface PlatformaticBasicConfig {
|
|
|
216
219
|
telemetry?: {
|
|
217
220
|
enabled?: boolean | string;
|
|
218
221
|
/**
|
|
219
|
-
* The name of the
|
|
222
|
+
* The name of the application. Defaults to the folder name if not specified.
|
|
220
223
|
*/
|
|
221
|
-
|
|
224
|
+
applicationName: string;
|
|
222
225
|
/**
|
|
223
|
-
* The version of the
|
|
226
|
+
* The version of the application (optional)
|
|
224
227
|
*/
|
|
225
228
|
version?: string;
|
|
226
229
|
/**
|
|
@@ -296,7 +299,7 @@ export interface PlatformaticBasicConfig {
|
|
|
296
299
|
watchDisabled?: boolean;
|
|
297
300
|
[k: string]: unknown;
|
|
298
301
|
};
|
|
299
|
-
|
|
302
|
+
applicationTimeout?: number | string;
|
|
300
303
|
messagingTimeout?: number | string;
|
|
301
304
|
env?: {
|
|
302
305
|
[k: string]: string;
|
package/eslint.config.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ export interface Dependency {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
export type BaseContext = Partial<{
|
|
12
|
-
|
|
12
|
+
applicationId: string
|
|
13
13
|
isEntrypoint: boolean
|
|
14
14
|
isProduction: boolean
|
|
15
15
|
isStandalone: boolean
|
|
@@ -18,7 +18,6 @@ export type BaseContext = Partial<{
|
|
|
18
18
|
metricsConfig: object
|
|
19
19
|
serverConfig: object
|
|
20
20
|
hasManagementApi: boolean
|
|
21
|
-
localServiceEnvVars: Map<string, string>
|
|
22
21
|
}>
|
|
23
22
|
|
|
24
23
|
export interface BaseOptions<Context = BaseContext> {
|
|
@@ -27,7 +26,7 @@ export interface BaseOptions<Context = BaseContext> {
|
|
|
27
26
|
|
|
28
27
|
export declare const schemaOptions: Partial<Record<string, unknown>>
|
|
29
28
|
|
|
30
|
-
export class
|
|
29
|
+
export class BaseCapability<Config = Record<string, any>, Options = BaseOptions> {
|
|
31
30
|
basePath: string
|
|
32
31
|
constructor (
|
|
33
32
|
type: string,
|
package/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { cleanBasePath } from './utils.js'
|
|
|
13
13
|
import { ChildManager } from './worker/child-manager.js'
|
|
14
14
|
const kITC = Symbol.for('plt.runtime.itc')
|
|
15
15
|
|
|
16
|
-
export class
|
|
16
|
+
export class BaseCapability extends EventEmitter {
|
|
17
17
|
childManager
|
|
18
18
|
subprocess
|
|
19
19
|
subprocessForceClose
|
|
@@ -32,7 +32,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
32
32
|
this.context.worker ??= { count: 1, index: 0 }
|
|
33
33
|
this.standardStreams = standardStreams
|
|
34
34
|
|
|
35
|
-
this.
|
|
35
|
+
this.applicationId = this.context.applicationId
|
|
36
36
|
this.workerId = this.context.worker.count > 1 ? this.context.worker.index : undefined
|
|
37
37
|
this.telemetryConfig = this.context.telemetryConfig
|
|
38
38
|
this.serverConfig = deepmerge(this.context.serverConfig ?? {}, config.server ?? {})
|
|
@@ -56,7 +56,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
56
56
|
|
|
57
57
|
// Setup globals
|
|
58
58
|
this.registerGlobals({
|
|
59
|
-
|
|
59
|
+
applicationId: this.applicationId,
|
|
60
60
|
workerId: this.workerId,
|
|
61
61
|
logLevel: this.logger.level,
|
|
62
62
|
// Always use URL to avoid serialization problem in Windows
|
|
@@ -90,11 +90,11 @@ export class BaseStackable extends EventEmitter {
|
|
|
90
90
|
}
|
|
91
91
|
|
|
92
92
|
start () {
|
|
93
|
-
throw new Error('
|
|
93
|
+
throw new Error('BaseCapability.start must be overriden by the subclasses')
|
|
94
94
|
}
|
|
95
95
|
|
|
96
96
|
stop () {
|
|
97
|
-
throw new Error('
|
|
97
|
+
throw new Error('BaseCapability.stop must be overriden by the subclasses')
|
|
98
98
|
}
|
|
99
99
|
|
|
100
100
|
build () {
|
|
@@ -107,7 +107,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
107
107
|
}
|
|
108
108
|
|
|
109
109
|
inject () {
|
|
110
|
-
throw new Error('
|
|
110
|
+
throw new Error('BaseCapability.inject must be overriden by the subclasses')
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
getUrl () {
|
|
@@ -158,7 +158,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
158
158
|
|
|
159
159
|
getMeta () {
|
|
160
160
|
return {
|
|
161
|
-
|
|
161
|
+
gateway: {
|
|
162
162
|
wantsAbsoluteUrls: false
|
|
163
163
|
}
|
|
164
164
|
}
|
|
@@ -338,7 +338,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
async stopCommand () {
|
|
341
|
-
const exitTimeout = this.runtimeConfig.gracefulShutdown.
|
|
341
|
+
const exitTimeout = this.runtimeConfig.gracefulShutdown.application
|
|
342
342
|
|
|
343
343
|
this.#subprocessStarted = false
|
|
344
344
|
const exitPromise = once(this.subprocess, 'exit')
|
|
@@ -380,7 +380,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
380
380
|
return {
|
|
381
381
|
id: this.id,
|
|
382
382
|
config: this.config,
|
|
383
|
-
|
|
383
|
+
applicationId: this.applicationId,
|
|
384
384
|
workerId: this.workerId,
|
|
385
385
|
// Always use URL to avoid serialization problem in Windows
|
|
386
386
|
root: pathToFileURL(this.root).toString(),
|
|
@@ -388,7 +388,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
388
388
|
logLevel: this.logger.level,
|
|
389
389
|
isEntrypoint: this.isEntrypoint,
|
|
390
390
|
runtimeBasePath: this.runtimeConfig?.basePath ?? null,
|
|
391
|
-
wantsAbsoluteUrls: meta.
|
|
391
|
+
wantsAbsoluteUrls: meta.gateway?.wantsAbsoluteUrls ?? false,
|
|
392
392
|
/* c8 ignore next 2 - else */
|
|
393
393
|
port: (this.isEntrypoint ? this.serverConfig?.port || 0 : undefined) ?? true,
|
|
394
394
|
host: (this.isEntrypoint ? this.serverConfig?.hostname : undefined) ?? true,
|
|
@@ -430,7 +430,7 @@ export class BaseStackable extends EventEmitter {
|
|
|
430
430
|
const pinoOptions = buildPinoOptions(
|
|
431
431
|
loggerOptions,
|
|
432
432
|
this.serverConfig?.logger,
|
|
433
|
-
this.
|
|
433
|
+
this.applicationId,
|
|
434
434
|
this.workerId,
|
|
435
435
|
this.context,
|
|
436
436
|
this.root
|
|
@@ -463,14 +463,14 @@ export class BaseStackable extends EventEmitter {
|
|
|
463
463
|
|
|
464
464
|
if (this.childManager && this.clientWs) {
|
|
465
465
|
await this.childManager.send(this.clientWs, 'collectMetrics', {
|
|
466
|
-
|
|
466
|
+
applicationId: this.applicationId,
|
|
467
467
|
workerId: this.workerId,
|
|
468
468
|
metricsConfig
|
|
469
469
|
})
|
|
470
470
|
return
|
|
471
471
|
}
|
|
472
472
|
|
|
473
|
-
await collectMetrics(this.
|
|
473
|
+
await collectMetrics(this.applicationId, this.workerId, metricsConfig, this.metricsRegistry)
|
|
474
474
|
}
|
|
475
475
|
|
|
476
476
|
#setHttpCacheMetrics () {
|
package/lib/config.js
CHANGED
|
@@ -54,7 +54,7 @@ export async function resolve (fileOrDirectory, sourceOrConfig, suffixes) {
|
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
export async function transform (config) {
|
|
57
|
-
const patch = workerData?.
|
|
57
|
+
const patch = workerData?.applicationConfig?.configPatch
|
|
58
58
|
|
|
59
59
|
if (!config) {
|
|
60
60
|
return config
|
package/lib/creation.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { resolve } from './config.js'
|
|
2
|
-
import {
|
|
2
|
+
import { importCapabilityAndConfig } from './modules.js'
|
|
3
3
|
|
|
4
4
|
export async function create (fileOrDirectory, sourceOrConfig, context) {
|
|
5
5
|
const { root, source } = await resolve(fileOrDirectory, sourceOrConfig)
|
|
6
|
-
const {
|
|
6
|
+
const { capability } = await importCapabilityAndConfig(root, source, context)
|
|
7
7
|
|
|
8
|
-
return
|
|
8
|
+
return capability.create(root, source, context)
|
|
9
9
|
}
|
package/lib/errors.js
CHANGED
package/lib/modules.js
CHANGED
|
@@ -7,7 +7,7 @@ import pino from 'pino'
|
|
|
7
7
|
import { packageJson } from './schema.js'
|
|
8
8
|
import { importFile } from './utils.js'
|
|
9
9
|
|
|
10
|
-
const
|
|
10
|
+
const importCapabilityPackageMarker = '__pltImportCapabilityPackage.js'
|
|
11
11
|
|
|
12
12
|
export function isImportFailedError (error, pkg) {
|
|
13
13
|
if (error.code !== 'ERR_MODULE_NOT_FOUND' && error.code !== 'MODULE_NOT_FOUND') {
|
|
@@ -16,10 +16,10 @@ export function isImportFailedError (error, pkg) {
|
|
|
16
16
|
|
|
17
17
|
const match = error.message.match(/Cannot find package '(.+)' imported from (.+)/)
|
|
18
18
|
|
|
19
|
-
return match?.[1] === pkg || error.requireStack?.[0].endsWith(
|
|
19
|
+
return match?.[1] === pkg || error.requireStack?.[0].endsWith(importCapabilityPackageMarker)
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export async function
|
|
22
|
+
export async function importCapabilityPackage (directory, pkg) {
|
|
23
23
|
let imported
|
|
24
24
|
try {
|
|
25
25
|
try {
|
|
@@ -30,8 +30,8 @@ export async function importStackablePackage (directory, pkg) {
|
|
|
30
30
|
throw e
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
// Scope to the
|
|
34
|
-
const require = createRequire(resolve(directory,
|
|
33
|
+
// Scope to the application
|
|
34
|
+
const require = createRequire(resolve(directory, importCapabilityPackageMarker))
|
|
35
35
|
const toImport = require.resolve(pkg)
|
|
36
36
|
imported = await importFile(toImport)
|
|
37
37
|
}
|
|
@@ -40,16 +40,16 @@ export async function importStackablePackage (directory, pkg) {
|
|
|
40
40
|
throw e
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const
|
|
43
|
+
const applicationDirectory = workerData ? relative(workerData.dirname, directory) : directory
|
|
44
44
|
throw new Error(
|
|
45
|
-
`Unable to import package '${pkg}'. Please add it as a dependency in the package.json file in the folder ${
|
|
45
|
+
`Unable to import package '${pkg}'. Please add it as a dependency in the package.json file in the folder ${applicationDirectory}.`
|
|
46
46
|
)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
return imported.default ?? imported
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export async function
|
|
52
|
+
export async function importCapabilityAndConfig (root, config, context) {
|
|
53
53
|
let rootPackageJson
|
|
54
54
|
try {
|
|
55
55
|
rootPackageJson = JSON.parse(await readFile(resolve(root, 'package.json'), 'utf-8'))
|
|
@@ -72,27 +72,27 @@ export async function importStackableAndConfig (root, config, context) {
|
|
|
72
72
|
const { label, name: moduleName } = appType
|
|
73
73
|
|
|
74
74
|
if (context) {
|
|
75
|
-
const
|
|
75
|
+
const applicationRoot = relative(process.cwd(), root)
|
|
76
76
|
|
|
77
|
-
if (!hadConfig && context.
|
|
77
|
+
if (!hadConfig && context.applicationId && !(await findConfigurationFile(root)) && context.worker?.index === 0) {
|
|
78
78
|
const autodetectDescription =
|
|
79
79
|
moduleName === '@platformatic/node' ? 'is a generic Node.js application' : `is using ${label}`
|
|
80
80
|
|
|
81
|
-
const logger = pino({ level: context.serverConfig?.logger?.level ?? 'warn', name: context.
|
|
81
|
+
const logger = pino({ level: context.serverConfig?.logger?.level ?? 'warn', name: context.applicationId })
|
|
82
82
|
|
|
83
|
-
logger.warn(`We have auto-detected that
|
|
83
|
+
logger.warn(`We have auto-detected that application "${context.applicationId}" ${autodetectDescription}.`)
|
|
84
84
|
logger.warn(
|
|
85
|
-
`We suggest you create a watt.json or a platformatic.json file in the folder ${
|
|
85
|
+
`We suggest you create a watt.json or a platformatic.json file in the folder ${applicationRoot} with the "$schema" property set to "https://schemas.platformatic.dev/${moduleName}/${packageJson.version}.json".`
|
|
86
86
|
)
|
|
87
|
-
logger.warn(`Also don't forget to add "${moduleName}" to the
|
|
87
|
+
logger.warn(`Also don't forget to add "${moduleName}" to the application dependencies.`)
|
|
88
88
|
logger.warn('You can also run "wattpm import" to do this automatically.\n')
|
|
89
89
|
}
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
const
|
|
92
|
+
const capability = await importCapabilityPackage(root, moduleName)
|
|
93
93
|
|
|
94
94
|
return {
|
|
95
|
-
|
|
95
|
+
capability,
|
|
96
96
|
config,
|
|
97
97
|
autodetectDescription:
|
|
98
98
|
moduleName === '@platformatic/node' ? 'is a generic Node.js application' : `is using ${label}`,
|
package/lib/schema.js
CHANGED
|
@@ -44,7 +44,7 @@ const buildableApplication = {
|
|
|
44
44
|
default: 'npm ci --omit-dev'
|
|
45
45
|
},
|
|
46
46
|
// All the following options purposely don't have a default so
|
|
47
|
-
// that
|
|
47
|
+
// that capabilities can detect if the user explicitly set them.
|
|
48
48
|
build: {
|
|
49
49
|
type: 'string'
|
|
50
50
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createDirectory, ensureLoggableError } from '@platformatic/foundation'
|
|
2
|
-
import { ITC } from '@platformatic/itc'
|
|
2
|
+
import { ITC } from '@platformatic/itc/lib/index.js'
|
|
3
3
|
import { once } from 'node:events'
|
|
4
4
|
import { rm, writeFile } from 'node:fs/promises'
|
|
5
5
|
import { createServer } from 'node:http'
|
|
@@ -137,7 +137,7 @@ export class ChildManager extends ITC {
|
|
|
137
137
|
async inject () {
|
|
138
138
|
await this.listen()
|
|
139
139
|
|
|
140
|
-
// Serialize data into a JSON file for the
|
|
140
|
+
// Serialize data into a JSON file for the capability to use
|
|
141
141
|
this.#dataPath = resolve(tmpdir(), 'platformatic', 'runtimes', `${this.#id}.json`)
|
|
142
142
|
await createDirectory(dirname(this.#dataPath))
|
|
143
143
|
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
ensureLoggableError,
|
|
6
6
|
features
|
|
7
7
|
} from '@platformatic/foundation'
|
|
8
|
-
import { ITC } from '@platformatic/itc'
|
|
8
|
+
import { ITC } from '@platformatic/itc/lib/index.js'
|
|
9
9
|
import { client, collectMetrics } from '@platformatic/metrics'
|
|
10
10
|
import diagnosticChannel, { tracingChannel } from 'node:diagnostics_channel'
|
|
11
11
|
import { EventEmitter, once } from 'node:events'
|
|
@@ -196,8 +196,8 @@ export class ChildProcess extends ITC {
|
|
|
196
196
|
this.#socket.close()
|
|
197
197
|
}
|
|
198
198
|
|
|
199
|
-
async #collectMetrics ({
|
|
200
|
-
await collectMetrics(
|
|
199
|
+
async #collectMetrics ({ applicationId, workerId, metricsConfig }) {
|
|
200
|
+
await collectMetrics(applicationId, workerId, metricsConfig, this.#metricsRegistry)
|
|
201
201
|
this.#setHttpCacheMetrics()
|
|
202
202
|
}
|
|
203
203
|
|
|
@@ -295,12 +295,12 @@ export class ChildProcess extends ITC {
|
|
|
295
295
|
disablePinoDirectWrite()
|
|
296
296
|
|
|
297
297
|
// Since this is executed by user code, make sure we only override this in the main thread
|
|
298
|
-
// The rest will be intercepted by the
|
|
298
|
+
// The rest will be intercepted by the BaseCapability.
|
|
299
299
|
const loggerOptions = globalThis.platformatic?.config?.logger ?? {}
|
|
300
300
|
const pinoOptions = {
|
|
301
301
|
...loggerOptions,
|
|
302
302
|
level: loggerOptions.level ?? 'info',
|
|
303
|
-
name: globalThis.platformatic.
|
|
303
|
+
name: globalThis.platformatic.applicationId
|
|
304
304
|
}
|
|
305
305
|
if (loggerOptions.formatters) {
|
|
306
306
|
pinoOptions.formatters = buildPinoFormatters(loggerOptions.formatters)
|
|
@@ -385,8 +385,8 @@ export class ChildProcess extends ITC {
|
|
|
385
385
|
#setupHandlers () {
|
|
386
386
|
const errorLabel =
|
|
387
387
|
typeof globalThis.platformatic.workerId !== 'undefined'
|
|
388
|
-
? `worker ${globalThis.platformatic.workerId} of the
|
|
389
|
-
: `
|
|
388
|
+
? `worker ${globalThis.platformatic.workerId} of the application "${globalThis.platformatic.applicationId}"`
|
|
389
|
+
: `application "${globalThis.platformatic.applicationId}"`
|
|
390
390
|
|
|
391
391
|
function handleUnhandled (type, err) {
|
|
392
392
|
this.#logger.error({ err: ensureLoggableError(err) }, `Child process for the ${errorLabel} threw an ${type}.`)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ensureLoggableError } from '@platformatic/foundation'
|
|
2
|
-
import { generateRequest, sanitize } from '@platformatic/itc'
|
|
2
|
+
import { generateRequest, sanitize } from '@platformatic/itc/lib/index.js'
|
|
3
3
|
import { once } from 'node:events'
|
|
4
4
|
import { platform } from 'node:os'
|
|
5
5
|
import { workerData } from 'node:worker_threads'
|
|
@@ -9,7 +9,7 @@ import { getSocketPath } from './child-manager.js'
|
|
|
9
9
|
|
|
10
10
|
/* c8 ignore next 5 */
|
|
11
11
|
function logDirectError (message, error) {
|
|
12
|
-
process._rawDebug(`Logger thread for child process of
|
|
12
|
+
process._rawDebug(`Logger thread for child process of application ${workerData.id} ${message}.`, {
|
|
13
13
|
error: ensureLoggableError(error)
|
|
14
14
|
})
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/basic",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.6",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -25,13 +25,13 @@
|
|
|
25
25
|
"split2": "^4.2.0",
|
|
26
26
|
"undici": "^7.0.0",
|
|
27
27
|
"ws": "^8.18.0",
|
|
28
|
-
"@platformatic/itc": "3.0.0-alpha.
|
|
29
|
-
"@platformatic/
|
|
30
|
-
"@platformatic/
|
|
31
|
-
"@platformatic/telemetry": "3.0.0-alpha.
|
|
28
|
+
"@platformatic/itc": "3.0.0-alpha.6",
|
|
29
|
+
"@platformatic/foundation": "3.0.0-alpha.6",
|
|
30
|
+
"@platformatic/metrics": "3.0.0-alpha.6",
|
|
31
|
+
"@platformatic/telemetry": "3.0.0-alpha.6"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
|
-
"
|
|
34
|
+
"cleaner-spec-reporter": "^0.5.0",
|
|
35
35
|
"eslint": "9",
|
|
36
36
|
"express": "^4.19.2",
|
|
37
37
|
"fastify": "^5.0.0",
|
|
@@ -44,8 +44,7 @@
|
|
|
44
44
|
"node": ">=22.18.0"
|
|
45
45
|
},
|
|
46
46
|
"scripts": {
|
|
47
|
-
"test": "
|
|
48
|
-
"coverage": "npm run lint && borp -C -X test -X test/fixtures --concurrency=1 --timeout 1200000",
|
|
47
|
+
"test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
|
49
48
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
50
49
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
51
50
|
"build": "pnpm run gen-schema && pnpm run gen-types",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/basic/3.0.0-alpha.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/basic/3.0.0-alpha.6.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Basic Config",
|
|
5
5
|
"type": "object",
|
|
@@ -28,6 +28,235 @@
|
|
|
28
28
|
"basePath": {
|
|
29
29
|
"type": "string"
|
|
30
30
|
},
|
|
31
|
+
"services": {
|
|
32
|
+
"type": "array",
|
|
33
|
+
"items": {
|
|
34
|
+
"type": "object",
|
|
35
|
+
"anyOf": [
|
|
36
|
+
{
|
|
37
|
+
"required": [
|
|
38
|
+
"id",
|
|
39
|
+
"path"
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"required": [
|
|
44
|
+
"id",
|
|
45
|
+
"url"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
48
|
+
],
|
|
49
|
+
"properties": {
|
|
50
|
+
"id": {
|
|
51
|
+
"type": "string"
|
|
52
|
+
},
|
|
53
|
+
"path": {
|
|
54
|
+
"type": "string",
|
|
55
|
+
"allowEmptyPaths": true,
|
|
56
|
+
"resolvePath": true
|
|
57
|
+
},
|
|
58
|
+
"config": {
|
|
59
|
+
"type": "string"
|
|
60
|
+
},
|
|
61
|
+
"url": {
|
|
62
|
+
"type": "string"
|
|
63
|
+
},
|
|
64
|
+
"gitBranch": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"default": "main"
|
|
67
|
+
},
|
|
68
|
+
"useHttp": {
|
|
69
|
+
"type": "boolean"
|
|
70
|
+
},
|
|
71
|
+
"workers": {
|
|
72
|
+
"anyOf": [
|
|
73
|
+
{
|
|
74
|
+
"type": "number",
|
|
75
|
+
"minimum": 1
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"type": "string"
|
|
79
|
+
}
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"health": {
|
|
83
|
+
"type": "object",
|
|
84
|
+
"default": {},
|
|
85
|
+
"properties": {
|
|
86
|
+
"enabled": {
|
|
87
|
+
"anyOf": [
|
|
88
|
+
{
|
|
89
|
+
"type": "boolean"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"type": "string"
|
|
93
|
+
}
|
|
94
|
+
]
|
|
95
|
+
},
|
|
96
|
+
"interval": {
|
|
97
|
+
"anyOf": [
|
|
98
|
+
{
|
|
99
|
+
"type": "number",
|
|
100
|
+
"minimum": 0
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"type": "string"
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
},
|
|
107
|
+
"gracePeriod": {
|
|
108
|
+
"anyOf": [
|
|
109
|
+
{
|
|
110
|
+
"type": "number",
|
|
111
|
+
"minimum": 0
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"type": "string"
|
|
115
|
+
}
|
|
116
|
+
]
|
|
117
|
+
},
|
|
118
|
+
"maxUnhealthyChecks": {
|
|
119
|
+
"anyOf": [
|
|
120
|
+
{
|
|
121
|
+
"type": "number",
|
|
122
|
+
"minimum": 1
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
"type": "string"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
"maxELU": {
|
|
130
|
+
"anyOf": [
|
|
131
|
+
{
|
|
132
|
+
"type": "number",
|
|
133
|
+
"minimum": 0,
|
|
134
|
+
"maximum": 1
|
|
135
|
+
},
|
|
136
|
+
{
|
|
137
|
+
"type": "string"
|
|
138
|
+
}
|
|
139
|
+
]
|
|
140
|
+
},
|
|
141
|
+
"maxHeapUsed": {
|
|
142
|
+
"anyOf": [
|
|
143
|
+
{
|
|
144
|
+
"type": "number",
|
|
145
|
+
"minimum": 0,
|
|
146
|
+
"maximum": 1
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
"type": "string"
|
|
150
|
+
}
|
|
151
|
+
]
|
|
152
|
+
},
|
|
153
|
+
"maxHeapTotal": {
|
|
154
|
+
"anyOf": [
|
|
155
|
+
{
|
|
156
|
+
"type": "number",
|
|
157
|
+
"minimum": 0
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"type": "string"
|
|
161
|
+
}
|
|
162
|
+
]
|
|
163
|
+
},
|
|
164
|
+
"maxYoungGeneration": {
|
|
165
|
+
"anyOf": [
|
|
166
|
+
{
|
|
167
|
+
"type": "number",
|
|
168
|
+
"minimum": 0
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"type": "string"
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
"additionalProperties": false
|
|
177
|
+
},
|
|
178
|
+
"arguments": {
|
|
179
|
+
"type": "array",
|
|
180
|
+
"items": {
|
|
181
|
+
"type": "string"
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
"env": {
|
|
185
|
+
"type": "object",
|
|
186
|
+
"additionalProperties": {
|
|
187
|
+
"type": "string"
|
|
188
|
+
}
|
|
189
|
+
},
|
|
190
|
+
"envfile": {
|
|
191
|
+
"type": "string"
|
|
192
|
+
},
|
|
193
|
+
"sourceMaps": {
|
|
194
|
+
"type": "boolean",
|
|
195
|
+
"default": false
|
|
196
|
+
},
|
|
197
|
+
"packageManager": {
|
|
198
|
+
"type": "string",
|
|
199
|
+
"enum": [
|
|
200
|
+
"npm",
|
|
201
|
+
"pnpm",
|
|
202
|
+
"yarn"
|
|
203
|
+
]
|
|
204
|
+
},
|
|
205
|
+
"preload": {
|
|
206
|
+
"anyOf": [
|
|
207
|
+
{
|
|
208
|
+
"type": "string",
|
|
209
|
+
"resolvePath": true
|
|
210
|
+
},
|
|
211
|
+
{
|
|
212
|
+
"type": "array",
|
|
213
|
+
"items": {
|
|
214
|
+
"type": "string",
|
|
215
|
+
"resolvePath": true
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
]
|
|
219
|
+
},
|
|
220
|
+
"nodeOptions": {
|
|
221
|
+
"type": "string"
|
|
222
|
+
},
|
|
223
|
+
"telemetry": {
|
|
224
|
+
"type": "object",
|
|
225
|
+
"properties": {
|
|
226
|
+
"instrumentations": {
|
|
227
|
+
"type": "array",
|
|
228
|
+
"description": "An array of instrumentations loaded if telemetry is enabled",
|
|
229
|
+
"items": {
|
|
230
|
+
"oneOf": [
|
|
231
|
+
{
|
|
232
|
+
"type": "string"
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
"type": "object",
|
|
236
|
+
"properties": {
|
|
237
|
+
"package": {
|
|
238
|
+
"type": "string"
|
|
239
|
+
},
|
|
240
|
+
"exportName": {
|
|
241
|
+
"type": "string"
|
|
242
|
+
},
|
|
243
|
+
"options": {
|
|
244
|
+
"type": "object",
|
|
245
|
+
"additionalProperties": true
|
|
246
|
+
}
|
|
247
|
+
},
|
|
248
|
+
"required": [
|
|
249
|
+
"package"
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
]
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
},
|
|
31
260
|
"workers": {
|
|
32
261
|
"anyOf": [
|
|
33
262
|
{
|
|
@@ -342,7 +571,7 @@
|
|
|
342
571
|
],
|
|
343
572
|
"default": 10000
|
|
344
573
|
},
|
|
345
|
-
"
|
|
574
|
+
"application": {
|
|
346
575
|
"anyOf": [
|
|
347
576
|
{
|
|
348
577
|
"type": "number",
|
|
@@ -358,7 +587,7 @@
|
|
|
358
587
|
"default": {},
|
|
359
588
|
"required": [
|
|
360
589
|
"runtime",
|
|
361
|
-
"
|
|
590
|
+
"application"
|
|
362
591
|
],
|
|
363
592
|
"additionalProperties": false
|
|
364
593
|
},
|
|
@@ -789,13 +1018,13 @@
|
|
|
789
1018
|
}
|
|
790
1019
|
]
|
|
791
1020
|
},
|
|
792
|
-
"
|
|
1021
|
+
"applicationName": {
|
|
793
1022
|
"type": "string",
|
|
794
|
-
"description": "The name of the
|
|
1023
|
+
"description": "The name of the application. Defaults to the folder name if not specified."
|
|
795
1024
|
},
|
|
796
1025
|
"version": {
|
|
797
1026
|
"type": "string",
|
|
798
|
-
"description": "The version of the
|
|
1027
|
+
"description": "The version of the application (optional)"
|
|
799
1028
|
},
|
|
800
1029
|
"skip": {
|
|
801
1030
|
"type": "array",
|
|
@@ -902,7 +1131,7 @@
|
|
|
902
1131
|
}
|
|
903
1132
|
},
|
|
904
1133
|
"required": [
|
|
905
|
-
"
|
|
1134
|
+
"applicationName"
|
|
906
1135
|
],
|
|
907
1136
|
"additionalProperties": false
|
|
908
1137
|
},
|
|
@@ -923,7 +1152,7 @@
|
|
|
923
1152
|
}
|
|
924
1153
|
}
|
|
925
1154
|
},
|
|
926
|
-
"
|
|
1155
|
+
"applicationTimeout": {
|
|
927
1156
|
"anyOf": [
|
|
928
1157
|
{
|
|
929
1158
|
"type": "number",
|