@platformatic/service 3.4.1 → 3.5.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/LICENSE +1 -1
- package/config.d.ts +450 -94
- package/eslint.config.js +4 -6
- package/index.d.ts +55 -48
- package/index.js +44 -179
- package/lib/application.js +35 -0
- package/lib/capability.js +281 -0
- package/lib/compile.js +2 -52
- package/lib/generator.js +426 -0
- package/lib/plugins/cors.js +5 -8
- package/lib/plugins/graphql.js +16 -14
- package/lib/plugins/health-check.js +6 -8
- package/lib/plugins/openapi.js +43 -32
- package/lib/plugins/plugins.js +6 -53
- package/lib/{root-endpoint/index.js → plugins/root.js} +9 -8
- package/lib/plugins/sandbox-wrapper.js +65 -63
- package/lib/schema.js +1075 -203
- package/lib/upgrade.js +6 -8
- package/lib/utils.js +30 -83
- package/lib/versions/0.16.0.js +14 -15
- package/lib/versions/{from-zero-twenty-eight-to-will-see.js → 0.28.0.js} +3 -6
- package/lib/versions/2.0.0.js +4 -7
- package/lib/versions/3.0.0.js +14 -0
- package/package.json +28 -36
- package/schema.json +1452 -165
- package/tsconfig.json +16 -6
- package/.c8rc +0 -6
- package/help/compile.txt +0 -19
- package/help/create.txt +0 -11
- package/help/help.txt +0 -8
- package/help/schema.txt +0 -9
- package/help/start.txt +0 -23
- package/index.test-d.ts +0 -107
- package/lib/create.mjs +0 -85
- package/lib/gen-schema.js +0 -15
- package/lib/gen-types.mjs +0 -38
- package/lib/generator/README.md +0 -31
- package/lib/generator/service-generator.d.ts +0 -11
- package/lib/generator/service-generator.js +0 -126
- package/lib/openapi-schema-defs.js +0 -1108
- package/lib/plugins/clients.js +0 -16
- package/lib/plugins/metrics.js +0 -244
- package/lib/plugins/typescript.js +0 -20
- package/lib/stackable.js +0 -306
- package/lib/start.js +0 -175
- package/service.mjs +0 -71
- /package/{lib/root-endpoint/public → public}/images/dark_mode.svg +0 -0
- /package/{lib/root-endpoint/public → public}/images/favicon.ico +0 -0
- /package/{lib/root-endpoint/public → public}/images/light_mode.svg +0 -0
- /package/{lib/root-endpoint/public → public}/images/platformatic-logo-dark.svg +0 -0
- /package/{lib/root-endpoint/public → public}/images/platformatic-logo-light.svg +0 -0
- /package/{lib/root-endpoint/public → public}/images/triangle_dark.svg +0 -0
- /package/{lib/root-endpoint/public → public}/images/triangle_light.svg +0 -0
- /package/{lib/root-endpoint/public → public}/index.html +0 -0
package/lib/upgrade.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = async function upgrade (config, version) {
|
|
6
|
-
const { semgrator } = await import('semgrator')
|
|
1
|
+
import { abstractLogger } from '@platformatic/foundation'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
3
|
+
import { semgrator } from 'semgrator'
|
|
7
4
|
|
|
5
|
+
export async function upgrade (logger, config, version) {
|
|
8
6
|
const iterator = semgrator({
|
|
9
7
|
version,
|
|
10
|
-
path:
|
|
8
|
+
path: resolve(import.meta.dirname, 'versions'),
|
|
11
9
|
input: config,
|
|
12
|
-
logger:
|
|
10
|
+
logger: logger?.child({ name: '@platformatic/service' }) ?? abstractLogger
|
|
13
11
|
})
|
|
14
12
|
|
|
15
13
|
let result
|
package/lib/utils.js
CHANGED
|
@@ -1,80 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { access, readFile, stat } from 'node:fs/promises'
|
|
2
|
+
import { resolve } from 'node:path'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const { resolve, join, relative, dirname, basename } = require('node:path')
|
|
5
|
-
const { isatty } = require('tty')
|
|
4
|
+
let _isDocker
|
|
6
5
|
|
|
7
|
-
async function
|
|
8
|
-
try {
|
|
9
|
-
const filePath = directory ? resolve(directory, filename) : filename
|
|
10
|
-
await access(filePath)
|
|
11
|
-
return true
|
|
12
|
-
} catch (err) {
|
|
13
|
-
return false
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/* c8 ignore start */
|
|
18
|
-
function addLoggerToTheConfig (config) {
|
|
19
|
-
// We might have a config with no server
|
|
20
|
-
if (!config.server) {
|
|
21
|
-
config.server = {}
|
|
22
|
-
}
|
|
23
|
-
// Set the logger if not present
|
|
24
|
-
if (!config.server.loggerInstance) {
|
|
25
|
-
let logger = config.server.logger
|
|
26
|
-
if (!logger) {
|
|
27
|
-
config.server.logger = { level: 'info' }
|
|
28
|
-
logger = config.server.logger
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// If TTY use pino-pretty
|
|
32
|
-
if (isatty(1)) {
|
|
33
|
-
if (!logger.transport) {
|
|
34
|
-
logger.transport = {
|
|
35
|
-
target: 'pino-pretty',
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
/* c8 ignore stop */
|
|
42
|
-
|
|
43
|
-
function getJSPluginPath (workingDir, tsPluginPath, compileDir) {
|
|
44
|
-
if (tsPluginPath.endsWith('js')) {
|
|
45
|
-
return tsPluginPath
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
if (tsPluginPath.indexOf(compileDir) === 0) {
|
|
49
|
-
// In this case, we passed through this function before and we have adjusted
|
|
50
|
-
// the path of the plugin to point to the dist/ folder. Then we restarted.
|
|
51
|
-
// Therefore, we can just return the path as is.
|
|
52
|
-
return tsPluginPath
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const isTs = tsPluginPath.endsWith('ts')
|
|
56
|
-
let newBaseName
|
|
57
|
-
|
|
58
|
-
// TODO: investigate why c8 does not see those
|
|
59
|
-
/* c8 ignore next 5 */
|
|
60
|
-
if (isTs) {
|
|
61
|
-
newBaseName = basename(tsPluginPath, '.ts') + '.js'
|
|
62
|
-
} else {
|
|
63
|
-
newBaseName = basename(tsPluginPath)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const tsPluginRelativePath = relative(workingDir, tsPluginPath)
|
|
67
|
-
const jsPluginRelativePath = join(
|
|
68
|
-
dirname(tsPluginRelativePath),
|
|
69
|
-
newBaseName
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
return join(compileDir, jsPluginRelativePath)
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
let isDockerCached
|
|
76
|
-
|
|
77
|
-
async function isDocker () {
|
|
6
|
+
export async function isDocker () {
|
|
78
7
|
async function hasDockerEnv () {
|
|
79
8
|
try {
|
|
80
9
|
await stat('/.dockerenv')
|
|
@@ -92,16 +21,34 @@ async function isDocker () {
|
|
|
92
21
|
}
|
|
93
22
|
}
|
|
94
23
|
|
|
95
|
-
if (
|
|
96
|
-
|
|
24
|
+
if (_isDocker === undefined) {
|
|
25
|
+
_isDocker = (await hasDockerEnv()) || (await hasDockerCGroup())
|
|
97
26
|
}
|
|
98
27
|
|
|
99
|
-
return
|
|
28
|
+
return _isDocker
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export async function isFileAccessible (filename, directory) {
|
|
32
|
+
try {
|
|
33
|
+
const filePath = directory ? resolve(directory, filename) : filename
|
|
34
|
+
await access(filePath)
|
|
35
|
+
return true
|
|
36
|
+
} catch (err) {
|
|
37
|
+
return false
|
|
38
|
+
}
|
|
100
39
|
}
|
|
101
40
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
41
|
+
export async function sanitizeHTTPSArgument (arg) {
|
|
42
|
+
if (typeof arg === 'string') {
|
|
43
|
+
return arg
|
|
44
|
+
} else if (!Array.isArray(arg)) {
|
|
45
|
+
return readFile(arg.path)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const sanitized = []
|
|
49
|
+
for (const item of arg) {
|
|
50
|
+
sanitized.push(typeof item === 'string' ? item : await readFile(item.path))
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return sanitized
|
|
107
54
|
}
|
package/lib/versions/0.16.0.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports = {
|
|
1
|
+
export default {
|
|
4
2
|
version: '0.16.0',
|
|
5
|
-
|
|
6
|
-
up: function (config) {
|
|
3
|
+
up (config) {
|
|
7
4
|
let kind = 'service'
|
|
8
5
|
// This file will be reused in platformatic/db
|
|
9
6
|
if (config.core) {
|
|
@@ -13,18 +10,18 @@ module.exports = {
|
|
|
13
10
|
if (config.plugin) {
|
|
14
11
|
if (Array.isArray(config.plugin)) {
|
|
15
12
|
config.plugins = {
|
|
16
|
-
paths: config.plugin.map(
|
|
13
|
+
paths: config.plugin.map(p => {
|
|
17
14
|
if (typeof p === 'string') {
|
|
18
15
|
return p
|
|
19
16
|
} else if (p.options) {
|
|
20
17
|
return {
|
|
21
18
|
path: p.path,
|
|
22
|
-
options: p.options
|
|
19
|
+
options: p.options
|
|
23
20
|
}
|
|
24
21
|
} else {
|
|
25
22
|
return p.path
|
|
26
23
|
}
|
|
27
|
-
})
|
|
24
|
+
})
|
|
28
25
|
}
|
|
29
26
|
|
|
30
27
|
if (typeof config.plugin[0] === 'object') {
|
|
@@ -41,14 +38,16 @@ module.exports = {
|
|
|
41
38
|
} else if (typeof config.plugin === 'object') {
|
|
42
39
|
if (config.plugin.options) {
|
|
43
40
|
config.plugins = {
|
|
44
|
-
paths: [
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
paths: [
|
|
42
|
+
{
|
|
43
|
+
path: config.plugin.path,
|
|
44
|
+
options: config.plugin.options
|
|
45
|
+
}
|
|
46
|
+
]
|
|
48
47
|
}
|
|
49
48
|
} else {
|
|
50
49
|
config.plugins = {
|
|
51
|
-
paths: [config.plugin.path]
|
|
50
|
+
paths: [config.plugin.path]
|
|
52
51
|
}
|
|
53
52
|
}
|
|
54
53
|
|
|
@@ -66,7 +65,7 @@ module.exports = {
|
|
|
66
65
|
}
|
|
67
66
|
} else {
|
|
68
67
|
config.plugins = {
|
|
69
|
-
paths: [config.plugin]
|
|
68
|
+
paths: [config.plugin]
|
|
70
69
|
}
|
|
71
70
|
}
|
|
72
71
|
|
|
@@ -78,5 +77,5 @@ module.exports = {
|
|
|
78
77
|
config.$schema = 'https://platformatic.dev/schemas/v0.17.0/' + kind
|
|
79
78
|
|
|
80
79
|
return config
|
|
81
|
-
}
|
|
80
|
+
}
|
|
82
81
|
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
module.exports.migration = {
|
|
1
|
+
export default {
|
|
4
2
|
version: '0.28.0',
|
|
5
|
-
|
|
6
|
-
up: function (config) {
|
|
3
|
+
up (config) {
|
|
7
4
|
if (config.watch !== false) {
|
|
8
5
|
config.watch = typeof config.watch === 'object' ? config.watch : true
|
|
9
6
|
}
|
|
10
7
|
delete config.plugins?.watch
|
|
11
8
|
|
|
12
9
|
return config
|
|
13
|
-
}
|
|
10
|
+
}
|
|
14
11
|
}
|
package/lib/versions/2.0.0.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { version } from '../schema.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports.migration = {
|
|
3
|
+
export default {
|
|
6
4
|
version: '2.0.0',
|
|
7
|
-
|
|
8
|
-
up: function (config) {
|
|
5
|
+
up (config) {
|
|
9
6
|
if (typeof config.allowCycles === 'boolean') {
|
|
10
7
|
delete config.allowCycles
|
|
11
8
|
}
|
|
@@ -13,5 +10,5 @@ module.exports.migration = {
|
|
|
13
10
|
config.$schema = `https://schemas.platformatic.dev/@platformatic/service/${version}.json`
|
|
14
11
|
|
|
15
12
|
return config
|
|
16
|
-
}
|
|
13
|
+
}
|
|
17
14
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
version: '2.99.0',
|
|
3
|
+
up (config) {
|
|
4
|
+
if (typeof config.plugins?.typescript !== 'undefined') {
|
|
5
|
+
delete config.plugins.typescript
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
if (typeof config.clients !== 'undefined') {
|
|
9
|
+
delete config.clients
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
return config
|
|
13
|
+
}
|
|
14
|
+
}
|
package/package.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
"author": "Matteo Collina <hello@matteocollina.com>",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"author": "Platformatic Inc. <oss@platformatic.dev> (https://platformatic.dev)",
|
|
10
9
|
"repository": {
|
|
11
10
|
"type": "git",
|
|
12
11
|
"url": "git+https://github.com/platformatic/platformatic.git"
|
|
@@ -20,18 +19,16 @@
|
|
|
20
19
|
"@fastify/aws-lambda": "^5.0.0",
|
|
21
20
|
"@fastify/compress": "^8.0.0",
|
|
22
21
|
"bindings": "^1.5.0",
|
|
23
|
-
"
|
|
22
|
+
"cleaner-spec-reporter": "^0.5.0",
|
|
24
23
|
"eslint": "9",
|
|
25
24
|
"json-schema-to-typescript": "^15.0.0",
|
|
26
|
-
"neostandard": "^0.
|
|
25
|
+
"neostandard": "^0.12.0",
|
|
27
26
|
"openapi-types": "^12.1.3",
|
|
28
27
|
"pino-abstract-transport": "^2.0.0",
|
|
29
28
|
"self-cert": "^2.0.0",
|
|
30
29
|
"split2": "^4.2.0",
|
|
31
|
-
"strip-ansi": "^7.1.0",
|
|
32
|
-
"tsd": "^0.31.0",
|
|
33
30
|
"typescript": "^5.5.4",
|
|
34
|
-
"undici": "
|
|
31
|
+
"undici": "7.11.0",
|
|
35
32
|
"vscode-json-languageservice": "^5.3.9",
|
|
36
33
|
"why-is-node-running": "^2.2.2",
|
|
37
34
|
"yaml": "^2.4.1"
|
|
@@ -39,57 +36,52 @@
|
|
|
39
36
|
"dependencies": {
|
|
40
37
|
"@fastify/accepts": "^5.0.0",
|
|
41
38
|
"@fastify/autoload": "^6.0.0",
|
|
42
|
-
"@fastify/basic-auth": "^6.0.0",
|
|
43
39
|
"@fastify/cors": "^10.0.0",
|
|
44
40
|
"@fastify/deepmerge": "^2.0.0",
|
|
45
41
|
"@fastify/error": "^4.0.0",
|
|
46
42
|
"@fastify/static": "^8.0.0",
|
|
47
43
|
"@fastify/swagger": "^9.0.0",
|
|
48
44
|
"@fastify/under-pressure": "^9.0.0",
|
|
49
|
-
"@
|
|
50
|
-
"@
|
|
51
|
-
"@scalar/fastify-api-reference": "^1.19.5",
|
|
45
|
+
"@scalar/fastify-api-reference": "1.34.6",
|
|
46
|
+
"@types/node": "^22.10.6",
|
|
52
47
|
"@types/ws": "^8.5.10",
|
|
53
48
|
"ajv": "^8.12.0",
|
|
54
49
|
"cli-progress": "^3.12.0",
|
|
55
50
|
"close-with-grace": "^2.0.0",
|
|
56
51
|
"code-block-writer": "^13.0.1",
|
|
57
52
|
"colorette": "^2.0.20",
|
|
58
|
-
"commist": "^3.2.0",
|
|
59
53
|
"console-table-printer": "^2.12.0",
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"execa": "^8.0.1",
|
|
54
|
+
"env-schema": "^6.0.0",
|
|
55
|
+
"execa": "^9.0.0",
|
|
56
|
+
"fast-json-patch": "^3.1.1",
|
|
64
57
|
"fastify": "^5.0.0",
|
|
65
|
-
"fastify-metrics": "^12.0.0",
|
|
66
58
|
"fastify-plugin": "^5.0.0",
|
|
67
59
|
"graphql": "^16.9.0",
|
|
68
60
|
"help-me": "^5.0.0",
|
|
69
|
-
"mercurius": "^
|
|
61
|
+
"mercurius": "^16.0.0",
|
|
70
62
|
"minimist": "^1.2.8",
|
|
71
63
|
"my-ua-parser": "^2.0.2",
|
|
72
64
|
"ora": "^6.3.1",
|
|
73
|
-
"pino": "^9.
|
|
74
|
-
"pino-pretty": "^
|
|
75
|
-
"prom-client": "^15.1.2",
|
|
65
|
+
"pino": "^9.9.0",
|
|
66
|
+
"pino-pretty": "^13.0.0",
|
|
76
67
|
"rfdc": "^1.3.1",
|
|
77
68
|
"semgrator": "^0.3.0",
|
|
78
|
-
"undici": "^
|
|
79
|
-
"@platformatic/
|
|
80
|
-
"@platformatic/
|
|
81
|
-
"@platformatic/
|
|
82
|
-
"@platformatic/
|
|
83
|
-
"@platformatic/
|
|
84
|
-
"@platformatic/telemetry": "3.
|
|
85
|
-
|
|
69
|
+
"undici": "^7.0.0",
|
|
70
|
+
"@platformatic/basic": "3.5.0",
|
|
71
|
+
"@platformatic/foundation": "3.5.0",
|
|
72
|
+
"@platformatic/generators": "3.5.0",
|
|
73
|
+
"@platformatic/metrics": "3.5.0",
|
|
74
|
+
"@platformatic/scalar-theme": "3.5.0",
|
|
75
|
+
"@platformatic/telemetry": "3.5.0"
|
|
76
|
+
},
|
|
77
|
+
"engines": {
|
|
78
|
+
"node": ">=22.19.0"
|
|
86
79
|
},
|
|
87
80
|
"scripts": {
|
|
88
|
-
"test": "
|
|
89
|
-
"unit": "borp --pattern 'test/**/*.test.{js,mjs}' --ignore 'fixtures/**/*' --concurrency=1 --timeout=180000 --no-typescript",
|
|
81
|
+
"test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
|
90
82
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
91
83
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
92
|
-
"build": "
|
|
93
|
-
"lint": "eslint
|
|
84
|
+
"build": "npm run gen-schema && npm run gen-types",
|
|
85
|
+
"lint": "eslint"
|
|
94
86
|
}
|
|
95
87
|
}
|