@aligent/microservice-util-lib 1.0.0 → 1.2.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/README.md +2 -2
- package/docs/classes/S3Dao.md +102 -107
- package/docs/functions/apiKeyAuthMiddleware.md +37 -0
- package/docs/functions/basicAuthMiddleware.md +37 -0
- package/docs/functions/chunkBy.md +43 -0
- package/docs/functions/fetchSsmParams.md +61 -0
- package/docs/functions/getAwsIdFromArn.md +37 -0
- package/docs/functions/hasDefinedProperties.md +57 -0
- package/docs/functions/oAuth10aAuthMiddleware.md +43 -0
- package/docs/functions/oAuth20AuthMiddleware.md +37 -0
- package/docs/functions/remap.md +71 -0
- package/docs/functions/retryWrapper.md +46 -0
- package/docs/interfaces/ApiKey.md +44 -0
- package/docs/interfaces/Basic.md +32 -0
- package/docs/interfaces/OAuth10a.md +93 -0
- package/docs/interfaces/OAuth20.md +44 -0
- package/docs/interfaces/RetryConfig.md +53 -42
- package/docs/modules.md +21 -302
- package/docs/type-aliases/ObjectMap.md +13 -0
- package/docs/type-aliases/Remap.md +21 -0
- package/package.json +15 -40
- package/{dist/chunkBy/chunkBy.js → src/chunk-by/chunk-by.js} +3 -4
- package/{dist/fetchSsmParams/fetchSsmParams.d.ts → src/fetch-ssm-params/fetch-ssm-params.d.ts} +2 -2
- package/src/fetch-ssm-params/fetch-ssm-params.js +28 -0
- package/{dist/getAwsIdFromArn/getAwsIdFromArn.js → src/get-aws-id-from-arn/get-aws-id-from-arn.js} +2 -3
- package/{dist/hasPropertiesDefined/hasPropertiesDefined.js → src/has-properties-defined/has-properties-defined.js} +2 -8
- package/src/index.d.ts +11 -0
- package/src/index.js +26 -0
- package/src/openapi-fetch-middlewares/authentications.d.ts +66 -0
- package/src/openapi-fetch-middlewares/authentications.js +96 -0
- package/src/openapi-fetch-middlewares/oauth10a/oauth10a.d.ts +12 -0
- package/src/openapi-fetch-middlewares/oauth10a/oauth10a.js +209 -0
- package/src/openapi-fetch-middlewares/retry.d.ts +54 -0
- package/src/openapi-fetch-middlewares/retry.js +218 -0
- package/src/openapi-fetch-middlewares/types/authentications.d.ts +71 -0
- package/src/openapi-fetch-middlewares/types/authentications.js +2 -0
- package/src/openapi-fetch-middlewares/types/retry.d.ts +93 -0
- package/src/openapi-fetch-middlewares/types/retry.js +2 -0
- package/src/openapi-fetch-middlewares/utils/is-network-error.d.ts +5 -0
- package/src/openapi-fetch-middlewares/utils/is-network-error.js +40 -0
- package/{dist → src}/remap/remap.d.ts +6 -6
- package/src/remap/remap.js +97 -0
- package/{dist/retryWrapper/retryWrapper.d.ts → src/retry-wrapper/retry-wrapper.d.ts} +1 -1
- package/src/retry-wrapper/retry-wrapper.js +56 -0
- package/{dist → src}/s3/s3.d.ts +2 -2
- package/src/s3/s3.js +86 -0
- package/dist/chunkBy/chunkBy.js.map +0 -1
- package/dist/chunkBy/chunkBy.test.d.ts +0 -1
- package/dist/chunkBy/chunkBy.test.js +0 -17
- package/dist/chunkBy/chunkBy.test.js.map +0 -1
- package/dist/fetchSsmParams/fetchSsmParams.js +0 -80
- package/dist/fetchSsmParams/fetchSsmParams.js.map +0 -1
- package/dist/fetchSsmParams/fetchSsmParams.test.d.ts +0 -1
- package/dist/fetchSsmParams/fetchSsmParams.test.js +0 -110
- package/dist/fetchSsmParams/fetchSsmParams.test.js.map +0 -1
- package/dist/getAwsIdFromArn/getAwsIdFromArn.js.map +0 -1
- package/dist/getAwsIdFromArn/getAwsIdFromArn.test.d.ts +0 -1
- package/dist/getAwsIdFromArn/getAwsIdFromArn.test.js +0 -20
- package/dist/getAwsIdFromArn/getAwsIdFromArn.test.js.map +0 -1
- package/dist/hasPropertiesDefined/hasPropertiesDefined.js.map +0 -1
- package/dist/hasPropertiesDefined/hasPropertiesDefined.test.d.ts +0 -1
- package/dist/hasPropertiesDefined/hasPropertiesDefined.test.js +0 -37
- package/dist/hasPropertiesDefined/hasPropertiesDefined.test.js.map +0 -1
- package/dist/index.d.ts +0 -8
- package/dist/index.js +0 -21
- package/dist/index.js.map +0 -1
- package/dist/remap/remap.js +0 -50
- package/dist/remap/remap.js.map +0 -1
- package/dist/remap/remap.test.d.ts +0 -1
- package/dist/remap/remap.test.js +0 -65
- package/dist/remap/remap.test.js.map +0 -1
- package/dist/retryWrapper/retryWrapper.js +0 -121
- package/dist/retryWrapper/retryWrapper.js.map +0 -1
- package/dist/retryWrapper/retryWrapper.test.d.ts +0 -1
- package/dist/retryWrapper/retryWrapper.test.js +0 -234
- package/dist/retryWrapper/retryWrapper.test.js.map +0 -1
- package/dist/s3/s3.js +0 -190
- package/dist/s3/s3.js.map +0 -1
- package/dist/s3/s3.test.d.ts +0 -1
- package/dist/s3/s3.test.js +0 -126
- package/dist/s3/s3.test.js.map +0 -1
- /package/{dist/chunkBy/chunkBy.d.ts → src/chunk-by/chunk-by.d.ts} +0 -0
- /package/{dist/getAwsIdFromArn/getAwsIdFromArn.d.ts → src/get-aws-id-from-arn/get-aws-id-from-arn.d.ts} +0 -0
- /package/{dist/hasPropertiesDefined/hasPropertiesDefined.d.ts → src/has-properties-defined/has-properties-defined.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Microservices Utilities Library
|
|
2
2
|
|
|
3
|
-
This library includes utility functions to simplify & standardise common
|
|
3
|
+
This library includes utility functions to simplify & standardise common
|
|
4
4
|
MicroServices tasks.
|
|
5
5
|
|
|
6
6
|
## Documentation
|
|
@@ -29,7 +29,7 @@ from your project root.
|
|
|
29
29
|
|
|
30
30
|
## Testing & Linting
|
|
31
31
|
|
|
32
|
-
|
|
32
|
+
Vitest tests, linting & type-checking can be run with
|
|
33
33
|
|
|
34
34
|
```sh
|
|
35
35
|
npm run test
|
package/docs/classes/S3Dao.md
CHANGED
|
@@ -1,206 +1,201 @@
|
|
|
1
|
-
[
|
|
2
|
-
|
|
3
|
-
# Class: S3Dao
|
|
4
|
-
|
|
5
|
-
A data access object for an S3 bucket
|
|
6
|
-
|
|
7
|
-
## Table of contents
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
8
2
|
|
|
9
|
-
|
|
3
|
+
***
|
|
10
4
|
|
|
11
|
-
-
|
|
12
|
-
|
|
13
|
-
### Properties
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / S3Dao
|
|
14
6
|
|
|
15
|
-
|
|
16
|
-
- [s3](S3Dao.md#s3)
|
|
7
|
+
# Class: S3Dao
|
|
17
8
|
|
|
18
|
-
|
|
9
|
+
Defined in: [s3/s3.ts:12](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/s3/s3.ts#L12)
|
|
19
10
|
|
|
20
|
-
|
|
21
|
-
- [fetchChunks](S3Dao.md#fetchchunks)
|
|
22
|
-
- [fetchData](S3Dao.md#fetchdata)
|
|
23
|
-
- [storeChunked](S3Dao.md#storechunked)
|
|
24
|
-
- [storeData](S3Dao.md#storedata)
|
|
11
|
+
A data access object for an S3 bucket
|
|
25
12
|
|
|
26
13
|
## Constructors
|
|
27
14
|
|
|
28
|
-
|
|
15
|
+
<a id="constructor"></a>
|
|
29
16
|
|
|
30
|
-
|
|
17
|
+
### Constructor
|
|
31
18
|
|
|
32
|
-
|
|
19
|
+
> **new S3Dao**(`bucket`): `S3Dao`
|
|
33
20
|
|
|
34
|
-
|
|
35
|
-
| :------ | :------ | :------ |
|
|
36
|
-
| `bucket` | `string` | the location of the bucket that objects should be stored in |
|
|
21
|
+
Defined in: [s3/s3.ts:19](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/s3/s3.ts#L19)
|
|
37
22
|
|
|
38
|
-
####
|
|
39
|
-
|
|
40
|
-
[s3/s3.ts:19](https://bitbucket.org/aligent/microservice-util-lib/src/5ba81bd/src/s3/s3.ts#lines-19)
|
|
41
|
-
|
|
42
|
-
## Properties
|
|
43
|
-
|
|
44
|
-
### <a id="bucket" name="bucket"></a> bucket
|
|
45
|
-
|
|
46
|
-
• `Private` **bucket**: `string`
|
|
23
|
+
#### Parameters
|
|
47
24
|
|
|
48
|
-
|
|
25
|
+
##### bucket
|
|
49
26
|
|
|
50
|
-
|
|
27
|
+
`string`
|
|
51
28
|
|
|
52
|
-
|
|
29
|
+
the location of the bucket that objects should be stored in
|
|
53
30
|
|
|
54
|
-
|
|
31
|
+
#### Returns
|
|
55
32
|
|
|
56
|
-
|
|
33
|
+
`S3Dao`
|
|
57
34
|
|
|
58
|
-
|
|
35
|
+
## Methods
|
|
59
36
|
|
|
60
|
-
|
|
37
|
+
<a id="deletedata"></a>
|
|
61
38
|
|
|
62
|
-
|
|
39
|
+
### deleteData()
|
|
63
40
|
|
|
64
|
-
|
|
41
|
+
> **deleteData**(`objectDetails`): `Promise`\<`DeleteObjectCommandOutput`\>
|
|
65
42
|
|
|
66
|
-
|
|
43
|
+
Defined in: [s3/s3.ts:100](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/s3/s3.ts#L100)
|
|
67
44
|
|
|
68
45
|
Delete an object from the S3 bucket
|
|
69
46
|
|
|
70
47
|
#### Parameters
|
|
71
48
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
49
|
+
##### objectDetails
|
|
50
|
+
|
|
51
|
+
`GetObjectCommandInput`
|
|
52
|
+
|
|
53
|
+
the object to delete
|
|
75
54
|
|
|
76
55
|
#### Returns
|
|
77
56
|
|
|
78
|
-
`Promise
|
|
57
|
+
`Promise`\<`DeleteObjectCommandOutput`\>
|
|
79
58
|
|
|
80
|
-
|
|
59
|
+
***
|
|
81
60
|
|
|
82
|
-
|
|
61
|
+
<a id="fetchchunks"></a>
|
|
83
62
|
|
|
84
|
-
|
|
63
|
+
### fetchChunks()
|
|
85
64
|
|
|
86
|
-
|
|
65
|
+
> **fetchChunks**\<`T`\>(`chunks`): `AsyncGenerator`\<\{ `chunk`: `T`; `s3Object`: `undefined` \| `GetObjectCommandInput`; \}, `Awaited`\<`T`\>, `unknown`\>
|
|
87
66
|
|
|
88
|
-
|
|
67
|
+
Defined in: [s3/s3.ts:81](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/s3/s3.ts#L81)
|
|
89
68
|
|
|
90
69
|
Generator to fetch chunked data, chunk by chunk
|
|
91
70
|
|
|
92
|
-
#### Type
|
|
71
|
+
#### Type Parameters
|
|
93
72
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
73
|
+
##### T
|
|
74
|
+
|
|
75
|
+
`T`
|
|
97
76
|
|
|
98
77
|
#### Parameters
|
|
99
78
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
79
|
+
##### chunks
|
|
80
|
+
|
|
81
|
+
`GetObjectCommandInput`[]
|
|
82
|
+
|
|
83
|
+
the list of object chunks
|
|
103
84
|
|
|
104
85
|
#### Returns
|
|
105
86
|
|
|
106
|
-
`AsyncGenerator
|
|
87
|
+
`AsyncGenerator`\<\{ `chunk`: `T`; `s3Object`: `undefined` \| `GetObjectCommandInput`; \}, `Awaited`\<`T`\>, `unknown`\>
|
|
107
88
|
|
|
108
|
-
|
|
89
|
+
***
|
|
109
90
|
|
|
110
|
-
|
|
91
|
+
<a id="fetchdata"></a>
|
|
111
92
|
|
|
112
|
-
|
|
93
|
+
### fetchData()
|
|
113
94
|
|
|
114
|
-
|
|
95
|
+
> **fetchData**\<`T`\>(`objectDetails`): `Promise`\<`T`\>
|
|
115
96
|
|
|
116
|
-
|
|
97
|
+
Defined in: [s3/s3.ts:66](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/s3/s3.ts#L66)
|
|
117
98
|
|
|
118
99
|
Fetch an object from the S3 bucket
|
|
119
100
|
|
|
120
|
-
#### Type
|
|
101
|
+
#### Type Parameters
|
|
121
102
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
103
|
+
##### T
|
|
104
|
+
|
|
105
|
+
`T`
|
|
125
106
|
|
|
126
107
|
#### Parameters
|
|
127
108
|
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
109
|
+
##### objectDetails
|
|
110
|
+
|
|
111
|
+
`GetObjectCommandInput`
|
|
112
|
+
|
|
113
|
+
the object which describes the location of the object
|
|
131
114
|
|
|
132
115
|
#### Returns
|
|
133
116
|
|
|
134
|
-
`Promise
|
|
117
|
+
`Promise`\<`T`\>
|
|
135
118
|
|
|
136
119
|
the body of the object
|
|
137
120
|
|
|
138
|
-
|
|
121
|
+
***
|
|
139
122
|
|
|
140
|
-
|
|
123
|
+
<a id="storechunked"></a>
|
|
141
124
|
|
|
142
|
-
|
|
125
|
+
### storeChunked()
|
|
143
126
|
|
|
144
|
-
|
|
127
|
+
> **storeChunked**\<`T`\>(`data`, `chunkSize`): `Promise`\<`GetObjectCommandInput`[]\>
|
|
145
128
|
|
|
146
|
-
|
|
129
|
+
Defined in: [s3/s3.ts:56](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/s3/s3.ts#L56)
|
|
147
130
|
|
|
148
131
|
Store an array of object as individual chunks in S3
|
|
149
132
|
|
|
150
|
-
#### Type
|
|
133
|
+
#### Type Parameters
|
|
134
|
+
|
|
135
|
+
##### T
|
|
151
136
|
|
|
152
|
-
|
|
153
|
-
| :------ | :------ |
|
|
154
|
-
| `T` | extends `any`[] |
|
|
137
|
+
`T` *extends* `unknown`[]
|
|
155
138
|
|
|
156
139
|
#### Parameters
|
|
157
140
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
141
|
+
##### data
|
|
142
|
+
|
|
143
|
+
`T`
|
|
144
|
+
|
|
145
|
+
the data to store
|
|
146
|
+
|
|
147
|
+
##### chunkSize
|
|
148
|
+
|
|
149
|
+
`number`
|
|
150
|
+
|
|
151
|
+
the number of entries that should be in each chunk
|
|
162
152
|
|
|
163
153
|
#### Returns
|
|
164
154
|
|
|
165
|
-
`Promise
|
|
155
|
+
`Promise`\<`GetObjectCommandInput`[]\>
|
|
166
156
|
|
|
167
157
|
an array of objects which can be used to fetch the chunks
|
|
168
158
|
|
|
169
|
-
|
|
159
|
+
***
|
|
170
160
|
|
|
171
|
-
|
|
161
|
+
<a id="storedata"></a>
|
|
172
162
|
|
|
173
|
-
|
|
163
|
+
### storeData()
|
|
174
164
|
|
|
175
|
-
|
|
165
|
+
> **storeData**\<`T`\>(`data`, `name`?): `Promise`\<`GetObjectCommandInput`\>
|
|
176
166
|
|
|
177
|
-
|
|
167
|
+
Defined in: [s3/s3.ts:30](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/s3/s3.ts#L30)
|
|
178
168
|
|
|
179
169
|
Store data in an S3 bucket
|
|
180
170
|
|
|
181
|
-
|
|
171
|
+
#### Type Parameters
|
|
182
172
|
|
|
183
|
-
|
|
173
|
+
##### T
|
|
184
174
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
| Name |
|
|
188
|
-
| :------ |
|
|
189
|
-
| `T` |
|
|
175
|
+
`T`
|
|
190
176
|
|
|
191
177
|
#### Parameters
|
|
192
178
|
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
179
|
+
##### data
|
|
180
|
+
|
|
181
|
+
`T`
|
|
182
|
+
|
|
183
|
+
the data to store
|
|
184
|
+
|
|
185
|
+
##### name?
|
|
186
|
+
|
|
187
|
+
`string`
|
|
188
|
+
|
|
189
|
+
the name to call the object in S3
|
|
197
190
|
|
|
198
191
|
#### Returns
|
|
199
192
|
|
|
200
|
-
`Promise
|
|
193
|
+
`Promise`\<`GetObjectCommandInput`\>
|
|
201
194
|
|
|
202
195
|
an object which can be used to fetch the data
|
|
203
196
|
|
|
204
|
-
####
|
|
197
|
+
#### Default
|
|
205
198
|
|
|
206
|
-
|
|
199
|
+
```ts
|
|
200
|
+
the hash of the data
|
|
201
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / apiKeyAuthMiddleware
|
|
6
|
+
|
|
7
|
+
# Function: apiKeyAuthMiddleware()
|
|
8
|
+
|
|
9
|
+
> **apiKeyAuthMiddleware**(`config`): `Middleware`
|
|
10
|
+
|
|
11
|
+
Defined in: [openapi-fetch-middlewares/authentications.ts:18](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/openapi-fetch-middlewares/authentications.ts#L18)
|
|
12
|
+
|
|
13
|
+
Creates an openapi-fetch middleware for API key authentication.
|
|
14
|
+
This middleware sets the API key in the specified header for each request.
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### config
|
|
19
|
+
|
|
20
|
+
[`ApiKey`](../interfaces/ApiKey.md)
|
|
21
|
+
|
|
22
|
+
The configuration for API key authentication.
|
|
23
|
+
|
|
24
|
+
## Returns
|
|
25
|
+
|
|
26
|
+
`Middleware`
|
|
27
|
+
|
|
28
|
+
The middleware for API key authentication.
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const middleware = apiKeyAuthMiddleware({
|
|
34
|
+
header: 'x-api-key',
|
|
35
|
+
value: async () => 'your-api-key',
|
|
36
|
+
});
|
|
37
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / basicAuthMiddleware
|
|
6
|
+
|
|
7
|
+
# Function: basicAuthMiddleware()
|
|
8
|
+
|
|
9
|
+
> **basicAuthMiddleware**(`config`): `Middleware`
|
|
10
|
+
|
|
11
|
+
Defined in: [openapi-fetch-middlewares/authentications.ts:39](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/openapi-fetch-middlewares/authentications.ts#L39)
|
|
12
|
+
|
|
13
|
+
Creates an openapi-fetch middleware for Basic authentication.
|
|
14
|
+
This middleware sets the `Authorization` header with the Basic authentication credentials
|
|
15
|
+
(username and password) for each request.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
### config
|
|
20
|
+
|
|
21
|
+
[`Basic`](../interfaces/Basic.md)
|
|
22
|
+
|
|
23
|
+
The configuration for Basic authentication.
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
`Middleware`
|
|
28
|
+
|
|
29
|
+
The middleware for Basic authentication.
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const middleware = basicAuthMiddleware({
|
|
35
|
+
credentials: async () => ({ username: 'user', password: 'pass' }),
|
|
36
|
+
});
|
|
37
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / chunkBy
|
|
6
|
+
|
|
7
|
+
# Function: chunkBy()
|
|
8
|
+
|
|
9
|
+
> **chunkBy**\<`ArrayItem`\>(`source`, `chunkSize`): `ArrayItem`[][]
|
|
10
|
+
|
|
11
|
+
Defined in: [chunk-by/chunk-by.ts:10](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/chunk-by/chunk-by.ts#L10)
|
|
12
|
+
|
|
13
|
+
Split an array into chunks of a certain size
|
|
14
|
+
|
|
15
|
+
## Type Parameters
|
|
16
|
+
|
|
17
|
+
### ArrayItem
|
|
18
|
+
|
|
19
|
+
`ArrayItem`
|
|
20
|
+
|
|
21
|
+
## Parameters
|
|
22
|
+
|
|
23
|
+
### source
|
|
24
|
+
|
|
25
|
+
`ArrayItem`[]
|
|
26
|
+
|
|
27
|
+
the array to split up
|
|
28
|
+
|
|
29
|
+
### chunkSize
|
|
30
|
+
|
|
31
|
+
`number`
|
|
32
|
+
|
|
33
|
+
the size of each chunk. (The final chunk will be whatever is remaining)
|
|
34
|
+
|
|
35
|
+
## Returns
|
|
36
|
+
|
|
37
|
+
`ArrayItem`[][]
|
|
38
|
+
|
|
39
|
+
## Example
|
|
40
|
+
|
|
41
|
+
```ts
|
|
42
|
+
chunkBy([1, 2, 3, 4, 5, 6, 7], 2) // [[1, 2], [3, 4], [5, 6], [7]]
|
|
43
|
+
```
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / fetchSsmParams
|
|
6
|
+
|
|
7
|
+
# Function: fetchSsmParams()
|
|
8
|
+
|
|
9
|
+
Fetch SSM Parameters
|
|
10
|
+
|
|
11
|
+
## Param
|
|
12
|
+
|
|
13
|
+
the keys of the parameters to fetch
|
|
14
|
+
|
|
15
|
+
## Call Signature
|
|
16
|
+
|
|
17
|
+
> **fetchSsmParams**(`param`): `Promise`\<`undefined` \| `Parameter`\>
|
|
18
|
+
|
|
19
|
+
Defined in: [fetch-ssm-params/fetch-ssm-params.ts:14](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/fetch-ssm-params/fetch-ssm-params.ts#L14)
|
|
20
|
+
|
|
21
|
+
Fetch one SSM parameter
|
|
22
|
+
|
|
23
|
+
### Parameters
|
|
24
|
+
|
|
25
|
+
#### param
|
|
26
|
+
|
|
27
|
+
`string`
|
|
28
|
+
|
|
29
|
+
key of the parameter to fetch
|
|
30
|
+
|
|
31
|
+
### Returns
|
|
32
|
+
|
|
33
|
+
`Promise`\<`undefined` \| `Parameter`\>
|
|
34
|
+
|
|
35
|
+
### Param
|
|
36
|
+
|
|
37
|
+
the keys of the parameters to fetch
|
|
38
|
+
|
|
39
|
+
## Call Signature
|
|
40
|
+
|
|
41
|
+
> **fetchSsmParams**(...`params`): `Promise`\<(`undefined` \| `Parameter`)[]\>
|
|
42
|
+
|
|
43
|
+
Defined in: [fetch-ssm-params/fetch-ssm-params.ts:20](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/fetch-ssm-params/fetch-ssm-params.ts#L20)
|
|
44
|
+
|
|
45
|
+
Fetch a list of SSM parameters
|
|
46
|
+
|
|
47
|
+
### Parameters
|
|
48
|
+
|
|
49
|
+
#### params
|
|
50
|
+
|
|
51
|
+
...`string`[]
|
|
52
|
+
|
|
53
|
+
list of parameter keys to fetch
|
|
54
|
+
|
|
55
|
+
### Returns
|
|
56
|
+
|
|
57
|
+
`Promise`\<(`undefined` \| `Parameter`)[]\>
|
|
58
|
+
|
|
59
|
+
### Param
|
|
60
|
+
|
|
61
|
+
the keys of the parameters to fetch
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / getAwsIdFromArn
|
|
6
|
+
|
|
7
|
+
# Function: getAwsIdFromArn()
|
|
8
|
+
|
|
9
|
+
> **getAwsIdFromArn**(`resourceArn`): `string`
|
|
10
|
+
|
|
11
|
+
Defined in: [get-aws-id-from-arn/get-aws-id-from-arn.ts:11](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/get-aws-id-from-arn/get-aws-id-from-arn.ts#L11)
|
|
12
|
+
|
|
13
|
+
Get the AWS ID from its resource ARN
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
### resourceArn
|
|
18
|
+
|
|
19
|
+
`string`
|
|
20
|
+
|
|
21
|
+
the ARN of the AWS resource
|
|
22
|
+
|
|
23
|
+
## Returns
|
|
24
|
+
|
|
25
|
+
`string`
|
|
26
|
+
|
|
27
|
+
the ID (if present in the ARN) of the AWS resource/execution
|
|
28
|
+
|
|
29
|
+
## Throws
|
|
30
|
+
|
|
31
|
+
when the provided ARN is empty
|
|
32
|
+
|
|
33
|
+
## Example
|
|
34
|
+
|
|
35
|
+
```ts
|
|
36
|
+
getAwsIdFromArn('arn:aws:states:ap-southeast-2:123123123:execution:prj-int-entity-ac-dc-dev-machine-name:this-is-the-id')
|
|
37
|
+
```
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / hasDefinedProperties
|
|
6
|
+
|
|
7
|
+
# Function: hasDefinedProperties()
|
|
8
|
+
|
|
9
|
+
> **hasDefinedProperties**\<`T`, `K`\>(`obj`, ...`keys`): `obj is SimplifyIntersection<Required<Pick<T, K>> & Omit<T, K>>`
|
|
10
|
+
|
|
11
|
+
Defined in: [has-properties-defined/has-properties-defined.ts:23](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/has-properties-defined/has-properties-defined.ts#L23)
|
|
12
|
+
|
|
13
|
+
Ensure that the given properties are defined on the object.
|
|
14
|
+
|
|
15
|
+
## Type Parameters
|
|
16
|
+
|
|
17
|
+
### T
|
|
18
|
+
|
|
19
|
+
`T` *extends* `object`
|
|
20
|
+
|
|
21
|
+
### K
|
|
22
|
+
|
|
23
|
+
`K` *extends* `string` \| `number` \| `symbol`
|
|
24
|
+
|
|
25
|
+
## Parameters
|
|
26
|
+
|
|
27
|
+
### obj
|
|
28
|
+
|
|
29
|
+
The object to check.
|
|
30
|
+
|
|
31
|
+
`object` | `T`
|
|
32
|
+
|
|
33
|
+
### keys
|
|
34
|
+
|
|
35
|
+
...`K`[]
|
|
36
|
+
|
|
37
|
+
The keys to check.
|
|
38
|
+
|
|
39
|
+
## Returns
|
|
40
|
+
|
|
41
|
+
`obj is SimplifyIntersection<Required<Pick<T, K>> & Omit<T, K>>`
|
|
42
|
+
|
|
43
|
+
`true` if the object has the given properties defined, `false` otherwise.
|
|
44
|
+
|
|
45
|
+
## Example
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
type Foo = { a?: number; b?: number };
|
|
49
|
+
const foo: Foo = { a: 1, b: 2 };
|
|
50
|
+
if (hasDefinedProperties(foo, 'a')) {
|
|
51
|
+
console.log(foo);
|
|
52
|
+
// ^? const bar: {
|
|
53
|
+
// a: number;
|
|
54
|
+
// b?: number;
|
|
55
|
+
// }
|
|
56
|
+
}
|
|
57
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / oAuth10aAuthMiddleware
|
|
6
|
+
|
|
7
|
+
# Function: oAuth10aAuthMiddleware()
|
|
8
|
+
|
|
9
|
+
> **oAuth10aAuthMiddleware**(`config`): `Middleware`
|
|
10
|
+
|
|
11
|
+
Defined in: [openapi-fetch-middlewares/authentications.ts:71](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/openapi-fetch-middlewares/authentications.ts#L71)
|
|
12
|
+
|
|
13
|
+
Creates an openapi-fetch middleware for OAuth 1.0a authentication.
|
|
14
|
+
This middleware generates OAuth 1.0a parameters and sets the `Authorization` header
|
|
15
|
+
for each request.
|
|
16
|
+
|
|
17
|
+
## Parameters
|
|
18
|
+
|
|
19
|
+
### config
|
|
20
|
+
|
|
21
|
+
[`OAuth10a`](../interfaces/OAuth10a.md)
|
|
22
|
+
|
|
23
|
+
The configuration for OAuth 1.0a authentication.
|
|
24
|
+
|
|
25
|
+
## Returns
|
|
26
|
+
|
|
27
|
+
`Middleware`
|
|
28
|
+
|
|
29
|
+
The middleware for OAuth 1.0a authentication.
|
|
30
|
+
|
|
31
|
+
## Example
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
const middleware = oAuth10aAuthMiddleware({
|
|
35
|
+
algorithm: 'HMAC-SHA256',
|
|
36
|
+
credentials: async () => ({
|
|
37
|
+
consumerKey: 'key',
|
|
38
|
+
consumerSecret: 'secret',
|
|
39
|
+
token: 'token',
|
|
40
|
+
tokenSecret: 'tokenSecret',
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
```
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
[**@aligent/microservice-util-lib**](../modules.md)
|
|
2
|
+
|
|
3
|
+
***
|
|
4
|
+
|
|
5
|
+
[@aligent/microservice-util-lib](../modules.md) / oAuth20AuthMiddleware
|
|
6
|
+
|
|
7
|
+
# Function: oAuth20AuthMiddleware()
|
|
8
|
+
|
|
9
|
+
> **oAuth20AuthMiddleware**(`options`): `Middleware`
|
|
10
|
+
|
|
11
|
+
Defined in: [openapi-fetch-middlewares/authentications.ts:94](https://github.com/aligent/microservice-development-utilities/blob/e13483771966234032f5249dc36c2c31c71d7cf1/packages/microservice-util-lib/src/openapi-fetch-middlewares/authentications.ts#L94)
|
|
12
|
+
|
|
13
|
+
Creates an openapi-fetch middleware for OAuth 2.0 authentication.
|
|
14
|
+
This middleware sets the `Authorization` header with the OAuth 2.0 token for each request.
|
|
15
|
+
|
|
16
|
+
## Parameters
|
|
17
|
+
|
|
18
|
+
### options
|
|
19
|
+
|
|
20
|
+
[`OAuth20`](../interfaces/OAuth20.md)
|
|
21
|
+
|
|
22
|
+
The configuration for OAuth 2.0 authentication.
|
|
23
|
+
|
|
24
|
+
## Returns
|
|
25
|
+
|
|
26
|
+
`Middleware`
|
|
27
|
+
|
|
28
|
+
The middleware for OAuth 2.0 authentication.
|
|
29
|
+
|
|
30
|
+
## Example
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
const middleware = oAuth20AuthMiddleware({
|
|
34
|
+
token: async () => 'your-access-token',
|
|
35
|
+
tokenType: 'Bearer',
|
|
36
|
+
});
|
|
37
|
+
```
|