@platformatic/service 2.0.0-alpha.2 → 2.0.0-alpha.3

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/lib/schema.js CHANGED
@@ -5,39 +5,7 @@
5
5
  const pkg = require('../package.json')
6
6
  const openApiDefs = require('./openapi-schema-defs')
7
7
  const telemetry = require('@platformatic/telemetry').schema
8
- const { server, cors } = require('@platformatic/utils').schemas
9
-
10
- const watch = {
11
- type: 'object',
12
- properties: {
13
- enabled: {
14
- default: true,
15
- anyOf: [{
16
- type: 'boolean'
17
- }, {
18
- type: 'string'
19
- }]
20
- },
21
- allow: {
22
- type: 'array',
23
- items: {
24
- type: 'string'
25
- },
26
- minItems: 1,
27
- nullable: true,
28
- default: null
29
- },
30
- ignore: {
31
- type: 'array',
32
- items: {
33
- type: 'string'
34
- },
35
- nullable: true,
36
- default: null
37
- }
38
- },
39
- additionalProperties: false
40
- }
8
+ const { server, cors, watch } = require('@platformatic/utils').schemas
41
9
 
42
10
  const plugins = {
43
11
  type: 'object',
@@ -45,123 +13,139 @@ const plugins = {
45
13
  packages: {
46
14
  type: 'array',
47
15
  items: {
48
- anyOf: [{
49
- type: 'string'
50
- }, {
51
- type: 'object',
52
- properties: {
53
- name: {
54
- type: 'string'
16
+ anyOf: [
17
+ {
18
+ type: 'string',
19
+ },
20
+ {
21
+ type: 'object',
22
+ properties: {
23
+ name: {
24
+ type: 'string',
25
+ },
26
+ options: {
27
+ type: 'object',
28
+ additionalProperties: true,
29
+ },
55
30
  },
56
- options: {
57
- type: 'object',
58
- additionalProperties: true
59
- }
31
+ required: ['name'],
60
32
  },
61
- required: ['name']
62
- }]
63
- }
33
+ ],
34
+ },
64
35
  },
65
36
  paths: {
66
37
  type: 'array',
67
38
  items: {
68
- anyOf: [{
69
- type: 'string',
70
- resolvePath: true
71
- }, {
39
+ anyOf: [
40
+ {
41
+ type: 'string',
42
+ resolvePath: true,
43
+ },
44
+ {
45
+ type: 'object',
46
+ properties: {
47
+ path: {
48
+ type: 'string',
49
+ resolvePath: true,
50
+ },
51
+ encapsulate: {
52
+ type: 'boolean',
53
+ default: true,
54
+ },
55
+ maxDepth: {
56
+ type: 'integer',
57
+ },
58
+ autoHooks: {
59
+ type: 'boolean',
60
+ },
61
+ autoHooksPattern: {
62
+ type: 'string',
63
+ },
64
+ cascadeHooks: {
65
+ type: 'boolean',
66
+ },
67
+ overwriteHooks: {
68
+ type: 'boolean',
69
+ },
70
+ routeParams: {
71
+ type: 'boolean',
72
+ },
73
+ forceESM: {
74
+ type: 'boolean',
75
+ },
76
+ ignoreFilter: {
77
+ type: 'string',
78
+ },
79
+ matchFilter: {
80
+ type: 'string',
81
+ },
82
+ ignorePattern: {
83
+ type: 'string',
84
+ },
85
+ scriptPattern: {
86
+ type: 'string',
87
+ },
88
+ indexPattern: {
89
+ type: 'string',
90
+ },
91
+ options: {
92
+ type: 'object',
93
+ additionalProperties: true,
94
+ },
95
+ },
96
+ },
97
+ ],
98
+ },
99
+ },
100
+ typescript: {
101
+ anyOf: [
102
+ {
72
103
  type: 'object',
73
104
  properties: {
74
- path: {
75
- type: 'string',
76
- resolvePath: true
77
- },
78
- encapsulate: {
79
- type: 'boolean',
80
- default: true
81
- },
82
- maxDepth: {
83
- type: 'integer'
84
- },
85
- autoHooks: {
86
- type: 'boolean'
87
- },
88
- autoHooksPattern: {
89
- type: 'string'
90
- },
91
- cascadeHooks: {
92
- type: 'boolean'
93
- },
94
- overwriteHooks: {
95
- type: 'boolean'
96
- },
97
- routeParams: {
98
- type: 'boolean'
105
+ enabled: {
106
+ anyOf: [
107
+ {
108
+ type: 'boolean',
109
+ },
110
+ {
111
+ type: 'string',
112
+ },
113
+ ],
99
114
  },
100
- forceESM: {
101
- type: 'boolean'
102
- },
103
- ignoreFilter: {
104
- type: 'string'
105
- },
106
- matchFilter: {
107
- type: 'string'
108
- },
109
- ignorePattern: {
110
- type: 'string'
115
+ tsConfig: {
116
+ type: 'string',
117
+ resolvePath: true,
111
118
  },
112
- scriptPattern: {
113
- type: 'string'
119
+ outDir: {
120
+ type: 'string',
121
+ resolvePath: true,
114
122
  },
115
- indexPattern: {
116
- type: 'string'
123
+ flags: {
124
+ type: 'array',
125
+ items: {
126
+ type: 'string',
127
+ },
117
128
  },
118
- options: {
119
- type: 'object',
120
- additionalProperties: true
121
- }
122
- }
123
- }]
124
- }
125
- },
126
- typescript: {
127
- anyOf: [{
128
- type: 'object',
129
- properties: {
130
- enabled: {
131
- anyOf: [{
132
- type: 'boolean'
133
- }, {
134
- type: 'string'
135
- }]
136
- },
137
- tsConfig: {
138
- type: 'string',
139
- resolvePath: true
140
- },
141
- outDir: {
142
- type: 'string',
143
- resolvePath: true
144
129
  },
145
- flags: {
146
- type: 'array',
147
- items: {
148
- type: 'string'
149
- }
150
- }
151
- }
152
- }, {
153
- type: 'boolean'
154
- }, {
155
- type: 'string'
156
- }]
157
- }
130
+ },
131
+ {
132
+ type: 'boolean',
133
+ },
134
+ {
135
+ type: 'string',
136
+ },
137
+ ],
138
+ },
158
139
  },
159
140
  additionalProperties: false,
160
- anyOf: [{
161
- required: ['paths']
162
- }, {
163
- required: ['packages']
164
- }]
141
+ anyOf: [
142
+ {
143
+ required: ['paths'],
144
+ },
145
+ {
146
+ required: ['packages'],
147
+ },
148
+ ],
165
149
  }
166
150
 
167
151
  const metrics = {
@@ -171,141 +155,143 @@ const metrics = {
171
155
  type: 'object',
172
156
  properties: {
173
157
  port: {
174
- anyOf: [
175
- { type: 'integer' },
176
- { type: 'string' }
177
- ]
158
+ anyOf: [{ type: 'integer' }, { type: 'string' }],
178
159
  },
179
160
  hostname: { type: 'string' },
180
161
  endpoint: { type: 'string' },
181
162
  server: {
182
163
  type: 'string',
183
- enum: ['own', 'parent', 'hide']
164
+ enum: ['own', 'parent', 'hide'],
184
165
  },
185
166
  defaultMetrics: {
186
167
  type: 'object',
187
168
  properties: {
188
- enabled: { type: 'boolean' }
169
+ enabled: { type: 'boolean' },
189
170
  },
190
171
  required: ['enabled'],
191
- additionalProperties: false
172
+ additionalProperties: false,
192
173
  },
193
- prefix: { type: 'string' },
194
174
  auth: {
195
175
  type: 'object',
196
176
  properties: {
197
177
  username: { type: 'string' },
198
- password: { type: 'string' }
178
+ password: { type: 'string' },
199
179
  },
200
180
  additionalProperties: false,
201
- required: ['username', 'password']
181
+ required: ['username', 'password'],
202
182
  },
203
183
  labels: {
204
184
  type: 'object',
205
- additionalProperties: { type: 'string' }
206
- }
185
+ additionalProperties: { type: 'string' },
186
+ },
207
187
  },
208
- additionalProperties: false
209
- }
210
- ]
188
+ additionalProperties: false,
189
+ },
190
+ ],
211
191
  }
212
192
 
213
193
  const openApiBase = {
214
194
  type: 'object',
215
195
  properties: {
216
196
  info: {
217
- $ref: '#/$defs/info'
197
+ $ref: '#/$defs/info',
218
198
  },
219
199
  jsonSchemaDialect: {
220
200
  type: 'string',
221
201
 
222
- default: 'https://spec.openapis.org/oas/3.1/dialect/base'
202
+ default: 'https://spec.openapis.org/oas/3.1/dialect/base',
223
203
  },
224
204
  servers: {
225
205
  type: 'array',
226
206
  items: {
227
- $ref: '#/$defs/server'
207
+ $ref: '#/$defs/server',
228
208
  },
229
209
  default: [
230
210
  {
231
- url: '/'
232
- }
233
- ]
211
+ url: '/',
212
+ },
213
+ ],
234
214
  },
235
215
  paths: {
236
- $ref: '#/$defs/paths'
216
+ $ref: '#/$defs/paths',
237
217
  },
238
218
  webhooks: {
239
219
  type: 'object',
240
220
  additionalProperties: {
241
- $ref: '#/$defs/path-item-or-reference'
242
- }
221
+ $ref: '#/$defs/path-item-or-reference',
222
+ },
243
223
  },
244
224
  components: {
245
- $ref: '#/$defs/components'
225
+ $ref: '#/$defs/components',
246
226
  },
247
227
  security: {
248
228
  type: 'array',
249
229
  items: {
250
- $ref: '#/$defs/security-requirement'
251
- }
230
+ $ref: '#/$defs/security-requirement',
231
+ },
252
232
  },
253
233
  tags: {
254
234
  type: 'array',
255
235
  items: {
256
- $ref: '#/$defs/tag'
257
- }
236
+ $ref: '#/$defs/tag',
237
+ },
258
238
  },
259
239
  externalDocs: {
260
- $ref: '#/$defs/external-documentation'
240
+ $ref: '#/$defs/external-documentation',
261
241
  },
262
242
  swaggerPrefix: {
263
243
  type: 'string',
264
- description: 'Base URL for the OpenAPI Swagger Documentation'
244
+ description: 'Base URL for the OpenAPI Swagger Documentation',
265
245
  },
266
246
  path: {
267
247
  type: 'string',
268
248
  description: 'Path to an OpenAPI spec file',
269
- resolvePath: true
270
- }
271
- }
249
+ resolvePath: true,
250
+ },
251
+ },
272
252
  }
273
253
 
274
254
  const openapi = {
275
- anyOf: [{
276
- ...openApiBase,
277
- additionalProperties: false
278
- }, {
279
- type: 'boolean'
280
- }]
255
+ anyOf: [
256
+ {
257
+ ...openApiBase,
258
+ additionalProperties: false,
259
+ },
260
+ {
261
+ type: 'boolean',
262
+ },
263
+ ],
281
264
  }
282
265
 
283
266
  const graphqlBase = {
284
267
  type: 'object',
285
268
  properties: {
286
269
  graphiql: {
287
- type: 'boolean'
288
- }
270
+ type: 'boolean',
271
+ },
289
272
  },
290
- additionalProperties: false
273
+ additionalProperties: false,
291
274
  }
292
275
 
293
276
  const graphql = {
294
- anyOf: [{
295
- ...graphqlBase,
296
- additionalProperties: false
297
- }, {
298
- type: 'boolean'
299
- }]
277
+ anyOf: [
278
+ {
279
+ ...graphqlBase,
280
+ additionalProperties: false,
281
+ },
282
+ {
283
+ type: 'boolean',
284
+ },
285
+ ],
300
286
  }
301
287
 
302
288
  const service = {
303
289
  type: 'object',
304
290
  properties: {
305
291
  openapi,
306
- graphql
292
+ graphql,
307
293
  },
308
- additionalProperties: false
294
+ additionalProperties: false,
309
295
  }
310
296
 
311
297
  const clients = {
@@ -314,36 +300,36 @@ const clients = {
314
300
  type: 'object',
315
301
  properties: {
316
302
  serviceId: {
317
- type: 'string'
303
+ type: 'string',
318
304
  },
319
305
  name: {
320
- type: 'string'
306
+ type: 'string',
321
307
  },
322
308
  type: {
323
309
  type: 'string',
324
- enum: ['openapi', 'graphql']
310
+ enum: ['openapi', 'graphql'],
325
311
  },
326
312
  path: {
327
313
  type: 'string',
328
- resolvePath: true
314
+ resolvePath: true,
329
315
  },
330
316
  schema: {
331
317
  type: 'string',
332
- resolvePath: true
318
+ resolvePath: true,
333
319
  },
334
320
  url: {
335
- type: 'string'
321
+ type: 'string',
336
322
  },
337
323
  fullResponse: { type: 'boolean' },
338
324
  fullRequest: { type: 'boolean' },
339
- validateResponse: { type: 'boolean' }
325
+ validateResponse: { type: 'boolean' },
340
326
  },
341
- additionalProperties: false
342
- }
327
+ additionalProperties: false,
328
+ },
343
329
  }
344
330
 
345
331
  const platformaticServiceSchema = {
346
- $id: `https://platformatic.dev/schemas/v${pkg.version}/service`,
332
+ $id: `https://schemas.platformatic.dev/@platformatic/service/${pkg.version}.json`,
347
333
  version: pkg.version,
348
334
  title: 'Platformatic Service',
349
335
  type: 'object',
@@ -353,20 +339,27 @@ const platformaticServiceSchema = {
353
339
  metrics,
354
340
  telemetry,
355
341
  watch: {
356
- anyOf: [watch, {
357
- type: 'boolean'
358
- }, {
359
- type: 'string'
360
- }]
342
+ anyOf: [
343
+ watch,
344
+ {
345
+ type: 'boolean',
346
+ },
347
+ {
348
+ type: 'string',
349
+ },
350
+ ],
361
351
  },
362
352
  $schema: {
363
- type: 'string'
353
+ type: 'string',
354
+ },
355
+ module: {
356
+ type: 'string',
364
357
  },
365
358
  service,
366
- clients
359
+ clients,
367
360
  },
368
361
  additionalProperties: false,
369
- $defs: openApiDefs
362
+ $defs: openApiDefs,
370
363
  }
371
364
 
372
365
  /*
@@ -375,52 +368,52 @@ const platformaticServiceSchema = {
375
368
  */
376
369
  Object.defineProperty(platformaticServiceSchema, 'schema', {
377
370
  enumerable: false,
378
- value: platformaticServiceSchema
371
+ value: platformaticServiceSchema,
379
372
  })
380
373
 
381
374
  Object.defineProperty(platformaticServiceSchema, 'server', {
382
375
  enumerable: false,
383
- value: server
376
+ value: server,
384
377
  })
385
378
 
386
379
  Object.defineProperty(platformaticServiceSchema, 'cors', {
387
380
  enumerable: false,
388
- value: cors
381
+ value: cors,
389
382
  })
390
383
 
391
384
  Object.defineProperty(platformaticServiceSchema, 'metrics', {
392
385
  enumerable: false,
393
- value: metrics
386
+ value: metrics,
394
387
  })
395
388
 
396
389
  Object.defineProperty(platformaticServiceSchema, 'plugins', {
397
390
  enumerable: false,
398
- value: plugins
391
+ value: plugins,
399
392
  })
400
393
 
401
394
  Object.defineProperty(platformaticServiceSchema, 'watch', {
402
395
  enumerable: false,
403
- value: watch
396
+ value: watch,
404
397
  })
405
398
 
406
399
  Object.defineProperty(platformaticServiceSchema, 'openApiDefs', {
407
400
  enumerable: false,
408
- value: openApiDefs
401
+ value: openApiDefs,
409
402
  })
410
403
 
411
404
  Object.defineProperty(platformaticServiceSchema, 'openApiBase', {
412
405
  enumerable: false,
413
- value: openApiBase
406
+ value: openApiBase,
414
407
  })
415
408
 
416
409
  Object.defineProperty(platformaticServiceSchema, 'graphqlBase', {
417
410
  enumerable: false,
418
- value: graphqlBase
411
+ value: graphqlBase,
419
412
  })
420
413
 
421
414
  Object.defineProperty(platformaticServiceSchema, 'clients', {
422
415
  enumerable: false,
423
- value: clients
416
+ value: clients,
424
417
  })
425
418
 
426
419
  /* end */