dyno-table 2.5.2 → 2.6.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/dist/builders/batch-builder.d.ts +249 -0
- package/dist/builders/builder-types.d.ts +123 -0
- package/dist/builders/condition-check-builder.d.ts +149 -0
- package/dist/builders/delete-builder.d.ts +208 -0
- package/dist/builders/entity-aware-builders.d.ts +127 -0
- package/dist/builders/filter-builder.d.ts +294 -0
- package/dist/builders/get-builder.d.ts +191 -0
- package/dist/builders/index.d.ts +14 -0
- package/dist/builders/paginator.d.ts +151 -0
- package/dist/builders/put-builder.d.ts +317 -0
- package/dist/builders/query-builder.d.ts +218 -0
- package/dist/builders/result-iterator.d.ts +55 -0
- package/dist/builders/scan-builder.d.ts +109 -0
- package/dist/builders/transaction-builder.d.ts +462 -0
- package/dist/builders/types.d.ts +25 -0
- package/dist/builders/update-builder.d.ts +372 -0
- package/dist/builders.d.ts +1 -4
- package/dist/conditions.d.ts +705 -3
- package/dist/entity/ddb-indexing.d.ts +45 -0
- package/dist/entity/entity.d.ts +188 -0
- package/dist/entity/index-utils.d.ts +24 -0
- package/dist/entity.cjs +4 -4
- package/dist/entity.d.ts +1 -261
- package/dist/entity.js +1 -1
- package/dist/errors.d.ts +212 -0
- package/dist/expression.d.ts +9 -0
- package/dist/index-definition.d.ts +10 -0
- package/dist/index.cjs +25 -25
- package/dist/index.d.ts +16 -273
- package/dist/index.js +1 -1
- package/dist/operation-types.d.ts +8 -0
- package/dist/standard-schema.d.ts +2 -4
- package/dist/table.d.ts +13 -8
- package/dist/types.d.ts +6 -9
- package/dist/utils/chunk-array.d.ts +9 -0
- package/dist/utils/debug-expression.d.ts +32 -0
- package/dist/utils/debug-transaction.d.ts +17 -0
- package/dist/utils/error-factory.d.ts +162 -0
- package/dist/utils/error-utils.d.ts +170 -0
- package/dist/utils/index.d.ts +7 -0
- package/dist/utils/partition-key-template.d.ts +30 -0
- package/dist/utils/sort-key-template.d.ts +33 -0
- package/dist/utils.d.ts +1 -66
- package/package.json +12 -10
- package/dist/builders.d.cts +0 -4
- package/dist/conditions-BSAcZswY.d.ts +0 -731
- package/dist/conditions-C8bM__Pn.d.cts +0 -731
- package/dist/conditions.d.cts +0 -3
- package/dist/entity.d.cts +0 -261
- package/dist/index-Bc-ra0im.d.ts +0 -3042
- package/dist/index-CPCmWsEv.d.cts +0 -3042
- package/dist/index.d.cts +0 -273
- package/dist/standard-schema.d.cts +0 -57
- package/dist/table.d.cts +0 -165
- package/dist/types.d.cts +0 -29
- package/dist/utils.d.cts +0 -66
- package/dist/{chunk-RNX2DAHA.js → chunk-JZB6TYST.js} +130 -130
- package/dist/{chunk-G5ERTQFX.cjs → chunk-Z334X72N.cjs} +130 -130
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base error class for all dyno-table errors
|
|
3
|
+
*
|
|
4
|
+
* All custom errors in the library extend this class, allowing consumers
|
|
5
|
+
* to catch all library errors with a single catch block if needed.
|
|
6
|
+
*/
|
|
7
|
+
export declare class DynoTableError extends Error {
|
|
8
|
+
/**
|
|
9
|
+
* Machine-readable error code for programmatic error handling
|
|
10
|
+
* @example "KEY_GENERATION_FAILED", "VALIDATION_ERROR", etc.
|
|
11
|
+
*/
|
|
12
|
+
readonly code: string;
|
|
13
|
+
/**
|
|
14
|
+
* Additional context about the error
|
|
15
|
+
* Contains operation-specific details like entity names, table names,
|
|
16
|
+
* expressions, conditions, and other relevant debugging information
|
|
17
|
+
*/
|
|
18
|
+
readonly context: Record<string, unknown>;
|
|
19
|
+
/**
|
|
20
|
+
* The original error that caused this error (if wrapping another error)
|
|
21
|
+
* Useful for preserving AWS SDK errors or other underlying errors
|
|
22
|
+
*/
|
|
23
|
+
readonly cause?: Error;
|
|
24
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Error for schema validation and input validation failures
|
|
28
|
+
*
|
|
29
|
+
* Thrown when user-provided data doesn't match the expected schema
|
|
30
|
+
* or when required fields are missing.
|
|
31
|
+
*/
|
|
32
|
+
export declare class ValidationError extends DynoTableError {
|
|
33
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Error for DynamoDB operation failures
|
|
37
|
+
*
|
|
38
|
+
* Wraps AWS SDK errors and adds library-specific context like
|
|
39
|
+
* the operation type, table name, and generated expressions.
|
|
40
|
+
*/
|
|
41
|
+
export declare class OperationError extends DynoTableError {
|
|
42
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Error for transaction-specific failures
|
|
46
|
+
*
|
|
47
|
+
* Thrown when transaction operations fail, including duplicate item
|
|
48
|
+
* detection, transaction cancellation, and other transaction-related issues.
|
|
49
|
+
*/
|
|
50
|
+
export declare class TransactionError extends DynoTableError {
|
|
51
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Error for batch operation failures
|
|
55
|
+
*
|
|
56
|
+
* Thrown when batch operations fail or when batch limits are exceeded.
|
|
57
|
+
* Includes information about unprocessed items and operation details.
|
|
58
|
+
*/
|
|
59
|
+
export declare class BatchError extends DynoTableError {
|
|
60
|
+
/**
|
|
61
|
+
* The type of batch operation that failed
|
|
62
|
+
*/
|
|
63
|
+
readonly operation: "write" | "read";
|
|
64
|
+
/**
|
|
65
|
+
* The items that were not processed during the batch operation
|
|
66
|
+
*/
|
|
67
|
+
readonly unprocessedItems: unknown[];
|
|
68
|
+
constructor(message: string, code: string, operation: "write" | "read", unprocessedItems?: unknown[], context?: Record<string, unknown>, cause?: Error);
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Error for expression building failures
|
|
72
|
+
*
|
|
73
|
+
* Thrown when building DynamoDB expressions (condition, filter, update, etc.)
|
|
74
|
+
* fails due to invalid conditions or missing required fields.
|
|
75
|
+
*/
|
|
76
|
+
export declare class ExpressionError extends DynoTableError {
|
|
77
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Error for table/index configuration issues
|
|
81
|
+
*
|
|
82
|
+
* Thrown when there are problems with table configuration,
|
|
83
|
+
* such as missing GSIs or invalid index references.
|
|
84
|
+
*/
|
|
85
|
+
export declare class ConfigurationError extends DynoTableError {
|
|
86
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Base error for all entity-related errors
|
|
90
|
+
*
|
|
91
|
+
* Parent class for entity-specific errors like key generation
|
|
92
|
+
* and index generation failures.
|
|
93
|
+
*/
|
|
94
|
+
export declare class EntityError extends DynoTableError {
|
|
95
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Error for primary key generation failures
|
|
99
|
+
*
|
|
100
|
+
* Thrown when generating entity primary keys fails due to missing
|
|
101
|
+
* attributes or invalid key formats.
|
|
102
|
+
*
|
|
103
|
+
* @example
|
|
104
|
+
* ```typescript
|
|
105
|
+
* try {
|
|
106
|
+
* await userRepo.create({ name: "John" }).execute();
|
|
107
|
+
* } catch (error) {
|
|
108
|
+
* if (error instanceof KeyGenerationError) {
|
|
109
|
+
* console.error("Failed to generate key");
|
|
110
|
+
* console.error("Entity:", error.context.entityName);
|
|
111
|
+
* console.error("Required attributes:", error.context.requiredAttributes);
|
|
112
|
+
* }
|
|
113
|
+
* }
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
export declare class KeyGenerationError extends EntityError {
|
|
117
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Error for index key generation failures
|
|
121
|
+
*
|
|
122
|
+
* Thrown when generating secondary index keys fails due to missing
|
|
123
|
+
* attributes or when trying to update readonly indexes without forcing.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* ```typescript
|
|
127
|
+
* try {
|
|
128
|
+
* await orderRepo.update({ id: "123" }, { status: "shipped" }).execute();
|
|
129
|
+
* } catch (error) {
|
|
130
|
+
* if (error instanceof IndexGenerationError) {
|
|
131
|
+
* console.error("Index failed:", error.context.indexName);
|
|
132
|
+
* console.error("Suggestion:", error.context.suggestion);
|
|
133
|
+
* }
|
|
134
|
+
* }
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
export declare class IndexGenerationError extends EntityError {
|
|
138
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Error for entity schema validation failures
|
|
142
|
+
*
|
|
143
|
+
* Thrown when entity data doesn't pass schema validation.
|
|
144
|
+
* Includes validation issues and the entity context.
|
|
145
|
+
*/
|
|
146
|
+
export declare class EntityValidationError extends ValidationError {
|
|
147
|
+
constructor(message: string, code: string, context?: Record<string, unknown>, cause?: Error);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Error codes used throughout the library
|
|
151
|
+
*
|
|
152
|
+
* These codes allow for programmatic error handling and can be used
|
|
153
|
+
* to implement retry logic, user-friendly error messages, etc.
|
|
154
|
+
*/
|
|
155
|
+
export declare const ErrorCodes: {
|
|
156
|
+
readonly KEY_GENERATION_FAILED: "KEY_GENERATION_FAILED";
|
|
157
|
+
readonly KEY_MISSING_ATTRIBUTES: "KEY_MISSING_ATTRIBUTES";
|
|
158
|
+
readonly KEY_INVALID_FORMAT: "KEY_INVALID_FORMAT";
|
|
159
|
+
readonly INDEX_GENERATION_FAILED: "INDEX_GENERATION_FAILED";
|
|
160
|
+
readonly INDEX_MISSING_ATTRIBUTES: "INDEX_MISSING_ATTRIBUTES";
|
|
161
|
+
readonly INDEX_NOT_FOUND: "INDEX_NOT_FOUND";
|
|
162
|
+
readonly INDEX_READONLY_UPDATE_FAILED: "INDEX_READONLY_UPDATE_FAILED";
|
|
163
|
+
readonly INDEX_UNDEFINED_VALUES: "INDEX_UNDEFINED_VALUES";
|
|
164
|
+
readonly ENTITY_VALIDATION_FAILED: "ENTITY_VALIDATION_FAILED";
|
|
165
|
+
readonly ASYNC_VALIDATION_NOT_SUPPORTED: "ASYNC_VALIDATION_NOT_SUPPORTED";
|
|
166
|
+
readonly QUERY_INPUT_VALIDATION_FAILED: "QUERY_INPUT_VALIDATION_FAILED";
|
|
167
|
+
readonly VALIDATION_ERROR: "VALIDATION_ERROR";
|
|
168
|
+
readonly VALIDATION_FAILED: "VALIDATION_FAILED";
|
|
169
|
+
readonly SCHEMA_VALIDATION_FAILED: "SCHEMA_VALIDATION_FAILED";
|
|
170
|
+
readonly INVALID_PARAMETER: "INVALID_PARAMETER";
|
|
171
|
+
readonly MISSING_REQUIRED_FIELD: "MISSING_REQUIRED_FIELD";
|
|
172
|
+
readonly UNDEFINED_VALUE: "UNDEFINED_VALUE";
|
|
173
|
+
readonly EXPRESSION_MISSING_ATTRIBUTE: "EXPRESSION_MISSING_ATTRIBUTE";
|
|
174
|
+
readonly EXPRESSION_MISSING_VALUE: "EXPRESSION_MISSING_VALUE";
|
|
175
|
+
readonly EXPRESSION_INVALID_CONDITION: "EXPRESSION_INVALID_CONDITION";
|
|
176
|
+
readonly EXPRESSION_EMPTY_ARRAY: "EXPRESSION_EMPTY_ARRAY";
|
|
177
|
+
readonly EXPRESSION_UNKNOWN_TYPE: "EXPRESSION_UNKNOWN_TYPE";
|
|
178
|
+
readonly EXPRESSION_INVALID: "EXPRESSION_INVALID";
|
|
179
|
+
readonly EXPRESSION_INVALID_OPERATOR: "EXPRESSION_INVALID_OPERATOR";
|
|
180
|
+
readonly QUERY_FAILED: "QUERY_FAILED";
|
|
181
|
+
readonly SCAN_FAILED: "SCAN_FAILED";
|
|
182
|
+
readonly GET_FAILED: "GET_FAILED";
|
|
183
|
+
readonly PUT_FAILED: "PUT_FAILED";
|
|
184
|
+
readonly DELETE_FAILED: "DELETE_FAILED";
|
|
185
|
+
readonly UPDATE_FAILED: "UPDATE_FAILED";
|
|
186
|
+
readonly BATCH_GET_FAILED: "BATCH_GET_FAILED";
|
|
187
|
+
readonly BATCH_WRITE_FAILED: "BATCH_WRITE_FAILED";
|
|
188
|
+
readonly NO_UPDATE_ACTIONS: "NO_UPDATE_ACTIONS";
|
|
189
|
+
readonly CONDITIONAL_CHECK_FAILED: "CONDITIONAL_CHECK_FAILED";
|
|
190
|
+
readonly TRANSACTION_FAILED: "TRANSACTION_FAILED";
|
|
191
|
+
readonly TRANSACTION_DUPLICATE_ITEM: "TRANSACTION_DUPLICATE_ITEM";
|
|
192
|
+
readonly TRANSACTION_EMPTY: "TRANSACTION_EMPTY";
|
|
193
|
+
readonly TRANSACTION_UNSUPPORTED_TYPE: "TRANSACTION_UNSUPPORTED_TYPE";
|
|
194
|
+
readonly TRANSACTION_ITEM_LIMIT: "TRANSACTION_ITEM_LIMIT";
|
|
195
|
+
readonly TRANSACTION_CANCELLED: "TRANSACTION_CANCELLED";
|
|
196
|
+
readonly BATCH_EMPTY: "BATCH_EMPTY";
|
|
197
|
+
readonly BATCH_UNSUPPORTED_TYPE: "BATCH_UNSUPPORTED_TYPE";
|
|
198
|
+
readonly BATCH_UNPROCESSED_ITEMS: "BATCH_UNPROCESSED_ITEMS";
|
|
199
|
+
readonly BATCH_SIZE_EXCEEDED: "BATCH_SIZE_EXCEEDED";
|
|
200
|
+
readonly GSI_NOT_FOUND: "GSI_NOT_FOUND";
|
|
201
|
+
readonly SORT_KEY_REQUIRED: "SORT_KEY_REQUIRED";
|
|
202
|
+
readonly SORT_KEY_NOT_DEFINED: "SORT_KEY_NOT_DEFINED";
|
|
203
|
+
readonly PRIMARY_KEY_MISSING: "PRIMARY_KEY_MISSING";
|
|
204
|
+
readonly INVALID_CHUNK_SIZE: "INVALID_CHUNK_SIZE";
|
|
205
|
+
readonly CONDITION_REQUIRED: "CONDITION_REQUIRED";
|
|
206
|
+
readonly CONDITION_GENERATION_FAILED: "CONDITION_GENERATION_FAILED";
|
|
207
|
+
readonly PK_EXTRACTION_FAILED: "PK_EXTRACTION_FAILED";
|
|
208
|
+
readonly CONFIGURATION_INVALID: "CONFIGURATION_INVALID";
|
|
209
|
+
readonly CONFIGURATION_MISSING_SORT_KEY: "CONFIGURATION_MISSING_SORT_KEY";
|
|
210
|
+
readonly CONFIGURATION_INVALID_GSI: "CONFIGURATION_INVALID_GSI";
|
|
211
|
+
};
|
|
212
|
+
export type ErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Condition, ExpressionParams } from "./conditions";
|
|
2
|
+
export declare const generateAttributeName: (params: ExpressionParams, attr: string) => string;
|
|
3
|
+
export declare const generateValueName: (params: ExpressionParams, value: unknown) => string;
|
|
4
|
+
export declare const buildExpression: (condition: Condition, params: ExpressionParams) => string;
|
|
5
|
+
export declare const prepareExpressionParams: (condition?: Condition) => {
|
|
6
|
+
expression?: string;
|
|
7
|
+
names?: Record<string, string>;
|
|
8
|
+
values?: Record<string, unknown>;
|
|
9
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { DynamoItem } from "./types";
|
|
2
|
+
export interface IndexDefinition<T extends DynamoItem, P extends (item: T) => string, S extends ((item: T) => string) | undefined = undefined> {
|
|
3
|
+
name: string;
|
|
4
|
+
partitionKey: P;
|
|
5
|
+
sortKey?: S;
|
|
6
|
+
generateKey: (item: T) => {
|
|
7
|
+
pk: string;
|
|
8
|
+
sk?: string;
|
|
9
|
+
};
|
|
10
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunkZUBCW3LA_cjs = require('./chunk-ZUBCW3LA.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkZ334X72N_cjs = require('./chunk-Z334X72N.cjs');
|
|
5
5
|
var chunkPB7BBCZO_cjs = require('./chunk-PB7BBCZO.cjs');
|
|
6
6
|
var chunk3DR6VOFW_cjs = require('./chunk-3DR6VOFW.cjs');
|
|
7
7
|
var chunkELULXDSB_cjs = require('./chunk-ELULXDSB.cjs');
|
|
@@ -15,99 +15,99 @@ Object.defineProperty(exports, "Table", {
|
|
|
15
15
|
});
|
|
16
16
|
Object.defineProperty(exports, "createIndex", {
|
|
17
17
|
enumerable: true,
|
|
18
|
-
get: function () { return
|
|
18
|
+
get: function () { return chunkZ334X72N_cjs.createIndex; }
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "createQueries", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function () { return
|
|
22
|
+
get: function () { return chunkZ334X72N_cjs.createQueries; }
|
|
23
23
|
});
|
|
24
24
|
Object.defineProperty(exports, "defineEntity", {
|
|
25
25
|
enumerable: true,
|
|
26
|
-
get: function () { return
|
|
26
|
+
get: function () { return chunkZ334X72N_cjs.defineEntity; }
|
|
27
27
|
});
|
|
28
28
|
Object.defineProperty(exports, "extractRequiredAttributes", {
|
|
29
29
|
enumerable: true,
|
|
30
|
-
get: function () { return
|
|
30
|
+
get: function () { return chunkZ334X72N_cjs.extractRequiredAttributes; }
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "formatErrorContext", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function () { return
|
|
34
|
+
get: function () { return chunkZ334X72N_cjs.formatErrorContext; }
|
|
35
35
|
});
|
|
36
36
|
Object.defineProperty(exports, "getAwsErrorCode", {
|
|
37
37
|
enumerable: true,
|
|
38
|
-
get: function () { return
|
|
38
|
+
get: function () { return chunkZ334X72N_cjs.getAwsErrorCode; }
|
|
39
39
|
});
|
|
40
40
|
Object.defineProperty(exports, "getAwsErrorMessage", {
|
|
41
41
|
enumerable: true,
|
|
42
|
-
get: function () { return
|
|
42
|
+
get: function () { return chunkZ334X72N_cjs.getAwsErrorMessage; }
|
|
43
43
|
});
|
|
44
44
|
Object.defineProperty(exports, "getErrorSummary", {
|
|
45
45
|
enumerable: true,
|
|
46
|
-
get: function () { return
|
|
46
|
+
get: function () { return chunkZ334X72N_cjs.getErrorSummary; }
|
|
47
47
|
});
|
|
48
48
|
Object.defineProperty(exports, "isBatchError", {
|
|
49
49
|
enumerable: true,
|
|
50
|
-
get: function () { return
|
|
50
|
+
get: function () { return chunkZ334X72N_cjs.isBatchError; }
|
|
51
51
|
});
|
|
52
52
|
Object.defineProperty(exports, "isConditionalCheckFailed", {
|
|
53
53
|
enumerable: true,
|
|
54
|
-
get: function () { return
|
|
54
|
+
get: function () { return chunkZ334X72N_cjs.isConditionalCheckFailed; }
|
|
55
55
|
});
|
|
56
56
|
Object.defineProperty(exports, "isConfigurationError", {
|
|
57
57
|
enumerable: true,
|
|
58
|
-
get: function () { return
|
|
58
|
+
get: function () { return chunkZ334X72N_cjs.isConfigurationError; }
|
|
59
59
|
});
|
|
60
60
|
Object.defineProperty(exports, "isDynoTableError", {
|
|
61
61
|
enumerable: true,
|
|
62
|
-
get: function () { return
|
|
62
|
+
get: function () { return chunkZ334X72N_cjs.isDynoTableError; }
|
|
63
63
|
});
|
|
64
64
|
Object.defineProperty(exports, "isEntityError", {
|
|
65
65
|
enumerable: true,
|
|
66
|
-
get: function () { return
|
|
66
|
+
get: function () { return chunkZ334X72N_cjs.isEntityError; }
|
|
67
67
|
});
|
|
68
68
|
Object.defineProperty(exports, "isEntityValidationError", {
|
|
69
69
|
enumerable: true,
|
|
70
|
-
get: function () { return
|
|
70
|
+
get: function () { return chunkZ334X72N_cjs.isEntityValidationError; }
|
|
71
71
|
});
|
|
72
72
|
Object.defineProperty(exports, "isExpressionError", {
|
|
73
73
|
enumerable: true,
|
|
74
|
-
get: function () { return
|
|
74
|
+
get: function () { return chunkZ334X72N_cjs.isExpressionError; }
|
|
75
75
|
});
|
|
76
76
|
Object.defineProperty(exports, "isIndexGenerationError", {
|
|
77
77
|
enumerable: true,
|
|
78
|
-
get: function () { return
|
|
78
|
+
get: function () { return chunkZ334X72N_cjs.isIndexGenerationError; }
|
|
79
79
|
});
|
|
80
80
|
Object.defineProperty(exports, "isKeyGenerationError", {
|
|
81
81
|
enumerable: true,
|
|
82
|
-
get: function () { return
|
|
82
|
+
get: function () { return chunkZ334X72N_cjs.isKeyGenerationError; }
|
|
83
83
|
});
|
|
84
84
|
Object.defineProperty(exports, "isOperationError", {
|
|
85
85
|
enumerable: true,
|
|
86
|
-
get: function () { return
|
|
86
|
+
get: function () { return chunkZ334X72N_cjs.isOperationError; }
|
|
87
87
|
});
|
|
88
88
|
Object.defineProperty(exports, "isProvisionedThroughputExceeded", {
|
|
89
89
|
enumerable: true,
|
|
90
|
-
get: function () { return
|
|
90
|
+
get: function () { return chunkZ334X72N_cjs.isProvisionedThroughputExceeded; }
|
|
91
91
|
});
|
|
92
92
|
Object.defineProperty(exports, "isRetryableError", {
|
|
93
93
|
enumerable: true,
|
|
94
|
-
get: function () { return
|
|
94
|
+
get: function () { return chunkZ334X72N_cjs.isRetryableError; }
|
|
95
95
|
});
|
|
96
96
|
Object.defineProperty(exports, "isTransactionCanceled", {
|
|
97
97
|
enumerable: true,
|
|
98
|
-
get: function () { return
|
|
98
|
+
get: function () { return chunkZ334X72N_cjs.isTransactionCanceled; }
|
|
99
99
|
});
|
|
100
100
|
Object.defineProperty(exports, "isTransactionError", {
|
|
101
101
|
enumerable: true,
|
|
102
|
-
get: function () { return
|
|
102
|
+
get: function () { return chunkZ334X72N_cjs.isTransactionError; }
|
|
103
103
|
});
|
|
104
104
|
Object.defineProperty(exports, "isValidationError", {
|
|
105
105
|
enumerable: true,
|
|
106
|
-
get: function () { return
|
|
106
|
+
get: function () { return chunkZ334X72N_cjs.isValidationError; }
|
|
107
107
|
});
|
|
108
108
|
Object.defineProperty(exports, "isValidationException", {
|
|
109
109
|
enumerable: true,
|
|
110
|
-
get: function () { return
|
|
110
|
+
get: function () { return chunkZ334X72N_cjs.isValidationException; }
|
|
111
111
|
});
|
|
112
112
|
Object.defineProperty(exports, "partitionKey", {
|
|
113
113
|
enumerable: true,
|
package/dist/index.d.ts
CHANGED
|
@@ -1,273 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
export {
|
|
6
|
-
export {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
invalidCondition: (conditionType: string, condition: unknown, suggestion?: string) => ExpressionError;
|
|
18
|
-
emptyArray: (conditionType: string, providedValue: unknown) => ExpressionError;
|
|
19
|
-
unknownType: (conditionType: string, condition: unknown) => ExpressionError;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Factory functions for Validation errors
|
|
23
|
-
*/
|
|
24
|
-
declare const ValidationErrors: {
|
|
25
|
-
indexSchemaValidationFailed: (validationIssues: unknown, keyType: "partition" | "sort" | "both") => ValidationError;
|
|
26
|
-
noUpdateActions: (tableName: string, key: Record<string, unknown>) => ValidationError;
|
|
27
|
-
conditionRequired: (tableName: string, key: Record<string, unknown>) => ValidationError;
|
|
28
|
-
queryInputValidationFailed: (entityName: string, queryName: string, validationIssues: unknown, providedInput: unknown) => ValidationError;
|
|
29
|
-
undefinedValue: (path: string, tableName: string, key: Record<string, unknown>) => ValidationError;
|
|
30
|
-
};
|
|
31
|
-
/**
|
|
32
|
-
* Factory functions for Configuration errors
|
|
33
|
-
*/
|
|
34
|
-
declare const ConfigurationErrors: {
|
|
35
|
-
invalidChunkSize: (size: number) => ConfigurationError;
|
|
36
|
-
sortKeyRequired: (tableName: string, partitionKey: string, sortKey?: string) => ConfigurationError;
|
|
37
|
-
sortKeyNotDefined: (tableName: string, partitionKey: string, indexName?: string) => ConfigurationError;
|
|
38
|
-
gsiNotFound: (indexName: string, tableName: string, availableIndexes: string[]) => ConfigurationError;
|
|
39
|
-
primaryKeyMissing: (tableName: string, partitionKeyName: string, providedItem: unknown) => ConfigurationError;
|
|
40
|
-
pkExtractionFailed: (tableName: string, indexName: string, item: unknown, cause?: Error) => ConfigurationError;
|
|
41
|
-
conditionGenerationFailed: (condition: unknown, suggestion?: string) => ExpressionError;
|
|
42
|
-
};
|
|
43
|
-
/**
|
|
44
|
-
* Factory functions for Operation errors
|
|
45
|
-
*/
|
|
46
|
-
declare const OperationErrors: {
|
|
47
|
-
queryFailed: (tableName: string, context: Record<string, unknown>, cause?: Error) => OperationError;
|
|
48
|
-
scanFailed: (tableName: string, context: Record<string, unknown>, cause?: Error) => OperationError;
|
|
49
|
-
getFailed: (tableName: string, key: Record<string, unknown>, cause?: Error) => OperationError;
|
|
50
|
-
putFailed: (tableName: string, item: unknown, cause?: Error) => OperationError;
|
|
51
|
-
updateFailed: (tableName: string, key: Record<string, unknown>, cause?: Error) => OperationError;
|
|
52
|
-
deleteFailed: (tableName: string, key: Record<string, unknown>, cause?: Error) => OperationError;
|
|
53
|
-
batchGetFailed: (tableName: string, context: Record<string, unknown>, cause?: Error) => OperationError;
|
|
54
|
-
batchWriteFailed: (tableName: string, context: Record<string, unknown>, cause?: Error) => OperationError;
|
|
55
|
-
};
|
|
56
|
-
/**
|
|
57
|
-
* Factory functions for Transaction errors
|
|
58
|
-
*/
|
|
59
|
-
declare const TransactionErrors: {
|
|
60
|
-
transactionFailed: (itemCount: number, context: Record<string, unknown>, cause?: Error) => TransactionError;
|
|
61
|
-
duplicateItem: (tableName: string, partitionKey: {
|
|
62
|
-
name: string;
|
|
63
|
-
value: unknown;
|
|
64
|
-
}, sortKey?: {
|
|
65
|
-
name: string;
|
|
66
|
-
value: unknown;
|
|
67
|
-
}) => TransactionError;
|
|
68
|
-
transactionEmpty: () => TransactionError;
|
|
69
|
-
unsupportedType: (item: unknown) => TransactionError;
|
|
70
|
-
};
|
|
71
|
-
/**
|
|
72
|
-
* Factory functions for Batch errors
|
|
73
|
-
*/
|
|
74
|
-
declare const BatchErrors: {
|
|
75
|
-
batchEmpty: (operation: "write" | "read") => BatchError;
|
|
76
|
-
unsupportedType: (operation: "write" | "read", item: unknown) => BatchError;
|
|
77
|
-
batchWriteFailed: (unprocessedItems: unknown[], context: Record<string, unknown>, cause?: Error) => BatchError;
|
|
78
|
-
batchGetFailed: (unprocessedItems: unknown[], context: Record<string, unknown>, cause?: Error) => BatchError;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Factory functions for Entity errors
|
|
82
|
-
*/
|
|
83
|
-
declare const EntityErrors: {
|
|
84
|
-
validationFailed: (entityName: string, operation: string, validationIssues: unknown, providedData: unknown) => EntityValidationError;
|
|
85
|
-
queryInputValidationFailed: (entityName: string, queryName: string, validationIssues: unknown, providedInput: unknown) => EntityValidationError;
|
|
86
|
-
asyncValidationNotSupported: (entityName: string, operation: string) => EntityValidationError;
|
|
87
|
-
keyGenerationFailed: (entityName: string, operation: string, providedData: unknown, requiredAttributes?: string[], cause?: Error) => KeyGenerationError;
|
|
88
|
-
keyInvalidFormat: (entityName: string, operation: string, providedData: unknown, generatedKey: unknown) => KeyGenerationError;
|
|
89
|
-
keyMissingAttributes: (entityName: string, operation: string, missingAttributes: string[], providedData: unknown) => KeyGenerationError;
|
|
90
|
-
};
|
|
91
|
-
/**
|
|
92
|
-
* Factory functions for Index errors
|
|
93
|
-
*/
|
|
94
|
-
declare const IndexErrors: {
|
|
95
|
-
generationFailed: (indexName: string, operation: string, providedItem: unknown, partitionKeyAttribute?: string, sortKeyAttribute?: string, cause?: Error) => IndexGenerationError;
|
|
96
|
-
missingAttributes: (indexName: string, operation: string, missingAttributes: string[], providedData: unknown, isReadOnly: boolean) => IndexGenerationError;
|
|
97
|
-
undefinedValues: (indexName: string, operation: string, generatedKey: unknown, providedItem: unknown) => IndexGenerationError;
|
|
98
|
-
notFound: (requestedIndexes: string[], availableIndexes: string[], entityName?: string, tableName?: string) => IndexGenerationError;
|
|
99
|
-
readonlyUpdateFailed: (indexName: string, operation: string, providedData: unknown) => IndexGenerationError;
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Utility functions for error handling
|
|
104
|
-
*
|
|
105
|
-
* This module provides helper functions for wrapping AWS SDK errors,
|
|
106
|
-
* extracting information from errors, and formatting error context.
|
|
107
|
-
*/
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* Checks if an error is a DynamoDB conditional check failure
|
|
111
|
-
*
|
|
112
|
-
* @param error - The error to check
|
|
113
|
-
* @returns true if the error is a conditional check failure
|
|
114
|
-
*/
|
|
115
|
-
declare function isConditionalCheckFailed(error: unknown): boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Checks if an error is a DynamoDB transaction cancellation
|
|
118
|
-
*
|
|
119
|
-
* @param error - The error to check
|
|
120
|
-
* @returns true if the error is a transaction cancellation
|
|
121
|
-
*/
|
|
122
|
-
declare function isTransactionCanceled(error: unknown): boolean;
|
|
123
|
-
/**
|
|
124
|
-
* Checks if an error is a DynamoDB validation exception
|
|
125
|
-
*
|
|
126
|
-
* @param error - The error to check
|
|
127
|
-
* @returns true if the error is a validation exception
|
|
128
|
-
*/
|
|
129
|
-
declare function isValidationException(error: unknown): boolean;
|
|
130
|
-
/**
|
|
131
|
-
* Checks if an error is a DynamoDB provisioned throughput exceeded exception
|
|
132
|
-
*
|
|
133
|
-
* @param error - The error to check
|
|
134
|
-
* @returns true if the error is a throughput exceeded exception
|
|
135
|
-
*/
|
|
136
|
-
declare function isProvisionedThroughputExceeded(error: unknown): boolean;
|
|
137
|
-
/**
|
|
138
|
-
* Checks if an error is a retryable error
|
|
139
|
-
*
|
|
140
|
-
* Retryable errors include:
|
|
141
|
-
* - ProvisionedThroughputExceededException
|
|
142
|
-
* - ThrottlingException
|
|
143
|
-
* - RequestLimitExceeded
|
|
144
|
-
* - InternalServerError
|
|
145
|
-
* - ServiceUnavailable
|
|
146
|
-
*
|
|
147
|
-
* @param error - The error to check
|
|
148
|
-
* @returns true if the error is retryable
|
|
149
|
-
*/
|
|
150
|
-
declare function isRetryableError(error: unknown): boolean;
|
|
151
|
-
/**
|
|
152
|
-
* Extracts the AWS error code from an error
|
|
153
|
-
*
|
|
154
|
-
* @param error - The error to extract the code from
|
|
155
|
-
* @returns The error code, or undefined if not found
|
|
156
|
-
*/
|
|
157
|
-
declare function getAwsErrorCode(error: unknown): string | undefined;
|
|
158
|
-
/**
|
|
159
|
-
* Extracts the AWS error message from an error
|
|
160
|
-
*
|
|
161
|
-
* @param error - The error to extract the message from
|
|
162
|
-
* @returns The error message, or undefined if not found
|
|
163
|
-
*/
|
|
164
|
-
declare function getAwsErrorMessage(error: unknown): string | undefined;
|
|
165
|
-
/**
|
|
166
|
-
* Attempts to extract required attribute names from an error message
|
|
167
|
-
*
|
|
168
|
-
* This is a best-effort function that looks for common patterns in error
|
|
169
|
-
* messages to identify which attributes are missing or required.
|
|
170
|
-
*
|
|
171
|
-
* @param error - The error to extract attributes from
|
|
172
|
-
* @returns Array of attribute names, or undefined if none found
|
|
173
|
-
*/
|
|
174
|
-
declare function extractRequiredAttributes(error: unknown): string[] | undefined;
|
|
175
|
-
/**
|
|
176
|
-
* Formats error context for logging
|
|
177
|
-
*
|
|
178
|
-
* Converts the error context object to a readable string format,
|
|
179
|
-
* handling special types like arrays and nested objects.
|
|
180
|
-
*
|
|
181
|
-
* @param context - The error context to format
|
|
182
|
-
* @param indent - The indentation level (for nested objects)
|
|
183
|
-
* @returns Formatted context string
|
|
184
|
-
*/
|
|
185
|
-
declare function formatErrorContext(context: Record<string, unknown>, indent?: number): string;
|
|
186
|
-
/**
|
|
187
|
-
* Creates a detailed error summary including context
|
|
188
|
-
*
|
|
189
|
-
* Useful for logging or displaying error information to developers.
|
|
190
|
-
*
|
|
191
|
-
* @param error - The DynoTableError to summarize
|
|
192
|
-
* @returns Formatted error summary
|
|
193
|
-
*/
|
|
194
|
-
declare function getErrorSummary(error: DynoTableError): string;
|
|
195
|
-
/**
|
|
196
|
-
* Type guard to check if an error is a DynoTableError
|
|
197
|
-
*
|
|
198
|
-
* @param error - The error to check
|
|
199
|
-
* @returns true if the error is a DynoTableError
|
|
200
|
-
*/
|
|
201
|
-
declare function isDynoTableError(error: unknown): error is DynoTableError;
|
|
202
|
-
/**
|
|
203
|
-
* Type guard to check if an error is a ValidationError
|
|
204
|
-
*
|
|
205
|
-
* @param error - The error to check
|
|
206
|
-
* @returns true if the error is a ValidationError
|
|
207
|
-
*/
|
|
208
|
-
declare function isValidationError(error: unknown): error is ValidationError;
|
|
209
|
-
/**
|
|
210
|
-
* Type guard to check if an error is an OperationError
|
|
211
|
-
*
|
|
212
|
-
* @param error - The error to check
|
|
213
|
-
* @returns true if the error is an OperationError
|
|
214
|
-
*/
|
|
215
|
-
declare function isOperationError(error: unknown): error is OperationError;
|
|
216
|
-
/**
|
|
217
|
-
* Type guard to check if an error is a TransactionError
|
|
218
|
-
*
|
|
219
|
-
* @param error - The error to check
|
|
220
|
-
* @returns true if the error is a TransactionError
|
|
221
|
-
*/
|
|
222
|
-
declare function isTransactionError(error: unknown): error is TransactionError;
|
|
223
|
-
/**
|
|
224
|
-
* Type guard to check if an error is a BatchError
|
|
225
|
-
*
|
|
226
|
-
* @param error - The error to check
|
|
227
|
-
* @returns true if the error is a BatchError
|
|
228
|
-
*/
|
|
229
|
-
declare function isBatchError(error: unknown): error is BatchError;
|
|
230
|
-
/**
|
|
231
|
-
* Type guard to check if an error is an ExpressionError
|
|
232
|
-
*
|
|
233
|
-
* @param error - The error to check
|
|
234
|
-
* @returns true if the error is an ExpressionError
|
|
235
|
-
*/
|
|
236
|
-
declare function isExpressionError(error: unknown): error is ExpressionError;
|
|
237
|
-
/**
|
|
238
|
-
* Type guard to check if an error is a ConfigurationError
|
|
239
|
-
*
|
|
240
|
-
* @param error - The error to check
|
|
241
|
-
* @returns true if the error is a ConfigurationError
|
|
242
|
-
*/
|
|
243
|
-
declare function isConfigurationError(error: unknown): error is ConfigurationError;
|
|
244
|
-
/**
|
|
245
|
-
* Type guard to check if an error is an EntityError
|
|
246
|
-
*
|
|
247
|
-
* @param error - The error to check
|
|
248
|
-
* @returns true if the error is an EntityError
|
|
249
|
-
*/
|
|
250
|
-
declare function isEntityError(error: unknown): error is EntityError;
|
|
251
|
-
/**
|
|
252
|
-
* Type guard to check if an error is a KeyGenerationError
|
|
253
|
-
*
|
|
254
|
-
* @param error - The error to check
|
|
255
|
-
* @returns true if the error is a KeyGenerationError
|
|
256
|
-
*/
|
|
257
|
-
declare function isKeyGenerationError(error: unknown): error is KeyGenerationError;
|
|
258
|
-
/**
|
|
259
|
-
* Type guard to check if an error is an IndexGenerationError
|
|
260
|
-
*
|
|
261
|
-
* @param error - The error to check
|
|
262
|
-
* @returns true if the error is an IndexGenerationError
|
|
263
|
-
*/
|
|
264
|
-
declare function isIndexGenerationError(error: unknown): error is IndexGenerationError;
|
|
265
|
-
/**
|
|
266
|
-
* Type guard to check if an error is an EntityValidationError
|
|
267
|
-
*
|
|
268
|
-
* @param error - The error to check
|
|
269
|
-
* @returns true if the error is an EntityValidationError
|
|
270
|
-
*/
|
|
271
|
-
declare function isEntityValidationError(error: unknown): error is EntityValidationError;
|
|
272
|
-
|
|
273
|
-
export { BatchError, BatchErrors, ConfigurationError, ConfigurationErrors, DynoTableError, EntityError, EntityErrors, EntityValidationError, ExpressionError, ExpressionErrors, IndexErrors, IndexGenerationError, KeyGenerationError, OperationError, OperationErrors, TransactionError, TransactionErrors, ValidationError, ValidationErrors, extractRequiredAttributes, formatErrorContext, getAwsErrorCode, getAwsErrorMessage, getErrorSummary, isBatchError, isConditionalCheckFailed, isConfigurationError, isDynoTableError, isEntityError, isEntityValidationError, isExpressionError, isIndexGenerationError, isKeyGenerationError, isOperationError, isProvisionedThroughputExceeded, isRetryableError, isTransactionCanceled, isTransactionError, isValidationError, isValidationException };
|
|
1
|
+
export { BatchBuilder, type BatchResult } from "./builders/batch-builder";
|
|
2
|
+
export { DeleteBuilder, type DeleteOptions } from "./builders/delete-builder";
|
|
3
|
+
export { PutBuilder, type PutOptions } from "./builders/put-builder";
|
|
4
|
+
export { QueryBuilder, type QueryOptions } from "./builders/query-builder";
|
|
5
|
+
export { TransactionBuilder, type TransactionOptions } from "./builders/transaction-builder";
|
|
6
|
+
export { UpdateBuilder, type UpdateOptions } from "./builders/update-builder";
|
|
7
|
+
export type { ComparisonOperator, Condition, ConditionOperator, ExpressionParams, KeyConditionOperator, LogicalOperator, PrimaryKey, PrimaryKeyWithoutExpression, } from "./conditions";
|
|
8
|
+
export { and, attributeExists, attributeNotExists, beginsWith, between, contains, eq, gt, gte, inArray, lt, lte, ne, not, or, } from "./conditions";
|
|
9
|
+
export type { EntityConfig, EntityDefinition, EntityDeleteBuilder, EntityGetBuilder, EntityPutBuilder, EntityRepository, EntityUpdateBuilder, IndexDefinition, QueryEntity, QueryRecord, } from "./entity/entity";
|
|
10
|
+
export { createIndex, createQueries, defineEntity } from "./entity/entity";
|
|
11
|
+
export * from "./errors";
|
|
12
|
+
export { Table } from "./table";
|
|
13
|
+
export { BatchErrors, ConfigurationErrors, EntityErrors, ExpressionErrors, IndexErrors, OperationErrors, TransactionErrors, ValidationErrors, } from "./utils/error-factory";
|
|
14
|
+
export * from "./utils/error-utils";
|
|
15
|
+
export { partitionKey } from "./utils/partition-key-template";
|
|
16
|
+
export { sortKey } from "./utils/sort-key-template";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { Table } from './chunk-42LH2UEM.js';
|
|
2
|
-
export { createIndex, createQueries, defineEntity, extractRequiredAttributes, formatErrorContext, getAwsErrorCode, getAwsErrorMessage, getErrorSummary, isBatchError, isConditionalCheckFailed, isConfigurationError, isDynoTableError, isEntityError, isEntityValidationError, isExpressionError, isIndexGenerationError, isKeyGenerationError, isOperationError, isProvisionedThroughputExceeded, isRetryableError, isTransactionCanceled, isTransactionError, isValidationError, isValidationException } from './chunk-
|
|
2
|
+
export { createIndex, createQueries, defineEntity, extractRequiredAttributes, formatErrorContext, getAwsErrorCode, getAwsErrorMessage, getErrorSummary, isBatchError, isConditionalCheckFailed, isConfigurationError, isDynoTableError, isEntityError, isEntityValidationError, isExpressionError, isIndexGenerationError, isKeyGenerationError, isOperationError, isProvisionedThroughputExceeded, isRetryableError, isTransactionCanceled, isTransactionError, isValidationError, isValidationException } from './chunk-JZB6TYST.js';
|
|
3
3
|
export { partitionKey, sortKey } from './chunk-QVRMYGC4.js';
|
|
4
4
|
export { BatchBuilder, DeleteBuilder, PutBuilder, QueryBuilder, TransactionBuilder, UpdateBuilder } from './chunk-NYJGW3XH.js';
|
|
5
5
|
export { BatchError, BatchErrors, ConfigurationError, ConfigurationErrors, DynoTableError, EntityError, EntityErrors, EntityValidationError, ErrorCodes, ExpressionError, ExpressionErrors, IndexErrors, IndexGenerationError, KeyGenerationError, OperationError, OperationErrors, TransactionError, TransactionErrors, ValidationError, ValidationErrors } from './chunk-FF7FYGDH.js';
|