@aurios/mizzle 1.1.1 → 1.1.3
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/.turbo/turbo-build.log +37 -0
- package/LICENSE +21 -0
- package/README.md +57 -0
- package/dist/chunk-AQVECMXP.js +1 -0
- package/dist/chunk-DU7UPWBW.js +1 -0
- package/dist/chunk-GPYZK4WY.js +1 -0
- package/dist/chunk-NPPZW6VT.js +1 -0
- package/dist/chunk-TOYV2M4M.js +1 -0
- package/dist/chunk-UM3YF5EC.js +1 -0
- package/dist/columns.d.ts +1 -0
- package/dist/columns.js +1 -0
- package/dist/db-zHIHBm1E.d.ts +815 -0
- package/dist/db.d.ts +3 -0
- package/dist/db.js +1 -0
- package/dist/diff.d.ts +18 -0
- package/dist/diff.js +1 -0
- package/dist/index.d.ts +42 -0
- package/dist/index.js +1 -0
- package/dist/introspection.d.ts +7 -0
- package/dist/introspection.js +1 -0
- package/dist/operators-BVreW0ky.d.ts +719 -0
- package/dist/snapshot.d.ts +24 -0
- package/dist/snapshot.js +1 -0
- package/dist/table.d.ts +1 -0
- package/dist/table.js +1 -0
- package/dist/transaction-RE7LXTGV.js +1 -0
- package/package.json +73 -24
- package/src/builders/base.ts +53 -56
- package/src/builders/batch-get.ts +63 -58
- package/src/builders/batch-write.ts +81 -78
- package/src/builders/delete.ts +46 -53
- package/src/builders/insert.ts +158 -150
- package/src/builders/query-promise.ts +26 -35
- package/src/builders/relational-builder.ts +214 -191
- package/src/builders/select.ts +250 -238
- package/src/builders/transaction.ts +170 -151
- package/src/builders/update.ts +198 -191
- package/src/columns/binary-set.ts +29 -38
- package/src/columns/binary.ts +25 -35
- package/src/columns/boolean.ts +25 -30
- package/src/columns/date.ts +57 -64
- package/src/columns/index.ts +15 -15
- package/src/columns/json.ts +39 -48
- package/src/columns/list.ts +26 -36
- package/src/columns/map.ts +26 -34
- package/src/columns/number-set.ts +29 -38
- package/src/columns/number.ts +33 -40
- package/src/columns/string-set.ts +38 -47
- package/src/columns/string.ts +37 -49
- package/src/columns/uuid.ts +26 -33
- package/src/core/client.ts +9 -9
- package/src/core/column-builder.ts +194 -220
- package/src/core/column.ts +127 -135
- package/src/core/diff.ts +40 -34
- package/src/core/errors.ts +20 -17
- package/src/core/introspection.ts +62 -58
- package/src/core/operations.ts +17 -23
- package/src/core/parser.ts +82 -88
- package/src/core/relations.ts +165 -152
- package/src/core/retry.ts +52 -52
- package/src/core/snapshot.ts +131 -130
- package/src/core/strategies.ts +222 -214
- package/src/core/table.ts +189 -202
- package/src/core/validation.ts +52 -52
- package/src/db.ts +216 -213
- package/src/expressions/actions.ts +26 -26
- package/src/expressions/builder.ts +62 -54
- package/src/expressions/operators.ts +48 -48
- package/src/expressions/update-builder.ts +79 -75
- package/src/index.ts +2 -1
- package/src/indexes.ts +8 -8
- package/test/batch-resilience.test.ts +138 -0
- package/test/builders/delete.test.ts +100 -0
- package/test/builders/insert.test.ts +216 -0
- package/test/builders/relational-types.test.ts +55 -0
- package/test/builders/relational.integration.test.ts +291 -0
- package/test/builders/relational.test.ts +66 -0
- package/test/builders/select.test.ts +411 -0
- package/test/builders/transaction-errors.test.ts +46 -0
- package/test/builders/transaction-execution.test.ts +99 -0
- package/test/builders/transaction-proxy.test.ts +41 -0
- package/test/builders/update-expression.test.ts +106 -0
- package/test/builders/update.test.ts +179 -0
- package/test/core/diff.test.ts +152 -0
- package/test/core/expressions.test.ts +64 -0
- package/test/core/introspection.test.ts +47 -0
- package/test/core/parser.test.ts +69 -0
- package/test/core/snapshot-gen.test.ts +155 -0
- package/test/core/snapshot.test.ts +52 -0
- package/test/date-column.test.ts +159 -0
- package/test/fluent-writes.integration.test.ts +148 -0
- package/test/integration-retry.test.ts +77 -0
- package/test/integration.test.ts +105 -0
- package/test/item-size-error.test.ts +16 -0
- package/test/item-size-validation.test.ts +82 -0
- package/test/item-size.test.ts +47 -0
- package/test/iterator-pagination.integration.test.ts +132 -0
- package/test/jsdoc-builders.test.ts +55 -0
- package/test/jsdoc-schema.test.ts +107 -0
- package/test/json-column.test.ts +51 -0
- package/test/metadata.test.ts +54 -0
- package/test/mizzle-package.test.ts +20 -0
- package/test/relational-centralized.test.ts +83 -0
- package/test/relational-definition.test.ts +75 -0
- package/test/relational-init.test.ts +30 -0
- package/test/relational-proxy.test.ts +52 -0
- package/test/relations.test.ts +45 -0
- package/test/resilience-config.test.ts +34 -0
- package/test/retry-handler.test.ts +63 -0
- package/test/transaction.integration.test.ts +153 -0
- package/test/unified-select.integration.test.ts +153 -0
- package/test/unified-update.integration.test.ts +139 -0
- package/test/update.integration.test.ts +132 -0
- package/tsconfig.json +12 -9
- package/tsup.config.ts +11 -11
- package/vitest.config.ts +8 -0
|
@@ -0,0 +1,719 @@
|
|
|
1
|
+
declare const INFER_MODE: {
|
|
2
|
+
readonly QUERY: "query";
|
|
3
|
+
readonly RAW: "raw";
|
|
4
|
+
};
|
|
5
|
+
declare const ORDER: {
|
|
6
|
+
readonly ASC: "asc";
|
|
7
|
+
readonly DESC: "desc";
|
|
8
|
+
};
|
|
9
|
+
declare const NULLS: {
|
|
10
|
+
readonly FIRST: "first";
|
|
11
|
+
readonly LAST: "last";
|
|
12
|
+
};
|
|
13
|
+
declare const TABLE_SYMBOLS: {
|
|
14
|
+
COLUMNS: symbol;
|
|
15
|
+
INDEXES: symbol;
|
|
16
|
+
SORT_KEY: symbol;
|
|
17
|
+
TABLE_NAME: symbol;
|
|
18
|
+
PARTITION_KEY: symbol;
|
|
19
|
+
};
|
|
20
|
+
declare const ENTITY_SYMBOLS: {
|
|
21
|
+
ENTITY_NAME: symbol;
|
|
22
|
+
ENTITY_STRATEGY: symbol;
|
|
23
|
+
PHYSICAL_TABLE: symbol;
|
|
24
|
+
COLUMNS: symbol;
|
|
25
|
+
ENTITY_KIND: symbol;
|
|
26
|
+
};
|
|
27
|
+
declare const RELATION_SYMBOLS: {
|
|
28
|
+
RELATION_CONFIG: symbol;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
type Assume<T, U> = T extends U ? T : U;
|
|
32
|
+
type Simplify<T> = {
|
|
33
|
+
[K in keyof T]: T[K];
|
|
34
|
+
} & {};
|
|
35
|
+
type Update<T, TUpdate> = {
|
|
36
|
+
[K in Exclude<keyof T, keyof TUpdate>]: T[K];
|
|
37
|
+
} & TUpdate;
|
|
38
|
+
declare function getEntityColumns<T extends {}>(entity: T): T[typeof ENTITY_SYMBOLS.COLUMNS];
|
|
39
|
+
declare function resolveTableName(entity: {}): string;
|
|
40
|
+
interface MinimalEntity {
|
|
41
|
+
}
|
|
42
|
+
declare function mapToLogical(entity: MinimalEntity, item: Record<string, unknown>): Record<string, unknown>;
|
|
43
|
+
interface ColumnType<TData = unknown, THasDefault extends boolean = boolean> {
|
|
44
|
+
_$data: TData;
|
|
45
|
+
_$hasDefault: THasDefault;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
type BinaryBuilderInitial<TName extends string> = BinaryColumnBuilder<{
|
|
49
|
+
name: TName;
|
|
50
|
+
dataType: "binary";
|
|
51
|
+
columnType: "B";
|
|
52
|
+
data: Buffer;
|
|
53
|
+
}>;
|
|
54
|
+
declare class BinaryColumnBuilder<T extends ColumnBuilderBaseConfig<"binary", "B">> extends ColumnBuider<T> {
|
|
55
|
+
constructor(name: T["name"]);
|
|
56
|
+
build<TTableName extends string>(table: AnyTable): BinaryColumn<MakeColumnConfig<T, TTableName>>;
|
|
57
|
+
}
|
|
58
|
+
declare class BinaryColumn<T extends ColumnBaseConfig<"binary", "B">> extends Column<T> {
|
|
59
|
+
}
|
|
60
|
+
declare function binary(): BinaryBuilderInitial<"">;
|
|
61
|
+
declare function binary<TName extends string>(name: TName): BinaryBuilderInitial<TName>;
|
|
62
|
+
|
|
63
|
+
type BinarySetColumnInitial<TName extends string> = BinarySetColumnBuilder<{
|
|
64
|
+
name: TName;
|
|
65
|
+
dataType: "binarySet";
|
|
66
|
+
columnType: "BS";
|
|
67
|
+
data: Set<Uint8Array>;
|
|
68
|
+
}>;
|
|
69
|
+
declare class BinarySetColumnBuilder<T extends ColumnBuilderBaseConfig<"binarySet", "BS">> extends ColumnBuider<T> {
|
|
70
|
+
constructor(name: T["name"]);
|
|
71
|
+
build<TTableName extends string>(table: AnyTable): BinarySetColumn<MakeColumnConfig<T, TTableName>>;
|
|
72
|
+
}
|
|
73
|
+
declare class BinarySetColumn<T extends ColumnBaseConfig<"binarySet", "BS">> extends Column<T> {
|
|
74
|
+
}
|
|
75
|
+
declare function binarySet(): BinarySetColumnInitial<"">;
|
|
76
|
+
declare function binarySet<TName extends string>(name: TName): BinarySetColumnInitial<TName>;
|
|
77
|
+
|
|
78
|
+
type BooleanColumnInitial<TName extends string> = BooleanColumnBuilder<{
|
|
79
|
+
name: TName;
|
|
80
|
+
dataType: "boolean";
|
|
81
|
+
columnType: "BOOL";
|
|
82
|
+
data: boolean;
|
|
83
|
+
}>;
|
|
84
|
+
declare class BooleanColumnBuilder<T extends ColumnBuilderBaseConfig<"boolean", "BOOL">> extends ColumnBuider<T> {
|
|
85
|
+
constructor(name: T["name"]);
|
|
86
|
+
build<TTableName extends string>(table: AnyTable): BooleanColumn<MakeColumnConfig<T, TTableName>>;
|
|
87
|
+
}
|
|
88
|
+
declare class BooleanColumn<T extends ColumnBaseConfig<"boolean", "BOOL">> extends Column<T> {
|
|
89
|
+
}
|
|
90
|
+
declare function boolean(): BooleanColumnInitial<"">;
|
|
91
|
+
declare function boolean<TName extends string>(name: TName): BooleanColumnInitial<TName>;
|
|
92
|
+
|
|
93
|
+
type DateColumnInitial<TName extends string> = DateColumnBuilder<{
|
|
94
|
+
name: TName;
|
|
95
|
+
dataType: "date";
|
|
96
|
+
columnType: "S";
|
|
97
|
+
data: Date;
|
|
98
|
+
}>;
|
|
99
|
+
declare class DateColumnBuilder<T extends ColumnBuilderBaseConfig<"date", "S">> extends ColumnBuider<T> {
|
|
100
|
+
constructor(name: T["name"]);
|
|
101
|
+
defaultNow(): HasRuntimeDefault<HasDefault<this>>;
|
|
102
|
+
onUpdateNow(): HasDefault<this>;
|
|
103
|
+
build<TTableName extends string>(table: AnyTable): DateColumn<MakeColumnConfig<T, TTableName>>;
|
|
104
|
+
}
|
|
105
|
+
declare class DateColumn<T extends ColumnBaseConfig<"date", "S">> extends Column<T> {
|
|
106
|
+
mapToDynamoValue(value: unknown): unknown;
|
|
107
|
+
mapFromDynamoValue(value: unknown): unknown;
|
|
108
|
+
}
|
|
109
|
+
declare function date(): DateColumnInitial<"">;
|
|
110
|
+
declare function date<TName extends string>(name: TName): DateColumnInitial<TName>;
|
|
111
|
+
|
|
112
|
+
type ListColumnInitial<TName extends string> = ListColumnBuilder<{
|
|
113
|
+
name: TName;
|
|
114
|
+
data: unknown[];
|
|
115
|
+
dataType: "array";
|
|
116
|
+
columnType: "L";
|
|
117
|
+
}>;
|
|
118
|
+
declare class ListColumnBuilder<T extends ColumnBuilderBaseConfig<"array", "L">> extends ColumnBuider<T> {
|
|
119
|
+
constructor(name: T["name"]);
|
|
120
|
+
build<TTableName extends string>(table: AnyTable): ListColumn<MakeColumnConfig<T, TTableName>>;
|
|
121
|
+
}
|
|
122
|
+
declare class ListColumn<T extends ColumnBaseConfig<"array", "L">> extends Column<T> {
|
|
123
|
+
}
|
|
124
|
+
declare function list(): ListColumnInitial<"">;
|
|
125
|
+
declare function list<TName extends string>(name: TName): ListColumnInitial<TName>;
|
|
126
|
+
|
|
127
|
+
type MapColumnInitial<TName extends string> = MapColumnBuilder<{
|
|
128
|
+
name: TName;
|
|
129
|
+
data: Record<string, unknown>;
|
|
130
|
+
dataType: "map";
|
|
131
|
+
columnType: "M";
|
|
132
|
+
}>;
|
|
133
|
+
declare class MapColumnBuilder<T extends ColumnBuilderBaseConfig<"map", "M">> extends ColumnBuider<T> {
|
|
134
|
+
constructor(name: T["name"]);
|
|
135
|
+
build<TTableName extends string>(table: AnyTable): MapColumn<MakeColumnConfig<T, TTableName>>;
|
|
136
|
+
}
|
|
137
|
+
declare class MapColumn<T extends ColumnBaseConfig<"map", "M">> extends Column<T> {
|
|
138
|
+
}
|
|
139
|
+
declare function map(): MapColumnInitial<"">;
|
|
140
|
+
declare function map<TName extends string>(name: TName): MapColumnInitial<TName>;
|
|
141
|
+
|
|
142
|
+
type NumberColumnInitial<TName extends string> = NumberColumnBuilder<{
|
|
143
|
+
name: TName;
|
|
144
|
+
dataType: "number";
|
|
145
|
+
columnType: "N";
|
|
146
|
+
data: number;
|
|
147
|
+
}>;
|
|
148
|
+
declare class NumberColumnBuilder<T extends ColumnBuilderBaseConfig<"number", "N">> extends ColumnBuider<T, {
|
|
149
|
+
validators?: {
|
|
150
|
+
min?: number;
|
|
151
|
+
max?: number;
|
|
152
|
+
};
|
|
153
|
+
}> {
|
|
154
|
+
constructor(name: T["name"]);
|
|
155
|
+
min(value: number): this;
|
|
156
|
+
max(value: number): this;
|
|
157
|
+
build<TTableName extends string>(table: AnyTable): NumberColumn<MakeColumnConfig<T, TTableName>>;
|
|
158
|
+
}
|
|
159
|
+
declare class NumberColumn<T extends ColumnBaseConfig<"number", "N">> extends Column<T> {
|
|
160
|
+
}
|
|
161
|
+
declare function number(): NumberColumnInitial<"">;
|
|
162
|
+
declare function number<TName extends string>(name: TName): NumberColumnInitial<TName>;
|
|
163
|
+
|
|
164
|
+
type NumberSetColumnInitial<TName extends string> = NumberSetColumnBuilder<{
|
|
165
|
+
name: TName;
|
|
166
|
+
data: Set<number>;
|
|
167
|
+
columnType: "NS";
|
|
168
|
+
dataType: "numberSet";
|
|
169
|
+
}>;
|
|
170
|
+
declare class NumberSetColumnBuilder<T extends ColumnBuilderBaseConfig<"numberSet", "NS">> extends ColumnBuider<T> {
|
|
171
|
+
constructor(name: T["name"]);
|
|
172
|
+
build<TTableName extends string>(table: AnyTable): NumberSetColumn<MakeColumnConfig<T, TTableName>>;
|
|
173
|
+
}
|
|
174
|
+
declare class NumberSetColumn<T extends ColumnBaseConfig<"numberSet", "NS">> extends Column<T> {
|
|
175
|
+
}
|
|
176
|
+
declare function numberSet(): NumberSetColumnInitial<"">;
|
|
177
|
+
declare function numberSet<TName extends string>(name: TName): NumberSetColumnInitial<TName>;
|
|
178
|
+
|
|
179
|
+
type StringColumnInitial<TName extends string> = StringColumnBuilder<{
|
|
180
|
+
name: TName;
|
|
181
|
+
dataType: "string";
|
|
182
|
+
columnType: "S";
|
|
183
|
+
data: string;
|
|
184
|
+
}>;
|
|
185
|
+
declare class StringColumnBuilder<T extends ColumnBuilderBaseConfig<"string", "S">> extends ColumnBuider<T, {
|
|
186
|
+
validators?: {
|
|
187
|
+
length?: number;
|
|
188
|
+
email?: boolean;
|
|
189
|
+
};
|
|
190
|
+
}> {
|
|
191
|
+
constructor(name: string);
|
|
192
|
+
length(value: number): this;
|
|
193
|
+
email(): this;
|
|
194
|
+
/** @internal */
|
|
195
|
+
build<TTableName extends string>(table: AnyTable): StringColumn<MakeColumnConfig<T, TTableName>>;
|
|
196
|
+
}
|
|
197
|
+
declare class StringColumn<T extends ColumnBaseConfig<"string", "S">> extends Column<T> {
|
|
198
|
+
}
|
|
199
|
+
declare function string(): StringColumnInitial<"">;
|
|
200
|
+
declare function string<TName extends string>(name: TName): StringColumnInitial<TName>;
|
|
201
|
+
|
|
202
|
+
type StringSetColumnInitial<TName extends string> = StringSetColumnBuilder<{
|
|
203
|
+
name: TName;
|
|
204
|
+
dataType: "string";
|
|
205
|
+
columnType: "SS";
|
|
206
|
+
data: Set<string>;
|
|
207
|
+
}>;
|
|
208
|
+
declare class StringSetColumnBuilder<T extends ColumnBuilderBaseConfig<"string", "SS">> extends ColumnBuider<T> {
|
|
209
|
+
constructor(name: string);
|
|
210
|
+
default(value: this["_"] extends {
|
|
211
|
+
$type: infer U;
|
|
212
|
+
} ? U : this["_"]["data"]): HasDefault<this>;
|
|
213
|
+
build<TTableName extends string>(table: AnyTable): StringSetColumn<MakeColumnConfig<T, TTableName>>;
|
|
214
|
+
}
|
|
215
|
+
declare class StringSetColumn<T extends ColumnBaseConfig<"string", "SS">> extends Column<T> {
|
|
216
|
+
}
|
|
217
|
+
declare function stringSet(): StringSetColumnInitial<"">;
|
|
218
|
+
declare function stringSet<TName extends string>(name: TName): StringSetColumnInitial<TName>;
|
|
219
|
+
|
|
220
|
+
type UUIDColumnInitial<TName extends string> = UUIDColumnBuilder<{
|
|
221
|
+
name: TName;
|
|
222
|
+
dataType: "string";
|
|
223
|
+
columnType: "S";
|
|
224
|
+
data: string;
|
|
225
|
+
}>;
|
|
226
|
+
declare class UUIDColumnBuilder<T extends ColumnBuilderBaseConfig<"string", "S">> extends ColumnBuider<T> {
|
|
227
|
+
constructor(name: string);
|
|
228
|
+
/** @internal */
|
|
229
|
+
build<TTableName extends string>(table: AnyTable): UUIDColumn<MakeColumnConfig<T, TTableName>>;
|
|
230
|
+
}
|
|
231
|
+
declare class UUIDColumn<T extends ColumnBaseConfig<"string", "S">> extends Column<T> {
|
|
232
|
+
}
|
|
233
|
+
declare function uuid(): UUIDColumnInitial<"">;
|
|
234
|
+
declare function uuid<TName extends string>(name: TName): UUIDColumnInitial<TName>;
|
|
235
|
+
|
|
236
|
+
type JsonColumnInitial<TName extends string> = JsonColumnBuilder<{
|
|
237
|
+
name: TName;
|
|
238
|
+
dataType: "json";
|
|
239
|
+
columnType: "S";
|
|
240
|
+
data: unknown;
|
|
241
|
+
}>;
|
|
242
|
+
declare class JsonColumnBuilder<T extends ColumnBuilderBaseConfig<"json", "S">> extends ColumnBuider<T> {
|
|
243
|
+
constructor(name: T["name"]);
|
|
244
|
+
build<TTableName extends string>(table: AnyTable): JsonColumn<MakeColumnConfig<T, TTableName>>;
|
|
245
|
+
}
|
|
246
|
+
declare class JsonColumn<T extends ColumnBaseConfig<"json", "S">> extends Column<T> {
|
|
247
|
+
mapToDynamoValue(value: T["data"]): string;
|
|
248
|
+
mapFromDynamoValue(value: T["data"] | string): T["data"];
|
|
249
|
+
}
|
|
250
|
+
declare function json(): JsonColumnInitial<"">;
|
|
251
|
+
declare function json<TName extends string>(name: TName): JsonColumnInitial<TName>;
|
|
252
|
+
|
|
253
|
+
declare function getColumnBuilders(): {
|
|
254
|
+
binary: typeof binary;
|
|
255
|
+
binarySet: typeof binarySet;
|
|
256
|
+
boolean: typeof boolean;
|
|
257
|
+
date: typeof date;
|
|
258
|
+
json: typeof json;
|
|
259
|
+
list: typeof list;
|
|
260
|
+
map: typeof map;
|
|
261
|
+
number: typeof number;
|
|
262
|
+
numberSet: typeof numberSet;
|
|
263
|
+
string: typeof string;
|
|
264
|
+
stringSet: typeof stringSet;
|
|
265
|
+
uuid: typeof uuid;
|
|
266
|
+
};
|
|
267
|
+
type ColumnsBuilder = ReturnType<typeof getColumnBuilders>;
|
|
268
|
+
|
|
269
|
+
interface IndexColumnConfig {
|
|
270
|
+
pk?: string;
|
|
271
|
+
sk?: string;
|
|
272
|
+
}
|
|
273
|
+
declare class IndexBuilder {
|
|
274
|
+
type: "gsi" | "lsi";
|
|
275
|
+
config: IndexColumnConfig;
|
|
276
|
+
constructor(type: "gsi" | "lsi", config: IndexColumnConfig);
|
|
277
|
+
}
|
|
278
|
+
declare function gsi(pkColumn: string, skColumn?: string): IndexBuilder;
|
|
279
|
+
declare function lsi(skColumn: string): IndexBuilder;
|
|
280
|
+
|
|
281
|
+
type RequiredKeyOnly<TKey extends string, T extends Column, TInferMode extends "select" | "insert" = "select"> = TInferMode extends "select" ? never : T extends AnyColumn<{
|
|
282
|
+
hasDefault: false;
|
|
283
|
+
notNull: true;
|
|
284
|
+
}> ? TKey : never;
|
|
285
|
+
type OpitionalKeyOnly<TKey extends string, T extends Column, TInferMode extends "select" | "insert" = "select"> = TKey extends RequiredKeyOnly<TKey, T, TInferMode> ? never : TKey;
|
|
286
|
+
type SelectedFieldsFlat<TColumn extends Column> = Record<string, TColumn>;
|
|
287
|
+
type SelectedFields<TColumn extends Column, TTable extends PhysicalTable> = Record<string, SelectedFieldsFlat<TColumn>[string] | TTable | SelectedFieldsFlat<TColumn>>;
|
|
288
|
+
|
|
289
|
+
type KeyStrategyType = "static" | "prefix" | "composite";
|
|
290
|
+
interface KeyStrategy {
|
|
291
|
+
type: KeyStrategyType;
|
|
292
|
+
segments: (string | Column)[];
|
|
293
|
+
separator?: string;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* SK = "METADATA"
|
|
297
|
+
*/
|
|
298
|
+
declare function staticKey(value: string): KeyStrategy;
|
|
299
|
+
/**
|
|
300
|
+
* PK = "USER#" + id
|
|
301
|
+
*/
|
|
302
|
+
declare function prefixKey(prefix: string, column: Column): KeyStrategy;
|
|
303
|
+
/**
|
|
304
|
+
* SK = "ORDER#" + date + "#STATUS#" + status
|
|
305
|
+
*/
|
|
306
|
+
declare function compositeKey(separator: string, ...segments: (string | Column)[]): KeyStrategy;
|
|
307
|
+
interface StrategyResolution {
|
|
308
|
+
keys: Record<string, unknown>;
|
|
309
|
+
hasPartitionKey: boolean;
|
|
310
|
+
hasSortKey: boolean;
|
|
311
|
+
indexName?: string;
|
|
312
|
+
}
|
|
313
|
+
declare function resolveStrategies(entity: Entity, whereClause?: Expression, providedValues?: Record<string, unknown>, forcedIndexName?: string): StrategyResolution;
|
|
314
|
+
|
|
315
|
+
type IndexStrategyConfig<TIndex extends IndexBuilder> = TIndex["type"] extends "lsi" ? {
|
|
316
|
+
sk: KeyStrategy | Column;
|
|
317
|
+
} : {
|
|
318
|
+
pk: KeyStrategy | Column;
|
|
319
|
+
sk?: KeyStrategy | Column;
|
|
320
|
+
};
|
|
321
|
+
type IndexesStrategy<TIndexes extends Record<string, IndexBuilder> | undefined> = TIndexes extends Record<string, IndexBuilder> ? {
|
|
322
|
+
[K in keyof TIndexes]?: IndexStrategyConfig<TIndexes[K]>;
|
|
323
|
+
} : object;
|
|
324
|
+
type StrategyCallback<TColumns extends Record<string, Column>, TPhysicalConfig extends PhysicalTableConfig> = (columns: TColumns) => {
|
|
325
|
+
[K in keyof TPhysicalConfig as K extends "pk" | "sk" ? K : never]: KeyStrategy | Column;
|
|
326
|
+
} & IndexesStrategy<TPhysicalConfig["indexes"]>;
|
|
327
|
+
interface EntityConfig<TColumn extends Column = Column> {
|
|
328
|
+
name: string;
|
|
329
|
+
table: PhysicalTable;
|
|
330
|
+
columns: Record<string, TColumn>;
|
|
331
|
+
}
|
|
332
|
+
interface PhysicalTableConfig {
|
|
333
|
+
pk: ColumnBuilderBase;
|
|
334
|
+
sk?: ColumnBuilderBase;
|
|
335
|
+
indexes?: Record<string, IndexBuilder>;
|
|
336
|
+
}
|
|
337
|
+
declare class PhysicalTable<T extends PhysicalTableConfig = PhysicalTableConfig> {
|
|
338
|
+
/** @internal */
|
|
339
|
+
[TABLE_SYMBOLS.TABLE_NAME]: string;
|
|
340
|
+
/** @internal */
|
|
341
|
+
[TABLE_SYMBOLS.INDEXES]: T["indexes"];
|
|
342
|
+
/** @internal */
|
|
343
|
+
[TABLE_SYMBOLS.PARTITION_KEY]: Column<ColumnBaseConfig<string, ColumnDataType>, object, object>;
|
|
344
|
+
/** @internal */
|
|
345
|
+
[TABLE_SYMBOLS.SORT_KEY]?: Column<ColumnBaseConfig<string, ColumnDataType>, object, object> | undefined;
|
|
346
|
+
readonly _: {
|
|
347
|
+
config: T;
|
|
348
|
+
name: string;
|
|
349
|
+
partitionKey: Column;
|
|
350
|
+
sortKey?: Column;
|
|
351
|
+
indexes: T["indexes"];
|
|
352
|
+
};
|
|
353
|
+
static readonly Symbol: {
|
|
354
|
+
COLUMNS: symbol;
|
|
355
|
+
INDEXES: symbol;
|
|
356
|
+
SORT_KEY: symbol;
|
|
357
|
+
TABLE_NAME: symbol;
|
|
358
|
+
PARTITION_KEY: symbol;
|
|
359
|
+
};
|
|
360
|
+
constructor(name: string, config: T);
|
|
361
|
+
}
|
|
362
|
+
declare class Entity<T extends EntityConfig = EntityConfig> {
|
|
363
|
+
/** @internal */
|
|
364
|
+
[ENTITY_SYMBOLS.ENTITY_NAME]: string;
|
|
365
|
+
/** @internal */
|
|
366
|
+
[ENTITY_SYMBOLS.PHYSICAL_TABLE]: T["table"];
|
|
367
|
+
/** @internal */
|
|
368
|
+
[ENTITY_SYMBOLS.COLUMNS]: T["columns"];
|
|
369
|
+
[ENTITY_SYMBOLS.ENTITY_STRATEGY]: Record<string, KeyStrategy>;
|
|
370
|
+
readonly _: {
|
|
371
|
+
readonly config: T;
|
|
372
|
+
readonly name: T["name"];
|
|
373
|
+
readonly table: T["table"];
|
|
374
|
+
readonly columns: T["columns"];
|
|
375
|
+
readonly strategies: Record<string, KeyStrategy>;
|
|
376
|
+
readonly inferSelect: InferSelectModel<Entity<T>>;
|
|
377
|
+
readonly inferInsert: InferInsertModel<Entity<T>>;
|
|
378
|
+
};
|
|
379
|
+
readonly $inferSelect: InferSelectModel<Entity<T>>;
|
|
380
|
+
readonly $inferInsert: InferInsertModel<Entity<T>>;
|
|
381
|
+
static readonly Symbol: {
|
|
382
|
+
ENTITY_NAME: symbol;
|
|
383
|
+
ENTITY_STRATEGY: symbol;
|
|
384
|
+
PHYSICAL_TABLE: symbol;
|
|
385
|
+
COLUMNS: symbol;
|
|
386
|
+
ENTITY_KIND: symbol;
|
|
387
|
+
};
|
|
388
|
+
constructor(name: T["name"], table: T["table"], columns: T["columns"], strategies: Record<string, KeyStrategy>);
|
|
389
|
+
}
|
|
390
|
+
type MapColumnName<TName extends string, TColumn extends Column, TDBColumnNames extends boolean> = TDBColumnNames extends true ? TColumn["_"]["name"] : TName;
|
|
391
|
+
type InferModelFromColumns<TColumns extends Record<string, Column>, TInferMode extends "select" | "insert" = "select", TConfig extends {
|
|
392
|
+
dbColumnNames: boolean;
|
|
393
|
+
override?: boolean;
|
|
394
|
+
} = {
|
|
395
|
+
dbColumnNames: false;
|
|
396
|
+
override: false;
|
|
397
|
+
}> = Simplify<{
|
|
398
|
+
[Key in keyof TColumns & string as RequiredKeyOnly<MapColumnName<Key, TColumns[Key], TConfig["dbColumnNames"]>, TColumns[Key], TInferMode>]: GetColumnData<TColumns[Key], typeof INFER_MODE.QUERY>;
|
|
399
|
+
} & {
|
|
400
|
+
[Key in keyof TColumns & string as OpitionalKeyOnly<MapColumnName<Key, TColumns[Key], TConfig["dbColumnNames"]>, TColumns[Key], TInferMode>]?: GetColumnData<TColumns[Key], typeof INFER_MODE.QUERY> | undefined;
|
|
401
|
+
}>;
|
|
402
|
+
type InferSelectModel<TTable extends Entity, TConfig extends {
|
|
403
|
+
dbColumnNames: boolean;
|
|
404
|
+
} = {
|
|
405
|
+
dbColumnNames: false;
|
|
406
|
+
}> = InferModelFromColumns<TTable["_"]["columns"], "select", TConfig>;
|
|
407
|
+
type InferInsertModel<TTable extends Entity, TConfig extends {
|
|
408
|
+
dbColumnNames: boolean;
|
|
409
|
+
override?: boolean;
|
|
410
|
+
} = {
|
|
411
|
+
dbColumnNames: false;
|
|
412
|
+
override: false;
|
|
413
|
+
}> = InferModelFromColumns<TTable["_"]["columns"], "insert", TConfig>;
|
|
414
|
+
type InferSelectedModel<TTable extends Entity, TConfig extends {
|
|
415
|
+
dbColumnNames: boolean;
|
|
416
|
+
} = {
|
|
417
|
+
dbColumnNames: false;
|
|
418
|
+
}> = InferSelectModel<TTable, TConfig>;
|
|
419
|
+
type TableDefinition<T extends EntityConfig = EntityConfig> = Entity<T> & {
|
|
420
|
+
columns: T["columns"];
|
|
421
|
+
};
|
|
422
|
+
type AtomicValues<T extends Entity> = Partial<InferInsertModel<T>>;
|
|
423
|
+
type EntityWithColumns<T extends EntityConfig> = Entity<T> & {
|
|
424
|
+
[Key in keyof T["columns"]]: T["columns"][Key];
|
|
425
|
+
};
|
|
426
|
+
type UpdateTableConfig<T extends PhysicalTableConfig, TUpdate extends Partial<PhysicalTableConfig>> = Required<Update<T, TUpdate>>;
|
|
427
|
+
type AnyTable<TPartial extends Partial<PhysicalTableConfig> = object> = PhysicalTable<UpdateTableConfig<PhysicalTableConfig, TPartial>>;
|
|
428
|
+
/**
|
|
429
|
+
* Defines a logical entity that maps to items within a DynamoDB table.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```ts
|
|
433
|
+
* const users = dynamoEntity(table, "users", {
|
|
434
|
+
* id: string("id"),
|
|
435
|
+
* name: string("name"),
|
|
436
|
+
* email: string("email"),
|
|
437
|
+
* });
|
|
438
|
+
* ```
|
|
439
|
+
*
|
|
440
|
+
* @param table The physical table definition this entity belongs to.
|
|
441
|
+
* @param name The unique name of the entity (used for typing and potentially in single-table design discriminators).
|
|
442
|
+
* @param columns A map of column definitions or a callback to define columns.
|
|
443
|
+
* @param strategies Optional configuration for key generation strategies (PK/SK construction).
|
|
444
|
+
* @returns The entity definition with strict typing.
|
|
445
|
+
*/
|
|
446
|
+
declare function dynamoEntity<TName extends string, TTable extends PhysicalTable, TColumnsMap extends Record<string, ColumnBuilderBase>>(table: TTable, name: TName, columns: TColumnsMap | ((columnsTypes: ColumnsBuilder) => TColumnsMap), strategies?: StrategyCallback<BuildColumns<TName, TColumnsMap>, TTable["_"]["config"]>): EntityWithColumns<{
|
|
447
|
+
name: TName;
|
|
448
|
+
table: TTable;
|
|
449
|
+
columns: BuildColumns<TName, TColumnsMap>;
|
|
450
|
+
}>;
|
|
451
|
+
/**
|
|
452
|
+
* Defines a physical DynamoDB table schema.
|
|
453
|
+
*
|
|
454
|
+
* @example
|
|
455
|
+
* ```ts
|
|
456
|
+
* const table = dynamoTable("my-app-table", {
|
|
457
|
+
* pk: string("pk"),
|
|
458
|
+
* sk: string("sk"),
|
|
459
|
+
* });
|
|
460
|
+
* ```
|
|
461
|
+
*
|
|
462
|
+
* @param name The actual name of the table in DynamoDB (or a reference name).
|
|
463
|
+
* @param config The table configuration, including primary key (pk) and sort key (sk) definitions.
|
|
464
|
+
* @returns A PhysicalTable instance representing the table schema.
|
|
465
|
+
*/
|
|
466
|
+
declare function dynamoTable<TTableName extends string, TConfig extends PhysicalTableConfig>(name: TTableName, config: TConfig): PhysicalTable<TConfig>;
|
|
467
|
+
|
|
468
|
+
type ColumnDataType = "S" | "N" | "BOOL" | "M" | "L" | "B" | "BS" | "NS" | "NULL" | "SS";
|
|
469
|
+
interface ColumnBuilderBaseConfig<TDataType extends string, TColumnDataType extends ColumnDataType> {
|
|
470
|
+
name: string;
|
|
471
|
+
dataType: TDataType;
|
|
472
|
+
columnType: TColumnDataType;
|
|
473
|
+
data: unknown;
|
|
474
|
+
}
|
|
475
|
+
type MakeColumnConfig<T extends ColumnBuilderBaseConfig<string, ColumnDataType>, TTableName extends string, TData = T extends {
|
|
476
|
+
$type: infer U;
|
|
477
|
+
} ? U : T["data"]> = {
|
|
478
|
+
name: T["name"];
|
|
479
|
+
tableName: TTableName;
|
|
480
|
+
dataType: T["dataType"];
|
|
481
|
+
columnType: T["columnType"];
|
|
482
|
+
data: TData;
|
|
483
|
+
notNull: T extends {
|
|
484
|
+
notNull: true;
|
|
485
|
+
} ? true : false;
|
|
486
|
+
hasDefault: T extends {
|
|
487
|
+
hasDefault: true;
|
|
488
|
+
} ? true : false;
|
|
489
|
+
hasRuntimeDefault: T extends {
|
|
490
|
+
hasRuntimeDefault: true;
|
|
491
|
+
} ? true : false;
|
|
492
|
+
isPartitionKey: T extends {
|
|
493
|
+
isPartitionKey: true;
|
|
494
|
+
} ? true : false;
|
|
495
|
+
isSortKey: T extends {
|
|
496
|
+
isSortKey: true;
|
|
497
|
+
} ? true : false;
|
|
498
|
+
} & object;
|
|
499
|
+
type ColumnBuilderRuntimeConfig<TData, TRuntimeConfig extends object = object> = {
|
|
500
|
+
name: string;
|
|
501
|
+
notNull: boolean;
|
|
502
|
+
default: TData;
|
|
503
|
+
dataType: string;
|
|
504
|
+
columnType: string;
|
|
505
|
+
isPartitionKey: boolean;
|
|
506
|
+
isSortKey: boolean;
|
|
507
|
+
hasDefault: boolean;
|
|
508
|
+
partitionKey: boolean;
|
|
509
|
+
sortKey: boolean;
|
|
510
|
+
defaultFn: () => TData | undefined;
|
|
511
|
+
onUpdateFn: () => TData | undefined;
|
|
512
|
+
} & TRuntimeConfig;
|
|
513
|
+
type ColumnBuilderTypeConfig<T extends ColumnBuilderBaseConfig<string, ColumnDataType>, TTypeConfig extends object = object> = Simplify<{
|
|
514
|
+
name: T["name"];
|
|
515
|
+
dataType: T["dataType"];
|
|
516
|
+
data: T["data"];
|
|
517
|
+
columnType: T["columnType"];
|
|
518
|
+
notNull: T extends {
|
|
519
|
+
notNull: infer U;
|
|
520
|
+
} ? U : boolean;
|
|
521
|
+
hasDefault: T extends {
|
|
522
|
+
hasDefault: infer U;
|
|
523
|
+
} ? U : boolean;
|
|
524
|
+
isPartitionKey: T extends {
|
|
525
|
+
isPartitionKey: infer U;
|
|
526
|
+
} ? U : boolean;
|
|
527
|
+
isSortKey: T extends {
|
|
528
|
+
isSortKey: infer U;
|
|
529
|
+
} ? U : boolean;
|
|
530
|
+
} & TTypeConfig>;
|
|
531
|
+
interface ColumnBuilderBase<T extends ColumnBuilderBaseConfig<string, ColumnDataType> = ColumnBuilderBaseConfig<string, ColumnDataType>, TTypeConfig extends object = object> {
|
|
532
|
+
_: ColumnBuilderTypeConfig<T, TTypeConfig>;
|
|
533
|
+
}
|
|
534
|
+
interface ColumnBuiderExtraConfig {
|
|
535
|
+
partitionKeyHasDefault?: boolean;
|
|
536
|
+
}
|
|
537
|
+
type NotNull<T extends ColumnBuilderBase> = T & {
|
|
538
|
+
_: {
|
|
539
|
+
notNull: true;
|
|
540
|
+
};
|
|
541
|
+
};
|
|
542
|
+
type HasDefault<T extends ColumnBuilderBase> = T & {
|
|
543
|
+
_: {
|
|
544
|
+
hasDefault: true;
|
|
545
|
+
};
|
|
546
|
+
};
|
|
547
|
+
type HasRuntimeDefault<T extends ColumnBuilderBase> = T & {
|
|
548
|
+
_: {
|
|
549
|
+
hasRuntimeDefault: true;
|
|
550
|
+
};
|
|
551
|
+
};
|
|
552
|
+
type IsPartitionKey<T extends ColumnBuilderBase> = T & {
|
|
553
|
+
_: {
|
|
554
|
+
isPartitionKey: true;
|
|
555
|
+
notNull: false;
|
|
556
|
+
};
|
|
557
|
+
};
|
|
558
|
+
type IsSortKey<T extends ColumnBuilderBase> = T & {
|
|
559
|
+
_: {
|
|
560
|
+
isSortKey: true;
|
|
561
|
+
notNull: false;
|
|
562
|
+
};
|
|
563
|
+
};
|
|
564
|
+
type $Type<T extends ColumnBuilderBase, TType> = T & {
|
|
565
|
+
_: {
|
|
566
|
+
$type: TType;
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
type BuildColumn<TTableName extends string, TBuilder extends ColumnBuilderBase> = Column<MakeColumnConfig<TBuilder["_"], TTableName>, object, Simplify<Omit<TBuilder["_"], keyof MakeColumnConfig<TBuilder["_"], TTableName>>>>;
|
|
570
|
+
type BuildColumns<TTableName extends string, TConfigMap extends Record<string, ColumnBuilderBase>> = Simplify<{
|
|
571
|
+
[Key in keyof TConfigMap]: BuildColumn<TTableName, {
|
|
572
|
+
_: Omit<TConfigMap[Key]["_"], "name"> & {
|
|
573
|
+
name: TConfigMap[Key]["_"]["name"] extends "" ? Assume<Key, string> : TConfigMap[Key]["_"]["name"];
|
|
574
|
+
};
|
|
575
|
+
}>;
|
|
576
|
+
}>;
|
|
577
|
+
declare abstract class ColumnBuider<T extends ColumnBuilderBaseConfig<string, ColumnDataType> = ColumnBuilderBaseConfig<string, ColumnDataType>, TRuntimeConfig extends object = object, TTypeConfig extends object = object, TExtraConfig extends ColumnBuiderExtraConfig = ColumnBuiderExtraConfig> implements ColumnBuilderBase<T, TTypeConfig> {
|
|
578
|
+
_: ColumnBuilderTypeConfig<T, TTypeConfig>;
|
|
579
|
+
config: ColumnBuilderRuntimeConfig<T["data"], TRuntimeConfig>;
|
|
580
|
+
constructor(name: T["name"], dataType: T["dataType"], columnType: T["columnType"]);
|
|
581
|
+
default(value: this["_"] extends {
|
|
582
|
+
$type: infer U;
|
|
583
|
+
} ? U : this["_"]["data"]): HasDefault<this>;
|
|
584
|
+
$defaultFn(fn: () => this["_"] extends {
|
|
585
|
+
$type: infer U;
|
|
586
|
+
} ? U : this["_"]["data"]): HasRuntimeDefault<HasDefault<this>>;
|
|
587
|
+
$onUpdateFn(fn: () => this["_"] extends {
|
|
588
|
+
$type: infer U;
|
|
589
|
+
} ? U : this["_"]["data"]): HasDefault<this>;
|
|
590
|
+
/**
|
|
591
|
+
* Change de data type of the column.
|
|
592
|
+
*
|
|
593
|
+
* ```ts
|
|
594
|
+
* const users = dynamoTable('users', {
|
|
595
|
+
* details: map().$type<UserDetails>().nullable()
|
|
596
|
+
* });
|
|
597
|
+
* ```
|
|
598
|
+
*/
|
|
599
|
+
$type<TType>(): $Type<this, TType>;
|
|
600
|
+
/** @internal */
|
|
601
|
+
getConfig(): ColumnBuilderRuntimeConfig<T["data"], TRuntimeConfig>;
|
|
602
|
+
partitionKey(): TExtraConfig["partitionKeyHasDefault"] extends true ? IsPartitionKey<HasDefault<NotNull<this>>> : IsPartitionKey<NotNull<this>>;
|
|
603
|
+
sortKey(): IsSortKey<this>;
|
|
604
|
+
/**
|
|
605
|
+
* Turns a column nullable.
|
|
606
|
+
*
|
|
607
|
+
* ```ts
|
|
608
|
+
* const users = dynamoTable('users', {
|
|
609
|
+
* name: string().nullable()
|
|
610
|
+
* });
|
|
611
|
+
* ```
|
|
612
|
+
*/
|
|
613
|
+
notNull(): NotNull<this>;
|
|
614
|
+
/** @internal */
|
|
615
|
+
setName(name: string): void;
|
|
616
|
+
/** @internal */
|
|
617
|
+
abstract build<TTableName extends string>(table: AnyTable): Column<MakeColumnConfig<T, TTableName>>;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
type AnyColumn<TPartial extends Partial<ColumnBaseConfig<string, ColumnDataType>> = Record<string, never>> = Column<Required<Update<ColumnBaseConfig<string, ColumnDataType>, TPartial>>>;
|
|
621
|
+
interface ColumnBaseConfig<TDataType extends string, TColumnType extends ColumnDataType> extends ColumnBuilderBaseConfig<TDataType, TColumnType> {
|
|
622
|
+
tableName: string;
|
|
623
|
+
name: string;
|
|
624
|
+
notNull: boolean;
|
|
625
|
+
hasDefault: boolean;
|
|
626
|
+
hasRuntimeDefault: boolean;
|
|
627
|
+
isPartitionKey: boolean;
|
|
628
|
+
isSortKey: boolean;
|
|
629
|
+
validators?: Record<string, unknown>;
|
|
630
|
+
}
|
|
631
|
+
type ColumnTypeConfig<T extends ColumnBaseConfig<string, ColumnDataType>, TTypeConfig extends object> = T & {
|
|
632
|
+
tableName: T["tableName"];
|
|
633
|
+
name: T["name"];
|
|
634
|
+
dataType: T["dataType"];
|
|
635
|
+
columnType: T["columnType"];
|
|
636
|
+
data: T["data"];
|
|
637
|
+
notNull: T["notNull"];
|
|
638
|
+
hasDefault: T["hasDefault"];
|
|
639
|
+
hasRuntimeDefault: T["hasRuntimeDefault"];
|
|
640
|
+
isPartitionKey: T["isPartitionKey"];
|
|
641
|
+
isSortKey: T["isSortKey"];
|
|
642
|
+
} & TTypeConfig;
|
|
643
|
+
type ColumnRuntimeConfig<TData, TRuntimeConfig extends object> = ColumnBuilderRuntimeConfig<TData, TRuntimeConfig>;
|
|
644
|
+
declare abstract class Column<T extends ColumnBaseConfig<string, ColumnDataType> = ColumnBaseConfig<string, ColumnDataType>, TRuntimeConfig extends object = object, TTypeConfig extends object = object> {
|
|
645
|
+
readonly table: PhysicalTable;
|
|
646
|
+
readonly _: ColumnTypeConfig<T, TTypeConfig>;
|
|
647
|
+
readonly name: string;
|
|
648
|
+
readonly primary: boolean;
|
|
649
|
+
readonly notNull: boolean;
|
|
650
|
+
readonly default: T["data"] | undefined;
|
|
651
|
+
readonly defaultFn: () => T["data"] | undefined;
|
|
652
|
+
readonly onUpdateFn: () => T["data"] | undefined;
|
|
653
|
+
readonly hasDefault: boolean;
|
|
654
|
+
readonly dataType: T["dataType"];
|
|
655
|
+
readonly columnType: T["columnType"];
|
|
656
|
+
protected config: ColumnRuntimeConfig<T["data"], TRuntimeConfig>;
|
|
657
|
+
constructor(table: PhysicalTable, config: ColumnRuntimeConfig<T["data"], TRuntimeConfig>);
|
|
658
|
+
getDynamoType(): string;
|
|
659
|
+
mapFromDynamoValue(value: unknown): unknown;
|
|
660
|
+
mapToDynamoValue(value: unknown): unknown;
|
|
661
|
+
}
|
|
662
|
+
type GetColumnData<TColumn extends Column, TInferMode extends "query" | "raw" = "query"> = TInferMode extends typeof INFER_MODE.RAW ? TColumn["_"]["data"] : TColumn["_"]["notNull"] extends false ? TColumn["_"]["data"] : TColumn["_"]["data"] | null;
|
|
663
|
+
|
|
664
|
+
type BinaryOperators = "=" | "<" | "<=" | ">=" | ">" | "between" | "in";
|
|
665
|
+
type LogicalOperators = "AND" | "OR";
|
|
666
|
+
type FunctionOperators = "begins_with" | "contains" | "attribute_exists";
|
|
667
|
+
declare abstract class Expression {
|
|
668
|
+
abstract readonly type: "binary" | "logical" | "function";
|
|
669
|
+
}
|
|
670
|
+
declare class BinaryExpression extends Expression {
|
|
671
|
+
readonly column: Column;
|
|
672
|
+
readonly operator: BinaryOperators;
|
|
673
|
+
readonly value: unknown;
|
|
674
|
+
readonly type = "binary";
|
|
675
|
+
constructor(column: Column, operator: BinaryOperators, value: unknown);
|
|
676
|
+
}
|
|
677
|
+
declare class LogicalExpression extends Expression {
|
|
678
|
+
readonly conditions: Expression[];
|
|
679
|
+
readonly operator: LogicalOperators;
|
|
680
|
+
readonly type = "logical";
|
|
681
|
+
constructor(conditions: Expression[], operator: LogicalOperators);
|
|
682
|
+
}
|
|
683
|
+
declare class FunctionExpression extends Expression {
|
|
684
|
+
readonly column: Column;
|
|
685
|
+
readonly operator: FunctionOperators;
|
|
686
|
+
readonly value: unknown;
|
|
687
|
+
readonly type = "function";
|
|
688
|
+
constructor(column: Column, operator: FunctionOperators, value: unknown);
|
|
689
|
+
}
|
|
690
|
+
declare function eq(column: Column, value: unknown): BinaryExpression;
|
|
691
|
+
declare function gt(column: Column, value: unknown): BinaryExpression;
|
|
692
|
+
declare function gte(column: Column, value: unknown): BinaryExpression;
|
|
693
|
+
declare function lt(column: Column, value: unknown): BinaryExpression;
|
|
694
|
+
declare function lte(column: Column, value: unknown): BinaryExpression;
|
|
695
|
+
declare function between(column: Column, values: [unknown, unknown]): BinaryExpression;
|
|
696
|
+
declare function inList(column: Column, values: unknown[]): BinaryExpression;
|
|
697
|
+
declare function beginsWith(column: Column, value: string): FunctionExpression;
|
|
698
|
+
declare function contains(column: Column, value: unknown): FunctionExpression;
|
|
699
|
+
declare function attributeExists(column: Column): FunctionExpression;
|
|
700
|
+
declare function or(...conditions: Expression[]): LogicalExpression;
|
|
701
|
+
declare function and(...conditions: Expression[]): LogicalExpression;
|
|
702
|
+
declare const operators: {
|
|
703
|
+
eq: typeof eq;
|
|
704
|
+
gt: typeof gt;
|
|
705
|
+
gte: typeof gte;
|
|
706
|
+
lt: typeof lt;
|
|
707
|
+
lte: typeof lte;
|
|
708
|
+
between: typeof between;
|
|
709
|
+
in: typeof inList;
|
|
710
|
+
and: typeof and;
|
|
711
|
+
or: typeof or;
|
|
712
|
+
contains: typeof contains;
|
|
713
|
+
beginsWith: typeof beginsWith;
|
|
714
|
+
attributeExists: typeof attributeExists;
|
|
715
|
+
};
|
|
716
|
+
type Operators = typeof operators;
|
|
717
|
+
type Condition = Expression;
|
|
718
|
+
|
|
719
|
+
export { gt as $, type AnyTable as A, BinaryExpression as B, type ColumnType as C, binarySet as D, Expression as E, FunctionExpression as F, boolean as G, compositeKey as H, INFER_MODE as I, contains as J, type KeyStrategy as K, LogicalExpression as L, type MapColumnName as M, NULLS as N, ORDER as O, PhysicalTable as P, date as Q, RELATION_SYMBOLS as R, type Simplify as S, TABLE_SYMBOLS as T, type Update as U, dynamoEntity as V, dynamoTable as W, eq as X, getColumnBuilders as Y, getEntityColumns as Z, gsi as _, type Assume as a, gte as a0, inList as a1, json as a2, list as a3, lsi as a4, lt as a5, lte as a6, map as a7, mapToLogical as a8, number as a9, numberSet as aa, operators as ab, or as ac, prefixKey as ad, resolveStrategies as ae, resolveTableName as af, staticKey as ag, string as ah, stringSet as ai, uuid as aj, Column as ak, type ColumnBaseConfig as al, type ColumnDataType as am, type AnyColumn as an, type OpitionalKeyOnly as ao, type SelectedFields as ap, type AtomicValues as b, type ColumnsBuilder as c, type Condition as d, ENTITY_SYMBOLS as e, Entity as f, type EntityConfig as g, type EntityWithColumns as h, IndexBuilder as i, type IndexColumnConfig as j, type InferInsertModel as k, type InferModelFromColumns as l, type InferSelectModel as m, type InferSelectedModel as n, type KeyStrategyType as o, type Operators as p, type PhysicalTableConfig as q, type StrategyCallback as r, type StrategyResolution as s, type TableDefinition as t, type UpdateTableConfig as u, and as v, attributeExists as w, beginsWith as x, between as y, binary as z };
|