@platformatic/runtime 2.74.3 → 3.0.0-alpha.2
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 +1 -1
- package/index.d.ts +70 -21
- package/index.js +151 -18
- package/lib/config.js +160 -219
- package/lib/errors.js +150 -108
- package/lib/{generator/runtime-generator.js → generator.js} +36 -53
- package/lib/logger.js +7 -30
- package/lib/management-api.js +6 -56
- package/lib/runtime.js +233 -264
- package/lib/schema.js +2 -1
- package/lib/shared-http-cache.js +1 -1
- package/lib/upgrade.js +6 -4
- package/lib/utils.js +1 -48
- package/lib/worker/app.js +52 -68
- package/lib/worker/itc.js +16 -4
- package/lib/worker/main.js +6 -3
- package/lib/worker/messaging.js +2 -2
- package/package.json +22 -30
- package/schema.json +2 -1
- package/help/compile.txt +0 -8
- package/help/help.txt +0 -5
- package/help/start.txt +0 -21
- package/index.test-d.ts +0 -41
- package/lib/build-server.js +0 -67
- package/lib/compile.js +0 -108
- package/lib/generator/README.md +0 -32
- package/lib/generator/errors.js +0 -10
- package/lib/generator/runtime-generator.d.ts +0 -37
- package/lib/start.js +0 -211
- package/lib/worker/default-stackable.js +0 -33
- package/runtime.mjs +0 -54
package/lib/schema.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
2
|
'use strict'
|
|
3
3
|
|
|
4
|
-
const { schemaComponents } = require('@platformatic/
|
|
4
|
+
const { schemaComponents } = require('@platformatic/foundation')
|
|
5
5
|
|
|
6
6
|
const pkg = require('../package.json')
|
|
7
7
|
|
|
@@ -21,6 +21,7 @@ schemaComponents.runtimeProperties.logger = runtimeLogger
|
|
|
21
21
|
const platformaticRuntimeSchema = {
|
|
22
22
|
$id: `https://schemas.platformatic.dev/@platformatic/runtime/${pkg.version}.json`,
|
|
23
23
|
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
24
|
+
title: 'Platformatic Runtime Config',
|
|
24
25
|
type: 'object',
|
|
25
26
|
properties: schemaComponents.runtimeProperties,
|
|
26
27
|
anyOf: [{ required: ['autoload'] }, { required: ['services'] }, { required: ['web'] }],
|
package/lib/shared-http-cache.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { join } = require('node:path')
|
|
4
|
-
const { loadModule } = require('@platformatic/
|
|
4
|
+
const { loadModule } = require('@platformatic/foundation')
|
|
5
5
|
const MemoryCacheStore = require('@platformatic/undici-cache-memory')
|
|
6
6
|
const { createRequire } = require('node:module')
|
|
7
7
|
|
package/lib/upgrade.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const { abstractLogger } = require('@platformatic/foundation')
|
|
3
4
|
const { join } = require('node:path')
|
|
5
|
+
const { semgrator } = require('semgrator')
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
const { semgrator } = await import('semgrator')
|
|
7
|
-
|
|
7
|
+
async function upgrade (logger, config, version) {
|
|
8
8
|
const iterator = semgrator({
|
|
9
9
|
version,
|
|
10
10
|
path: join(__dirname, 'versions'),
|
|
11
11
|
input: config,
|
|
12
|
-
logger:
|
|
12
|
+
logger: logger?.child({ name: '@platformatic/runtime' }) ?? abstractLogger
|
|
13
13
|
})
|
|
14
14
|
|
|
15
15
|
let result
|
|
@@ -20,3 +20,5 @@ module.exports = async function upgrade (config, version) {
|
|
|
20
20
|
|
|
21
21
|
return result
|
|
22
22
|
}
|
|
23
|
+
|
|
24
|
+
module.exports = { upgrade }
|
package/lib/utils.js
CHANGED
|
@@ -4,14 +4,6 @@ const { createHash } = require('node:crypto')
|
|
|
4
4
|
const { tmpdir } = require('node:os')
|
|
5
5
|
const { join } = require('node:path')
|
|
6
6
|
|
|
7
|
-
const {
|
|
8
|
-
Store,
|
|
9
|
-
loadConfig: pltConfigLoadConfig,
|
|
10
|
-
loadEmptyConfig: pltConfigLoadEmptyConfig
|
|
11
|
-
} = require('@platformatic/config')
|
|
12
|
-
|
|
13
|
-
const { platformaticRuntime } = require('./config')
|
|
14
|
-
|
|
15
7
|
function getArrayDifference (a, b) {
|
|
16
8
|
return a.filter(element => {
|
|
17
9
|
return !b.includes(element)
|
|
@@ -28,47 +20,8 @@ function getRuntimeTmpDir (runtimeDir) {
|
|
|
28
20
|
return join(platformaticTmpDir, runtimeDirHash)
|
|
29
21
|
}
|
|
30
22
|
|
|
31
|
-
function getRuntimeLogsDir (runtimeDir, runtimePID) {
|
|
32
|
-
const runtimeTmpDir = getRuntimeTmpDir(runtimeDir)
|
|
33
|
-
return join(runtimeTmpDir, runtimePID.toString(), 'logs')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
async function loadConfig (minimistConfig, args, overrides, replaceEnv = true) {
|
|
37
|
-
const { default: platformaticBasic } = await import('@platformatic/basic')
|
|
38
|
-
const store = new Store()
|
|
39
|
-
store.add(platformaticRuntime)
|
|
40
|
-
|
|
41
|
-
const id = platformaticRuntime.schema.$id.replace('@platformatic/runtime', 'wattpm')
|
|
42
|
-
const schema = {
|
|
43
|
-
...platformaticRuntime.schema,
|
|
44
|
-
$id: id
|
|
45
|
-
}
|
|
46
|
-
const configManagerConfig = {
|
|
47
|
-
...platformaticRuntime.configManagerConfig,
|
|
48
|
-
schema
|
|
49
|
-
}
|
|
50
|
-
const wattpm = {
|
|
51
|
-
...platformaticRuntime,
|
|
52
|
-
schema,
|
|
53
|
-
configManagerConfig
|
|
54
|
-
}
|
|
55
|
-
store.add(wattpm)
|
|
56
|
-
store.add(platformaticBasic)
|
|
57
|
-
|
|
58
|
-
return pltConfigLoadConfig(minimistConfig, args, store, overrides, replaceEnv)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
async function loadEmptyConfig (path, overrides, replaceEnv = true) {
|
|
62
|
-
const { default: platformaticBasic } = await import('@platformatic/basic')
|
|
63
|
-
|
|
64
|
-
return pltConfigLoadEmptyConfig(path, platformaticBasic, overrides, replaceEnv)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
23
|
module.exports = {
|
|
68
24
|
getArrayDifference,
|
|
69
|
-
getRuntimeLogsDir,
|
|
70
25
|
getRuntimeTmpDir,
|
|
71
|
-
getServiceUrl
|
|
72
|
-
loadConfig,
|
|
73
|
-
loadEmptyConfig
|
|
26
|
+
getServiceUrl
|
|
74
27
|
}
|
package/lib/worker/app.js
CHANGED
|
@@ -7,14 +7,27 @@ const {
|
|
|
7
7
|
performance: { eventLoopUtilization }
|
|
8
8
|
} = require('node:perf_hooks')
|
|
9
9
|
const { workerData } = require('node:worker_threads')
|
|
10
|
-
const {
|
|
11
|
-
|
|
10
|
+
const {
|
|
11
|
+
FileWatcher,
|
|
12
|
+
listRecognizedConfigurationFiles,
|
|
13
|
+
loadConfigurationModule,
|
|
14
|
+
loadConfiguration,
|
|
15
|
+
ensureLoggableError
|
|
16
|
+
} = require('@platformatic/foundation')
|
|
12
17
|
const { getGlobalDispatcher, setGlobalDispatcher } = require('undici')
|
|
13
18
|
const debounce = require('debounce')
|
|
14
|
-
|
|
15
19
|
const errors = require('../errors')
|
|
16
|
-
const
|
|
17
|
-
|
|
20
|
+
const { getServiceUrl } = require('../utils')
|
|
21
|
+
|
|
22
|
+
function fetchServiceUrl (service, key) {
|
|
23
|
+
if (service.localServiceEnvVars.has(key)) {
|
|
24
|
+
return service.localServiceEnvVars.get(key)
|
|
25
|
+
} else if (!key.endsWith('_URL') || !service.id) {
|
|
26
|
+
return null
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return getServiceUrl(service.id)
|
|
30
|
+
}
|
|
18
31
|
|
|
19
32
|
class PlatformaticApp extends EventEmitter {
|
|
20
33
|
#starting
|
|
@@ -60,7 +73,8 @@ class PlatformaticApp extends EventEmitter {
|
|
|
60
73
|
serverConfig,
|
|
61
74
|
worker: workerData?.worker,
|
|
62
75
|
hasManagementApi: !!hasManagementApi,
|
|
63
|
-
localServiceEnvVars: this.appConfig.localServiceEnvVars
|
|
76
|
+
localServiceEnvVars: this.appConfig.localServiceEnvVars,
|
|
77
|
+
fetchServiceUrl: fetchServiceUrl.bind(null, appConfig)
|
|
64
78
|
}
|
|
65
79
|
}
|
|
66
80
|
|
|
@@ -73,70 +87,56 @@ class PlatformaticApp extends EventEmitter {
|
|
|
73
87
|
async updateContext (context) {
|
|
74
88
|
this.#context = { ...this.#context, ...context }
|
|
75
89
|
if (this.stackable) {
|
|
76
|
-
this.stackable.updateContext(context)
|
|
90
|
+
await this.stackable.updateContext(context)
|
|
77
91
|
}
|
|
78
92
|
}
|
|
79
93
|
|
|
80
94
|
async getBootstrapDependencies () {
|
|
81
|
-
return this.stackable.getBootstrapDependencies()
|
|
95
|
+
return this.stackable.getBootstrapDependencies?.() ?? []
|
|
82
96
|
}
|
|
83
97
|
|
|
84
98
|
async init () {
|
|
85
99
|
try {
|
|
86
100
|
const appConfig = this.appConfig
|
|
87
|
-
|
|
101
|
+
|
|
102
|
+
if (appConfig.isProduction && !process.env.NODE_ENV) {
|
|
103
|
+
process.env.NODE_ENV = 'production'
|
|
104
|
+
}
|
|
88
105
|
|
|
89
106
|
// Before returning the base application, check if there is any file we recognize
|
|
90
107
|
// and the user just forgot to specify in the configuration.
|
|
91
108
|
if (!appConfig.config) {
|
|
92
|
-
const candidate =
|
|
109
|
+
const candidate = listRecognizedConfigurationFiles().find(f => existsSync(resolve(appConfig.path, f)))
|
|
93
110
|
|
|
94
111
|
if (candidate) {
|
|
95
112
|
appConfig.config = resolve(appConfig.path, candidate)
|
|
96
113
|
}
|
|
97
114
|
}
|
|
98
115
|
|
|
99
|
-
if (
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
)
|
|
116
|
+
if (appConfig.config) {
|
|
117
|
+
// Parse the configuration file the first time to obtain the schema
|
|
118
|
+
const unvalidatedConfig = await loadConfiguration(appConfig.config, null, {
|
|
119
|
+
onMissingEnv: this.#context.fetchServiceUrl
|
|
120
|
+
})
|
|
121
|
+
const pkg = await loadConfigurationModule(appConfig.path, unvalidatedConfig)
|
|
122
|
+
this.stackable = await pkg.create(appConfig.path, appConfig.config, this.#context)
|
|
123
|
+
// We could not find a configuration file, we use the bundle @platformatic/basic with the runtime to load it
|
|
108
124
|
} else {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
['-c', appConfig.config],
|
|
112
|
-
{
|
|
113
|
-
onMissingEnv: this.#fetchServiceUrl,
|
|
114
|
-
context: appConfig
|
|
115
|
-
},
|
|
116
|
-
true
|
|
117
|
-
)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const app = loadedConfig.app
|
|
121
|
-
|
|
122
|
-
if (appConfig.isProduction && !process.env.NODE_ENV) {
|
|
123
|
-
process.env.NODE_ENV = 'production'
|
|
125
|
+
const pkg = await loadConfigurationModule(resolve(__dirname, '../..'), {}, '@platformatic/basic')
|
|
126
|
+
this.stackable = await pkg.create(appConfig.path, {}, this.#context)
|
|
124
127
|
}
|
|
125
128
|
|
|
126
|
-
const stackable = await app.buildStackable({
|
|
127
|
-
onMissingEnv: this.#fetchServiceUrl,
|
|
128
|
-
config: this.appConfig.config,
|
|
129
|
-
context: this.#context
|
|
130
|
-
})
|
|
131
|
-
this.stackable = this.#wrapStackable(stackable)
|
|
132
|
-
|
|
133
129
|
this.#updateDispatcher()
|
|
134
130
|
} catch (err) {
|
|
135
131
|
if (err.validationErrors) {
|
|
136
|
-
|
|
132
|
+
globalThis.platformatic.logger.error(
|
|
133
|
+
{ err: ensureLoggableError(err.validationErrors) },
|
|
134
|
+
'The application threw a validation error.'
|
|
135
|
+
)
|
|
136
|
+
|
|
137
137
|
process.exit(1)
|
|
138
138
|
} else {
|
|
139
|
-
this.#
|
|
139
|
+
this.#logAndThrow(err)
|
|
140
140
|
}
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -149,13 +149,14 @@ class PlatformaticApp extends EventEmitter {
|
|
|
149
149
|
this.#starting = true
|
|
150
150
|
|
|
151
151
|
try {
|
|
152
|
-
await this.stackable.init()
|
|
152
|
+
await this.stackable.init?.()
|
|
153
153
|
} catch (err) {
|
|
154
|
-
this.#
|
|
154
|
+
this.#logAndThrow(err)
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
if (this.#watch) {
|
|
158
158
|
const watchConfig = await this.stackable.getWatchConfig()
|
|
159
|
+
|
|
159
160
|
if (watchConfig.enabled !== false) {
|
|
160
161
|
/* c8 ignore next 4 */
|
|
161
162
|
this.#debouncedRestart = debounce(() => {
|
|
@@ -168,6 +169,7 @@ class PlatformaticApp extends EventEmitter {
|
|
|
168
169
|
}
|
|
169
170
|
|
|
170
171
|
const listen = !!this.appConfig.useHttp
|
|
172
|
+
|
|
171
173
|
try {
|
|
172
174
|
await this.stackable.start({ listen })
|
|
173
175
|
this.#listening = listen
|
|
@@ -183,8 +185,8 @@ class PlatformaticApp extends EventEmitter {
|
|
|
183
185
|
this.emit('start')
|
|
184
186
|
}
|
|
185
187
|
|
|
186
|
-
async stop () {
|
|
187
|
-
if (!this.#started || this.#starting) {
|
|
188
|
+
async stop (force = false) {
|
|
189
|
+
if (!force && (!this.#started || this.#starting)) {
|
|
188
190
|
throw new errors.ApplicationNotStartedError()
|
|
189
191
|
}
|
|
190
192
|
|
|
@@ -236,16 +238,6 @@ class PlatformaticApp extends EventEmitter {
|
|
|
236
238
|
}
|
|
237
239
|
}
|
|
238
240
|
|
|
239
|
-
#fetchServiceUrl (key, { parent, context: service }) {
|
|
240
|
-
if (service.localServiceEnvVars.has(key)) {
|
|
241
|
-
return service.localServiceEnvVars.get(key)
|
|
242
|
-
} else if (!key.endsWith('_URL') || !parent.serviceId) {
|
|
243
|
-
return null
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
return getServiceUrl(parent.serviceId)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
241
|
#startFileWatching (watch) {
|
|
250
242
|
if (this.#fileWatcher) {
|
|
251
243
|
return
|
|
@@ -275,17 +267,9 @@ class PlatformaticApp extends EventEmitter {
|
|
|
275
267
|
}
|
|
276
268
|
}
|
|
277
269
|
|
|
278
|
-
#
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
#wrapStackable (stackable) {
|
|
284
|
-
const newStackable = {}
|
|
285
|
-
for (const method of Object.keys(defaultStackable)) {
|
|
286
|
-
newStackable[method] = stackable[method] ? stackable[method].bind(stackable) : defaultStackable[method]
|
|
287
|
-
}
|
|
288
|
-
return newStackable
|
|
270
|
+
#logAndThrow (err) {
|
|
271
|
+
globalThis.platformatic.logger.error({ err: ensureLoggableError(err) }, 'The application threw an error.')
|
|
272
|
+
throw err
|
|
289
273
|
}
|
|
290
274
|
|
|
291
275
|
#updateDispatcher () {
|
package/lib/worker/itc.js
CHANGED
|
@@ -4,6 +4,7 @@ const { once } = require('node:events')
|
|
|
4
4
|
const { parentPort, workerData } = require('node:worker_threads')
|
|
5
5
|
|
|
6
6
|
const { ITC } = require('@platformatic/itc')
|
|
7
|
+
const { ensureLoggableError } = require('@platformatic/foundation')
|
|
7
8
|
const { Unpromise } = require('@watchable/unpromise')
|
|
8
9
|
|
|
9
10
|
const errors = require('../errors')
|
|
@@ -56,6 +57,12 @@ async function waitEventFromITC (worker, event) {
|
|
|
56
57
|
return safeHandleInITC(worker, () => once(worker[kITC], event))
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
async function closeITC (dispatcher, itc, messaging) {
|
|
61
|
+
await dispatcher.interceptor.close()
|
|
62
|
+
itc.close()
|
|
63
|
+
messaging.close()
|
|
64
|
+
}
|
|
65
|
+
|
|
59
66
|
function setupITC (app, service, dispatcher, sharedContext) {
|
|
60
67
|
const messaging = new MessagingITC(app.appConfig.id, workerData.config)
|
|
61
68
|
|
|
@@ -79,7 +86,14 @@ function setupITC (app, service, dispatcher, sharedContext) {
|
|
|
79
86
|
// This gives a chance to a stackable to perform custom logic
|
|
80
87
|
globalThis.platformatic.events.emit('start')
|
|
81
88
|
|
|
82
|
-
|
|
89
|
+
try {
|
|
90
|
+
await app.start()
|
|
91
|
+
} catch (e) {
|
|
92
|
+
await app.stop(true)
|
|
93
|
+
await closeITC(dispatcher, itc, messaging)
|
|
94
|
+
|
|
95
|
+
throw ensureLoggableError(e)
|
|
96
|
+
}
|
|
83
97
|
}
|
|
84
98
|
|
|
85
99
|
if (service.entrypoint) {
|
|
@@ -104,9 +118,7 @@ function setupITC (app, service, dispatcher, sharedContext) {
|
|
|
104
118
|
await app.stop()
|
|
105
119
|
}
|
|
106
120
|
|
|
107
|
-
await dispatcher
|
|
108
|
-
itc.close()
|
|
109
|
-
messaging.close()
|
|
121
|
+
await closeITC(dispatcher, itc, messaging)
|
|
110
122
|
},
|
|
111
123
|
|
|
112
124
|
async build () {
|
package/lib/worker/main.js
CHANGED
|
@@ -11,13 +11,12 @@ const { ServerResponse } = require('node:http')
|
|
|
11
11
|
|
|
12
12
|
const {
|
|
13
13
|
disablePinoDirectWrite,
|
|
14
|
-
ensureFlushedWorkerStdio,
|
|
15
14
|
executeWithTimeout,
|
|
16
15
|
ensureLoggableError,
|
|
17
16
|
getPrivateSymbol,
|
|
18
17
|
buildPinoFormatters,
|
|
19
18
|
buildPinoTimestamp
|
|
20
|
-
} = require('@platformatic/
|
|
19
|
+
} = require('@platformatic/foundation')
|
|
21
20
|
const dotenv = require('dotenv')
|
|
22
21
|
const pino = require('pino')
|
|
23
22
|
const { fetch } = require('undici')
|
|
@@ -45,7 +44,6 @@ function handleUnhandled (app, type, err) {
|
|
|
45
44
|
|
|
46
45
|
function patchLogging () {
|
|
47
46
|
disablePinoDirectWrite()
|
|
48
|
-
ensureFlushedWorkerStdio()
|
|
49
47
|
|
|
50
48
|
const kFormatForStderr = getPrivateSymbol(console, 'kFormatForStderr')
|
|
51
49
|
|
|
@@ -67,6 +65,11 @@ function patchLogging () {
|
|
|
67
65
|
}
|
|
68
66
|
|
|
69
67
|
function createLogger () {
|
|
68
|
+
// Do not propagate runtime transports to the worker
|
|
69
|
+
if (workerData.config.logger) {
|
|
70
|
+
delete workerData.config.logger.transport
|
|
71
|
+
}
|
|
72
|
+
|
|
70
73
|
const pinoOptions = {
|
|
71
74
|
level: 'trace',
|
|
72
75
|
name: workerData.serviceConfig.id,
|
package/lib/worker/messaging.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { executeWithTimeout, kTimeout } = require('@platformatic/foundation')
|
|
4
4
|
const { ITC, generateResponse, sanitize } = require('@platformatic/itc')
|
|
5
5
|
const errors = require('../errors')
|
|
6
6
|
const { RoundRobinMap } = require('./round-robin-map')
|
|
@@ -112,7 +112,7 @@ class MessagingITC extends ITC {
|
|
|
112
112
|
}
|
|
113
113
|
|
|
114
114
|
_createClosePromise () {
|
|
115
|
-
const { promise, resolve, reject } = withResolvers()
|
|
115
|
+
const { promise, resolve, reject } = Promise.withResolvers()
|
|
116
116
|
this.#closeResolvers = { resolve, reject }
|
|
117
117
|
return promise
|
|
118
118
|
}
|
package/package.json
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/runtime",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.2",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"bin": {
|
|
7
|
-
"plt-runtime": "./runtime.mjs"
|
|
8
|
-
},
|
|
9
6
|
"author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
|
|
10
7
|
"repository": {
|
|
11
8
|
"type": "git",
|
|
@@ -33,67 +30,62 @@
|
|
|
33
30
|
"neostandard": "^0.12.0",
|
|
34
31
|
"pino-abstract-transport": "^2.0.0",
|
|
35
32
|
"split2": "^4.2.0",
|
|
36
|
-
"tsd": "^0.32.0",
|
|
37
33
|
"typescript": "^5.5.4",
|
|
38
34
|
"undici-oidc-interceptor": "^0.5.0",
|
|
39
35
|
"why-is-node-running": "^2.2.2",
|
|
40
|
-
"@platformatic/composer": "
|
|
41
|
-
"@platformatic/db": "
|
|
42
|
-
"@platformatic/node": "
|
|
43
|
-
"@platformatic/service": "
|
|
44
|
-
"@platformatic/sql-
|
|
45
|
-
"@platformatic/sql-
|
|
36
|
+
"@platformatic/composer": "3.0.0-alpha.2",
|
|
37
|
+
"@platformatic/db": "3.0.0-alpha.2",
|
|
38
|
+
"@platformatic/node": "3.0.0-alpha.2",
|
|
39
|
+
"@platformatic/service": "3.0.0-alpha.2",
|
|
40
|
+
"@platformatic/sql-mapper": "3.0.0-alpha.2",
|
|
41
|
+
"@platformatic/sql-graphql": "3.0.0-alpha.2"
|
|
46
42
|
},
|
|
47
43
|
"dependencies": {
|
|
48
44
|
"@fastify/accepts": "^5.0.0",
|
|
49
45
|
"@fastify/error": "^4.0.0",
|
|
50
46
|
"@fastify/websocket": "^11.0.0",
|
|
51
47
|
"@hapi/topo": "^6.0.2",
|
|
52
|
-
"@opentelemetry/api": "^1.
|
|
48
|
+
"@opentelemetry/api": "^1.9.0",
|
|
53
49
|
"@platformatic/undici-cache-memory": "^0.8.1",
|
|
54
50
|
"@watchable/unpromise": "^1.0.2",
|
|
55
51
|
"change-case-all": "^2.1.0",
|
|
56
52
|
"close-with-grace": "^2.0.0",
|
|
57
|
-
"
|
|
53
|
+
"colorette": "^2.0.20",
|
|
58
54
|
"cron": "^4.1.0",
|
|
59
55
|
"debounce": "^2.0.0",
|
|
60
|
-
"desm": "^1.3.1",
|
|
61
56
|
"dotenv": "^16.4.5",
|
|
62
57
|
"dotenv-tool": "^0.1.1",
|
|
63
|
-
"es-main": "^1.3.0",
|
|
64
58
|
"fastest-levenshtein": "^1.0.16",
|
|
65
59
|
"fastify": "^5.0.0",
|
|
66
60
|
"graphql": "^16.8.1",
|
|
67
61
|
"help-me": "^5.0.0",
|
|
68
62
|
"minimist": "^1.2.8",
|
|
69
|
-
"pino": "^9.
|
|
63
|
+
"pino": "^9.9.0",
|
|
70
64
|
"pino-pretty": "^13.0.0",
|
|
71
|
-
"pino-roll": "^2.0.0",
|
|
72
65
|
"prom-client": "^15.1.2",
|
|
73
66
|
"semgrator": "^0.3.0",
|
|
74
67
|
"sonic-boom": "^4.2.0",
|
|
75
|
-
"tail-file-stream": "^0.2.0",
|
|
76
68
|
"undici": "^7.0.0",
|
|
77
69
|
"undici-thread-interceptor": "^0.14.0",
|
|
78
70
|
"ws": "^8.16.0",
|
|
79
|
-
"@platformatic/basic": "
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/
|
|
84
|
-
"@platformatic/telemetry": "
|
|
85
|
-
|
|
86
|
-
|
|
71
|
+
"@platformatic/basic": "3.0.0-alpha.2",
|
|
72
|
+
"@platformatic/generators": "3.0.0-alpha.2",
|
|
73
|
+
"@platformatic/foundation": "3.0.0-alpha.2",
|
|
74
|
+
"@platformatic/itc": "3.0.0-alpha.2",
|
|
75
|
+
"@platformatic/metrics": "3.0.0-alpha.2",
|
|
76
|
+
"@platformatic/telemetry": "3.0.0-alpha.2"
|
|
77
|
+
},
|
|
78
|
+
"engines": {
|
|
79
|
+
"node": ">=22.18.0"
|
|
87
80
|
},
|
|
88
81
|
"scripts": {
|
|
89
|
-
"test": "pnpm run lint && borp --concurrency=1 --timeout=1200000
|
|
82
|
+
"test": "pnpm run lint && borp --concurrency=1 --timeout=1200000",
|
|
90
83
|
"test:main": "borp --concurrency=1 --timeout=1200000 test/*.test.js test/*.test.mjs test/versions/*.test.js test/versions/*.test.mjs",
|
|
91
84
|
"test:api": "borp --concurrency=1 --timeout=1200000 test/api/*.test.js test/api/*.test.mjs test/management-api/*.test.js test/management-api/*.test.mjs",
|
|
92
85
|
"test:cli": "borp --concurrency=1 --timeout=1200000 test/cli/*.test.js test/cli/*.test.mjs test/cli/**/*.test.js test/cli/**/*.test.mjs",
|
|
93
|
-
"test:start": "borp --concurrency=1 --timeout=1200000 test/start/*.test.js test/start/*.test.mjs",
|
|
86
|
+
"test:start": "borp --concurrency=1 --reporter=tap --timeout=1200000 test/start/*.test.js test/start/*.test.mjs",
|
|
94
87
|
"test:multiple-workers": "borp --concurrency=1 --timeout=1200000 test/multiple-workers/*.test.js test/multiple-workers/*.test.mjs",
|
|
95
|
-
"
|
|
96
|
-
"coverage": "pnpm run lint && borp -X fixtures -X test -C --concurrency=1 --timeout=1200000 && tsd",
|
|
88
|
+
"coverage": "pnpm run lint && borp -X fixtures -X test -C --concurrency=1 --timeout=1200000 ",
|
|
97
89
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
98
90
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
99
91
|
"build": "pnpm run gen-schema && pnpm run gen-types",
|
package/schema.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/runtime/3.0.0-alpha.2.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
|
+
"title": "Platformatic Runtime Config",
|
|
4
5
|
"type": "object",
|
|
5
6
|
"properties": {
|
|
6
7
|
"$schema": {
|
package/help/compile.txt
DELETED
package/help/help.txt
DELETED
package/help/start.txt
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
Start the Platformatic Runtime with the following command:
|
|
2
|
-
|
|
3
|
-
```bash
|
|
4
|
-
$ platformatic runtime start
|
|
5
|
-
```
|
|
6
|
-
|
|
7
|
-
You can also specify a custom routes file, for example:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
$ platformatic runtime start routes.js
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
Where `routes.js` is:
|
|
14
|
-
|
|
15
|
-
```javascript
|
|
16
|
-
module.exports = async function (app) {
|
|
17
|
-
app.get('/hello', async () => {
|
|
18
|
-
return { hello: 'hello123' }
|
|
19
|
-
})
|
|
20
|
-
}
|
|
21
|
-
```
|
package/index.test-d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { expectError, expectType } from 'tsd'
|
|
2
|
-
import { LightMyRequestResponse } from 'fastify'
|
|
3
|
-
import { pltRuntimeBuildServer, errors } from '.'
|
|
4
|
-
import { FastifyError } from '@fastify/error'
|
|
5
|
-
|
|
6
|
-
const server: pltRuntimeBuildServer = {
|
|
7
|
-
address: 'localhost',
|
|
8
|
-
port: 3000,
|
|
9
|
-
restart: async () => { },
|
|
10
|
-
stop: async () => { },
|
|
11
|
-
inject: async () => ({} as LightMyRequestResponse),
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
expectType<pltRuntimeBuildServer>(server)
|
|
15
|
-
expectError<pltRuntimeBuildServer>({ ...server, address: 42 })
|
|
16
|
-
expectError<pltRuntimeBuildServer>({ ...server, port: 'WRONG' })
|
|
17
|
-
expectError<pltRuntimeBuildServer>({ ...server, restart: 'WRONG' })
|
|
18
|
-
expectError<pltRuntimeBuildServer>({ ...server, stop: 'WRONG' })
|
|
19
|
-
expectError<pltRuntimeBuildServer>({ ...server, inject: 'WRONG' })
|
|
20
|
-
|
|
21
|
-
// Errors
|
|
22
|
-
type ErrorWithNoParams = () => FastifyError
|
|
23
|
-
type ErrorWithOneParam = (param: string) => FastifyError
|
|
24
|
-
type ErrorWithTwoParams = (param1: string, param2: string) => FastifyError
|
|
25
|
-
|
|
26
|
-
expectType<ErrorWithNoParams>(errors.RuntimeExitedError)
|
|
27
|
-
expectType<ErrorWithOneParam>(errors.UnknownRuntimeAPICommandError)
|
|
28
|
-
expectType<ErrorWithOneParam>(errors.ServiceNotFoundError)
|
|
29
|
-
expectType<ErrorWithOneParam>(errors.ServiceNotStartedError)
|
|
30
|
-
expectType<ErrorWithTwoParams>(errors.FailedToRetrieveOpenAPISchemaError)
|
|
31
|
-
expectType<ErrorWithNoParams>(errors.ApplicationAlreadyStartedError)
|
|
32
|
-
expectType<ErrorWithNoParams>(errors.ApplicationNotStartedError)
|
|
33
|
-
expectType<ErrorWithNoParams>(errors.ConfigPathMustBeStringError)
|
|
34
|
-
expectType<ErrorWithOneParam>(errors.NoConfigFileFoundError)
|
|
35
|
-
expectType<ErrorWithOneParam>(errors.InvalidEntrypointError)
|
|
36
|
-
expectType<ErrorWithOneParam>(errors.MissingDependencyError)
|
|
37
|
-
expectType<ErrorWithNoParams>(errors.InspectAndInspectBrkError)
|
|
38
|
-
expectType<ErrorWithNoParams>(errors.InspectorPortError)
|
|
39
|
-
expectType<ErrorWithNoParams>(errors.InspectorHostError)
|
|
40
|
-
expectType<ErrorWithOneParam>(errors.CannotMapSpecifierToAbsolutePathError)
|
|
41
|
-
expectType<ErrorWithNoParams>(errors.NodeInspectorFlagsNotSupportedError)
|