@3sixty/api-tenant-processor 0.0.0-stage → 0.20.0-next.0
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 +24 -2
- package/dist/es/entities/tenant.js +77 -0
- package/dist/es/entities/tenant.js.map +1 -0
- package/dist/es/entities/tenantV0.js +61 -0
- package/dist/es/entities/tenantV0.js.map +1 -0
- package/dist/es/entities/tenantV1.js +77 -0
- package/dist/es/entities/tenantV1.js.map +1 -0
- package/dist/es/index.js +29 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/ISingleTenantProcessorConfig.js +4 -0
- package/dist/es/models/ISingleTenantProcessorConfig.js.map +1 -0
- package/dist/es/models/ISingleTenantProcessorConstructorOptions.js +2 -0
- package/dist/es/models/ISingleTenantProcessorConstructorOptions.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/ITenantOverrideProcessorConfig.js +4 -0
- package/dist/es/models/ITenantOverrideProcessorConfig.js.map +1 -0
- package/dist/es/models/ITenantOverrideProcessorConstructorOptions.js +2 -0
- package/dist/es/models/ITenantOverrideProcessorConstructorOptions.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/models/api/ITenantCreateRequest.js +2 -0
- package/dist/es/models/api/ITenantCreateRequest.js.map +1 -0
- package/dist/es/models/api/ITenantGetByApiKeyRequest.js +4 -0
- package/dist/es/models/api/ITenantGetByApiKeyRequest.js.map +1 -0
- package/dist/es/models/api/ITenantGetByIdRequest.js +4 -0
- package/dist/es/models/api/ITenantGetByIdRequest.js.map +1 -0
- package/dist/es/models/api/ITenantGetByPublicOriginRequest.js +4 -0
- package/dist/es/models/api/ITenantGetByPublicOriginRequest.js.map +1 -0
- package/dist/es/models/api/ITenantGetResponse.js +2 -0
- package/dist/es/models/api/ITenantGetResponse.js.map +1 -0
- package/dist/es/models/api/ITenantListRequest.js +4 -0
- package/dist/es/models/api/ITenantListRequest.js.map +1 -0
- package/dist/es/models/api/ITenantListResponse.js +2 -0
- package/dist/es/models/api/ITenantListResponse.js.map +1 -0
- package/dist/es/models/api/ITenantRemoveRequest.js +4 -0
- package/dist/es/models/api/ITenantRemoveRequest.js.map +1 -0
- package/dist/es/models/api/ITenantUpdateRequest.js +2 -0
- package/dist/es/models/api/ITenantUpdateRequest.js.map +1 -0
- package/dist/es/restEntryPoints.js +13 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/es/schema.js +64 -0
- package/dist/es/schema.js.map +1 -0
- package/dist/es/singleTenantProcessor.js +81 -0
- package/dist/es/singleTenantProcessor.js.map +1 -0
- package/dist/es/tenantAdminService.js +500 -0
- package/dist/es/tenantAdminService.js.map +1 -0
- package/dist/es/tenantIdContextIdHandler.js +47 -0
- package/dist/es/tenantIdContextIdHandler.js.map +1 -0
- package/dist/es/tenantOverrideProcessor.js +119 -0
- package/dist/es/tenantOverrideProcessor.js.map +1 -0
- package/dist/es/tenantProcessor.js +164 -0
- package/dist/es/tenantProcessor.js.map +1 -0
- package/dist/es/tenantRoutes.js +404 -0
- package/dist/es/tenantRoutes.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 +37 -0
- package/dist/types/entities/tenantV0.d.ts +29 -0
- package/dist/types/entities/tenantV1.d.ts +37 -0
- package/dist/types/index.d.ts +26 -0
- package/dist/types/models/ISingleTenantProcessorConfig.d.ts +9 -0
- package/dist/types/models/ISingleTenantProcessorConstructorOptions.d.ts +10 -0
- package/dist/types/models/ITenantAdminServiceConfig.d.ts +24 -0
- package/dist/types/models/ITenantAdminServiceConstructorOptions.d.ts +15 -0
- package/dist/types/models/ITenantOverrideProcessorConfig.d.ts +13 -0
- package/dist/types/models/ITenantOverrideProcessorConstructorOptions.d.ts +15 -0
- package/dist/types/models/ITenantProcessorConfig.d.ts +18 -0
- package/dist/types/models/ITenantProcessorConstructorOptions.d.ts +15 -0
- package/dist/types/models/api/ITenantCreateRequest.d.ts +12 -0
- package/dist/types/models/api/ITenantGetByApiKeyRequest.d.ts +14 -0
- package/dist/types/models/api/ITenantGetByIdRequest.d.ts +14 -0
- package/dist/types/models/api/ITenantGetByPublicOriginRequest.d.ts +14 -0
- package/dist/types/models/api/ITenantGetResponse.d.ts +10 -0
- package/dist/types/models/api/ITenantListRequest.d.ts +27 -0
- package/dist/types/models/api/ITenantListResponse.d.ts +17 -0
- package/dist/types/models/api/ITenantRemoveRequest.d.ts +14 -0
- package/dist/types/models/api/ITenantUpdateRequest.d.ts +19 -0
- package/dist/types/restEntryPoints.d.ts +5 -0
- package/dist/types/schema.d.ts +5 -0
- package/dist/types/singleTenantProcessor.d.ts +41 -0
- package/dist/types/tenantAdminService.d.ts +109 -0
- package/dist/types/tenantIdContextIdHandler.d.ts +33 -0
- package/dist/types/tenantOverrideProcessor.d.ts +44 -0
- package/dist/types/tenantProcessor.d.ts +34 -0
- package/dist/types/tenantRoutes.d.ts +78 -0
- package/dist/types/utils/tenantIdHelper.d.ts +15 -0
- package/docs/changelog.md +0 -0
- package/docs/examples.md +81 -0
- package/docs/reference/classes/SingleTenantProcessor.md +128 -0
- package/docs/reference/classes/Tenant.md +77 -0
- package/docs/reference/classes/TenantAdminService.md +393 -0
- package/docs/reference/classes/TenantIdContextIdHandler.md +123 -0
- package/docs/reference/classes/TenantIdHelper.md +41 -0
- package/docs/reference/classes/TenantOverrideProcessor.md +119 -0
- package/docs/reference/classes/TenantProcessor.md +101 -0
- package/docs/reference/functions/generateRestRoutesTenants.md +25 -0
- package/docs/reference/functions/initSchema.md +10 -0
- package/docs/reference/functions/tenantByApiKey.md +31 -0
- package/docs/reference/functions/tenantById.md +31 -0
- package/docs/reference/functions/tenantByPublicOrigin.md +31 -0
- package/docs/reference/functions/tenantCreate.md +37 -0
- package/docs/reference/functions/tenantList.md +31 -0
- package/docs/reference/functions/tenantRemove.md +31 -0
- package/docs/reference/functions/tenantUpdate.md +31 -0
- package/docs/reference/index.md +47 -0
- package/docs/reference/interfaces/ISingleTenantProcessorConfig.md +11 -0
- package/docs/reference/interfaces/ISingleTenantProcessorConstructorOptions.md +11 -0
- package/docs/reference/interfaces/ITenantAdminServiceConfig.md +49 -0
- package/docs/reference/interfaces/ITenantAdminServiceConstructorOptions.md +25 -0
- package/docs/reference/interfaces/ITenantCreateRequest.md +17 -0
- package/docs/reference/interfaces/ITenantGetByApiKeyRequest.md +17 -0
- package/docs/reference/interfaces/ITenantGetByIdRequest.md +17 -0
- package/docs/reference/interfaces/ITenantGetByPublicOriginRequest.md +17 -0
- package/docs/reference/interfaces/ITenantGetResponse.md +11 -0
- package/docs/reference/interfaces/ITenantListRequest.md +36 -0
- package/docs/reference/interfaces/ITenantListResponse.md +23 -0
- package/docs/reference/interfaces/ITenantOverrideProcessorConfig.md +19 -0
- package/docs/reference/interfaces/ITenantOverrideProcessorConstructorOptions.md +25 -0
- package/docs/reference/interfaces/ITenantProcessorConfig.md +33 -0
- package/docs/reference/interfaces/ITenantProcessorConstructorOptions.md +25 -0
- package/docs/reference/interfaces/ITenantRemoveRequest.md +17 -0
- package/docs/reference/interfaces/ITenantUpdateRequest.md +25 -0
- package/docs/reference/variables/tagsTenants.md +5 -0
- package/locales/en.json +24 -0
- package/package.json +57 -5
package/docs/examples.md
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# Tenant Processor Examples
|
|
2
|
+
|
|
3
|
+
These snippets show tenant lifecycle management and request context routing for multi-tenant deployments.
|
|
4
|
+
|
|
5
|
+
## TenantAdminService
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { TenantAdminService } from '@3sixty/api-tenant-processor';
|
|
9
|
+
|
|
10
|
+
const tenantAdmin = new TenantAdminService();
|
|
11
|
+
|
|
12
|
+
console.log(tenantAdmin.className()); // TenantAdminService
|
|
13
|
+
|
|
14
|
+
const createdTenantId = await tenantAdmin.create({
|
|
15
|
+
label: 'North Region',
|
|
16
|
+
apiKey: '0123456789abcdef0123456789abcdef',
|
|
17
|
+
publicOrigin: 'https://north.example.org'
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
await tenantAdmin.update({
|
|
21
|
+
id: createdTenantId,
|
|
22
|
+
label: 'North Region EU'
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const byKey = await tenantAdmin.getByApiKey('0123456789abcdef0123456789abcdef');
|
|
26
|
+
console.log(byKey.id.length); // 32
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
import { TenantAdminService } from '@3sixty/api-tenant-processor';
|
|
31
|
+
|
|
32
|
+
const tenantAdmin = new TenantAdminService();
|
|
33
|
+
|
|
34
|
+
const byId = await tenantAdmin.get('0123456789abcdef0123456789abcdef');
|
|
35
|
+
const byOrigin = await tenantAdmin.getByPublicOrigin('https://north.example.org');
|
|
36
|
+
const page = await tenantAdmin.query({ isNodeTenant: false }, '', 10);
|
|
37
|
+
|
|
38
|
+
await tenantAdmin.remove(byId.id);
|
|
39
|
+
|
|
40
|
+
console.log(byOrigin.label); // North Region EU
|
|
41
|
+
console.log(page.tenants.length); // 1
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## TenantIdContextIdHandler
|
|
45
|
+
|
|
46
|
+
```typescript
|
|
47
|
+
import { TenantIdContextIdHandler } from '@3sixty/api-tenant-processor';
|
|
48
|
+
|
|
49
|
+
const handler = new TenantIdContextIdHandler();
|
|
50
|
+
|
|
51
|
+
console.log(handler.className()); // TenantIdContextIdHandler
|
|
52
|
+
console.log(handler.short('0123456789abcdef0123456789abcdef')); // ASNFZ4mrze8BI0VniavN7w
|
|
53
|
+
|
|
54
|
+
handler.guard('0123456789abcdef0123456789abcdef');
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## TenantProcessor
|
|
58
|
+
|
|
59
|
+
```typescript
|
|
60
|
+
import { TenantProcessor } from '@3sixty/api-tenant-processor';
|
|
61
|
+
|
|
62
|
+
const tenantProcessor = new TenantProcessor();
|
|
63
|
+
|
|
64
|
+
console.log(tenantProcessor.className()); // TenantProcessor
|
|
65
|
+
|
|
66
|
+
const request = {
|
|
67
|
+
method: 'get',
|
|
68
|
+
url: '/info',
|
|
69
|
+
headers: {
|
|
70
|
+
'x-api-key': '0123456789abcdef0123456789abcdef'
|
|
71
|
+
},
|
|
72
|
+
query: {}
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
const response = {};
|
|
76
|
+
const contextIds = {};
|
|
77
|
+
const processorState: { [id: string]: unknown } = {};
|
|
78
|
+
|
|
79
|
+
await tenantProcessor.pre(request, response, { skipTenant: false }, contextIds, processorState);
|
|
80
|
+
console.log(typeof contextIds.tenant); // string
|
|
81
|
+
```
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
# Class: SingleTenantProcessor
|
|
2
|
+
|
|
3
|
+
Injects the single-tenant organization ID into every request context and validates any organization query parameter.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IBaseRouteProcessor`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new SingleTenantProcessor**(`options?`): `SingleTenantProcessor`
|
|
14
|
+
|
|
15
|
+
Create a new instance of SingleTenantProcessor.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`ISingleTenantProcessorConstructorOptions`](../interfaces/ISingleTenantProcessorConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
Options for the processor.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`SingleTenantProcessor`
|
|
28
|
+
|
|
29
|
+
## Properties
|
|
30
|
+
|
|
31
|
+
### CLASS\_NAME {#class_name}
|
|
32
|
+
|
|
33
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
|
+
|
|
35
|
+
Runtime name for the class.
|
|
36
|
+
|
|
37
|
+
## Methods
|
|
38
|
+
|
|
39
|
+
### className() {#classname}
|
|
40
|
+
|
|
41
|
+
> **className**(): `string`
|
|
42
|
+
|
|
43
|
+
Returns the class name of the component.
|
|
44
|
+
|
|
45
|
+
#### Returns
|
|
46
|
+
|
|
47
|
+
`string`
|
|
48
|
+
|
|
49
|
+
The class name of the component.
|
|
50
|
+
|
|
51
|
+
#### Implementation of
|
|
52
|
+
|
|
53
|
+
`IBaseRouteProcessor.className`
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### start() {#start}
|
|
58
|
+
|
|
59
|
+
> **start**(`nodeLoggingComponentType?`): `Promise`\<`void`\>
|
|
60
|
+
|
|
61
|
+
Cache the node organization ID from the engine context so it can be injected into each
|
|
62
|
+
per-request context without requiring a separate ContextIdProcessor for Organization.
|
|
63
|
+
|
|
64
|
+
#### Parameters
|
|
65
|
+
|
|
66
|
+
##### nodeLoggingComponentType?
|
|
67
|
+
|
|
68
|
+
`string`
|
|
69
|
+
|
|
70
|
+
The node logging component type.
|
|
71
|
+
|
|
72
|
+
#### Returns
|
|
73
|
+
|
|
74
|
+
`Promise`\<`void`\>
|
|
75
|
+
|
|
76
|
+
A promise that resolves when the node organization ID has been cached.
|
|
77
|
+
|
|
78
|
+
#### Implementation of
|
|
79
|
+
|
|
80
|
+
`IBaseRouteProcessor.start`
|
|
81
|
+
|
|
82
|
+
***
|
|
83
|
+
|
|
84
|
+
### pre() {#pre}
|
|
85
|
+
|
|
86
|
+
> **pre**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
|
|
87
|
+
|
|
88
|
+
Pre process the REST request for the specified route.
|
|
89
|
+
|
|
90
|
+
#### Parameters
|
|
91
|
+
|
|
92
|
+
##### request
|
|
93
|
+
|
|
94
|
+
`IHttpServerRequest`
|
|
95
|
+
|
|
96
|
+
The incoming request.
|
|
97
|
+
|
|
98
|
+
##### response
|
|
99
|
+
|
|
100
|
+
`IHttpResponse`
|
|
101
|
+
|
|
102
|
+
The outgoing response.
|
|
103
|
+
|
|
104
|
+
##### route
|
|
105
|
+
|
|
106
|
+
`IBaseRoute` \| `undefined`
|
|
107
|
+
|
|
108
|
+
The route to process.
|
|
109
|
+
|
|
110
|
+
##### contextIds
|
|
111
|
+
|
|
112
|
+
`IContextIds`
|
|
113
|
+
|
|
114
|
+
The context IDs of the request.
|
|
115
|
+
|
|
116
|
+
##### processorState
|
|
117
|
+
|
|
118
|
+
The state handed through the processors.
|
|
119
|
+
|
|
120
|
+
#### Returns
|
|
121
|
+
|
|
122
|
+
`Promise`\<`void`\>
|
|
123
|
+
|
|
124
|
+
A promise that resolves when the organization ID has been injected and any query parameter validated.
|
|
125
|
+
|
|
126
|
+
#### Implementation of
|
|
127
|
+
|
|
128
|
+
`IBaseRouteProcessor.pre`
|
|
@@ -0,0 +1,77 @@
|
|
|
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 {#id}
|
|
18
|
+
|
|
19
|
+
> **id**: `string`
|
|
20
|
+
|
|
21
|
+
The unique identifier for the tenant.
|
|
22
|
+
|
|
23
|
+
***
|
|
24
|
+
|
|
25
|
+
### apiKey {#apikey}
|
|
26
|
+
|
|
27
|
+
> **apiKey**: `string`
|
|
28
|
+
|
|
29
|
+
The api key for the tenant.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### label {#label}
|
|
34
|
+
|
|
35
|
+
> **label**: `string`
|
|
36
|
+
|
|
37
|
+
The label of the tenant.
|
|
38
|
+
|
|
39
|
+
***
|
|
40
|
+
|
|
41
|
+
### dateCreated {#datecreated}
|
|
42
|
+
|
|
43
|
+
> **dateCreated**: `string`
|
|
44
|
+
|
|
45
|
+
The date the tenant was created.
|
|
46
|
+
|
|
47
|
+
***
|
|
48
|
+
|
|
49
|
+
### dateModified {#datemodified}
|
|
50
|
+
|
|
51
|
+
> **dateModified**: `string`
|
|
52
|
+
|
|
53
|
+
The date the tenant was modified.
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### publicOrigin? {#publicorigin}
|
|
58
|
+
|
|
59
|
+
> `optional` **publicOrigin?**: `string`
|
|
60
|
+
|
|
61
|
+
The origin available to the public for accessing the API.
|
|
62
|
+
|
|
63
|
+
***
|
|
64
|
+
|
|
65
|
+
### organizationId {#organizationid}
|
|
66
|
+
|
|
67
|
+
> **organizationId**: `string`
|
|
68
|
+
|
|
69
|
+
The organization id for the tenant.
|
|
70
|
+
|
|
71
|
+
***
|
|
72
|
+
|
|
73
|
+
### organizationIdLegacy? {#organizationidlegacy}
|
|
74
|
+
|
|
75
|
+
> `optional` **organizationIdLegacy?**: `string`[]
|
|
76
|
+
|
|
77
|
+
Optional list of organization aliases that can be used for legacy lookups, indexed format.
|
|
@@ -0,0 +1,393 @@
|
|
|
1
|
+
# Class: TenantAdminService
|
|
2
|
+
|
|
3
|
+
Service for performing tenant administration operations.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `ITenantAdminComponent`
|
|
8
|
+
- `IHealthProviderComponent`
|
|
9
|
+
|
|
10
|
+
## Constructors
|
|
11
|
+
|
|
12
|
+
### Constructor
|
|
13
|
+
|
|
14
|
+
> **new TenantAdminService**(`options?`): `TenantAdminService`
|
|
15
|
+
|
|
16
|
+
Create a new instance of TenantAdminService.
|
|
17
|
+
|
|
18
|
+
#### Parameters
|
|
19
|
+
|
|
20
|
+
##### options?
|
|
21
|
+
|
|
22
|
+
[`ITenantAdminServiceConstructorOptions`](../interfaces/ITenantAdminServiceConstructorOptions.md)
|
|
23
|
+
|
|
24
|
+
The options for the connector.
|
|
25
|
+
|
|
26
|
+
#### Returns
|
|
27
|
+
|
|
28
|
+
`TenantAdminService`
|
|
29
|
+
|
|
30
|
+
## Properties
|
|
31
|
+
|
|
32
|
+
### CLASS\_NAME {#class_name}
|
|
33
|
+
|
|
34
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
35
|
+
|
|
36
|
+
Runtime name for the class.
|
|
37
|
+
|
|
38
|
+
## Methods
|
|
39
|
+
|
|
40
|
+
### className() {#classname}
|
|
41
|
+
|
|
42
|
+
> **className**(): `string`
|
|
43
|
+
|
|
44
|
+
Returns the class name of the component.
|
|
45
|
+
|
|
46
|
+
#### Returns
|
|
47
|
+
|
|
48
|
+
`string`
|
|
49
|
+
|
|
50
|
+
The class name of the component.
|
|
51
|
+
|
|
52
|
+
#### Implementation of
|
|
53
|
+
|
|
54
|
+
`ITenantAdminComponent.className`
|
|
55
|
+
|
|
56
|
+
***
|
|
57
|
+
|
|
58
|
+
### stop() {#stop}
|
|
59
|
+
|
|
60
|
+
> **stop**(): `Promise`\<`void`\>
|
|
61
|
+
|
|
62
|
+
Stop the service and release the tenant cache.
|
|
63
|
+
|
|
64
|
+
#### Returns
|
|
65
|
+
|
|
66
|
+
`Promise`\<`void`\>
|
|
67
|
+
|
|
68
|
+
A promise that resolves when the service has stopped.
|
|
69
|
+
|
|
70
|
+
#### Implementation of
|
|
71
|
+
|
|
72
|
+
`ITenantAdminComponent.stop`
|
|
73
|
+
|
|
74
|
+
***
|
|
75
|
+
|
|
76
|
+
### get() {#get}
|
|
77
|
+
|
|
78
|
+
> **get**(`tenantId`): `Promise`\<`ITenant`\>
|
|
79
|
+
|
|
80
|
+
Get a tenant by its id.
|
|
81
|
+
|
|
82
|
+
#### Parameters
|
|
83
|
+
|
|
84
|
+
##### tenantId
|
|
85
|
+
|
|
86
|
+
`string`
|
|
87
|
+
|
|
88
|
+
The id of the tenant.
|
|
89
|
+
|
|
90
|
+
#### Returns
|
|
91
|
+
|
|
92
|
+
`Promise`\<`ITenant`\>
|
|
93
|
+
|
|
94
|
+
The tenant.
|
|
95
|
+
|
|
96
|
+
#### Throws
|
|
97
|
+
|
|
98
|
+
Error if the tenant is not found.
|
|
99
|
+
|
|
100
|
+
#### Implementation of
|
|
101
|
+
|
|
102
|
+
`ITenantAdminComponent.get`
|
|
103
|
+
|
|
104
|
+
***
|
|
105
|
+
|
|
106
|
+
### getByApiKey() {#getbyapikey}
|
|
107
|
+
|
|
108
|
+
> **getByApiKey**(`apiKey`): `Promise`\<`ITenant`\>
|
|
109
|
+
|
|
110
|
+
Get a tenant by its api key.
|
|
111
|
+
|
|
112
|
+
#### Parameters
|
|
113
|
+
|
|
114
|
+
##### apiKey
|
|
115
|
+
|
|
116
|
+
`string`
|
|
117
|
+
|
|
118
|
+
The api key of the tenant.
|
|
119
|
+
|
|
120
|
+
#### Returns
|
|
121
|
+
|
|
122
|
+
`Promise`\<`ITenant`\>
|
|
123
|
+
|
|
124
|
+
The tenant.
|
|
125
|
+
|
|
126
|
+
#### Throws
|
|
127
|
+
|
|
128
|
+
Error if the tenant is not found.
|
|
129
|
+
|
|
130
|
+
#### Implementation of
|
|
131
|
+
|
|
132
|
+
`ITenantAdminComponent.getByApiKey`
|
|
133
|
+
|
|
134
|
+
***
|
|
135
|
+
|
|
136
|
+
### getByPublicOrigin() {#getbypublicorigin}
|
|
137
|
+
|
|
138
|
+
> **getByPublicOrigin**(`publicOrigin`): `Promise`\<`ITenant`\>
|
|
139
|
+
|
|
140
|
+
Get a tenant by its public origin.
|
|
141
|
+
|
|
142
|
+
#### Parameters
|
|
143
|
+
|
|
144
|
+
##### publicOrigin
|
|
145
|
+
|
|
146
|
+
`string`
|
|
147
|
+
|
|
148
|
+
The origin of the tenant.
|
|
149
|
+
|
|
150
|
+
#### Returns
|
|
151
|
+
|
|
152
|
+
`Promise`\<`ITenant`\>
|
|
153
|
+
|
|
154
|
+
The tenant.
|
|
155
|
+
|
|
156
|
+
#### Throws
|
|
157
|
+
|
|
158
|
+
Error if the tenant is not found.
|
|
159
|
+
|
|
160
|
+
#### Implementation of
|
|
161
|
+
|
|
162
|
+
`ITenantAdminComponent.getByPublicOrigin`
|
|
163
|
+
|
|
164
|
+
***
|
|
165
|
+
|
|
166
|
+
### getTenantByOrganizationId() {#gettenantbyorganizationid}
|
|
167
|
+
|
|
168
|
+
> **getTenantByOrganizationId**(`organizationId`, `includeLegacy?`): `Promise`\<`ITenant`\>
|
|
169
|
+
|
|
170
|
+
Get a tenant by its organization id, optionally searching legacy ids.
|
|
171
|
+
|
|
172
|
+
#### Parameters
|
|
173
|
+
|
|
174
|
+
##### organizationId
|
|
175
|
+
|
|
176
|
+
`string`
|
|
177
|
+
|
|
178
|
+
The organization id of the tenant.
|
|
179
|
+
|
|
180
|
+
##### includeLegacy?
|
|
181
|
+
|
|
182
|
+
`boolean`
|
|
183
|
+
|
|
184
|
+
Whether to also search the legacy organization id array.
|
|
185
|
+
|
|
186
|
+
#### Returns
|
|
187
|
+
|
|
188
|
+
`Promise`\<`ITenant`\>
|
|
189
|
+
|
|
190
|
+
The tenant.
|
|
191
|
+
|
|
192
|
+
#### Throws
|
|
193
|
+
|
|
194
|
+
Error if the tenant is not found.
|
|
195
|
+
|
|
196
|
+
#### Implementation of
|
|
197
|
+
|
|
198
|
+
`ITenantAdminComponent.getTenantByOrganizationId`
|
|
199
|
+
|
|
200
|
+
***
|
|
201
|
+
|
|
202
|
+
### create() {#create}
|
|
203
|
+
|
|
204
|
+
> **create**(`tenant`): `Promise`\<`string`\>
|
|
205
|
+
|
|
206
|
+
Create a tenant.
|
|
207
|
+
|
|
208
|
+
#### Parameters
|
|
209
|
+
|
|
210
|
+
##### tenant
|
|
211
|
+
|
|
212
|
+
`Omit`\<`ITenant`, `"id"` \| `"dateCreated"` \| `"dateModified"`\> & `object`
|
|
213
|
+
|
|
214
|
+
The tenant to store.
|
|
215
|
+
|
|
216
|
+
#### Returns
|
|
217
|
+
|
|
218
|
+
`Promise`\<`string`\>
|
|
219
|
+
|
|
220
|
+
The tenant id.
|
|
221
|
+
|
|
222
|
+
#### Implementation of
|
|
223
|
+
|
|
224
|
+
`ITenantAdminComponent.create`
|
|
225
|
+
|
|
226
|
+
***
|
|
227
|
+
|
|
228
|
+
### update() {#update}
|
|
229
|
+
|
|
230
|
+
> **update**(`tenant`): `Promise`\<`void`\>
|
|
231
|
+
|
|
232
|
+
Update a tenant.
|
|
233
|
+
|
|
234
|
+
#### Parameters
|
|
235
|
+
|
|
236
|
+
##### tenant
|
|
237
|
+
|
|
238
|
+
`Partial`\<`Omit`\<`ITenant`, `"dateCreated"` \| `"dateModified"`\>\>
|
|
239
|
+
|
|
240
|
+
The tenant to update.
|
|
241
|
+
|
|
242
|
+
#### Returns
|
|
243
|
+
|
|
244
|
+
`Promise`\<`void`\>
|
|
245
|
+
|
|
246
|
+
A promise that resolves when the tenant has been updated.
|
|
247
|
+
|
|
248
|
+
#### Implementation of
|
|
249
|
+
|
|
250
|
+
`ITenantAdminComponent.update`
|
|
251
|
+
|
|
252
|
+
***
|
|
253
|
+
|
|
254
|
+
### remove() {#remove}
|
|
255
|
+
|
|
256
|
+
> **remove**(`tenantId`): `Promise`\<`void`\>
|
|
257
|
+
|
|
258
|
+
Remove a tenant by its id.
|
|
259
|
+
|
|
260
|
+
#### Parameters
|
|
261
|
+
|
|
262
|
+
##### tenantId
|
|
263
|
+
|
|
264
|
+
`string`
|
|
265
|
+
|
|
266
|
+
The id of the tenant.
|
|
267
|
+
|
|
268
|
+
#### Returns
|
|
269
|
+
|
|
270
|
+
`Promise`\<`void`\>
|
|
271
|
+
|
|
272
|
+
Nothing.
|
|
273
|
+
|
|
274
|
+
#### Implementation of
|
|
275
|
+
|
|
276
|
+
`ITenantAdminComponent.remove`
|
|
277
|
+
|
|
278
|
+
***
|
|
279
|
+
|
|
280
|
+
### query() {#query}
|
|
281
|
+
|
|
282
|
+
> **query**(`conditions?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `tenants`: `ITenant`[]; `cursor?`: `string`; \}\>
|
|
283
|
+
|
|
284
|
+
Query tenants with pagination.
|
|
285
|
+
|
|
286
|
+
#### Parameters
|
|
287
|
+
|
|
288
|
+
##### conditions?
|
|
289
|
+
|
|
290
|
+
`EntityCondition`\<`ITenant`\>
|
|
291
|
+
|
|
292
|
+
The conditions to filter the tenants.
|
|
293
|
+
|
|
294
|
+
##### properties?
|
|
295
|
+
|
|
296
|
+
keyof `ITenant`[]
|
|
297
|
+
|
|
298
|
+
The properties to include in the returned tenants.
|
|
299
|
+
|
|
300
|
+
##### cursor?
|
|
301
|
+
|
|
302
|
+
`string`
|
|
303
|
+
|
|
304
|
+
The cursor to start from.
|
|
305
|
+
|
|
306
|
+
##### limit?
|
|
307
|
+
|
|
308
|
+
`number`
|
|
309
|
+
|
|
310
|
+
The maximum number of tenants to return.
|
|
311
|
+
|
|
312
|
+
#### Returns
|
|
313
|
+
|
|
314
|
+
`Promise`\<\{ `tenants`: `ITenant`[]; `cursor?`: `string`; \}\>
|
|
315
|
+
|
|
316
|
+
The tenants and the next cursor if more tenants are available.
|
|
317
|
+
|
|
318
|
+
#### Implementation of
|
|
319
|
+
|
|
320
|
+
`ITenantAdminComponent.query`
|
|
321
|
+
|
|
322
|
+
***
|
|
323
|
+
|
|
324
|
+
### healthApplicationInit() {#healthapplicationinit}
|
|
325
|
+
|
|
326
|
+
> **healthApplicationInit**(`contextIds`): `Promise`\<`void`\>
|
|
327
|
+
|
|
328
|
+
Provision a temporary tenant for the application health cycle.
|
|
329
|
+
|
|
330
|
+
#### Parameters
|
|
331
|
+
|
|
332
|
+
##### contextIds
|
|
333
|
+
|
|
334
|
+
`IContextIds`
|
|
335
|
+
|
|
336
|
+
Accumulated context IDs; receives the provisional tenant ID.
|
|
337
|
+
|
|
338
|
+
#### Returns
|
|
339
|
+
|
|
340
|
+
`Promise`\<`void`\>
|
|
341
|
+
|
|
342
|
+
A promise that resolves when provisioning is complete.
|
|
343
|
+
|
|
344
|
+
#### Implementation of
|
|
345
|
+
|
|
346
|
+
`IHealthProviderComponent.healthApplicationInit`
|
|
347
|
+
|
|
348
|
+
***
|
|
349
|
+
|
|
350
|
+
### healthApplication() {#healthapplication}
|
|
351
|
+
|
|
352
|
+
> **healthApplication**(`callback`): `Promise`\<`IHealth`[] \| `undefined`\>
|
|
353
|
+
|
|
354
|
+
Verify the provisioned tenant can be retrieved.
|
|
355
|
+
The tenant ID is read from the active context set by the init pass.
|
|
356
|
+
|
|
357
|
+
#### Parameters
|
|
358
|
+
|
|
359
|
+
##### callback
|
|
360
|
+
|
|
361
|
+
`HealthApplicationCallback`
|
|
362
|
+
|
|
363
|
+
The callback to invoke when a deferred health result is ready.
|
|
364
|
+
|
|
365
|
+
#### Returns
|
|
366
|
+
|
|
367
|
+
`Promise`\<`IHealth`[] \| `undefined`\>
|
|
368
|
+
|
|
369
|
+
The health entries for this component.
|
|
370
|
+
|
|
371
|
+
#### Implementation of
|
|
372
|
+
|
|
373
|
+
`IHealthProviderComponent.healthApplication`
|
|
374
|
+
|
|
375
|
+
***
|
|
376
|
+
|
|
377
|
+
### healthApplicationTeardown() {#healthapplicationteardown}
|
|
378
|
+
|
|
379
|
+
> **healthApplicationTeardown**(): `Promise`\<`void`\>
|
|
380
|
+
|
|
381
|
+
Remove the temporary tenant provisioned during init.
|
|
382
|
+
The tenant ID is read from the active context set by the init pass.
|
|
383
|
+
Does nothing when no tenant ID is present.
|
|
384
|
+
|
|
385
|
+
#### Returns
|
|
386
|
+
|
|
387
|
+
`Promise`\<`void`\>
|
|
388
|
+
|
|
389
|
+
A promise that resolves when teardown is complete.
|
|
390
|
+
|
|
391
|
+
#### Implementation of
|
|
392
|
+
|
|
393
|
+
`IHealthProviderComponent.healthApplicationTeardown`
|