@platformatic/service 3.0.0-alpha.5 → 3.0.0-alpha.8

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/LICENSE CHANGED
@@ -136,7 +136,7 @@
136
136
  with Licensor regarding such Contributions.
137
137
 
138
138
  6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
139
+ names, trademarks, application marks, or product names of the Licensor,
140
140
  except as required for reasonable and customary use in describing the
141
141
  origin of the Work and reproducing the content of the NOTICE file.
142
142
 
package/config.d.ts CHANGED
@@ -167,11 +167,11 @@ export interface PlatformaticServiceConfig {
167
167
  telemetry?: {
168
168
  enabled?: boolean | string;
169
169
  /**
170
- * The name of the service. Defaults to the folder name if not specified.
170
+ * The name of the application. Defaults to the folder name if not specified.
171
171
  */
172
- serviceName: string;
172
+ applicationName: string;
173
173
  /**
174
- * The version of the service (optional)
174
+ * The version of the application (optional)
175
175
  */
176
176
  version?: string;
177
177
  /**
@@ -310,6 +310,9 @@ export interface PlatformaticServiceConfig {
310
310
  runtime?: {
311
311
  preload?: string | string[];
312
312
  basePath?: string;
313
+ services?: {
314
+ [k: string]: unknown;
315
+ }[];
313
316
  workers?: number | string;
314
317
  logger?: {
315
318
  level: (
@@ -397,7 +400,7 @@ export interface PlatformaticServiceConfig {
397
400
  restartOnError?: boolean | number;
398
401
  gracefulShutdown?: {
399
402
  runtime: number | string;
400
- service: number | string;
403
+ application: number | string;
401
404
  };
402
405
  health?: {
403
406
  enabled?: boolean | string;
@@ -516,11 +519,11 @@ export interface PlatformaticServiceConfig {
516
519
  telemetry?: {
517
520
  enabled?: boolean | string;
518
521
  /**
519
- * The name of the service. Defaults to the folder name if not specified.
522
+ * The name of the application. Defaults to the folder name if not specified.
520
523
  */
521
- serviceName: string;
524
+ applicationName: string;
522
525
  /**
523
- * The version of the service (optional)
526
+ * The version of the application (optional)
524
527
  */
525
528
  version?: string;
526
529
  /**
@@ -596,7 +599,7 @@ export interface PlatformaticServiceConfig {
596
599
  watchDisabled?: boolean;
597
600
  [k: string]: unknown;
598
601
  };
599
- serviceTimeout?: number | string;
602
+ applicationTimeout?: number | string;
600
603
  messagingTimeout?: number | string;
601
604
  env?: {
602
605
  [k: string]: string;
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { BaseContext, BaseOptions, BaseStackable } from '@platformatic/basic'
1
+ import { BaseCapability, BaseContext, BaseOptions } from '@platformatic/basic'
2
2
  import { Configuration, ConfigurationOptions } from '@platformatic/foundation'
3
3
  import { BaseGenerator } from '@platformatic/generators'
4
4
  import { JSONSchemaType } from 'ajv'
@@ -34,11 +34,11 @@ export declare function create (
34
34
  root: string | PlatformaticServiceConfig,
35
35
  source?: string | PlatformaticServiceConfig,
36
36
  context?: ConfigurationOptions
37
- ): Promise<ServiceStackable>
37
+ ): Promise<ServiceCapability>
38
38
 
39
39
  export declare const skipTelemetryHooks: boolean
40
40
 
41
- export declare function platformaticService (app: FastifyInstance, stackable: ServiceStackable): Promise<void>
41
+ export declare function platformaticService (app: FastifyInstance, capability: ServiceCapability): Promise<void>
42
42
 
43
43
  export declare class Generator extends BaseGenerator.BaseGenerator {}
44
44
  export declare function applyTestHelperCustomizations (
@@ -59,12 +59,12 @@ export declare const schemaComponents: {
59
59
  proxy: JSONSchemaType<object>
60
60
  graphqlBase: JSONSchemaType<object>
61
61
  graphql: JSONSchemaType<object>
62
- service: JSONSchemaType<object>
62
+ application: JSONSchemaType<object>
63
63
  }
64
64
 
65
65
  export declare const version: string
66
66
 
67
- export declare class ServiceStackable<Config = PlatformaticServiceConfig> extends BaseStackable<
67
+ export declare class ServiceCapability<Config = PlatformaticServiceConfig> extends BaseCapability<
68
68
  Config,
69
69
  BaseOptions<ServiceContext>
70
70
  > {
package/index.js CHANGED
@@ -2,8 +2,8 @@ import { transform as basicTransform, resolve, validationOptions } from '@platfo
2
2
  import { kMetadata, loadConfiguration as utilsLoadConfiguration } from '@platformatic/foundation'
3
3
  import { readFile } from 'node:fs/promises'
4
4
  import { join } from 'node:path'
5
+ import { ServiceCapability } from './lib/capability.js'
5
6
  import { schema } from './lib/schema.js'
6
- import { ServiceStackable } from './lib/stackable.js'
7
7
  import { upgrade } from './lib/upgrade.js'
8
8
  import { isDocker } from './lib/utils.js'
9
9
 
@@ -52,12 +52,12 @@ export async function loadConfiguration (configOrRoot, sourceOrConfig, context)
52
52
 
53
53
  export async function create (configOrRoot, sourceOrConfig, context) {
54
54
  const config = await loadConfiguration(configOrRoot, sourceOrConfig, context)
55
- return new ServiceStackable(config[kMetadata].root, config, context)
55
+ return new ServiceCapability(config[kMetadata].root, config, context)
56
56
  }
57
57
 
58
58
  export const skipTelemetryHooks = true
59
59
 
60
60
  export { platformaticService } from './lib/application.js'
61
+ export { ServiceCapability } from './lib/capability.js'
61
62
  export { applyTestHelperCustomizations, Generator } from './lib/generator.js'
62
63
  export { packageJson, schema, schemaComponents, version } from './lib/schema.js'
63
- export { ServiceStackable } from './lib/stackable.js'
@@ -5,8 +5,8 @@ import { setupHealthCheck } from './plugins/health-check.js'
5
5
  import { setupOpenAPI } from './plugins/openapi.js'
6
6
  import { loadPlugins } from './plugins/plugins.js'
7
7
 
8
- export async function platformaticService (app, stackable) {
9
- const config = await stackable.getConfig()
8
+ export async function platformaticService (app, capability) {
9
+ const config = await capability.getConfig()
10
10
 
11
11
  const serviceConfig = config.service || {}
12
12
 
@@ -20,7 +20,7 @@ export async function platformaticService (app, stackable) {
20
20
  }
21
21
 
22
22
  if (config.plugins) {
23
- await app.register(loadPlugins, stackable.context)
23
+ await app.register(loadPlugins, capability.context)
24
24
  }
25
25
 
26
26
  if (isKeyEnabled('cors', config.server)) {
@@ -1,4 +1,4 @@
1
- import { BaseStackable, cleanBasePath, ensureTrailingSlash, getServerUrl } from '@platformatic/basic'
1
+ import { BaseCapability, cleanBasePath, ensureTrailingSlash, getServerUrl } from '@platformatic/basic'
2
2
  import { buildPinoFormatters, buildPinoTimestamp, deepmerge, features, isKeyEnabled } from '@platformatic/foundation'
3
3
  import { telemetry } from '@platformatic/telemetry'
4
4
  import fastify from 'fastify'
@@ -11,7 +11,7 @@ import { setupRoot } from './plugins/root.js'
11
11
  import { version } from './schema.js'
12
12
  import { sanitizeHTTPSArgument } from './utils.js'
13
13
 
14
- export class ServiceStackable extends BaseStackable {
14
+ export class ServiceCapability extends BaseCapability {
15
15
  #app
16
16
  #basePath
17
17
 
@@ -28,7 +28,7 @@ export class ServiceStackable extends BaseStackable {
28
28
  }
29
29
 
30
30
  const config = this.config
31
- this.#basePath = ensureTrailingSlash(cleanBasePath(config.basePath ?? this.serviceId))
31
+ this.#basePath = ensureTrailingSlash(cleanBasePath(config.basePath ?? this.applicationId))
32
32
 
33
33
  // Create the application
34
34
  this.#app = fastify({
@@ -84,7 +84,8 @@ export class ServiceStackable extends BaseStackable {
84
84
  }
85
85
 
86
86
  async stop () {
87
- return this.#app?.close()
87
+ await super.stop()
88
+ await this.#app?.close()
88
89
  }
89
90
 
90
91
  async inject (injectParams, onInject) {
@@ -139,7 +140,7 @@ export class ServiceStackable extends BaseStackable {
139
140
 
140
141
  getMeta () {
141
142
  return {
142
- composer: {
143
+ gateway: {
143
144
  tcp: typeof this.url !== 'undefined',
144
145
  url: this.url,
145
146
  prefix: this.basePath ?? this.#basePath,
@@ -234,8 +235,8 @@ export class ServiceStackable extends BaseStackable {
234
235
  logLevel: pinoOptions.level
235
236
  })
236
237
 
237
- if (this.context?.serviceId) {
238
- pinoOptions.name = this.context.serviceId
238
+ if (this.context?.applicationId) {
239
+ pinoOptions.name = this.context.applicationId
239
240
  }
240
241
 
241
242
  if (this.context?.worker?.count > 1 && this.loggerConfig?.base !== null) {
@@ -51,7 +51,6 @@ function stringPatternToRegExp (stringPattern) {
51
51
  }
52
52
 
53
53
  async function sandboxWrapperPlugin (app, options) {
54
- // fake require next to the configManager dirname
55
54
  const require = createRequire(resolve(app.platformatic.config[kMetadata].root, 'noop.js'))
56
55
 
57
56
  for (const plugin of options.packages || []) {
package/lib/schema.js CHANGED
@@ -1178,7 +1178,7 @@ export const openapi = {
1178
1178
  ]
1179
1179
  }
1180
1180
 
1181
- // same as composer/proxy
1181
+ // same as gateway/proxy
1182
1182
  export const proxy = {
1183
1183
  anyOf: [
1184
1184
  { type: 'boolean', const: false },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@platformatic/service",
3
- "version": "3.0.0-alpha.5",
3
+ "version": "3.0.0-alpha.8",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -19,7 +19,7 @@
19
19
  "@fastify/aws-lambda": "^5.0.0",
20
20
  "@fastify/compress": "^8.0.0",
21
21
  "bindings": "^1.5.0",
22
- "borp": "^0.20.0",
22
+ "cleaner-spec-reporter": "^0.5.0",
23
23
  "eslint": "9",
24
24
  "json-schema-to-typescript": "^15.0.0",
25
25
  "neostandard": "^0.12.0",
@@ -42,7 +42,7 @@
42
42
  "@fastify/static": "^8.0.0",
43
43
  "@fastify/swagger": "^9.0.0",
44
44
  "@fastify/under-pressure": "^9.0.0",
45
- "@scalar/fastify-api-reference": "1.33.0",
45
+ "@scalar/fastify-api-reference": "1.34.4",
46
46
  "@types/node": "^22.10.6",
47
47
  "@types/ws": "^8.5.10",
48
48
  "ajv": "^8.12.0",
@@ -67,22 +67,21 @@
67
67
  "rfdc": "^1.3.1",
68
68
  "semgrator": "^0.3.0",
69
69
  "undici": "^7.0.0",
70
- "@platformatic/basic": "3.0.0-alpha.5",
71
- "@platformatic/metrics": "3.0.0-alpha.5",
72
- "@platformatic/generators": "3.0.0-alpha.5",
73
- "@platformatic/scalar-theme": "3.0.0-alpha.5",
74
- "@platformatic/foundation": "3.0.0-alpha.5",
75
- "@platformatic/telemetry": "3.0.0-alpha.5"
70
+ "@platformatic/basic": "3.0.0-alpha.8",
71
+ "@platformatic/scalar-theme": "3.0.0-alpha.8",
72
+ "@platformatic/foundation": "3.0.0-alpha.8",
73
+ "@platformatic/generators": "3.0.0-alpha.8",
74
+ "@platformatic/telemetry": "3.0.0-alpha.8",
75
+ "@platformatic/metrics": "3.0.0-alpha.8"
76
76
  },
77
77
  "engines": {
78
78
  "node": ">=22.18.0"
79
79
  },
80
80
  "scripts": {
81
- "test": "pnpm run lint && borp --concurrency=1 --timeout 1200000 --no-typescript",
82
- "coverage": "pnpm run lint && borp -C -X test -X test/fixtures --concurrency=1 --timeout 1200000 --no-typescript",
81
+ "test": "node --test --test-reporter=cleaner-spec-reporter --test-concurrency=1 --test-timeout=2000000 test/*.test.js test/**/*.test.js",
83
82
  "gen-schema": "node lib/schema.js > schema.json",
84
83
  "gen-types": "json2ts > config.d.ts < schema.json",
85
- "build": "pnpm run gen-schema && pnpm run gen-types",
84
+ "build": "npm run gen-schema && npm run gen-types",
86
85
  "lint": "eslint"
87
86
  }
88
87
  }
package/schema.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/service/3.0.0-alpha.5.json",
3
- "version": "3.0.0-alpha.5",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/service/3.0.0-alpha.8.json",
3
+ "version": "3.0.0-alpha.8",
4
4
  "title": "Platformatic Service Config",
5
5
  "type": "object",
6
6
  "properties": {
@@ -658,13 +658,13 @@
658
658
  }
659
659
  ]
660
660
  },
661
- "serviceName": {
661
+ "applicationName": {
662
662
  "type": "string",
663
- "description": "The name of the service. Defaults to the folder name if not specified."
663
+ "description": "The name of the application. Defaults to the folder name if not specified."
664
664
  },
665
665
  "version": {
666
666
  "type": "string",
667
- "description": "The version of the service (optional)"
667
+ "description": "The version of the application (optional)"
668
668
  },
669
669
  "skip": {
670
670
  "type": "array",
@@ -771,7 +771,7 @@
771
771
  }
772
772
  },
773
773
  "required": [
774
- "serviceName"
774
+ "applicationName"
775
775
  ],
776
776
  "additionalProperties": false
777
777
  },
@@ -1014,6 +1014,242 @@
1014
1014
  "basePath": {
1015
1015
  "type": "string"
1016
1016
  },
1017
+ "services": {
1018
+ "type": "array",
1019
+ "items": {
1020
+ "type": "object",
1021
+ "anyOf": [
1022
+ {
1023
+ "required": [
1024
+ "id",
1025
+ "path"
1026
+ ]
1027
+ },
1028
+ {
1029
+ "required": [
1030
+ "id",
1031
+ "url"
1032
+ ]
1033
+ }
1034
+ ],
1035
+ "properties": {
1036
+ "id": {
1037
+ "type": "string"
1038
+ },
1039
+ "path": {
1040
+ "type": "string",
1041
+ "allowEmptyPaths": true,
1042
+ "resolvePath": true
1043
+ },
1044
+ "config": {
1045
+ "type": "string"
1046
+ },
1047
+ "url": {
1048
+ "type": "string"
1049
+ },
1050
+ "gitBranch": {
1051
+ "type": "string",
1052
+ "default": "main"
1053
+ },
1054
+ "useHttp": {
1055
+ "type": "boolean"
1056
+ },
1057
+ "workers": {
1058
+ "anyOf": [
1059
+ {
1060
+ "type": "number",
1061
+ "minimum": 1
1062
+ },
1063
+ {
1064
+ "type": "string"
1065
+ }
1066
+ ]
1067
+ },
1068
+ "health": {
1069
+ "type": "object",
1070
+ "default": {},
1071
+ "properties": {
1072
+ "enabled": {
1073
+ "anyOf": [
1074
+ {
1075
+ "type": "boolean"
1076
+ },
1077
+ {
1078
+ "type": "string"
1079
+ }
1080
+ ]
1081
+ },
1082
+ "interval": {
1083
+ "anyOf": [
1084
+ {
1085
+ "type": "number",
1086
+ "minimum": 0
1087
+ },
1088
+ {
1089
+ "type": "string"
1090
+ }
1091
+ ]
1092
+ },
1093
+ "gracePeriod": {
1094
+ "anyOf": [
1095
+ {
1096
+ "type": "number",
1097
+ "minimum": 0
1098
+ },
1099
+ {
1100
+ "type": "string"
1101
+ }
1102
+ ]
1103
+ },
1104
+ "maxUnhealthyChecks": {
1105
+ "anyOf": [
1106
+ {
1107
+ "type": "number",
1108
+ "minimum": 1
1109
+ },
1110
+ {
1111
+ "type": "string"
1112
+ }
1113
+ ]
1114
+ },
1115
+ "maxELU": {
1116
+ "anyOf": [
1117
+ {
1118
+ "type": "number",
1119
+ "minimum": 0,
1120
+ "maximum": 1
1121
+ },
1122
+ {
1123
+ "type": "string"
1124
+ }
1125
+ ]
1126
+ },
1127
+ "maxHeapUsed": {
1128
+ "anyOf": [
1129
+ {
1130
+ "type": "number",
1131
+ "minimum": 0,
1132
+ "maximum": 1
1133
+ },
1134
+ {
1135
+ "type": "string"
1136
+ }
1137
+ ]
1138
+ },
1139
+ "maxHeapTotal": {
1140
+ "anyOf": [
1141
+ {
1142
+ "type": "number",
1143
+ "minimum": 0
1144
+ },
1145
+ {
1146
+ "type": "string"
1147
+ }
1148
+ ]
1149
+ },
1150
+ "maxYoungGeneration": {
1151
+ "anyOf": [
1152
+ {
1153
+ "type": "number",
1154
+ "minimum": 0
1155
+ },
1156
+ {
1157
+ "type": "string"
1158
+ }
1159
+ ]
1160
+ }
1161
+ },
1162
+ "additionalProperties": false
1163
+ },
1164
+ "dependencies": {
1165
+ "type": "array",
1166
+ "items": {
1167
+ "type": "string"
1168
+ },
1169
+ "default": []
1170
+ },
1171
+ "arguments": {
1172
+ "type": "array",
1173
+ "items": {
1174
+ "type": "string"
1175
+ }
1176
+ },
1177
+ "env": {
1178
+ "type": "object",
1179
+ "additionalProperties": {
1180
+ "type": "string"
1181
+ }
1182
+ },
1183
+ "envfile": {
1184
+ "type": "string"
1185
+ },
1186
+ "sourceMaps": {
1187
+ "type": "boolean",
1188
+ "default": false
1189
+ },
1190
+ "packageManager": {
1191
+ "type": "string",
1192
+ "enum": [
1193
+ "npm",
1194
+ "pnpm",
1195
+ "yarn"
1196
+ ]
1197
+ },
1198
+ "preload": {
1199
+ "anyOf": [
1200
+ {
1201
+ "type": "string",
1202
+ "resolvePath": true
1203
+ },
1204
+ {
1205
+ "type": "array",
1206
+ "items": {
1207
+ "type": "string",
1208
+ "resolvePath": true
1209
+ }
1210
+ }
1211
+ ]
1212
+ },
1213
+ "nodeOptions": {
1214
+ "type": "string"
1215
+ },
1216
+ "telemetry": {
1217
+ "type": "object",
1218
+ "properties": {
1219
+ "instrumentations": {
1220
+ "type": "array",
1221
+ "description": "An array of instrumentations loaded if telemetry is enabled",
1222
+ "items": {
1223
+ "oneOf": [
1224
+ {
1225
+ "type": "string"
1226
+ },
1227
+ {
1228
+ "type": "object",
1229
+ "properties": {
1230
+ "package": {
1231
+ "type": "string"
1232
+ },
1233
+ "exportName": {
1234
+ "type": "string"
1235
+ },
1236
+ "options": {
1237
+ "type": "object",
1238
+ "additionalProperties": true
1239
+ }
1240
+ },
1241
+ "required": [
1242
+ "package"
1243
+ ]
1244
+ }
1245
+ ]
1246
+ }
1247
+ }
1248
+ }
1249
+ }
1250
+ }
1251
+ }
1252
+ },
1017
1253
  "workers": {
1018
1254
  "anyOf": [
1019
1255
  {
@@ -1328,7 +1564,7 @@
1328
1564
  ],
1329
1565
  "default": 10000
1330
1566
  },
1331
- "service": {
1567
+ "application": {
1332
1568
  "anyOf": [
1333
1569
  {
1334
1570
  "type": "number",
@@ -1344,7 +1580,7 @@
1344
1580
  "default": {},
1345
1581
  "required": [
1346
1582
  "runtime",
1347
- "service"
1583
+ "application"
1348
1584
  ],
1349
1585
  "additionalProperties": false
1350
1586
  },
@@ -1775,13 +2011,13 @@
1775
2011
  }
1776
2012
  ]
1777
2013
  },
1778
- "serviceName": {
2014
+ "applicationName": {
1779
2015
  "type": "string",
1780
- "description": "The name of the service. Defaults to the folder name if not specified."
2016
+ "description": "The name of the application. Defaults to the folder name if not specified."
1781
2017
  },
1782
2018
  "version": {
1783
2019
  "type": "string",
1784
- "description": "The version of the service (optional)"
2020
+ "description": "The version of the application (optional)"
1785
2021
  },
1786
2022
  "skip": {
1787
2023
  "type": "array",
@@ -1888,7 +2124,7 @@
1888
2124
  }
1889
2125
  },
1890
2126
  "required": [
1891
- "serviceName"
2127
+ "applicationName"
1892
2128
  ],
1893
2129
  "additionalProperties": false
1894
2130
  },
@@ -1909,7 +2145,7 @@
1909
2145
  }
1910
2146
  }
1911
2147
  },
1912
- "serviceTimeout": {
2148
+ "applicationTimeout": {
1913
2149
  "anyOf": [
1914
2150
  {
1915
2151
  "type": "number",