@aligent/aws-wrappers 0.1.2 → 0.3.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 +57 -1
- package/cjs/index.cjs +343 -49
- package/cjs/package.json +2 -1
- package/cjs/src/dynamodb/dynamodb.d.ts +4 -0
- package/cjs/src/index.d.ts +1 -0
- package/cjs/src/s3/s3.d.ts +4 -0
- package/cjs/src/scheduler/scheduler.d.ts +85 -0
- package/cjs/src/secrets-manager/secrets-manager.d.ts +7 -6
- package/cjs/src/sfn/sfn.d.ts +4 -0
- package/cjs/src/sns/sns.d.ts +5 -2
- package/cjs/src/sqs/sqs.d.ts +5 -2
- package/cjs/src/ssm/ssm.d.ts +4 -0
- package/cjs/src/util/redact.d.ts +14 -4
- package/docs/classes/DynamoDBService.md +69 -34
- package/docs/classes/S3Service.md +77 -33
- package/docs/classes/SNSService.md +31 -8
- package/docs/classes/SQSService.md +33 -11
- package/docs/classes/SSMService.md +70 -9
- package/docs/classes/SchedulerService.md +271 -0
- package/docs/classes/SecretsManagerService.md +120 -7
- package/docs/classes/StepFunctionsService.md +13 -9
- package/docs/modules.md +1 -0
- package/esm/index.mjs +344 -51
- package/esm/package.json +2 -1
- package/esm/src/dynamodb/dynamodb.d.ts +4 -0
- package/esm/src/index.d.ts +1 -0
- package/esm/src/s3/s3.d.ts +4 -0
- package/esm/src/scheduler/scheduler.d.ts +85 -0
- package/esm/src/secrets-manager/secrets-manager.d.ts +7 -6
- package/esm/src/sfn/sfn.d.ts +4 -0
- package/esm/src/sns/sns.d.ts +5 -2
- package/esm/src/sqs/sqs.d.ts +5 -2
- package/esm/src/ssm/ssm.d.ts +4 -0
- package/esm/src/util/redact.d.ts +14 -4
- package/package.json +2 -1
|
@@ -11,6 +11,10 @@ type WithTypedKey<TInput, K extends Record<string, unknown>> = Omit<TInput, 'Key
|
|
|
11
11
|
* Wrapper around the AWS DynamoDB Document client providing structured
|
|
12
12
|
* Powertools logging and X-Ray tracing by default.
|
|
13
13
|
*
|
|
14
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
15
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
16
|
+
* `TRACE`) log full SDK inputs.
|
|
17
|
+
*
|
|
14
18
|
* Items are automatically marshalled / unmarshalled via the document client —
|
|
15
19
|
* callers work with plain TypeScript objects in both directions.
|
|
16
20
|
*/
|
package/cjs/src/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export { DynamoDBService } from './dynamodb/dynamodb.js';
|
|
2
2
|
export { S3Service } from './s3/s3.js';
|
|
3
|
+
export { SchedulerService } from './scheduler/scheduler.js';
|
|
3
4
|
export { SecretsManagerService } from './secrets-manager/secrets-manager.js';
|
|
4
5
|
export { StepFunctionsService } from './sfn/sfn.js';
|
|
5
6
|
export { SNSService } from './sns/sns.js';
|
package/cjs/src/s3/s3.d.ts
CHANGED
|
@@ -13,6 +13,10 @@ type PutJsonObjectInput<T> = {
|
|
|
13
13
|
* Wrapper around the AWS S3 client providing structured Powertools logging
|
|
14
14
|
* and X-Ray tracing by default.
|
|
15
15
|
*
|
|
16
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
17
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
18
|
+
* `TRACE`) log full SDK inputs.
|
|
19
|
+
*
|
|
16
20
|
* Input shapes are intentionally tight (Bucket/Key/Body only). Callers
|
|
17
21
|
* needing SDK-level options not exposed here (server-side encryption,
|
|
18
22
|
* tagging, version IDs) should use `S3Client` directly.
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import type { LoggerInterface } from '@aws-lambda-powertools/logger/types';
|
|
2
|
+
import { CreateScheduleCommandInput, CreateScheduleCommandOutput, CreateScheduleGroupCommandInput, CreateScheduleGroupCommandOutput, DeleteScheduleCommandInput, DeleteScheduleCommandOutput, DeleteScheduleGroupCommandInput, DeleteScheduleGroupCommandOutput, GetScheduleCommandInput, GetScheduleCommandOutput, GetScheduleGroupCommandInput, GetScheduleGroupCommandOutput, ListScheduleGroupsCommandInput, ListSchedulesCommandInput, ScheduleGroupSummary, SchedulerClient, ScheduleSummary, UpdateScheduleCommandInput, UpdateScheduleCommandOutput } from '@aws-sdk/client-scheduler';
|
|
3
|
+
/**
|
|
4
|
+
* Wrapper around the AWS EventBridge Scheduler client providing structured
|
|
5
|
+
* Powertools logging and X-Ray tracing by default.
|
|
6
|
+
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
10
|
+
*
|
|
11
|
+
* Covers CRUD on schedules and their groups. Named `SchedulerService` (not
|
|
12
|
+
* `EventBridgeSchedulerService`) so it doesn't collide with a future wrapper
|
|
13
|
+
* over the separate EventBridge bus/rules API (`@aws-sdk/client-eventbridge`).
|
|
14
|
+
*
|
|
15
|
+
* `FlexibleTimeWindow` is required by `CreateSchedule` and is passed through
|
|
16
|
+
* untouched — the wrapper bakes in no default, so the caller must state their
|
|
17
|
+
* intent (`{ Mode: 'OFF' }` for a fixed-time schedule).
|
|
18
|
+
*/
|
|
19
|
+
export declare class SchedulerService {
|
|
20
|
+
private readonly client;
|
|
21
|
+
private readonly logger;
|
|
22
|
+
/**
|
|
23
|
+
* @param opts.logger - Optional Powertools logger. Defaults to `new Logger()`,
|
|
24
|
+
* which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
25
|
+
* @param opts.client - Optional pre-configured `SchedulerClient`. When
|
|
26
|
+
* supplied, the wrapper does not apply X-Ray instrumentation.
|
|
27
|
+
*/
|
|
28
|
+
constructor(opts?: {
|
|
29
|
+
logger?: LoggerInterface;
|
|
30
|
+
client?: SchedulerClient;
|
|
31
|
+
});
|
|
32
|
+
/**
|
|
33
|
+
* Create a new schedule. At INFO the log line omits `Target.Input` (the
|
|
34
|
+
* target payload, a PII carrier).
|
|
35
|
+
*/
|
|
36
|
+
createSchedule(input: CreateScheduleCommandInput): Promise<CreateScheduleCommandOutput>;
|
|
37
|
+
/**
|
|
38
|
+
* Fetch a schedule's full configuration.
|
|
39
|
+
*/
|
|
40
|
+
getSchedule(input: GetScheduleCommandInput): Promise<GetScheduleCommandOutput>;
|
|
41
|
+
/**
|
|
42
|
+
* Update an existing schedule.
|
|
43
|
+
*
|
|
44
|
+
* **`UpdateSchedule` has PUT (full-replacement) semantics.** Any field you
|
|
45
|
+
* omit is reset to its default — this is not a partial patch. To change one
|
|
46
|
+
* attribute, `getSchedule` first and resend the complete configuration with
|
|
47
|
+
* that attribute modified, or you will silently erase `ScheduleExpression`,
|
|
48
|
+
* `Target`, `Description`, `StartDate`, etc. The wrapper does not merge on
|
|
49
|
+
* your behalf: deep-merging a `Target` (with its mutually-exclusive
|
|
50
|
+
* target-type params) has no single correct semantics.
|
|
51
|
+
*
|
|
52
|
+
* At INFO the log line omits `Target.Input`.
|
|
53
|
+
*/
|
|
54
|
+
updateSchedule(input: UpdateScheduleCommandInput): Promise<UpdateScheduleCommandOutput>;
|
|
55
|
+
/**
|
|
56
|
+
* Delete a schedule.
|
|
57
|
+
*/
|
|
58
|
+
deleteSchedule(input: DeleteScheduleCommandInput): Promise<DeleteScheduleCommandOutput>;
|
|
59
|
+
/**
|
|
60
|
+
* List schedules, auto-paginating across all pages. Bounded in practice by
|
|
61
|
+
* the account's schedule count and the `GroupName` / `NamePrefix` / `State`
|
|
62
|
+
* filters, so the flat-array shape is safe.
|
|
63
|
+
*/
|
|
64
|
+
listSchedules(input?: ListSchedulesCommandInput): Promise<ScheduleSummary[]>;
|
|
65
|
+
/**
|
|
66
|
+
* Create a new schedule group. Groups are containers for schedules and are
|
|
67
|
+
* typically IaC-managed; use this for dynamically-provisioned groups only.
|
|
68
|
+
*/
|
|
69
|
+
createScheduleGroup(input: CreateScheduleGroupCommandInput): Promise<CreateScheduleGroupCommandOutput>;
|
|
70
|
+
/**
|
|
71
|
+
* Fetch a schedule group's configuration.
|
|
72
|
+
*/
|
|
73
|
+
getScheduleGroup(input: GetScheduleGroupCommandInput): Promise<GetScheduleGroupCommandOutput>;
|
|
74
|
+
/**
|
|
75
|
+
* Delete a schedule group. Deleting a group also deletes every schedule it
|
|
76
|
+
* contains, asynchronously — the API has no `UpdateScheduleGroup`, so this
|
|
77
|
+
* is the only mutating group operation besides create.
|
|
78
|
+
*/
|
|
79
|
+
deleteScheduleGroup(input: DeleteScheduleGroupCommandInput): Promise<DeleteScheduleGroupCommandOutput>;
|
|
80
|
+
/**
|
|
81
|
+
* List schedule groups, auto-paginating across all pages. Bounded in
|
|
82
|
+
* practice by the account's group count and the `NamePrefix` filter.
|
|
83
|
+
*/
|
|
84
|
+
listScheduleGroups(input?: ListScheduleGroupsCommandInput): Promise<ScheduleGroupSummary[]>;
|
|
85
|
+
}
|
|
@@ -4,6 +4,10 @@ import { CreateSecretCommandInput, CreateSecretCommandOutput, DeleteSecretComman
|
|
|
4
4
|
* Wrapper around the AWS Secrets Manager client providing structured
|
|
5
5
|
* Powertools logging and X-Ray tracing by default.
|
|
6
6
|
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
10
|
+
*
|
|
7
11
|
* Write operations (`createSecret`, `updateSecret`, `putSecretValue`,
|
|
8
12
|
* `deleteSecret`) are exposed for convenience but should be used with care:
|
|
9
13
|
* secret lifecycle is usually managed by IaC (CDK / Terraform). Prefer IaC
|
|
@@ -43,8 +47,7 @@ export declare class SecretsManagerService {
|
|
|
43
47
|
getJsonSecret<T>(secretId: string): Promise<T>;
|
|
44
48
|
/**
|
|
45
49
|
* Create a new secret. At INFO level the log line includes only identity
|
|
46
|
-
* and non-secret metadata
|
|
47
|
-
* input (including `SecretString` / `SecretBinary`).
|
|
50
|
+
* and non-secret metadata.
|
|
48
51
|
*
|
|
49
52
|
* Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
|
|
50
53
|
* dynamically-issued credentials only.
|
|
@@ -52,8 +55,7 @@ export declare class SecretsManagerService {
|
|
|
52
55
|
createSecret(input: CreateSecretCommandInput): Promise<CreateSecretCommandOutput>;
|
|
53
56
|
/**
|
|
54
57
|
* Update an existing secret's metadata or value. At INFO level the log
|
|
55
|
-
* line omits `SecretString` / `SecretBinary
|
|
56
|
-
* unlocks the full input.
|
|
58
|
+
* line omits `SecretString` / `SecretBinary`.
|
|
57
59
|
*
|
|
58
60
|
* Prefer IaC (CDK / Terraform) for secret lifecycle — use this for
|
|
59
61
|
* runtime metadata updates only.
|
|
@@ -61,8 +63,7 @@ export declare class SecretsManagerService {
|
|
|
61
63
|
updateSecret(input: UpdateSecretCommandInput): Promise<UpdateSecretCommandOutput>;
|
|
62
64
|
/**
|
|
63
65
|
* Store a new version of a secret's value. At INFO level the log line
|
|
64
|
-
* omits `SecretString` / `SecretBinary
|
|
65
|
-
* unlocks the full input.
|
|
66
|
+
* omits `SecretString` / `SecretBinary`.
|
|
66
67
|
*
|
|
67
68
|
* Typically used by rotation flows.
|
|
68
69
|
*/
|
package/cjs/src/sfn/sfn.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { DescribeExecutionCommandInput, DescribeExecutionCommandOutput, Executio
|
|
|
3
3
|
/**
|
|
4
4
|
* Wrapper around the AWS Step Functions client providing structured
|
|
5
5
|
* Powertools logging and X-Ray tracing by default.
|
|
6
|
+
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
6
10
|
*/
|
|
7
11
|
export declare class StepFunctionsService {
|
|
8
12
|
private readonly client;
|
package/cjs/src/sns/sns.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { PublishBatchCommandInput, PublishBatchCommandOutput, PublishCommandInpu
|
|
|
3
3
|
/**
|
|
4
4
|
* Wrapper around the AWS SNS client providing structured Powertools logging
|
|
5
5
|
* and X-Ray tracing by default.
|
|
6
|
+
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
6
10
|
*/
|
|
7
11
|
export declare class SNSService {
|
|
8
12
|
private readonly client;
|
|
@@ -28,8 +32,7 @@ export declare class SNSService {
|
|
|
28
32
|
* Publish a single message to an SNS topic.
|
|
29
33
|
*
|
|
30
34
|
* At INFO level the log line includes only routing / dedup metadata; see
|
|
31
|
-
* `PUBLISH_SAFE_FIELDS` for the list.
|
|
32
|
-
* unlocks the full input.
|
|
35
|
+
* `PUBLISH_SAFE_FIELDS` for the list.
|
|
33
36
|
*
|
|
34
37
|
* @param input - PublishCommandInput including TopicArn and Message.
|
|
35
38
|
*/
|
package/cjs/src/sqs/sqs.d.ts
CHANGED
|
@@ -3,6 +3,10 @@ import { DeleteMessageBatchCommandInput, DeleteMessageBatchCommandOutput, Delete
|
|
|
3
3
|
/**
|
|
4
4
|
* Wrapper around the AWS SQS client providing structured Powertools logging
|
|
5
5
|
* and X-Ray tracing by default.
|
|
6
|
+
*
|
|
7
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
8
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
9
|
+
* `TRACE`) log full SDK inputs.
|
|
6
10
|
*/
|
|
7
11
|
export declare class SQSService {
|
|
8
12
|
private readonly client;
|
|
@@ -27,8 +31,7 @@ export declare class SQSService {
|
|
|
27
31
|
* Send a single message to an SQS queue.
|
|
28
32
|
*
|
|
29
33
|
* At INFO level the log line includes only queue routing / FIFO metadata;
|
|
30
|
-
* see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
31
|
-
* full input.
|
|
34
|
+
* see `SEND_MESSAGE_SAFE_FIELDS`.
|
|
32
35
|
*/
|
|
33
36
|
sendMessage(input: SendMessageCommandInput, opts?: {
|
|
34
37
|
truncate?: boolean;
|
package/cjs/src/ssm/ssm.d.ts
CHANGED
|
@@ -6,6 +6,10 @@ import { Parameter, PutParameterCommandInput, PutParameterCommandOutput, SSMClie
|
|
|
6
6
|
* `WithDecryption` — callers needing plaintext should use `SSMClient`
|
|
7
7
|
* directly.
|
|
8
8
|
*
|
|
9
|
+
* Where a method's input carries payloads, secret material or PII, the INFO
|
|
10
|
+
* log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
11
|
+
* `TRACE`) log full SDK inputs.
|
|
12
|
+
*
|
|
9
13
|
* Write operations (`putParameter`, `deleteParameter`) are exposed for
|
|
10
14
|
* convenience but should be used with care: parameter lifecycle is usually
|
|
11
15
|
* managed by IaC (CDK / Terraform). Prefer IaC for anything that exists at
|
package/cjs/src/util/redact.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import type { LoggerInterface } from '@aws-lambda-powertools/logger/types';
|
|
2
|
+
/**
|
|
3
|
+
* Whether the logger is verbose enough that full SDK inputs — payloads, secret
|
|
4
|
+
* material and PII — may be written to the log.
|
|
5
|
+
*
|
|
6
|
+
* **This is the only place in the package that reads the log level.** Never
|
|
7
|
+
* compare `logger.getLevelName()` yourself: Powertools orders `TRACE` as *more*
|
|
8
|
+
* verbose than `DEBUG` (thresholds 6 and 8), so the obvious
|
|
9
|
+
* `getLevelName() === 'DEBUG'` check silently redacts at the most verbose level
|
|
10
|
+
* available. Route every disclosure decision through this predicate instead.
|
|
11
|
+
*/
|
|
12
|
+
export declare function shouldLogFullInput(logger: LoggerInterface): boolean;
|
|
2
13
|
/**
|
|
3
14
|
* Return a log-safe projection of `input` based on the logger's configured level.
|
|
4
15
|
*
|
|
5
|
-
* At
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* and PII.
|
|
16
|
+
* At the verbose levels — see {@link shouldLogFullInput} — the full input is
|
|
17
|
+
* returned unchanged: operators who asked for that verbosity have explicitly
|
|
18
|
+
* opted into seeing everything, including payloads, secret material and PII.
|
|
9
19
|
*
|
|
10
20
|
* At any other level, only the fields listed in `safeFields` are included.
|
|
11
21
|
* Missing fields are silently skipped — the result type narrows to
|
|
@@ -6,11 +6,15 @@
|
|
|
6
6
|
|
|
7
7
|
# Class: DynamoDBService
|
|
8
8
|
|
|
9
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
9
|
+
Defined in: [dynamodb/dynamodb.ts:153](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L153)
|
|
10
10
|
|
|
11
11
|
Wrapper around the AWS DynamoDB Document client providing structured
|
|
12
12
|
Powertools logging and X-Ray tracing by default.
|
|
13
13
|
|
|
14
|
+
Where a method's input carries payloads, secret material or PII, the INFO
|
|
15
|
+
log line omits them; the verbose levels (`POWERTOOLS_LOG_LEVEL=DEBUG` or
|
|
16
|
+
`TRACE`) log full SDK inputs.
|
|
17
|
+
|
|
14
18
|
Items are automatically marshalled / unmarshalled via the document client —
|
|
15
19
|
callers work with plain TypeScript objects in both directions.
|
|
16
20
|
|
|
@@ -22,7 +26,7 @@ callers work with plain TypeScript objects in both directions.
|
|
|
22
26
|
|
|
23
27
|
> **new DynamoDBService**(`opts?`): `DynamoDBService`
|
|
24
28
|
|
|
25
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
29
|
+
Defined in: [dynamodb/dynamodb.ts:166](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L166)
|
|
26
30
|
|
|
27
31
|
#### Parameters
|
|
28
32
|
|
|
@@ -40,10 +44,10 @@ tracing captures every DynamoDB call.
|
|
|
40
44
|
|
|
41
45
|
###### logger?
|
|
42
46
|
|
|
43
|
-
`
|
|
47
|
+
`LoggerInterface`
|
|
44
48
|
|
|
45
|
-
Optional Powertools logger. Defaults to
|
|
46
|
-
`
|
|
49
|
+
Optional Powertools logger. Defaults to `new Logger()`,
|
|
50
|
+
which picks up `POWERTOOLS_SERVICE_NAME` from the environment.
|
|
47
51
|
|
|
48
52
|
#### Returns
|
|
49
53
|
|
|
@@ -57,7 +61,7 @@ Optional Powertools logger. Defaults to a logger with
|
|
|
57
61
|
|
|
58
62
|
> **batchGet**(`input`): `Promise`\<`BatchGetCommandOutput`\>
|
|
59
63
|
|
|
60
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
64
|
+
Defined in: [dynamodb/dynamodb.ts:317](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L317)
|
|
61
65
|
|
|
62
66
|
Batch-get items from one or more DynamoDB tables.
|
|
63
67
|
|
|
@@ -84,7 +88,7 @@ Callers should narrow the result type at the call site.
|
|
|
84
88
|
|
|
85
89
|
> **batchWrite**(`input`): `Promise`\<`BatchWriteCommandOutput`\>
|
|
86
90
|
|
|
87
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
91
|
+
Defined in: [dynamodb/dynamodb.ts:334](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L334)
|
|
88
92
|
|
|
89
93
|
Batch-write items to DynamoDB, retrying `UnprocessedItems` with jittered
|
|
90
94
|
exponential backoff. Up to 5 attempts (200ms base delay). Throws when
|
|
@@ -106,18 +110,24 @@ items remain unprocessed after the final attempt.
|
|
|
106
110
|
|
|
107
111
|
### deleteItem()
|
|
108
112
|
|
|
109
|
-
> **deleteItem**\<`
|
|
113
|
+
> **deleteItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`DeleteCommandOutput`, `"Attributes"`\> & `object`\>
|
|
110
114
|
|
|
111
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
115
|
+
Defined in: [dynamodb/dynamodb.ts:247](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L247)
|
|
112
116
|
|
|
113
117
|
Delete an item from DynamoDB. The `Attributes` field on the response is
|
|
114
|
-
typed as `
|
|
118
|
+
typed as `R` — relevant when `ReturnValues: 'ALL_OLD'` is set.
|
|
115
119
|
|
|
116
120
|
#### Type Parameters
|
|
117
121
|
|
|
118
|
-
#####
|
|
122
|
+
##### K
|
|
123
|
+
|
|
124
|
+
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
125
|
+
|
|
126
|
+
Shape of the partition / sort key.
|
|
119
127
|
|
|
120
|
-
|
|
128
|
+
##### R
|
|
129
|
+
|
|
130
|
+
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
121
131
|
|
|
122
132
|
Expected shape of the returned `Attributes`.
|
|
123
133
|
|
|
@@ -125,7 +135,7 @@ Expected shape of the returned `Attributes`.
|
|
|
125
135
|
|
|
126
136
|
##### input
|
|
127
137
|
|
|
128
|
-
`DeleteCommandInput`
|
|
138
|
+
`WithTypedKey`\<`DeleteCommandInput`, `K`\>
|
|
129
139
|
|
|
130
140
|
#### Returns
|
|
131
141
|
|
|
@@ -137,17 +147,23 @@ Expected shape of the returned `Attributes`.
|
|
|
137
147
|
|
|
138
148
|
### getItem()
|
|
139
149
|
|
|
140
|
-
> **getItem**\<`
|
|
150
|
+
> **getItem**\<`K`, `R`\>(`input`): `Promise`\<`R` \| `undefined`\>
|
|
141
151
|
|
|
142
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
152
|
+
Defined in: [dynamodb/dynamodb.ts:181](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L181)
|
|
143
153
|
|
|
144
154
|
Get an item from DynamoDB.
|
|
145
155
|
|
|
146
156
|
#### Type Parameters
|
|
147
157
|
|
|
148
|
-
#####
|
|
158
|
+
##### K
|
|
159
|
+
|
|
160
|
+
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
161
|
+
|
|
162
|
+
Shape of the partition / sort key.
|
|
149
163
|
|
|
150
|
-
|
|
164
|
+
##### R
|
|
165
|
+
|
|
166
|
+
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
151
167
|
|
|
152
168
|
Expected unmarshalled item shape.
|
|
153
169
|
|
|
@@ -155,11 +171,11 @@ Expected unmarshalled item shape.
|
|
|
155
171
|
|
|
156
172
|
##### input
|
|
157
173
|
|
|
158
|
-
`GetCommandInput`
|
|
174
|
+
`WithTypedKey`\<`GetCommandInput`, `K`\>
|
|
159
175
|
|
|
160
176
|
#### Returns
|
|
161
177
|
|
|
162
|
-
`Promise`\<`
|
|
178
|
+
`Promise`\<`R` \| `undefined`\>
|
|
163
179
|
|
|
164
180
|
The item, or `undefined` if not found.
|
|
165
181
|
|
|
@@ -171,7 +187,7 @@ The item, or `undefined` if not found.
|
|
|
171
187
|
|
|
172
188
|
> **paginateItems**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
173
189
|
|
|
174
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
190
|
+
Defined in: [dynamodb/dynamodb.ts:362](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L362)
|
|
175
191
|
|
|
176
192
|
Paginate over Query results, yielding one unmarshalled item at a time.
|
|
177
193
|
|
|
@@ -179,7 +195,7 @@ Paginate over Query results, yielding one unmarshalled item at a time.
|
|
|
179
195
|
|
|
180
196
|
##### T
|
|
181
197
|
|
|
182
|
-
`T` = `Record`\<`string`, `unknown`\>
|
|
198
|
+
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
183
199
|
|
|
184
200
|
Expected shape of each yielded item.
|
|
185
201
|
|
|
@@ -201,7 +217,7 @@ Expected shape of each yielded item.
|
|
|
201
217
|
|
|
202
218
|
> **paginateScan**\<`T`\>(`input`): `AsyncGenerator`\<`T`\>
|
|
203
219
|
|
|
204
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
220
|
+
Defined in: [dynamodb/dynamodb.ts:379](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L379)
|
|
205
221
|
|
|
206
222
|
Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
207
223
|
|
|
@@ -209,7 +225,7 @@ Paginate over Scan results, yielding one unmarshalled item at a time.
|
|
|
209
225
|
|
|
210
226
|
##### T
|
|
211
227
|
|
|
212
|
-
`T` = `Record`\<`string`, `unknown`\>
|
|
228
|
+
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
213
229
|
|
|
214
230
|
Expected shape of each yielded item.
|
|
215
231
|
|
|
@@ -231,7 +247,7 @@ Expected shape of each yielded item.
|
|
|
231
247
|
|
|
232
248
|
> **putItem**\<`T`\>(`input`): `Promise`\<`PutCommandOutput`\>
|
|
233
249
|
|
|
234
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
250
|
+
Defined in: [dynamodb/dynamodb.ts:201](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L201)
|
|
235
251
|
|
|
236
252
|
Put an item into DynamoDB. The caller's `Item` is typed as `T`, which
|
|
237
253
|
the document client marshalls automatically.
|
|
@@ -262,7 +278,7 @@ Type of the item being stored.
|
|
|
262
278
|
|
|
263
279
|
> **query**\<`T`\>(`input`): `Promise`\<`Omit`\<`QueryCommandOutput`, `"Items"`\> & `object`\>
|
|
264
280
|
|
|
265
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
281
|
+
Defined in: [dynamodb/dynamodb.ts:270](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L270)
|
|
266
282
|
|
|
267
283
|
Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
268
284
|
`Items` typed as `T[]` so callers retain pagination metadata
|
|
@@ -272,7 +288,7 @@ Execute a DynamoDB Query. The full `QueryCommandOutput` is returned with
|
|
|
272
288
|
|
|
273
289
|
##### T
|
|
274
290
|
|
|
275
|
-
`T` = `Record`\<`string`, `unknown`\>
|
|
291
|
+
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
276
292
|
|
|
277
293
|
Expected shape of each unmarshalled item.
|
|
278
294
|
|
|
@@ -294,16 +310,29 @@ Expected shape of each unmarshalled item.
|
|
|
294
310
|
|
|
295
311
|
> **scan**\<`T`\>(`input`): `Promise`\<`Omit`\<`ScanCommandOutput`, `"Items"`\> & `object`\>
|
|
296
312
|
|
|
297
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
313
|
+
Defined in: [dynamodb/dynamodb.ts:299](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L299)
|
|
298
314
|
|
|
299
315
|
Scan a DynamoDB table. The full `ScanCommandOutput` is returned with
|
|
300
316
|
`Items` typed as `T[]` so callers retain pagination metadata.
|
|
301
317
|
|
|
318
|
+
Scan reads every item in the table, so cost and latency grow linearly
|
|
319
|
+
with table size; it is rarely the right tool in a runtime service.
|
|
320
|
+
Prefer, in order:
|
|
321
|
+
|
|
322
|
+
1. `query` with the table's partition key.
|
|
323
|
+
2. `query` against a GSI or LSI whose key matches your access pattern.
|
|
324
|
+
3. A sparse GSI populated only for the items you need to enumerate.
|
|
325
|
+
4. A denormalised lookup item or table maintained on write.
|
|
326
|
+
|
|
327
|
+
Legitimate scan use cases are mostly one-off admin work (export,
|
|
328
|
+
migration, audit). For those, prefer the AWS CLI or Console rather than
|
|
329
|
+
embedding a scan in a Lambda.
|
|
330
|
+
|
|
302
331
|
#### Type Parameters
|
|
303
332
|
|
|
304
333
|
##### T
|
|
305
334
|
|
|
306
|
-
`T` = `Record`\<`string`, `unknown`\>
|
|
335
|
+
`T` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
307
336
|
|
|
308
337
|
Expected shape of each unmarshalled item.
|
|
309
338
|
|
|
@@ -323,12 +352,12 @@ Expected shape of each unmarshalled item.
|
|
|
323
352
|
|
|
324
353
|
### updateItem()
|
|
325
354
|
|
|
326
|
-
> **updateItem**\<`
|
|
355
|
+
> **updateItem**\<`K`, `R`\>(`input`): `Promise`\<`Omit`\<`UpdateCommandOutput`, `"Attributes"`\> & `object`\>
|
|
327
356
|
|
|
328
|
-
Defined in: [dynamodb/dynamodb.ts:
|
|
357
|
+
Defined in: [dynamodb/dynamodb.ts:224](https://github.com/aligent/microservice-development-utilities/blob/a2bb34fea27b6af8b52791a3302aefd2b6af331f/packages/aws-wrappers/src/dynamodb/dynamodb.ts#L224)
|
|
329
358
|
|
|
330
359
|
Update an item in DynamoDB. The `Attributes` field on the response is
|
|
331
|
-
typed as `
|
|
360
|
+
typed as `R` — the caller should choose `R` to match their
|
|
332
361
|
`ReturnValues` setting:
|
|
333
362
|
- `NONE` (default): no `Attributes` returned.
|
|
334
363
|
- `ALL_OLD` / `ALL_NEW`: full item.
|
|
@@ -336,9 +365,15 @@ typed as `T` — the caller should choose `T` to match their
|
|
|
336
365
|
|
|
337
366
|
#### Type Parameters
|
|
338
367
|
|
|
339
|
-
#####
|
|
368
|
+
##### K
|
|
369
|
+
|
|
370
|
+
`K` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
371
|
+
|
|
372
|
+
Shape of the partition / sort key.
|
|
373
|
+
|
|
374
|
+
##### R
|
|
340
375
|
|
|
341
|
-
`
|
|
376
|
+
`R` *extends* `Record`\<`string`, `unknown`\> = `Record`\<`string`, `unknown`\>
|
|
342
377
|
|
|
343
378
|
Expected shape of the returned `Attributes`.
|
|
344
379
|
|
|
@@ -346,7 +381,7 @@ Expected shape of the returned `Attributes`.
|
|
|
346
381
|
|
|
347
382
|
##### input
|
|
348
383
|
|
|
349
|
-
`UpdateCommandInput`
|
|
384
|
+
`WithTypedKey`\<`UpdateCommandInput`, `K`\>
|
|
350
385
|
|
|
351
386
|
#### Returns
|
|
352
387
|
|