@platformatic/service 1.18.0 → 1.20.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/index.d.ts +9 -3
- package/index.test-d.ts +22 -3
- package/lib/generator/service-generator.js +1 -1
- package/lib/plugins/openapi.js +8 -2
- package/lib/root-endpoint/public/index.html +3 -6
- package/package.json +42 -41
package/index.d.ts
CHANGED
|
@@ -4,9 +4,14 @@
|
|
|
4
4
|
import { FastifyInstance, FastifyBaseLogger } from 'fastify'
|
|
5
5
|
import ConfigManager from '@platformatic/config'
|
|
6
6
|
import type { IConfigManagerOptions } from '@platformatic/config'
|
|
7
|
+
import { BaseGenerator } from '@platformatic/generators'
|
|
7
8
|
import { PlatformaticService } from './config'
|
|
8
9
|
import type { JSONSchemaType } from 'ajv'
|
|
9
10
|
import { ServiceGenerator } from './lib/generator/service-generator'
|
|
11
|
+
|
|
12
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
13
|
+
export import Generator = ServiceGenerator.ServiceGenerator
|
|
14
|
+
|
|
10
15
|
export interface PlatformaticApp<T> {
|
|
11
16
|
configManager: ConfigManager<T>
|
|
12
17
|
config: T
|
|
@@ -14,7 +19,8 @@ export interface PlatformaticApp<T> {
|
|
|
14
19
|
|
|
15
20
|
export type PlatformaticServiceConfig = PlatformaticService
|
|
16
21
|
|
|
17
|
-
export function buildServer (opts: object, app?: object,
|
|
22
|
+
export function buildServer (opts: object, app?: object, ConfigManagerConstructor?: object): Promise<FastifyInstance>
|
|
23
|
+
export function start<ConfigType> (app: Stackable<ConfigType>, args: string[]): Promise<void>
|
|
18
24
|
|
|
19
25
|
declare module 'fastify' {
|
|
20
26
|
interface FastifyInstance {
|
|
@@ -33,6 +39,7 @@ export interface Stackable<ConfigType> {
|
|
|
33
39
|
configType: string
|
|
34
40
|
configManagerConfig: ConfigManagerConfig<ConfigType>
|
|
35
41
|
schema: object
|
|
42
|
+
Generator?: new () => BaseGenerator.BaseGenerator
|
|
36
43
|
}
|
|
37
44
|
|
|
38
45
|
interface SchemaExport {
|
|
@@ -45,6 +52,7 @@ interface TSCompilerOptions {
|
|
|
45
52
|
interface TSCompiler {
|
|
46
53
|
compile: (cwd: string, config: object, originalLogger: FastifyBaseLogger, options: TSCompilerOptions) => Promise<boolean>
|
|
47
54
|
}
|
|
55
|
+
|
|
48
56
|
export const schema: SchemaExport
|
|
49
57
|
|
|
50
58
|
export declare const platformaticService: Stackable<PlatformaticServiceConfig>
|
|
@@ -52,5 +60,3 @@ export declare const platformaticService: Stackable<PlatformaticServiceConfig>
|
|
|
52
60
|
export default platformaticService
|
|
53
61
|
|
|
54
62
|
export const tsCompiler: TSCompiler
|
|
55
|
-
|
|
56
|
-
export const Generator: ServiceGenerator.ServiceGenerator
|
package/index.test-d.ts
CHANGED
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import { expectType } from 'tsd'
|
|
2
2
|
import { FastifyInstance } from 'fastify'
|
|
3
|
-
import { buildServer, PlatformaticApp, platformaticService, Stackable, PlatformaticServiceConfig } from '.'
|
|
4
3
|
import ConfigManager from '@platformatic/config'
|
|
5
4
|
import { OpenAPI } from 'openapi-types'
|
|
6
5
|
import type { MercuriusPlugin } from 'mercurius'
|
|
7
6
|
import { PlatformaticService } from './config'
|
|
7
|
+
import { BaseGenerator } from '@platformatic/generators'
|
|
8
|
+
import {
|
|
9
|
+
start,
|
|
10
|
+
buildServer,
|
|
11
|
+
PlatformaticApp,
|
|
12
|
+
platformaticService,
|
|
13
|
+
Stackable,
|
|
14
|
+
Generator,
|
|
15
|
+
PlatformaticServiceConfig
|
|
16
|
+
} from '.'
|
|
8
17
|
|
|
9
18
|
declare module 'fastify' {
|
|
10
19
|
interface FastifyInstance {
|
|
@@ -12,8 +21,7 @@ declare module 'fastify' {
|
|
|
12
21
|
}
|
|
13
22
|
}
|
|
14
23
|
|
|
15
|
-
const server = await buildServer({
|
|
16
|
-
})
|
|
24
|
+
const server = await buildServer({})
|
|
17
25
|
|
|
18
26
|
expectType<FastifyInstance>(server)
|
|
19
27
|
expectType<ConfigManager<PlatformaticService>>(server.platformatic.configManager)
|
|
@@ -41,7 +49,18 @@ function buildStackable (): Stackable<PlatformaticServiceConfig> {
|
|
|
41
49
|
}
|
|
42
50
|
}
|
|
43
51
|
|
|
52
|
+
await start(myApp, ['--help'])
|
|
53
|
+
|
|
44
54
|
return myApp
|
|
45
55
|
}
|
|
46
56
|
|
|
47
57
|
expectType<Stackable<PlatformaticServiceConfig>>(buildStackable())
|
|
58
|
+
|
|
59
|
+
const generator = new Generator()
|
|
60
|
+
expectType<Generator>(generator)
|
|
61
|
+
|
|
62
|
+
class MyGenerator extends Generator {}
|
|
63
|
+
const myGenerator = new MyGenerator()
|
|
64
|
+
|
|
65
|
+
expectType<MyGenerator>(myGenerator)
|
|
66
|
+
expectType<BaseGenerator.BaseGeneratorConfig>(myGenerator.config)
|
package/lib/plugins/openapi.js
CHANGED
|
@@ -58,8 +58,14 @@ async function setupOpenAPI (app, opts) {
|
|
|
58
58
|
const routePrefix = openapi.swaggerPrefix || '/documentation'
|
|
59
59
|
|
|
60
60
|
/** Serve spec file in yaml and json */
|
|
61
|
-
app.get(`${routePrefix}/json`, {
|
|
62
|
-
|
|
61
|
+
app.get(`${routePrefix}/json`, {
|
|
62
|
+
schema: { hide: true },
|
|
63
|
+
logLevel: 'warn'
|
|
64
|
+
}, async () => app.swagger())
|
|
65
|
+
app.get(`${routePrefix}/yaml`, {
|
|
66
|
+
schema: { hide: true },
|
|
67
|
+
logLevel: 'warn'
|
|
68
|
+
}, async () => app.swagger({ yaml: true }))
|
|
63
69
|
|
|
64
70
|
app.register(ScalarApiReference, {
|
|
65
71
|
...opts,
|
|
@@ -222,9 +222,6 @@
|
|
|
222
222
|
<script>
|
|
223
223
|
const currentPath = window.location.pathname
|
|
224
224
|
|
|
225
|
-
const openApiLink = document.getElementById('openapi-link')
|
|
226
|
-
openApiLink.href = currentPath + 'documentation'
|
|
227
|
-
|
|
228
225
|
const graphqlLink = document.getElementById('graphql-link')
|
|
229
226
|
graphqlLink.href = currentPath + 'graphiql'
|
|
230
227
|
|
|
@@ -253,14 +250,14 @@
|
|
|
253
250
|
fetch('/_platformatic_versions')
|
|
254
251
|
.then(response => response.json())
|
|
255
252
|
.then(versions => {
|
|
256
|
-
const sharedOpenapiHref = join(currentPath, 'documentation
|
|
253
|
+
const sharedOpenapiHref = join(currentPath, 'documentation')
|
|
257
254
|
const openapiButtons = [
|
|
258
255
|
`<a href="${sharedOpenapiHref}"target="_blank" class="button-link">OpenAPI Documentation</a>`
|
|
259
256
|
]
|
|
260
257
|
|
|
261
258
|
for (const version of versions) {
|
|
262
|
-
const href = join(currentPath, version.prefix, 'documentation
|
|
263
|
-
openapiButtons.push(`<a href="${href}"target="_blank" class="button-link">OpenAPI Documentation ${version.name}</a>`)
|
|
259
|
+
const href = join(currentPath, version.prefix, 'documentation')
|
|
260
|
+
openapiButtons.push(`<a href="${href}" target="_blank" class="button-link">OpenAPI Documentation ${version.name}</a>`)
|
|
264
261
|
}
|
|
265
262
|
|
|
266
263
|
const buttonList = document.getElementsByClassName('open-documentation-version')[0]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.20.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
},
|
|
18
18
|
"homepage": "https://github.com/platformatic/platformatic#readme",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"@fastify/aws-lambda": "^
|
|
21
|
-
"@fastify/compress": "^
|
|
20
|
+
"@fastify/aws-lambda": "^4.0.0",
|
|
21
|
+
"@fastify/compress": "^7.0.0",
|
|
22
22
|
"bindings": "^1.5.0",
|
|
23
|
-
"
|
|
23
|
+
"borp": "^0.9.0",
|
|
24
24
|
"glob": "^10.3.10",
|
|
25
|
-
"json-schema-to-typescript": "^13.1.
|
|
25
|
+
"json-schema-to-typescript": "^13.1.2",
|
|
26
26
|
"openapi-types": "^12.1.3",
|
|
27
27
|
"pino-abstract-transport": "^1.1.0",
|
|
28
28
|
"self-cert": "^2.0.0",
|
|
@@ -31,61 +31,61 @@
|
|
|
31
31
|
"standard": "^17.1.0",
|
|
32
32
|
"strip-ansi": "^7.1.0",
|
|
33
33
|
"ts-standard": "^12.0.2",
|
|
34
|
-
"tsd": "^0.30.
|
|
35
|
-
"typescript": "^5.
|
|
34
|
+
"tsd": "^0.30.4",
|
|
35
|
+
"typescript": "^5.3.3",
|
|
36
36
|
"undici": "^6.0.0",
|
|
37
|
-
"vscode-json-languageservice": "^5.3.
|
|
37
|
+
"vscode-json-languageservice": "^5.3.9",
|
|
38
38
|
"why-is-node-running": "^2.2.2",
|
|
39
|
-
"yaml": "^2.3.
|
|
39
|
+
"yaml": "^2.3.4"
|
|
40
40
|
},
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@fastify/accepts": "^4.
|
|
43
|
-
"@fastify/autoload": "^5.
|
|
44
|
-
"@fastify/basic-auth": "^5.
|
|
45
|
-
"@fastify/cors": "^
|
|
42
|
+
"@fastify/accepts": "^4.3.0",
|
|
43
|
+
"@fastify/autoload": "^5.8.0",
|
|
44
|
+
"@fastify/basic-auth": "^5.1.1",
|
|
45
|
+
"@fastify/cors": "^9.0.0",
|
|
46
46
|
"@fastify/deepmerge": "^1.3.0",
|
|
47
|
-
"@fastify/error": "^3.4.
|
|
48
|
-
"@fastify/restartable": "^2.
|
|
49
|
-
"@fastify/static": "^
|
|
50
|
-
"@fastify/swagger": "^8.
|
|
47
|
+
"@fastify/error": "^3.4.1",
|
|
48
|
+
"@fastify/restartable": "^2.2.0",
|
|
49
|
+
"@fastify/static": "^7.0.0",
|
|
50
|
+
"@fastify/swagger": "^8.14.0",
|
|
51
51
|
"@fastify/under-pressure": "^8.3.0",
|
|
52
52
|
"@mercuriusjs/federation": "^2.0.0",
|
|
53
|
-
"@scalar/fastify-api-reference": "^1.
|
|
54
|
-
"@types/ws": "^8.5.
|
|
53
|
+
"@scalar/fastify-api-reference": "^1.13.18",
|
|
54
|
+
"@types/ws": "^8.5.10",
|
|
55
55
|
"ajv": "^8.12.0",
|
|
56
56
|
"cli-progress": "^3.12.0",
|
|
57
57
|
"close-with-grace": "^1.2.0",
|
|
58
58
|
"code-block-writer": "^12.0.0",
|
|
59
59
|
"colorette": "^2.0.20",
|
|
60
60
|
"commist": "^3.2.0",
|
|
61
|
-
"console-table-printer": "^2.
|
|
62
|
-
"desm": "^1.3.
|
|
63
|
-
"env-schema": "^5.2.
|
|
61
|
+
"console-table-printer": "^2.12.0",
|
|
62
|
+
"desm": "^1.3.1",
|
|
63
|
+
"env-schema": "^5.2.1",
|
|
64
64
|
"es-main": "^1.3.0",
|
|
65
65
|
"execa": "^8.0.1",
|
|
66
|
-
"fastify": "^4.
|
|
67
|
-
"fastify-metrics": "^10.
|
|
68
|
-
"fastify-openapi-glue": "^4.
|
|
66
|
+
"fastify": "^4.26.0",
|
|
67
|
+
"fastify-metrics": "^10.6.0",
|
|
68
|
+
"fastify-openapi-glue": "^4.4.3",
|
|
69
69
|
"fastify-plugin": "^4.5.1",
|
|
70
70
|
"graphql": "^16.8.1",
|
|
71
71
|
"help-me": "^5.0.0",
|
|
72
|
-
"mercurius": "^13.
|
|
72
|
+
"mercurius": "^13.3.3",
|
|
73
73
|
"minimist": "^1.2.8",
|
|
74
74
|
"openapi-schema-diff": "^0.0.1",
|
|
75
75
|
"ora": "^6.3.1",
|
|
76
|
-
"pino": "^8.
|
|
77
|
-
"pino-pretty": "^10.
|
|
78
|
-
"rfdc": "^1.3.
|
|
79
|
-
"ua-parser-js": "^1.0.
|
|
80
|
-
"undici": "^6.
|
|
81
|
-
"@platformatic/authenticate": "1.
|
|
82
|
-
"@platformatic/client": "1.
|
|
83
|
-
"@platformatic/config": "1.
|
|
84
|
-
"@platformatic/
|
|
85
|
-
"@platformatic/
|
|
86
|
-
"@platformatic/scalar-theme": "1.
|
|
87
|
-
"@platformatic/
|
|
88
|
-
"@platformatic/
|
|
76
|
+
"pino": "^8.17.2",
|
|
77
|
+
"pino-pretty": "^10.3.1",
|
|
78
|
+
"rfdc": "^1.3.1",
|
|
79
|
+
"ua-parser-js": "^1.0.37",
|
|
80
|
+
"undici": "^6.6.0",
|
|
81
|
+
"@platformatic/authenticate": "1.20.0",
|
|
82
|
+
"@platformatic/client": "1.20.0",
|
|
83
|
+
"@platformatic/config": "1.20.0",
|
|
84
|
+
"@platformatic/generators": "1.20.0",
|
|
85
|
+
"@platformatic/metaconfig": "1.20.0",
|
|
86
|
+
"@platformatic/scalar-theme": "1.20.0",
|
|
87
|
+
"@platformatic/utils": "1.20.0",
|
|
88
|
+
"@platformatic/telemetry": "1.20.0"
|
|
89
89
|
},
|
|
90
90
|
"standard": {
|
|
91
91
|
"ignore": [
|
|
@@ -100,9 +100,10 @@
|
|
|
100
100
|
]
|
|
101
101
|
},
|
|
102
102
|
"scripts": {
|
|
103
|
-
"test": "pnpm run
|
|
103
|
+
"test": "pnpm run test && pnpm run lint",
|
|
104
|
+
"unit": "borp --pattern 'test/**/*.test.{js,mjs}' --ignore 'fixtures/**/*' --concurrency=1 --timeout=120000 --no-typescript",
|
|
104
105
|
"nocov": "pnpm run lint && node ./test/runner.js && tsd",
|
|
105
106
|
"build": "node lib/schema.js | json2ts > config.d.ts",
|
|
106
|
-
"lint": "standard | snazzy && ts-standard | snazzy"
|
|
107
|
+
"lint": "standard | snazzy && ts-standard | snazzy && tsd"
|
|
107
108
|
}
|
|
108
109
|
}
|