@platformatic/service 2.0.0-alpha.9 → 2.0.1
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 +7 -1
- package/index.js +19 -13
- package/lib/plugins/openapi.js +1 -0
- package/lib/plugins/plugins.js +5 -5
- package/lib/root-endpoint/public/images/platformatic-logo-dark.svg +30 -8
- package/lib/root-endpoint/public/images/platformatic-logo-light.svg +30 -8
- package/lib/root-endpoint/public/index.html +10 -6
- package/lib/schema.js +1 -1
- package/lib/stackable.js +19 -7
- package/lib/start.js +13 -0
- package/lib/upgrade.js +0 -3
- package/lib/versions/2.0.0.js +11 -0
- package/package.json +11 -10
- package/schema.json +24 -3
package/config.d.ts
CHANGED
|
@@ -31,7 +31,13 @@ export interface PlatformaticService {
|
|
|
31
31
|
logger?:
|
|
32
32
|
| boolean
|
|
33
33
|
| {
|
|
34
|
-
level
|
|
34
|
+
level: (
|
|
35
|
+
| ("fatal" | "error" | "warn" | "info" | "debug" | "trace" | "silent")
|
|
36
|
+
| {
|
|
37
|
+
[k: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
) &
|
|
40
|
+
string;
|
|
35
41
|
transport?:
|
|
36
42
|
| {
|
|
37
43
|
target?: string;
|
package/index.js
CHANGED
|
@@ -104,7 +104,7 @@ module.exports.configManagerConfig = {
|
|
|
104
104
|
useDefaults: true,
|
|
105
105
|
coerceTypes: true,
|
|
106
106
|
allErrors: true,
|
|
107
|
-
strict: false
|
|
107
|
+
strict: false
|
|
108
108
|
},
|
|
109
109
|
async transformConfig () {
|
|
110
110
|
// Set watch to true by default. This is not possible
|
|
@@ -134,7 +134,7 @@ module.exports.configManagerConfig = {
|
|
|
134
134
|
this.current.watch.ignore.push(outDir + '/**/*')
|
|
135
135
|
}
|
|
136
136
|
},
|
|
137
|
-
upgrade
|
|
137
|
+
upgrade
|
|
138
138
|
}
|
|
139
139
|
|
|
140
140
|
platformaticService.configType = 'service'
|
|
@@ -145,33 +145,39 @@ function _buildServer (options, app) {
|
|
|
145
145
|
return buildServer(options, app || module.exports)
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
-
async function buildStackable (
|
|
149
|
-
options,
|
|
150
|
-
app = platformaticService,
|
|
151
|
-
Stackable = ServiceStackable
|
|
152
|
-
) {
|
|
148
|
+
async function buildStackable (options, app = platformaticService, Stackable = ServiceStackable) {
|
|
153
149
|
let configManager = options.configManager
|
|
154
150
|
|
|
155
151
|
if (configManager === undefined) {
|
|
156
152
|
if (typeof options.config === 'string') {
|
|
157
|
-
({ configManager } = await loadConfig(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
153
|
+
;({ configManager } = await loadConfig(
|
|
154
|
+
{},
|
|
155
|
+
['-c', options.config],
|
|
156
|
+
app,
|
|
157
|
+
{
|
|
158
|
+
onMissingEnv: options.onMissingEnv,
|
|
159
|
+
context: options.context
|
|
160
|
+
},
|
|
161
|
+
true
|
|
162
|
+
))
|
|
161
163
|
} else {
|
|
162
164
|
configManager = new ConfigManager({
|
|
163
165
|
...app.configManagerConfig,
|
|
164
166
|
source: options.config,
|
|
167
|
+
dirname: options.context?.directory
|
|
165
168
|
})
|
|
166
169
|
await configManager.parseAndValidate()
|
|
167
170
|
}
|
|
168
171
|
}
|
|
169
172
|
|
|
170
173
|
const stackable = new Stackable({
|
|
171
|
-
init: () => buildServer(
|
|
174
|
+
init: () => buildServer({
|
|
175
|
+
configManager,
|
|
176
|
+
...configManager.current,
|
|
177
|
+
}, app, options.context),
|
|
172
178
|
stackable: app,
|
|
173
179
|
configManager,
|
|
174
|
-
context: options.context
|
|
180
|
+
context: options.context
|
|
175
181
|
})
|
|
176
182
|
|
|
177
183
|
return stackable
|
package/lib/plugins/openapi.js
CHANGED
package/lib/plugins/plugins.js
CHANGED
|
@@ -32,12 +32,12 @@ async function loadPlugins (app, opts) {
|
|
|
32
32
|
|
|
33
33
|
if (outDir) {
|
|
34
34
|
isOutDirAccessible = await isFileAccessible(outDir)
|
|
35
|
-
}
|
|
36
35
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
36
|
+
if (opts.context?.isProduction && !isOutDirAccessible) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
`Cannot access directory '${outDir}'. Please run the 'build' command before running in production mode.`
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
if (config.plugins.paths && isOutDirAccessible) {
|
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg id="Logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 568.18 568.18">
|
|
3
|
+
<defs>
|
|
4
|
+
<style>
|
|
5
|
+
.cls-1 {
|
|
6
|
+
stroke: #00fe84;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.cls-1, .cls-2 {
|
|
10
|
+
fill: none;
|
|
11
|
+
stroke-linecap: round;
|
|
12
|
+
stroke-linejoin: round;
|
|
13
|
+
stroke-width: 16.34px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.cls-2 {
|
|
17
|
+
stroke: #fff;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
</defs>
|
|
21
|
+
<g>
|
|
22
|
+
<line class="cls-1" x1="148.26" y1="317.46" x2="148.26" y2="389.92"/>
|
|
23
|
+
<polyline class="cls-1" points="176.75 303.19 234.68 336.63 321.11 286.74 321.11 186.94 234.68 137.04 148.26 186.94 148.26 273.55"/>
|
|
24
|
+
<polyline class="cls-1" points="176.75 334.87 176.75 303.19 205.15 285.91"/>
|
|
25
|
+
</g>
|
|
26
|
+
<polyline class="cls-2" points="466.14 259.75 501.19 280.47 501.19 301.18 466.14 321.89"/>
|
|
27
|
+
<polyline class="cls-2" points="106.23 210.58 66.98 233.24 66.98 334.38 105.4 356.56"/>
|
|
28
|
+
<polyline class="cls-2" points="176.75 376.88 176.75 399.34 234.33 431.14 278.53 405.35 278.17 358.41"/>
|
|
29
|
+
<polyline class="cls-2" points="321.66 332.06 321.66 356.76 363.05 380.98 423.55 344.88 423.55 246.39 364.01 212.25"/>
|
|
30
|
+
</svg>
|
|
@@ -1,8 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
<
|
|
3
|
-
<
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg id="Logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 568.18 568.18">
|
|
3
|
+
<defs>
|
|
4
|
+
<style>
|
|
5
|
+
.cls-1 {
|
|
6
|
+
stroke: #00050b;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.cls-1, .cls-2 {
|
|
10
|
+
fill: none;
|
|
11
|
+
stroke-linecap: round;
|
|
12
|
+
stroke-linejoin: round;
|
|
13
|
+
stroke-width: 16.73px;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.cls-2 {
|
|
17
|
+
stroke: #00fe84;
|
|
18
|
+
}
|
|
19
|
+
</style>
|
|
20
|
+
</defs>
|
|
21
|
+
<g>
|
|
22
|
+
<line class="cls-2" x1="144.97" y1="318.27" x2="144.97" y2="392.48"/>
|
|
23
|
+
<polyline class="cls-2" points="174.15 303.65 233.49 337.91 322.01 286.8 322.01 184.58 233.49 133.48 144.97 184.58 144.97 273.29"/>
|
|
24
|
+
<polyline class="cls-2" points="174.15 336.1 174.15 303.66 203.24 285.96"/>
|
|
25
|
+
</g>
|
|
26
|
+
<polyline class="cls-1" points="470.56 259.16 506.46 280.38 506.46 301.59 470.56 322.81"/>
|
|
27
|
+
<polyline class="cls-1" points="101.92 208.8 61.72 232.01 61.72 335.6 101.07 358.32"/>
|
|
28
|
+
<polyline class="cls-1" points="174.15 379.13 174.15 402.14 233.12 434.7 278.4 408.29 278.03 360.22"/>
|
|
29
|
+
<polyline class="cls-1" points="322.57 333.23 322.57 358.53 364.96 383.33 426.93 346.35 426.93 245.48 365.94 210.51"/>
|
|
30
|
+
</svg>
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<html lang="en">
|
|
3
3
|
<head>
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
|
-
<link rel="icon" type="image/svg+xml" href="
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="./images/favicon.ico" />
|
|
6
6
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800&display=swap" rel="stylesheet">
|
|
7
7
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
8
8
|
<title>Platformatic Service</title>
|
|
@@ -204,7 +204,11 @@
|
|
|
204
204
|
</div>
|
|
205
205
|
|
|
206
206
|
<script>
|
|
207
|
-
|
|
207
|
+
let currentPath = window.location.pathname
|
|
208
|
+
|
|
209
|
+
if (!currentPath.endsWith('/')) {
|
|
210
|
+
currentPath += '/'
|
|
211
|
+
}
|
|
208
212
|
|
|
209
213
|
const openApiLink = document.getElementById('openapi-link')
|
|
210
214
|
openApiLink.href = currentPath + 'documentation'
|
|
@@ -215,18 +219,18 @@
|
|
|
215
219
|
const prefersLightScheme = window.matchMedia('(prefers-color-scheme: light)');
|
|
216
220
|
if (prefersLightScheme.matches) {
|
|
217
221
|
document.body.classList.add('light-theme');
|
|
218
|
-
document.getElementById('logo').src = 'images/platformatic-logo-light.svg'
|
|
222
|
+
document.getElementById('logo').src = currentPath + 'images/platformatic-logo-light.svg'
|
|
219
223
|
} else {
|
|
220
224
|
document.body.classList.remove('light-theme');
|
|
221
|
-
document.getElementById('logo').src = 'images/platformatic-logo-dark.svg'
|
|
225
|
+
document.getElementById('logo').src = currentPath + 'images/platformatic-logo-dark.svg'
|
|
222
226
|
}
|
|
223
227
|
|
|
224
228
|
const toggleLightMode = function() {
|
|
225
229
|
document.body.classList.toggle('light-theme');
|
|
226
230
|
if (document.body.classList.contains('light-theme')) {
|
|
227
|
-
document.getElementById('logo').src = 'images/platformatic-logo-light.svg'
|
|
231
|
+
document.getElementById('logo').src = currentPath + 'images/platformatic-logo-light.svg'
|
|
228
232
|
} else {
|
|
229
|
-
document.getElementById('logo').src = 'images/platformatic-logo-dark.svg'
|
|
233
|
+
document.getElementById('logo').src = currentPath + 'images/platformatic-logo-dark.svg'
|
|
230
234
|
}
|
|
231
235
|
}
|
|
232
236
|
</script>
|
package/lib/schema.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
const pkg = require('../package.json')
|
|
6
6
|
const openApiDefs = require('./openapi-schema-defs')
|
|
7
7
|
const telemetry = require('@platformatic/telemetry').schema
|
|
8
|
-
const { server, cors, watch } = require('@platformatic/utils').schemaComponents
|
|
8
|
+
const { fastifyServer: server, cors, watch } = require('@platformatic/utils').schemaComponents
|
|
9
9
|
|
|
10
10
|
const plugins = {
|
|
11
11
|
type: 'object',
|
package/lib/stackable.js
CHANGED
|
@@ -6,6 +6,7 @@ const pino = require('pino')
|
|
|
6
6
|
const httpMetrics = require('@platformatic/fastify-http-metrics')
|
|
7
7
|
const { extractTypeScriptCompileOptionsFromConfig } = require('./compile')
|
|
8
8
|
const { compile } = require('@platformatic/ts-compiler')
|
|
9
|
+
const { deepmerge } = require('@platformatic/utils')
|
|
9
10
|
|
|
10
11
|
class ServiceStackable {
|
|
11
12
|
constructor (options) {
|
|
@@ -64,9 +65,9 @@ class ServiceStackable {
|
|
|
64
65
|
const compileOptions = {
|
|
65
66
|
...typeScriptCompileOptions,
|
|
66
67
|
cwd,
|
|
67
|
-
logger: this.
|
|
68
|
+
logger: this.logger
|
|
68
69
|
}
|
|
69
|
-
if (!await compile(compileOptions)) {
|
|
70
|
+
if (!(await compile(compileOptions))) {
|
|
70
71
|
throw new Error(`Failed to compile ${cwd}`)
|
|
71
72
|
}
|
|
72
73
|
}
|
|
@@ -99,6 +100,10 @@ class ServiceStackable {
|
|
|
99
100
|
return config
|
|
100
101
|
}
|
|
101
102
|
|
|
103
|
+
async getEnv () {
|
|
104
|
+
return this.configManager.env
|
|
105
|
+
}
|
|
106
|
+
|
|
102
107
|
async getWatchConfig () {
|
|
103
108
|
const config = this.configManager.current
|
|
104
109
|
|
|
@@ -210,7 +215,7 @@ class ServiceStackable {
|
|
|
210
215
|
config.metrics = metricsConfig
|
|
211
216
|
}
|
|
212
217
|
if (serverConfig) {
|
|
213
|
-
config.server = serverConfig
|
|
218
|
+
config.server = deepmerge(config.server ?? {}, serverConfig ?? {})
|
|
214
219
|
}
|
|
215
220
|
|
|
216
221
|
if ((hasManagementApi && config.metrics === undefined) || config.metrics) {
|
|
@@ -239,20 +244,27 @@ class ServiceStackable {
|
|
|
239
244
|
}
|
|
240
245
|
|
|
241
246
|
#initLogger () {
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
if (this.configManager.current.server?.loggerInstance) {
|
|
248
|
+
this.logger = this.configManager.current.server?.loggerInstance
|
|
249
|
+
return
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
this.configManager.current.server ??= {}
|
|
253
|
+
this.loggerConfig = deepmerge(this.context.loggerConfig ?? {}, this.configManager.current.server?.logger ?? {})
|
|
244
254
|
|
|
245
255
|
const pinoOptions = {
|
|
246
|
-
level: level ?? 'trace'
|
|
256
|
+
level: this.loggerConfig?.level ?? 'trace'
|
|
247
257
|
}
|
|
248
258
|
|
|
249
259
|
if (this.context?.serviceId) {
|
|
250
260
|
pinoOptions.name = this.context.serviceId
|
|
251
261
|
}
|
|
252
262
|
|
|
263
|
+
this.logger = pino(pinoOptions)
|
|
264
|
+
|
|
253
265
|
// Only one of logger and loggerInstance should be set
|
|
254
266
|
delete this.configManager.current.server.logger
|
|
255
|
-
this.configManager.current.server.loggerInstance =
|
|
267
|
+
this.configManager.current.server.loggerInstance = this.logger
|
|
256
268
|
}
|
|
257
269
|
}
|
|
258
270
|
|
package/lib/start.js
CHANGED
|
@@ -56,12 +56,25 @@ async function createServer (serverContext) {
|
|
|
56
56
|
return root
|
|
57
57
|
}
|
|
58
58
|
async function buildConfigManager (options, app) {
|
|
59
|
+
const loggerInstance = options.server?.loggerInstance
|
|
60
|
+
if (loggerInstance) {
|
|
61
|
+
delete options.server.loggerInstance
|
|
62
|
+
options.server ||= {}
|
|
63
|
+
options.server.logger = { level: loggerInstance.level }
|
|
64
|
+
}
|
|
65
|
+
|
|
59
66
|
let configManager = options.configManager
|
|
60
67
|
if (!configManager) {
|
|
61
68
|
// instantiate a new config manager from current options
|
|
62
69
|
configManager = new ConfigManager({ ...app.configManagerConfig, source: options })
|
|
63
70
|
await configManager.parseAndValidate()
|
|
64
71
|
}
|
|
72
|
+
|
|
73
|
+
if (loggerInstance) {
|
|
74
|
+
configManager.current.server ||= {}
|
|
75
|
+
delete configManager.current.server.logger
|
|
76
|
+
configManager.current.server.loggerInstance = loggerInstance
|
|
77
|
+
}
|
|
65
78
|
return configManager
|
|
66
79
|
}
|
|
67
80
|
|
package/lib/upgrade.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const { join } = require('path')
|
|
4
|
-
const pkg = require('../package.json')
|
|
5
4
|
|
|
6
5
|
module.exports = async function upgrade (config, version) {
|
|
7
6
|
const { semgrator } = await import('semgrator')
|
|
@@ -19,7 +18,5 @@ module.exports = async function upgrade (config, version) {
|
|
|
19
18
|
result = updated.result
|
|
20
19
|
}
|
|
21
20
|
|
|
22
|
-
result.$schema = `https://schemas.platformatic.dev/@platformatic/service/${pkg.version}.json`
|
|
23
|
-
|
|
24
21
|
return result
|
|
25
22
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@fastify/aws-lambda": "^
|
|
20
|
+
"@fastify/aws-lambda": "^5.0.0",
|
|
21
21
|
"@fastify/compress": "^8.0.0",
|
|
22
22
|
"bindings": "^1.5.0",
|
|
23
23
|
"borp": "^0.17.0",
|
|
@@ -61,7 +61,8 @@
|
|
|
61
61
|
"env-schema": "^5.2.1",
|
|
62
62
|
"es-main": "^1.3.0",
|
|
63
63
|
"execa": "^8.0.1",
|
|
64
|
-
"fastify": "5.0.0
|
|
64
|
+
"fastify": "^5.0.0",
|
|
65
|
+
"fastify-metrics": "^12.0.0",
|
|
65
66
|
"fastify-plugin": "^5.0.0",
|
|
66
67
|
"graphql": "^16.9.0",
|
|
67
68
|
"help-me": "^5.0.0",
|
|
@@ -75,13 +76,13 @@
|
|
|
75
76
|
"rfdc": "^1.3.1",
|
|
76
77
|
"semgrator": "^0.3.0",
|
|
77
78
|
"undici": "^6.9.0",
|
|
78
|
-
"@platformatic/
|
|
79
|
-
"@platformatic/
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/scalar-theme": "2.0.
|
|
82
|
-
"@platformatic/telemetry": "2.0.
|
|
83
|
-
"@platformatic/ts-compiler": "2.0.
|
|
84
|
-
"@platformatic/utils": "2.0.
|
|
79
|
+
"@platformatic/config": "2.0.1",
|
|
80
|
+
"@platformatic/client": "2.0.1",
|
|
81
|
+
"@platformatic/generators": "2.0.1",
|
|
82
|
+
"@platformatic/scalar-theme": "2.0.1",
|
|
83
|
+
"@platformatic/telemetry": "2.0.1",
|
|
84
|
+
"@platformatic/ts-compiler": "2.0.1",
|
|
85
|
+
"@platformatic/utils": "2.0.1"
|
|
85
86
|
},
|
|
86
87
|
"scripts": {
|
|
87
88
|
"test": "pnpm run lint && borp -T --concurrency=1 --timeout=180000 && tsd",
|
package/schema.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.0.
|
|
3
|
-
"version": "2.0.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/service/2.0.1.json",
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"title": "Platformatic Service",
|
|
5
5
|
"type": "object",
|
|
6
6
|
"properties": {
|
|
@@ -93,7 +93,24 @@
|
|
|
93
93
|
"type": "object",
|
|
94
94
|
"properties": {
|
|
95
95
|
"level": {
|
|
96
|
-
"type": "string"
|
|
96
|
+
"type": "string",
|
|
97
|
+
"default": "info",
|
|
98
|
+
"oneOf": [
|
|
99
|
+
{
|
|
100
|
+
"enum": [
|
|
101
|
+
"fatal",
|
|
102
|
+
"error",
|
|
103
|
+
"warn",
|
|
104
|
+
"info",
|
|
105
|
+
"debug",
|
|
106
|
+
"trace",
|
|
107
|
+
"silent"
|
|
108
|
+
]
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
"pattern": "^\\{.+\\}$"
|
|
112
|
+
}
|
|
113
|
+
]
|
|
97
114
|
},
|
|
98
115
|
"transport": {
|
|
99
116
|
"anyOf": [
|
|
@@ -154,6 +171,10 @@
|
|
|
154
171
|
"additionalProperties": false
|
|
155
172
|
}
|
|
156
173
|
},
|
|
174
|
+
"required": [
|
|
175
|
+
"level"
|
|
176
|
+
],
|
|
177
|
+
"default": {},
|
|
157
178
|
"additionalProperties": true
|
|
158
179
|
}
|
|
159
180
|
]
|