@platformatic/service 3.0.0-alpha.4 → 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.
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({
@@ -139,7 +139,7 @@ export class ServiceStackable extends BaseStackable {
139
139
 
140
140
  getMeta () {
141
141
  return {
142
- composer: {
142
+ gateway: {
143
143
  tcp: typeof this.url !== 'undefined',
144
144
  url: this.url,
145
145
  prefix: this.basePath ?? this.#basePath,
@@ -234,8 +234,8 @@ export class ServiceStackable extends BaseStackable {
234
234
  logLevel: pinoOptions.level
235
235
  })
236
236
 
237
- if (this.context?.serviceId) {
238
- pinoOptions.name = this.context.serviceId
237
+ if (this.context?.applicationId) {
238
+ pinoOptions.name = this.context.applicationId
239
239
  }
240
240
 
241
241
  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.4",
3
+ "version": "3.0.0-alpha.6",
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",
@@ -67,19 +67,18 @@
67
67
  "rfdc": "^1.3.1",
68
68
  "semgrator": "^0.3.0",
69
69
  "undici": "^7.0.0",
70
- "@platformatic/metrics": "3.0.0-alpha.4",
71
- "@platformatic/generators": "3.0.0-alpha.4",
72
- "@platformatic/telemetry": "3.0.0-alpha.4",
73
- "@platformatic/foundation": "3.0.0-alpha.4",
74
- "@platformatic/basic": "3.0.0-alpha.4",
75
- "@platformatic/scalar-theme": "3.0.0-alpha.4"
70
+ "@platformatic/basic": "3.0.0-alpha.6",
71
+ "@platformatic/foundation": "3.0.0-alpha.6",
72
+ "@platformatic/generators": "3.0.0-alpha.6",
73
+ "@platformatic/metrics": "3.0.0-alpha.6",
74
+ "@platformatic/scalar-theme": "3.0.0-alpha.6",
75
+ "@platformatic/telemetry": "3.0.0-alpha.6"
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
84
  "build": "pnpm run gen-schema && pnpm run gen-types",
package/schema.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
- "$id": "https://schemas.platformatic.dev/@platformatic/service/3.0.0-alpha.4.json",
3
- "version": "3.0.0-alpha.4",
2
+ "$id": "https://schemas.platformatic.dev/@platformatic/service/3.0.0-alpha.6.json",
3
+ "version": "3.0.0-alpha.6",
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,235 @@
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
+ "arguments": {
1165
+ "type": "array",
1166
+ "items": {
1167
+ "type": "string"
1168
+ }
1169
+ },
1170
+ "env": {
1171
+ "type": "object",
1172
+ "additionalProperties": {
1173
+ "type": "string"
1174
+ }
1175
+ },
1176
+ "envfile": {
1177
+ "type": "string"
1178
+ },
1179
+ "sourceMaps": {
1180
+ "type": "boolean",
1181
+ "default": false
1182
+ },
1183
+ "packageManager": {
1184
+ "type": "string",
1185
+ "enum": [
1186
+ "npm",
1187
+ "pnpm",
1188
+ "yarn"
1189
+ ]
1190
+ },
1191
+ "preload": {
1192
+ "anyOf": [
1193
+ {
1194
+ "type": "string",
1195
+ "resolvePath": true
1196
+ },
1197
+ {
1198
+ "type": "array",
1199
+ "items": {
1200
+ "type": "string",
1201
+ "resolvePath": true
1202
+ }
1203
+ }
1204
+ ]
1205
+ },
1206
+ "nodeOptions": {
1207
+ "type": "string"
1208
+ },
1209
+ "telemetry": {
1210
+ "type": "object",
1211
+ "properties": {
1212
+ "instrumentations": {
1213
+ "type": "array",
1214
+ "description": "An array of instrumentations loaded if telemetry is enabled",
1215
+ "items": {
1216
+ "oneOf": [
1217
+ {
1218
+ "type": "string"
1219
+ },
1220
+ {
1221
+ "type": "object",
1222
+ "properties": {
1223
+ "package": {
1224
+ "type": "string"
1225
+ },
1226
+ "exportName": {
1227
+ "type": "string"
1228
+ },
1229
+ "options": {
1230
+ "type": "object",
1231
+ "additionalProperties": true
1232
+ }
1233
+ },
1234
+ "required": [
1235
+ "package"
1236
+ ]
1237
+ }
1238
+ ]
1239
+ }
1240
+ }
1241
+ }
1242
+ }
1243
+ }
1244
+ }
1245
+ },
1017
1246
  "workers": {
1018
1247
  "anyOf": [
1019
1248
  {
@@ -1328,7 +1557,7 @@
1328
1557
  ],
1329
1558
  "default": 10000
1330
1559
  },
1331
- "service": {
1560
+ "application": {
1332
1561
  "anyOf": [
1333
1562
  {
1334
1563
  "type": "number",
@@ -1344,7 +1573,7 @@
1344
1573
  "default": {},
1345
1574
  "required": [
1346
1575
  "runtime",
1347
- "service"
1576
+ "application"
1348
1577
  ],
1349
1578
  "additionalProperties": false
1350
1579
  },
@@ -1775,13 +2004,13 @@
1775
2004
  }
1776
2005
  ]
1777
2006
  },
1778
- "serviceName": {
2007
+ "applicationName": {
1779
2008
  "type": "string",
1780
- "description": "The name of the service. Defaults to the folder name if not specified."
2009
+ "description": "The name of the application. Defaults to the folder name if not specified."
1781
2010
  },
1782
2011
  "version": {
1783
2012
  "type": "string",
1784
- "description": "The version of the service (optional)"
2013
+ "description": "The version of the application (optional)"
1785
2014
  },
1786
2015
  "skip": {
1787
2016
  "type": "array",
@@ -1888,7 +2117,7 @@
1888
2117
  }
1889
2118
  },
1890
2119
  "required": [
1891
- "serviceName"
2120
+ "applicationName"
1892
2121
  ],
1893
2122
  "additionalProperties": false
1894
2123
  },
@@ -1909,7 +2138,7 @@
1909
2138
  }
1910
2139
  }
1911
2140
  },
1912
- "serviceTimeout": {
2141
+ "applicationTimeout": {
1913
2142
  "anyOf": [
1914
2143
  {
1915
2144
  "type": "number",