@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,396 @@
1
+ import { Coerce, ComponentFactory, Guards, Is } from "@twin.org/core";
2
+ import { HeaderHelper, HeaderTypes, HttpStatusCode } from "@twin.org/web";
3
+ /**
4
+ * The source used when communicating about these routes.
5
+ */
6
+ const ROUTES_SOURCE = "tenantRoutes";
7
+ /**
8
+ * The tag to associate with the routes.
9
+ */
10
+ export const tagsTenants = [
11
+ {
12
+ name: "Tenants",
13
+ description: "Tenants endpoints for the REST server."
14
+ }
15
+ ];
16
+ /**
17
+ * The REST routes for tenant management.
18
+ * @param baseRouteName Prefix to prepend to the paths.
19
+ * @param componentName The name of the component to use in the routes stored in the ComponentFactory.
20
+ * @returns The generated routes.
21
+ */
22
+ export function generateRestRoutesTenants(baseRouteName, componentName) {
23
+ const tenantListRoute = {
24
+ operationId: "tenantList",
25
+ summary: "Get the list of tenants",
26
+ tag: tagsTenants[0].name,
27
+ method: "GET",
28
+ path: `${baseRouteName}/`,
29
+ handler: async (httpRequestContext, request) => tenantList(httpRequestContext, componentName, request),
30
+ responseType: [
31
+ {
32
+ type: "ITenantListResponse",
33
+ examples: [
34
+ {
35
+ id: "tenantListResponse",
36
+ description: "The response for the list tenants request.",
37
+ response: {
38
+ headers: {
39
+ [HeaderTypes.Link]: '<https://api.twin.org/tenants/1>; rel="next"'
40
+ },
41
+ body: [
42
+ {
43
+ id: "2a39d6e62d98aa5372432f2e5d2208d4",
44
+ apiKey: "ad7a5b0b816ca314b69c813ae1368232",
45
+ label: "node",
46
+ dateCreated: "2026-01-19T03:59:35.742Z",
47
+ dateModified: "2026-01-19T03:59:35.742Z",
48
+ publicOrigin: "https://example.com:4321",
49
+ isNodeTenant: false
50
+ }
51
+ ]
52
+ }
53
+ }
54
+ ]
55
+ }
56
+ ],
57
+ requiredScope: ["tenant-admin"]
58
+ };
59
+ const tenantGetByIdRoute = {
60
+ operationId: "tenantGetById",
61
+ summary: "Get the tenant by id",
62
+ tag: tagsTenants[0].name,
63
+ method: "GET",
64
+ path: `${baseRouteName}/:id`,
65
+ handler: async (httpRequestContext, request) => tenantById(httpRequestContext, componentName, request),
66
+ requestType: {
67
+ type: "ITenantGetByIdRequest",
68
+ examples: [
69
+ {
70
+ id: "tenantGetByIdRequestExample",
71
+ request: {
72
+ pathParams: {
73
+ id: "2a39d6e62d98aa5372432f2e5d2208d4"
74
+ }
75
+ }
76
+ }
77
+ ]
78
+ },
79
+ responseType: [
80
+ {
81
+ type: "ITenantGetResponse",
82
+ examples: [
83
+ {
84
+ id: "tenantGetByIdResponse",
85
+ description: "The response for the get tenant by id request.",
86
+ response: {
87
+ body: {
88
+ id: "2a39d6e62d98aa5372432f2e5d2208d4",
89
+ apiKey: "ad7a5b0b816ca314b69c813ae1368232",
90
+ label: "node",
91
+ dateCreated: "2026-01-19T03:59:35.742Z",
92
+ dateModified: "2026-01-19T03:59:35.742Z",
93
+ publicOrigin: "https://example.com:4321",
94
+ isNodeTenant: false
95
+ }
96
+ }
97
+ }
98
+ ]
99
+ }
100
+ ],
101
+ requiredScope: ["tenant-admin"]
102
+ };
103
+ const tenantGetByApiKeyRoute = {
104
+ operationId: "tenantGetByApiKey",
105
+ summary: "Get the tenant by api key",
106
+ tag: tagsTenants[0].name,
107
+ method: "GET",
108
+ path: `${baseRouteName}/api-key/:apiKey`,
109
+ handler: async (httpRequestContext, request) => tenantByApiKey(httpRequestContext, componentName, request),
110
+ responseType: [
111
+ {
112
+ type: "ITenantGetResponse",
113
+ examples: [
114
+ {
115
+ id: "tenantGetByApiKeyResponse",
116
+ description: "The response for the get tenant by api key request.",
117
+ response: {
118
+ body: {
119
+ id: "2a39d6e62d98aa5372432f2e5d2208d4",
120
+ apiKey: "ad7a5b0b816ca314b69c813ae1368232",
121
+ label: "node",
122
+ dateCreated: "2026-01-19T03:59:35.742Z",
123
+ dateModified: "2026-01-19T03:59:35.742Z",
124
+ publicOrigin: "https://example.com:4321",
125
+ isNodeTenant: false
126
+ }
127
+ }
128
+ }
129
+ ]
130
+ }
131
+ ],
132
+ requiredScope: ["tenant-admin"]
133
+ };
134
+ const tenantGetByPublicOriginRoute = {
135
+ operationId: "tenantGetByPublicOrigin",
136
+ summary: "Get the tenant by public origin",
137
+ tag: tagsTenants[0].name,
138
+ method: "GET",
139
+ path: `${baseRouteName}/public-origin/:publicOrigin`,
140
+ handler: async (httpRequestContext, request) => tenantByPublicOrigin(httpRequestContext, componentName, request),
141
+ responseType: [
142
+ {
143
+ type: "ITenantGetResponse",
144
+ examples: [
145
+ {
146
+ id: "tenantGetByPublicOriginResponse",
147
+ description: "The response for the get tenant by public origin request.",
148
+ response: {
149
+ body: {
150
+ id: "2a39d6e62d98aa5372432f2e5d2208d4",
151
+ apiKey: "ad7a5b0b816ca314b69c813ae1368232",
152
+ label: "node",
153
+ dateCreated: "2026-01-19T03:59:35.742Z",
154
+ publicOrigin: "https://example.com:4321"
155
+ }
156
+ }
157
+ }
158
+ ]
159
+ }
160
+ ],
161
+ requiredScope: ["tenant-admin"]
162
+ };
163
+ const tenantRemoveRoute = {
164
+ operationId: "tenantRemove",
165
+ summary: "Remove the tenant by id",
166
+ tag: tagsTenants[0].name,
167
+ method: "DELETE",
168
+ path: `${baseRouteName}/:id`,
169
+ handler: async (httpRequestContext, request) => tenantRemove(httpRequestContext, componentName, request),
170
+ requestType: {
171
+ type: "ITenantRemoveRequest",
172
+ examples: [
173
+ {
174
+ id: "tenantRemoveRequestExample",
175
+ description: "The request for the remove tenant by id request.",
176
+ request: {
177
+ pathParams: {
178
+ id: "2a39d6e62d98aa5372432f2e5d2208d4"
179
+ }
180
+ }
181
+ }
182
+ ]
183
+ },
184
+ responseType: [
185
+ {
186
+ type: "INoContentResponse"
187
+ }
188
+ ],
189
+ requiredScope: ["tenant-admin"]
190
+ };
191
+ const tenantCreateRoute = {
192
+ operationId: "tenantCreate",
193
+ summary: "Create a new tenant",
194
+ tag: tagsTenants[0].name,
195
+ method: "POST",
196
+ path: `${baseRouteName}/`,
197
+ handler: async (httpRequestContext, request) => tenantCreate(httpRequestContext, componentName, request),
198
+ requestType: {
199
+ type: "ITenantCreateRequest",
200
+ examples: [
201
+ {
202
+ id: "tenantCreateRequestExample",
203
+ description: "The request for the create tenant request.",
204
+ request: {
205
+ body: {
206
+ apiKey: "ad7a5b0b816ca314b69c813ae1368232",
207
+ label: "node",
208
+ publicOrigin: "https://example.com:4321",
209
+ isNodeTenant: false
210
+ }
211
+ }
212
+ }
213
+ ]
214
+ },
215
+ responseType: [
216
+ {
217
+ type: "ICreatedResponse"
218
+ }
219
+ ],
220
+ requiredScope: ["tenant-admin"]
221
+ };
222
+ const tenantUpdateRoute = {
223
+ operationId: "tenantUpdate",
224
+ summary: "Update an existing tenant",
225
+ tag: tagsTenants[0].name,
226
+ method: "PUT",
227
+ path: `${baseRouteName}/:id`,
228
+ handler: async (httpRequestContext, request) => tenantUpdate(httpRequestContext, componentName, request),
229
+ requestType: {
230
+ type: "ITenantUpdateRequest",
231
+ examples: [
232
+ {
233
+ id: "tenantUpdateRequestExample",
234
+ description: "The request for the update tenant request.",
235
+ request: {
236
+ pathParams: {
237
+ id: "2a39d6e62d98aa5372432f2e5d2208d4"
238
+ },
239
+ body: {
240
+ apiKey: "ad7a5b0b816ca314b69c813ae1368232",
241
+ label: "node",
242
+ publicOrigin: "https://example.com:4321",
243
+ isNodeTenant: false
244
+ }
245
+ }
246
+ }
247
+ ]
248
+ },
249
+ responseType: [
250
+ {
251
+ type: "INoContentResponse"
252
+ }
253
+ ],
254
+ requiredScope: ["tenant-admin"]
255
+ };
256
+ return [
257
+ tenantListRoute,
258
+ tenantCreateRoute,
259
+ tenantGetByIdRoute,
260
+ tenantGetByApiKeyRoute,
261
+ tenantGetByPublicOriginRoute,
262
+ tenantRemoveRoute,
263
+ tenantUpdateRoute
264
+ ];
265
+ }
266
+ /**
267
+ * Get the list of tenants.
268
+ * @param httpRequestContext The request context for the API.
269
+ * @param componentName The name of the component to use in the routes.
270
+ * @param request The request.
271
+ * @returns The response object with additional http response properties.
272
+ */
273
+ export async function tenantList(httpRequestContext, componentName, request) {
274
+ const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
275
+ const component = ComponentFactory.get(componentName);
276
+ const result = await component.query(undefined, request.query?.cursor, Coerce.integer(request.query?.limit));
277
+ const headers = {};
278
+ if (Is.stringValue(result.cursor)) {
279
+ headers[HeaderTypes.Link] = HeaderHelper.createLinkHeader(await hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url), { cursor: result.cursor }, "next");
280
+ }
281
+ const defaultPublicOrigin = await hostingComponent.getPublicOrigin(httpRequestContext.serverRequest.url);
282
+ return {
283
+ headers,
284
+ body: result.tenants.map(t => ({ ...t, publicOrigin: t.publicOrigin ?? defaultPublicOrigin }))
285
+ };
286
+ }
287
+ /**
288
+ * Get the tenant by id.
289
+ * @param httpRequestContext The request context for the API.
290
+ * @param componentName The name of the component to use in the routes.
291
+ * @param request The request.
292
+ * @returns The response object with additional http response properties.
293
+ */
294
+ export async function tenantById(httpRequestContext, componentName, request) {
295
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
296
+ const component = ComponentFactory.get(componentName);
297
+ const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
298
+ const result = await component.get(request.pathParams.id);
299
+ if (!Is.stringValue(result.publicOrigin)) {
300
+ const defaultPublicOrigin = await hostingComponent.getPublicOrigin(httpRequestContext.serverRequest.url);
301
+ result.publicOrigin ??= defaultPublicOrigin;
302
+ }
303
+ return {
304
+ body: result
305
+ };
306
+ }
307
+ /**
308
+ * Get the tenant by api key.
309
+ * @param httpRequestContext The request context for the API.
310
+ * @param componentName The name of the component to use in the routes.
311
+ * @param request The request.
312
+ * @returns The response object with additional http response properties.
313
+ */
314
+ export async function tenantByApiKey(httpRequestContext, componentName, request) {
315
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.apiKey", request.pathParams.apiKey);
316
+ const component = ComponentFactory.get(componentName);
317
+ const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
318
+ const result = await component.getByApiKey(request.pathParams.apiKey);
319
+ if (!Is.stringValue(result.publicOrigin)) {
320
+ const defaultPublicOrigin = await hostingComponent.getPublicOrigin(httpRequestContext.serverRequest.url);
321
+ result.publicOrigin ??= defaultPublicOrigin;
322
+ }
323
+ return {
324
+ body: result
325
+ };
326
+ }
327
+ /**
328
+ * Get the tenant by public origin.
329
+ * @param httpRequestContext The request context for the API.
330
+ * @param componentName The name of the component to use in the routes.
331
+ * @param request The request.
332
+ * @returns The response object with additional http response properties.
333
+ */
334
+ export async function tenantByPublicOrigin(httpRequestContext, componentName, request) {
335
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.publicOrigin", request.pathParams.publicOrigin);
336
+ const component = ComponentFactory.get(componentName);
337
+ const hostingComponent = ComponentFactory.get(httpRequestContext.hostingComponentType ?? "hosting");
338
+ const result = await component.getByPublicOrigin(request.pathParams.publicOrigin);
339
+ if (!Is.stringValue(result.publicOrigin)) {
340
+ const defaultPublicOrigin = await hostingComponent.getPublicOrigin(httpRequestContext.serverRequest.url);
341
+ result.publicOrigin ??= defaultPublicOrigin;
342
+ }
343
+ return {
344
+ body: result
345
+ };
346
+ }
347
+ /**
348
+ * Remove the tenant by id.
349
+ * @param httpRequestContext The request context for the API.
350
+ * @param componentName The name of the component to use in the routes.
351
+ * @param request The request.
352
+ * @returns The response object with additional http response properties.
353
+ */
354
+ export async function tenantRemove(httpRequestContext, componentName, request) {
355
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
356
+ const component = ComponentFactory.get(componentName);
357
+ await component.remove(request.pathParams.id);
358
+ return {
359
+ statusCode: HttpStatusCode.noContent
360
+ };
361
+ }
362
+ /**
363
+ * Create the tenant.
364
+ * @param httpRequestContext The request context for the API.
365
+ * @param componentName The name of the component to use in the routes.
366
+ * @param request The request.
367
+ * @returns The response object with additional http response properties.
368
+ */
369
+ export async function tenantCreate(httpRequestContext, componentName, request) {
370
+ Guards.stringValue(ROUTES_SOURCE, "request.body", request.body);
371
+ const component = ComponentFactory.get(componentName);
372
+ const createdId = await component.create(request.body);
373
+ return {
374
+ statusCode: HttpStatusCode.created,
375
+ headers: {
376
+ [HeaderTypes.Location]: createdId
377
+ }
378
+ };
379
+ }
380
+ /**
381
+ * Update the tenant.
382
+ * @param httpRequestContext The request context for the API.
383
+ * @param componentName The name of the component to use in the routes.
384
+ * @param request The request.
385
+ * @returns The response object with additional http response properties.
386
+ */
387
+ export async function tenantUpdate(httpRequestContext, componentName, request) {
388
+ Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
389
+ Guards.stringValue(ROUTES_SOURCE, "request.body", request.body);
390
+ const component = ComponentFactory.get(componentName);
391
+ await component.update(request.body);
392
+ return {
393
+ statusCode: HttpStatusCode.noContent
394
+ };
395
+ }
396
+ //# sourceMappingURL=tenantRoutes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tenantRoutes.js","sourceRoot":"","sources":["../../src/tenantRoutes.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAEtE,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAW1E;;GAEG;AACH,MAAM,aAAa,GAAG,cAAc,CAAC;AAErC;;GAEG;AACH,MAAM,CAAC,MAAM,WAAW,GAAW;IAClC;QACC,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,wCAAwC;KACrD;CACD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,yBAAyB,CACxC,aAAqB,EACrB,aAAqB;IAErB,MAAM,eAAe,GAAwD;QAC5E,WAAW,EAAE,YAAY;QACzB,OAAO,EAAE,yBAAyB;QAClC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,IAAI;QACxB,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,GAAG,aAAa,GAAG;QACzB,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,OAAO,EAAE,EAAE,CAC9C,UAAU,CAAC,kBAAkB,EAAE,aAAa,EAAE,OAAO,CAAC;QACvD,YAAY,EAAE;YACb;gBACC,IAAI,uBAA+B;gBACnC,QAAQ,EAAE;oBACT;wBACC,EAAE,EAAE,oBAAoB;wBACxB,WAAW,EAAE,4CAA4C;wBACzD,QAAQ,EAAE;4BACT,OAAO,EAAE;gCACR,CAAC,WAAW,CAAC,IAAI,CAAC,EAAE,8CAA8C;6BAClE;4BACD,IAAI,EAAE;gCACL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AC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,kBAAuC,EACvC,aAAqB,EACrB,OAA6B;IAE7B,MAAM,CAAC,WAAW,CAAC,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAwB,aAAa,CAAC,CAAC;IAE7E,MAAM,SAAS,GAAG,MAAM,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvD,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,OAAO;QAClC,OAAO,EAAE;YACR,CAAC,WAAW,CAAC,QAAQ,CAAC,EAAE,SAAS;SACjC;KACD,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CACjC,kBAAuC,EACvC,aAAqB,EACrB,OAA6B;IAE7B,MAAM,CAAC,WAAW,CAAC,aAAa,2BAAiC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;IACxF,MAAM,CAAC,WAAW,CAAC,aAAa,kBAAwB,OAAO,CAAC,IAAI,CAAC,CAAC;IACtE,MAAM,SAAS,GAAG,gBAAgB,CAAC,GAAG,CAAwB,aAAa,CAAC,CAAC;IAE7E,MAAM,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAErC,OAAO;QACN,UAAU,EAAE,cAAc,CAAC,SAAS;KACpC,CAAC;AACH,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tICreatedResponse,\n\tIHostingComponent,\n\tIHttpRequestContext,\n\tINoContentResponse,\n\tIRestRoute,\n\tITag,\n\tITenantAdminComponent\n} from \"@twin.org/api-models\";\nimport { Coerce, ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HeaderHelper, HeaderTypes, HttpStatusCode } from \"@twin.org/web\";\nimport type { ITenantCreateRequest } from \"./models/api/ITenantCreateRequest.js\";\nimport type { ITenantGetByApiKeyRequest } from \"./models/api/ITenantGetByApiKeyRequest.js\";\nimport type { ITenantGetByIdRequest } from \"./models/api/ITenantGetByIdRequest.js\";\nimport type { ITenantGetByPublicOriginRequest } from \"./models/api/ITenantGetByPublicOriginRequest.js\";\nimport type { ITenantGetResponse } from \"./models/api/ITenantGetResponse.js\";\nimport type { ITenantListRequest } from \"./models/api/ITenantListRequest.js\";\nimport type { ITenantListResponse } from \"./models/api/ITenantListResponse.js\";\nimport type { ITenantRemoveRequest } from \"./models/api/ITenantRemoveRequest.js\";\nimport type { ITenantUpdateRequest } from \"./models/api/ITenantUpdateRequest.js\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"tenantRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsTenants: ITag[] = [\n\t{\n\t\tname: \"Tenants\",\n\t\tdescription: \"Tenants endpoints for the REST server.\"\n\t}\n];\n\n/**\n * The REST routes for tenant management.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesTenants(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst tenantListRoute: IRestRoute<ITenantListRequest, ITenantListResponse> = {\n\t\toperationId: \"tenantList\",\n\t\tsummary: \"Get the list of tenants\",\n\t\ttag: tagsTenants[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\ttenantList(httpRequestContext, componentName, request),\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ITenantListResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"tenantListResponse\",\n\t\t\t\t\t\tdescription: \"The response for the list tenants request.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\theaders: {\n\t\t\t\t\t\t\t\t[HeaderTypes.Link]: '<https://api.twin.org/tenants/1>; rel=\"next\"'\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tbody: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\tid: \"2a39d6e62d98aa5372432f2e5d2208d4\",\n\t\t\t\t\t\t\t\t\tapiKey: \"ad7a5b0b816ca314b69c813ae1368232\",\n\t\t\t\t\t\t\t\t\tlabel: \"node\",\n\t\t\t\t\t\t\t\t\tdateCreated: \"2026-01-19T03:59:35.742Z\",\n\t\t\t\t\t\t\t\t\tdateModified: \"2026-01-19T03:59:35.742Z\",\n\t\t\t\t\t\t\t\t\tpublicOrigin: \"https://example.com:4321\",\n\t\t\t\t\t\t\t\t\tisNodeTenant: false\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t]\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"tenant-admin\"]\n\t};\n\n\tconst tenantGetByIdRoute: IRestRoute<ITenantGetByIdRequest, ITenantGetResponse> = {\n\t\toperationId: \"tenantGetById\",\n\t\tsummary: \"Get the tenant by id\",\n\t\ttag: tagsTenants[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\ttenantById(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ITenantGetByIdRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"tenantGetByIdRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"2a39d6e62d98aa5372432f2e5d2208d4\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ITenantGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"tenantGetByIdResponse\",\n\t\t\t\t\t\tdescription: \"The response for the get tenant by id request.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tid: \"2a39d6e62d98aa5372432f2e5d2208d4\",\n\t\t\t\t\t\t\t\tapiKey: \"ad7a5b0b816ca314b69c813ae1368232\",\n\t\t\t\t\t\t\t\tlabel: \"node\",\n\t\t\t\t\t\t\t\tdateCreated: \"2026-01-19T03:59:35.742Z\",\n\t\t\t\t\t\t\t\tdateModified: \"2026-01-19T03:59:35.742Z\",\n\t\t\t\t\t\t\t\tpublicOrigin: \"https://example.com:4321\",\n\t\t\t\t\t\t\t\tisNodeTenant: false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"tenant-admin\"]\n\t};\n\n\tconst tenantGetByApiKeyRoute: IRestRoute<ITenantGetByApiKeyRequest, ITenantGetResponse> = {\n\t\toperationId: \"tenantGetByApiKey\",\n\t\tsummary: \"Get the tenant by api key\",\n\t\ttag: tagsTenants[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/api-key/:apiKey`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\ttenantByApiKey(httpRequestContext, componentName, request),\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ITenantGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"tenantGetByApiKeyResponse\",\n\t\t\t\t\t\tdescription: \"The response for the get tenant by api key request.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tid: \"2a39d6e62d98aa5372432f2e5d2208d4\",\n\t\t\t\t\t\t\t\tapiKey: \"ad7a5b0b816ca314b69c813ae1368232\",\n\t\t\t\t\t\t\t\tlabel: \"node\",\n\t\t\t\t\t\t\t\tdateCreated: \"2026-01-19T03:59:35.742Z\",\n\t\t\t\t\t\t\t\tdateModified: \"2026-01-19T03:59:35.742Z\",\n\t\t\t\t\t\t\t\tpublicOrigin: \"https://example.com:4321\",\n\t\t\t\t\t\t\t\tisNodeTenant: false\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"tenant-admin\"]\n\t};\n\n\tconst tenantGetByPublicOriginRoute: IRestRoute = {\n\t\toperationId: \"tenantGetByPublicOrigin\",\n\t\tsummary: \"Get the tenant by public origin\",\n\t\ttag: tagsTenants[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/public-origin/:publicOrigin`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\ttenantByPublicOrigin(httpRequestContext, componentName, request),\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ITenantGetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"tenantGetByPublicOriginResponse\",\n\t\t\t\t\t\tdescription: \"The response for the get tenant by public origin request.\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tid: \"2a39d6e62d98aa5372432f2e5d2208d4\",\n\t\t\t\t\t\t\t\tapiKey: \"ad7a5b0b816ca314b69c813ae1368232\",\n\t\t\t\t\t\t\t\tlabel: \"node\",\n\t\t\t\t\t\t\t\tdateCreated: \"2026-01-19T03:59:35.742Z\",\n\t\t\t\t\t\t\t\tpublicOrigin: \"https://example.com:4321\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"tenant-admin\"]\n\t};\n\n\tconst tenantRemoveRoute: IRestRoute<ITenantRemoveRequest, INoContentResponse> = {\n\t\toperationId: \"tenantRemove\",\n\t\tsummary: \"Remove the tenant by id\",\n\t\ttag: tagsTenants[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\ttenantRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ITenantRemoveRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"tenantRemoveRequestExample\",\n\t\t\t\t\tdescription: \"The request for the remove tenant by id request.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"2a39d6e62d98aa5372432f2e5d2208d4\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"tenant-admin\"]\n\t};\n\n\tconst tenantCreateRoute: IRestRoute<ITenantCreateRequest, ICreatedResponse> = {\n\t\toperationId: \"tenantCreate\",\n\t\tsummary: \"Create a new tenant\",\n\t\ttag: tagsTenants[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\ttenantCreate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ITenantCreateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"tenantCreateRequestExample\",\n\t\t\t\t\tdescription: \"The request for the create tenant request.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tapiKey: \"ad7a5b0b816ca314b69c813ae1368232\",\n\t\t\t\t\t\t\tlabel: \"node\",\n\t\t\t\t\t\t\tpublicOrigin: \"https://example.com:4321\",\n\t\t\t\t\t\t\tisNodeTenant: false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICreatedResponse>()\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"tenant-admin\"]\n\t};\n\n\tconst tenantUpdateRoute: IRestRoute<ITenantUpdateRequest, INoContentResponse> = {\n\t\toperationId: \"tenantUpdate\",\n\t\tsummary: \"Update an existing tenant\",\n\t\ttag: tagsTenants[0].name,\n\t\tmethod: \"PUT\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\ttenantUpdate(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ITenantUpdateRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"tenantUpdateRequestExample\",\n\t\t\t\t\tdescription: \"The request for the update tenant request.\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"2a39d6e62d98aa5372432f2e5d2208d4\"\n\t\t\t\t\t\t},\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tapiKey: \"ad7a5b0b816ca314b69c813ae1368232\",\n\t\t\t\t\t\t\tlabel: \"node\",\n\t\t\t\t\t\t\tpublicOrigin: \"https://example.com:4321\",\n\t\t\t\t\t\t\tisNodeTenant: false\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t],\n\t\trequiredScope: [\"tenant-admin\"]\n\t};\n\n\treturn [\n\t\ttenantListRoute,\n\t\ttenantCreateRoute,\n\t\ttenantGetByIdRoute,\n\t\ttenantGetByApiKeyRoute,\n\t\ttenantGetByPublicOriginRoute,\n\t\ttenantRemoveRoute,\n\t\ttenantUpdateRoute\n\t];\n}\n\n/**\n * Get the list of tenants.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function tenantList(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITenantListRequest\n): Promise<ITenantListResponse> {\n\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\n\n\tconst component = ComponentFactory.get<ITenantAdminComponent>(componentName);\n\n\tconst result = await component.query(\n\t\tundefined,\n\t\trequest.query?.cursor,\n\t\tCoerce.integer(request.query?.limit)\n\t);\n\n\tconst headers: ITenantListResponse[\"headers\"] = {};\n\n\tif (Is.stringValue(result.cursor)) {\n\t\theaders[HeaderTypes.Link] = HeaderHelper.createLinkHeader(\n\t\t\tawait hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url),\n\t\t\t{ cursor: result.cursor },\n\t\t\t\"next\"\n\t\t);\n\t}\n\n\tconst defaultPublicOrigin = await hostingComponent.getPublicOrigin(\n\t\thttpRequestContext.serverRequest.url\n\t);\n\n\treturn {\n\t\theaders,\n\t\tbody: result.tenants.map(t => ({ ...t, publicOrigin: t.publicOrigin ?? defaultPublicOrigin }))\n\t};\n}\n\n/**\n * Get the tenant by id.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function tenantById(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITenantGetByIdRequest\n): Promise<ITenantGetResponse> {\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tconst component = ComponentFactory.get<ITenantAdminComponent>(componentName);\n\n\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\n\n\tconst result = await component.get(request.pathParams.id);\n\n\tif (!Is.stringValue(result.publicOrigin)) {\n\t\tconst defaultPublicOrigin = await hostingComponent.getPublicOrigin(\n\t\t\thttpRequestContext.serverRequest.url\n\t\t);\n\n\t\tresult.publicOrigin ??= defaultPublicOrigin;\n\t}\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Get the tenant by api key.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function tenantByApiKey(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITenantGetByApiKeyRequest\n): Promise<ITenantGetResponse> {\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.apiKey), request.pathParams.apiKey);\n\tconst component = ComponentFactory.get<ITenantAdminComponent>(componentName);\n\n\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\n\n\tconst result = await component.getByApiKey(request.pathParams.apiKey);\n\n\tif (!Is.stringValue(result.publicOrigin)) {\n\t\tconst defaultPublicOrigin = await hostingComponent.getPublicOrigin(\n\t\t\thttpRequestContext.serverRequest.url\n\t\t);\n\n\t\tresult.publicOrigin ??= defaultPublicOrigin;\n\t}\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Get the tenant by public origin.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function tenantByPublicOrigin(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITenantGetByPublicOriginRequest\n): Promise<ITenantGetResponse> {\n\tGuards.stringValue(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams.publicOrigin),\n\t\trequest.pathParams.publicOrigin\n\t);\n\tconst component = ComponentFactory.get<ITenantAdminComponent>(componentName);\n\n\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t);\n\n\tconst result = await component.getByPublicOrigin(request.pathParams.publicOrigin);\n\n\tif (!Is.stringValue(result.publicOrigin)) {\n\t\tconst defaultPublicOrigin = await hostingComponent.getPublicOrigin(\n\t\t\thttpRequestContext.serverRequest.url\n\t\t);\n\n\t\tresult.publicOrigin ??= defaultPublicOrigin;\n\t}\n\n\treturn {\n\t\tbody: result\n\t};\n}\n\n/**\n * Remove the tenant by id.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function tenantRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITenantRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tconst component = ComponentFactory.get<ITenantAdminComponent>(componentName);\n\n\tawait component.remove(request.pathParams.id);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Create the tenant.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function tenantCreate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITenantCreateRequest\n): Promise<ICreatedResponse> {\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.body), request.body);\n\tconst component = ComponentFactory.get<ITenantAdminComponent>(componentName);\n\n\tconst createdId = await component.create(request.body);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.created,\n\t\theaders: {\n\t\t\t[HeaderTypes.Location]: createdId\n\t\t}\n\t};\n}\n\n/**\n * Update the tenant.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function tenantUpdate(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ITenantUpdateRequest\n): Promise<INoContentResponse> {\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.body), request.body);\n\tconst component = ComponentFactory.get<ITenantAdminComponent>(componentName);\n\n\tawait component.update(request.body);\n\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  // Copyright 2025 IOTA Stiftung.
2
2
  // SPDX-License-Identifier: Apache-2.0.
3
- import { Converter, RandomHelper } from "@twin.org/core";
3
+ import { RandomHelper } from "@twin.org/core";
4
4
  /**
5
5
  * Helper class for tenant id related operations.
6
6
  */
@@ -10,14 +10,14 @@ export class TenantIdHelper {
10
10
  * @returns A new tenant ID.
11
11
  */
12
12
  static generateTenantId() {
13
- return Converter.bytesToHex(RandomHelper.generate(16));
13
+ return RandomHelper.generateUuidV7("compact");
14
14
  }
15
15
  /**
16
16
  * Generates a new API Key.
17
17
  * @returns A new API Key.
18
18
  */
19
19
  static generateApiKey() {
20
- return Converter.bytesToHex(RandomHelper.generate(16));
20
+ return RandomHelper.generateUuidV7("compact");
21
21
  }
22
22
  }
23
23
  //# sourceMappingURL=tenantIdHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tenantIdHelper.js","sourceRoot":"","sources":["../../../src/utils/tenantIdHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAEzD;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;;OAGG;IACI,MAAM,CAAC,gBAAgB;QAC7B,OAAO,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,cAAc;QAC3B,OAAO,SAAS,CAAC,UAAU,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC;IACxD,CAAC;CACD","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Converter, RandomHelper } from \"@twin.org/core\";\n\n/**\n * Helper class for tenant id related operations.\n */\nexport class TenantIdHelper {\n\t/**\n\t * Generates a new tenant ID.\n\t * @returns A new tenant ID.\n\t */\n\tpublic static generateTenantId(): string {\n\t\treturn Converter.bytesToHex(RandomHelper.generate(16));\n\t}\n\n\t/**\n\t * Generates a new API Key.\n\t * @returns A new API Key.\n\t */\n\tpublic static generateApiKey(): string {\n\t\treturn Converter.bytesToHex(RandomHelper.generate(16));\n\t}\n}\n"]}
1
+ {"version":3,"file":"tenantIdHelper.js","sourceRoot":"","sources":["../../../src/utils/tenantIdHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAE9C;;GAEG;AACH,MAAM,OAAO,cAAc;IAC1B;;;OAGG;IACI,MAAM,CAAC,gBAAgB;QAC7B,OAAO,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,cAAc;QAC3B,OAAO,YAAY,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAC/C,CAAC;CACD","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { RandomHelper } from \"@twin.org/core\";\n\n/**\n * Helper class for tenant id related operations.\n */\nexport class TenantIdHelper {\n\t/**\n\t * Generates a new tenant ID.\n\t * @returns A new tenant ID.\n\t */\n\tpublic static generateTenantId(): string {\n\t\treturn RandomHelper.generateUuidV7(\"compact\");\n\t}\n\n\t/**\n\t * Generates a new API Key.\n\t * @returns A new API Key.\n\t */\n\tpublic static generateApiKey(): string {\n\t\treturn RandomHelper.generateUuidV7(\"compact\");\n\t}\n}\n"]}
@@ -18,4 +18,16 @@ export declare class Tenant {
18
18
  * The date the tenant was created.
19
19
  */
20
20
  dateCreated: string;
21
+ /**
22
+ * The date the tenant was modified.
23
+ */
24
+ dateModified: string;
25
+ /**
26
+ * The 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;
21
33
  }
@@ -1,6 +1,13 @@
1
1
  export * from "./entities/tenant.js";
2
- export * from "./models/ITenant.js";
3
- export * from "./models/ITenantAdminComponent.js";
2
+ export * from "./models/api/ITenantCreateRequest.js";
3
+ export * from "./models/api/ITenantGetByApiKeyRequest.js";
4
+ export * from "./models/api/ITenantGetByIdRequest.js";
5
+ export * from "./models/api/ITenantGetByPublicOriginRequest.js";
6
+ export * from "./models/api/ITenantGetResponse.js";
7
+ export * from "./models/api/ITenantListRequest.js";
8
+ export * from "./models/api/ITenantListResponse.js";
9
+ export * from "./models/api/ITenantRemoveRequest.js";
10
+ export * from "./models/api/ITenantUpdateRequest.js";
4
11
  export * from "./models/ITenantAdminServiceConfig.js";
5
12
  export * from "./models/ITenantAdminServiceConstructorOptions.js";
6
13
  export * from "./models/ITenantProcessorConfig.js";
@@ -9,4 +16,5 @@ export * from "./schema.js";
9
16
  export * from "./tenantAdminService.js";
10
17
  export * from "./tenantIdContextIdHandler.js";
11
18
  export * from "./tenantProcessor.js";
19
+ export * from "./tenantRoutes.js";
12
20
  export * from "./utils/tenantIdHelper.js";
@@ -0,0 +1,12 @@
1
+ import type { ITenant } from "@twin.org/api-models";
2
+ /**
3
+ * The tenant to create.
4
+ */
5
+ export interface ITenantCreateRequest {
6
+ /**
7
+ * The tenant to create.
8
+ */
9
+ body: Omit<ITenant, "id" | "dateCreated" | "dateModified"> & {
10
+ id?: string;
11
+ };
12
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The tenant to get by API key.
3
+ */
4
+ export interface ITenantGetByApiKeyRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The API key of the tenant to get.
11
+ */
12
+ apiKey: string;
13
+ };
14
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The tenant to get by id.
3
+ */
4
+ export interface ITenantGetByIdRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The id of the tenant to get.
11
+ */
12
+ id: string;
13
+ };
14
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The tenant to get by public origin.
3
+ */
4
+ export interface ITenantGetByPublicOriginRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The public origin of the tenant to get.
11
+ */
12
+ publicOrigin: string;
13
+ };
14
+ }
@@ -0,0 +1,10 @@
1
+ import type { ITenant } from "@twin.org/api-models";
2
+ /**
3
+ * The tenant get response.
4
+ */
5
+ export interface ITenantGetResponse {
6
+ /**
7
+ * The tenant.
8
+ */
9
+ body: ITenant;
10
+ }
@@ -0,0 +1,18 @@
1
+ /**
2
+ * The list of tenants.
3
+ */
4
+ export interface ITenantListRequest {
5
+ /**
6
+ * The query parameters.
7
+ */
8
+ query: {
9
+ /**
10
+ * The cursor to get the next chunk of tenants.
11
+ */
12
+ cursor?: string;
13
+ /**
14
+ * The number of tenants to return.
15
+ */
16
+ limit?: string;
17
+ };
18
+ }
@@ -0,0 +1,17 @@
1
+ import type { ITenant } from "@twin.org/api-models";
2
+ import type { HeaderTypes } from "@twin.org/web";
3
+ /**
4
+ * The list of tenants.
5
+ */
6
+ export interface ITenantListResponse {
7
+ /**
8
+ * The headers which can be used to include the cursor.
9
+ */
10
+ headers?: {
11
+ [HeaderTypes.Link]?: string | string[];
12
+ };
13
+ /**
14
+ * The list of tenants.
15
+ */
16
+ body: ITenant[];
17
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * The tenant to remove by id.
3
+ */
4
+ export interface ITenantRemoveRequest {
5
+ /**
6
+ * The path parameters.
7
+ */
8
+ pathParams: {
9
+ /**
10
+ * The id of the tenant to remove.
11
+ */
12
+ id: string;
13
+ };
14
+ }