@twin.org/api-tenant-processor 0.0.3-next.1
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/LICENSE +201 -0
- package/README.md +21 -0
- package/dist/es/entities/tenant.js +45 -0
- package/dist/es/entities/tenant.js.map +1 -0
- package/dist/es/index.js +15 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/ITenant.js +4 -0
- package/dist/es/models/ITenant.js.map +1 -0
- package/dist/es/models/ITenantAdminComponent.js +2 -0
- package/dist/es/models/ITenantAdminComponent.js.map +1 -0
- package/dist/es/models/ITenantAdminServiceConfig.js +4 -0
- package/dist/es/models/ITenantAdminServiceConfig.js.map +1 -0
- package/dist/es/models/ITenantAdminServiceConstructorOptions.js +2 -0
- package/dist/es/models/ITenantAdminServiceConstructorOptions.js.map +1 -0
- package/dist/es/models/ITenantProcessorConfig.js +4 -0
- package/dist/es/models/ITenantProcessorConfig.js.map +1 -0
- package/dist/es/models/ITenantProcessorConstructorOptions.js +2 -0
- package/dist/es/models/ITenantProcessorConstructorOptions.js.map +1 -0
- package/dist/es/schema.js +11 -0
- package/dist/es/schema.js.map +1 -0
- package/dist/es/tenantAdminService.js +98 -0
- package/dist/es/tenantAdminService.js.map +1 -0
- package/dist/es/tenantIdContextIdHandler.js +27 -0
- package/dist/es/tenantIdContextIdHandler.js.map +1 -0
- package/dist/es/tenantProcessor.js +83 -0
- package/dist/es/tenantProcessor.js.map +1 -0
- package/dist/es/utils/tenantIdHelper.js +23 -0
- package/dist/es/utils/tenantIdHelper.js.map +1 -0
- package/dist/types/entities/tenant.d.ts +21 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/models/ITenant.d.ts +21 -0
- package/dist/types/models/ITenantAdminComponent.d.ts +41 -0
- package/dist/types/models/ITenantAdminServiceConfig.d.ts +5 -0
- package/dist/types/models/ITenantAdminServiceConstructorOptions.d.ts +15 -0
- package/dist/types/models/ITenantProcessorConfig.d.ts +10 -0
- package/dist/types/models/ITenantProcessorConstructorOptions.d.ts +15 -0
- package/dist/types/schema.d.ts +4 -0
- package/dist/types/tenantAdminService.d.ts +56 -0
- package/dist/types/tenantIdContextIdHandler.d.ts +22 -0
- package/dist/types/tenantProcessor.d.ts +33 -0
- package/dist/types/utils/tenantIdHelper.d.ts +15 -0
- package/docs/changelog.md +17 -0
- package/docs/examples.md +1 -0
- package/docs/reference/classes/Tenant.md +45 -0
- package/docs/reference/classes/TenantAdminService.md +189 -0
- package/docs/reference/classes/TenantIdContextIdHandler.md +79 -0
- package/docs/reference/classes/TenantIdHelper.md +41 -0
- package/docs/reference/classes/TenantProcessor.md +99 -0
- package/docs/reference/functions/initSchema.md +9 -0
- package/docs/reference/index.md +22 -0
- package/docs/reference/interfaces/ITenant.md +35 -0
- package/docs/reference/interfaces/ITenantAdminComponent.md +123 -0
- package/docs/reference/interfaces/ITenantAdminServiceConfig.md +3 -0
- package/docs/reference/interfaces/ITenantAdminServiceConstructorOptions.md +25 -0
- package/docs/reference/interfaces/ITenantProcessorConfig.md +17 -0
- package/docs/reference/interfaces/ITenantProcessorConstructorOptions.md +25 -0
- package/locales/en.json +8 -0
- package/package.json +56 -0
|
@@ -0,0 +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"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Class defining the storage for node tenants.
|
|
3
|
+
*/
|
|
4
|
+
export declare class Tenant {
|
|
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
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from "./entities/tenant.js";
|
|
2
|
+
export * from "./models/ITenant.js";
|
|
3
|
+
export * from "./models/ITenantAdminComponent.js";
|
|
4
|
+
export * from "./models/ITenantAdminServiceConfig.js";
|
|
5
|
+
export * from "./models/ITenantAdminServiceConstructorOptions.js";
|
|
6
|
+
export * from "./models/ITenantProcessorConfig.js";
|
|
7
|
+
export * from "./models/ITenantProcessorConstructorOptions.js";
|
|
8
|
+
export * from "./schema.js";
|
|
9
|
+
export * from "./tenantAdminService.js";
|
|
10
|
+
export * from "./tenantIdContextIdHandler.js";
|
|
11
|
+
export * from "./tenantProcessor.js";
|
|
12
|
+
export * from "./utils/tenantIdHelper.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ITenantAdminServiceConfig } from "./ITenantAdminServiceConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Tenant Admin Service constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITenantAdminServiceConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The entity storage for the tenants.
|
|
8
|
+
* @default tenant
|
|
9
|
+
*/
|
|
10
|
+
tenantEntityStorageType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the admin service.
|
|
13
|
+
*/
|
|
14
|
+
config?: ITenantAdminServiceConfig;
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ITenantProcessorConfig } from "./ITenantProcessorConfig.js";
|
|
2
|
+
/**
|
|
3
|
+
* Options for the Tenant Processor constructor.
|
|
4
|
+
*/
|
|
5
|
+
export interface ITenantProcessorConstructorOptions {
|
|
6
|
+
/**
|
|
7
|
+
* The entity storage for the tenants.
|
|
8
|
+
* @default tenant
|
|
9
|
+
*/
|
|
10
|
+
tenantEntityStorageType?: string;
|
|
11
|
+
/**
|
|
12
|
+
* Configuration for the processor.
|
|
13
|
+
*/
|
|
14
|
+
config?: ITenantProcessorConfig;
|
|
15
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ITenant } from "./models/ITenant.js";
|
|
2
|
+
import type { ITenantAdminComponent } from "./models/ITenantAdminComponent.js";
|
|
3
|
+
import type { ITenantAdminServiceConstructorOptions } from "./models/ITenantAdminServiceConstructorOptions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Service for performing email messaging operations to a connector.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TenantAdminService implements ITenantAdminComponent {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime name for the class.
|
|
10
|
+
*/
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new instance of TenantAdminService.
|
|
14
|
+
* @param options The options for the connector.
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: ITenantAdminServiceConstructorOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Get a tenant by its id.
|
|
24
|
+
* @param tenantId The id of the tenant.
|
|
25
|
+
* @returns The tenant or undefined if not found.
|
|
26
|
+
*/
|
|
27
|
+
get(tenantId: string): Promise<ITenant | undefined>;
|
|
28
|
+
/**
|
|
29
|
+
* Get a tenant by its api key.
|
|
30
|
+
* @param apiKey The api key of the tenant.
|
|
31
|
+
* @returns The tenant or undefined if not found.
|
|
32
|
+
*/
|
|
33
|
+
getByApiKey(apiKey: string): Promise<ITenant | undefined>;
|
|
34
|
+
/**
|
|
35
|
+
* Set a tenant.
|
|
36
|
+
* @param tenant The tenant to store.
|
|
37
|
+
* @returns Nothing.
|
|
38
|
+
*/
|
|
39
|
+
set(tenant: ITenant): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Remove a tenant by its id.
|
|
42
|
+
* @param tenantId The id of the tenant.
|
|
43
|
+
* @returns Nothing.
|
|
44
|
+
*/
|
|
45
|
+
remove(tenantId: string): Promise<void>;
|
|
46
|
+
/**
|
|
47
|
+
* Query tenants with pagination.
|
|
48
|
+
* @param cursor The cursor to start from.
|
|
49
|
+
* @param limit The maximum number of tenants to return.
|
|
50
|
+
* @returns The tenants and the next cursor if more tenants are available.
|
|
51
|
+
*/
|
|
52
|
+
query(cursor?: string, limit?: number): Promise<{
|
|
53
|
+
tenants: ITenant[];
|
|
54
|
+
cursor?: string;
|
|
55
|
+
}>;
|
|
56
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { IContextIdHandler } from "@twin.org/context";
|
|
2
|
+
/**
|
|
3
|
+
* Context Id handler for testing as a tenant id.
|
|
4
|
+
*/
|
|
5
|
+
export declare class TenantIdContextIdHandler implements IContextIdHandler {
|
|
6
|
+
/**
|
|
7
|
+
* Runtime name for the class.
|
|
8
|
+
*/
|
|
9
|
+
static readonly CLASS_NAME: string;
|
|
10
|
+
/**
|
|
11
|
+
* The short form of the tenant id is the same as the full version.
|
|
12
|
+
* @param value The full context id value.
|
|
13
|
+
* @returns Short form string.
|
|
14
|
+
*/
|
|
15
|
+
short(value: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Guard the value ensuring length.
|
|
18
|
+
* @param value The value to guard.
|
|
19
|
+
* @throws GeneralError if the value is too short.
|
|
20
|
+
*/
|
|
21
|
+
guard(value: string): void;
|
|
22
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { type IBaseRoute, type IBaseRouteProcessor, type IHttpResponse, type IHttpServerRequest } from "@twin.org/api-models";
|
|
2
|
+
import { type IContextIds } from "@twin.org/context";
|
|
3
|
+
import type { ITenantProcessorConstructorOptions } from "./models/ITenantProcessorConstructorOptions.js";
|
|
4
|
+
/**
|
|
5
|
+
* Handles incoming api keys and maps them to tenant ids.
|
|
6
|
+
*/
|
|
7
|
+
export declare class TenantProcessor implements IBaseRouteProcessor {
|
|
8
|
+
/**
|
|
9
|
+
* Runtime name for the class.
|
|
10
|
+
*/
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new instance of NodeTenantProcessor.
|
|
14
|
+
* @param options Options for the processor.
|
|
15
|
+
*/
|
|
16
|
+
constructor(options?: ITenantProcessorConstructorOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
22
|
+
/**
|
|
23
|
+
* Pre process the REST request for the specified route.
|
|
24
|
+
* @param request The incoming request.
|
|
25
|
+
* @param response The outgoing response.
|
|
26
|
+
* @param route The route to process.
|
|
27
|
+
* @param contextIds The context IDs of the request.
|
|
28
|
+
* @param processorState The state handed through the processors.
|
|
29
|
+
*/
|
|
30
|
+
pre(request: IHttpServerRequest, response: IHttpResponse, route: IBaseRoute | undefined, contextIds: IContextIds, processorState: {
|
|
31
|
+
[id: string]: unknown;
|
|
32
|
+
}): Promise<void>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper class for tenant id related operations.
|
|
3
|
+
*/
|
|
4
|
+
export declare class TenantIdHelper {
|
|
5
|
+
/**
|
|
6
|
+
* Generates a new tenant ID.
|
|
7
|
+
* @returns A new tenant ID.
|
|
8
|
+
*/
|
|
9
|
+
static generateTenantId(): string;
|
|
10
|
+
/**
|
|
11
|
+
* Generates a new API Key.
|
|
12
|
+
* @returns A new API Key.
|
|
13
|
+
*/
|
|
14
|
+
static generateApiKey(): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3-next.1](https://github.com/twinfoundation/api/compare/api-tenant-processor-v0.0.3-next.0...api-tenant-processor-v0.0.3-next.1) (2025-11-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add context id features ([#42](https://github.com/twinfoundation/api/issues/42)) ([0186055](https://github.com/twinfoundation/api/commit/0186055c48afde842a4254b4df9ac9249c40fe40))
|
|
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.0 to 0.0.3-next.1
|
|
16
|
+
|
|
17
|
+
## @twin.org/api-tenant-processor - Changelog
|
package/docs/examples.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
# @twin.org/api-tenant-processor - Examples
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Class: Tenant
|
|
2
|
+
|
|
3
|
+
Class defining the storage for node tenants.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new Tenant**(): `Tenant`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`Tenant`
|
|
14
|
+
|
|
15
|
+
## Properties
|
|
16
|
+
|
|
17
|
+
### id
|
|
18
|
+
|
|
19
|
+
> **id**: `string`
|
|
20
|
+
|
|
21
|
+
The unique identifier for the tenant.
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### apiKey
|
|
26
|
+
|
|
27
|
+
> **apiKey**: `string`
|
|
28
|
+
|
|
29
|
+
The api key for the tenant.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### label
|
|
34
|
+
|
|
35
|
+
> **label**: `string`
|
|
36
|
+
|
|
37
|
+
The label of the tenant.
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
41
|
+
### dateCreated
|
|
42
|
+
|
|
43
|
+
> **dateCreated**: `string`
|
|
44
|
+
|
|
45
|
+
The date the tenant was created.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# Class: TenantAdminService
|
|
2
|
+
|
|
3
|
+
Service for performing email messaging operations to a connector.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- [`ITenantAdminComponent`](../interfaces/ITenantAdminComponent.md)
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new TenantAdminService**(`options?`): `TenantAdminService`
|
|
14
|
+
|
|
15
|
+
Create a new instance of TenantAdminService.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`ITenantAdminServiceConstructorOptions`](../interfaces/ITenantAdminServiceConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
The options for the connector.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`TenantAdminService`
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### CLASS\_NAME
|
|
32
|
+
|
|
33
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
|
+
|
|
35
|
+
Runtime name for the class.
|
|
36
|
+
|
|
37
|
+
## Methods
|
|
38
|
+
|
|
39
|
+
### 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
|
+
`ITenantAdminComponent.className`
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### get()
|
|
58
|
+
|
|
59
|
+
> **get**(`tenantId`): `Promise`\<[`ITenant`](../interfaces/ITenant.md) \| `undefined`\>
|
|
60
|
+
|
|
61
|
+
Get a tenant by its id.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
##### tenantId
|
|
66
|
+
|
|
67
|
+
`string`
|
|
68
|
+
|
|
69
|
+
The id of the tenant.
|
|
70
|
+
|
|
71
|
+
#### Returns
|
|
72
|
+
|
|
73
|
+
`Promise`\<[`ITenant`](../interfaces/ITenant.md) \| `undefined`\>
|
|
74
|
+
|
|
75
|
+
The tenant or undefined if not found.
|
|
76
|
+
|
|
77
|
+
#### Implementation of
|
|
78
|
+
|
|
79
|
+
[`ITenantAdminComponent`](../interfaces/ITenantAdminComponent.md).[`get`](../interfaces/ITenantAdminComponent.md#get)
|
|
80
|
+
|
|
81
|
+
***
|
|
82
|
+
|
|
83
|
+
### getByApiKey()
|
|
84
|
+
|
|
85
|
+
> **getByApiKey**(`apiKey`): `Promise`\<[`ITenant`](../interfaces/ITenant.md) \| `undefined`\>
|
|
86
|
+
|
|
87
|
+
Get a tenant by its api key.
|
|
88
|
+
|
|
89
|
+
#### Parameters
|
|
90
|
+
|
|
91
|
+
##### apiKey
|
|
92
|
+
|
|
93
|
+
`string`
|
|
94
|
+
|
|
95
|
+
The api key of the tenant.
|
|
96
|
+
|
|
97
|
+
#### Returns
|
|
98
|
+
|
|
99
|
+
`Promise`\<[`ITenant`](../interfaces/ITenant.md) \| `undefined`\>
|
|
100
|
+
|
|
101
|
+
The tenant or undefined if not found.
|
|
102
|
+
|
|
103
|
+
#### Implementation of
|
|
104
|
+
|
|
105
|
+
[`ITenantAdminComponent`](../interfaces/ITenantAdminComponent.md).[`getByApiKey`](../interfaces/ITenantAdminComponent.md#getbyapikey)
|
|
106
|
+
|
|
107
|
+
***
|
|
108
|
+
|
|
109
|
+
### set()
|
|
110
|
+
|
|
111
|
+
> **set**(`tenant`): `Promise`\<`void`\>
|
|
112
|
+
|
|
113
|
+
Set a tenant.
|
|
114
|
+
|
|
115
|
+
#### Parameters
|
|
116
|
+
|
|
117
|
+
##### tenant
|
|
118
|
+
|
|
119
|
+
[`ITenant`](../interfaces/ITenant.md)
|
|
120
|
+
|
|
121
|
+
The tenant to store.
|
|
122
|
+
|
|
123
|
+
#### Returns
|
|
124
|
+
|
|
125
|
+
`Promise`\<`void`\>
|
|
126
|
+
|
|
127
|
+
Nothing.
|
|
128
|
+
|
|
129
|
+
#### Implementation of
|
|
130
|
+
|
|
131
|
+
[`ITenantAdminComponent`](../interfaces/ITenantAdminComponent.md).[`set`](../interfaces/ITenantAdminComponent.md#set)
|
|
132
|
+
|
|
133
|
+
***
|
|
134
|
+
|
|
135
|
+
### remove()
|
|
136
|
+
|
|
137
|
+
> **remove**(`tenantId`): `Promise`\<`void`\>
|
|
138
|
+
|
|
139
|
+
Remove a tenant by its id.
|
|
140
|
+
|
|
141
|
+
#### Parameters
|
|
142
|
+
|
|
143
|
+
##### tenantId
|
|
144
|
+
|
|
145
|
+
`string`
|
|
146
|
+
|
|
147
|
+
The id of the tenant.
|
|
148
|
+
|
|
149
|
+
#### Returns
|
|
150
|
+
|
|
151
|
+
`Promise`\<`void`\>
|
|
152
|
+
|
|
153
|
+
Nothing.
|
|
154
|
+
|
|
155
|
+
#### Implementation of
|
|
156
|
+
|
|
157
|
+
[`ITenantAdminComponent`](../interfaces/ITenantAdminComponent.md).[`remove`](../interfaces/ITenantAdminComponent.md#remove)
|
|
158
|
+
|
|
159
|
+
***
|
|
160
|
+
|
|
161
|
+
### query()
|
|
162
|
+
|
|
163
|
+
> **query**(`cursor?`, `limit?`): `Promise`\<\{ `tenants`: [`ITenant`](../interfaces/ITenant.md)[]; `cursor?`: `string`; \}\>
|
|
164
|
+
|
|
165
|
+
Query tenants with pagination.
|
|
166
|
+
|
|
167
|
+
#### Parameters
|
|
168
|
+
|
|
169
|
+
##### cursor?
|
|
170
|
+
|
|
171
|
+
`string`
|
|
172
|
+
|
|
173
|
+
The cursor to start from.
|
|
174
|
+
|
|
175
|
+
##### limit?
|
|
176
|
+
|
|
177
|
+
`number`
|
|
178
|
+
|
|
179
|
+
The maximum number of tenants to return.
|
|
180
|
+
|
|
181
|
+
#### Returns
|
|
182
|
+
|
|
183
|
+
`Promise`\<\{ `tenants`: [`ITenant`](../interfaces/ITenant.md)[]; `cursor?`: `string`; \}\>
|
|
184
|
+
|
|
185
|
+
The tenants and the next cursor if more tenants are available.
|
|
186
|
+
|
|
187
|
+
#### Implementation of
|
|
188
|
+
|
|
189
|
+
[`ITenantAdminComponent`](../interfaces/ITenantAdminComponent.md).[`query`](../interfaces/ITenantAdminComponent.md#query)
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Class: TenantIdContextIdHandler
|
|
2
|
+
|
|
3
|
+
Context Id handler for testing as a tenant id.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IContextIdHandler`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new TenantIdContextIdHandler**(): `TenantIdContextIdHandler`
|
|
14
|
+
|
|
15
|
+
#### Returns
|
|
16
|
+
|
|
17
|
+
`TenantIdContextIdHandler`
|
|
18
|
+
|
|
19
|
+
## Properties
|
|
20
|
+
|
|
21
|
+
### CLASS\_NAME
|
|
22
|
+
|
|
23
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
24
|
+
|
|
25
|
+
Runtime name for the class.
|
|
26
|
+
|
|
27
|
+
## Methods
|
|
28
|
+
|
|
29
|
+
### short()
|
|
30
|
+
|
|
31
|
+
> **short**(`value`): `string`
|
|
32
|
+
|
|
33
|
+
The short form of the tenant id is the same as the full version.
|
|
34
|
+
|
|
35
|
+
#### Parameters
|
|
36
|
+
|
|
37
|
+
##### value
|
|
38
|
+
|
|
39
|
+
`string`
|
|
40
|
+
|
|
41
|
+
The full context id value.
|
|
42
|
+
|
|
43
|
+
#### Returns
|
|
44
|
+
|
|
45
|
+
`string`
|
|
46
|
+
|
|
47
|
+
Short form string.
|
|
48
|
+
|
|
49
|
+
#### Implementation of
|
|
50
|
+
|
|
51
|
+
`IContextIdHandler.short`
|
|
52
|
+
|
|
53
|
+
***
|
|
54
|
+
|
|
55
|
+
### guard()
|
|
56
|
+
|
|
57
|
+
> **guard**(`value`): `void`
|
|
58
|
+
|
|
59
|
+
Guard the value ensuring length.
|
|
60
|
+
|
|
61
|
+
#### Parameters
|
|
62
|
+
|
|
63
|
+
##### value
|
|
64
|
+
|
|
65
|
+
`string`
|
|
66
|
+
|
|
67
|
+
The value to guard.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`void`
|
|
72
|
+
|
|
73
|
+
#### Throws
|
|
74
|
+
|
|
75
|
+
GeneralError if the value is too short.
|
|
76
|
+
|
|
77
|
+
#### Implementation of
|
|
78
|
+
|
|
79
|
+
`IContextIdHandler.guard`
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# Class: TenantIdHelper
|
|
2
|
+
|
|
3
|
+
Helper class for tenant id related operations.
|
|
4
|
+
|
|
5
|
+
## Constructors
|
|
6
|
+
|
|
7
|
+
### Constructor
|
|
8
|
+
|
|
9
|
+
> **new TenantIdHelper**(): `TenantIdHelper`
|
|
10
|
+
|
|
11
|
+
#### Returns
|
|
12
|
+
|
|
13
|
+
`TenantIdHelper`
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
### generateTenantId()
|
|
18
|
+
|
|
19
|
+
> `static` **generateTenantId**(): `string`
|
|
20
|
+
|
|
21
|
+
Generates a new tenant ID.
|
|
22
|
+
|
|
23
|
+
#### Returns
|
|
24
|
+
|
|
25
|
+
`string`
|
|
26
|
+
|
|
27
|
+
A new tenant ID.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### generateApiKey()
|
|
32
|
+
|
|
33
|
+
> `static` **generateApiKey**(): `string`
|
|
34
|
+
|
|
35
|
+
Generates a new API Key.
|
|
36
|
+
|
|
37
|
+
#### Returns
|
|
38
|
+
|
|
39
|
+
`string`
|
|
40
|
+
|
|
41
|
+
A new API Key.
|