@twin.org/api-tenant-processor 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 (87) hide show
  1. package/README.md +1 -1
  2. package/dist/es/entities/tenant.js +25 -1
  3. package/dist/es/entities/tenant.js.map +1 -1
  4. package/dist/es/index.js +10 -2
  5. package/dist/es/index.js.map +1 -1
  6. package/dist/es/models/api/ITenantCreateRequest.js +2 -0
  7. package/dist/es/models/api/ITenantCreateRequest.js.map +1 -0
  8. package/dist/es/models/api/ITenantGetByApiKeyRequest.js +4 -0
  9. package/dist/es/models/api/ITenantGetByApiKeyRequest.js.map +1 -0
  10. package/dist/es/models/api/ITenantGetByIdRequest.js +4 -0
  11. package/dist/es/models/api/ITenantGetByIdRequest.js.map +1 -0
  12. package/dist/es/models/api/ITenantGetByPublicOriginRequest.js +4 -0
  13. package/dist/es/models/api/ITenantGetByPublicOriginRequest.js.map +1 -0
  14. package/dist/es/models/api/ITenantGetResponse.js +2 -0
  15. package/dist/es/models/api/ITenantGetResponse.js.map +1 -0
  16. package/dist/es/models/api/ITenantListRequest.js +4 -0
  17. package/dist/es/models/api/ITenantListRequest.js.map +1 -0
  18. package/dist/es/models/api/ITenantListResponse.js +2 -0
  19. package/dist/es/models/api/ITenantListResponse.js.map +1 -0
  20. package/dist/es/models/api/ITenantRemoveRequest.js +4 -0
  21. package/dist/es/models/api/ITenantRemoveRequest.js.map +1 -0
  22. package/dist/es/models/api/ITenantUpdateRequest.js +2 -0
  23. package/dist/es/models/api/ITenantUpdateRequest.js.map +1 -0
  24. package/dist/es/restEntryPoints.js +10 -0
  25. package/dist/es/restEntryPoints.js.map +1 -0
  26. package/dist/es/tenantAdminService.js +112 -15
  27. package/dist/es/tenantAdminService.js.map +1 -1
  28. package/dist/es/tenantIdContextIdHandler.js +8 -1
  29. package/dist/es/tenantIdContextIdHandler.js.map +1 -1
  30. package/dist/es/tenantProcessor.js +26 -21
  31. package/dist/es/tenantProcessor.js.map +1 -1
  32. package/dist/es/tenantRoutes.js +396 -0
  33. package/dist/es/tenantRoutes.js.map +1 -0
  34. package/dist/es/utils/tenantIdHelper.js +3 -3
  35. package/dist/es/utils/tenantIdHelper.js.map +1 -1
  36. package/dist/types/entities/tenant.d.ts +12 -0
  37. package/dist/types/index.d.ts +10 -2
  38. package/dist/types/models/api/ITenantCreateRequest.d.ts +12 -0
  39. package/dist/types/models/api/ITenantGetByApiKeyRequest.d.ts +14 -0
  40. package/dist/types/models/api/ITenantGetByIdRequest.d.ts +14 -0
  41. package/dist/types/models/api/ITenantGetByPublicOriginRequest.d.ts +14 -0
  42. package/dist/types/models/api/ITenantGetResponse.d.ts +10 -0
  43. package/dist/types/models/api/ITenantListRequest.d.ts +18 -0
  44. package/dist/types/models/api/ITenantListResponse.d.ts +17 -0
  45. package/dist/types/models/api/ITenantRemoveRequest.d.ts +14 -0
  46. package/dist/types/models/api/ITenantUpdateRequest.d.ts +19 -0
  47. package/dist/types/restEntryPoints.d.ts +2 -0
  48. package/dist/types/tenantAdminService.d.ts +30 -10
  49. package/dist/types/tenantIdContextIdHandler.d.ts +5 -0
  50. package/dist/types/tenantRoutes.d.ts +77 -0
  51. package/docs/changelog.md +293 -1
  52. package/docs/examples.md +81 -1
  53. package/docs/reference/classes/Tenant.md +24 -0
  54. package/docs/reference/classes/TenantAdminService.md +93 -19
  55. package/docs/reference/classes/TenantIdContextIdHandler.md +18 -0
  56. package/docs/reference/functions/generateRestRoutesTenants.md +25 -0
  57. package/docs/reference/functions/tenantByApiKey.md +31 -0
  58. package/docs/reference/functions/tenantById.md +31 -0
  59. package/docs/reference/functions/tenantByPublicOrigin.md +31 -0
  60. package/docs/reference/functions/tenantCreate.md +31 -0
  61. package/docs/reference/functions/tenantList.md +31 -0
  62. package/docs/reference/functions/tenantRemove.md +31 -0
  63. package/docs/reference/functions/tenantUpdate.md +31 -0
  64. package/docs/reference/index.md +21 -2
  65. package/docs/reference/interfaces/ITenantAdminServiceConstructorOptions.md +0 -6
  66. package/docs/reference/interfaces/ITenantCreateRequest.md +17 -0
  67. package/docs/reference/interfaces/ITenantGetByApiKeyRequest.md +17 -0
  68. package/docs/reference/interfaces/ITenantGetByIdRequest.md +17 -0
  69. package/docs/reference/interfaces/ITenantGetByPublicOriginRequest.md +17 -0
  70. package/docs/reference/interfaces/ITenantGetResponse.md +11 -0
  71. package/docs/reference/interfaces/ITenantListRequest.md +23 -0
  72. package/docs/reference/interfaces/ITenantListResponse.md +23 -0
  73. package/docs/reference/interfaces/ITenantProcessorConfig.md +0 -6
  74. package/docs/reference/interfaces/ITenantProcessorConstructorOptions.md +0 -6
  75. package/docs/reference/interfaces/ITenantRemoveRequest.md +17 -0
  76. package/docs/reference/interfaces/ITenantUpdateRequest.md +25 -0
  77. package/docs/reference/variables/tagsTenants.md +5 -0
  78. package/locales/en.json +4 -0
  79. package/package.json +3 -3
  80. package/dist/es/models/ITenant.js +0 -4
  81. package/dist/es/models/ITenant.js.map +0 -1
  82. package/dist/es/models/ITenantAdminComponent.js +0 -2
  83. package/dist/es/models/ITenantAdminComponent.js.map +0 -1
  84. package/dist/types/models/ITenant.d.ts +0 -21
  85. package/dist/types/models/ITenantAdminComponent.d.ts +0 -41
  86. package/docs/reference/interfaces/ITenant.md +0 -35
  87. package/docs/reference/interfaces/ITenantAdminComponent.md +0 -123
@@ -0,0 +1,25 @@
1
+ # Interface: ITenantUpdateRequest
2
+
3
+ The tenant to update.
4
+
5
+ ## Properties
6
+
7
+ ### pathParams
8
+
9
+ > **pathParams**: `object`
10
+
11
+ The path parameters.
12
+
13
+ #### id
14
+
15
+ > **id**: `string`
16
+
17
+ The id of the tenant to update.
18
+
19
+ ***
20
+
21
+ ### body
22
+
23
+ > **body**: `Omit`\<`ITenant`, `"id"` \| `"dateCreated"` \| `"dateModified"`\>
24
+
25
+ The tenant to update.
@@ -0,0 +1,5 @@
1
+ # Variable: tagsTenants
2
+
3
+ > `const` **tagsTenants**: `ITag`[]
4
+
5
+ The tag to associate with the routes.
package/locales/en.json CHANGED
@@ -3,6 +3,10 @@
3
3
  "tenantProcessor": {
4
4
  "missingApiKey": "API key header or query param \"{keyName}\" is missing or invalid.",
5
5
  "apiKeyNotFound": "No node tenant found for API key \"{key}\"."
6
+ },
7
+ "tenantAdminService": {
8
+ "apiKeyAlreadyInUse": "The provided API key is already in use by another tenant.",
9
+ "tenantNotFound": "Tenant with ID \"{notFoundId}\" not found."
6
10
  }
7
11
  }
8
12
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@twin.org/api-tenant-processor",
3
- "version": "0.0.3-next.2",
4
- "description": "API Tenant Processor for converting and api key to a tenant id.",
3
+ "version": "0.0.3-next.21",
4
+ "description": "Tenant resolution services and route handlers that derive tenant context from API keys.",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/twinfoundation/api.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.2",
17
+ "@twin.org/api-models": "0.0.3-next.21",
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/entity": "next",
@@ -1,4 +0,0 @@
1
- // Copyright 2025 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
- export {};
4
- //# sourceMappingURL=ITenant.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ITenant.js","sourceRoot":"","sources":["../../../src/models/ITenant.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Model defining the tenant.\n */\nexport interface ITenant {\n\t/**\n\t * The unique identifier for the tenant.\n\t */\n\tid: string;\n\n\t/**\n\t * The api key for the tenant.\n\t */\n\tapiKey: string;\n\n\t/**\n\t * The label of the tenant.\n\t */\n\tlabel: string;\n\n\t/**\n\t * The date the tenant was created.\n\t */\n\tdateCreated: string;\n}\n"]}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=ITenantAdminComponent.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ITenantAdminComponent.js","sourceRoot":"","sources":["../../../src/models/ITenantAdminComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { ITenant } from \"./ITenant.js\";\n\n/**\n * Configuration for the tenant admin component\n */\nexport interface ITenantAdminComponent extends IComponent {\n\t/**\n\t * Get a tenant by its id.\n\t * @param tenantId The id of the tenant.\n\t * @returns The tenant or undefined if not found.\n\t */\n\tget(tenantId: string): Promise<ITenant | undefined>;\n\n\t/**\n\t * Get a tenant by its api key.\n\t * @param apiKey The api key of the tenant.\n\t * @returns The tenant or undefined if not found.\n\t */\n\tgetByApiKey(apiKey: string): Promise<ITenant | undefined>;\n\n\t/**\n\t * Set a tenant.\n\t * @param tenant The tenant to store.\n\t * @returns Nothing.\n\t */\n\tset(tenant: ITenant): Promise<void>;\n\n\t/**\n\t * Remove a tenant by its id.\n\t * @param tenantId The id of the tenant.\n\t * @returns Nothing.\n\t */\n\tremove(tenantId: string): Promise<void>;\n\n\t/**\n\t * Query tenants with pagination.\n\t * @param cursor The cursor to start from.\n\t * @param limit The maximum number of tenants to return.\n\t * @returns The tenants and the next cursor if more tenants are available.\n\t */\n\tquery(cursor?: string, limit?: number): Promise<{ tenants: ITenant[]; cursor?: string }>;\n}\n"]}
@@ -1,21 +0,0 @@
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
- }
@@ -1,41 +0,0 @@
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
- * Get a tenant by its id.
9
- * @param tenantId The id of the tenant.
10
- * @returns The tenant or undefined if not found.
11
- */
12
- get(tenantId: string): Promise<ITenant | undefined>;
13
- /**
14
- * Get a tenant by its api key.
15
- * @param apiKey The api key of the tenant.
16
- * @returns The tenant or undefined if not found.
17
- */
18
- getByApiKey(apiKey: string): Promise<ITenant | undefined>;
19
- /**
20
- * Set a tenant.
21
- * @param tenant The tenant to store.
22
- * @returns Nothing.
23
- */
24
- set(tenant: ITenant): Promise<void>;
25
- /**
26
- * Remove a tenant by its id.
27
- * @param tenantId The id of the tenant.
28
- * @returns Nothing.
29
- */
30
- remove(tenantId: string): Promise<void>;
31
- /**
32
- * Query tenants with pagination.
33
- * @param cursor The cursor to start from.
34
- * @param limit The maximum number of tenants to return.
35
- * @returns The tenants and the next cursor if more tenants are available.
36
- */
37
- query(cursor?: string, limit?: number): Promise<{
38
- tenants: ITenant[];
39
- cursor?: string;
40
- }>;
41
- }
@@ -1,35 +0,0 @@
1
- # Interface: ITenant
2
-
3
- Model defining the tenant.
4
-
5
- ## Properties
6
-
7
- ### id
8
-
9
- > **id**: `string`
10
-
11
- The unique identifier for the tenant.
12
-
13
- ***
14
-
15
- ### apiKey
16
-
17
- > **apiKey**: `string`
18
-
19
- The api key for the tenant.
20
-
21
- ***
22
-
23
- ### label
24
-
25
- > **label**: `string`
26
-
27
- The label of the tenant.
28
-
29
- ***
30
-
31
- ### dateCreated
32
-
33
- > **dateCreated**: `string`
34
-
35
- The date the tenant was created.
@@ -1,123 +0,0 @@
1
- # Interface: ITenantAdminComponent
2
-
3
- Configuration for the tenant admin component
4
-
5
- ## Extends
6
-
7
- - `IComponent`
8
-
9
- ## Methods
10
-
11
- ### get()
12
-
13
- > **get**(`tenantId`): `Promise`\<[`ITenant`](ITenant.md) \| `undefined`\>
14
-
15
- Get a tenant by its id.
16
-
17
- #### Parameters
18
-
19
- ##### tenantId
20
-
21
- `string`
22
-
23
- The id of the tenant.
24
-
25
- #### Returns
26
-
27
- `Promise`\<[`ITenant`](ITenant.md) \| `undefined`\>
28
-
29
- The tenant or undefined if not found.
30
-
31
- ***
32
-
33
- ### getByApiKey()
34
-
35
- > **getByApiKey**(`apiKey`): `Promise`\<[`ITenant`](ITenant.md) \| `undefined`\>
36
-
37
- Get a tenant by its api key.
38
-
39
- #### Parameters
40
-
41
- ##### apiKey
42
-
43
- `string`
44
-
45
- The api key of the tenant.
46
-
47
- #### Returns
48
-
49
- `Promise`\<[`ITenant`](ITenant.md) \| `undefined`\>
50
-
51
- The tenant or undefined if not found.
52
-
53
- ***
54
-
55
- ### set()
56
-
57
- > **set**(`tenant`): `Promise`\<`void`\>
58
-
59
- Set a tenant.
60
-
61
- #### Parameters
62
-
63
- ##### tenant
64
-
65
- [`ITenant`](ITenant.md)
66
-
67
- The tenant to store.
68
-
69
- #### Returns
70
-
71
- `Promise`\<`void`\>
72
-
73
- Nothing.
74
-
75
- ***
76
-
77
- ### remove()
78
-
79
- > **remove**(`tenantId`): `Promise`\<`void`\>
80
-
81
- Remove a tenant by its id.
82
-
83
- #### Parameters
84
-
85
- ##### tenantId
86
-
87
- `string`
88
-
89
- The id of the tenant.
90
-
91
- #### Returns
92
-
93
- `Promise`\<`void`\>
94
-
95
- Nothing.
96
-
97
- ***
98
-
99
- ### query()
100
-
101
- > **query**(`cursor?`, `limit?`): `Promise`\<\{ `tenants`: [`ITenant`](ITenant.md)[]; `cursor?`: `string`; \}\>
102
-
103
- Query tenants with pagination.
104
-
105
- #### Parameters
106
-
107
- ##### cursor?
108
-
109
- `string`
110
-
111
- The cursor to start from.
112
-
113
- ##### limit?
114
-
115
- `number`
116
-
117
- The maximum number of tenants to return.
118
-
119
- #### Returns
120
-
121
- `Promise`\<\{ `tenants`: [`ITenant`](ITenant.md)[]; `cursor?`: `string`; \}\>
122
-
123
- The tenants and the next cursor if more tenants are available.