@platformatic/gateway 3.45.0 → 3.47.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/config.d.ts +1 -0
- package/index.d.ts +25 -10
- package/lib/capability.js +7 -2
- package/lib/proxy.js +4 -0
- package/lib/schema.js +1 -0
- package/package.json +10 -8
- package/schema.json +4 -1
package/config.d.ts
CHANGED
package/index.d.ts
CHANGED
|
@@ -3,13 +3,22 @@ import { Configuration, ConfigurationOptions } from '@platformatic/foundation'
|
|
|
3
3
|
import {
|
|
4
4
|
ServiceCapability,
|
|
5
5
|
Generator as ServiceGenerator,
|
|
6
|
-
PlatformaticServiceConfig,
|
|
7
6
|
ServerInstance as ServiceServerInstance
|
|
8
7
|
} from '@platformatic/service'
|
|
9
8
|
import { JSONSchemaType } from 'ajv'
|
|
10
9
|
import { FastifyError, FastifyInstance } from 'fastify'
|
|
11
10
|
import type { PlatformaticGatewayConfig } from './config.d.ts'
|
|
12
11
|
|
|
12
|
+
export interface GatewayCommand {
|
|
13
|
+
usage: string
|
|
14
|
+
description: string
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface GatewayCommandDefinition {
|
|
18
|
+
commands: Record<string, (...args: unknown[]) => Promise<void> | void>
|
|
19
|
+
help: Record<string, GatewayCommand>
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
export type { PlatformaticServiceConfig } from '@platformatic/service'
|
|
14
23
|
export type { PlatformaticGatewayConfig } from './config.d.ts'
|
|
15
24
|
|
|
@@ -20,19 +29,21 @@ export type ServerInstance = ServiceServerInstance<PlatformaticGatewayConfig>
|
|
|
20
29
|
type GatewayConfiguration = Configuration<PlatformaticGatewayConfig>
|
|
21
30
|
|
|
22
31
|
export declare function loadConfiguration (
|
|
23
|
-
root: string |
|
|
24
|
-
source?: string |
|
|
32
|
+
root: string | PlatformaticGatewayConfig,
|
|
33
|
+
source?: string | PlatformaticGatewayConfig,
|
|
25
34
|
context?: ConfigurationOptions
|
|
26
35
|
): Promise<GatewayConfiguration>
|
|
27
36
|
|
|
28
37
|
export function create (
|
|
29
|
-
root: string,
|
|
38
|
+
root: string | PlatformaticGatewayConfig,
|
|
30
39
|
source?: string | PlatformaticGatewayConfig,
|
|
31
40
|
context?: ConfigurationOptions
|
|
32
41
|
): Promise<GatewayCapability>
|
|
33
42
|
|
|
34
43
|
export declare function platformaticGateway (app: FastifyInstance, capability: BaseCapability): Promise<void>
|
|
35
44
|
|
|
45
|
+
export declare function createCommands (id: string): GatewayCommandDefinition
|
|
46
|
+
|
|
36
47
|
export class Generator extends ServiceGenerator {}
|
|
37
48
|
|
|
38
49
|
export declare const packageJson: Record<string, unknown>
|
|
@@ -44,15 +55,19 @@ export declare const schemaComponents: {
|
|
|
44
55
|
entityResolver: JSONSchemaType<object>
|
|
45
56
|
entities: JSONSchemaType<object>
|
|
46
57
|
graphqlApplication: JSONSchemaType<object>
|
|
47
|
-
|
|
58
|
+
graphqlComposerOptions: JSONSchemaType<object>
|
|
48
59
|
gateway: JSONSchemaType<object>
|
|
49
60
|
types: JSONSchemaType<object>
|
|
50
61
|
}
|
|
51
62
|
|
|
63
|
+
export declare const skipTelemetryHooks: boolean
|
|
64
|
+
|
|
52
65
|
export declare const version: string
|
|
53
66
|
|
|
54
|
-
export
|
|
55
|
-
export
|
|
56
|
-
export
|
|
57
|
-
export
|
|
58
|
-
export
|
|
67
|
+
export namespace errors {
|
|
68
|
+
export const FastifyInstanceIsAlreadyListeningError: () => FastifyError
|
|
69
|
+
export const FailedToFetchOpenAPISchemaError: () => FastifyError
|
|
70
|
+
export const ValidationErrors: () => FastifyError
|
|
71
|
+
export const PathAlreadyExistsError: () => FastifyError
|
|
72
|
+
export const CouldNotReadOpenAPIConfigError: () => FastifyError
|
|
73
|
+
}
|
package/lib/capability.js
CHANGED
|
@@ -41,8 +41,13 @@ export class GatewayCapability extends ServiceCapability {
|
|
|
41
41
|
|
|
42
42
|
const url = await super.start()
|
|
43
43
|
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
// Only register the runtime event handler once. start() can be called
|
|
45
|
+
// multiple times (first with listen:false, then listen:true) so guard
|
|
46
|
+
// against duplicate registrations.
|
|
47
|
+
if (!this.#runtimeEventHandler) {
|
|
48
|
+
this.#runtimeEventHandler = this.#handleRuntimeEvent.bind(this)
|
|
49
|
+
globalThis[kITC]?.on('runtime:event', this.#runtimeEventHandler)
|
|
50
|
+
}
|
|
46
51
|
|
|
47
52
|
return url
|
|
48
53
|
}
|
package/lib/proxy.js
CHANGED
|
@@ -50,6 +50,10 @@ async function resolveApplicationProxyParameters (application, root) {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
if (typeof application.proxy?.rewriteLocationHeader === 'boolean') {
|
|
54
|
+
internalRewriteLocationHeader = application.proxy.rewriteLocationHeader
|
|
55
|
+
}
|
|
56
|
+
|
|
53
57
|
const require = createRequire(import.meta.filename)
|
|
54
58
|
|
|
55
59
|
if (application.proxy?.custom) {
|
package/lib/schema.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/gateway",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.47.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"dedent": "^1.5.1",
|
|
23
23
|
"eslint": "9",
|
|
24
24
|
"json-schema-to-typescript": "^15.0.0",
|
|
25
|
+
"tstyche": "^6.2.0",
|
|
25
26
|
"neostandard": "^0.12.0",
|
|
26
27
|
"openapi-schema-validator": "^12.1.3",
|
|
27
28
|
"pino-test": "^1.0.1",
|
|
@@ -32,7 +33,7 @@
|
|
|
32
33
|
"typescript": "^5.5.4",
|
|
33
34
|
"why-is-node-running": "2",
|
|
34
35
|
"ws": "^8.16.0",
|
|
35
|
-
"@platformatic/db": "3.
|
|
36
|
+
"@platformatic/db": "3.47.0"
|
|
36
37
|
},
|
|
37
38
|
"dependencies": {
|
|
38
39
|
"@fastify/error": "^4.0.0",
|
|
@@ -63,17 +64,18 @@
|
|
|
63
64
|
"rfdc": "^1.3.1",
|
|
64
65
|
"semgrator": "^0.3.0",
|
|
65
66
|
"undici": "^7.0.0",
|
|
66
|
-
"@platformatic/basic": "3.
|
|
67
|
-
"@platformatic/foundation": "^3.
|
|
68
|
-
"@platformatic/
|
|
69
|
-
"@platformatic/
|
|
70
|
-
"@platformatic/
|
|
67
|
+
"@platformatic/basic": "3.47.0",
|
|
68
|
+
"@platformatic/foundation": "^3.47.0",
|
|
69
|
+
"@platformatic/service": "3.47.0",
|
|
70
|
+
"@platformatic/telemetry": "3.47.0",
|
|
71
|
+
"@platformatic/scalar-theme": "3.47.0"
|
|
71
72
|
},
|
|
72
73
|
"engines": {
|
|
73
74
|
"node": ">=22.19.0"
|
|
74
75
|
},
|
|
75
76
|
"scripts": {
|
|
76
|
-
"test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
|
77
|
+
"test": "npm run test:types && node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
|
|
78
|
+
"test:types": "tstyche",
|
|
77
79
|
"gen-schema": "node lib/schema.js > schema.json",
|
|
78
80
|
"gen-types": "json2ts > config.d.ts < schema.json",
|
|
79
81
|
"build": "npm run gen-schema && npm run gen-types",
|
package/schema.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.
|
|
2
|
+
"$id": "https://schemas.platformatic.dev/@platformatic/gateway/3.47.0.json",
|
|
3
3
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
4
4
|
"title": "Platformatic Gateway Config",
|
|
5
5
|
"type": "object",
|
|
@@ -840,6 +840,9 @@
|
|
|
840
840
|
"rewritePrefix": {
|
|
841
841
|
"type": "string"
|
|
842
842
|
},
|
|
843
|
+
"rewriteLocationHeader": {
|
|
844
|
+
"type": "boolean"
|
|
845
|
+
},
|
|
843
846
|
"hostname": {
|
|
844
847
|
"type": "string"
|
|
845
848
|
},
|