@platformatic/gateway 3.0.0-alpha.6

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.
Files changed (49) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +13 -0
  3. package/config.d.ts +1000 -0
  4. package/eslint.config.js +12 -0
  5. package/index.d.ts +58 -0
  6. package/index.js +34 -0
  7. package/lib/application.js +186 -0
  8. package/lib/capability.js +89 -0
  9. package/lib/commands/index.js +15 -0
  10. package/lib/commands/openapi-fetch-schemas.js +48 -0
  11. package/lib/errors.js +18 -0
  12. package/lib/gateway-hook.js +66 -0
  13. package/lib/generator.js +127 -0
  14. package/lib/graphql-fetch.js +83 -0
  15. package/lib/graphql-generator.js +33 -0
  16. package/lib/graphql.js +29 -0
  17. package/lib/metrics.js +12 -0
  18. package/lib/not-host-constraints.js +31 -0
  19. package/lib/openapi-composer.js +101 -0
  20. package/lib/openapi-config-schema.js +89 -0
  21. package/lib/openapi-generator.js +215 -0
  22. package/lib/openapi-load-config.js +31 -0
  23. package/lib/openapi-modifier.js +131 -0
  24. package/lib/openapi-scalar.js +22 -0
  25. package/lib/proxy.js +266 -0
  26. package/lib/root.js +75 -0
  27. package/lib/schema.js +258 -0
  28. package/lib/upgrade.js +20 -0
  29. package/lib/utils.js +16 -0
  30. package/lib/versions/2.0.0.js +9 -0
  31. package/lib/versions/3.0.0.js +24 -0
  32. package/package.json +83 -0
  33. package/public/images/dark_mode.svg +3 -0
  34. package/public/images/ellipse.svg +21 -0
  35. package/public/images/external-link.svg +5 -0
  36. package/public/images/favicon.ico +0 -0
  37. package/public/images/graphiql.svg +10 -0
  38. package/public/images/graphql.svg +10 -0
  39. package/public/images/light_mode.svg +11 -0
  40. package/public/images/openapi.svg +13 -0
  41. package/public/images/platformatic-logo-dark.svg +30 -0
  42. package/public/images/platformatic-logo-light.svg +30 -0
  43. package/public/images/reverse-proxy.svg +8 -0
  44. package/public/images/triangle_dark.svg +3 -0
  45. package/public/images/triangle_light.svg +3 -0
  46. package/public/index.html +253 -0
  47. package/public/index.njk +101 -0
  48. package/public/main.css +244 -0
  49. package/schema.json +3779 -0
@@ -0,0 +1,253 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <link rel="icon" type="image/svg+xml" href="./images/favicon.ico" />
6
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800&display=swap" rel="stylesheet">
7
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
8
+ <title>Platformatic Gateway</title>
9
+ <style>
10
+ body {
11
+ width: 100%;
12
+ height: 100vh;
13
+ overflow-y: auto;
14
+ overflow-x: hidden;
15
+ --secondary-color: #FFFFFF;
16
+ --primary-color: #00050B;
17
+ --primary-color-rgb: 0, 5, 11;
18
+ --secondary-color-rgb: 255, 255, 255;
19
+ --theme-img: url('./images/light_mode.svg');
20
+ --triangle-url: url('./images/triangle_light.svg');
21
+ }
22
+
23
+ body.light-theme {
24
+ --secondary-color: #001825;
25
+ --primary-color: #FFFFFF;
26
+ --secondary-color-rgb: 0, 5, 11;
27
+ --primary-color-rgb: 255, 255, 255;
28
+ --theme-img: url('./images/dark_mode.svg');
29
+ --triangle-url: url('./images/triangle_dark.svg');
30
+ }
31
+
32
+ body {
33
+ background: var(--primary-color);
34
+ }
35
+
36
+ :root {
37
+ font-family: Montserrat, Inter, Avenir, Helvetica, Arial, sans-serif;
38
+ font-size: 16px;
39
+ line-height: 24px;
40
+ font-weight: 400;
41
+
42
+ color-scheme: light dark;
43
+ color: inherit;
44
+
45
+ position: relative;
46
+ font-synthesis: none;
47
+ text-rendering: optimizeLegibility;
48
+ -webkit-font-smoothing: antialiased;
49
+ -moz-osx-font-smoothing: grayscale;
50
+ -webkit-text-size-adjust: 100%;
51
+ }
52
+
53
+
54
+ a {
55
+ font-weight: 600;
56
+ color: var(--secondary-color);
57
+ text-decoration: inherit;
58
+ width: 100%;
59
+ text-align: center;
60
+ padding: 4px 0px;
61
+ }
62
+ .button-container a:hover {
63
+ background-color: rgba(var(--secondary-color-rgb), 0.3);
64
+ }
65
+
66
+ .text-opacque {
67
+ opacity: 0.7;
68
+ }
69
+ .text-center {
70
+ text-align: center;
71
+ }
72
+
73
+ .button-container {
74
+ display: flex;
75
+ column-gap: 0.5rem;
76
+ justify-content: center;
77
+ align-items: start;
78
+ margin: 2rem 0;
79
+ }
80
+
81
+ .buttons-list-container {
82
+ display: flex;
83
+ flex-direction: column;
84
+ row-gap: 1rem;
85
+ justify-content: center;
86
+ align-items: start;
87
+ }
88
+
89
+ .button-link {
90
+ width: 233px;
91
+ border: 1px solid var(--secondary-color);
92
+ border-radius: 4px;
93
+ padding: 8px 16px;
94
+ cursor: pointer;
95
+ display: flex;
96
+ align-items: center;
97
+ flex-grow: 1;
98
+ }
99
+
100
+ .button-link > img {
101
+ margin-right: 0.5rem;
102
+ }
103
+ button {
104
+ border-radius: 8px;
105
+ border: 1px solid transparent;
106
+ padding: 0.6em 1.2em;
107
+ font-size: 1em;
108
+ font-weight: 500;
109
+ font-family: inherit;
110
+ background-color: #1a1a1a;
111
+ cursor: pointer;
112
+ transition: border-color 0.25s;
113
+ }
114
+ button:hover {
115
+ border-color: #646cff;
116
+ }
117
+ button:focus,
118
+ button:focus-visible {
119
+ outline: 4px auto -webkit-focus-ring-color;
120
+ }
121
+
122
+ #root {
123
+ width: 100%;
124
+ min-height: inherit;
125
+ height: 100%;
126
+ display: flex;
127
+ position: relative;
128
+ z-index: 20;
129
+ }
130
+
131
+ #content {
132
+ display: flex;
133
+ flex-direction: column;
134
+ align-items: center;
135
+ justify-content: center;
136
+ margin: auto;
137
+ position: relative;
138
+ z-index: 20;
139
+ color: var(--secondary-color);
140
+ }
141
+
142
+ .plt-triangle-container {
143
+ position: absolute;
144
+ top: 0;
145
+ right: 0;
146
+ width: 25%;
147
+ height: 50vH;
148
+ z-index: -1;
149
+ content: '';
150
+ background: var(--triangle-url) repeat;
151
+ opacity: 0.25;
152
+ }
153
+
154
+ .plt-triangle-content-opacque {
155
+ position: absolute;
156
+ height: 100%;
157
+ width: 100%;
158
+ top: 0;
159
+ left: 0;
160
+ content: '';
161
+ background: linear-gradient(to top, rgba(var(--primary-color-rgb), 1), rgba(var(--primary-color-rgb), 0.2) 43%);
162
+ }
163
+
164
+ #button-theme-selector {
165
+ border: none;
166
+ position: absolute;
167
+ top: 2rem;
168
+ right: 3rem;
169
+ width: 40px;
170
+ height: 40px;
171
+ background: var(--theme-img);
172
+ outline: none;
173
+ z-index: 1;
174
+ }
175
+
176
+ .text-desktop-display {
177
+ font-family: Inter;
178
+ font-size: 4rem;
179
+ font-weight: 600;
180
+ line-height: 5rem;
181
+ text-align: center;
182
+ margin: 0;
183
+ }
184
+
185
+ .text-desktop-body-large {
186
+ font-family: Inter;
187
+ font-size: 1.125rem;
188
+ font-weight: 300;
189
+ line-height: 1.688rem;
190
+ text-align: center;
191
+ }
192
+
193
+ a.external-link {
194
+ color: #2588E4;
195
+ font-weight: 400;
196
+ }
197
+ </style>
198
+ </head>
199
+ <body>
200
+ <div id="root">
201
+ <div class="plt-triangle-container"><div class="plt-triangle-content-opacque"></div></div>
202
+ <button id="button-theme-selector" type="button" class="theme-selector" alt="theme selector" onclick="toggleLightMode()"></button>
203
+
204
+ <div id="content">
205
+ <img id="logo" height="256" />
206
+ <p class="text-desktop-display"><span>Welcome to</span><br/><span class="text-main-green">Platformatic Gateway</span></p>
207
+ <div class="button-container">
208
+ <a id="openapi-link" target="_blank" class="button-link">
209
+ <img src="./images/openapi.svg" />
210
+ OpenAPI Documentation
211
+ </a>
212
+ <a id="graphql-link" target="_blank" class="button-link">
213
+ <img src="./images/graphiql.svg" />
214
+ GraphiQL
215
+ </a>
216
+ </div>
217
+ <a href="https://docs.platformatic.dev" target="_blank" class="external-link">Explore our documentation</a>
218
+ </div>
219
+ </div>
220
+
221
+ <script>
222
+ let currentPath = window.location.pathname
223
+
224
+ if (!currentPath.endsWith('/')) {
225
+ currentPath += '/'
226
+ }
227
+
228
+ const openApiLink = document.getElementById('openapi-link')
229
+ openApiLink.href = currentPath + 'documentation'
230
+
231
+ const graphqlLink = document.getElementById('graphql-link')
232
+ graphqlLink.href = currentPath + 'graphiql'
233
+
234
+ const prefersLightScheme = window.matchMedia('(prefers-color-scheme: light)');
235
+ if (prefersLightScheme.matches) {
236
+ document.body.classList.add('light-theme');
237
+ document.getElementById('logo').src = currentPath + 'images/platformatic-logo-light.svg'
238
+ } else {
239
+ document.body.classList.remove('light-theme');
240
+ document.getElementById('logo').src = currentPath + 'images/platformatic-logo-dark.svg'
241
+ }
242
+
243
+ const toggleLightMode = function() {
244
+ document.body.classList.toggle('light-theme');
245
+ if (document.body.classList.contains('light-theme')) {
246
+ document.getElementById('logo').src = currentPath + 'images/platformatic-logo-light.svg'
247
+ } else {
248
+ document.getElementById('logo').src = currentPath + 'images/platformatic-logo-dark.svg'
249
+ }
250
+ }
251
+ </script>
252
+ </body>
253
+ </html>
@@ -0,0 +1,101 @@
1
+ {% set origin = window.location.origin %}
2
+ <!DOCTYPE html>
3
+ <html lang="en">
4
+ <head>
5
+ <meta charset="UTF-8" />
6
+ <link rel="icon" type="image/svg+xml" href="./images/favicon.ico" />
7
+ <link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800&display=swap" rel="stylesheet">
8
+ <link rel="stylesheet" href="./main.css" />
9
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
10
+ <title>Platformatic Gateway</title>
11
+ </head>
12
+ <body>
13
+ <div id="root">
14
+ <div class="plt-triangle-container"><div class="plt-triangle-content-opacque"></div></div>
15
+ <button id="button-theme-selector" type="button" class="theme-selector" alt="theme selector" onclick="toggleLightMode()"></button>
16
+
17
+ <div id="content">
18
+ <img id="logo" height="256" />
19
+ <p class="text-desktop-display"><span>Welcome to</span><br/><span class="text-main-green">Platformatic Gateway</span></p>
20
+ <div class="button-container">
21
+ {% if hasOpenAPIServices %}
22
+ <a id="openapi-link" target="_blank" class="button-link" href="documentation">
23
+ <img src="./images/openapi.svg" />
24
+ OpenAPI Documentation
25
+ </a>
26
+ {% endif %}
27
+ {% if hasGraphQLServices %}
28
+ <a id="graphql-link" target="_blank" class="button-link" href="graphiql">
29
+ <img src="./images/graphiql.svg" />
30
+ GraphiQL
31
+ </a>
32
+ {% endif %}
33
+ </div>
34
+ <a href="https://docs.platformatic.dev" target="_blank" class="plt-doc-link">Explore our documentation</a>
35
+
36
+ <div class="services-container">
37
+ {% for key, value in services %}
38
+ {% if value.services.length %}
39
+ <div class="service-type">
40
+ <div class="service-type-name">
41
+ <img src="{{ value.icon }}" alt="{{ value.title }}">
42
+ {{ value.title }} <span class="count">({{ value.services.length }})</span></div>
43
+ <div class="services-list">
44
+ {% for svc in value.services %}
45
+ <div class="service-details">
46
+ <div>
47
+ <div class="service-title">{{ svc.id }}</div>
48
+ {% if key === 'proxy' %}
49
+ <div class="service-path">{{ svc.proxy.prefix }}</div>
50
+ {% elif key === 'openapi' %}
51
+ <div class="service-path">/{{ svc.id }}</div>
52
+ {% endif %}
53
+ </div>
54
+ {% if key === 'proxy' %}
55
+ <a id="{{ key }}-{{ svc.id }}-external-link" target="_blank">
56
+ <img src="./images/external-link.svg" alt="External Link">
57
+ </a>
58
+ {% endif %}
59
+ </div>
60
+ {% endfor %}
61
+
62
+ </div>
63
+ </div>
64
+ {% endif %}
65
+ {% endfor %}
66
+ </div>
67
+ </div>
68
+ </div>
69
+
70
+ <script>
71
+ let currentPath = window.location.pathname
72
+ const href = window.location.href.replace(/\/$/, '')
73
+ {% for key, value in services %}
74
+ {% if key === 'proxy' %}
75
+ {% if value.services.length %}
76
+ {% for svc in value.services %}
77
+ document.getElementById('{{ key }}-{{ svc.id}}-external-link').href = href + '{{ svc.externalLink }}'
78
+ {% endfor %}
79
+ {% endif %}
80
+ {% endif %}
81
+ {% endfor %}
82
+ const prefersLightScheme = window.matchMedia('(prefers-color-scheme: light)');
83
+ if (prefersLightScheme.matches) {
84
+ document.body.classList.add('light-theme');
85
+ document.getElementById('logo').src = currentPath + 'images/platformatic-logo-light.svg'
86
+ } else {
87
+ document.body.classList.remove('light-theme');
88
+ document.getElementById('logo').src = currentPath + 'images/platformatic-logo-dark.svg'
89
+ }
90
+
91
+ const toggleLightMode = function() {
92
+ document.body.classList.toggle('light-theme');
93
+ if (document.body.classList.contains('light-theme')) {
94
+ document.getElementById('logo').src = currentPath + 'images/platformatic-logo-light.svg'
95
+ } else {
96
+ document.getElementById('logo').src = currentPath + 'images/platformatic-logo-dark.svg'
97
+ }
98
+ }
99
+ </script>
100
+ </body>
101
+ </html>
@@ -0,0 +1,244 @@
1
+ body {
2
+ width: 100%;
3
+ height: 100vh;
4
+ overflow-y: auto;
5
+ overflow-x: hidden;
6
+ --secondary-color: #FFFFFF;
7
+ --primary-color: #00050B;
8
+ --primary-color-rgb: 0, 5, 11;
9
+ --secondary-color-rgb: 255, 255, 255;
10
+ --theme-img: url('./images/light_mode.svg');
11
+ --triangle-url: url('./images/triangle_light.svg');
12
+ --ellipse-url: url('./images/ellipse.svg');
13
+ }
14
+
15
+ body.light-theme {
16
+ --secondary-color: #001825;
17
+ --primary-color: #FFFFFF;
18
+ --secondary-color-rgb: 0, 5, 11;
19
+ --primary-color-rgb: 255, 255, 255;
20
+ --theme-img: url('./images/dark_mode.svg');
21
+ --triangle-url: url('./images/triangle_dark.svg');
22
+ --ellipse-url: url('./images/ellipse.svg');
23
+ }
24
+
25
+ body {
26
+ background: var(--primary-color);
27
+ }
28
+
29
+ :root {
30
+ font-family: Montserrat, Inter, Avenir, Helvetica, Arial, sans-serif;
31
+ font-size: 16px;
32
+ line-height: 24px;
33
+ font-weight: 400;
34
+
35
+ color-scheme: light dark;
36
+ color: inherit;
37
+
38
+ position: relative;
39
+ font-synthesis: none;
40
+ text-rendering: optimizeLegibility;
41
+ -webkit-font-smoothing: antialiased;
42
+ -moz-osx-font-smoothing: grayscale;
43
+ -webkit-text-size-adjust: 100%;
44
+ }
45
+
46
+
47
+ a {
48
+ font-weight: 600;
49
+ color: var(--secondary-color);
50
+ text-decoration: inherit;
51
+ width: 100%;
52
+ text-align: center;
53
+ padding: 4px 0px;
54
+ }
55
+ .button-container a:hover {
56
+ background-color: rgba(var(--secondary-color-rgb), 0.3);
57
+ }
58
+
59
+ .text-opacque {
60
+ opacity: 0.7;
61
+ }
62
+ .text-center {
63
+ text-align: center;
64
+ }
65
+
66
+ .button-container {
67
+ display: flex;
68
+ column-gap: 0.5rem;
69
+ justify-content: center;
70
+ align-items: start;
71
+ margin: 1rem 0;
72
+ }
73
+
74
+ .buttons-list-container {
75
+ display: flex;
76
+ flex-direction: column;
77
+ row-gap: 1rem;
78
+ justify-content: center;
79
+ align-items: start;
80
+ }
81
+
82
+ .button-link {
83
+ width: 233px;
84
+ border: 1px solid var(--secondary-color);
85
+ border-radius: 4px;
86
+ padding: 8px 16px;
87
+ cursor: pointer;
88
+ display: flex;
89
+ align-items: center;
90
+ flex-grow: 1;
91
+ }
92
+
93
+ .button-link > img {
94
+ margin-right: 0.5rem;
95
+ }
96
+ button {
97
+ border-radius: 8px;
98
+ border: 1px solid transparent;
99
+ padding: 0.6em 1.2em;
100
+ font-size: 1em;
101
+ font-weight: 500;
102
+ font-family: inherit;
103
+ background-color: #1a1a1a;
104
+ cursor: pointer;
105
+ transition: border-color 0.25s;
106
+ }
107
+ button:hover {
108
+ border-color: #646cff;
109
+ }
110
+ button:focus,
111
+ button:focus-visible {
112
+ outline: 4px auto -webkit-focus-ring-color;
113
+ }
114
+
115
+ #root {
116
+ width: 100%;
117
+ min-height: inherit;
118
+ height: 100%;
119
+ display: flex;
120
+ position: relative;
121
+ z-index: 20;
122
+ }
123
+
124
+ #content {
125
+ display: flex;
126
+ flex-direction: column;
127
+ align-items: center;
128
+ justify-content: center;
129
+ margin: auto;
130
+ position: relative;
131
+ z-index: 20;
132
+ color: var(--secondary-color);
133
+ }
134
+
135
+ .plt-triangle-container {
136
+ position: absolute;
137
+ top: 0;
138
+ right: 0;
139
+ width: 25%;
140
+ height: 50vH;
141
+ z-index: -1;
142
+ content: '';
143
+ background: var(--triangle-url) repeat;
144
+ opacity: 0.25;
145
+ }
146
+
147
+ .plt-triangle-content-opacque {
148
+ position: absolute;
149
+ height: 100%;
150
+ width: 100%;
151
+ top: 0;
152
+ left: 0;
153
+ content: '';
154
+ background: linear-gradient(to top, rgba(var(--primary-color-rgb), 1), rgba(var(--primary-color-rgb), 0.2) 43%);
155
+ }
156
+
157
+ #button-theme-selector {
158
+ border: none;
159
+ position: absolute;
160
+ top: 2rem;
161
+ right: 3rem;
162
+ width: 40px;
163
+ height: 40px;
164
+ background: var(--theme-img);
165
+ outline: none;
166
+ z-index: 1;
167
+ }
168
+
169
+ .text-desktop-display {
170
+ font-family: Inter;
171
+ font-size: 4rem;
172
+ font-weight: 600;
173
+ line-height: 5rem;
174
+ text-align: center;
175
+ margin: 0;
176
+ }
177
+
178
+ .text-desktop-body-large {
179
+ font-family: Inter;
180
+ font-size: 1.125rem;
181
+ font-weight: 300;
182
+ line-height: 1.688rem;
183
+ text-align: center;
184
+ }
185
+
186
+ a.plt-doc-link {
187
+ color: #2588E4;
188
+ font-weight: 400;
189
+ margin: 0 0 2rem;
190
+ }
191
+
192
+ .services-container {
193
+ display: flex;
194
+ background-color: #090E17;
195
+ padding: 1rem;
196
+ gap: 1rem;
197
+
198
+ }
199
+
200
+ .services-list {
201
+ color: #FFFFFF;
202
+ display: flex;
203
+ flex-direction: column;
204
+ gap: 1rem;
205
+ }
206
+
207
+ .services-list > div{
208
+ height: 3rem;
209
+ }
210
+
211
+ .service-type {
212
+ border-radius: 4px;
213
+ }
214
+ .service-type-name {
215
+ color: #FFFFFF;
216
+ margin-bottom: .5rem ;
217
+ display: flex;
218
+ font-weight: bold;
219
+ }
220
+
221
+ .service-type-name img {
222
+ margin-right: .5rem;
223
+ }
224
+ .service-type-name .count {
225
+ opacity: 0.7;
226
+ font-weight: normal;
227
+ margin-left: 1rem;
228
+ }
229
+ .service-details {
230
+ display: flex;
231
+ justify-content: space-between;
232
+ align-items: flex-start;
233
+ width: 300px;
234
+ background-color: #040607;
235
+ padding: .5rem;
236
+ }
237
+
238
+ .service-details a {
239
+ display: block;
240
+ width: 25px;
241
+ }
242
+ .service-path {
243
+ opacity: 0.7;
244
+ }