@twin.org/api-models 0.0.3-next.2 → 0.0.3-next.21

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.
Files changed (82) hide show
  1. package/README.md +1 -1
  2. package/dist/es/helpers/httpErrorHelper.js +28 -19
  3. package/dist/es/helpers/httpErrorHelper.js.map +1 -1
  4. package/dist/es/helpers/httpUrlHelper.js +92 -0
  5. package/dist/es/helpers/httpUrlHelper.js.map +1 -0
  6. package/dist/es/index.js +6 -2
  7. package/dist/es/index.js.map +1 -1
  8. package/dist/es/models/api/IServerLivezResponse.js +2 -0
  9. package/dist/es/models/api/IServerLivezResponse.js.map +1 -0
  10. package/dist/es/models/api/IServerRootResponse.js +0 -2
  11. package/dist/es/models/api/IServerRootResponse.js.map +1 -1
  12. package/dist/es/models/protocol/IHttpRequestContext.js.map +1 -1
  13. package/dist/es/models/protocol/IHttpRequestPathParams.js.map +1 -1
  14. package/dist/es/models/protocol/IHttpRequestQuery.js.map +1 -1
  15. package/dist/es/models/protocol/IHttpServerRequest.js.map +1 -1
  16. package/dist/es/models/routes/IBaseRoute.js.map +1 -1
  17. package/dist/es/models/server/IBaseRouteProcessor.js.map +1 -1
  18. package/dist/es/models/server/IRestRouteProcessor.js.map +1 -1
  19. package/dist/es/models/server/ISocketRouteProcessor.js.map +1 -1
  20. package/dist/es/models/services/IHealthComponentInfo.js +2 -0
  21. package/dist/es/models/services/IHealthComponentInfo.js.map +1 -0
  22. package/dist/es/models/services/IHealthInfo.js.map +1 -1
  23. package/dist/es/models/services/IHostingComponent.js +2 -0
  24. package/dist/es/models/services/IHostingComponent.js.map +1 -0
  25. package/dist/es/models/services/IInformationComponent.js.map +1 -1
  26. package/dist/es/models/services/ITenant.js +4 -0
  27. package/dist/es/models/services/ITenant.js.map +1 -0
  28. package/dist/es/models/services/ITenantAdminComponent.js +2 -0
  29. package/dist/es/models/services/ITenantAdminComponent.js.map +1 -0
  30. package/dist/types/helpers/httpErrorHelper.d.ts +6 -0
  31. package/dist/types/helpers/httpUrlHelper.d.ts +46 -0
  32. package/dist/types/index.d.ts +6 -2
  33. package/dist/types/models/api/IServerLivezResponse.d.ts +16 -0
  34. package/dist/types/models/api/IServerRootResponse.d.ts +7 -0
  35. package/dist/types/models/protocol/IHttpRequestContext.d.ts +4 -0
  36. package/dist/types/models/protocol/IHttpRequestPathParams.d.ts +1 -1
  37. package/dist/types/models/protocol/IHttpRequestQuery.d.ts +1 -1
  38. package/dist/types/models/protocol/IHttpServerRequest.d.ts +4 -4
  39. package/dist/types/models/routes/IBaseRoute.d.ts +9 -1
  40. package/dist/types/models/server/IBaseRouteProcessor.d.ts +14 -4
  41. package/dist/types/models/server/IRestRouteProcessor.d.ts +7 -2
  42. package/dist/types/models/services/IHealthComponentInfo.d.ts +18 -0
  43. package/dist/types/models/services/IHealthInfo.d.ts +2 -14
  44. package/dist/types/models/services/IHostingComponent.d.ts +24 -0
  45. package/dist/types/models/services/IInformationComponent.d.ts +9 -2
  46. package/dist/types/models/services/ITenant.d.ts +33 -0
  47. package/dist/types/models/services/ITenantAdminComponent.d.ts +63 -0
  48. package/docs/changelog.md +165 -1
  49. package/docs/examples.md +63 -1
  50. package/docs/reference/classes/HttpErrorHelper.md +12 -0
  51. package/docs/reference/classes/HttpUrlHelper.md +169 -0
  52. package/docs/reference/index.md +6 -2
  53. package/docs/reference/interfaces/IBaseRoute.md +17 -1
  54. package/docs/reference/interfaces/IBaseRouteProcessor.md +26 -6
  55. package/docs/reference/interfaces/IHealthComponentInfo.md +27 -0
  56. package/docs/reference/interfaces/IHealthInfo.md +1 -19
  57. package/docs/reference/interfaces/IHostingComponent.md +73 -0
  58. package/docs/reference/interfaces/IHttpRequestContext.md +8 -0
  59. package/docs/reference/interfaces/IHttpRequestPathParams.md +1 -1
  60. package/docs/reference/interfaces/IHttpRequestQuery.md +1 -1
  61. package/docs/reference/interfaces/IHttpServerRequest.md +6 -6
  62. package/docs/reference/interfaces/IInformationComponent.md +28 -2
  63. package/docs/reference/interfaces/IRestRoute.md +25 -1
  64. package/docs/reference/interfaces/IRestRouteProcessor.md +39 -9
  65. package/docs/reference/interfaces/IServerLivezResponse.md +23 -0
  66. package/docs/reference/interfaces/IServerRootResponse.md +12 -0
  67. package/docs/reference/interfaces/ISocketRequestContext.md +12 -0
  68. package/docs/reference/interfaces/ISocketRoute.md +25 -1
  69. package/docs/reference/interfaces/ISocketRouteProcessor.md +26 -6
  70. package/docs/reference/interfaces/ISocketServerRequest.md +8 -8
  71. package/docs/reference/interfaces/ITenant.md +59 -0
  72. package/docs/reference/interfaces/ITenantAdminComponent.md +193 -0
  73. package/docs/reference/interfaces/IWebServerOptions.md +0 -24
  74. package/package.json +2 -2
  75. package/dist/es/factories/authenticationGeneratorFactory.js +0 -9
  76. package/dist/es/factories/authenticationGeneratorFactory.js.map +0 -1
  77. package/dist/es/models/client/IAuthenticationGenerator.js +0 -2
  78. package/dist/es/models/client/IAuthenticationGenerator.js.map +0 -1
  79. package/dist/types/factories/authenticationGeneratorFactory.d.ts +0 -6
  80. package/dist/types/models/client/IAuthenticationGenerator.d.ts +0 -14
  81. package/docs/reference/interfaces/IAuthenticationGenerator.md +0 -35
  82. package/docs/reference/variables/AuthenticationGeneratorFactory.md +0 -5
@@ -5,11 +5,11 @@ import type { IHttpRequest } from "./IHttpRequest.js";
5
5
  */
6
6
  export interface IHttpServerRequest<T = any> extends IHttpRequest<T> {
7
7
  /**
8
- * The request method.
8
+ * The request url.
9
9
  */
10
- method?: HttpMethod;
10
+ url: string;
11
11
  /**
12
- * The request url.
12
+ * The request method.
13
13
  */
14
- url?: string;
14
+ method?: HttpMethod;
15
15
  }
@@ -11,9 +11,17 @@ export interface IBaseRoute {
11
11
  */
12
12
  path: string;
13
13
  /**
14
- * Skips the authentication for this route.
14
+ * Skips the authentication requirement for this route.
15
15
  */
16
16
  skipAuth?: boolean;
17
+ /**
18
+ * Skips the tenant requirement for this route.
19
+ */
20
+ skipTenant?: boolean;
21
+ /**
22
+ * The user must have one of the specified scopes to access the route.
23
+ */
24
+ requiredScope?: string[];
17
25
  /**
18
26
  * The features supported by additional processors to run for this route.
19
27
  */
@@ -21,12 +21,17 @@ export interface IBaseRouteProcessor<T = IBaseRoute, R = IHttpServerRequest> ext
21
21
  * @param route The route being requested, if a matching one was found.
22
22
  * @param contextIds The context IDs of the request.
23
23
  * @param processorState The state handed through the processors.
24
- * @param loggingComponentType The logging component type for the request.
24
+ * @param componentTypes The component types for the request.
25
+ * @param componentTypes.loggingComponentType The logging component type.
26
+ * @param componentTypes.hostingComponentType The hosting component type.
25
27
  * @returns Promise that resolves when the request is processed.
26
28
  */
27
29
  pre?(request: R, response: IHttpResponse, route: T | undefined, contextIds: IContextIds, processorState: {
28
30
  [id: string]: unknown;
29
- }, loggingComponentType?: string): Promise<void>;
31
+ }, componentTypes?: {
32
+ loggingComponentType?: string;
33
+ hostingComponentType?: string;
34
+ }): Promise<void>;
30
35
  /**
31
36
  * Post process the REST request for the specified route.
32
37
  * @param request The request to handle.
@@ -34,10 +39,15 @@ export interface IBaseRouteProcessor<T = IBaseRoute, R = IHttpServerRequest> ext
34
39
  * @param route The route being requested, if a matching one was found.
35
40
  * @param contextIds The context IDs of the request.
36
41
  * @param processorState The state handed through the processors.
37
- * @param loggingComponentType The logging component type for the request.
42
+ * @param componentTypes The component types for the request.
43
+ * @param componentTypes.loggingComponentType The logging component type.
44
+ * @param componentTypes.hostingComponentType The hosting component type.
38
45
  * @returns Promise that resolves when the request is processed.
39
46
  */
40
47
  post?(request: R, response: IHttpResponse, route: T | undefined, contextIds: IContextIds, processorState: {
41
48
  [id: string]: unknown;
42
- }, loggingComponentType?: string): Promise<void>;
49
+ }, componentTypes?: {
50
+ loggingComponentType?: string;
51
+ hostingComponentType?: string;
52
+ }): Promise<void>;
43
53
  }
@@ -12,10 +12,15 @@ export interface IRestRouteProcessor extends IBaseRouteProcessor<IRestRoute> {
12
12
  * @param response The response data to send if any.
13
13
  * @param route The route being requested, if a matching one was found.
14
14
  * @param processorState The state handed through the processors.
15
- * @param loggingComponentType The logging component type for the request.
15
+ * @param componentTypes The component types for the request.
16
+ * @param componentTypes.loggingComponentType The logging component type.
17
+ * @param componentTypes.hostingComponentType The hosting component type.
16
18
  * @returns Promise that resolves when the request is processed.
17
19
  */
18
20
  process?(request: IHttpServerRequest, response: IHttpResponse, route: IRestRoute | undefined, processorState: {
19
21
  [id: string]: unknown;
20
- }, loggingComponentType?: string): Promise<void>;
22
+ }, componentTypes?: {
23
+ loggingComponentType?: string;
24
+ hostingComponentType?: string;
25
+ }): Promise<void>;
21
26
  }
@@ -0,0 +1,18 @@
1
+ import type { HealthStatus } from "./healthStatus.js";
2
+ /**
3
+ * The health component information.
4
+ */
5
+ export interface IHealthComponentInfo {
6
+ /**
7
+ * The name of the component.
8
+ */
9
+ name: string;
10
+ /**
11
+ * The status of the component.
12
+ */
13
+ status: HealthStatus;
14
+ /**
15
+ * The details for the status.
16
+ */
17
+ details?: string;
18
+ }
@@ -1,4 +1,5 @@
1
1
  import type { HealthStatus } from "./healthStatus.js";
2
+ import type { IHealthComponentInfo } from "./IHealthComponentInfo.js";
2
3
  /**
3
4
  * The status of the server.
4
5
  */
@@ -10,18 +11,5 @@ export interface IHealthInfo {
10
11
  /**
11
12
  * The status of the components.
12
13
  */
13
- components?: {
14
- /**
15
- * The name of the component.
16
- */
17
- name: string;
18
- /**
19
- * The status of the component.
20
- */
21
- status: HealthStatus;
22
- /**
23
- * The details for the status.
24
- */
25
- details?: string;
26
- }[];
14
+ components?: IHealthComponentInfo[];
27
15
  }
@@ -0,0 +1,24 @@
1
+ import type { IComponent } from "@twin.org/core";
2
+ /**
3
+ * The information about the hosting of the API.
4
+ */
5
+ export interface IHostingComponent extends IComponent {
6
+ /**
7
+ * Get the public origin for the hosting.
8
+ * @param serverRequestUrl The url of the current server request if there is one.
9
+ * @returns The public origin.
10
+ */
11
+ getPublicOrigin(serverRequestUrl?: string): Promise<string>;
12
+ /**
13
+ * Get the public origin for the tenant if one exists.
14
+ * @param tenantId The tenant identifier.
15
+ * @returns The public origin for the tenant.
16
+ */
17
+ getTenantOrigin(tenantId: string): Promise<string | undefined>;
18
+ /**
19
+ * Build a public url based on the public origin and the url provided.
20
+ * @param url The url to build upon the public origin.
21
+ * @returns The full url based on the public origin.
22
+ */
23
+ buildPublicUrl(url: string): Promise<string>;
24
+ }
@@ -26,6 +26,11 @@ export interface IInformationComponent extends IComponent {
26
26
  * @returns The OpenAPI spec.
27
27
  */
28
28
  spec(): Promise<unknown>;
29
+ /**
30
+ * Is the server live.
31
+ * @returns True if the server is live.
32
+ */
33
+ livez(): Promise<boolean>;
29
34
  /**
30
35
  * Get the server health.
31
36
  * @returns The service health.
@@ -36,13 +41,15 @@ export interface IInformationComponent extends IComponent {
36
41
  * @param name The component name.
37
42
  * @param status The status of the component.
38
43
  * @param details The details for the status.
44
+ * @param tenantId The tenant id, optional if the health status is not tenant specific.
39
45
  * @returns Nothing.
40
46
  */
41
- setComponentHealth(name: string, status: HealthStatus, details?: string): Promise<void>;
47
+ setComponentHealth(name: string, status: HealthStatus, details?: string, tenantId?: string): Promise<void>;
42
48
  /**
43
49
  * Remove the status of a component.
44
50
  * @param name The component name.
51
+ * @param tenantId The tenant id, optional if the health status is not tenant specific.
45
52
  * @returns Nothing.
46
53
  */
47
- removeComponentHealth(name: string): Promise<void>;
54
+ removeComponentHealth(name: string, tenantId?: string): Promise<void>;
48
55
  }
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Model defining the tenant.
3
+ */
4
+ export interface ITenant {
5
+ /**
6
+ * The unique identifier for the tenant.
7
+ */
8
+ id: string;
9
+ /**
10
+ * The api key for the tenant.
11
+ */
12
+ apiKey: string;
13
+ /**
14
+ * The label of the tenant.
15
+ */
16
+ label: string;
17
+ /**
18
+ * The date the tenant was created.
19
+ */
20
+ dateCreated: string;
21
+ /**
22
+ * The date the tenant was modified.
23
+ */
24
+ dateModified: string;
25
+ /**
26
+ * The public origin available to the public for accessing the API.
27
+ */
28
+ publicOrigin?: string;
29
+ /**
30
+ * Indicates whether the tenant is the node tenant.
31
+ */
32
+ isNodeTenant: boolean;
33
+ }
@@ -0,0 +1,63 @@
1
+ import type { IComponent } from "@twin.org/core";
2
+ import type { ITenant } from "./ITenant.js";
3
+ /**
4
+ * Configuration for the tenant admin component
5
+ */
6
+ export interface ITenantAdminComponent extends IComponent {
7
+ /**
8
+ * Create a tenant.
9
+ * @param tenant The tenant to store.
10
+ * @returns The tenant id.
11
+ */
12
+ create(tenant: Omit<ITenant, "id" | "dateCreated" | "dateModified"> & {
13
+ id?: string;
14
+ }): Promise<string>;
15
+ /**
16
+ * Update a tenant.
17
+ * @param tenant The tenant to update.
18
+ * @returns Nothing.
19
+ */
20
+ update(tenant: Partial<Omit<ITenant, "dateCreated" | "dateModified">>): Promise<void>;
21
+ /**
22
+ * Get a tenant by its id.
23
+ * @param tenantId The id of the tenant.
24
+ * @returns The tenant.
25
+ * @throws Error if the tenant is not found.
26
+ */
27
+ get(tenantId: string): Promise<ITenant>;
28
+ /**
29
+ * Get a tenant by its api key.
30
+ * @param apiKey The api key of the tenant.
31
+ * @returns The tenant.
32
+ * @throws Error if the tenant is not found.
33
+ */
34
+ getByApiKey(apiKey: string): Promise<ITenant>;
35
+ /**
36
+ * Get a tenant by its public origin.
37
+ * @param publicOrigin The origin of the tenant.
38
+ * @returns The tenant.
39
+ * @throws Error if the tenant is not found.
40
+ */
41
+ getByPublicOrigin(publicOrigin: string): Promise<ITenant>;
42
+ /**
43
+ * Remove a tenant by its id.
44
+ * @param tenantId The id of the tenant.
45
+ * @returns Nothing.
46
+ * @throws Error if the tenant is not found.
47
+ */
48
+ remove(tenantId: string): Promise<void>;
49
+ /**
50
+ * Query tenants with pagination.
51
+ * @param options Optional query options.
52
+ * @param options.isNodeTenant Whether to filter for node admin tenants.
53
+ * @param cursor The cursor to start from.
54
+ * @param limit The maximum number of tenants to return.
55
+ * @returns The tenants and the next cursor if more tenants are available.
56
+ */
57
+ query(options?: {
58
+ isNodeTenant?: boolean;
59
+ }, cursor?: string, limit?: number): Promise<{
60
+ tenants: ITenant[];
61
+ cursor?: string;
62
+ }>;
63
+ }
package/docs/changelog.md CHANGED
@@ -1,4 +1,168 @@
1
- # @twin.org/api-models - Changelog
1
+ # Changelog
2
+
3
+ ## [0.0.3-next.21](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.20...api-models-v0.0.3-next.21) (2026-03-11)
4
+
5
+
6
+ ### Miscellaneous Chores
7
+
8
+ * **api-models:** Synchronize repo versions
9
+
10
+ ## [0.0.3-next.20](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.19...api-models-v0.0.3-next.20) (2026-02-09)
11
+
12
+
13
+ ### Miscellaneous Chores
14
+
15
+ * **api-models:** Synchronize repo versions
16
+
17
+ ## [0.0.3-next.19](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.18...api-models-v0.0.3-next.19) (2026-02-06)
18
+
19
+
20
+ ### Miscellaneous Chores
21
+
22
+ * **api-models:** Synchronize repo versions
23
+
24
+ ## [0.0.3-next.18](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.17...api-models-v0.0.3-next.18) (2026-02-04)
25
+
26
+
27
+ ### Features
28
+
29
+ * tenant api and scopes ([#75](https://github.com/twinfoundation/api/issues/75)) ([c663141](https://github.com/twinfoundation/api/commit/c663141091e8974d769f8f9904ecdab009ebd083))
30
+
31
+ ## [0.0.3-next.17](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.16...api-models-v0.0.3-next.17) (2026-01-26)
32
+
33
+
34
+ ### Features
35
+
36
+ * update public origin building ([6c8e042](https://github.com/twinfoundation/api/commit/6c8e0422d9ddbed42a843e1c23498c99977b2fc7))
37
+
38
+ ## [0.0.3-next.16](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.15...api-models-v0.0.3-next.16) (2026-01-26)
39
+
40
+
41
+ ### Features
42
+
43
+ * public base url ([#70](https://github.com/twinfoundation/api/issues/70)) ([5b958cd](https://github.com/twinfoundation/api/commit/5b958cd91e8a38cdae2835ff5f2356c7e48d37c3))
44
+
45
+ ## [0.0.3-next.15](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.14...api-models-v0.0.3-next.15) (2026-01-22)
46
+
47
+
48
+ ### Miscellaneous Chores
49
+
50
+ * **api-models:** Synchronize repo versions
51
+
52
+ ## [0.0.3-next.14](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.13...api-models-v0.0.3-next.14) (2026-01-20)
53
+
54
+
55
+ ### Features
56
+
57
+ * export error type map ([#68](https://github.com/twinfoundation/api/issues/68)) ([697dfc4](https://github.com/twinfoundation/api/commit/697dfc4c9f6a7be493bf4b3619d7bcebf2e4584e))
58
+
59
+ ## [0.0.3-next.13](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.12...api-models-v0.0.3-next.13) (2026-01-19)
60
+
61
+
62
+ ### Features
63
+
64
+ * remove authentication generators ([#66](https://github.com/twinfoundation/api/issues/66)) ([adaa169](https://github.com/twinfoundation/api/commit/adaa1698df1c5ccb0ad645a7a7c0d3ef82ef6ac1))
65
+
66
+ ## [0.0.3-next.12](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.11...api-models-v0.0.3-next.12) (2026-01-12)
67
+
68
+
69
+ ### Miscellaneous Chores
70
+
71
+ * **api-models:** Synchronize repo versions
72
+
73
+ ## [0.0.3-next.11](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.10...api-models-v0.0.3-next.11) (2026-01-08)
74
+
75
+
76
+ ### Miscellaneous Chores
77
+
78
+ * **api-models:** Synchronize repo versions
79
+
80
+ ## [0.0.3-next.10](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.9...api-models-v0.0.3-next.10) (2026-01-05)
81
+
82
+
83
+ ### Miscellaneous Chores
84
+
85
+ * **api-models:** Synchronize repo versions
86
+
87
+ ## [0.0.3-next.9](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.8...api-models-v0.0.3-next.9) (2026-01-05)
88
+
89
+
90
+ ### Features
91
+
92
+ * add authentication generators and process features option ([a67edf1](https://github.com/twinfoundation/api/commit/a67edf1df212bd8ab94a40cddf5338551155696f))
93
+ * add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
94
+ * add livez endpoint ([#57](https://github.com/twinfoundation/api/issues/57)) ([ef007db](https://github.com/twinfoundation/api/commit/ef007db8201736dd3053211f849ffd03baaa485e))
95
+ * add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
96
+ * add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
97
+ * add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
98
+ * add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
99
+ * decodeURIComponent for query and path params ([ead68a2](https://github.com/twinfoundation/api/commit/ead68a257425c10dd912497f7edd473c469ca132))
100
+ * eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
101
+ * update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
102
+ * update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
103
+ * update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
104
+ * use new includeStackTrace flag for toJsonObject ([6452b15](https://github.com/twinfoundation/api/commit/6452b153af786eee14b21152420f8a2578b70593))
105
+ * use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
106
+ * validationError mapped to http status badrequest ([adc5eb1](https://github.com/twinfoundation/api/commit/adc5eb11d987abb0ab9f7e0dc8e1fdae207e436e))
107
+
108
+
109
+ ### Bug Fixes
110
+
111
+ * error handling make sure primary error takes precedence ([84b61f2](https://github.com/twinfoundation/api/commit/84b61f27fe5e4919c0c9f9a1edc8ff46dc45c1f7))
112
+
113
+ ## [0.0.3-next.8](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.7...api-models-v0.0.3-next.8) (2025-12-17)
114
+
115
+
116
+ ### Miscellaneous Chores
117
+
118
+ * **api-models:** Synchronize repo versions
119
+
120
+ ## [0.0.3-next.7](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.6...api-models-v0.0.3-next.7) (2025-11-26)
121
+
122
+
123
+ ### Bug Fixes
124
+
125
+ * error handling make sure primary error takes precedence ([84b61f2](https://github.com/twinfoundation/api/commit/84b61f27fe5e4919c0c9f9a1edc8ff46dc45c1f7))
126
+
127
+ ## [0.0.3-next.6](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.5...api-models-v0.0.3-next.6) (2025-11-20)
128
+
129
+
130
+ ### Miscellaneous Chores
131
+
132
+ * **api-models:** Synchronize repo versions
133
+
134
+ ## [0.0.3-next.5](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.4...api-models-v0.0.3-next.5) (2025-11-14)
135
+
136
+
137
+ ### Features
138
+
139
+ * decodeURIComponent for query and path params ([ead68a2](https://github.com/twinfoundation/api/commit/ead68a257425c10dd912497f7edd473c469ca132))
140
+
141
+ ## [0.0.3-next.4](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.3...api-models-v0.0.3-next.4) (2025-11-14)
142
+
143
+
144
+ ### Features
145
+
146
+ * add authentication generators and process features option ([a67edf1](https://github.com/twinfoundation/api/commit/a67edf1df212bd8ab94a40cddf5338551155696f))
147
+ * add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
148
+ * add logging component type to request contexts ([210de1b](https://github.com/twinfoundation/api/commit/210de1b9e1c91079b59a2b90ddd57569668d647d))
149
+ * add root, favicon routes ([71da1c3](https://github.com/twinfoundation/api/commit/71da1c3a93c349588aff7084d1d8d6a29a277da8))
150
+ * add socket id, connect and disconnect ([20b0d0e](https://github.com/twinfoundation/api/commit/20b0d0ec279cab46141fee09de2c4a7087cdce16))
151
+ * add validate-locales ([cdba610](https://github.com/twinfoundation/api/commit/cdba610a0acb5022d2e3ce729732e6646a297e5e))
152
+ * eslint migration to flat config ([0dd5820](https://github.com/twinfoundation/api/commit/0dd5820e3af97350fd08b8d226f4a6c1a9246805))
153
+ * update dependencies ([1171dc4](https://github.com/twinfoundation/api/commit/1171dc416a9481737f6a640e3cf30145768f37e9))
154
+ * update framework core ([d8eebf2](https://github.com/twinfoundation/api/commit/d8eebf267fa2a0abaa84e58590496e9d20490cfa))
155
+ * update IComponent signatures ([915ce37](https://github.com/twinfoundation/api/commit/915ce37712326ab4aa6869c350eabaa4622e8430))
156
+ * use new includeStackTrace flag for toJsonObject ([6452b15](https://github.com/twinfoundation/api/commit/6452b153af786eee14b21152420f8a2578b70593))
157
+ * use shared store mechanism ([#19](https://github.com/twinfoundation/api/issues/19)) ([32116df](https://github.com/twinfoundation/api/commit/32116df3b4380a30137f5056f242a5c99afa2df9))
158
+ * validationError mapped to http status badrequest ([adc5eb1](https://github.com/twinfoundation/api/commit/adc5eb11d987abb0ab9f7e0dc8e1fdae207e436e))
159
+
160
+ ## [0.0.3-next.3](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.2...api-models-v0.0.3-next.3) (2025-11-14)
161
+
162
+
163
+ ### Miscellaneous Chores
164
+
165
+ * **api-models:** Synchronize repo versions
2
166
 
3
167
  ## [0.0.3-next.2](https://github.com/twinfoundation/api/compare/api-models-v0.0.3-next.1...api-models-v0.0.3-next.2) (2025-11-12)
4
168
 
package/docs/examples.md CHANGED
@@ -1 +1,63 @@
1
- # @twin.org/api-models - Examples
1
+ # Models Examples
2
+
3
+ These snippets show practical helpers for URL manipulation, request parameter conversion, and consistent error responses.
4
+
5
+ ## HttpUrlHelper
6
+
7
+ ```typescript
8
+ import { HttpUrlHelper } from '@twin.org/api-models';
9
+
10
+ const fullUrl = 'https://tenant.example.org/orders?page=2';
11
+
12
+ console.log(HttpUrlHelper.extractOrigin(fullUrl)); // https://tenant.example.org
13
+ console.log(HttpUrlHelper.extractPath(fullUrl)); // /orders
14
+ console.log(HttpUrlHelper.extractSearch(fullUrl)); // ?page=2
15
+ console.log(HttpUrlHelper.extractPathAndSearch(fullUrl)); // /orders?page=2
16
+ ```
17
+
18
+ ```typescript
19
+ import { HttpUrlHelper } from '@twin.org/api-models';
20
+
21
+ const combined = HttpUrlHelper.combineParts('https://tenant.example.org/', '/api/v1/orders');
22
+ const replaced = HttpUrlHelper.replaceOrigin(combined ?? '', 'https://edge.example.org');
23
+
24
+ console.log(combined); // https://tenant.example.org/api/v1/orders
25
+ console.log(replaced); // https://edge.example.org/api/v1/orders
26
+ ```
27
+
28
+ ## HttpParameterHelper
29
+
30
+ ```typescript
31
+ import { HttpParameterHelper } from '@twin.org/api-models';
32
+
33
+ const ids = HttpParameterHelper.arrayFromString('id-1,id-2,id-3');
34
+ const idsAsString = HttpParameterHelper.arrayToString(ids);
35
+
36
+ const filterObject = HttpParameterHelper.objectFromString('{"status":"active"}');
37
+ const filterString = HttpParameterHelper.objectToString(filterObject);
38
+
39
+ console.log(ids.length); // 3
40
+ console.log(idsAsString); // id-1,id-2,id-3
41
+ console.log(filterString); // {"status":"active"}
42
+ ```
43
+
44
+ ## HttpErrorHelper
45
+
46
+ ```typescript
47
+ import { HttpErrorHelper } from '@twin.org/api-models';
48
+
49
+ try {
50
+ throw new Error('Invalid request');
51
+ } catch (err) {
52
+ const mapped = HttpErrorHelper.processError(err, false);
53
+ const response: {
54
+ body?: unknown;
55
+ statusCode?: number;
56
+ headers?: { [id: string]: string };
57
+ } = {};
58
+ HttpErrorHelper.buildResponse(response, mapped.error, mapped.httpStatusCode);
59
+
60
+ console.log(response.statusCode); // 500
61
+ console.log(mapped.error.message); // Error: Invalid request
62
+ }
63
+ ```
@@ -12,6 +12,18 @@ Class to help with processing http errors.
12
12
 
13
13
  `HttpErrorHelper`
14
14
 
15
+ ## Properties
16
+
17
+ ### ERROR\_TYPE\_MAP
18
+
19
+ > `readonly` `static` **ERROR\_TYPE\_MAP**: `object`
20
+
21
+ Mapping of error types to status codes.
22
+
23
+ #### Index Signature
24
+
25
+ \[`id`: `string`\]: `HttpStatusCode`
26
+
15
27
  ## Methods
16
28
 
17
29
  ### processError()