@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,99 @@
|
|
|
1
|
+
# Class: TenantProcessor
|
|
2
|
+
|
|
3
|
+
Handles incoming api keys and maps them to tenant ids.
|
|
4
|
+
|
|
5
|
+
## Implements
|
|
6
|
+
|
|
7
|
+
- `IBaseRouteProcessor`
|
|
8
|
+
|
|
9
|
+
## Constructors
|
|
10
|
+
|
|
11
|
+
### Constructor
|
|
12
|
+
|
|
13
|
+
> **new TenantProcessor**(`options?`): `TenantProcessor`
|
|
14
|
+
|
|
15
|
+
Create a new instance of NodeTenantProcessor.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### options?
|
|
20
|
+
|
|
21
|
+
[`ITenantProcessorConstructorOptions`](../interfaces/ITenantProcessorConstructorOptions.md)
|
|
22
|
+
|
|
23
|
+
Options for the processor.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`TenantProcessor`
|
|
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
|
+
`IBaseRouteProcessor.className`
|
|
54
|
+
|
|
55
|
+
***
|
|
56
|
+
|
|
57
|
+
### pre()
|
|
58
|
+
|
|
59
|
+
> **pre**(`request`, `response`, `route`, `contextIds`, `processorState`): `Promise`\<`void`\>
|
|
60
|
+
|
|
61
|
+
Pre process the REST request for the specified route.
|
|
62
|
+
|
|
63
|
+
#### Parameters
|
|
64
|
+
|
|
65
|
+
##### request
|
|
66
|
+
|
|
67
|
+
`IHttpServerRequest`
|
|
68
|
+
|
|
69
|
+
The incoming request.
|
|
70
|
+
|
|
71
|
+
##### response
|
|
72
|
+
|
|
73
|
+
`IHttpResponse`
|
|
74
|
+
|
|
75
|
+
The outgoing response.
|
|
76
|
+
|
|
77
|
+
##### route
|
|
78
|
+
|
|
79
|
+
The route to process.
|
|
80
|
+
|
|
81
|
+
`IBaseRoute` | `undefined`
|
|
82
|
+
|
|
83
|
+
##### contextIds
|
|
84
|
+
|
|
85
|
+
`IContextIds`
|
|
86
|
+
|
|
87
|
+
The context IDs of the request.
|
|
88
|
+
|
|
89
|
+
##### processorState
|
|
90
|
+
|
|
91
|
+
The state handed through the processors.
|
|
92
|
+
|
|
93
|
+
#### Returns
|
|
94
|
+
|
|
95
|
+
`Promise`\<`void`\>
|
|
96
|
+
|
|
97
|
+
#### Implementation of
|
|
98
|
+
|
|
99
|
+
`IBaseRouteProcessor.pre`
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# @twin.org/api-tenant-processor
|
|
2
|
+
|
|
3
|
+
## Classes
|
|
4
|
+
|
|
5
|
+
- [Tenant](classes/Tenant.md)
|
|
6
|
+
- [TenantAdminService](classes/TenantAdminService.md)
|
|
7
|
+
- [TenantIdContextIdHandler](classes/TenantIdContextIdHandler.md)
|
|
8
|
+
- [TenantProcessor](classes/TenantProcessor.md)
|
|
9
|
+
- [TenantIdHelper](classes/TenantIdHelper.md)
|
|
10
|
+
|
|
11
|
+
## Interfaces
|
|
12
|
+
|
|
13
|
+
- [ITenant](interfaces/ITenant.md)
|
|
14
|
+
- [ITenantAdminComponent](interfaces/ITenantAdminComponent.md)
|
|
15
|
+
- [ITenantAdminServiceConfig](interfaces/ITenantAdminServiceConfig.md)
|
|
16
|
+
- [ITenantAdminServiceConstructorOptions](interfaces/ITenantAdminServiceConstructorOptions.md)
|
|
17
|
+
- [ITenantProcessorConfig](interfaces/ITenantProcessorConfig.md)
|
|
18
|
+
- [ITenantProcessorConstructorOptions](interfaces/ITenantProcessorConstructorOptions.md)
|
|
19
|
+
|
|
20
|
+
## Functions
|
|
21
|
+
|
|
22
|
+
- [initSchema](functions/initSchema.md)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Interface: ITenant
|
|
2
|
+
|
|
3
|
+
Model defining the tenant.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### id
|
|
8
|
+
|
|
9
|
+
> **id**: `string`
|
|
10
|
+
|
|
11
|
+
The unique identifier for the tenant.
|
|
12
|
+
|
|
13
|
+
***
|
|
14
|
+
|
|
15
|
+
### apiKey
|
|
16
|
+
|
|
17
|
+
> **apiKey**: `string`
|
|
18
|
+
|
|
19
|
+
The api key for the tenant.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### label
|
|
24
|
+
|
|
25
|
+
> **label**: `string`
|
|
26
|
+
|
|
27
|
+
The label of the tenant.
|
|
28
|
+
|
|
29
|
+
***
|
|
30
|
+
|
|
31
|
+
### dateCreated
|
|
32
|
+
|
|
33
|
+
> **dateCreated**: `string`
|
|
34
|
+
|
|
35
|
+
The date the tenant was created.
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# Interface: ITenantAdminComponent
|
|
2
|
+
|
|
3
|
+
Configuration for the tenant admin component
|
|
4
|
+
|
|
5
|
+
## Extends
|
|
6
|
+
|
|
7
|
+
- `IComponent`
|
|
8
|
+
|
|
9
|
+
## Methods
|
|
10
|
+
|
|
11
|
+
### get()
|
|
12
|
+
|
|
13
|
+
> **get**(`tenantId`): `Promise`\<[`ITenant`](ITenant.md) \| `undefined`\>
|
|
14
|
+
|
|
15
|
+
Get a tenant by its id.
|
|
16
|
+
|
|
17
|
+
#### Parameters
|
|
18
|
+
|
|
19
|
+
##### tenantId
|
|
20
|
+
|
|
21
|
+
`string`
|
|
22
|
+
|
|
23
|
+
The id of the tenant.
|
|
24
|
+
|
|
25
|
+
#### Returns
|
|
26
|
+
|
|
27
|
+
`Promise`\<[`ITenant`](ITenant.md) \| `undefined`\>
|
|
28
|
+
|
|
29
|
+
The tenant or undefined if not found.
|
|
30
|
+
|
|
31
|
+
***
|
|
32
|
+
|
|
33
|
+
### getByApiKey()
|
|
34
|
+
|
|
35
|
+
> **getByApiKey**(`apiKey`): `Promise`\<[`ITenant`](ITenant.md) \| `undefined`\>
|
|
36
|
+
|
|
37
|
+
Get a tenant by its api key.
|
|
38
|
+
|
|
39
|
+
#### Parameters
|
|
40
|
+
|
|
41
|
+
##### apiKey
|
|
42
|
+
|
|
43
|
+
`string`
|
|
44
|
+
|
|
45
|
+
The api key of the tenant.
|
|
46
|
+
|
|
47
|
+
#### Returns
|
|
48
|
+
|
|
49
|
+
`Promise`\<[`ITenant`](ITenant.md) \| `undefined`\>
|
|
50
|
+
|
|
51
|
+
The tenant or undefined if not found.
|
|
52
|
+
|
|
53
|
+
***
|
|
54
|
+
|
|
55
|
+
### set()
|
|
56
|
+
|
|
57
|
+
> **set**(`tenant`): `Promise`\<`void`\>
|
|
58
|
+
|
|
59
|
+
Set a tenant.
|
|
60
|
+
|
|
61
|
+
#### Parameters
|
|
62
|
+
|
|
63
|
+
##### tenant
|
|
64
|
+
|
|
65
|
+
[`ITenant`](ITenant.md)
|
|
66
|
+
|
|
67
|
+
The tenant to store.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`Promise`\<`void`\>
|
|
72
|
+
|
|
73
|
+
Nothing.
|
|
74
|
+
|
|
75
|
+
***
|
|
76
|
+
|
|
77
|
+
### remove()
|
|
78
|
+
|
|
79
|
+
> **remove**(`tenantId`): `Promise`\<`void`\>
|
|
80
|
+
|
|
81
|
+
Remove a tenant by its id.
|
|
82
|
+
|
|
83
|
+
#### Parameters
|
|
84
|
+
|
|
85
|
+
##### tenantId
|
|
86
|
+
|
|
87
|
+
`string`
|
|
88
|
+
|
|
89
|
+
The id of the tenant.
|
|
90
|
+
|
|
91
|
+
#### Returns
|
|
92
|
+
|
|
93
|
+
`Promise`\<`void`\>
|
|
94
|
+
|
|
95
|
+
Nothing.
|
|
96
|
+
|
|
97
|
+
***
|
|
98
|
+
|
|
99
|
+
### query()
|
|
100
|
+
|
|
101
|
+
> **query**(`cursor?`, `limit?`): `Promise`\<\{ `tenants`: [`ITenant`](ITenant.md)[]; `cursor?`: `string`; \}\>
|
|
102
|
+
|
|
103
|
+
Query tenants with pagination.
|
|
104
|
+
|
|
105
|
+
#### Parameters
|
|
106
|
+
|
|
107
|
+
##### cursor?
|
|
108
|
+
|
|
109
|
+
`string`
|
|
110
|
+
|
|
111
|
+
The cursor to start from.
|
|
112
|
+
|
|
113
|
+
##### limit?
|
|
114
|
+
|
|
115
|
+
`number`
|
|
116
|
+
|
|
117
|
+
The maximum number of tenants to return.
|
|
118
|
+
|
|
119
|
+
#### Returns
|
|
120
|
+
|
|
121
|
+
`Promise`\<\{ `tenants`: [`ITenant`](ITenant.md)[]; `cursor?`: `string`; \}\>
|
|
122
|
+
|
|
123
|
+
The tenants and the next cursor if more tenants are available.
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Interface: ITenantAdminServiceConstructorOptions
|
|
2
|
+
|
|
3
|
+
Options for the Tenant Admin Service constructor.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### tenantEntityStorageType?
|
|
8
|
+
|
|
9
|
+
> `optional` **tenantEntityStorageType**: `string`
|
|
10
|
+
|
|
11
|
+
The entity storage for the tenants.
|
|
12
|
+
|
|
13
|
+
#### Default
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
tenant
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### config?
|
|
22
|
+
|
|
23
|
+
> `optional` **config**: [`ITenantAdminServiceConfig`](ITenantAdminServiceConfig.md)
|
|
24
|
+
|
|
25
|
+
Configuration for the admin service.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Interface: ITenantProcessorConfig
|
|
2
|
+
|
|
3
|
+
Configuration for the tenant processor
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### apiKeyName?
|
|
8
|
+
|
|
9
|
+
> `optional` **apiKeyName**: `string`
|
|
10
|
+
|
|
11
|
+
The key to look for in the header or query params for the api key.
|
|
12
|
+
|
|
13
|
+
#### Default
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
x-api-key
|
|
17
|
+
```
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Interface: ITenantProcessorConstructorOptions
|
|
2
|
+
|
|
3
|
+
Options for the Tenant Processor constructor.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
### tenantEntityStorageType?
|
|
8
|
+
|
|
9
|
+
> `optional` **tenantEntityStorageType**: `string`
|
|
10
|
+
|
|
11
|
+
The entity storage for the tenants.
|
|
12
|
+
|
|
13
|
+
#### Default
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
tenant
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
***
|
|
20
|
+
|
|
21
|
+
### config?
|
|
22
|
+
|
|
23
|
+
> `optional` **config**: [`ITenantProcessorConfig`](ITenantProcessorConfig.md)
|
|
24
|
+
|
|
25
|
+
Configuration for the processor.
|
package/locales/en.json
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@twin.org/api-tenant-processor",
|
|
3
|
+
"version": "0.0.3-next.1",
|
|
4
|
+
"description": "API Tenant Processor for converting and api key to a tenant id.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/twinfoundation/api.git",
|
|
8
|
+
"directory": "packages/api-tenant-processor"
|
|
9
|
+
},
|
|
10
|
+
"author": "martyn.janes@iota.org",
|
|
11
|
+
"license": "Apache-2.0",
|
|
12
|
+
"type": "module",
|
|
13
|
+
"engines": {
|
|
14
|
+
"node": ">=20.0.0"
|
|
15
|
+
},
|
|
16
|
+
"dependencies": {
|
|
17
|
+
"@twin.org/api-models": "0.0.3-next.1",
|
|
18
|
+
"@twin.org/context": "next",
|
|
19
|
+
"@twin.org/core": "next",
|
|
20
|
+
"@twin.org/entity": "next",
|
|
21
|
+
"@twin.org/entity-storage-models": "next",
|
|
22
|
+
"@twin.org/nameof": "next",
|
|
23
|
+
"@twin.org/web": "next"
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/es/index.js",
|
|
26
|
+
"types": "./dist/types/index.d.ts",
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"types": "./dist/types/index.d.ts",
|
|
30
|
+
"import": "./dist/es/index.js",
|
|
31
|
+
"default": "./dist/es/index.js"
|
|
32
|
+
},
|
|
33
|
+
"./locales/*.json": "./locales/*.json"
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist/es",
|
|
37
|
+
"dist/types",
|
|
38
|
+
"locales",
|
|
39
|
+
"docs"
|
|
40
|
+
],
|
|
41
|
+
"keywords": [
|
|
42
|
+
"twin",
|
|
43
|
+
"trade",
|
|
44
|
+
"iota",
|
|
45
|
+
"framework",
|
|
46
|
+
"blockchain",
|
|
47
|
+
"node",
|
|
48
|
+
"tenant",
|
|
49
|
+
"foundation",
|
|
50
|
+
"utilities"
|
|
51
|
+
],
|
|
52
|
+
"bugs": {
|
|
53
|
+
"url": "git+https://github.com/twinfoundation/api/issues"
|
|
54
|
+
},
|
|
55
|
+
"homepage": "https://twindev.org"
|
|
56
|
+
}
|