@platformatic/service 1.13.7 → 1.14.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.
@@ -10,7 +10,8 @@
10
10
  body {
11
11
  width: 100%;
12
12
  height: 100vh;
13
- overflow-y: hidden;
13
+ overflow-y: auto;
14
+ overflow-x: hidden;
14
15
  --text-color: #FFFFFF;
15
16
  --bg-color: #001825;
16
17
  --theme-img: url('./images/light_mode.svg')
@@ -76,15 +77,24 @@
76
77
  display: flex;
77
78
  column-gap: 3rem;
78
79
  justify-content: center;
79
- align-items: center;
80
+ align-items: start;
80
81
  margin: 2rem 0;
81
82
  }
82
83
 
84
+ .buttons-list-container {
85
+ display: flex;
86
+ flex-direction: column;
87
+ row-gap: 1rem;
88
+ justify-content: center;
89
+ align-items: start;
90
+ }
91
+
83
92
  .button-link {
84
93
  width: 250px;
85
94
  border: 1px solid var(--text-color);
86
95
  border-radius: 2px;
87
- }
96
+ padding: 2px 6px;
97
+ }
88
98
 
89
99
  button {
90
100
  border-radius: 8px;
@@ -203,7 +213,7 @@
203
213
  <h2 class="text-center">Explore our flexible toolkit for building robust APIs.</h2>
204
214
  <div class="button-container">
205
215
  <a href="https://docs.platformatic.dev" target="_blank" class="button-link">Documentation</a>
206
- <a id="openapi-link" target="_blank" class="button-link">OpenAPI Documentation</a>
216
+ <div class="open-documentation-version buttons-list-container">&nbsp;</div>
207
217
  <a id="graphql-link" target="_blank" class="button-link">GraphiQL</a>
208
218
  </div>
209
219
  </div>
@@ -212,9 +222,6 @@
212
222
  <script>
213
223
  const currentPath = window.location.pathname
214
224
 
215
- const openApiLink = document.getElementById('openapi-link')
216
- openApiLink.href = currentPath + 'documentation/static/index.html'
217
-
218
225
  const graphqlLink = document.getElementById('graphql-link')
219
226
  graphqlLink.href = currentPath + 'graphiql'
220
227
 
@@ -235,6 +242,27 @@
235
242
  document.getElementById('logo').src = 'images/platformatic-logo-dark.svg'
236
243
  }
237
244
  }
245
+
246
+ function join (...paths) {
247
+ return paths.join('/').replace(/\/+/g, '/')
248
+ }
249
+
250
+ fetch('/_platformatic_versions')
251
+ .then(response => response.json())
252
+ .then(versions => {
253
+ const sharedOpenapiHref = join(currentPath, 'documentation/static/index.html')
254
+ const openapiButtons = [
255
+ `<a href="${sharedOpenapiHref}"target="_blank" class="button-link">OpenAPI Documentation</a>`
256
+ ]
257
+
258
+ for (const version of versions) {
259
+ const href = join(currentPath, version.prefix, 'documentation/static/index.html')
260
+ openapiButtons.push(`<a href="${href}"target="_blank" class="button-link">OpenAPI Documentation ${version.name}</a>`)
261
+ }
262
+
263
+ const buttonList = document.getElementsByClassName('open-documentation-version')[0]
264
+ buttonList.innerHTML = openapiButtons.join('')
265
+ })
238
266
  </script>
239
267
  </body>
240
268
  </html>
package/lib/schema.js CHANGED
@@ -3,7 +3,6 @@
3
3
  'use strict'
4
4
 
5
5
  const pkg = require('../package.json')
6
- const version = 'v' + pkg.version
7
6
  const openApiDefs = require('./openapi-schema-defs')
8
7
  const telemetry = require('@platformatic/telemetry').schema
9
8
 
@@ -419,7 +418,6 @@ const watch = {
419
418
  }
420
419
 
421
420
  const plugins = {
422
- $id: '#plugins',
423
421
  type: 'object',
424
422
  properties: {
425
423
  packages: {
@@ -642,16 +640,22 @@ const openapi = {
642
640
  }]
643
641
  }
644
642
 
643
+ const graphqlBase = {
644
+ type: 'object',
645
+ properties: {
646
+ graphiql: {
647
+ type: 'boolean'
648
+ }
649
+ },
650
+ additionalProperties: false
651
+ }
652
+
645
653
  const graphql = {
646
654
  anyOf: [{
647
- type: 'boolean'
655
+ ...graphqlBase,
656
+ additionalProperties: false
648
657
  }, {
649
- type: 'object',
650
- properties: {
651
- graphiql: {
652
- type: 'boolean'
653
- }
654
- }
658
+ type: 'boolean'
655
659
  }]
656
660
  }
657
661
 
@@ -695,8 +699,49 @@ const clients = {
695
699
  }
696
700
  }
697
701
 
702
+ const version = {
703
+ type: 'object',
704
+ properties: {
705
+ version: { type: 'string' },
706
+ openapi: {
707
+ type: 'object',
708
+ properties: {
709
+ prefix: {
710
+ type: 'string'
711
+ },
712
+ path: {
713
+ type: 'string',
714
+ resolvePath: true
715
+ }
716
+ },
717
+ additionalProperties: false
718
+ },
719
+ plugins
720
+ },
721
+ required: ['version'],
722
+ additionalProperties: false
723
+ }
724
+
725
+ const versions = {
726
+ type: 'object',
727
+ properties: {
728
+ dir: {
729
+ type: 'string',
730
+ description: 'The path to the directory containing the versions mappers',
731
+ resolvePath: true,
732
+ default: 'versions'
733
+ },
734
+ configs: {
735
+ type: 'array',
736
+ items: version
737
+ }
738
+ },
739
+ required: ['dir', 'configs'],
740
+ additionalProperties: false
741
+ }
742
+
698
743
  const platformaticServiceSchema = {
699
- $id: `https://platformatic.dev/schemas/${version}/service`,
744
+ $id: `https://platformatic.dev/schemas/v${pkg.version}/service`,
700
745
  title: 'Platformatic Service',
701
746
  type: 'object',
702
747
  properties: {
@@ -715,7 +760,8 @@ const platformaticServiceSchema = {
715
760
  type: 'string'
716
761
  },
717
762
  service,
718
- clients
763
+ clients,
764
+ versions
719
765
  },
720
766
  additionalProperties: false,
721
767
  $defs: openApiDefs
@@ -729,6 +775,7 @@ module.exports.plugins = plugins
729
775
  module.exports.watch = watch
730
776
  module.exports.openApiDefs = openApiDefs
731
777
  module.exports.openApiBase = openApiBase
778
+ module.exports.graphqlBase = graphqlBase
732
779
  module.exports.clients = clients
733
780
 
734
781
  if (require.main === module) {
package/lib/start.js CHANGED
@@ -58,7 +58,9 @@ async function buildServer (options, app) {
58
58
  root.decorate('platformatic', { configManager, config })
59
59
  await root.register(app)
60
60
  if (!root.hasRoute({ url: '/', method: 'GET' })) {
61
- await root.register(require('./root-endpoint'))
61
+ await root.register(require('./root-endpoint'), {
62
+ versions: config.versions
63
+ })
62
64
  }
63
65
 
64
66
  root.decorate('url', {