@twin.org/api-service 0.0.3-next.45 → 0.0.3-next.47

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/dist/es/index.js CHANGED
@@ -2,13 +2,10 @@
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
3
  export * from "./healthRoutes.js";
4
4
  export * from "./healthService.js";
5
- export * from "./hostingService.js";
6
5
  export * from "./informationRoutes.js";
7
6
  export * from "./informationService.js";
8
7
  export * from "./models/IHealthServiceConfig.js";
9
8
  export * from "./models/IHealthServiceConstructorOptions.js";
10
- export * from "./models/IHostingServiceConfig.js";
11
- export * from "./models/IHostingServiceConstructorOptions.js";
12
9
  export * from "./models/IInformationServiceConfig.js";
13
10
  export * from "./models/IInformationServiceConstructorOptions.js";
14
11
  export * from "./models/IPlatformServiceConfig.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,qBAAqB,CAAC;AACpC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,mCAAmC,CAAC;AAClD,cAAc,+CAA+C,CAAC;AAC9D,cAAc,uCAAuC,CAAC;AACtD,cAAc,mDAAmD,CAAC;AAClE,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./healthRoutes.js\";\nexport * from \"./healthService.js\";\nexport * from \"./hostingService.js\";\nexport * from \"./informationRoutes.js\";\nexport * from \"./informationService.js\";\nexport * from \"./models/IHealthServiceConfig.js\";\nexport * from \"./models/IHealthServiceConstructorOptions.js\";\nexport * from \"./models/IHostingServiceConfig.js\";\nexport * from \"./models/IHostingServiceConstructorOptions.js\";\nexport * from \"./models/IInformationServiceConfig.js\";\nexport * from \"./models/IInformationServiceConstructorOptions.js\";\nexport * from \"./models/IPlatformServiceConfig.js\";\nexport * from \"./models/IPlatformServiceConstructorOptions.js\";\nexport * from \"./platformService.js\";\nexport * from \"./restEntryPoints.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,uCAAuC,CAAC;AACtD,cAAc,mDAAmD,CAAC;AAClE,cAAc,oCAAoC,CAAC;AACnD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./healthRoutes.js\";\nexport * from \"./healthService.js\";\nexport * from \"./informationRoutes.js\";\nexport * from \"./informationService.js\";\nexport * from \"./models/IHealthServiceConfig.js\";\nexport * from \"./models/IHealthServiceConstructorOptions.js\";\nexport * from \"./models/IInformationServiceConfig.js\";\nexport * from \"./models/IInformationServiceConstructorOptions.js\";\nexport * from \"./models/IPlatformServiceConfig.js\";\nexport * from \"./models/IPlatformServiceConstructorOptions.js\";\nexport * from \"./platformService.js\";\nexport * from \"./restEntryPoints.js\";\n"]}
@@ -1,12 +1,9 @@
1
1
  export * from "./healthRoutes.js";
2
2
  export * from "./healthService.js";
3
- export * from "./hostingService.js";
4
3
  export * from "./informationRoutes.js";
5
4
  export * from "./informationService.js";
6
5
  export * from "./models/IHealthServiceConfig.js";
7
6
  export * from "./models/IHealthServiceConstructorOptions.js";
8
- export * from "./models/IHostingServiceConfig.js";
9
- export * from "./models/IHostingServiceConstructorOptions.js";
10
7
  export * from "./models/IInformationServiceConfig.js";
11
8
  export * from "./models/IInformationServiceConstructorOptions.js";
12
9
  export * from "./models/IPlatformServiceConfig.js";
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.47](https://github.com/iotaledger/twin-api/compare/api-service-v0.0.3-next.46...api-service-v0.0.3-next.47) (2026-06-18)
4
+
5
+
6
+ ### Features
7
+
8
+ * remove hosting component ([#170](https://github.com/iotaledger/twin-api/issues/170)) ([e78c1e8](https://github.com/iotaledger/twin-api/commit/e78c1e87d2747bf58da02b6b77680708ff681122))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/api-models bumped from 0.0.3-next.46 to 0.0.3-next.47
16
+
17
+ ## [0.0.3-next.46](https://github.com/iotaledger/twin-api/compare/api-service-v0.0.3-next.45...api-service-v0.0.3-next.46) (2026-06-17)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **api-service:** Synchronize repo versions
23
+
24
+
25
+ ### Dependencies
26
+
27
+ * The following workspace dependencies were updated
28
+ * dependencies
29
+ * @twin.org/api-models bumped from 0.0.3-next.45 to 0.0.3-next.46
30
+
3
31
  ## [0.0.3-next.45](https://github.com/iotaledger/twin-api/compare/api-service-v0.0.3-next.44...api-service-v0.0.3-next.45) (2026-06-15)
4
32
 
5
33
 
@@ -3,7 +3,6 @@
3
3
  ## Classes
4
4
 
5
5
  - [HealthService](classes/HealthService.md)
6
- - [HostingService](classes/HostingService.md)
7
6
  - [InformationService](classes/InformationService.md)
8
7
  - [PlatformService](classes/PlatformService.md)
9
8
 
@@ -11,8 +10,6 @@
11
10
 
12
11
  - [IHealthServiceConfig](interfaces/IHealthServiceConfig.md)
13
12
  - [IHealthServiceConstructorOptions](interfaces/IHealthServiceConstructorOptions.md)
14
- - [IHostingServiceConfig](interfaces/IHostingServiceConfig.md)
15
- - [IHostingServiceConstructorOptions](interfaces/IHostingServiceConstructorOptions.md)
16
13
  - [IInformationServiceConfig](interfaces/IInformationServiceConfig.md)
17
14
  - [IInformationServiceConstructorOptions](interfaces/IInformationServiceConstructorOptions.md)
18
15
  - [IPlatformServiceConfig](interfaces/IPlatformServiceConfig.md)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/api-service",
3
- "version": "0.0.3-next.45",
3
+ "version": "0.0.3-next.47",
4
4
  "description": "Information and hosting service implementations with generated REST route handlers.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -14,7 +14,7 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/api-models": "0.0.3-next.45",
17
+ "@twin.org/api-models": "0.0.3-next.47",
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/engine-models": "next",
@@ -1,115 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- import { HttpUrlHelper } from "@twin.org/api-models";
4
- import { ContextIdKeys, ContextIdStore } from "@twin.org/context";
5
- import { ComponentFactory, Guards, Is } from "@twin.org/core";
6
- /**
7
- * The hosting service for the server.
8
- */
9
- export class HostingService {
10
- /**
11
- * Runtime name for the class.
12
- */
13
- static CLASS_NAME = "HostingService";
14
- /**
15
- * The tenant admin component.
16
- * @internal
17
- */
18
- _tenantAdminComponentType;
19
- /**
20
- * The local origin URL e.g. "http://localhost:3000".
21
- * @internal
22
- */
23
- _localOrigin;
24
- /**
25
- * The APIs public base URL e.g. "https://api.example.com:1234".
26
- * @internal
27
- */
28
- _publicOrigin;
29
- /**
30
- * Create a new instance of HostingService.
31
- * @param options The options to create the service.
32
- */
33
- constructor(options) {
34
- Guards.object(HostingService.CLASS_NAME, "options", options);
35
- Guards.object(HostingService.CLASS_NAME, "options.config", options.config);
36
- Guards.stringValue(HostingService.CLASS_NAME, "options.config.localOrigin", options.config.localOrigin);
37
- this._tenantAdminComponentType = options?.tenantAdminComponentType ?? "tenant-admin";
38
- this._localOrigin = options.config.localOrigin;
39
- this._publicOrigin = options.config.publicOrigin;
40
- }
41
- /**
42
- * Returns the class name of the component.
43
- * @returns The class name of the component.
44
- */
45
- className() {
46
- return HostingService.CLASS_NAME;
47
- }
48
- /**
49
- * Get the public origin for the hosting.
50
- * @param serverRequestUrl The url of the current server request if there is one.
51
- * @returns The public origin.
52
- */
53
- async getPublicOrigin(serverRequestUrl) {
54
- const contextIds = await ContextIdStore.getContextIds();
55
- const tenantId = contextIds?.[ContextIdKeys.Tenant];
56
- let tenantPublicOrigin;
57
- if (Is.stringValue(tenantId)) {
58
- tenantPublicOrigin = await this.getTenantOrigin(tenantId);
59
- }
60
- const serverRequestOrigin = Is.stringValue(serverRequestUrl)
61
- ? HttpUrlHelper.extractOrigin(serverRequestUrl)
62
- : undefined;
63
- return tenantPublicOrigin ?? this._publicOrigin ?? serverRequestOrigin ?? this._localOrigin;
64
- }
65
- /**
66
- * Get the public origin for the tenant if one exists.
67
- * @param tenantId The tenant identifier.
68
- * @returns The public origin for the tenant.
69
- */
70
- async getTenantOrigin(tenantId) {
71
- Guards.stringHexLength(HostingService.CLASS_NAME, "tenantId", tenantId, 32);
72
- const tenantAdminComponent = ComponentFactory.getIfExists(this._tenantAdminComponentType);
73
- if (Is.empty(tenantAdminComponent)) {
74
- return undefined;
75
- }
76
- const tenant = await tenantAdminComponent.get(tenantId);
77
- return tenant?.publicOrigin;
78
- }
79
- /**
80
- * Build a public url based on the public origin and the url provided.
81
- * @param url The url to build upon the public origin.
82
- * @returns The full url based on the public origin.
83
- */
84
- async buildPublicUrl(url) {
85
- const publicOrigin = await this.getPublicOrigin(url);
86
- return HttpUrlHelper.replaceOrigin(url, publicOrigin);
87
- }
88
- /**
89
- * Check if the origin of the given url matches the node public origin or any tenant's public origin.
90
- * @param url The url whose origin to check.
91
- * @returns "node" for the node public origin, the tenant id for a tenant public origin, or undefined.
92
- */
93
- async matchesLocalOrigin(url) {
94
- Guards.stringValue(HostingService.CLASS_NAME, "url", url);
95
- const origin = HttpUrlHelper.extractOrigin(url);
96
- if (!Is.stringValue(origin)) {
97
- return undefined;
98
- }
99
- if (Is.stringValue(this._publicOrigin) && origin === this._publicOrigin) {
100
- return "node";
101
- }
102
- const tenantAdminComponent = ComponentFactory.getIfExists(this._tenantAdminComponentType);
103
- if (Is.empty(tenantAdminComponent)) {
104
- return undefined;
105
- }
106
- try {
107
- const tenant = await tenantAdminComponent.getByPublicOrigin(origin);
108
- return tenant?.id;
109
- }
110
- catch {
111
- return undefined;
112
- }
113
- }
114
- }
115
- //# sourceMappingURL=hostingService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"hostingService.js","sourceRoot":"","sources":["../../src/hostingService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,aAAa,EAGb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAI9D;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;OAEG;IACI,MAAM,CAAU,UAAU,oBAAoC;IAErE;;;OAGG;IACc,yBAAyB,CAAU;IAEpD;;;OAGG;IACc,YAAY,CAAS;IAEtC;;;OAGG;IACc,aAAa,CAAU;IAExC;;;OAGG;IACH,YAAY,OAA0C;QACrD,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,aAAmB,OAAO,CAAC,CAAC;QACnE,MAAM,CAAC,MAAM,CAAC,cAAc,CAAC,UAAU,oBAA0B,OAAO,CAAC,MAAM,CAAC,CAAC;QACjF,MAAM,CAAC,WAAW,CACjB,cAA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A Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport {\n\tHttpUrlHelper,\n\ttype IHostingComponent,\n\ttype ITenantAdminComponent\n} from \"@twin.org/api-models\";\nimport { ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IHostingServiceConstructorOptions } from \"./models/IHostingServiceConstructorOptions.js\";\n\n/**\n * The hosting service for the server.\n */\nexport class HostingService implements IHostingComponent {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<HostingService>();\n\n\t/**\n\t * The tenant admin component.\n\t * @internal\n\t */\n\tprivate readonly _tenantAdminComponentType?: string;\n\n\t/**\n\t * The local origin URL e.g. \"http://localhost:3000\".\n\t * @internal\n\t */\n\tprivate readonly _localOrigin: string;\n\n\t/**\n\t * The APIs public base URL e.g. \"https://api.example.com:1234\".\n\t * @internal\n\t */\n\tprivate readonly _publicOrigin?: string;\n\n\t/**\n\t * Create a new instance of HostingService.\n\t * @param options The options to create the service.\n\t */\n\tconstructor(options: IHostingServiceConstructorOptions) {\n\t\tGuards.object(HostingService.CLASS_NAME, nameof(options), options);\n\t\tGuards.object(HostingService.CLASS_NAME, nameof(options.config), options.config);\n\t\tGuards.stringValue(\n\t\t\tHostingService.CLASS_NAME,\n\t\t\tnameof(options.config.localOrigin),\n\t\t\toptions.config.localOrigin\n\t\t);\n\t\tthis._tenantAdminComponentType = options?.tenantAdminComponentType ?? \"tenant-admin\";\n\t\tthis._localOrigin = options.config.localOrigin;\n\t\tthis._publicOrigin = options.config.publicOrigin;\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn HostingService.CLASS_NAME;\n\t}\n\n\t/**\n\t * Get the public origin for the hosting.\n\t * @param serverRequestUrl The url of the current server request if there is one.\n\t * @returns The public origin.\n\t */\n\tpublic async getPublicOrigin(serverRequestUrl?: string): Promise<string> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst tenantId = contextIds?.[ContextIdKeys.Tenant];\n\t\tlet tenantPublicOrigin;\n\t\tif (Is.stringValue(tenantId)) {\n\t\t\ttenantPublicOrigin = await this.getTenantOrigin(tenantId);\n\t\t}\n\n\t\tconst serverRequestOrigin = Is.stringValue(serverRequestUrl)\n\t\t\t? HttpUrlHelper.extractOrigin(serverRequestUrl)\n\t\t\t: undefined;\n\n\t\treturn tenantPublicOrigin ?? this._publicOrigin ?? serverRequestOrigin ?? this._localOrigin;\n\t}\n\n\t/**\n\t * Get the public origin for the tenant if one exists.\n\t * @param tenantId The tenant identifier.\n\t * @returns The public origin for the tenant.\n\t */\n\tpublic async getTenantOrigin(tenantId: string): Promise<string | undefined> {\n\t\tGuards.stringHexLength(HostingService.CLASS_NAME, nameof(tenantId), tenantId, 32);\n\n\t\tconst tenantAdminComponent = ComponentFactory.getIfExists<ITenantAdminComponent>(\n\t\t\tthis._tenantAdminComponentType\n\t\t);\n\n\t\tif (Is.empty(tenantAdminComponent)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tconst tenant = await tenantAdminComponent.get(tenantId);\n\t\treturn tenant?.publicOrigin;\n\t}\n\n\t/**\n\t * Build a public url based on the public origin and the url provided.\n\t * @param url The url to build upon the public origin.\n\t * @returns The full url based on the public origin.\n\t */\n\tpublic async buildPublicUrl(url: string): Promise<string> {\n\t\tconst publicOrigin = await this.getPublicOrigin(url);\n\t\treturn HttpUrlHelper.replaceOrigin(url, publicOrigin);\n\t}\n\n\t/**\n\t * Check if the origin of the given url matches the node public origin or any tenant's public origin.\n\t * @param url The url whose origin to check.\n\t * @returns \"node\" for the node public origin, the tenant id for a tenant public origin, or undefined.\n\t */\n\tpublic async matchesLocalOrigin(url: string): Promise<string | undefined> {\n\t\tGuards.stringValue(HostingService.CLASS_NAME, nameof(url), url);\n\n\t\tconst origin = HttpUrlHelper.extractOrigin(url);\n\t\tif (!Is.stringValue(origin)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\tif (Is.stringValue(this._publicOrigin) && origin === this._publicOrigin) {\n\t\t\treturn \"node\";\n\t\t}\n\n\t\tconst tenantAdminComponent = ComponentFactory.getIfExists<ITenantAdminComponent>(\n\t\t\tthis._tenantAdminComponentType\n\t\t);\n\n\t\tif (Is.empty(tenantAdminComponent)) {\n\t\t\treturn undefined;\n\t\t}\n\n\t\ttry {\n\t\t\tconst tenant = await tenantAdminComponent.getByPublicOrigin(origin);\n\t\t\treturn tenant?.id;\n\t\t} catch {\n\t\t\treturn undefined;\n\t\t}\n\t}\n}\n"]}
@@ -1,4 +0,0 @@
1
- // Copyright 2024 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- export {};
4
- //# sourceMappingURL=IHostingServiceConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IHostingServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IHostingServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the hosting service.\n */\nexport interface IHostingServiceConfig {\n\t/**\n\t * The local origin, must be provided as a fallback e.g. http://localhost:1234.\n\t */\n\tlocalOrigin: string;\n\n\t/**\n\t * The APIs public base URL e.g. \"https://api.example.com:1234\".\n\t */\n\tpublicOrigin?: string;\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=IHostingServiceConstructorOptions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IHostingServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IHostingServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IHostingServiceConfig } from \"./IHostingServiceConfig.js\";\n\n/**\n * Options for the HostingService constructor.\n */\nexport interface IHostingServiceConstructorOptions {\n\t/**\n\t * The tenant admin component type.\n\t * @default tenant-admin\n\t */\n\ttenantAdminComponentType?: string;\n\n\t/**\n\t * The configuration for the service.\n\t */\n\tconfig: IHostingServiceConfig;\n}\n"]}
@@ -1,45 +0,0 @@
1
- import { type IHostingComponent } from "@twin.org/api-models";
2
- import type { IHostingServiceConstructorOptions } from "./models/IHostingServiceConstructorOptions.js";
3
- /**
4
- * The hosting service for the server.
5
- */
6
- export declare class HostingService implements IHostingComponent {
7
- /**
8
- * Runtime name for the class.
9
- */
10
- static readonly CLASS_NAME: string;
11
- /**
12
- * Create a new instance of HostingService.
13
- * @param options The options to create the service.
14
- */
15
- constructor(options: IHostingServiceConstructorOptions);
16
- /**
17
- * Returns the class name of the component.
18
- * @returns The class name of the component.
19
- */
20
- className(): string;
21
- /**
22
- * Get the public origin for the hosting.
23
- * @param serverRequestUrl The url of the current server request if there is one.
24
- * @returns The public origin.
25
- */
26
- getPublicOrigin(serverRequestUrl?: string): Promise<string>;
27
- /**
28
- * Get the public origin for the tenant if one exists.
29
- * @param tenantId The tenant identifier.
30
- * @returns The public origin for the tenant.
31
- */
32
- getTenantOrigin(tenantId: string): Promise<string | undefined>;
33
- /**
34
- * Build a public url based on the public origin and the url provided.
35
- * @param url The url to build upon the public origin.
36
- * @returns The full url based on the public origin.
37
- */
38
- buildPublicUrl(url: string): Promise<string>;
39
- /**
40
- * Check if the origin of the given url matches the node public origin or any tenant's public origin.
41
- * @param url The url whose origin to check.
42
- * @returns "node" for the node public origin, the tenant id for a tenant public origin, or undefined.
43
- */
44
- matchesLocalOrigin(url: string): Promise<string | undefined>;
45
- }
@@ -1,13 +0,0 @@
1
- /**
2
- * Configuration for the hosting service.
3
- */
4
- export interface IHostingServiceConfig {
5
- /**
6
- * The local origin, must be provided as a fallback e.g. http://localhost:1234.
7
- */
8
- localOrigin: string;
9
- /**
10
- * The APIs public base URL e.g. "https://api.example.com:1234".
11
- */
12
- publicOrigin?: string;
13
- }
@@ -1,15 +0,0 @@
1
- import type { IHostingServiceConfig } from "./IHostingServiceConfig.js";
2
- /**
3
- * Options for the HostingService constructor.
4
- */
5
- export interface IHostingServiceConstructorOptions {
6
- /**
7
- * The tenant admin component type.
8
- * @default tenant-admin
9
- */
10
- tenantAdminComponentType?: string;
11
- /**
12
- * The configuration for the service.
13
- */
14
- config: IHostingServiceConfig;
15
- }
@@ -1,157 +0,0 @@
1
- # Class: HostingService
2
-
3
- The hosting service for the server.
4
-
5
- ## Implements
6
-
7
- - `IHostingComponent`
8
-
9
- ## Constructors
10
-
11
- ### Constructor
12
-
13
- > **new HostingService**(`options`): `HostingService`
14
-
15
- Create a new instance of HostingService.
16
-
17
- #### Parameters
18
-
19
- ##### options
20
-
21
- [`IHostingServiceConstructorOptions`](../interfaces/IHostingServiceConstructorOptions.md)
22
-
23
- The options to create the service.
24
-
25
- #### Returns
26
-
27
- `HostingService`
28
-
29
- ## Properties
30
-
31
- ### CLASS\_NAME {#class_name}
32
-
33
- > `readonly` `static` **CLASS\_NAME**: `string`
34
-
35
- Runtime name for the class.
36
-
37
- ## Methods
38
-
39
- ### className() {#classname}
40
-
41
- > **className**(): `string`
42
-
43
- Returns the class name of the component.
44
-
45
- #### Returns
46
-
47
- `string`
48
-
49
- The class name of the component.
50
-
51
- #### Implementation of
52
-
53
- `IHostingComponent.className`
54
-
55
- ***
56
-
57
- ### getPublicOrigin() {#getpublicorigin}
58
-
59
- > **getPublicOrigin**(`serverRequestUrl?`): `Promise`\<`string`\>
60
-
61
- Get the public origin for the hosting.
62
-
63
- #### Parameters
64
-
65
- ##### serverRequestUrl?
66
-
67
- `string`
68
-
69
- The url of the current server request if there is one.
70
-
71
- #### Returns
72
-
73
- `Promise`\<`string`\>
74
-
75
- The public origin.
76
-
77
- #### Implementation of
78
-
79
- `IHostingComponent.getPublicOrigin`
80
-
81
- ***
82
-
83
- ### getTenantOrigin() {#gettenantorigin}
84
-
85
- > **getTenantOrigin**(`tenantId`): `Promise`\<`string` \| `undefined`\>
86
-
87
- Get the public origin for the tenant if one exists.
88
-
89
- #### Parameters
90
-
91
- ##### tenantId
92
-
93
- `string`
94
-
95
- The tenant identifier.
96
-
97
- #### Returns
98
-
99
- `Promise`\<`string` \| `undefined`\>
100
-
101
- The public origin for the tenant.
102
-
103
- #### Implementation of
104
-
105
- `IHostingComponent.getTenantOrigin`
106
-
107
- ***
108
-
109
- ### buildPublicUrl() {#buildpublicurl}
110
-
111
- > **buildPublicUrl**(`url`): `Promise`\<`string`\>
112
-
113
- Build a public url based on the public origin and the url provided.
114
-
115
- #### Parameters
116
-
117
- ##### url
118
-
119
- `string`
120
-
121
- The url to build upon the public origin.
122
-
123
- #### Returns
124
-
125
- `Promise`\<`string`\>
126
-
127
- The full url based on the public origin.
128
-
129
- #### Implementation of
130
-
131
- `IHostingComponent.buildPublicUrl`
132
-
133
- ***
134
-
135
- ### matchesLocalOrigin() {#matcheslocalorigin}
136
-
137
- > **matchesLocalOrigin**(`url`): `Promise`\<`string` \| `undefined`\>
138
-
139
- Check if the origin of the given url matches the node public origin or any tenant's public origin.
140
-
141
- #### Parameters
142
-
143
- ##### url
144
-
145
- `string`
146
-
147
- The url whose origin to check.
148
-
149
- #### Returns
150
-
151
- `Promise`\<`string` \| `undefined`\>
152
-
153
- "node" for the node public origin, the tenant id for a tenant public origin, or undefined.
154
-
155
- #### Implementation of
156
-
157
- `IHostingComponent.matchesLocalOrigin`
@@ -1,19 +0,0 @@
1
- # Interface: IHostingServiceConfig
2
-
3
- Configuration for the hosting service.
4
-
5
- ## Properties
6
-
7
- ### localOrigin {#localorigin}
8
-
9
- > **localOrigin**: `string`
10
-
11
- The local origin, must be provided as a fallback e.g. http://localhost:1234.
12
-
13
- ***
14
-
15
- ### publicOrigin? {#publicorigin}
16
-
17
- > `optional` **publicOrigin?**: `string`
18
-
19
- The APIs public base URL e.g. "https://api.example.com:1234".
@@ -1,25 +0,0 @@
1
- # Interface: IHostingServiceConstructorOptions
2
-
3
- Options for the HostingService constructor.
4
-
5
- ## Properties
6
-
7
- ### tenantAdminComponentType? {#tenantadmincomponenttype}
8
-
9
- > `optional` **tenantAdminComponentType?**: `string`
10
-
11
- The tenant admin component type.
12
-
13
- #### Default
14
-
15
- ```ts
16
- tenant-admin
17
- ```
18
-
19
- ***
20
-
21
- ### config {#config}
22
-
23
- > **config**: [`IHostingServiceConfig`](IHostingServiceConfig.md)
24
-
25
- The configuration for the service.