@twin.org/engine-server-types 0.0.2-next.1 → 0.0.2-next.2

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.
@@ -1,8 +1,10 @@
1
1
  'use strict';
2
2
 
3
+ var apiAuthEntityStorageRestClient = require('@twin.org/api-auth-entity-storage-rest-client');
3
4
  var apiAuthEntityStorageService = require('@twin.org/api-auth-entity-storage-service');
4
5
  var core = require('@twin.org/core');
5
6
  var engineTypes = require('@twin.org/engine-types');
7
+ var apiRestClient = require('@twin.org/api-rest-client');
6
8
  var apiService = require('@twin.org/api-service');
7
9
  var apiModels = require('@twin.org/api-models');
8
10
  var apiProcessors = require('@twin.org/api-processors');
@@ -17,7 +19,11 @@ const AuthenticationComponentType = {
17
19
  /**
18
20
  * Entity storage.
19
21
  */
20
- EntityStorage: "entity-storage"
22
+ EntityStorage: "entity-storage",
23
+ /**
24
+ * REST client.
25
+ */
26
+ RestClient: "rest-client"
21
27
  };
22
28
 
23
29
  /**
@@ -44,7 +50,11 @@ function initialiseAuthenticationComponent(engineCore, context, instanceConfig,
44
50
  authenticationAdminServiceType: context.defaultTypes.authenticationAdminComponent,
45
51
  ...instanceConfig.options
46
52
  });
47
- instanceType = apiAuthEntityStorageService.EntityStorageAuthenticationService.NAMESPACE;
53
+ instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationService");
54
+ }
55
+ else if (type === AuthenticationComponentType.RestClient) {
56
+ component = new apiAuthEntityStorageRestClient.EntityStorageAuthenticationClient(instanceConfig.options);
57
+ instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationClient");
48
58
  }
49
59
  else {
50
60
  throw new core.GeneralError("engineCore", "componentUnknownType", {
@@ -96,7 +106,7 @@ function initialiseAuthenticationAdminComponent(engineCore, context, instanceCon
96
106
  component = new apiAuthEntityStorageService.EntityStorageAuthenticationAdminService({
97
107
  ...instanceConfig.options
98
108
  });
99
- instanceType = apiAuthEntityStorageService.EntityStorageAuthenticationAdminService.NAMESPACE;
109
+ instanceType = core.StringHelper.kebabCase("EntityStorageAuthenticationAdminService");
100
110
  }
101
111
  else {
102
112
  throw new core.GeneralError("engineCore", "componentUnknownType", {
@@ -123,7 +133,11 @@ const InformationComponentType = {
123
133
  /**
124
134
  * Service.
125
135
  */
126
- Service: "service"
136
+ Service: "service",
137
+ /**
138
+ * REST client.
139
+ */
140
+ RestClient: "rest-client"
127
141
  };
128
142
 
129
143
  /**
@@ -144,7 +158,11 @@ function initialiseInformationComponent(engineCore, context, instanceConfig, ove
144
158
  let instanceType;
145
159
  if (type === InformationComponentType.Service) {
146
160
  component = new apiService.InformationService(instanceConfig.options);
147
- instanceType = apiService.InformationService.NAMESPACE;
161
+ instanceType = core.StringHelper.kebabCase("InformationService");
162
+ }
163
+ else if (type === InformationComponentType.RestClient) {
164
+ component = new apiRestClient.InformationClient(instanceConfig.options);
165
+ instanceType = core.StringHelper.kebabCase("InformationClient");
148
166
  }
149
167
  else {
150
168
  throw new core.GeneralError("engineCore", "componentUnknownType", {
@@ -194,7 +212,7 @@ function initialiseMimeTypeProcessorComponent(engineCore, context, instanceConfi
194
212
  let instanceType;
195
213
  if (type === MimeTypeProcessorType.Jwt) {
196
214
  component = new apiProcessors.JwtMimeTypeProcessor();
197
- instanceType = apiProcessors.JwtMimeTypeProcessor.NAMESPACE;
215
+ instanceType = core.StringHelper.kebabCase("JwtMimeTypeProcessor");
198
216
  }
199
217
  else {
200
218
  throw new core.GeneralError("engineCore", "componentUnknownType", {
@@ -265,7 +283,7 @@ function initialiseRestRouteProcessorComponent(engineCore, context, instanceConf
265
283
  ...instanceConfig.options?.config
266
284
  }
267
285
  });
268
- instanceType = apiAuthEntityStorageService.AuthHeaderProcessor.NAMESPACE;
286
+ instanceType = core.StringHelper.kebabCase("AuthHeaderProcessor");
269
287
  }
270
288
  else if (type === RestRouteProcessorType.Logging) {
271
289
  component = new apiProcessors.LoggingProcessor({
@@ -274,19 +292,19 @@ function initialiseRestRouteProcessorComponent(engineCore, context, instanceConf
274
292
  ...instanceConfig.options?.config
275
293
  }
276
294
  });
277
- instanceType = apiProcessors.LoggingProcessor.NAMESPACE;
295
+ instanceType = core.StringHelper.kebabCase("LoggingProcessor");
278
296
  }
279
297
  else if (type === RestRouteProcessorType.NodeIdentity) {
280
298
  component = new apiProcessors.NodeIdentityProcessor();
281
- instanceType = apiProcessors.NodeIdentityProcessor.NAMESPACE;
299
+ instanceType = core.StringHelper.kebabCase("NodeIdentityProcessor");
282
300
  }
283
301
  else if (type === RestRouteProcessorType.StaticUserIdentity) {
284
302
  component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
285
- instanceType = apiProcessors.StaticUserIdentityProcessor.NAMESPACE;
303
+ instanceType = core.StringHelper.kebabCase("StaticUserIdentityProcessor");
286
304
  }
287
305
  else if (type === RestRouteProcessorType.RestRoute) {
288
306
  component = new apiProcessors.RestRouteProcessor(instanceConfig.options);
289
- instanceType = apiProcessors.RestRouteProcessor.NAMESPACE;
307
+ instanceType = core.StringHelper.kebabCase("RestRouteProcessor");
290
308
  }
291
309
  else {
292
310
  throw new core.GeneralError("engineCore", "componentUnknownType", {
@@ -357,7 +375,7 @@ function initialiseSocketRouteProcessorComponent(engineCore, context, instanceCo
357
375
  ...instanceConfig.options?.config
358
376
  }
359
377
  });
360
- instanceType = apiAuthEntityStorageService.AuthHeaderProcessor.NAMESPACE;
378
+ instanceType = core.StringHelper.kebabCase("AuthHeaderProcessor");
361
379
  }
362
380
  else if (type === SocketRouteProcessorType.Logging) {
363
381
  component = new apiProcessors.LoggingProcessor({
@@ -366,19 +384,19 @@ function initialiseSocketRouteProcessorComponent(engineCore, context, instanceCo
366
384
  ...instanceConfig.options?.config
367
385
  }
368
386
  });
369
- instanceType = apiProcessors.LoggingProcessor.NAMESPACE;
387
+ instanceType = core.StringHelper.kebabCase("LoggingProcessor");
370
388
  }
371
389
  else if (type === SocketRouteProcessorType.NodeIdentity) {
372
390
  component = new apiProcessors.NodeIdentityProcessor();
373
- instanceType = apiProcessors.NodeIdentityProcessor.NAMESPACE;
391
+ instanceType = core.StringHelper.kebabCase("NodeIdentityProcessor");
374
392
  }
375
393
  else if (type === SocketRouteProcessorType.StaticUserIdentity) {
376
394
  component = new apiProcessors.StaticUserIdentityProcessor(instanceConfig.options);
377
- instanceType = apiProcessors.StaticUserIdentityProcessor.NAMESPACE;
395
+ instanceType = core.StringHelper.kebabCase("StaticUserIdentityProcessor");
378
396
  }
379
397
  else if (type === SocketRouteProcessorType.SocketRoute) {
380
398
  component = new apiProcessors.SocketRouteProcessor(instanceConfig.options);
381
- instanceType = apiProcessors.SocketRouteProcessor.NAMESPACE;
399
+ instanceType = core.StringHelper.kebabCase("SocketRouteProcessor");
382
400
  }
383
401
  else {
384
402
  throw new core.GeneralError("engineCore", "componentUnknownType", {
@@ -1,6 +1,8 @@
1
+ import { EntityStorageAuthenticationClient } from '@twin.org/api-auth-entity-storage-rest-client';
1
2
  import { initSchema, EntityStorageAuthenticationService, EntityStorageAuthenticationAdminService, AuthHeaderProcessor } from '@twin.org/api-auth-entity-storage-service';
2
- import { I18n, GeneralError, ComponentFactory } from '@twin.org/core';
3
+ import { I18n, StringHelper, GeneralError, ComponentFactory } from '@twin.org/core';
3
4
  import { initialiseEntityStorageConnector } from '@twin.org/engine-types';
5
+ import { InformationClient } from '@twin.org/api-rest-client';
4
6
  import { InformationService } from '@twin.org/api-service';
5
7
  import { MimeTypeProcessorFactory, RestRouteProcessorFactory, SocketRouteProcessorFactory } from '@twin.org/api-models';
6
8
  import { JwtMimeTypeProcessor, LoggingProcessor, NodeIdentityProcessor, StaticUserIdentityProcessor, RestRouteProcessor, SocketRouteProcessor } from '@twin.org/api-processors';
@@ -15,7 +17,11 @@ const AuthenticationComponentType = {
15
17
  /**
16
18
  * Entity storage.
17
19
  */
18
- EntityStorage: "entity-storage"
20
+ EntityStorage: "entity-storage",
21
+ /**
22
+ * REST client.
23
+ */
24
+ RestClient: "rest-client"
19
25
  };
20
26
 
21
27
  /**
@@ -42,7 +48,11 @@ function initialiseAuthenticationComponent(engineCore, context, instanceConfig,
42
48
  authenticationAdminServiceType: context.defaultTypes.authenticationAdminComponent,
43
49
  ...instanceConfig.options
44
50
  });
45
- instanceType = EntityStorageAuthenticationService.NAMESPACE;
51
+ instanceType = StringHelper.kebabCase("EntityStorageAuthenticationService");
52
+ }
53
+ else if (type === AuthenticationComponentType.RestClient) {
54
+ component = new EntityStorageAuthenticationClient(instanceConfig.options);
55
+ instanceType = StringHelper.kebabCase("EntityStorageAuthenticationClient");
46
56
  }
47
57
  else {
48
58
  throw new GeneralError("engineCore", "componentUnknownType", {
@@ -94,7 +104,7 @@ function initialiseAuthenticationAdminComponent(engineCore, context, instanceCon
94
104
  component = new EntityStorageAuthenticationAdminService({
95
105
  ...instanceConfig.options
96
106
  });
97
- instanceType = EntityStorageAuthenticationAdminService.NAMESPACE;
107
+ instanceType = StringHelper.kebabCase("EntityStorageAuthenticationAdminService");
98
108
  }
99
109
  else {
100
110
  throw new GeneralError("engineCore", "componentUnknownType", {
@@ -121,7 +131,11 @@ const InformationComponentType = {
121
131
  /**
122
132
  * Service.
123
133
  */
124
- Service: "service"
134
+ Service: "service",
135
+ /**
136
+ * REST client.
137
+ */
138
+ RestClient: "rest-client"
125
139
  };
126
140
 
127
141
  /**
@@ -142,7 +156,11 @@ function initialiseInformationComponent(engineCore, context, instanceConfig, ove
142
156
  let instanceType;
143
157
  if (type === InformationComponentType.Service) {
144
158
  component = new InformationService(instanceConfig.options);
145
- instanceType = InformationService.NAMESPACE;
159
+ instanceType = StringHelper.kebabCase("InformationService");
160
+ }
161
+ else if (type === InformationComponentType.RestClient) {
162
+ component = new InformationClient(instanceConfig.options);
163
+ instanceType = StringHelper.kebabCase("InformationClient");
146
164
  }
147
165
  else {
148
166
  throw new GeneralError("engineCore", "componentUnknownType", {
@@ -192,7 +210,7 @@ function initialiseMimeTypeProcessorComponent(engineCore, context, instanceConfi
192
210
  let instanceType;
193
211
  if (type === MimeTypeProcessorType.Jwt) {
194
212
  component = new JwtMimeTypeProcessor();
195
- instanceType = JwtMimeTypeProcessor.NAMESPACE;
213
+ instanceType = StringHelper.kebabCase("JwtMimeTypeProcessor");
196
214
  }
197
215
  else {
198
216
  throw new GeneralError("engineCore", "componentUnknownType", {
@@ -263,7 +281,7 @@ function initialiseRestRouteProcessorComponent(engineCore, context, instanceConf
263
281
  ...instanceConfig.options?.config
264
282
  }
265
283
  });
266
- instanceType = AuthHeaderProcessor.NAMESPACE;
284
+ instanceType = StringHelper.kebabCase("AuthHeaderProcessor");
267
285
  }
268
286
  else if (type === RestRouteProcessorType.Logging) {
269
287
  component = new LoggingProcessor({
@@ -272,19 +290,19 @@ function initialiseRestRouteProcessorComponent(engineCore, context, instanceConf
272
290
  ...instanceConfig.options?.config
273
291
  }
274
292
  });
275
- instanceType = LoggingProcessor.NAMESPACE;
293
+ instanceType = StringHelper.kebabCase("LoggingProcessor");
276
294
  }
277
295
  else if (type === RestRouteProcessorType.NodeIdentity) {
278
296
  component = new NodeIdentityProcessor();
279
- instanceType = NodeIdentityProcessor.NAMESPACE;
297
+ instanceType = StringHelper.kebabCase("NodeIdentityProcessor");
280
298
  }
281
299
  else if (type === RestRouteProcessorType.StaticUserIdentity) {
282
300
  component = new StaticUserIdentityProcessor(instanceConfig.options);
283
- instanceType = StaticUserIdentityProcessor.NAMESPACE;
301
+ instanceType = StringHelper.kebabCase("StaticUserIdentityProcessor");
284
302
  }
285
303
  else if (type === RestRouteProcessorType.RestRoute) {
286
304
  component = new RestRouteProcessor(instanceConfig.options);
287
- instanceType = RestRouteProcessor.NAMESPACE;
305
+ instanceType = StringHelper.kebabCase("RestRouteProcessor");
288
306
  }
289
307
  else {
290
308
  throw new GeneralError("engineCore", "componentUnknownType", {
@@ -355,7 +373,7 @@ function initialiseSocketRouteProcessorComponent(engineCore, context, instanceCo
355
373
  ...instanceConfig.options?.config
356
374
  }
357
375
  });
358
- instanceType = AuthHeaderProcessor.NAMESPACE;
376
+ instanceType = StringHelper.kebabCase("AuthHeaderProcessor");
359
377
  }
360
378
  else if (type === SocketRouteProcessorType.Logging) {
361
379
  component = new LoggingProcessor({
@@ -364,19 +382,19 @@ function initialiseSocketRouteProcessorComponent(engineCore, context, instanceCo
364
382
  ...instanceConfig.options?.config
365
383
  }
366
384
  });
367
- instanceType = LoggingProcessor.NAMESPACE;
385
+ instanceType = StringHelper.kebabCase("LoggingProcessor");
368
386
  }
369
387
  else if (type === SocketRouteProcessorType.NodeIdentity) {
370
388
  component = new NodeIdentityProcessor();
371
- instanceType = NodeIdentityProcessor.NAMESPACE;
389
+ instanceType = StringHelper.kebabCase("NodeIdentityProcessor");
372
390
  }
373
391
  else if (type === SocketRouteProcessorType.StaticUserIdentity) {
374
392
  component = new StaticUserIdentityProcessor(instanceConfig.options);
375
- instanceType = StaticUserIdentityProcessor.NAMESPACE;
393
+ instanceType = StringHelper.kebabCase("StaticUserIdentityProcessor");
376
394
  }
377
395
  else if (type === SocketRouteProcessorType.SocketRoute) {
378
396
  component = new SocketRouteProcessor(instanceConfig.options);
379
- instanceType = SocketRouteProcessor.NAMESPACE;
397
+ instanceType = StringHelper.kebabCase("SocketRouteProcessor");
380
398
  }
381
399
  else {
382
400
  throw new GeneralError("engineCore", "componentUnknownType", {
@@ -1,4 +1,4 @@
1
- import type { IEngineCoreContext, IEngineCore } from "@twin.org/engine-models";
1
+ import type { IEngineCore, IEngineCoreContext } from "@twin.org/engine-models";
2
2
  import type { AuthenticationComponentConfig } from "../models/config/authenticationComponentConfig";
3
3
  import type { IEngineServerConfig } from "../models/IEngineServerConfig";
4
4
  /**
@@ -1,4 +1,5 @@
1
1
  import type { IEntityStorageAuthenticationServiceConstructorOptions } from "@twin.org/api-auth-entity-storage-service";
2
+ import type { IBaseRestClientConfig } from "@twin.org/api-models";
2
3
  import type { AuthenticationComponentType } from "../types/authenticationComponentType";
3
4
  /**
4
5
  * Authentication component config types.
@@ -6,4 +7,7 @@ import type { AuthenticationComponentType } from "../types/authenticationCompone
6
7
  export type AuthenticationComponentConfig = {
7
8
  type: typeof AuthenticationComponentType.EntityStorage;
8
9
  options?: IEntityStorageAuthenticationServiceConstructorOptions;
10
+ } | {
11
+ type: typeof AuthenticationComponentType.RestClient;
12
+ options: IBaseRestClientConfig;
9
13
  };
@@ -1,3 +1,4 @@
1
+ import type { IBaseRestClientConfig } from "@twin.org/api-models";
1
2
  import type { IInformationServiceConstructorOptions } from "@twin.org/api-service";
2
3
  import type { InformationComponentType } from "../types/informationComponentType";
3
4
  /**
@@ -6,4 +7,7 @@ import type { InformationComponentType } from "../types/informationComponentType
6
7
  export type InformationComponentConfig = {
7
8
  type: typeof InformationComponentType.Service;
8
9
  options: IInformationServiceConstructorOptions;
10
+ } | {
11
+ type: typeof InformationComponentType.RestClient;
12
+ options: IBaseRestClientConfig;
9
13
  };
@@ -6,6 +6,10 @@ export declare const AuthenticationComponentType: {
6
6
  * Entity storage.
7
7
  */
8
8
  readonly EntityStorage: "entity-storage";
9
+ /**
10
+ * REST client.
11
+ */
12
+ readonly RestClient: "rest-client";
9
13
  };
10
14
  /**
11
15
  * Authentication component types.
@@ -6,6 +6,10 @@ export declare const InformationComponentType: {
6
6
  * Service.
7
7
  */
8
8
  readonly Service: "service";
9
+ /**
10
+ * REST client.
11
+ */
12
+ readonly RestClient: "rest-client";
9
13
  };
10
14
  /**
11
15
  * Information component types.
package/docs/changelog.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # @twin.org/engine-server-types - Changelog
2
2
 
3
+ ## [0.0.2-next.2](https://github.com/twinfoundation/engine/compare/engine-server-types-v0.0.2-next.1...engine-server-types-v0.0.2-next.2) (2025-07-21)
4
+
5
+
6
+ ### Features
7
+
8
+ * add rest clients as components ([c6f956a](https://github.com/twinfoundation/engine/commit/c6f956afe4fc22cd552174539c92a109448dc242))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/engine-models bumped from 0.0.2-next.1 to 0.0.2-next.2
16
+ * @twin.org/engine-types bumped from 0.0.2-next.1 to 0.0.2-next.2
17
+
3
18
  ## [0.0.2-next.1](https://github.com/twinfoundation/engine/compare/engine-server-types-v0.0.2-next.0...engine-server-types-v0.0.2-next.1) (2025-07-11)
4
19
 
5
20
 
@@ -1,17 +1,5 @@
1
1
  # Type Alias: AuthenticationComponentConfig
2
2
 
3
- > **AuthenticationComponentConfig** = `object`
3
+ > **AuthenticationComponentConfig** = \{ `type`: *typeof* [`EntityStorage`](../variables/AuthenticationComponentType.md#entitystorage); `options?`: `IEntityStorageAuthenticationServiceConstructorOptions`; \} \| \{ `type`: *typeof* [`RestClient`](../variables/AuthenticationComponentType.md#restclient); `options`: `IBaseRestClientConfig`; \}
4
4
 
5
5
  Authentication component config types.
6
-
7
- ## Properties
8
-
9
- ### type
10
-
11
- > **type**: *typeof* [`EntityStorage`](../variables/AuthenticationComponentType.md#entitystorage)
12
-
13
- ***
14
-
15
- ### options?
16
-
17
- > `optional` **options**: `IEntityStorageAuthenticationServiceConstructorOptions`
@@ -1,17 +1,5 @@
1
1
  # Type Alias: InformationComponentConfig
2
2
 
3
- > **InformationComponentConfig** = `object`
3
+ > **InformationComponentConfig** = \{ `type`: *typeof* [`Service`](../variables/InformationComponentType.md#service); `options`: `IInformationServiceConstructorOptions`; \} \| \{ `type`: *typeof* [`RestClient`](../variables/InformationComponentType.md#restclient); `options`: `IBaseRestClientConfig`; \}
4
4
 
5
5
  Information component config types.
6
-
7
- ## Properties
8
-
9
- ### type
10
-
11
- > **type**: *typeof* [`Service`](../variables/InformationComponentType.md#service)
12
-
13
- ***
14
-
15
- ### options
16
-
17
- > **options**: `IInformationServiceConstructorOptions`
@@ -11,3 +11,9 @@ Authentication component types.
11
11
  > `readonly` **EntityStorage**: `"entity-storage"` = `"entity-storage"`
12
12
 
13
13
  Entity storage.
14
+
15
+ ### RestClient
16
+
17
+ > `readonly` **RestClient**: `"rest-client"` = `"rest-client"`
18
+
19
+ REST client.
@@ -11,3 +11,9 @@ Information component types.
11
11
  > `readonly` **Service**: `"service"` = `"service"`
12
12
 
13
13
  Service.
14
+
15
+ ### RestClient
16
+
17
+ > `readonly` **RestClient**: `"rest-client"` = `"rest-client"`
18
+
19
+ REST client.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/engine-server-types",
3
- "version": "0.0.2-next.1",
3
+ "version": "0.0.2-next.2",
4
4
  "description": "Server types to use in an engine server.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,15 +14,17 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
+ "@twin.org/api-auth-entity-storage-rest-client": "next",
17
18
  "@twin.org/api-auth-entity-storage-service": "next",
18
19
  "@twin.org/api-core": "next",
19
20
  "@twin.org/api-models": "next",
20
21
  "@twin.org/api-processors": "next",
22
+ "@twin.org/api-rest-client": "next",
21
23
  "@twin.org/api-server-fastify": "next",
22
24
  "@twin.org/api-service": "next",
23
25
  "@twin.org/core": "next",
24
- "@twin.org/engine-models": "0.0.2-next.1",
25
- "@twin.org/engine-types": "0.0.2-next.1",
26
+ "@twin.org/engine-models": "0.0.2-next.2",
27
+ "@twin.org/engine-types": "0.0.2-next.2",
26
28
  "@twin.org/entity": "next",
27
29
  "@twin.org/nameof": "next"
28
30
  },