@twin.org/api-tenant-processor 0.0.3-next.4 → 0.0.3-next.41
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/README.md +1 -1
- package/dist/es/entities/tenant.js +17 -1
- package/dist/es/entities/tenant.js.map +1 -1
- package/dist/es/index.js +13 -2
- package/dist/es/index.js.map +1 -1
- package/dist/es/models/ITenantProcessorConfig.js.map +1 -1
- package/dist/es/models/ITenantProcessorConstructorOptions.js.map +1 -1
- package/dist/es/models/ITenantServiceConfig.js +4 -0
- package/dist/es/models/ITenantServiceConfig.js.map +1 -0
- package/dist/es/models/ITenantServiceConstructorOptions.js +2 -0
- package/dist/es/models/ITenantServiceConstructorOptions.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 +10 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/es/tenantAdminService.js +101 -16
- package/dist/es/tenantAdminService.js.map +1 -1
- package/dist/es/tenantIdContextIdHandler.js +7 -0
- package/dist/es/tenantIdContextIdHandler.js.map +1 -1
- package/dist/es/tenantProcessor.js +75 -17
- package/dist/es/tenantProcessor.js.map +1 -1
- package/dist/es/tenantRoutes.js +394 -0
- package/dist/es/tenantRoutes.js.map +1 -0
- package/dist/es/tenantService.js +51 -0
- package/dist/es/tenantService.js.map +1 -0
- package/dist/es/utils/tenantIdHelper.js +3 -3
- package/dist/es/utils/tenantIdHelper.js.map +1 -1
- package/dist/types/entities/tenant.d.ts +8 -0
- package/dist/types/index.d.ts +13 -2
- package/dist/types/models/ITenantProcessorConfig.d.ts +4 -0
- package/dist/types/models/ITenantProcessorConstructorOptions.d.ts +5 -0
- package/dist/types/models/ITenantServiceConfig.d.ts +5 -0
- package/dist/types/models/ITenantServiceConstructorOptions.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 +23 -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 +2 -0
- package/dist/types/tenantAdminService.d.ts +28 -11
- package/dist/types/tenantIdContextIdHandler.d.ts +5 -0
- package/dist/types/tenantProcessor.d.ts +1 -1
- package/dist/types/tenantRoutes.d.ts +77 -0
- package/dist/types/tenantService.d.ts +27 -0
- package/docs/changelog.md +546 -15
- package/docs/examples.md +81 -1
- package/docs/reference/classes/Tenant.md +20 -4
- package/docs/reference/classes/TenantAdminService.md +96 -26
- package/docs/reference/classes/TenantIdContextIdHandler.md +21 -3
- package/docs/reference/classes/TenantIdHelper.md +2 -2
- package/docs/reference/classes/TenantProcessor.md +6 -6
- package/docs/reference/classes/TenantService.md +79 -0
- package/docs/reference/functions/generateRestRoutesTenants.md +25 -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 +31 -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 +24 -2
- package/docs/reference/interfaces/ITenantAdminServiceConstructorOptions.md +4 -4
- 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 +30 -0
- package/docs/reference/interfaces/ITenantListResponse.md +23 -0
- package/docs/reference/interfaces/ITenantProcessorConfig.md +10 -2
- package/docs/reference/interfaces/ITenantProcessorConstructorOptions.md +18 -4
- package/docs/reference/interfaces/ITenantRemoveRequest.md +17 -0
- package/docs/reference/interfaces/ITenantServiceConfig.md +3 -0
- package/docs/reference/interfaces/ITenantServiceConstructorOptions.md +25 -0
- package/docs/reference/interfaces/ITenantUpdateRequest.md +25 -0
- package/docs/reference/variables/tagsTenants.md +5 -0
- package/locales/en.json +8 -2
- package/package.json +6 -5
- package/dist/es/models/ITenant.js +0 -4
- package/dist/es/models/ITenant.js.map +0 -1
- package/dist/es/models/ITenantAdminComponent.js +0 -2
- package/dist/es/models/ITenantAdminComponent.js.map +0 -1
- package/dist/types/models/ITenant.d.ts +0 -21
- package/dist/types/models/ITenantAdminComponent.d.ts +0 -41
- package/docs/reference/interfaces/ITenant.md +0 -35
- package/docs/reference/interfaces/ITenantAdminComponent.md +0 -123
package/docs/examples.md
CHANGED
|
@@ -1 +1,81 @@
|
|
|
1
|
-
#
|
|
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 '@twin.org/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 '@twin.org/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 '@twin.org/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 '@twin.org/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
|
+
```
|
|
@@ -14,7 +14,7 @@ Class defining the storage for node tenants.
|
|
|
14
14
|
|
|
15
15
|
## Properties
|
|
16
16
|
|
|
17
|
-
### id
|
|
17
|
+
### id {#id}
|
|
18
18
|
|
|
19
19
|
> **id**: `string`
|
|
20
20
|
|
|
@@ -22,7 +22,7 @@ The unique identifier for the tenant.
|
|
|
22
22
|
|
|
23
23
|
***
|
|
24
24
|
|
|
25
|
-
### apiKey
|
|
25
|
+
### apiKey {#apikey}
|
|
26
26
|
|
|
27
27
|
> **apiKey**: `string`
|
|
28
28
|
|
|
@@ -30,7 +30,7 @@ The api key for the tenant.
|
|
|
30
30
|
|
|
31
31
|
***
|
|
32
32
|
|
|
33
|
-
### label
|
|
33
|
+
### label {#label}
|
|
34
34
|
|
|
35
35
|
> **label**: `string`
|
|
36
36
|
|
|
@@ -38,8 +38,24 @@ The label of the tenant.
|
|
|
38
38
|
|
|
39
39
|
***
|
|
40
40
|
|
|
41
|
-
### dateCreated
|
|
41
|
+
### dateCreated {#datecreated}
|
|
42
42
|
|
|
43
43
|
> **dateCreated**: `string`
|
|
44
44
|
|
|
45
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.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# Class: TenantAdminService
|
|
2
2
|
|
|
3
|
-
Service for performing
|
|
3
|
+
Service for performing tenant administration operations.
|
|
4
4
|
|
|
5
5
|
## Implements
|
|
6
6
|
|
|
7
|
-
-
|
|
7
|
+
- `ITenantAdminComponent`
|
|
8
8
|
|
|
9
9
|
## Constructors
|
|
10
10
|
|
|
@@ -28,7 +28,7 @@ The options for the connector.
|
|
|
28
28
|
|
|
29
29
|
## Properties
|
|
30
30
|
|
|
31
|
-
### CLASS\_NAME
|
|
31
|
+
### CLASS\_NAME {#class_name}
|
|
32
32
|
|
|
33
33
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ Runtime name for the class.
|
|
|
36
36
|
|
|
37
37
|
## Methods
|
|
38
38
|
|
|
39
|
-
### className()
|
|
39
|
+
### className() {#classname}
|
|
40
40
|
|
|
41
41
|
> **className**(): `string`
|
|
42
42
|
|
|
@@ -54,9 +54,9 @@ The class name of the component.
|
|
|
54
54
|
|
|
55
55
|
***
|
|
56
56
|
|
|
57
|
-
### get()
|
|
57
|
+
### get() {#get}
|
|
58
58
|
|
|
59
|
-
> **get**(`tenantId`): `Promise
|
|
59
|
+
> **get**(`tenantId`): `Promise`\<`ITenant`\>
|
|
60
60
|
|
|
61
61
|
Get a tenant by its id.
|
|
62
62
|
|
|
@@ -70,19 +70,23 @@ The id of the tenant.
|
|
|
70
70
|
|
|
71
71
|
#### Returns
|
|
72
72
|
|
|
73
|
-
`Promise
|
|
73
|
+
`Promise`\<`ITenant`\>
|
|
74
74
|
|
|
75
|
-
The tenant
|
|
75
|
+
The tenant.
|
|
76
|
+
|
|
77
|
+
#### Throws
|
|
78
|
+
|
|
79
|
+
Error if the tenant is not found.
|
|
76
80
|
|
|
77
81
|
#### Implementation of
|
|
78
82
|
|
|
79
|
-
|
|
83
|
+
`ITenantAdminComponent.get`
|
|
80
84
|
|
|
81
85
|
***
|
|
82
86
|
|
|
83
|
-
### getByApiKey()
|
|
87
|
+
### getByApiKey() {#getbyapikey}
|
|
84
88
|
|
|
85
|
-
> **getByApiKey**(`apiKey`): `Promise
|
|
89
|
+
> **getByApiKey**(`apiKey`): `Promise`\<`ITenant`\>
|
|
86
90
|
|
|
87
91
|
Get a tenant by its api key.
|
|
88
92
|
|
|
@@ -96,43 +100,103 @@ The api key of the tenant.
|
|
|
96
100
|
|
|
97
101
|
#### Returns
|
|
98
102
|
|
|
99
|
-
`Promise
|
|
103
|
+
`Promise`\<`ITenant`\>
|
|
104
|
+
|
|
105
|
+
The tenant.
|
|
106
|
+
|
|
107
|
+
#### Throws
|
|
108
|
+
|
|
109
|
+
Error if the tenant is not found.
|
|
110
|
+
|
|
111
|
+
#### Implementation of
|
|
112
|
+
|
|
113
|
+
`ITenantAdminComponent.getByApiKey`
|
|
114
|
+
|
|
115
|
+
***
|
|
116
|
+
|
|
117
|
+
### getByPublicOrigin() {#getbypublicorigin}
|
|
118
|
+
|
|
119
|
+
> **getByPublicOrigin**(`publicOrigin`): `Promise`\<`ITenant`\>
|
|
120
|
+
|
|
121
|
+
Get a tenant by its public origin.
|
|
122
|
+
|
|
123
|
+
#### Parameters
|
|
124
|
+
|
|
125
|
+
##### publicOrigin
|
|
126
|
+
|
|
127
|
+
`string`
|
|
128
|
+
|
|
129
|
+
The origin of the tenant.
|
|
130
|
+
|
|
131
|
+
#### Returns
|
|
132
|
+
|
|
133
|
+
`Promise`\<`ITenant`\>
|
|
134
|
+
|
|
135
|
+
The tenant.
|
|
100
136
|
|
|
101
|
-
|
|
137
|
+
#### Throws
|
|
138
|
+
|
|
139
|
+
Error if the tenant is not found.
|
|
102
140
|
|
|
103
141
|
#### Implementation of
|
|
104
142
|
|
|
105
|
-
|
|
143
|
+
`ITenantAdminComponent.getByPublicOrigin`
|
|
106
144
|
|
|
107
145
|
***
|
|
108
146
|
|
|
109
|
-
###
|
|
147
|
+
### create() {#create}
|
|
110
148
|
|
|
111
|
-
> **
|
|
149
|
+
> **create**(`tenant`): `Promise`\<`string`\>
|
|
112
150
|
|
|
113
|
-
|
|
151
|
+
Create a tenant.
|
|
114
152
|
|
|
115
153
|
#### Parameters
|
|
116
154
|
|
|
117
155
|
##### tenant
|
|
118
156
|
|
|
119
|
-
|
|
157
|
+
`Omit`\<`ITenant`, `"id"` \| `"dateCreated"` \| `"dateModified"`\> & `object`
|
|
120
158
|
|
|
121
159
|
The tenant to store.
|
|
122
160
|
|
|
123
161
|
#### Returns
|
|
124
162
|
|
|
163
|
+
`Promise`\<`string`\>
|
|
164
|
+
|
|
165
|
+
The tenant id.
|
|
166
|
+
|
|
167
|
+
#### Implementation of
|
|
168
|
+
|
|
169
|
+
`ITenantAdminComponent.create`
|
|
170
|
+
|
|
171
|
+
***
|
|
172
|
+
|
|
173
|
+
### update() {#update}
|
|
174
|
+
|
|
175
|
+
> **update**(`tenant`): `Promise`\<`void`\>
|
|
176
|
+
|
|
177
|
+
Update a tenant.
|
|
178
|
+
|
|
179
|
+
#### Parameters
|
|
180
|
+
|
|
181
|
+
##### tenant
|
|
182
|
+
|
|
183
|
+
`Partial`\<`Omit`\<`ITenant`, `"dateCreated"` \| `"dateModified"`\>\>
|
|
184
|
+
|
|
185
|
+
The tenant to update.
|
|
186
|
+
|
|
187
|
+
#### Returns
|
|
188
|
+
|
|
125
189
|
`Promise`\<`void`\>
|
|
126
190
|
|
|
127
|
-
|
|
191
|
+
The nothing.
|
|
128
192
|
|
|
129
193
|
#### Implementation of
|
|
130
194
|
|
|
131
|
-
|
|
195
|
+
`ITenantAdminComponent.update`
|
|
132
196
|
|
|
133
197
|
***
|
|
134
198
|
|
|
135
|
-
### remove()
|
|
199
|
+
### remove() {#remove}
|
|
136
200
|
|
|
137
201
|
> **remove**(`tenantId`): `Promise`\<`void`\>
|
|
138
202
|
|
|
@@ -154,18 +218,24 @@ Nothing.
|
|
|
154
218
|
|
|
155
219
|
#### Implementation of
|
|
156
220
|
|
|
157
|
-
|
|
221
|
+
`ITenantAdminComponent.remove`
|
|
158
222
|
|
|
159
223
|
***
|
|
160
224
|
|
|
161
|
-
### query()
|
|
225
|
+
### query() {#query}
|
|
162
226
|
|
|
163
|
-
> **query**(`cursor?`, `limit?`): `Promise`\<\{ `tenants`:
|
|
227
|
+
> **query**(`properties`, `cursor?`, `limit?`): `Promise`\<\{ `tenants`: `ITenant`[]; `cursor?`: `string`; \}\>
|
|
164
228
|
|
|
165
229
|
Query tenants with pagination.
|
|
166
230
|
|
|
167
231
|
#### Parameters
|
|
168
232
|
|
|
233
|
+
##### properties
|
|
234
|
+
|
|
235
|
+
keyof `ITenant`[] \| `undefined`
|
|
236
|
+
|
|
237
|
+
The properties to include in the returned tenants.
|
|
238
|
+
|
|
169
239
|
##### cursor?
|
|
170
240
|
|
|
171
241
|
`string`
|
|
@@ -180,10 +250,10 @@ The maximum number of tenants to return.
|
|
|
180
250
|
|
|
181
251
|
#### Returns
|
|
182
252
|
|
|
183
|
-
`Promise`\<\{ `tenants`:
|
|
253
|
+
`Promise`\<\{ `tenants`: `ITenant`[]; `cursor?`: `string`; \}\>
|
|
184
254
|
|
|
185
255
|
The tenants and the next cursor if more tenants are available.
|
|
186
256
|
|
|
187
257
|
#### Implementation of
|
|
188
258
|
|
|
189
|
-
|
|
259
|
+
`ITenantAdminComponent.query`
|
|
@@ -18,7 +18,7 @@ Context Id handler for testing as a tenant id.
|
|
|
18
18
|
|
|
19
19
|
## Properties
|
|
20
20
|
|
|
21
|
-
### CLASS\_NAME
|
|
21
|
+
### CLASS\_NAME {#class_name}
|
|
22
22
|
|
|
23
23
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
24
24
|
|
|
@@ -26,7 +26,25 @@ Runtime name for the class.
|
|
|
26
26
|
|
|
27
27
|
## Methods
|
|
28
28
|
|
|
29
|
-
###
|
|
29
|
+
### className() {#classname}
|
|
30
|
+
|
|
31
|
+
> **className**(): `string`
|
|
32
|
+
|
|
33
|
+
The class name of the component.
|
|
34
|
+
|
|
35
|
+
#### Returns
|
|
36
|
+
|
|
37
|
+
`string`
|
|
38
|
+
|
|
39
|
+
The class name.
|
|
40
|
+
|
|
41
|
+
#### Implementation of
|
|
42
|
+
|
|
43
|
+
`IContextIdHandler.className`
|
|
44
|
+
|
|
45
|
+
***
|
|
46
|
+
|
|
47
|
+
### short() {#short}
|
|
30
48
|
|
|
31
49
|
> **short**(`value`): `string`
|
|
32
50
|
|
|
@@ -52,7 +70,7 @@ Short form string.
|
|
|
52
70
|
|
|
53
71
|
***
|
|
54
72
|
|
|
55
|
-
### guard()
|
|
73
|
+
### guard() {#guard}
|
|
56
74
|
|
|
57
75
|
> **guard**(`value`): `void`
|
|
58
76
|
|
|
@@ -14,7 +14,7 @@ Helper class for tenant id related operations.
|
|
|
14
14
|
|
|
15
15
|
## Methods
|
|
16
16
|
|
|
17
|
-
### generateTenantId()
|
|
17
|
+
### generateTenantId() {#generatetenantid}
|
|
18
18
|
|
|
19
19
|
> `static` **generateTenantId**(): `string`
|
|
20
20
|
|
|
@@ -28,7 +28,7 @@ A new tenant ID.
|
|
|
28
28
|
|
|
29
29
|
***
|
|
30
30
|
|
|
31
|
-
### generateApiKey()
|
|
31
|
+
### generateApiKey() {#generateapikey}
|
|
32
32
|
|
|
33
33
|
> `static` **generateApiKey**(): `string`
|
|
34
34
|
|
|
@@ -12,7 +12,7 @@ Handles incoming api keys and maps them to tenant ids.
|
|
|
12
12
|
|
|
13
13
|
> **new TenantProcessor**(`options?`): `TenantProcessor`
|
|
14
14
|
|
|
15
|
-
Create a new instance of
|
|
15
|
+
Create a new instance of TenantProcessor.
|
|
16
16
|
|
|
17
17
|
#### Parameters
|
|
18
18
|
|
|
@@ -28,7 +28,7 @@ Options for the processor.
|
|
|
28
28
|
|
|
29
29
|
## Properties
|
|
30
30
|
|
|
31
|
-
### CLASS\_NAME
|
|
31
|
+
### CLASS\_NAME {#class_name}
|
|
32
32
|
|
|
33
33
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ Runtime name for the class.
|
|
|
36
36
|
|
|
37
37
|
## Methods
|
|
38
38
|
|
|
39
|
-
### className()
|
|
39
|
+
### className() {#classname}
|
|
40
40
|
|
|
41
41
|
> **className**(): `string`
|
|
42
42
|
|
|
@@ -54,7 +54,7 @@ The class name of the component.
|
|
|
54
54
|
|
|
55
55
|
***
|
|
56
56
|
|
|
57
|
-
### pre()
|
|
57
|
+
### pre() {#pre}
|
|
58
58
|
|
|
59
59
|
> **pre**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
|
|
60
60
|
|
|
@@ -76,9 +76,9 @@ The outgoing response.
|
|
|
76
76
|
|
|
77
77
|
##### route
|
|
78
78
|
|
|
79
|
-
|
|
79
|
+
`IBaseRoute` \| `undefined`
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
The route to process.
|
|
82
82
|
|
|
83
83
|
##### contextIds
|
|
84
84
|
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
# Class: TenantService
|
|
2
|
+
|
|
3
|
+
Service for performing tenant administration operations.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `ITenantComponent`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new TenantService**(`options?`): `TenantService`
|
|
14
|
+
|
|
15
|
+
Create a new instance of TenantService.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`ITenantAdminServiceConstructorOptions`](../interfaces/ITenantAdminServiceConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
The options for the connector.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`TenantService`
|
|
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
|
+
`ITenantComponent.className`
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### runPerTenant() {#runpertenant}
|
|
58
|
+
|
|
59
|
+
> **runPerTenant**(`method`): `Promise`\<`void`\>
|
|
60
|
+
|
|
61
|
+
Run a per tenant operation.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
##### method
|
|
66
|
+
|
|
67
|
+
() => `Promise`\<`void`\>
|
|
68
|
+
|
|
69
|
+
The method to run for each tenant.
|
|
70
|
+
|
|
71
|
+
#### Returns
|
|
72
|
+
|
|
73
|
+
`Promise`\<`void`\>
|
|
74
|
+
|
|
75
|
+
Nothing.
|
|
76
|
+
|
|
77
|
+
#### Implementation of
|
|
78
|
+
|
|
79
|
+
`ITenantComponent.runPerTenant`
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Function: generateRestRoutesTenants()
|
|
2
|
+
|
|
3
|
+
> **generateRestRoutesTenants**(`baseRouteName`, `componentName`): `IRestRoute`\<`any`, `any`\>[]
|
|
4
|
+
|
|
5
|
+
The REST routes for tenant management.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### baseRouteName
|
|
10
|
+
|
|
11
|
+
`string`
|
|
12
|
+
|
|
13
|
+
Prefix to prepend to the paths.
|
|
14
|
+
|
|
15
|
+
### componentName
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The name of the component to use in the routes stored in the ComponentFactory.
|
|
20
|
+
|
|
21
|
+
## Returns
|
|
22
|
+
|
|
23
|
+
`IRestRoute`\<`any`, `any`\>[]
|
|
24
|
+
|
|
25
|
+
The generated routes.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: tenantByApiKey()
|
|
2
|
+
|
|
3
|
+
> **tenantByApiKey**(`httpRequestContext`, `componentName`, `request`): `Promise`\<[`ITenantGetResponse`](../interfaces/ITenantGetResponse.md)\>
|
|
4
|
+
|
|
5
|
+
Get the tenant by api key.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### httpRequestContext
|
|
10
|
+
|
|
11
|
+
`IHttpRequestContext`
|
|
12
|
+
|
|
13
|
+
The request context for the API.
|
|
14
|
+
|
|
15
|
+
### componentName
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The name of the component to use in the routes.
|
|
20
|
+
|
|
21
|
+
### request
|
|
22
|
+
|
|
23
|
+
[`ITenantGetByApiKeyRequest`](../interfaces/ITenantGetByApiKeyRequest.md)
|
|
24
|
+
|
|
25
|
+
The request.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`Promise`\<[`ITenantGetResponse`](../interfaces/ITenantGetResponse.md)\>
|
|
30
|
+
|
|
31
|
+
The response object with additional http response properties.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: tenantById()
|
|
2
|
+
|
|
3
|
+
> **tenantById**(`httpRequestContext`, `componentName`, `request`): `Promise`\<[`ITenantGetResponse`](../interfaces/ITenantGetResponse.md)\>
|
|
4
|
+
|
|
5
|
+
Get the tenant by id.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### httpRequestContext
|
|
10
|
+
|
|
11
|
+
`IHttpRequestContext`
|
|
12
|
+
|
|
13
|
+
The request context for the API.
|
|
14
|
+
|
|
15
|
+
### componentName
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The name of the component to use in the routes.
|
|
20
|
+
|
|
21
|
+
### request
|
|
22
|
+
|
|
23
|
+
[`ITenantGetByIdRequest`](../interfaces/ITenantGetByIdRequest.md)
|
|
24
|
+
|
|
25
|
+
The request.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`Promise`\<[`ITenantGetResponse`](../interfaces/ITenantGetResponse.md)\>
|
|
30
|
+
|
|
31
|
+
The response object with additional http response properties.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: tenantByPublicOrigin()
|
|
2
|
+
|
|
3
|
+
> **tenantByPublicOrigin**(`httpRequestContext`, `componentName`, `request`): `Promise`\<[`ITenantGetResponse`](../interfaces/ITenantGetResponse.md)\>
|
|
4
|
+
|
|
5
|
+
Get the tenant by public origin.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### httpRequestContext
|
|
10
|
+
|
|
11
|
+
`IHttpRequestContext`
|
|
12
|
+
|
|
13
|
+
The request context for the API.
|
|
14
|
+
|
|
15
|
+
### componentName
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The name of the component to use in the routes.
|
|
20
|
+
|
|
21
|
+
### request
|
|
22
|
+
|
|
23
|
+
[`ITenantGetByPublicOriginRequest`](../interfaces/ITenantGetByPublicOriginRequest.md)
|
|
24
|
+
|
|
25
|
+
The request.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`Promise`\<[`ITenantGetResponse`](../interfaces/ITenantGetResponse.md)\>
|
|
30
|
+
|
|
31
|
+
The response object with additional http response properties.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Function: tenantCreate()
|
|
2
|
+
|
|
3
|
+
> **tenantCreate**(`httpRequestContext`, `componentName`, `request`): `Promise`\<`ICreatedResponse`\>
|
|
4
|
+
|
|
5
|
+
Create the tenant.
|
|
6
|
+
|
|
7
|
+
## Parameters
|
|
8
|
+
|
|
9
|
+
### httpRequestContext
|
|
10
|
+
|
|
11
|
+
`IHttpRequestContext`
|
|
12
|
+
|
|
13
|
+
The request context for the API.
|
|
14
|
+
|
|
15
|
+
### componentName
|
|
16
|
+
|
|
17
|
+
`string`
|
|
18
|
+
|
|
19
|
+
The name of the component to use in the routes.
|
|
20
|
+
|
|
21
|
+
### request
|
|
22
|
+
|
|
23
|
+
[`ITenantCreateRequest`](../interfaces/ITenantCreateRequest.md)
|
|
24
|
+
|
|
25
|
+
The request.
|
|
26
|
+
|
|
27
|
+
## Returns
|
|
28
|
+
|
|
29
|
+
`Promise`\<`ICreatedResponse`\>
|
|
30
|
+
|
|
31
|
+
The response object with additional http response properties.
|