dynamo-command-builder 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 theDashpuntsag
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,10 @@
1
+ # Simple dynamo wrapper
2
+
3
+ A simple and lightweight DynamoDB command builder for TypeScript and JavaScript applications. This library provides an easy-to-use interface for constructing DynamoDB commands, making it easier to interact with DynamoDB tables without dealing with the complexities of the AWS SDK directly.
4
+
5
+ ## Features
6
+
7
+ - Fluent API for building DynamoDB commands
8
+ - TypeScript support for type safety
9
+ - Lightweight and easy to integrate into existing projects
10
+ - Supports common DynamoDB operations like GetItem, QueryItem, PutItem, UpdateItem, DeleteItem
@@ -0,0 +1,138 @@
1
+ import { GetCommandInput, PutCommandInput, QueryCommandInput, UpdateCommandInput } from '@aws-sdk/lib-dynamodb';
2
+ import { z } from 'zod';
3
+
4
+ declare const customGetCommandInputSchema: z.ZodObject<{
5
+ tableName: z.ZodString;
6
+ key: z.ZodRecord<z.ZodString, z.ZodUnknown>;
7
+ projectionExpression: z.ZodOptional<z.ZodString>;
8
+ expressionAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
9
+ consistentRead: z.ZodOptional<z.ZodBoolean>;
10
+ returnConsumedCapacity: z.ZodOptional<z.ZodEnum<{
11
+ INDEXES: "INDEXES";
12
+ TOTAL: "TOTAL";
13
+ NONE: "NONE";
14
+ }>>;
15
+ }, z.core.$strip>;
16
+ type CustomGetCommandInput = z.infer<typeof customGetCommandInputSchema>;
17
+ declare const customQueryCommandInputSchema: z.ZodObject<{
18
+ tableName: z.ZodString;
19
+ queryRequest: z.ZodObject<{
20
+ pKey: z.ZodString;
21
+ pKeyType: z.ZodString;
22
+ pKeyProp: z.ZodString;
23
+ sKey: z.ZodOptional<z.ZodString>;
24
+ sKeyType: z.ZodOptional<z.ZodString>;
25
+ sKeyProp: z.ZodOptional<z.ZodString>;
26
+ skValue2: z.ZodOptional<z.ZodString>;
27
+ skValue2Type: z.ZodOptional<z.ZodString>;
28
+ skComparator: z.ZodOptional<z.ZodString>;
29
+ indexName: z.ZodOptional<z.ZodString>;
30
+ limit: z.ZodOptional<z.ZodNumber>;
31
+ lastEvaluatedKey: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
32
+ sorting: z.ZodOptional<z.ZodString>;
33
+ }, z.core.$strip>;
34
+ keyConditionExpression: z.ZodOptional<z.ZodString>;
35
+ filterExpression: z.ZodOptional<z.ZodString>;
36
+ expressionAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
37
+ expressionAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
+ extraExpAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
39
+ extraExpAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
40
+ projectionExpression: z.ZodOptional<z.ZodString>;
41
+ scanIndexForward: z.ZodOptional<z.ZodBoolean>;
42
+ returnConsumedCapacity: z.ZodOptional<z.ZodEnum<{
43
+ INDEXES: "INDEXES";
44
+ TOTAL: "TOTAL";
45
+ NONE: "NONE";
46
+ }>>;
47
+ }, z.core.$strip>;
48
+ type CustomQueryCommandInput = z.infer<typeof customQueryCommandInputSchema>;
49
+ declare const customPutCommandInputSchema: z.ZodObject<{
50
+ tableName: z.ZodString;
51
+ item: z.ZodRecord<z.ZodString, z.ZodUnknown>;
52
+ conditionExpression: z.ZodOptional<z.ZodString>;
53
+ expressionAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
54
+ expressionAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
55
+ returnValues: z.ZodOptional<z.ZodEnum<{
56
+ NONE: "NONE";
57
+ ALL_OLD: "ALL_OLD";
58
+ UPDATED_OLD: "UPDATED_OLD";
59
+ ALL_NEW: "ALL_NEW";
60
+ UPDATED_NEW: "UPDATED_NEW";
61
+ }>>;
62
+ returnConsumedCapacity: z.ZodOptional<z.ZodEnum<{
63
+ INDEXES: "INDEXES";
64
+ TOTAL: "TOTAL";
65
+ NONE: "NONE";
66
+ }>>;
67
+ returnItemCollectionMetrics: z.ZodOptional<z.ZodEnum<{
68
+ NONE: "NONE";
69
+ SIZE: "SIZE";
70
+ }>>;
71
+ }, z.core.$strip>;
72
+ type CustomPutCommandInput = z.infer<typeof customPutCommandInputSchema>;
73
+ declare const customUpdateCommandInputSchema: z.ZodObject<{
74
+ tableName: z.ZodString;
75
+ key: z.ZodRecord<z.ZodString, z.ZodUnknown>;
76
+ item: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
77
+ updateExpression: z.ZodOptional<z.ZodString>;
78
+ conditionExpression: z.ZodOptional<z.ZodString>;
79
+ expressionAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
80
+ expressionAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
81
+ extraExpAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
82
+ extraExpAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
83
+ returnValues: z.ZodOptional<z.ZodEnum<{
84
+ NONE: "NONE";
85
+ ALL_OLD: "ALL_OLD";
86
+ UPDATED_OLD: "UPDATED_OLD";
87
+ ALL_NEW: "ALL_NEW";
88
+ UPDATED_NEW: "UPDATED_NEW";
89
+ }>>;
90
+ returnConsumedCapacity: z.ZodOptional<z.ZodEnum<{
91
+ INDEXES: "INDEXES";
92
+ TOTAL: "TOTAL";
93
+ NONE: "NONE";
94
+ }>>;
95
+ returnItemCollectionMetrics: z.ZodOptional<z.ZodEnum<{
96
+ NONE: "NONE";
97
+ SIZE: "SIZE";
98
+ }>>;
99
+ }, z.core.$strip>;
100
+ type CustomUpdateCommandInput = z.infer<typeof customUpdateCommandInputSchema>;
101
+
102
+ declare function buildGetCommandInput(input: CustomGetCommandInput): GetCommandInput;
103
+
104
+ declare const dynamoQueryRequestSch: z.ZodObject<{
105
+ pKey: z.ZodString;
106
+ pKeyType: z.ZodString;
107
+ pKeyProp: z.ZodString;
108
+ sKey: z.ZodOptional<z.ZodString>;
109
+ sKeyType: z.ZodOptional<z.ZodString>;
110
+ sKeyProp: z.ZodOptional<z.ZodString>;
111
+ skValue2: z.ZodOptional<z.ZodString>;
112
+ skValue2Type: z.ZodOptional<z.ZodString>;
113
+ skComparator: z.ZodOptional<z.ZodString>;
114
+ indexName: z.ZodOptional<z.ZodString>;
115
+ limit: z.ZodOptional<z.ZodNumber>;
116
+ lastEvaluatedKey: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
117
+ sorting: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strip>;
119
+ type DynamoQueryRequest = z.infer<typeof dynamoQueryRequestSch>;
120
+
121
+ declare function buildPutCommandInput(input: CustomPutCommandInput): PutCommandInput;
122
+
123
+ declare function buildQueryCommandInput(input: CustomQueryCommandInput): QueryCommandInput;
124
+
125
+ declare function buildUpdateCommandInput(input: CustomUpdateCommandInput): UpdateCommandInput;
126
+
127
+ declare function createKeyConditionExpression(queryRequest: DynamoQueryRequest): string;
128
+
129
+ declare function parseDynamoKeyValue(key: string, keyType: string): unknown;
130
+
131
+ declare function extractExpAttributeNamesFromExpression(expression: string): Record<string, string>;
132
+ declare function extractExpAttributeNamesFromUpdateExp(expression: string): Record<string, string>;
133
+
134
+ declare const RESERVED_KEYWORDS_SET: Set<string>;
135
+ declare function replaceReservedKeywordsFromUpdateExp(updateExpression: string): string;
136
+ declare function replaceReservedKeywordsFromProjection(projection: string): string;
137
+
138
+ export { type CustomGetCommandInput, type CustomPutCommandInput, type CustomQueryCommandInput, type CustomUpdateCommandInput, type DynamoQueryRequest, RESERVED_KEYWORDS_SET, buildGetCommandInput, buildPutCommandInput, buildQueryCommandInput, buildUpdateCommandInput, createKeyConditionExpression, customGetCommandInputSchema, customPutCommandInputSchema, customQueryCommandInputSchema, customUpdateCommandInputSchema, dynamoQueryRequestSch, extractExpAttributeNamesFromExpression, extractExpAttributeNamesFromUpdateExp, parseDynamoKeyValue, replaceReservedKeywordsFromProjection, replaceReservedKeywordsFromUpdateExp };
@@ -0,0 +1,138 @@
1
+ import { GetCommandInput, PutCommandInput, QueryCommandInput, UpdateCommandInput } from '@aws-sdk/lib-dynamodb';
2
+ import { z } from 'zod';
3
+
4
+ declare const customGetCommandInputSchema: z.ZodObject<{
5
+ tableName: z.ZodString;
6
+ key: z.ZodRecord<z.ZodString, z.ZodUnknown>;
7
+ projectionExpression: z.ZodOptional<z.ZodString>;
8
+ expressionAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
9
+ consistentRead: z.ZodOptional<z.ZodBoolean>;
10
+ returnConsumedCapacity: z.ZodOptional<z.ZodEnum<{
11
+ INDEXES: "INDEXES";
12
+ TOTAL: "TOTAL";
13
+ NONE: "NONE";
14
+ }>>;
15
+ }, z.core.$strip>;
16
+ type CustomGetCommandInput = z.infer<typeof customGetCommandInputSchema>;
17
+ declare const customQueryCommandInputSchema: z.ZodObject<{
18
+ tableName: z.ZodString;
19
+ queryRequest: z.ZodObject<{
20
+ pKey: z.ZodString;
21
+ pKeyType: z.ZodString;
22
+ pKeyProp: z.ZodString;
23
+ sKey: z.ZodOptional<z.ZodString>;
24
+ sKeyType: z.ZodOptional<z.ZodString>;
25
+ sKeyProp: z.ZodOptional<z.ZodString>;
26
+ skValue2: z.ZodOptional<z.ZodString>;
27
+ skValue2Type: z.ZodOptional<z.ZodString>;
28
+ skComparator: z.ZodOptional<z.ZodString>;
29
+ indexName: z.ZodOptional<z.ZodString>;
30
+ limit: z.ZodOptional<z.ZodNumber>;
31
+ lastEvaluatedKey: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
32
+ sorting: z.ZodOptional<z.ZodString>;
33
+ }, z.core.$strip>;
34
+ keyConditionExpression: z.ZodOptional<z.ZodString>;
35
+ filterExpression: z.ZodOptional<z.ZodString>;
36
+ expressionAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
37
+ expressionAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
38
+ extraExpAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
39
+ extraExpAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
40
+ projectionExpression: z.ZodOptional<z.ZodString>;
41
+ scanIndexForward: z.ZodOptional<z.ZodBoolean>;
42
+ returnConsumedCapacity: z.ZodOptional<z.ZodEnum<{
43
+ INDEXES: "INDEXES";
44
+ TOTAL: "TOTAL";
45
+ NONE: "NONE";
46
+ }>>;
47
+ }, z.core.$strip>;
48
+ type CustomQueryCommandInput = z.infer<typeof customQueryCommandInputSchema>;
49
+ declare const customPutCommandInputSchema: z.ZodObject<{
50
+ tableName: z.ZodString;
51
+ item: z.ZodRecord<z.ZodString, z.ZodUnknown>;
52
+ conditionExpression: z.ZodOptional<z.ZodString>;
53
+ expressionAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
54
+ expressionAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
55
+ returnValues: z.ZodOptional<z.ZodEnum<{
56
+ NONE: "NONE";
57
+ ALL_OLD: "ALL_OLD";
58
+ UPDATED_OLD: "UPDATED_OLD";
59
+ ALL_NEW: "ALL_NEW";
60
+ UPDATED_NEW: "UPDATED_NEW";
61
+ }>>;
62
+ returnConsumedCapacity: z.ZodOptional<z.ZodEnum<{
63
+ INDEXES: "INDEXES";
64
+ TOTAL: "TOTAL";
65
+ NONE: "NONE";
66
+ }>>;
67
+ returnItemCollectionMetrics: z.ZodOptional<z.ZodEnum<{
68
+ NONE: "NONE";
69
+ SIZE: "SIZE";
70
+ }>>;
71
+ }, z.core.$strip>;
72
+ type CustomPutCommandInput = z.infer<typeof customPutCommandInputSchema>;
73
+ declare const customUpdateCommandInputSchema: z.ZodObject<{
74
+ tableName: z.ZodString;
75
+ key: z.ZodRecord<z.ZodString, z.ZodUnknown>;
76
+ item: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
77
+ updateExpression: z.ZodOptional<z.ZodString>;
78
+ conditionExpression: z.ZodOptional<z.ZodString>;
79
+ expressionAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
80
+ expressionAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
81
+ extraExpAttributeNames: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
82
+ extraExpAttributeValues: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
83
+ returnValues: z.ZodOptional<z.ZodEnum<{
84
+ NONE: "NONE";
85
+ ALL_OLD: "ALL_OLD";
86
+ UPDATED_OLD: "UPDATED_OLD";
87
+ ALL_NEW: "ALL_NEW";
88
+ UPDATED_NEW: "UPDATED_NEW";
89
+ }>>;
90
+ returnConsumedCapacity: z.ZodOptional<z.ZodEnum<{
91
+ INDEXES: "INDEXES";
92
+ TOTAL: "TOTAL";
93
+ NONE: "NONE";
94
+ }>>;
95
+ returnItemCollectionMetrics: z.ZodOptional<z.ZodEnum<{
96
+ NONE: "NONE";
97
+ SIZE: "SIZE";
98
+ }>>;
99
+ }, z.core.$strip>;
100
+ type CustomUpdateCommandInput = z.infer<typeof customUpdateCommandInputSchema>;
101
+
102
+ declare function buildGetCommandInput(input: CustomGetCommandInput): GetCommandInput;
103
+
104
+ declare const dynamoQueryRequestSch: z.ZodObject<{
105
+ pKey: z.ZodString;
106
+ pKeyType: z.ZodString;
107
+ pKeyProp: z.ZodString;
108
+ sKey: z.ZodOptional<z.ZodString>;
109
+ sKeyType: z.ZodOptional<z.ZodString>;
110
+ sKeyProp: z.ZodOptional<z.ZodString>;
111
+ skValue2: z.ZodOptional<z.ZodString>;
112
+ skValue2Type: z.ZodOptional<z.ZodString>;
113
+ skComparator: z.ZodOptional<z.ZodString>;
114
+ indexName: z.ZodOptional<z.ZodString>;
115
+ limit: z.ZodOptional<z.ZodNumber>;
116
+ lastEvaluatedKey: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
117
+ sorting: z.ZodOptional<z.ZodString>;
118
+ }, z.core.$strip>;
119
+ type DynamoQueryRequest = z.infer<typeof dynamoQueryRequestSch>;
120
+
121
+ declare function buildPutCommandInput(input: CustomPutCommandInput): PutCommandInput;
122
+
123
+ declare function buildQueryCommandInput(input: CustomQueryCommandInput): QueryCommandInput;
124
+
125
+ declare function buildUpdateCommandInput(input: CustomUpdateCommandInput): UpdateCommandInput;
126
+
127
+ declare function createKeyConditionExpression(queryRequest: DynamoQueryRequest): string;
128
+
129
+ declare function parseDynamoKeyValue(key: string, keyType: string): unknown;
130
+
131
+ declare function extractExpAttributeNamesFromExpression(expression: string): Record<string, string>;
132
+ declare function extractExpAttributeNamesFromUpdateExp(expression: string): Record<string, string>;
133
+
134
+ declare const RESERVED_KEYWORDS_SET: Set<string>;
135
+ declare function replaceReservedKeywordsFromUpdateExp(updateExpression: string): string;
136
+ declare function replaceReservedKeywordsFromProjection(projection: string): string;
137
+
138
+ export { type CustomGetCommandInput, type CustomPutCommandInput, type CustomQueryCommandInput, type CustomUpdateCommandInput, type DynamoQueryRequest, RESERVED_KEYWORDS_SET, buildGetCommandInput, buildPutCommandInput, buildQueryCommandInput, buildUpdateCommandInput, createKeyConditionExpression, customGetCommandInputSchema, customPutCommandInputSchema, customQueryCommandInputSchema, customUpdateCommandInputSchema, dynamoQueryRequestSch, extractExpAttributeNamesFromExpression, extractExpAttributeNamesFromUpdateExp, parseDynamoKeyValue, replaceReservedKeywordsFromProjection, replaceReservedKeywordsFromUpdateExp };