@platformatic/service 0.46.2 → 0.47.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/.c8rc +6 -0
- package/config.d.ts +0 -1
- package/index.d.ts +25 -0
- package/index.js +1 -0
- package/index.test-d.ts +24 -1
- package/lib/schema.js +0 -3
- package/package.json +9 -7
package/.c8rc
ADDED
package/config.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
/// <reference types="@fastify/swagger" />
|
|
4
4
|
import { FastifyInstance } from 'fastify'
|
|
5
5
|
import ConfigManager from '@platformatic/config'
|
|
6
|
+
import type { IConfigManagerOptions } from '@platformatic/config'
|
|
6
7
|
import { PlatformaticService } from './config'
|
|
8
|
+
import type { JSONSchemaType } from 'ajv'
|
|
7
9
|
|
|
8
10
|
export interface PlatformaticApp<T> {
|
|
9
11
|
configManager: ConfigManager<T>
|
|
@@ -19,3 +21,26 @@ declare module 'fastify' {
|
|
|
19
21
|
restart: () => Promise<void>
|
|
20
22
|
}
|
|
21
23
|
}
|
|
24
|
+
|
|
25
|
+
export interface ConfigManagerConfig<T> extends Omit<IConfigManagerOptions, 'source' | 'watch' | 'schema'> {
|
|
26
|
+
transformConfig: (this: ConfigManager<T>) => Promise<void>
|
|
27
|
+
schema: object
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface Stackable<ConfigType> {
|
|
31
|
+
(app: FastifyInstance, opts: object): Promise<void>
|
|
32
|
+
|
|
33
|
+
configType: string
|
|
34
|
+
configManagerConfig: ConfigManagerConfig<ConfigType>
|
|
35
|
+
schema: object
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface SchemaExport {
|
|
39
|
+
schema: JSONSchemaType<PlatformaticServiceConfig>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const schema: SchemaExport
|
|
43
|
+
|
|
44
|
+
export declare const platformaticService: Stackable<PlatformaticServiceConfig>
|
|
45
|
+
|
|
46
|
+
export default platformaticService
|
package/index.js
CHANGED
|
@@ -54,6 +54,7 @@ async function platformaticService (app, opts, toLoad = []) {
|
|
|
54
54
|
if (config.plugins) {
|
|
55
55
|
let registerTsCompiler = false
|
|
56
56
|
const typescript = config.plugins.typescript
|
|
57
|
+
/* c8 ignore next 6 */
|
|
57
58
|
if (typescript === true) {
|
|
58
59
|
registerTsCompiler = true
|
|
59
60
|
} else if (typeof typescript === 'object') {
|
package/index.test-d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { expectType } from 'tsd'
|
|
2
2
|
import { FastifyInstance } from 'fastify'
|
|
3
|
-
import { buildServer, PlatformaticApp } from '.'
|
|
3
|
+
import { buildServer, PlatformaticApp, platformaticService, Stackable, PlatformaticServiceConfig } from '.'
|
|
4
4
|
import ConfigManager from '@platformatic/config'
|
|
5
5
|
import { OpenAPI } from 'openapi-types'
|
|
6
6
|
import type { MercuriusPlugin } from 'mercurius'
|
|
@@ -22,3 +22,26 @@ expectType<PlatformaticService>(server.platformatic.config)
|
|
|
22
22
|
expectType<OpenAPI.Document>(server.swagger())
|
|
23
23
|
expectType<MercuriusPlugin>(server.graphql)
|
|
24
24
|
expectType<Promise<void>>(server.restart())
|
|
25
|
+
|
|
26
|
+
function buildStackable (): Stackable<PlatformaticServiceConfig> {
|
|
27
|
+
async function myApp (app: FastifyInstance, opts: object): Promise<void> {
|
|
28
|
+
await platformaticService(app, opts)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
myApp.schema = platformaticService.configManagerConfig.schema
|
|
32
|
+
myApp.configType = 'myApp'
|
|
33
|
+
myApp.configManagerConfig = {
|
|
34
|
+
...platformaticService.configManagerConfig,
|
|
35
|
+
async transformConfig (this: ConfigManager<PlatformaticServiceConfig>) {
|
|
36
|
+
this.current.plugins = {
|
|
37
|
+
paths: [{
|
|
38
|
+
path: 'my-plugin'
|
|
39
|
+
}]
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return myApp
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
expectType<Stackable<PlatformaticServiceConfig>>(buildStackable())
|
package/lib/schema.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/service",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.47.1",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
@@ -48,6 +48,8 @@
|
|
|
48
48
|
"@fastify/swagger-ui": "^1.9.0",
|
|
49
49
|
"@fastify/under-pressure": "^8.2.0",
|
|
50
50
|
"@mercuriusjs/federation": "^2.0.0",
|
|
51
|
+
"@types/ws": "^8.5.5",
|
|
52
|
+
"ajv": "^8.12.0",
|
|
51
53
|
"close-with-grace": "^1.2.0",
|
|
52
54
|
"commist": "^3.2.0",
|
|
53
55
|
"desm": "^1.3.0",
|
|
@@ -56,7 +58,7 @@
|
|
|
56
58
|
"execa": "^8.0.0",
|
|
57
59
|
"fastify": "^4.18.0",
|
|
58
60
|
"fastify-metrics": "^10.3.0",
|
|
59
|
-
"fastify-plugin": "^4.5.
|
|
61
|
+
"fastify-plugin": "^4.5.1",
|
|
60
62
|
"graphql": "^16.6.0",
|
|
61
63
|
"help-me": "^4.2.0",
|
|
62
64
|
"mercurius": "^13.0.0",
|
|
@@ -65,11 +67,11 @@
|
|
|
65
67
|
"pino-pretty": "^10.0.0",
|
|
66
68
|
"rfdc": "^1.3.0",
|
|
67
69
|
"ua-parser-js": "^1.0.35",
|
|
68
|
-
"@platformatic/client": "0.
|
|
69
|
-
"@platformatic/
|
|
70
|
-
"@platformatic/
|
|
71
|
-
"@platformatic/utils": "0.
|
|
72
|
-
"@platformatic/telemetry": "0.
|
|
70
|
+
"@platformatic/client": "0.47.1",
|
|
71
|
+
"@platformatic/swagger-ui-theme": "0.47.1",
|
|
72
|
+
"@platformatic/config": "0.47.1",
|
|
73
|
+
"@platformatic/utils": "0.47.1",
|
|
74
|
+
"@platformatic/telemetry": "0.47.1"
|
|
73
75
|
},
|
|
74
76
|
"standard": {
|
|
75
77
|
"ignore": [
|