@aligent/aws-wrappers 0.0.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.
@@ -0,0 +1,157 @@
1
+ [**@aligent/aws-wrappers**](../modules.md)
2
+
3
+ ***
4
+
5
+ [@aligent/aws-wrappers](../modules.md) / SSMService
6
+
7
+ # Class: SSMService
8
+
9
+ Defined in: [ssm/ssm.ts:17](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/ssm/ssm.ts#L17)
10
+
11
+ Wrapper around the AWS SSM Parameter Store client providing structured
12
+ Powertools logging and X-Ray tracing by default. All operations enable
13
+ `WithDecryption` — callers needing plaintext should use `SSMClient`
14
+ directly.
15
+
16
+ ## Constructors
17
+
18
+ <a id="constructor"></a>
19
+
20
+ ### Constructor
21
+
22
+ > **new SSMService**(`opts?`): `SSMService`
23
+
24
+ Defined in: [ssm/ssm.ts:27](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/ssm/ssm.ts#L27)
25
+
26
+ #### Parameters
27
+
28
+ ##### opts?
29
+
30
+ ###### client?
31
+
32
+ `SSMClient`
33
+
34
+ Optional pre-configured `SSMClient`. When supplied,
35
+ the wrapper does not apply X-Ray instrumentation.
36
+
37
+ ###### logger?
38
+
39
+ `Logger`
40
+
41
+ Optional Powertools logger. Defaults to a logger with
42
+ `serviceName: 'SSMService'`.
43
+
44
+ #### Returns
45
+
46
+ `SSMService`
47
+
48
+ ## Methods
49
+
50
+ <a id="getparameter"></a>
51
+
52
+ ### getParameter()
53
+
54
+ > **getParameter**(`name`): `Promise`\<`string` \| `undefined`\>
55
+
56
+ Defined in: [ssm/ssm.ts:38](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/ssm/ssm.ts#L38)
57
+
58
+ Fetch a single SSM parameter's value.
59
+
60
+ #### Parameters
61
+
62
+ ##### name
63
+
64
+ `string`
65
+
66
+ The parameter name (or ARN).
67
+
68
+ #### Returns
69
+
70
+ `Promise`\<`string` \| `undefined`\>
71
+
72
+ The parameter value, or `undefined` if the parameter has no
73
+ value set.
74
+
75
+ ***
76
+
77
+ <a id="getparameters"></a>
78
+
79
+ ### getParameters()
80
+
81
+ > **getParameters**\<`K`\>(`aliases`): `Promise`\<`Record`\<`K`, `string` \| `undefined`\>\>
82
+
83
+ Defined in: [ssm/ssm.ts:65](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/ssm/ssm.ts#L65)
84
+
85
+ Fetch multiple SSM parameters in a single request. Callers supply an
86
+ alias-to-path record, and the returned record is keyed by the same
87
+ aliases — so the SSM path is only mentioned at the call site and the
88
+ destructured names are whatever the caller wants to use locally:
89
+
90
+ ```ts
91
+ const { username, password } = await ssm.getParameters({
92
+ username: '/myapp/db/username',
93
+ password: '/myapp/db/password',
94
+ });
95
+ ```
96
+
97
+ #### Type Parameters
98
+
99
+ ##### K
100
+
101
+ `K` *extends* `string`
102
+
103
+ #### Parameters
104
+
105
+ ##### aliases
106
+
107
+ `Record`\<`K`, `string`\>
108
+
109
+ Record mapping each desired local alias to its SSM
110
+ parameter name (or ARN).
111
+
112
+ #### Returns
113
+
114
+ `Promise`\<`Record`\<`K`, `string` \| `undefined`\>\>
115
+
116
+ A record keyed by the same aliases, mapping each to the
117
+ parameter's value, or `undefined` when the parameter is missing or has
118
+ no value.
119
+
120
+ ***
121
+
122
+ <a id="getparametersbypath"></a>
123
+
124
+ ### getParametersByPath()
125
+
126
+ > **getParametersByPath**(`path`, `opts?`): `Promise`\<`Parameter`[]\>
127
+
128
+ Defined in: [ssm/ssm.ts:97](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/ssm/ssm.ts#L97)
129
+
130
+ Fetch all parameters under an SSM hierarchy path, auto-paginating across
131
+ all pages. `Recursive` defaults to `true` (overriding the AWS SDK
132
+ default of `false`) to match the typical "load all config under
133
+ `/myapp/`" use case.
134
+
135
+ #### Parameters
136
+
137
+ ##### path
138
+
139
+ `string`
140
+
141
+ The parameter path prefix (e.g. `/myapp/`).
142
+
143
+ ##### opts?
144
+
145
+ ###### recursive?
146
+
147
+ `boolean`
148
+
149
+ Whether to recurse into nested paths. Defaults
150
+ to `true`.
151
+
152
+ #### Returns
153
+
154
+ `Promise`\<`Parameter`[]\>
155
+
156
+ The full `Parameter` objects (including `Version`,
157
+ `LastModifiedDate`, etc.).
@@ -0,0 +1,114 @@
1
+ [**@aligent/aws-wrappers**](../modules.md)
2
+
3
+ ***
4
+
5
+ [@aligent/aws-wrappers](../modules.md) / SecretsManagerService
6
+
7
+ # Class: SecretsManagerService
8
+
9
+ Defined in: [secrets-manager/secrets-manager.ts:9](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L9)
10
+
11
+ Wrapper around the AWS Secrets Manager client providing structured
12
+ Powertools logging and X-Ray tracing by default.
13
+
14
+ ## Constructors
15
+
16
+ <a id="constructor"></a>
17
+
18
+ ### Constructor
19
+
20
+ > **new SecretsManagerService**(`opts?`): `SecretsManagerService`
21
+
22
+ Defined in: [secrets-manager/secrets-manager.ts:20](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L20)
23
+
24
+ #### Parameters
25
+
26
+ ##### opts?
27
+
28
+ ###### client?
29
+
30
+ `SecretsManagerClient`
31
+
32
+ Optional pre-configured `SecretsManagerClient`. When
33
+ supplied, the wrapper does not apply X-Ray instrumentation — the caller
34
+ owns that decision.
35
+
36
+ ###### logger?
37
+
38
+ `Logger`
39
+
40
+ Optional Powertools logger. Defaults to a logger with
41
+ `serviceName: 'SecretsManagerService'`.
42
+
43
+ #### Returns
44
+
45
+ `SecretsManagerService`
46
+
47
+ ## Methods
48
+
49
+ <a id="getjsonsecret"></a>
50
+
51
+ ### getJsonSecret()
52
+
53
+ > **getJsonSecret**\<`T`\>(`secretId`): `Promise`\<`T`\>
54
+
55
+ Defined in: [secrets-manager/secrets-manager.ts:44](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L44)
56
+
57
+ Fetch a secret and parse it as JSON.
58
+
59
+ #### Type Parameters
60
+
61
+ ##### T
62
+
63
+ `T`
64
+
65
+ Expected shape of the parsed secret.
66
+
67
+ #### Parameters
68
+
69
+ ##### secretId
70
+
71
+ `string`
72
+
73
+ The ARN or friendly name of the secret.
74
+
75
+ #### Returns
76
+
77
+ `Promise`\<`T`\>
78
+
79
+ The parsed secret value.
80
+
81
+ #### Throws
82
+
83
+ If the secret has no `SecretString` or the value is not valid JSON.
84
+
85
+ ***
86
+
87
+ <a id="getsecret"></a>
88
+
89
+ ### getSecret()
90
+
91
+ > **getSecret**(`secretId`): `Promise`\<`string`\>
92
+
93
+ Defined in: [secrets-manager/secrets-manager.ts:32](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/secrets-manager/secrets-manager.ts#L32)
94
+
95
+ Fetch a secret's string value from Secrets Manager.
96
+
97
+ #### Parameters
98
+
99
+ ##### secretId
100
+
101
+ `string`
102
+
103
+ The ARN or friendly name of the secret.
104
+
105
+ #### Returns
106
+
107
+ `Promise`\<`string`\>
108
+
109
+ The secret's `SecretString` value.
110
+
111
+ #### Throws
112
+
113
+ If the response does not contain a `SecretString` (e.g. the secret
114
+ stores binary data).
@@ -0,0 +1,134 @@
1
+ [**@aligent/aws-wrappers**](../modules.md)
2
+
3
+ ***
4
+
5
+ [@aligent/aws-wrappers](../modules.md) / StepFunctionsService
6
+
7
+ # Class: StepFunctionsService
8
+
9
+ Defined in: [sfn/sfn.ts:23](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/sfn/sfn.ts#L23)
10
+
11
+ Wrapper around the AWS Step Functions client providing structured
12
+ Powertools logging and X-Ray tracing by default.
13
+
14
+ ## Constructors
15
+
16
+ <a id="constructor"></a>
17
+
18
+ ### Constructor
19
+
20
+ > **new StepFunctionsService**(`opts?`): `StepFunctionsService`
21
+
22
+ Defined in: [sfn/sfn.ts:33](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/sfn/sfn.ts#L33)
23
+
24
+ #### Parameters
25
+
26
+ ##### opts?
27
+
28
+ ###### client?
29
+
30
+ `SFNClient`
31
+
32
+ Optional pre-configured `SFNClient`. When supplied,
33
+ the wrapper does not apply X-Ray instrumentation.
34
+
35
+ ###### logger?
36
+
37
+ `Logger`
38
+
39
+ Optional Powertools logger. Defaults to a logger with
40
+ `serviceName: 'StepFunctionsService'`.
41
+
42
+ #### Returns
43
+
44
+ `StepFunctionsService`
45
+
46
+ ## Methods
47
+
48
+ <a id="describeexecution"></a>
49
+
50
+ ### describeExecution()
51
+
52
+ > **describeExecution**(`input`): `Promise`\<`DescribeExecutionCommandOutput`\>
53
+
54
+ Defined in: [sfn/sfn.ts:64](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/sfn/sfn.ts#L64)
55
+
56
+ Describe an existing Step Functions execution.
57
+
58
+ #### Parameters
59
+
60
+ ##### input
61
+
62
+ `DescribeExecutionCommandInput`
63
+
64
+ #### Returns
65
+
66
+ `Promise`\<`DescribeExecutionCommandOutput`\>
67
+
68
+ ***
69
+
70
+ <a id="listexecutions"></a>
71
+
72
+ ### listExecutions()
73
+
74
+ > **listExecutions**(`input`): `Promise`\<`ExecutionListItem`[]\>
75
+
76
+ Defined in: [sfn/sfn.ts:43](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/sfn/sfn.ts#L43)
77
+
78
+ List all executions for a state machine, auto-paginating across all
79
+ pages. Typically bounded by `statusFilter` and state-machine retention,
80
+ so the flat-array shape is safe in practice.
81
+
82
+ #### Parameters
83
+
84
+ ##### input
85
+
86
+ `ListExecutionsCommandInput`
87
+
88
+ #### Returns
89
+
90
+ `Promise`\<`ExecutionListItem`[]\>
91
+
92
+ ***
93
+
94
+ <a id="startexecution"></a>
95
+
96
+ ### startExecution()
97
+
98
+ > **startExecution**(`input`): `Promise`\<`StartExecutionCommandOutput`\>
99
+
100
+ Defined in: [sfn/sfn.ts:56](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/sfn/sfn.ts#L56)
101
+
102
+ Start a new Step Functions execution.
103
+
104
+ #### Parameters
105
+
106
+ ##### input
107
+
108
+ `StartExecutionCommandInput`
109
+
110
+ #### Returns
111
+
112
+ `Promise`\<`StartExecutionCommandOutput`\>
113
+
114
+ ***
115
+
116
+ <a id="stopexecution"></a>
117
+
118
+ ### stopExecution()
119
+
120
+ > **stopExecution**(`input`): `Promise`\<`StopExecutionCommandOutput`\>
121
+
122
+ Defined in: [sfn/sfn.ts:74](https://github.com/aligent/microservice-development-utilities/blob/30b581ee09ba114f98caadf97f423e40b9b4f410/packages/aws-wrappers/src/sfn/sfn.ts#L74)
123
+
124
+ Stop an in-progress Step Functions execution.
125
+
126
+ #### Parameters
127
+
128
+ ##### input
129
+
130
+ `StopExecutionCommandInput`
131
+
132
+ #### Returns
133
+
134
+ `Promise`\<`StopExecutionCommandOutput`\>
@@ -0,0 +1,15 @@
1
+ **@aligent/aws-wrappers**
2
+
3
+ ***
4
+
5
+ # @aligent/aws-wrappers
6
+
7
+ ## Classes
8
+
9
+ - [DynamoDBService](classes/DynamoDBService.md)
10
+ - [S3Service](classes/S3Service.md)
11
+ - [SecretsManagerService](classes/SecretsManagerService.md)
12
+ - [SNSService](classes/SNSService.md)
13
+ - [SQSService](classes/SQSService.md)
14
+ - [SSMService](classes/SSMService.md)
15
+ - [StepFunctionsService](classes/StepFunctionsService.md)
package/package.json ADDED
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@aligent/aws-wrappers",
3
+ "version": "0.0.1",
4
+ "description": "Opinionated AWS SDK wrappers with Powertools logging and X-Ray tracing",
5
+ "type": "commonjs",
6
+ "main": "./src/index.js",
7
+ "typings": "./src/index.d.ts",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "https://github.com/aligent/microservice-development-utilities.git",
11
+ "directory": "packages/aws-wrappers"
12
+ },
13
+ "dependencies": {
14
+ "@aws-lambda-powertools/logger": "^2.33.0",
15
+ "@aws-sdk/client-dynamodb": "^3.1045.0",
16
+ "@aws-sdk/client-s3": "^3.1045.0",
17
+ "@aws-sdk/client-secrets-manager": "^3.1045.0",
18
+ "@aws-sdk/client-sfn": "^3.1045.0",
19
+ "@aws-sdk/client-sns": "^3.1045.0",
20
+ "@aws-sdk/client-sqs": "^3.1045.0",
21
+ "@aws-sdk/client-ssm": "^3.1045.0",
22
+ "@aws-sdk/lib-dynamodb": "^3.1045.0",
23
+ "@aws-sdk/s3-request-presigner": "^3.1045.0",
24
+ "aws-xray-sdk-core": "^3.12.0"
25
+ },
26
+ "author": "Aligent",
27
+ "license": "MIT",
28
+ "devDependencies": {
29
+ "aws-sdk-client-mock": "^4.1.0"
30
+ },
31
+ "types": "./src/index.d.ts"
32
+ }
@@ -0,0 +1,127 @@
1
+ import { Logger } from '@aws-lambda-powertools/logger';
2
+ import { BatchGetCommandInput, BatchGetCommandOutput, BatchWriteCommandInput, BatchWriteCommandOutput, DeleteCommandInput, DeleteCommandOutput, DynamoDBDocumentClient, GetCommandInput, PutCommandInput, PutCommandOutput, QueryCommandInput, QueryCommandOutput, ScanCommandInput, ScanCommandOutput, UpdateCommandInput, UpdateCommandOutput } from '@aws-sdk/lib-dynamodb';
3
+ /**
4
+ * DynamoDB command input with a typed `Key`. Used to thread a caller-defined
5
+ * key shape through the SDK input shape while preserving every other field.
6
+ */
7
+ type WithTypedKey<TInput, K extends Record<string, unknown>> = Omit<TInput, 'Key'> & {
8
+ Key: K;
9
+ };
10
+ /**
11
+ * Wrapper around the AWS DynamoDB Document client providing structured
12
+ * Powertools logging and X-Ray tracing by default.
13
+ *
14
+ * Items are automatically marshalled / unmarshalled via the document client —
15
+ * callers work with plain TypeScript objects in both directions.
16
+ */
17
+ export declare class DynamoDBService {
18
+ private readonly client;
19
+ private readonly logger;
20
+ /**
21
+ * @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
22
+ * which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
23
+ * @param opts.client - Optional pre-configured `DynamoDBDocumentClient`.
24
+ * When supplied, the wrapper does not apply X-Ray instrumentation. When
25
+ * omitted, a default `DynamoDBClient` is wrapped with `captureAWSv3Client`
26
+ * *before* being passed to `DynamoDBDocumentClient.from`, so X-Ray
27
+ * tracing captures every DynamoDB call.
28
+ */
29
+ constructor(opts?: {
30
+ logger?: Logger;
31
+ client?: DynamoDBDocumentClient;
32
+ });
33
+ /**
34
+ * Get an item from DynamoDB.
35
+ * @template K - Shape of the partition / sort key.
36
+ * @template R - Expected unmarshalled item shape.
37
+ * @returns The item, or `undefined` if not found.
38
+ */
39
+ getItem<K extends Record<string, unknown> = Record<string, unknown>, R extends Record<string, unknown> = Record<string, unknown>>(input: WithTypedKey<GetCommandInput, K>): Promise<R | undefined>;
40
+ /**
41
+ * Put an item into DynamoDB. The caller's `Item` is typed as `T`, which
42
+ * the document client marshalls automatically.
43
+ * @template T - Type of the item being stored.
44
+ */
45
+ putItem<T>(input: Omit<PutCommandInput, 'Item'> & {
46
+ Item: T;
47
+ }): Promise<PutCommandOutput>;
48
+ /**
49
+ * Update an item in DynamoDB. The `Attributes` field on the response is
50
+ * typed as `R` — the caller should choose `R` to match their
51
+ * `ReturnValues` setting:
52
+ * - `NONE` (default): no `Attributes` returned.
53
+ * - `ALL_OLD` / `ALL_NEW`: full item.
54
+ * - `UPDATED_OLD` / `UPDATED_NEW`: only updated attributes (partial).
55
+ * @template K - Shape of the partition / sort key.
56
+ * @template R - Expected shape of the returned `Attributes`.
57
+ */
58
+ updateItem<K extends Record<string, unknown> = Record<string, unknown>, R extends Record<string, unknown> = Record<string, unknown>>(input: WithTypedKey<UpdateCommandInput, K>): Promise<Omit<UpdateCommandOutput, 'Attributes'> & {
59
+ Attributes?: R;
60
+ }>;
61
+ /**
62
+ * Delete an item from DynamoDB. The `Attributes` field on the response is
63
+ * typed as `R` — relevant when `ReturnValues: 'ALL_OLD'` is set.
64
+ * @template K - Shape of the partition / sort key.
65
+ * @template R - Expected shape of the returned `Attributes`.
66
+ */
67
+ deleteItem<K extends Record<string, unknown> = Record<string, unknown>, R extends Record<string, unknown> = Record<string, unknown>>(input: WithTypedKey<DeleteCommandInput, K>): Promise<Omit<DeleteCommandOutput, 'Attributes'> & {
68
+ Attributes?: R;
69
+ }>;
70
+ /**
71
+ * Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
72
+ * `Items` typed as `T[]` so callers retain pagination metadata
73
+ * (`LastEvaluatedKey`, `Count`, etc.).
74
+ * @template T - Expected shape of each unmarshalled item.
75
+ */
76
+ query<T extends Record<string, unknown> = Record<string, unknown>>(input: QueryCommandInput): Promise<Omit<QueryCommandOutput, 'Items'> & {
77
+ Items?: T[];
78
+ }>;
79
+ /**
80
+ * Scan a DynamoDB table. The full `ScanCommandOutput` is returned with
81
+ * `Items` typed as `T[]` so callers retain pagination metadata.
82
+ *
83
+ * Scan reads every item in the table, so cost and latency grow linearly
84
+ * with table size; it is rarely the right tool in a runtime service.
85
+ * Prefer, in order:
86
+ *
87
+ * 1. `query` with the table's partition key.
88
+ * 2. `query` against a GSI or LSI whose key matches your access pattern.
89
+ * 3. A sparse GSI populated only for the items you need to enumerate.
90
+ * 4. A denormalised lookup item or table maintained on write.
91
+ *
92
+ * Legitimate scan use cases are mostly one-off admin work (export,
93
+ * migration, audit). For those, prefer the AWS CLI or Console rather than
94
+ * embedding a scan in a Lambda.
95
+ *
96
+ * @template T - Expected shape of each unmarshalled item.
97
+ */
98
+ scan<T extends Record<string, unknown> = Record<string, unknown>>(input: ScanCommandInput): Promise<Omit<ScanCommandOutput, 'Items'> & {
99
+ Items?: T[];
100
+ }>;
101
+ /**
102
+ * Batch-get items from one or more DynamoDB tables.
103
+ *
104
+ * Note: this method is intentionally **not** generic. `BatchGet`'s
105
+ * `Responses` field is a multi-table `Record<string, item[]>` whose item
106
+ * shapes can differ per table — no single `T` can soundly describe it.
107
+ * Callers should narrow the result type at the call site.
108
+ */
109
+ batchGet(input: BatchGetCommandInput): Promise<BatchGetCommandOutput>;
110
+ /**
111
+ * Batch-write items to DynamoDB, retrying `UnprocessedItems` with jittered
112
+ * exponential backoff. Up to 5 attempts (200ms base delay). Throws when
113
+ * items remain unprocessed after the final attempt.
114
+ */
115
+ batchWrite(input: BatchWriteCommandInput): Promise<BatchWriteCommandOutput>;
116
+ /**
117
+ * Paginate over Query results, yielding one unmarshalled item at a time.
118
+ * @template T - Expected shape of each yielded item.
119
+ */
120
+ paginateItems<T extends Record<string, unknown> = Record<string, unknown>>(input: QueryCommandInput): AsyncGenerator<T>;
121
+ /**
122
+ * Paginate over Scan results, yielding one unmarshalled item at a time.
123
+ * @template T - Expected shape of each yielded item.
124
+ */
125
+ paginateScan<T extends Record<string, unknown> = Record<string, unknown>>(input: ScanCommandInput): AsyncGenerator<T>;
126
+ }
127
+ export {};