dyno-table 2.5.1 → 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/{chunk-U6MQGB6Y.js → chunk-JZB6TYST.js} +133 -136
- package/dist/{chunk-ZXM6LPRV.cjs → chunk-Z334X72N.cjs} +133 -136
- 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/conditions.d.cts
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
export { C as ComparisonOperator, b as Condition, c as ConditionOperator, E as ExpressionParams, K as KeyConditionOperator, L as LogicalOperator, a as PrimaryKey, P as PrimaryKeyWithoutExpression, d as and, e as attributeExists, f as attributeNotExists, g as beginsWith, h as between, i as contains, u as createComparisonCondition, j as eq, k as gt, l as gte, m as inArray, n as lt, o as lte, p as ne, q as not, r as or } from './conditions-C8bM__Pn.cjs';
|
|
2
|
-
import './types.cjs';
|
|
3
|
-
import '@aws-sdk/lib-dynamodb';
|
package/dist/entity.d.cts
DELETED
|
@@ -1,261 +0,0 @@
|
|
|
1
|
-
import { s as Path, t as PathType, b as Condition, c as ConditionOperator, P as PrimaryKeyWithoutExpression, a as PrimaryKey } from './conditions-C8bM__Pn.cjs';
|
|
2
|
-
import { P as PutBuilder, G as GetBuilder, U as UpdateBuilder, p as UpdateCommandParams, T as TransactionBuilder, D as DeleteBuilder, S as ScanBuilder, Q as QueryBuilder } from './index-CPCmWsEv.cjs';
|
|
3
|
-
import { StandardSchemaV1 } from './standard-schema.cjs';
|
|
4
|
-
import { Table } from './table.cjs';
|
|
5
|
-
import { DynamoItem, Index, TableConfig } from './types.cjs';
|
|
6
|
-
import '@aws-sdk/lib-dynamodb';
|
|
7
|
-
|
|
8
|
-
type SetElementType<T> = T extends Set<infer U> ? U : T extends Array<infer U> ? U : never;
|
|
9
|
-
type PathSetElementType<T, K extends Path<T>> = SetElementType<PathType<T, K>>;
|
|
10
|
-
/**
|
|
11
|
-
* Entity-aware wrapper for PutBuilder that automatically provides entity name to batch operations
|
|
12
|
-
*/
|
|
13
|
-
type EntityAwarePutBuilder<T extends DynamoItem> = PutBuilder<T> & {
|
|
14
|
-
readonly entityName: string;
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Entity-aware wrapper for GetBuilder that automatically provides entity name to batch operations
|
|
18
|
-
*/
|
|
19
|
-
type EntityAwareGetBuilder<T extends DynamoItem> = GetBuilder<T> & {
|
|
20
|
-
readonly entityName: string;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Entity-aware wrapper for DeleteBuilder that automatically provides entity name to batch operations
|
|
24
|
-
*/
|
|
25
|
-
type EntityAwareDeleteBuilder = DeleteBuilder & {
|
|
26
|
-
readonly entityName: string;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Entity-aware wrapper for UpdateBuilder that adds forceIndexRebuild functionality
|
|
30
|
-
* and automatically provides entity name to batch operations
|
|
31
|
-
*/
|
|
32
|
-
declare class EntityAwareUpdateBuilder<T extends DynamoItem> {
|
|
33
|
-
private forceRebuildIndexes;
|
|
34
|
-
readonly entityName: string;
|
|
35
|
-
private builder;
|
|
36
|
-
private entityConfig?;
|
|
37
|
-
private updateDataApplied;
|
|
38
|
-
constructor(builder: UpdateBuilder<T>, entityName: string);
|
|
39
|
-
/**
|
|
40
|
-
* Configure entity-specific logic for automatic timestamp generation and index updates
|
|
41
|
-
*/
|
|
42
|
-
configureEntityLogic(config: {
|
|
43
|
-
data: Partial<T>;
|
|
44
|
-
key: T;
|
|
45
|
-
table: Table;
|
|
46
|
-
indexes: Record<string, IndexDefinition<T>> | undefined;
|
|
47
|
-
generateTimestamps: () => Record<string, string | number>;
|
|
48
|
-
buildIndexUpdates: (currentData: T, updates: Partial<T>, table: Table, indexes: Record<string, IndexDefinition<T>> | undefined, forceRebuildIndexes?: string[]) => Record<string, string>;
|
|
49
|
-
}): void;
|
|
50
|
-
/**
|
|
51
|
-
* Forces a rebuild of one or more readonly indexes during the update operation.
|
|
52
|
-
*
|
|
53
|
-
* By default, readonly indexes are not updated during entity updates to prevent
|
|
54
|
-
* errors when required index attributes are missing. This method allows you to
|
|
55
|
-
* override that behavior and force specific indexes to be rebuilt.
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```typescript
|
|
59
|
-
* // Force rebuild a single readonly index
|
|
60
|
-
* const result = await repo.update({ id: 'TREX-001' }, { status: 'ACTIVE' })
|
|
61
|
-
* .forceIndexRebuild('gsi1')
|
|
62
|
-
* .execute();
|
|
63
|
-
*
|
|
64
|
-
* // Force rebuild multiple readonly indexes
|
|
65
|
-
* const result = await repo.update({ id: 'TREX-001' }, { status: 'ACTIVE' })
|
|
66
|
-
* .forceIndexRebuild(['gsi1', 'gsi2'])
|
|
67
|
-
* .execute();
|
|
68
|
-
*
|
|
69
|
-
* // Chain with other update operations
|
|
70
|
-
* const result = await repo.update({ id: 'TREX-001' }, { status: 'ACTIVE' })
|
|
71
|
-
* .set('lastUpdated', new Date().toISOString())
|
|
72
|
-
* .forceIndexRebuild('gsi1')
|
|
73
|
-
* .condition(op => op.eq('status', 'INACTIVE'))
|
|
74
|
-
* .execute();
|
|
75
|
-
* ```
|
|
76
|
-
*
|
|
77
|
-
* @param indexes - A single index name or array of index names to force rebuild
|
|
78
|
-
* @returns The builder instance for method chaining
|
|
79
|
-
*/
|
|
80
|
-
forceIndexRebuild(indexes: string | string[]): this;
|
|
81
|
-
/**
|
|
82
|
-
* Gets the list of indexes that should be force rebuilt.
|
|
83
|
-
* This is used internally by entity update logic.
|
|
84
|
-
*
|
|
85
|
-
* @returns Array of index names to force rebuild
|
|
86
|
-
*/
|
|
87
|
-
getForceRebuildIndexes(): string[];
|
|
88
|
-
/**
|
|
89
|
-
* Apply entity-specific update data (timestamps and index updates)
|
|
90
|
-
* This is called automatically when needed
|
|
91
|
-
*/
|
|
92
|
-
private applyEntityUpdates;
|
|
93
|
-
set(values: Partial<T>): this;
|
|
94
|
-
set<K extends Path<T>>(path: K, value: PathType<T, K>): this;
|
|
95
|
-
remove<K extends Path<T>>(path: K): this;
|
|
96
|
-
add<K extends Path<T>>(path: K, value: PathType<T, K>): this;
|
|
97
|
-
deleteElementsFromSet<K extends Path<T>>(path: K, value: PathSetElementType<T, K>[] | Set<PathSetElementType<T, K>>): this;
|
|
98
|
-
condition(condition: Condition | ((op: ConditionOperator<T>) => Condition)): this;
|
|
99
|
-
returnValues(returnValues: "ALL_NEW" | "UPDATED_NEW" | "ALL_OLD" | "UPDATED_OLD" | "NONE"): this;
|
|
100
|
-
toDynamoCommand(): UpdateCommandParams;
|
|
101
|
-
withTransaction(transaction: TransactionBuilder): void;
|
|
102
|
-
debug(): ReturnType<UpdateBuilder<T>["debug"]>;
|
|
103
|
-
execute(): Promise<{
|
|
104
|
-
item?: T;
|
|
105
|
-
}>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
type QueryFunction<_T extends DynamoItem, I, R> = (input: I) => R;
|
|
109
|
-
type QueryFunctionWithSchema<T extends DynamoItem, I, R> = QueryFunction<T, I, R> & {
|
|
110
|
-
schema?: StandardSchemaV1<I>;
|
|
111
|
-
};
|
|
112
|
-
type QueryRecord<T extends DynamoItem> = {
|
|
113
|
-
[K: string]: QueryFunctionWithSchema<T, any, any>;
|
|
114
|
-
};
|
|
115
|
-
type MappedQueries<T extends DynamoItem, Q extends QueryRecord<T>> = {
|
|
116
|
-
[K in keyof Q]: Q[K] extends QueryFunctionWithSchema<T, infer I, infer R> ? (input: I) => R : never;
|
|
117
|
-
};
|
|
118
|
-
type QueryEntity<T extends DynamoItem> = {
|
|
119
|
-
scan: () => ScanBuilder<T>;
|
|
120
|
-
get: (key: PrimaryKeyWithoutExpression) => EntityAwareGetBuilder<T>;
|
|
121
|
-
query: (keyCondition: PrimaryKey) => QueryBuilder<T, TableConfig>;
|
|
122
|
-
};
|
|
123
|
-
interface Settings {
|
|
124
|
-
/**
|
|
125
|
-
* Defaults to "entityType"
|
|
126
|
-
*/
|
|
127
|
-
entityTypeAttributeName?: string;
|
|
128
|
-
timestamps?: {
|
|
129
|
-
createdAt?: {
|
|
130
|
-
/**
|
|
131
|
-
* ISO vs Unix trade-offs
|
|
132
|
-
*
|
|
133
|
-
* Both options support between, greater than and less than comparisons.
|
|
134
|
-
*
|
|
135
|
-
* ISO:
|
|
136
|
-
* - Human readable, but requires more storage space
|
|
137
|
-
* - Does not work with DynamoDBs TTL feature.
|
|
138
|
-
*
|
|
139
|
-
* UNIX:
|
|
140
|
-
* - Less readable, but requires less storage space.
|
|
141
|
-
* - Works with DynamoDBs TTL feature.
|
|
142
|
-
*/
|
|
143
|
-
format: "ISO" | "UNIX";
|
|
144
|
-
/**
|
|
145
|
-
* Defaults to "createdAt"
|
|
146
|
-
*/
|
|
147
|
-
attributeName?: string;
|
|
148
|
-
};
|
|
149
|
-
updatedAt?: {
|
|
150
|
-
/**
|
|
151
|
-
* ISO vs Unix trade-offs
|
|
152
|
-
*
|
|
153
|
-
* Both options support between, greater than and less than comparisons.
|
|
154
|
-
*
|
|
155
|
-
* ISO:
|
|
156
|
-
* - Human readable, but requires more storage space
|
|
157
|
-
* - Does not work with DynamoDBs TTL feature.
|
|
158
|
-
*
|
|
159
|
-
* UNIX:
|
|
160
|
-
* - Less readable, but requires less storage space.
|
|
161
|
-
* - Works with DynamoDBs TTL feature.
|
|
162
|
-
*/
|
|
163
|
-
format: "ISO" | "UNIX";
|
|
164
|
-
/**
|
|
165
|
-
* Defaults to "updatedAt"
|
|
166
|
-
*/
|
|
167
|
-
attributeName?: string;
|
|
168
|
-
};
|
|
169
|
-
};
|
|
170
|
-
}
|
|
171
|
-
interface EntityConfig<T extends DynamoItem, TInput extends DynamoItem = T, I extends DynamoItem = T, Q extends QueryRecord<T> = QueryRecord<T>> {
|
|
172
|
-
name: string;
|
|
173
|
-
schema: StandardSchemaV1<TInput, T>;
|
|
174
|
-
primaryKey: IndexDefinition<I>;
|
|
175
|
-
indexes?: Record<string, IndexDefinition<T>>;
|
|
176
|
-
queries: Q;
|
|
177
|
-
settings?: Settings;
|
|
178
|
-
}
|
|
179
|
-
interface EntityRepository<
|
|
180
|
-
/**
|
|
181
|
-
* The Entity Type (output type)
|
|
182
|
-
*/
|
|
183
|
-
T extends DynamoItem,
|
|
184
|
-
/**
|
|
185
|
-
* The Input Type (for create operations)
|
|
186
|
-
*/
|
|
187
|
-
TInput extends DynamoItem = T,
|
|
188
|
-
/**
|
|
189
|
-
* The Primary Index (Partition index) Type
|
|
190
|
-
*/
|
|
191
|
-
I extends DynamoItem = T,
|
|
192
|
-
/**
|
|
193
|
-
* The Queries object
|
|
194
|
-
*/
|
|
195
|
-
Q extends QueryRecord<T> = QueryRecord<T>> {
|
|
196
|
-
create: (data: TInput) => EntityAwarePutBuilder<T>;
|
|
197
|
-
upsert: (data: TInput & I) => EntityAwarePutBuilder<T>;
|
|
198
|
-
get: (key: I) => EntityAwareGetBuilder<T>;
|
|
199
|
-
update: (key: I, data: Partial<T>) => EntityAwareUpdateBuilder<T>;
|
|
200
|
-
delete: (key: I) => EntityAwareDeleteBuilder;
|
|
201
|
-
query: MappedQueries<T, Q>;
|
|
202
|
-
scan: () => ScanBuilder<T>;
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* Creates an entity definition with type-safe operations
|
|
206
|
-
*
|
|
207
|
-
* @example
|
|
208
|
-
* ```typescript
|
|
209
|
-
* interface User {
|
|
210
|
-
* id: string;
|
|
211
|
-
* name: string;
|
|
212
|
-
* }
|
|
213
|
-
*
|
|
214
|
-
* const UserEntity = defineEntity<User>({
|
|
215
|
-
* name: "User",
|
|
216
|
-
* schema: userSchema,
|
|
217
|
-
* primaryKey: primaryKey,
|
|
218
|
-
* });
|
|
219
|
-
* ```
|
|
220
|
-
*/
|
|
221
|
-
declare function defineEntity<T extends DynamoItem, TInput extends DynamoItem = T, I extends DynamoItem = T, Q extends QueryRecord<T> = QueryRecord<T>>(config: EntityConfig<T, TInput, I, Q>): {
|
|
222
|
-
name: string;
|
|
223
|
-
createRepository: (table: Table) => EntityRepository<T, TInput, I, Q>;
|
|
224
|
-
};
|
|
225
|
-
declare function createQueries<T extends DynamoItem>(): {
|
|
226
|
-
input: <I>(schema: StandardSchemaV1<I>) => {
|
|
227
|
-
query: <R extends ScanBuilder<T> | QueryBuilder<T, TableConfig> | GetBuilder<T>>(handler: (params: {
|
|
228
|
-
input: I;
|
|
229
|
-
entity: QueryEntity<T>;
|
|
230
|
-
}) => R) => QueryFunctionWithSchema<T, I, R>;
|
|
231
|
-
};
|
|
232
|
-
};
|
|
233
|
-
/**
|
|
234
|
-
* Defines a DynamoDB index configuration
|
|
235
|
-
*/
|
|
236
|
-
interface IndexDefinition<T extends DynamoItem> extends Index<T> {
|
|
237
|
-
/** The name of the index */
|
|
238
|
-
name: string;
|
|
239
|
-
/** Whether the index is read-only */
|
|
240
|
-
isReadOnly: boolean;
|
|
241
|
-
/** Function to generate the index key from an item */
|
|
242
|
-
generateKey: (item: T) => {
|
|
243
|
-
pk: string;
|
|
244
|
-
sk?: string;
|
|
245
|
-
};
|
|
246
|
-
}
|
|
247
|
-
declare function createIndex(): {
|
|
248
|
-
input: <T extends DynamoItem>(schema: StandardSchemaV1<T>) => {
|
|
249
|
-
partitionKey: <P extends (item: T) => string>(pkFn: P) => {
|
|
250
|
-
sortKey: <S extends (item: T) => string>(skFn: S) => IndexDefinition<T> & {
|
|
251
|
-
readOnly: (value?: boolean) => IndexDefinition<T>;
|
|
252
|
-
};
|
|
253
|
-
withoutSortKey: () => IndexDefinition<T> & {
|
|
254
|
-
readOnly: (value?: boolean) => IndexDefinition<T>;
|
|
255
|
-
};
|
|
256
|
-
};
|
|
257
|
-
readOnly: (value?: boolean) => /*elided*/ any;
|
|
258
|
-
};
|
|
259
|
-
};
|
|
260
|
-
|
|
261
|
-
export { type EntityConfig, type EntityRepository, type IndexDefinition, type MappedQueries, type QueryEntity, type QueryFunction, type QueryFunctionWithSchema, type QueryRecord, createIndex, createQueries, defineEntity };
|