@nr1e/aws 1.0.6 → 1.0.7
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/dist/{bedrock-runtime.d.mts → bedrock-runtime.d.ts} +1 -1
- package/dist/bedrock-runtime.d.ts.map +1 -0
- package/dist/{bedrock-runtime.mjs → bedrock-runtime.js} +2 -2
- package/dist/bedrock-runtime.js.map +1 -0
- package/dist/{dynamodb-stream.d.mts → dynamodb-stream.d.ts} +1 -1
- package/dist/dynamodb-stream.d.ts.map +1 -0
- package/dist/{dynamodb-stream.mjs → dynamodb-stream.js} +1 -1
- package/dist/dynamodb-stream.js.map +1 -0
- package/dist/dynamodb.d.ts +307 -0
- package/dist/dynamodb.d.ts.map +1 -0
- package/dist/dynamodb.js +603 -0
- package/dist/dynamodb.js.map +1 -0
- package/dist/empty.test.d.ts +2 -0
- package/dist/empty.test.d.ts.map +1 -0
- package/dist/{empty.test.mjs → empty.test.js} +1 -1
- package/dist/empty.test.js.map +1 -0
- package/dist/{event-bridge.d.mts → event-bridge.d.ts} +1 -1
- package/dist/event-bridge.d.ts.map +1 -0
- package/dist/{event-bridge.mjs → event-bridge.js} +1 -1
- package/dist/event-bridge.js.map +1 -0
- package/dist/{geo-places.d.mts → geo-places.d.ts} +1 -1
- package/dist/geo-places.d.ts.map +1 -0
- package/dist/{geo-places.mjs → geo-places.js} +2 -2
- package/dist/geo-places.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/{lambda.d.mts → lambda.d.ts} +1 -1
- package/dist/lambda.d.ts.map +1 -0
- package/dist/{lambda.mjs → lambda.js} +2 -2
- package/dist/lambda.js.map +1 -0
- package/dist/lambda.test.d.ts +2 -0
- package/dist/lambda.test.d.ts.map +1 -0
- package/dist/{lambda.test.mjs → lambda.test.js} +2 -2
- package/dist/lambda.test.js.map +1 -0
- package/dist/{region.d.mts → region.d.ts} +1 -1
- package/dist/region.d.ts.map +1 -0
- package/dist/{region.mjs → region.js} +1 -1
- package/dist/region.js.map +1 -0
- package/dist/{s3.d.mts → s3.d.ts} +1 -1
- package/dist/s3.d.ts.map +1 -0
- package/dist/{s3.mjs → s3.js} +1 -1
- package/dist/s3.js.map +1 -0
- package/dist/{secrets-manager.d.mts → secrets-manager.d.ts} +1 -1
- package/dist/secrets-manager.d.ts.map +1 -0
- package/dist/{secrets-manager.mjs → secrets-manager.js} +2 -2
- package/dist/secrets-manager.js.map +1 -0
- package/dist/{ses.d.mts → ses.d.ts} +1 -1
- package/dist/ses.d.ts.map +1 -0
- package/dist/{ses.mjs → ses.js} +1 -1
- package/dist/ses.js.map +1 -0
- package/dist/{sqs.d.mts → sqs.d.ts} +1 -1
- package/dist/sqs.d.ts.map +1 -0
- package/dist/{sqs.mjs → sqs.js} +1 -1
- package/dist/sqs.js.map +1 -0
- package/dist/{sts.d.mts → sts.d.ts} +1 -1
- package/dist/sts.d.ts.map +1 -0
- package/dist/{sts.mjs → sts.js} +2 -2
- package/dist/sts.js.map +1 -0
- package/package.json +5 -5
- package/dist/bedrock-runtime.d.mts.map +0 -1
- package/dist/bedrock-runtime.mjs.map +0 -1
- package/dist/dynamodb-stream.d.mts.map +0 -1
- package/dist/dynamodb-stream.mjs.map +0 -1
- package/dist/dynamodb.d.mts +0 -107
- package/dist/dynamodb.d.mts.map +0 -1
- package/dist/dynamodb.mjs +0 -302
- package/dist/dynamodb.mjs.map +0 -1
- package/dist/empty.test.d.mts +0 -2
- package/dist/empty.test.d.mts.map +0 -1
- package/dist/empty.test.mjs.map +0 -1
- package/dist/event-bridge.d.mts.map +0 -1
- package/dist/event-bridge.mjs.map +0 -1
- package/dist/geo-places.d.mts.map +0 -1
- package/dist/geo-places.mjs.map +0 -1
- package/dist/index.d.mts +0 -13
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs +0 -13
- package/dist/index.mjs.map +0 -1
- package/dist/lambda.d.mts.map +0 -1
- package/dist/lambda.mjs.map +0 -1
- package/dist/lambda.test.d.mts +0 -2
- package/dist/lambda.test.d.mts.map +0 -1
- package/dist/lambda.test.mjs.map +0 -1
- package/dist/region.d.mts.map +0 -1
- package/dist/region.mjs.map +0 -1
- package/dist/s3.d.mts.map +0 -1
- package/dist/s3.mjs.map +0 -1
- package/dist/secrets-manager.d.mts.map +0 -1
- package/dist/secrets-manager.mjs.map +0 -1
- package/dist/ses.d.mts.map +0 -1
- package/dist/ses.mjs.map +0 -1
- package/dist/sqs.d.mts.map +0 -1
- package/dist/sqs.mjs.map +0 -1
- package/dist/sts.d.mts.map +0 -1
- package/dist/sts.mjs.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { BedrockRuntimeClient, ConverseCommand, ConverseCommandInput, ConverseCommandOutput, ConverseStreamCommand, ConverseStreamCommandInput, ConverseStreamCommandOutput, InvokeModelCommand, InvokeModelCommandInput, InvokeModelCommandOutput, Message, SystemContentBlock } from '@aws-sdk/client-bedrock-runtime';
|
|
2
2
|
export { BedrockRuntimeClient, ConverseCommand, ConverseCommandInput, ConverseCommandOutput, ConverseStreamCommand, ConverseStreamCommandInput, ConverseStreamCommandOutput, InvokeModelCommand, InvokeModelCommandInput, InvokeModelCommandOutput, Message, SystemContentBlock, };
|
|
3
3
|
export declare function getBedrockRuntimeClient(region?: string): BedrockRuntimeClient;
|
|
4
|
-
//# sourceMappingURL=bedrock-runtime.d.
|
|
4
|
+
//# sourceMappingURL=bedrock-runtime.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bedrock-runtime.d.ts","sourceRoot":"","sources":["../src/bedrock-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,OAAO,EACP,kBAAkB,EACnB,MAAM,iCAAiC,CAAC;AAGzC,OAAO,EACL,oBAAoB,EACpB,eAAe,EACf,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,0BAA0B,EAC1B,2BAA2B,EAC3B,kBAAkB,EAClB,uBAAuB,EACvB,wBAAwB,EACxB,OAAO,EACP,kBAAkB,GACnB,CAAC;AAIF,wBAAgB,uBAAuB,CAAC,MAAM,CAAC,EAAE,MAAM,wBAQtD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BedrockRuntimeClient, ConverseCommand, ConverseStreamCommand, InvokeModelCommand, } from '@aws-sdk/client-bedrock-runtime';
|
|
2
|
-
import { getAwsRegion } from './region.
|
|
2
|
+
import { getAwsRegion } from './region.js';
|
|
3
3
|
export { BedrockRuntimeClient, ConverseCommand, ConverseStreamCommand, InvokeModelCommand, };
|
|
4
4
|
const bedrockRuntimeClients = new Map();
|
|
5
5
|
export function getBedrockRuntimeClient(region) {
|
|
@@ -11,4 +11,4 @@ export function getBedrockRuntimeClient(region) {
|
|
|
11
11
|
}
|
|
12
12
|
return client;
|
|
13
13
|
}
|
|
14
|
-
//# sourceMappingURL=bedrock-runtime.
|
|
14
|
+
//# sourceMappingURL=bedrock-runtime.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bedrock-runtime.js","sourceRoot":"","sources":["../src/bedrock-runtime.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,eAAe,EAGf,qBAAqB,EAGrB,kBAAkB,GAKnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAEzC,OAAO,EACL,oBAAoB,EACpB,eAAe,EAGf,qBAAqB,EAGrB,kBAAkB,GAKnB,CAAC;AAEF,MAAM,qBAAqB,GAAG,IAAI,GAAG,EAAgC,CAAC;AAEtE,MAAM,UAAU,uBAAuB,CAAC,MAAe;IACrD,MAAM,SAAS,GAAG,MAAM,IAAI,YAAY,EAAE,CAAC;IAC3C,IAAI,MAAM,GAAG,qBAAqB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAClD,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,MAAM,GAAG,IAAI,oBAAoB,CAAC,EAAC,MAAM,EAAE,SAAS,EAAC,CAAC,CAAC;QACvD,qBAAqB,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -16,4 +16,4 @@ export interface UnmarshalledStreamRecord {
|
|
|
16
16
|
StreamViewType?: 'KEYS_ONLY' | 'NEW_IMAGE' | 'OLD_IMAGE' | 'NEW_AND_OLD_IMAGES' | undefined;
|
|
17
17
|
}
|
|
18
18
|
export declare function unmarshallStreamRecord(record: StreamRecord): UnmarshalledStreamRecord;
|
|
19
|
-
//# sourceMappingURL=dynamodb-stream.d.
|
|
19
|
+
//# sourceMappingURL=dynamodb-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamodb-stream.d.ts","sourceRoot":"","sources":["../src/dynamodb-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAElD,OAAO,EAAC,cAAc,EAAE,YAAY,EAAC,MAAM,YAAY,CAAC;AAExD,OAAO,EAAC,UAAU,EAAE,YAAY,EAAE,cAAc,EAAC,CAAC;AAClD,OAAO,EAAC,mBAAmB,EAAC,MAAM,YAAY,CAAC;AAE/C,MAAM,MAAM,iBAAiB,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,cAAc,CAAA;CAAC,CAAC;AAEhE,wBAAgB,2BAA2B,CAAC,CAAC,EAC3C,GAAG,CAAC,EAAE,iBAAiB,GACtB,CAAC,GAAG,SAAS,CAMf;AAED,MAAM,WAAW,wBAAwB;IACvC,2BAA2B,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAEjD,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE3B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAE/B,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,cAAc,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACpC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,cAAc,CAAC,EACX,WAAW,GACX,WAAW,GACX,WAAW,GACX,oBAAoB,GACpB,SAAS,CAAC;CACf;AAED,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,YAAY,GACnB,wBAAwB,CAO1B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamodb-stream.js","sourceRoot":"","sources":["../src/dynamodb-stream.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,wBAAwB,CAAC;AAIlD,OAAO,EAAC,UAAU,EAA+B,CAAC;AAKlD,MAAM,UAAU,2BAA2B,CACzC,GAAuB;IAEvB,IAAI,CAAC,GAAG,EAAE,CAAC;QACT,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,0GAA0G;IAC1G,OAAO,UAAU,CAAC,GAA8C,CAAM,CAAC;AACzE,CAAC;AAoBD,MAAM,UAAU,sBAAsB,CACpC,MAAoB;IAEpB,OAAO;QACL,GAAG,MAAM;QACT,IAAI,EAAE,2BAA2B,CAAC,MAAM,CAAC,IAAI,CAAC;QAC9C,QAAQ,EAAE,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC;QACtD,QAAQ,EAAE,2BAA2B,CAAC,MAAM,CAAC,QAAQ,CAAC;KACvD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
import { DeleteCommand, DeleteCommandInput, DeleteCommandOutput, DynamoDBDocumentClient, QueryCommand, QueryCommandInput, QueryCommandOutput, ScanCommand, ScanCommandInput, ScanCommandOutput, GetCommand, GetCommandInput, GetCommandOutput, PutCommand, PutCommandInput, PutCommandOutput, UpdateCommand, UpdateCommandInput, UpdateCommandOutput } from '@aws-sdk/lib-dynamodb';
|
|
3
|
+
/**
|
|
4
|
+
* Re-exporting commands to be helpful so clients may not have to import the AWS SDK directly.
|
|
5
|
+
*/
|
|
6
|
+
export { DynamoDBDocumentClient, DynamoDBClient, DeleteCommand, DeleteCommandInput, DeleteCommandOutput, GetCommand, GetCommandInput, GetCommandOutput, QueryCommand, QueryCommandInput, QueryCommandOutput, ScanCommand, ScanCommandInput, ScanCommandOutput, PutCommand, PutCommandInput, PutCommandOutput, UpdateCommand, UpdateCommandInput, UpdateCommandOutput, };
|
|
7
|
+
export declare function getDynamoDBClient(region?: string): DynamoDBClient;
|
|
8
|
+
export declare function getDynamoDBDocumentClient(region?: string): DynamoDBDocumentClient;
|
|
9
|
+
export interface PaginationParams {
|
|
10
|
+
cursor?: string | null | undefined;
|
|
11
|
+
direction?: 'next' | 'prev' | null | undefined;
|
|
12
|
+
limit?: number | null | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface PaginatedResult<T> {
|
|
15
|
+
items: T[];
|
|
16
|
+
cursor: string;
|
|
17
|
+
hasNext: boolean;
|
|
18
|
+
page: number;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Executes a paginated DynamoDB query with full cursor-based pagination support.
|
|
22
|
+
*
|
|
23
|
+
* This helper encapsulates all pagination logic including:
|
|
24
|
+
* - Cursor encoding/decoding
|
|
25
|
+
* - ExclusiveStartKey calculation
|
|
26
|
+
* - Bidirectional pagination (next/prev)
|
|
27
|
+
* - First/last key tracking
|
|
28
|
+
* - Automatic item ordering
|
|
29
|
+
*
|
|
30
|
+
* @param params Configuration for the query and item mapping
|
|
31
|
+
* @param params.client DynamoDB Document Client instance
|
|
32
|
+
* @param params.query QueryCommand input (without ExclusiveStartKey, Limit, ScanIndexForward)
|
|
33
|
+
* @param params.keyAttributes Array of key attribute names for the table/index being queried
|
|
34
|
+
* @param params.mapItem Function to transform raw DynamoDB items into desired format
|
|
35
|
+
* @param pagination Pagination parameters from the client
|
|
36
|
+
* @param pagination.cursor Base64-encoded cursor from previous request
|
|
37
|
+
* @param pagination.direction Direction to paginate ('next' or 'prev')
|
|
38
|
+
* @param pagination.limit Number of items per page (locked after first request)
|
|
39
|
+
* @param defaultScanForward Controls the default scan direction. When true, 'next' scans forward (ascending) and 'prev' scans backward (descending). When false, the behavior is inverted.
|
|
40
|
+
* @returns Paginated result with items, cursor, hasNext flag, and page number
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* return executePaginatedQuery(
|
|
45
|
+
* {
|
|
46
|
+
* client: getDynamoDBDocumentClient(),
|
|
47
|
+
* query: {
|
|
48
|
+
* TableName: 'MyTable',
|
|
49
|
+
* IndexName: 'Gs1',
|
|
50
|
+
* KeyConditionExpression: 'Gs1Pk = :pk',
|
|
51
|
+
* ExpressionAttributeValues: { ':pk': 'Agency#123' },
|
|
52
|
+
* },
|
|
53
|
+
* keyAttributes: ['Pk', 'Sk', 'Gs1Pk', 'Gs1Sk'],
|
|
54
|
+
* mapItem: (item) => item.Detail,
|
|
55
|
+
* },
|
|
56
|
+
* { cursor: '...', direction: 'next', limit: 10 },
|
|
57
|
+
* true // defaultScanForward
|
|
58
|
+
* );
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
export declare function executePaginatedQuery<T = any>(params: {
|
|
62
|
+
client: DynamoDBDocumentClient;
|
|
63
|
+
query: Omit<QueryCommandInput, 'ExclusiveStartKey' | 'Limit' | 'ScanIndexForward'>;
|
|
64
|
+
keyAttributes: string[];
|
|
65
|
+
mapItem: (item: Record<string, any>) => T;
|
|
66
|
+
}, pagination: PaginationParams, defaultScanForward?: boolean): Promise<PaginatedResult<T>>;
|
|
67
|
+
/**
|
|
68
|
+
* Executes a paginated DynamoDB scan with cursor-based pagination support.
|
|
69
|
+
*
|
|
70
|
+
* Similar to executePaginatedQuery but for Scan operations. Note that Scan operations
|
|
71
|
+
* are unordered by nature and do not support scan direction control (unlike Query operations).
|
|
72
|
+
* Scan operations only support forward pagination (no bidirectional navigation).
|
|
73
|
+
*
|
|
74
|
+
* @param params Configuration for the scan and item mapping
|
|
75
|
+
* @param params.client DynamoDB Document Client instance
|
|
76
|
+
* @param params.scan ScanCommand input (without ExclusiveStartKey or Limit)
|
|
77
|
+
* @param params.keyNames Array of key attribute names for the table
|
|
78
|
+
* @param params.mapItem Function to transform raw DynamoDB items into desired format
|
|
79
|
+
* @param pagination Pagination parameters from the client
|
|
80
|
+
* @param pagination.cursor Base64-encoded cursor from previous request
|
|
81
|
+
* @param pagination.limit Number of items per page (locked after first request)
|
|
82
|
+
* @returns Paginated result with items, cursor, hasNext flag, and page number
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```typescript
|
|
86
|
+
* return executePaginatedScan(
|
|
87
|
+
* {
|
|
88
|
+
* client: getDynamoDBDocumentClient(),
|
|
89
|
+
* scan: {
|
|
90
|
+
* TableName: 'MyTable',
|
|
91
|
+
* FilterExpression: 'attribute_exists(#attr)',
|
|
92
|
+
* ExpressionAttributeNames: { '#attr': 'myAttribute' },
|
|
93
|
+
* },
|
|
94
|
+
* keyNames: ['Pk', 'Sk'],
|
|
95
|
+
* mapItem: (item) => item.Detail,
|
|
96
|
+
* },
|
|
97
|
+
* { cursor: '...', limit: 10 }
|
|
98
|
+
* );
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function executePaginatedScan<T = any>(params: {
|
|
102
|
+
client: DynamoDBDocumentClient;
|
|
103
|
+
scan: Omit<QueryCommandInput, 'ExclusiveStartKey' | 'Limit'>;
|
|
104
|
+
keyNames: string[];
|
|
105
|
+
mapItem: (item: Record<string, any>) => T;
|
|
106
|
+
}, pagination: PaginationParams): Promise<PaginatedResult<T>>;
|
|
107
|
+
/**
|
|
108
|
+
* Builds a dynamic DynamoDB update expression from an input object.
|
|
109
|
+
* Only includes fields that are defined (not undefined) and not in the excluded list.
|
|
110
|
+
*
|
|
111
|
+
* @param input - The input object containing fields to update
|
|
112
|
+
* @param options - Configuration options
|
|
113
|
+
* @param options.excludedFields - Fields to exclude from the update expression (e.g., 'id', 'createdAt')
|
|
114
|
+
* @param options.prefix - Prefix for nested objects (e.g., 'Detail', 'Data'). Set to empty string for no prefix. Default: 'Detail'
|
|
115
|
+
* @returns Object containing UpdateExpression, ExpressionAttributeNames, and ExpressionAttributeValues
|
|
116
|
+
*/
|
|
117
|
+
export declare function buildUpdateExpression(input: Record<string, unknown>, options?: {
|
|
118
|
+
excludedFields?: string[];
|
|
119
|
+
prefix?: string;
|
|
120
|
+
}): {
|
|
121
|
+
UpdateExpression: string;
|
|
122
|
+
ExpressionAttributeNames: Record<string, string>;
|
|
123
|
+
ExpressionAttributeValues: Record<string, unknown>;
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Executes a DynamoDB update operation that only succeeds if the item already exists.
|
|
127
|
+
*
|
|
128
|
+
* This function builds a dynamic update expression from the input object and applies
|
|
129
|
+
* an existence check condition. Unlike DynamoDB's default upsert behavior, this function
|
|
130
|
+
* will throw an error if you attempt to update a non-existent item.
|
|
131
|
+
*
|
|
132
|
+
* @template T - The type of the returned item or nested object
|
|
133
|
+
* @param input - Object containing the fields to update. Only defined values are included.
|
|
134
|
+
* @param tableName - The name of the DynamoDB table
|
|
135
|
+
* @param key - The primary key of the item to update (e.g., `{ Pk: 'User#123', Sk: 'Profile' }`)
|
|
136
|
+
* @param options - Configuration options
|
|
137
|
+
* @param options.client - Custom DynamoDB Document Client instance (defaults to singleton client)
|
|
138
|
+
* @param options.excludedFields - Fields to exclude from the update (e.g., `['id', 'createdAt']`)
|
|
139
|
+
* @param options.prefix - Prefix for nested object updates (default: 'Detail'). Set to empty string for no prefix.
|
|
140
|
+
* @returns The updated item or nested object (based on prefix setting)
|
|
141
|
+
*
|
|
142
|
+
* @throws {ConditionalCheckFailedException} When the item doesn't exist in the table
|
|
143
|
+
* @throws {Error} When the key object is empty
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* // Update a user profile (with default 'Detail' prefix)
|
|
148
|
+
* const updated = await executeUpdate<UserProfile>(
|
|
149
|
+
* { name: 'John Doe', email: 'john@example.com', updatedAt: new Date().toISOString() },
|
|
150
|
+
* 'MyTable',
|
|
151
|
+
* { Pk: 'User#123', Sk: 'Profile' }
|
|
152
|
+
* );
|
|
153
|
+
* // Returns: updated.name, updated.email, etc. from the Detail object
|
|
154
|
+
*
|
|
155
|
+
* // Update without prefix (top-level attributes)
|
|
156
|
+
* const updated = await executeUpdate<User>(
|
|
157
|
+
* { status: 'active', lastLogin: Date.now() },
|
|
158
|
+
* 'MyTable',
|
|
159
|
+
* { Pk: 'User#123', Sk: 'Metadata' },
|
|
160
|
+
* { prefix: '' }
|
|
161
|
+
* );
|
|
162
|
+
* // Returns: full item with top-level attributes
|
|
163
|
+
*
|
|
164
|
+
* // Exclude certain fields and add timestamp
|
|
165
|
+
* const updated = await executeUpdate<Product>(
|
|
166
|
+
* { ...productData, updatedAt: new Date().toISOString() },
|
|
167
|
+
* 'Products',
|
|
168
|
+
* { Pk: 'Product#456' },
|
|
169
|
+
* { excludedFields: ['id', 'createdAt'] }
|
|
170
|
+
* );
|
|
171
|
+
* ```
|
|
172
|
+
*/
|
|
173
|
+
export declare function executeUpdate<T>(input: Record<string, unknown>, tableName: string, key: Record<string, unknown>, options?: {
|
|
174
|
+
client?: DynamoDBDocumentClient;
|
|
175
|
+
excludedFields?: string[];
|
|
176
|
+
prefix?: string;
|
|
177
|
+
}): Promise<T>;
|
|
178
|
+
/**
|
|
179
|
+
* Executes a DynamoDB put operation to create or replace an item in the table.
|
|
180
|
+
*
|
|
181
|
+
* This function puts an entire item into DynamoDB. By default, it will NOT overwrite
|
|
182
|
+
* existing items (preventOverwrite is true by default). Set preventOverwrite to false
|
|
183
|
+
* if you want to allow replacing existing items.
|
|
184
|
+
*
|
|
185
|
+
* @template T - The type of the returned item
|
|
186
|
+
* @param item - The complete item to put into the table, including the primary key
|
|
187
|
+
* @param tableName - The name of the DynamoDB table
|
|
188
|
+
* @param key - The primary key of the item (e.g., `{ Pk: 'User#123', Sk: 'Profile' }`). Used for the preventOverwrite condition.
|
|
189
|
+
* @param options - Configuration options
|
|
190
|
+
* @param options.client - Custom DynamoDB Document Client instance (defaults to singleton client)
|
|
191
|
+
* @param options.preventOverwrite - If true, the put will fail if an item with the same key already exists (default: true)
|
|
192
|
+
* @param options.returnValues - Specify what values to return. 'NONE' (default) or 'ALL_OLD' to return the previous item
|
|
193
|
+
* @returns The item that was put (or the old item if returnValues is 'ALL_OLD')
|
|
194
|
+
*
|
|
195
|
+
* @throws {ConditionalCheckFailedException} When preventOverwrite is true and the item already exists
|
|
196
|
+
* @throws {Error} When the key object is empty
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* ```typescript
|
|
200
|
+
* // Create a new user (will fail if already exists - default behavior)
|
|
201
|
+
* const user = await executePut<User>(
|
|
202
|
+
* {
|
|
203
|
+
* Pk: 'User#123',
|
|
204
|
+
* Sk: 'Profile',
|
|
205
|
+
* Detail: {
|
|
206
|
+
* name: 'John Doe',
|
|
207
|
+
* email: 'john@example.com',
|
|
208
|
+
* createdAt: new Date().toISOString()
|
|
209
|
+
* }
|
|
210
|
+
* },
|
|
211
|
+
* 'MyTable',
|
|
212
|
+
* { Pk: 'User#123', Sk: 'Profile' }
|
|
213
|
+
* );
|
|
214
|
+
* // Throws ConditionalCheckFailedException if User#123 already exists
|
|
215
|
+
*
|
|
216
|
+
* // Allow overwriting existing item
|
|
217
|
+
* const user = await executePut<User>(
|
|
218
|
+
* {
|
|
219
|
+
* Pk: 'User#456',
|
|
220
|
+
* Sk: 'Profile',
|
|
221
|
+
* Detail: { name: 'Jane Doe', email: 'jane@example.com' }
|
|
222
|
+
* },
|
|
223
|
+
* 'MyTable',
|
|
224
|
+
* { Pk: 'User#456', Sk: 'Profile' },
|
|
225
|
+
* { preventOverwrite: false }
|
|
226
|
+
* );
|
|
227
|
+
* // Will replace the item if User#456 already exists
|
|
228
|
+
*
|
|
229
|
+
* // Replace item and return the old version
|
|
230
|
+
* const oldUser = await executePut<User>(
|
|
231
|
+
* {
|
|
232
|
+
* Pk: 'User#789',
|
|
233
|
+
* Sk: 'Profile',
|
|
234
|
+
* Detail: { name: 'Updated Name', email: 'updated@example.com' }
|
|
235
|
+
* },
|
|
236
|
+
* 'MyTable',
|
|
237
|
+
* { Pk: 'User#789', Sk: 'Profile' },
|
|
238
|
+
* { preventOverwrite: false, returnValues: 'ALL_OLD' }
|
|
239
|
+
* );
|
|
240
|
+
* // Returns the previous item data
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
export declare function executePut<T>(item: Record<string, unknown>, tableName: string, key: Record<string, unknown>, options?: {
|
|
244
|
+
client?: DynamoDBDocumentClient;
|
|
245
|
+
preventOverwrite?: boolean;
|
|
246
|
+
returnValues?: 'NONE' | 'ALL_OLD';
|
|
247
|
+
}): Promise<T | undefined>;
|
|
248
|
+
/**
|
|
249
|
+
* Executes a DynamoDB delete operation to remove an item from the table.
|
|
250
|
+
*
|
|
251
|
+
* @param tableName - The name of the DynamoDB table
|
|
252
|
+
* @param key - The primary key of the item to delete (e.g., `{ Pk: 'User#123', Sk: 'Profile' }`)
|
|
253
|
+
* @param options - Configuration options
|
|
254
|
+
* @param options.client - Custom DynamoDB Document Client instance (defaults to singleton client)
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* ```typescript
|
|
258
|
+
* await executeDelete('MyTable', { Pk: 'User#123', Sk: 'Profile' });
|
|
259
|
+
* ```
|
|
260
|
+
*/
|
|
261
|
+
export declare function executeDelete(tableName: string, key: Record<string, unknown>, options?: {
|
|
262
|
+
client?: DynamoDBDocumentClient;
|
|
263
|
+
}): Promise<void>;
|
|
264
|
+
/**
|
|
265
|
+
* Executes a DynamoDB get operation to retrieve an item from the table.
|
|
266
|
+
*
|
|
267
|
+
* @template T - The type of the returned item
|
|
268
|
+
* @param tableName - The name of the DynamoDB table
|
|
269
|
+
* @param key - The primary key of the item to retrieve (e.g., `{ Pk: 'User#123', Sk: 'Profile' }`)
|
|
270
|
+
* @param options - Configuration options
|
|
271
|
+
* @param options.client - Custom DynamoDB Document Client instance (defaults to singleton client)
|
|
272
|
+
* @returns The item if found, or null if not found
|
|
273
|
+
*
|
|
274
|
+
* @example
|
|
275
|
+
* ```typescript
|
|
276
|
+
* const user = await executeGet<User>('MyTable', { Pk: 'User#123', Sk: 'Profile' });
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
export declare function executeGet<T>(tableName: string, key: Record<string, unknown>, options?: {
|
|
280
|
+
client?: DynamoDBDocumentClient;
|
|
281
|
+
prefix?: string;
|
|
282
|
+
}): Promise<T | null>;
|
|
283
|
+
/**
|
|
284
|
+
* Executes a DynamoDB query on a secondary index and returns the first matching item.
|
|
285
|
+
*
|
|
286
|
+
* @template T - The type of the returned item
|
|
287
|
+
* @param tableName - The name of the DynamoDB table
|
|
288
|
+
* @param indexName - The name of the secondary index to query
|
|
289
|
+
* @param key - The key attributes to query (e.g., `{ Gs1Pk: 'User#123' }` or `{ Gs1Pk: 'User#123', Gs1Sk: 'Profile' }`)
|
|
290
|
+
* @param options - Configuration options
|
|
291
|
+
* @param options.client - Custom DynamoDB Document Client instance (defaults to singleton client)
|
|
292
|
+
* @returns The first matching item if found, or null if not found
|
|
293
|
+
*
|
|
294
|
+
* @example
|
|
295
|
+
* ```typescript
|
|
296
|
+
* // Query with just partition key
|
|
297
|
+
* const user = await executeGetFromIndex<User>('MyTable', 'Gs1', { Gs1Pk: 'User#123' });
|
|
298
|
+
*
|
|
299
|
+
* // Query with partition and sort key
|
|
300
|
+
* const user = await executeGetFromIndex<User>('MyTable', 'Gs1', { Gs1Pk: 'User#123', Gs1Sk: 'Profile' });
|
|
301
|
+
* ```
|
|
302
|
+
*/
|
|
303
|
+
export declare function executeGetFromIndex<T>(tableName: string, indexName: string, key: Record<string, unknown>, options?: {
|
|
304
|
+
client?: DynamoDBDocumentClient;
|
|
305
|
+
prefix?: string;
|
|
306
|
+
}): Promise<T | null>;
|
|
307
|
+
//# sourceMappingURL=dynamodb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dynamodb.d.ts","sourceRoot":"","sources":["../src/dynamodb.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,0BAA0B,CAAC;AACxD,OAAO,EACL,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,uBAAuB,CAAC;AAG/B;;GAEG;AACH,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,gBAAgB,EAChB,aAAa,EACb,kBAAkB,EAClB,mBAAmB,GACpB,CAAC;AAKF,wBAAgB,iBAAiB,CAAC,MAAM,CAAC,EAAE,MAAM,kBAQhD;AAED,wBAAgB,yBAAyB,CAAC,MAAM,CAAC,EAAE,MAAM,0BAYxD;AAyJD,MAAM,WAAW,gBAAgB;IAC/B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC;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