dyna-record 0.5.3 → 0.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/README.md +198 -7
- package/dist/src/DynaRecord.d.ts +72 -61
- package/dist/src/DynaRecord.d.ts.map +1 -1
- package/dist/src/DynaRecord.js +7 -2
- package/dist/src/decorators/Entity.d.ts +12 -6
- package/dist/src/decorators/Entity.d.ts.map +1 -1
- package/dist/src/decorators/Entity.js +9 -5
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/operations/Query/types.d.ts +305 -10
- package/dist/src/operations/Query/types.d.ts.map +1 -1
- package/dist/src/operations/types.d.ts +43 -0
- package/dist/src/operations/types.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.js +4 -0
- package/dist/src/types.d.ts +10 -1
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@ Note: ACID compliant according to DynamoDB [limitations](https://docs.aws.amazon
|
|
|
21
21
|
- [FindById](#findbyid)
|
|
22
22
|
- [Query](#query)
|
|
23
23
|
- [Filtering on Object Attributes](#filtering-on-object-attributes)
|
|
24
|
+
- [Typed Query Filters](#typed-query-filters)
|
|
24
25
|
- [Update](#update)
|
|
25
26
|
- [Updating Object Attributes](#updating-object-attributes)
|
|
26
27
|
- [Delete](#delete)
|
|
@@ -111,13 +112,15 @@ abstract class MyTable extends DynaRecord {
|
|
|
111
112
|
|
|
112
113
|
Each entity must extend the Table class. To support single table design patterns, they must extend the same tables class.
|
|
113
114
|
|
|
115
|
+
Each entity **must** declare its `type` property as a string literal matching the class name. This enables compile-time type safety for query filters and return types. Omitting this declaration will produce a compile error at the `@Entity` decorator.
|
|
116
|
+
|
|
114
117
|
By default, each entity will have [default attributes](https://dyna-record.com/types/_internal_.DefaultFields.html)
|
|
115
118
|
|
|
116
119
|
- The partition key defined on the [table](#table) class
|
|
117
120
|
- The sort key defined on the [table](#table) class
|
|
118
121
|
- [id](https://dyna-record.com/classes/default.html#id) - The id for the model. This will be an autogenerated uuid unless [IdAttribute](<(https://dyna-record.com/functions/IdAttribute.html)>) is set on a non-nullable entity attribute.
|
|
119
|
-
- [type](https://dyna-record.com/classes/default.html#type) - The type of the entity. Value is the entity class name
|
|
120
|
-
- [createdAt](https://dyna-record.com/classes/default.html#
|
|
122
|
+
- [type](https://dyna-record.com/classes/default.html#type) - The type of the entity. Value is the entity class name. Must be declared as a string literal via `declare readonly type: "ClassName"`.
|
|
123
|
+
- [createdAt](https://dyna-record.com/classes/default.html#createdAt) - The timestamp of when the entity was created
|
|
121
124
|
- [updatedAt](https://dyna-record.com/classes/default.html#updatedAt) - Timestamp of when the entity was updated last
|
|
122
125
|
|
|
123
126
|
```typescript
|
|
@@ -125,15 +128,19 @@ import { Entity } from "dyna-record";
|
|
|
125
128
|
|
|
126
129
|
@Entity
|
|
127
130
|
class Student extends MyTable {
|
|
131
|
+
declare readonly type: "Student";
|
|
128
132
|
// ...
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
@Entity
|
|
132
136
|
class Course extends MyTable {
|
|
133
|
-
|
|
137
|
+
declare readonly type: "Course";
|
|
138
|
+
// ...
|
|
134
139
|
}
|
|
135
140
|
```
|
|
136
141
|
|
|
142
|
+
> **Note:** `declare readonly type` is a pure TypeScript type annotation with zero runtime impact. The ORM sets `type` to the class name automatically. The declaration simply tells TypeScript the exact literal type, enabling typed query filters and return type narrowing.
|
|
143
|
+
|
|
137
144
|
### Attributes
|
|
138
145
|
|
|
139
146
|
Use the attribute decorators below to define attributes on a model. The decorator maps class properties to DynamoDB table attributes.
|
|
@@ -157,6 +164,8 @@ import { Entity, Attribute } from "dyna-record";
|
|
|
157
164
|
|
|
158
165
|
@Entity
|
|
159
166
|
class Student extends MyTable {
|
|
167
|
+
declare readonly type: "Student";
|
|
168
|
+
|
|
160
169
|
@StringAttribute({ alias: "Username" }) // Sets alias if field in Dynamo is different then on the model
|
|
161
170
|
public username: string;
|
|
162
171
|
|
|
@@ -196,6 +205,8 @@ const addressSchema = {
|
|
|
196
205
|
|
|
197
206
|
@Entity
|
|
198
207
|
class Store extends MyTable {
|
|
208
|
+
declare readonly type: "Store";
|
|
209
|
+
|
|
199
210
|
@ObjectAttribute({ alias: "Address", schema: addressSchema })
|
|
200
211
|
public readonly address: InferObjectSchema<typeof addressSchema>;
|
|
201
212
|
}
|
|
@@ -259,6 +270,8 @@ import {
|
|
|
259
270
|
|
|
260
271
|
@Entity
|
|
261
272
|
class Assignment extends MyTable {
|
|
273
|
+
declare readonly type: "Assignment";
|
|
274
|
+
|
|
262
275
|
@ForeignKeyAttribute(() => Course)
|
|
263
276
|
public readonly courseId: ForeignKey<Course>;
|
|
264
277
|
|
|
@@ -268,6 +281,8 @@ class Assignment extends MyTable {
|
|
|
268
281
|
|
|
269
282
|
@Entity
|
|
270
283
|
class Course extends MyTable {
|
|
284
|
+
declare readonly type: "Course";
|
|
285
|
+
|
|
271
286
|
@ForeignKeyAttribute(() => Teacher, { nullable: true })
|
|
272
287
|
public readonly teacherId?: NullableForeignKey<Teacher>; // Set as optional
|
|
273
288
|
|
|
@@ -300,6 +315,8 @@ import {
|
|
|
300
315
|
|
|
301
316
|
@Entity
|
|
302
317
|
class Assignment extends MyTable {
|
|
318
|
+
declare readonly type: "Assignment";
|
|
319
|
+
|
|
303
320
|
// 'assignmentId' must be defined on associated model
|
|
304
321
|
@HasOne(() => Grade, { foreignKey: "assignmentId" })
|
|
305
322
|
public readonly grade: Grade;
|
|
@@ -307,6 +324,8 @@ class Assignment extends MyTable {
|
|
|
307
324
|
|
|
308
325
|
@Entity
|
|
309
326
|
class Grade extends MyTable {
|
|
327
|
+
declare readonly type: "Grade";
|
|
328
|
+
|
|
310
329
|
@ForeignKeyAttribute(() => Assignment)
|
|
311
330
|
public readonly assignmentId: ForeignKey<Assignment>;
|
|
312
331
|
|
|
@@ -325,6 +344,8 @@ import { Entity, NullableForeignKey, BelongsTo, HasMany } from "dyna-record";
|
|
|
325
344
|
|
|
326
345
|
@Entity
|
|
327
346
|
class Teacher extends MyTable {
|
|
347
|
+
declare readonly type: "Teacher";
|
|
348
|
+
|
|
328
349
|
// 'teacherId' must be defined on associated model
|
|
329
350
|
@HasMany(() => Course, { foreignKey: "teacherId" })
|
|
330
351
|
public readonly courses: Course[];
|
|
@@ -332,6 +353,8 @@ class Teacher extends MyTable {
|
|
|
332
353
|
|
|
333
354
|
@Entity
|
|
334
355
|
class Course extends MyTable {
|
|
356
|
+
declare readonly type: "Course";
|
|
357
|
+
|
|
335
358
|
@ForeignKeyAttribute(() => Teacher, { nullable: true })
|
|
336
359
|
public readonly teacherId?: NullableForeignKey<Teacher>; // Mark as optional
|
|
337
360
|
|
|
@@ -350,6 +373,8 @@ import { Entity, NullableForeignKey, BelongsTo, HasMany } from "dyna-record";
|
|
|
350
373
|
|
|
351
374
|
@Entity
|
|
352
375
|
class Teacher extends MyTable {
|
|
376
|
+
declare readonly type: "Teacher";
|
|
377
|
+
|
|
353
378
|
// 'teacherId' must be defined on associated model
|
|
354
379
|
@HasMany(() => Course, { foreignKey: "teacherId", uniDirectional: true })
|
|
355
380
|
public readonly courses: Course[];
|
|
@@ -357,6 +382,8 @@ class Teacher extends MyTable {
|
|
|
357
382
|
|
|
358
383
|
@Entity
|
|
359
384
|
class Course extends MyTable {
|
|
385
|
+
declare readonly type: "Course";
|
|
386
|
+
|
|
360
387
|
@ForeignKeyAttribute(() => Teacher, { nullable: true })
|
|
361
388
|
public readonly teacherId?: NullableForeignKey<Teacher>; // Mark as optional
|
|
362
389
|
}
|
|
@@ -383,6 +410,8 @@ class StudentCourse extends JoinTable<Student, Course> {
|
|
|
383
410
|
|
|
384
411
|
@Entity
|
|
385
412
|
class Course extends MyTable {
|
|
413
|
+
declare readonly type: "Course";
|
|
414
|
+
|
|
386
415
|
@HasAndBelongsToMany(() => Student, {
|
|
387
416
|
targetKey: "courses",
|
|
388
417
|
through: () => ({ joinTable: StudentCourse, foreignKey: "courseId" })
|
|
@@ -392,6 +421,8 @@ class Course extends MyTable {
|
|
|
392
421
|
|
|
393
422
|
@Entity
|
|
394
423
|
class Student extends OtherTable {
|
|
424
|
+
declare readonly type: "Student";
|
|
425
|
+
|
|
395
426
|
@HasAndBelongsToMany(() => Course, {
|
|
396
427
|
targetKey: "students",
|
|
397
428
|
through: () => ({ joinTable: StudentCourse, foreignKey: "studentId" })
|
|
@@ -528,7 +559,7 @@ const result = await Customer.query("123", {
|
|
|
528
559
|
|
|
529
560
|
##### Query by primary key
|
|
530
561
|
|
|
531
|
-
To be more precise to the underlying data, you can specify the partition key and sort key directly. The keys here will be the partition and sort keys defined on the [table](#table) class.
|
|
562
|
+
To be more precise to the underlying data, you can specify the partition key and sort key directly. The keys here will be the partition and sort keys defined on the [table](#table) class. The `sk` value is typed to only accept valid entity names from the partition.
|
|
532
563
|
|
|
533
564
|
```typescript
|
|
534
565
|
const orders = await Customer.query({
|
|
@@ -556,9 +587,8 @@ const result = await Course.query(
|
|
|
556
587
|
updatedAt: { $beginsWith: "2023-02-15" }
|
|
557
588
|
},
|
|
558
589
|
{
|
|
559
|
-
type:
|
|
560
|
-
createdAt: { $beginsWith: "2021-09-15T" }
|
|
561
|
-
type: "Assignment"
|
|
590
|
+
type: "Assignment",
|
|
591
|
+
createdAt: { $beginsWith: "2021-09-15T" }
|
|
562
592
|
},
|
|
563
593
|
{
|
|
564
594
|
id: "123"
|
|
@@ -632,6 +662,163 @@ const result = await Store.query("123", {
|
|
|
632
662
|
});
|
|
633
663
|
```
|
|
634
664
|
|
|
665
|
+
#### Typed Query Filters
|
|
666
|
+
|
|
667
|
+
Query filters are strongly typed based on the entities in the queried partition. A partition includes the entity itself plus all entities reachable through its declared relationships (`@HasMany`, `@HasOne`, `@BelongsTo`, `@HasAndBelongsToMany`). For example, if `Customer` has `@HasMany(() => Order)` and `@HasOne(() => ContactInformation)`, then Customer's partition entities are `Customer`, `Order`, and `ContactInformation`.
|
|
668
|
+
|
|
669
|
+
The type system validates:
|
|
670
|
+
|
|
671
|
+
- **Filter attribute keys**: Only attributes that exist on the entity or its related entities are accepted. Relationship property names, partition keys, and sort keys are excluded.
|
|
672
|
+
- **`type` field values**: The `type` field only accepts entity names from the partition — the entity itself and its declared relationships. Entities from other tables or unrelated entities on the same table are rejected.
|
|
673
|
+
- **Sort key values**: Both `skCondition` and the `sk` property in key conditions only accept entity names from the partition. This matches dyna-record's single-table design where sort key values always start with an entity class name.
|
|
674
|
+
- **`type` narrowing in `$or`**: Each `$or` element is independently narrowed. When an `$or` block specifies `type: "Order"`, only Order's attributes are allowed in that block.
|
|
675
|
+
- **Dot-path keys**: Nested `@ObjectAttribute` fields are available as typed filter keys using dot notation (e.g., `"address.city"`).
|
|
676
|
+
|
|
677
|
+
##### Filter key validation
|
|
678
|
+
|
|
679
|
+
```typescript
|
|
680
|
+
// Valid: 'name' exists on Customer, 'lastFour' on PaymentMethod
|
|
681
|
+
await Customer.query("123", {
|
|
682
|
+
filter: { name: "John", lastFour: "1234" }
|
|
683
|
+
});
|
|
684
|
+
|
|
685
|
+
// Error: 'nonExistent' is not an attribute on any entity in Customer's partition
|
|
686
|
+
await Customer.query("123", {
|
|
687
|
+
filter: { nonExistent: "value" } // Compile error
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
// Error: 'orders' is a relationship property, not a filterable attribute
|
|
691
|
+
await Customer.query("123", {
|
|
692
|
+
filter: { orders: "value" } // Compile error
|
|
693
|
+
});
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
##### Type field narrowing
|
|
697
|
+
|
|
698
|
+
```typescript
|
|
699
|
+
// Valid entity names only
|
|
700
|
+
await Customer.query("123", {
|
|
701
|
+
filter: { type: "Order" } // OK: "Order" is in Customer's partition
|
|
702
|
+
});
|
|
703
|
+
|
|
704
|
+
await Customer.query("123", {
|
|
705
|
+
filter: { type: "NonExistent" } // Compile error
|
|
706
|
+
});
|
|
707
|
+
|
|
708
|
+
// Array form (IN operator) accepts valid entity names
|
|
709
|
+
await Customer.query("123", {
|
|
710
|
+
filter: { type: ["Order", "PaymentMethod"] }
|
|
711
|
+
});
|
|
712
|
+
```
|
|
713
|
+
|
|
714
|
+
##### $or element narrowing
|
|
715
|
+
|
|
716
|
+
Each `$or` element narrows independently based on its own `type` value:
|
|
717
|
+
|
|
718
|
+
```typescript
|
|
719
|
+
await Customer.query("123", {
|
|
720
|
+
filter: {
|
|
721
|
+
$or: [
|
|
722
|
+
{ type: "Order", orderDate: "2023" }, // OK: orderDate is on Order
|
|
723
|
+
{ type: "PaymentMethod", lastFour: "1234" } // OK: lastFour is on PaymentMethod
|
|
724
|
+
]
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
// Error in $or: lastFour is not an attribute on Order
|
|
729
|
+
await Customer.query("123", {
|
|
730
|
+
filter: {
|
|
731
|
+
$or: [
|
|
732
|
+
{ type: "Order", lastFour: "1234" } // Compile error
|
|
733
|
+
]
|
|
734
|
+
}
|
|
735
|
+
});
|
|
736
|
+
```
|
|
737
|
+
|
|
738
|
+
##### Return type narrowing
|
|
739
|
+
|
|
740
|
+
When querying a partition with no filter or sort key condition, the return type is a union of the entity itself and all its related entities:
|
|
741
|
+
|
|
742
|
+
```typescript
|
|
743
|
+
// Return type: Array<EntityAttributesInstance<Customer> | EntityAttributesInstance<Order>
|
|
744
|
+
// | EntityAttributesInstance<PaymentMethod> | EntityAttributesInstance<ContactInformation>>
|
|
745
|
+
const results = await Customer.query("123");
|
|
746
|
+
```
|
|
747
|
+
|
|
748
|
+
When the filter specifies a `type` value, the return type automatically narrows to only the matching entities:
|
|
749
|
+
|
|
750
|
+
```typescript
|
|
751
|
+
// Return type: Array<EntityAttributesInstance<Order>>
|
|
752
|
+
const orders = await Customer.query("123", {
|
|
753
|
+
filter: { type: "Order" }
|
|
754
|
+
});
|
|
755
|
+
|
|
756
|
+
orders[0]?.orderDate; // OK: orderDate is accessible
|
|
757
|
+
|
|
758
|
+
// Return type: Array<EntityAttributesInstance<Order> | EntityAttributesInstance<PaymentMethod>>
|
|
759
|
+
const mixed = await Customer.query("123", {
|
|
760
|
+
filter: { type: ["Order", "PaymentMethod"] }
|
|
761
|
+
});
|
|
762
|
+
```
|
|
763
|
+
|
|
764
|
+
##### Sort key validation and narrowing
|
|
765
|
+
|
|
766
|
+
Sort key values are typed to only accept valid entity names from the partition, matching dyna-record's single-table design where SK values always start with an entity class name. This applies to both the `skCondition` option and the `sk` property in key conditions:
|
|
767
|
+
|
|
768
|
+
```typescript
|
|
769
|
+
// Both forms validate sort key values against partition entity names
|
|
770
|
+
|
|
771
|
+
// skCondition option (string form)
|
|
772
|
+
await Customer.query("123", { skCondition: "Order" }); // OK
|
|
773
|
+
await Customer.query("123", { skCondition: "Order#123" }); // OK
|
|
774
|
+
await Customer.query("123", { skCondition: { $beginsWith: "Order" } }); // OK
|
|
775
|
+
await Customer.query("123", { skCondition: "NonExistent" }); // Compile error
|
|
776
|
+
|
|
777
|
+
// sk property in key conditions (object form)
|
|
778
|
+
await Customer.query({ pk: "Customer#123", sk: "Order" }); // OK
|
|
779
|
+
await Customer.query({ pk: "Customer#123", sk: "Order#001" }); // OK
|
|
780
|
+
await Customer.query({ pk: "Customer#123", sk: { $beginsWith: "Order" } }); // OK
|
|
781
|
+
await Customer.query({ pk: "Customer#123", sk: "NonExistent" }); // Compile error
|
|
782
|
+
```
|
|
783
|
+
|
|
784
|
+
**Return type narrowing** works with `skCondition` when the value is an exact entity name or `$beginsWith` with an entity name:
|
|
785
|
+
|
|
786
|
+
```typescript
|
|
787
|
+
// skCondition narrows the return type
|
|
788
|
+
const orders = await Customer.query("123", { skCondition: "Order" });
|
|
789
|
+
// orders is Array<EntityAttributesInstance<Order>>
|
|
790
|
+
|
|
791
|
+
const orders2 = await Customer.query("123", {
|
|
792
|
+
skCondition: { $beginsWith: "Order" }
|
|
793
|
+
});
|
|
794
|
+
// orders2 is Array<EntityAttributesInstance<Order>>
|
|
795
|
+
|
|
796
|
+
// Suffix prevents narrowing (delimiter is configurable)
|
|
797
|
+
const specific = await Customer.query("123", { skCondition: "Order#123" });
|
|
798
|
+
// specific is QueryResults<Customer> (full union)
|
|
799
|
+
```
|
|
800
|
+
|
|
801
|
+
When using the object key form (`{ pk: "...", sk: "..." }`), sort key values are **validated** but the return type is **not narrowed**. Use `filter: { type: "Order" }` alongside key conditions for return type narrowing:
|
|
802
|
+
|
|
803
|
+
```typescript
|
|
804
|
+
// sk is validated but does NOT narrow the return type
|
|
805
|
+
const results = await Customer.query({ pk: "Customer#123", sk: "Order" });
|
|
806
|
+
// results is QueryResults<Customer> (full union)
|
|
807
|
+
|
|
808
|
+
// Combine with filter type for return type narrowing
|
|
809
|
+
const orders = await Customer.query(
|
|
810
|
+
{ pk: "Customer#123", sk: { $beginsWith: "Order" } },
|
|
811
|
+
{ filter: { type: "Order" } }
|
|
812
|
+
);
|
|
813
|
+
// orders is Array<EntityAttributesInstance<Order>>
|
|
814
|
+
```
|
|
815
|
+
|
|
816
|
+
> **Note:** Return type narrowing applies to the top-level `type` filter field, `type` values within `$or` elements, and to the `skCondition` option. When `$or` elements specify `type` values, the return type narrows to the union of those entity types. The `sk` property in key conditions validates values but does not narrow return types. Index queries (`{ indexName: "..." }`) use untyped filters.
|
|
817
|
+
>
|
|
818
|
+
> **Filter key narrowing:** When no `type` is specified, the return type automatically narrows based on which entities have the filtered attributes. For example, `filter: { orderDate: "2023" }` narrows to `Order` if only `Order` has `orderDate`. In `$or` blocks, each element narrows independently — by `type` if present, or by filter keys otherwise — and the return type is the union across all blocks.
|
|
819
|
+
>
|
|
820
|
+
> **AND intersection:** Since DynamoDB ANDs top-level filter conditions with `$or` blocks, the return type reflects this. When both top-level conditions and `$or` blocks independently narrow to specific entity sets, the return type is their intersection. If no entity satisfies both (e.g., `{ orderDate: "2023", $or: [{ lastFour: "1234" }] }` where `orderDate` is on `Order` and `lastFour` is on `PaymentMethod`), the return type is `never[]` — correctly indicating that no records can match.
|
|
821
|
+
|
|
635
822
|
### Querying on an index
|
|
636
823
|
|
|
637
824
|
For querying based on secondary indexes, you can specify the index name in the options.
|
|
@@ -821,9 +1008,13 @@ If deleting an entity or its relationships fails due to database constraints or
|
|
|
821
1008
|
|
|
822
1009
|
Dyna-Record integrates type safety into your DynamoDB interactions, reducing runtime errors and enhancing code quality.
|
|
823
1010
|
|
|
1011
|
+
- **Entity Type Declaration**: The `@Entity` decorator enforces that each entity declares `readonly type` as a string literal matching the class name (`declare readonly type: "MyEntity"`). This is required for compile-time query type safety.
|
|
824
1012
|
- **Attribute Type Enforcement**: Ensures that the data types of attributes match their definitions in your entities.
|
|
825
1013
|
- **Method Parameter Checking**: Validates method parameters against entity definitions, preventing invalid operations.
|
|
826
1014
|
- **Relationship Integrity**: Automatically manages the consistency of relationships between entities, ensuring data integrity.
|
|
1015
|
+
- **Typed Query Filters**: Query filter keys are validated against the attributes of entities in the partition. Invalid keys, relationship property names, and non-existent attributes produce compile errors. The `type` field only accepts valid entity class names.
|
|
1016
|
+
- **Return Type Narrowing**: When a query filter specifies a `type` value, the return type is automatically narrowed to only the matching entity types instead of the full partition union.
|
|
1017
|
+
- **`$or` Element Narrowing**: Each element in a `$or` filter array is independently type-checked based on its own `type` field, preventing attribute mismatches.
|
|
827
1018
|
|
|
828
1019
|
## Best Practices
|
|
829
1020
|
|
package/dist/src/DynaRecord.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type TableMetadata } from "./metadata";
|
|
2
|
-
import { type FindByIdOptions, type FindByIdIncludesRes, type EntityKeyConditions, type QueryResults, Create, type CreateOptions, type UpdateOptions, type EntityAttributesInstance, type IncludedAssociations, type IndexKeyConditions, type OptionsWithoutIndex, type OptionsWithIndex } from "./operations";
|
|
2
|
+
import { type FindByIdOptions, type FindByIdIncludesRes, type EntityKeyConditions, type QueryResults, Create, type CreateOptions, type UpdateOptions, type EntityAttributesInstance, type IncludedAssociations, type IndexKeyConditions, type OptionsWithoutIndex, type OptionsWithIndex, type TypedFilterParams, type TypedSortKeyCondition, type InferQueryResults } from "./operations";
|
|
3
3
|
import type { DynamoTableItem, EntityClass, Optional } from "./types";
|
|
4
4
|
interface DynaRecordBase {
|
|
5
5
|
id: string;
|
|
@@ -26,7 +26,8 @@ interface DynaRecordBase {
|
|
|
26
26
|
*
|
|
27
27
|
* @Entity
|
|
28
28
|
* class User extends MyTable {
|
|
29
|
-
*
|
|
29
|
+
* declare readonly type: "User";
|
|
30
|
+
* // User implementation
|
|
30
31
|
* }
|
|
31
32
|
* ```
|
|
32
33
|
*/
|
|
@@ -36,7 +37,11 @@ declare abstract class DynaRecord implements DynaRecordBase {
|
|
|
36
37
|
*/
|
|
37
38
|
readonly id: string;
|
|
38
39
|
/**
|
|
39
|
-
* The type of the
|
|
40
|
+
* The type of the entity. Set automatically to the class name at runtime.
|
|
41
|
+
*
|
|
42
|
+
* Each entity must narrow this field to a string literal matching the class name
|
|
43
|
+
* via `declare readonly type: "ClassName"`. This enables compile-time type safety
|
|
44
|
+
* for query filters and return type narrowing.
|
|
40
45
|
*/
|
|
41
46
|
readonly type: string;
|
|
42
47
|
/**
|
|
@@ -75,88 +80,94 @@ declare abstract class DynaRecord implements DynaRecordBase {
|
|
|
75
80
|
/**
|
|
76
81
|
* Query an EntityPartition by EntityId (string) or by PartitionKey/SortKey conditions (object).
|
|
77
82
|
* QueryByIndex not supported with this overload. Use Query with keys and indexName option if needed.
|
|
78
|
-
* @param {string | EntityKeyConditions<T>} key - Entity Id (string) or an object with PartitionKey and optional SortKey conditions.
|
|
79
|
-
* @param {Object=} options - QueryOptions. Supports filter, consistentRead and skCondition. indexName is not supported
|
|
80
83
|
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
84
|
+
* **Filter key validation:** Filter keys are strongly typed to only accept valid attribute
|
|
85
|
+
* names from the entity and its declared relationships (`@HasMany`, `@HasOne`, `@BelongsTo`,
|
|
86
|
+
* `@HasAndBelongsToMany`). The `type` field only accepts the entity itself or its related
|
|
87
|
+
* entity names — entities from other tables or unrelated entities are rejected.
|
|
88
|
+
* When `type` is specified as a single value in a `$or` block, filter keys are narrowed to
|
|
89
|
+
* that entity's attributes.
|
|
85
90
|
*
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
*
|
|
91
|
+
* **Sort key validation:** Both `skCondition` (string form) and `sk` (object key form) only
|
|
92
|
+
* accept the entity itself or its related entity names, matching dyna-record's single-table
|
|
93
|
+
* sort key format where SK values always start with an entity class name. Unrelated entities
|
|
94
|
+
* and entities from other tables are rejected at compile time.
|
|
90
95
|
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
96
|
+
* **Return type narrowing:** The return type narrows automatically based on:
|
|
97
|
+
* - Top-level filter `type`: `type: "Order"` → `Array<EntityAttributesInstance<Order>>`
|
|
98
|
+
* - Top-level filter `type` array: `type: ["Order", "PaymentMethod"]` → union of both
|
|
99
|
+
* - Top-level filter keys: `{ orderDate: "2023" }` → narrows to entities that have `orderDate`
|
|
100
|
+
* - `$or` elements: each block narrows by `type` (if present) or by filter keys; return type is the union
|
|
101
|
+
* - AND intersection: when top-level conditions and `$or` both narrow, the return type is their intersection. Empty intersection → `never[]`.
|
|
102
|
+
* - `skCondition` option: `skCondition: "Order"` or `skCondition: { $beginsWith: "Order" }` → narrows to Order
|
|
103
|
+
* - No type/keys/SK specified → union of T and all related entities (e.g., `Customer | Order | PaymentMethod | ContactInformation`)
|
|
95
104
|
*
|
|
96
|
-
*
|
|
105
|
+
* Note: When using the object key form (`{ pk: "...", sk: "Order" }`), the `sk` value is
|
|
106
|
+
* validated against entity names but does **not** narrow the return type due to a TypeScript
|
|
107
|
+
* inference limitation. Use `filter: { type: "Order" }` or the `skCondition` option for
|
|
108
|
+
* return type narrowing.
|
|
109
|
+
*
|
|
110
|
+
* @template T - The entity type being queried.
|
|
111
|
+
* @template F - The inferred filter type, captured via `const` generic for literal type inference.
|
|
112
|
+
* @template SK - The inferred sort key condition type, captured via `const` generic for literal type inference.
|
|
113
|
+
* @param {string | EntityKeyConditions<T>} key - Entity Id (string) or an object with PartitionKey and optional SortKey conditions.
|
|
114
|
+
* @param {Object=} options - QueryOptions. Supports typed filter, consistentRead and skCondition. indexName is not supported.
|
|
115
|
+
* @param {TypedFilterParams<T>=} options.filter - Typed filter conditions. Keys are validated against partition entity attributes. The `type` field accepts valid entity class names.
|
|
116
|
+
* @param {TypedSortKeyCondition<T>=} options.skCondition - Sort key condition. Only accepts valid entity names from the partition. Narrows the return type when matching an exact entity name.
|
|
117
|
+
* @returns A promise resolving to query results. The return type narrows based on the filter's `type` value or `skCondition`.
|
|
118
|
+
*
|
|
119
|
+
* @example By entity ID
|
|
97
120
|
* ```typescript
|
|
98
|
-
* const
|
|
99
|
-
* filter: {
|
|
100
|
-
* type: "Profile",
|
|
101
|
-
* createdAt: "2023-11-21T12:31:21.148Z"
|
|
102
|
-
* }
|
|
103
|
-
* });
|
|
121
|
+
* const results = await Customer.query("123");
|
|
104
122
|
* ```
|
|
105
123
|
*
|
|
106
|
-
* @example
|
|
124
|
+
* @example With skCondition (narrows return type to Order)
|
|
107
125
|
* ```typescript
|
|
108
|
-
* const
|
|
126
|
+
* const orders = await Customer.query("123", { skCondition: "Order" });
|
|
127
|
+
* // orders is Array<EntityAttributesInstance<Order>>
|
|
109
128
|
* ```
|
|
110
129
|
*
|
|
111
|
-
* @example
|
|
130
|
+
* @example With skCondition $beginsWith (narrows return type)
|
|
112
131
|
* ```typescript
|
|
113
|
-
* const
|
|
132
|
+
* const orders = await Customer.query("123", { skCondition: { $beginsWith: "Order" } });
|
|
133
|
+
* // orders is Array<EntityAttributesInstance<Order>>
|
|
114
134
|
* ```
|
|
115
135
|
*
|
|
116
|
-
* @example
|
|
136
|
+
* @example With typed filter (narrows return type)
|
|
117
137
|
* ```typescript
|
|
118
|
-
* const
|
|
138
|
+
* const orders = await Customer.query("123", {
|
|
139
|
+
* filter: { type: "Order", orderDate: "2023-01-01" }
|
|
140
|
+
* });
|
|
141
|
+
* // orders is Array<EntityAttributesInstance<Order>>
|
|
119
142
|
* ```
|
|
120
143
|
*
|
|
121
|
-
* @example By
|
|
144
|
+
* @example By primary key (sk validated, return type NOT narrowed)
|
|
122
145
|
* ```typescript
|
|
123
|
-
* const
|
|
146
|
+
* const results = await Customer.query({ pk: "Customer#123", sk: "Order" });
|
|
147
|
+
* // results is QueryResults<Customer> — use filter type for narrowing
|
|
124
148
|
* ```
|
|
125
149
|
*
|
|
126
|
-
* @example
|
|
150
|
+
* @example By primary key with filter type (narrows return type)
|
|
127
151
|
* ```typescript
|
|
128
|
-
* const
|
|
129
|
-
*
|
|
130
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* filter: {
|
|
134
|
-
* type: ["Profile", "Preferences"],
|
|
135
|
-
* createdAt: { $beginsWith: "2023" },
|
|
136
|
-
* $or: [
|
|
137
|
-
* {
|
|
138
|
-
* name: "John",
|
|
139
|
-
* email: { $beginsWith: "testing" }
|
|
140
|
-
* },
|
|
141
|
-
* {
|
|
142
|
-
* name: "Jane",
|
|
143
|
-
* updatedAt: { $beginsWith: "2024" },
|
|
144
|
-
* },
|
|
145
|
-
* {
|
|
146
|
-
* id: "123"
|
|
147
|
-
* }
|
|
148
|
-
* ]
|
|
149
|
-
* }
|
|
150
|
-
* }
|
|
151
|
-
*);
|
|
152
|
+
* const orders = await Customer.query(
|
|
153
|
+
* { pk: "Customer#123", sk: { $beginsWith: "Order" } },
|
|
154
|
+
* { filter: { type: "Order" } }
|
|
155
|
+
* );
|
|
156
|
+
* // orders is Array<EntityAttributesInstance<Order>>
|
|
152
157
|
* ```
|
|
153
158
|
*
|
|
154
|
-
* @example
|
|
159
|
+
* @example Query as consistent read
|
|
155
160
|
* ```typescript
|
|
156
|
-
* const
|
|
161
|
+
* const results = await Customer.query("123", { consistentRead: true });
|
|
157
162
|
* ```
|
|
158
163
|
*/
|
|
159
|
-
static query<T extends DynaRecord>(this: EntityClass<T>, key: string
|
|
164
|
+
static query<T extends DynaRecord, const F extends TypedFilterParams<T> = TypedFilterParams<T>, const SK extends TypedSortKeyCondition<T> = TypedSortKeyCondition<T>>(this: EntityClass<T>, key: string, options?: OptionsWithoutIndex<T> & {
|
|
165
|
+
filter?: F;
|
|
166
|
+
skCondition?: SK;
|
|
167
|
+
}): Promise<InferQueryResults<T, F, SK>>;
|
|
168
|
+
static query<T extends DynaRecord, const F extends TypedFilterParams<T> = TypedFilterParams<T>>(this: EntityClass<T>, key: EntityKeyConditions<T>, options?: Omit<OptionsWithoutIndex<T>, "skCondition"> & {
|
|
169
|
+
filter?: F;
|
|
170
|
+
}): Promise<InferQueryResults<T, F>>;
|
|
160
171
|
/**
|
|
161
172
|
* Query by PartitionKey and optional SortKey/Filter/Index conditions with an index
|
|
162
173
|
* When querying on an index, any of the entities attributes can be part of the key condition
|
|
@@ -167,7 +178,7 @@ declare abstract class DynaRecord implements DynaRecordBase {
|
|
|
167
178
|
* ```typescript
|
|
168
179
|
* const result = await User.query(
|
|
169
180
|
* {
|
|
170
|
-
* name: "SomeName" // An attribute that is part of the key condition on an
|
|
181
|
+
* name: "SomeName" // An attribute that is part of the key condition on an index
|
|
171
182
|
* },
|
|
172
183
|
* { indexName: "myIndex" }
|
|
173
184
|
* );
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynaRecord.d.ts","sourceRoot":"","sources":["../../src/DynaRecord.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAsB,KAAK,aAAa,EAAE,MAAM,YAAY,CAAC;AAE9E,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,mBAAmB,EAExB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,MAAM,EACN,KAAK,aAAa,EAElB,KAAK,aAAa,EAGlB,KAAK,wBAAwB,EAC7B,KAAK,oBAAoB,EACzB,KA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AC,CAAC,SAAS,UAAU,EAC7C,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC,EACpB,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,IAAI,CAAC;IAKhB;;;;;;;;;OASG;WACW,iBAAiB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM;IAKnD;;OAEG;WACW,iBAAiB,CAAC,CAAC,SAAS,UAAU,EAClD,IAAI,EAAE,UAAU,CAAC,EACjB,SAAS,EAAE,eAAe,GACzB,wBAAwB,CAAC,CAAC,CAAC;IAW9B;;;OAGG;IACI,iBAAiB,IAAI,MAAM;IAIlC;;;;;;;;;;;;OAYG;WACW,QAAQ,IAAI,UAAU,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;CAK9D;AAED,eAAe,UAAU,CAAC"}
|
package/dist/src/DynaRecord.js
CHANGED
|
@@ -91,7 +91,8 @@ const utils_2 = require("./utils");
|
|
|
91
91
|
*
|
|
92
92
|
* @Entity
|
|
93
93
|
* class User extends MyTable {
|
|
94
|
-
*
|
|
94
|
+
* declare readonly type: "User";
|
|
95
|
+
* // User implementation
|
|
95
96
|
* }
|
|
96
97
|
* ```
|
|
97
98
|
*/
|
|
@@ -126,7 +127,11 @@ let DynaRecord = (() => {
|
|
|
126
127
|
*/
|
|
127
128
|
id = __runInitializers(this, _id_initializers, void 0);
|
|
128
129
|
/**
|
|
129
|
-
* The type of the
|
|
130
|
+
* The type of the entity. Set automatically to the class name at runtime.
|
|
131
|
+
*
|
|
132
|
+
* Each entity must narrow this field to a string literal matching the class name
|
|
133
|
+
* via `declare readonly type: "ClassName"`. This enables compile-time type safety
|
|
134
|
+
* for query filters and return type narrowing.
|
|
130
135
|
*/
|
|
131
136
|
type = (__runInitializers(this, _id_extraInitializers), __runInitializers(this, _type_initializers, void 0));
|
|
132
137
|
/**
|
|
@@ -4,20 +4,26 @@ import type DynaRecord from "../DynaRecord";
|
|
|
4
4
|
*
|
|
5
5
|
* IMPORTANT - All entity classes should extend a table class decorated by {@link Table}
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* @
|
|
7
|
+
* Entities MUST declare their `type` property as a string literal matching the class name.
|
|
8
|
+
* This enables compile-time type safety for query filters and return types.
|
|
9
|
+
*
|
|
10
|
+
* @template C The constructor of the class being decorated. The class must extend `DynaRecord`
|
|
11
|
+
* and declare `readonly type` as a string literal (e.g., `declare readonly type: "Order"`).
|
|
12
|
+
* @param target The constructor function of the class being decorated.
|
|
13
|
+
* @param context The context in which the decorator is applied, provided by the TypeScript runtime.
|
|
14
|
+
* @returns {void} The decorator does not return a value.
|
|
11
15
|
*
|
|
12
16
|
* Usage example:
|
|
13
17
|
* ```typescript
|
|
14
18
|
* @Entity
|
|
15
19
|
* class User extends MyTable {
|
|
20
|
+
* declare readonly type: "User";
|
|
16
21
|
* // User entity implementation
|
|
17
22
|
* }
|
|
18
23
|
* ```
|
|
19
|
-
* In this example, the `User` class is marked as an entity using the `@Entity` decorator. This designation registers the `User` class within the ORM's metadata system, making it a recognized entity for the ORM to manage. The registration process involves associating the class with its corresponding table name and any additional metadata required by the ORM to handle instances of this class effectively.
|
|
20
24
|
*/
|
|
21
|
-
declare function Entity
|
|
25
|
+
declare function Entity<C extends abstract new (...args: never[]) => DynaRecord>(target: C & (string extends InstanceType<C>["type"] ? {
|
|
26
|
+
__entityTypeError: 'Entity must declare: declare readonly type: "ClassName"';
|
|
27
|
+
} : unknown), _context: ClassDecoratorContext<C>): void;
|
|
22
28
|
export default Entity;
|
|
23
29
|
//# sourceMappingURL=Entity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/decorators/Entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAE5C
|
|
1
|
+
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/decorators/Entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAE5C;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,MAAM,CAAC,CAAC,SAAS,QAAQ,MAAM,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,UAAU,EACrE,MAAM,EAAE,CAAC,GACP,CAAC,MAAM,SAAS,YAAY,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GACnC;IACE,iBAAiB,EAAE,yDAAyD,CAAC;CAC9E,GACD,OAAO,CAAC,EACd,QAAQ,EAAE,qBAAqB,CAAC,CAAC,CAAC,GACjC,IAAI,CAKN;AAED,eAAe,MAAM,CAAC"}
|
|
@@ -9,19 +9,23 @@ const metadata_1 = __importDefault(require("../metadata"));
|
|
|
9
9
|
*
|
|
10
10
|
* IMPORTANT - All entity classes should extend a table class decorated by {@link Table}
|
|
11
11
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* @
|
|
12
|
+
* Entities MUST declare their `type` property as a string literal matching the class name.
|
|
13
|
+
* This enables compile-time type safety for query filters and return types.
|
|
14
|
+
*
|
|
15
|
+
* @template C The constructor of the class being decorated. The class must extend `DynaRecord`
|
|
16
|
+
* and declare `readonly type` as a string literal (e.g., `declare readonly type: "Order"`).
|
|
17
|
+
* @param target The constructor function of the class being decorated.
|
|
18
|
+
* @param context The context in which the decorator is applied, provided by the TypeScript runtime.
|
|
19
|
+
* @returns {void} The decorator does not return a value.
|
|
16
20
|
*
|
|
17
21
|
* Usage example:
|
|
18
22
|
* ```typescript
|
|
19
23
|
* @Entity
|
|
20
24
|
* class User extends MyTable {
|
|
25
|
+
* declare readonly type: "User";
|
|
21
26
|
* // User entity implementation
|
|
22
27
|
* }
|
|
23
28
|
* ```
|
|
24
|
-
* In this example, the `User` class is marked as an entity using the `@Entity` decorator. This designation registers the `User` class within the ORM's metadata system, making it a recognized entity for the ORM to manage. The registration process involves associating the class with its corresponding table name and any additional metadata required by the ORM to handle instances of this class effectively.
|
|
25
29
|
*/
|
|
26
30
|
function Entity(target, _context) {
|
|
27
31
|
const tableClassName = Object.getPrototypeOf(target).name;
|
package/dist/src/index.d.ts
CHANGED
|
@@ -2,6 +2,6 @@ export * from "./decorators";
|
|
|
2
2
|
export * from "./errors";
|
|
3
3
|
export * from "./relationships";
|
|
4
4
|
export * from "./dynamo-utils/errors";
|
|
5
|
-
export type { EntityAttributesOnly, EntityAttributesInstance as EntityInstance, FindByIdIncludesRes } from "./operations";
|
|
5
|
+
export type { EntityAttributesOnly, EntityAttributesInstance as EntityInstance, FindByIdIncludesRes, TypedFilterParams, TypedSortKeyCondition, InferQueryResults, PartitionEntityNames } from "./operations";
|
|
6
6
|
export type { PartitionKey, SortKey, ForeignKey, NullableForeignKey } from "./types";
|
|
7
7
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAEtC,YAAY,EACV,oBAAoB,EACpB,wBAAwB,IAAI,cAAc,EAC1C,mBAAmB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,iBAAiB,CAAC;AAChC,cAAc,uBAAuB,CAAC;AAEtC,YAAY,EACV,oBAAoB,EACpB,wBAAwB,IAAI,cAAc,EAC1C,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,EACjB,oBAAoB,EACrB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,YAAY,EACZ,OAAO,EACP,UAAU,EACV,kBAAkB,EACnB,MAAM,SAAS,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type DynaRecord from "../../DynaRecord";
|
|
2
|
-
import type { KeyConditions as QueryKeyConditions, QueryOptions as QueryBuilderOptions,
|
|
3
|
-
import type { PartitionKey, SortKey } from "../../types";
|
|
4
|
-
import type { EntityAttributesInstance } from "../types";
|
|
2
|
+
import type { KeyConditions as QueryKeyConditions, QueryOptions as QueryBuilderOptions, FilterTypes, SortKeyCondition } from "../../query-utils";
|
|
3
|
+
import type { IsAny, PartitionKey, SortKey } from "../../types";
|
|
4
|
+
import type { EntityAttributesInstance, EntityFilterableKeys } from "../types";
|
|
5
5
|
/**
|
|
6
6
|
* Extends the basic query builder options by adding an optional sort key condition for more precise querying capabilities.
|
|
7
7
|
*
|
|
@@ -15,9 +15,25 @@ export type QueryOptions = QueryBuilderOptions & {
|
|
|
15
15
|
skCondition?: SortKeyCondition;
|
|
16
16
|
};
|
|
17
17
|
/**
|
|
18
|
-
* Options for querying without an index
|
|
18
|
+
* Options for querying without an index.
|
|
19
|
+
*
|
|
20
|
+
* Omits `indexName`, `filter`, and `skCondition` from {@link QueryOptions}.
|
|
21
|
+
* The `filter` property is re-declared using {@link TypedFilterParams} for compile-time
|
|
22
|
+
* key validation. The `skCondition` property is omitted here and re-added at the query
|
|
23
|
+
* overload level with a `const SK` generic parameter for literal type inference and
|
|
24
|
+
* return type narrowing.
|
|
25
|
+
*
|
|
26
|
+
* The query overload also re-declares `filter` with a `const F` generic parameter to
|
|
27
|
+
* enable literal type inference for return type narrowing. Both declarations are required:
|
|
28
|
+
* this one provides excess property checking on object literals, while the generic
|
|
29
|
+
* provides literal type capture for return type inference.
|
|
30
|
+
*
|
|
31
|
+
* @template T - The entity type being queried. Defaults to `DynaRecord` for backward
|
|
32
|
+
* compatibility in generic contexts.
|
|
19
33
|
*/
|
|
20
|
-
export type OptionsWithoutIndex = Omit<QueryOptions, "indexName"
|
|
34
|
+
export type OptionsWithoutIndex<T extends DynaRecord = DynaRecord> = Omit<QueryOptions, "indexName" | "filter" | "skCondition"> & {
|
|
35
|
+
filter?: TypedFilterParams<T>;
|
|
36
|
+
};
|
|
21
37
|
/**
|
|
22
38
|
* Options for querying on an index. Consistent reads are not allowed
|
|
23
39
|
*/
|
|
@@ -28,15 +44,16 @@ export type OptionsWithIndex = QueryBuilderOptions & {
|
|
|
28
44
|
/**
|
|
29
45
|
* Defines key conditions for querying entities based on their keys.
|
|
30
46
|
*
|
|
31
|
-
* PartitionKey is required, SortKey is optional.
|
|
47
|
+
* PartitionKey is required, SortKey is optional. The SortKey value is typed
|
|
48
|
+
* to only accept valid entity names from the partition (or entity name prefixes),
|
|
49
|
+
* matching dyna-record's single-table sort key format.
|
|
32
50
|
*
|
|
33
51
|
* @template T - The type of the entity being queried, extending `DynaRecord`.
|
|
34
|
-
* @property {KeyConditions} - Conditions applied to entity keys. Each key in the entity can have conditions such as equality, range conditions, or begins with conditions.
|
|
35
52
|
*/
|
|
36
|
-
export type EntityKeyConditions<T> = {
|
|
53
|
+
export type EntityKeyConditions<T extends DynaRecord = DynaRecord> = {
|
|
37
54
|
[K in keyof T as T[K] extends PartitionKey ? K : never]-?: string;
|
|
38
55
|
} & {
|
|
39
|
-
[K in keyof T as T[K] extends SortKey ? K : never]?:
|
|
56
|
+
[K in keyof T as T[K] extends SortKey ? K : never]?: TypedSortKeyCondition<T>;
|
|
40
57
|
};
|
|
41
58
|
/**
|
|
42
59
|
* Key conditions when querying on an index. Can be any attribute on the entity but must be the keys of the given index
|
|
@@ -96,5 +113,283 @@ export type QueryResult<T extends DynaRecord> = QueryResults<T>[number];
|
|
|
96
113
|
* When querying the main table this will enforce that the keys are the PartitionKey and SortKey from the table
|
|
97
114
|
* When querying an index, this can be any key on the table, but must be the keys for that index
|
|
98
115
|
*/
|
|
99
|
-
export type EntityQueryKeyConditions<T> = EntityKeyConditions<T> | IndexKeyConditions<T>;
|
|
116
|
+
export type EntityQueryKeyConditions<T extends DynaRecord = DynaRecord> = EntityKeyConditions<T> | IndexKeyConditions<T>;
|
|
117
|
+
/**
|
|
118
|
+
* Union of T itself and all entity types reachable through its declared relationships
|
|
119
|
+
* (`@HasMany`, `@HasOne`, `@BelongsTo`, `@HasAndBelongsToMany`).
|
|
120
|
+
*
|
|
121
|
+
* This defines which entities can appear in a partition query's `type` filter,
|
|
122
|
+
* `skCondition`, and `sk` key conditions. Only the entity itself and its direct
|
|
123
|
+
* relationships are included — entities from other tables or unrelated entities
|
|
124
|
+
* on the same table are excluded.
|
|
125
|
+
*
|
|
126
|
+
* E.g. for Customer with HasMany Order/PaymentMethod and HasOne ContactInformation:
|
|
127
|
+
* `Customer | Order | PaymentMethod | ContactInformation`
|
|
128
|
+
*/
|
|
129
|
+
export type PartitionEntities<T extends DynaRecord> = T | RelationshipEntities<T>;
|
|
130
|
+
/**
|
|
131
|
+
* Union of entity name string literals for the entity and its related entities.
|
|
132
|
+
* These are the only valid values for the `type` filter field, `skCondition`, and
|
|
133
|
+
* the `sk` property in key conditions.
|
|
134
|
+
*
|
|
135
|
+
* Falls back to `string` if any entity lacks `declare readonly type`.
|
|
136
|
+
*/
|
|
137
|
+
export type PartitionEntityNames<T extends DynaRecord> = PartitionEntities<T>["type"];
|
|
138
|
+
/**
|
|
139
|
+
* Union of EntityFilterableKeys<E> for each entity E in PartitionEntities<T>.
|
|
140
|
+
* This is the full set of valid filter keys when no `type` narrowing is applied.
|
|
141
|
+
*/
|
|
142
|
+
export type AllPartitionFilterableKeys<T extends DynaRecord> = PartitionEntities<T> extends infer E ? E extends DynaRecord ? EntityFilterableKeys<E> : never : never;
|
|
143
|
+
/**
|
|
144
|
+
* Maps a union of string keys to an optional FilterTypes record.
|
|
145
|
+
* Shared helper for building filter records from key unions.
|
|
146
|
+
*
|
|
147
|
+
* @template Keys - The union of string keys to include in the record.
|
|
148
|
+
*/
|
|
149
|
+
type FilterRecord<Keys extends string> = {
|
|
150
|
+
[K in Keys]?: FilterTypes;
|
|
151
|
+
};
|
|
152
|
+
/**
|
|
153
|
+
* Filter record scoped to a single entity's attributes.
|
|
154
|
+
*
|
|
155
|
+
* @template E - The entity type whose attributes form the record keys.
|
|
156
|
+
*/
|
|
157
|
+
export type EntityFilterRecord<E extends DynaRecord> = FilterRecord<EntityFilterableKeys<E>>;
|
|
158
|
+
/**
|
|
159
|
+
* Filter record for all entities in a partition (union of all filter keys).
|
|
160
|
+
*
|
|
161
|
+
* @template T - The root entity whose partition defines the filter keys.
|
|
162
|
+
*/
|
|
163
|
+
type FullPartitionFilterRecord<T extends DynaRecord> = FilterRecord<AllPartitionFilterableKeys<T>>;
|
|
164
|
+
/**
|
|
165
|
+
* Discriminated union enabling per-block `type` narrowing.
|
|
166
|
+
* When type is a single string literal, only that entity's attributes are allowed.
|
|
167
|
+
* When type is an array or absent, all partition attributes are allowed.
|
|
168
|
+
* The `type` field is handled separately from other filter keys to enable narrowing.
|
|
169
|
+
*/
|
|
170
|
+
export type TypedAndFilter<T extends DynaRecord> = (PartitionEntities<T> extends infer E ? E extends DynaRecord ? {
|
|
171
|
+
type: E["type"];
|
|
172
|
+
} & EntityFilterRecord<E> : never : never) | ({
|
|
173
|
+
type: PartitionEntityNames<T>[];
|
|
174
|
+
} & FullPartitionFilterRecord<T>) | ({
|
|
175
|
+
type?: never;
|
|
176
|
+
} & FullPartitionFilterRecord<T>);
|
|
177
|
+
/**
|
|
178
|
+
* Typed `$or` filter block for partition queries.
|
|
179
|
+
* Each `$or` element is independently narrowed: when a block specifies
|
|
180
|
+
* `type: "Order"`, only Order's attributes are accepted in that block.
|
|
181
|
+
*
|
|
182
|
+
* @template T - The root entity whose partition defines valid filter keys and type values.
|
|
183
|
+
*/
|
|
184
|
+
export type TypedOrFilter<T extends DynaRecord> = {
|
|
185
|
+
$or?: TypedAndFilter<T>[];
|
|
186
|
+
};
|
|
187
|
+
/**
|
|
188
|
+
* Top-level filter combining AND and OR.
|
|
189
|
+
*/
|
|
190
|
+
export type TypedFilterParams<T extends DynaRecord> = TypedAndFilter<T> & TypedOrFilter<T>;
|
|
191
|
+
/**
|
|
192
|
+
* Typed sort key condition for querying within an entity's partition.
|
|
193
|
+
*
|
|
194
|
+
* In dyna-record's single-table design, sort key values always start with an entity
|
|
195
|
+
* class name — either the entity itself or one of its declared relationships
|
|
196
|
+
* (`@HasMany`, `@HasOne`, `@BelongsTo`, `@HasAndBelongsToMany`):
|
|
197
|
+
* - Self/HasOne records: `SK = "EntityName"` (exact entity name)
|
|
198
|
+
* - HasMany records: `SK = "EntityName#id"` (entity name + delimiter + id)
|
|
199
|
+
*
|
|
200
|
+
* This type restricts `skCondition` and the `sk` key condition to only accept the
|
|
201
|
+
* entity's own name or its related entity names (or prefixes thereof). Unrelated
|
|
202
|
+
* entities and entities from other tables are rejected at compile time.
|
|
203
|
+
*
|
|
204
|
+
* @template T - The entity type being queried.
|
|
205
|
+
*/
|
|
206
|
+
export type TypedSortKeyCondition<T extends DynaRecord> = PartitionEntityNames<T> | `${PartitionEntityNames<T>}${string}` | {
|
|
207
|
+
$beginsWith: PartitionEntityNames<T> | `${PartitionEntityNames<T>}${string}`;
|
|
208
|
+
};
|
|
209
|
+
/**
|
|
210
|
+
* Extracts the entity name from a typed sort key condition for return type narrowing.
|
|
211
|
+
*
|
|
212
|
+
* Narrows when:
|
|
213
|
+
* - SK is an exact entity name: `"Order"` → `"Order"`
|
|
214
|
+
* - SK is `{ $beginsWith: "Order" }` → `"Order"`
|
|
215
|
+
*
|
|
216
|
+
* Does not narrow when:
|
|
217
|
+
* - SK is a prefixed string like `"Order#123"` (can't parse the delimiter at type level)
|
|
218
|
+
* - SK is `{ $beginsWith: "Order#..." }` (specific prefix, not just entity name)
|
|
219
|
+
*
|
|
220
|
+
* @template T - The entity type being queried.
|
|
221
|
+
* @template SK - The inferred sort key condition literal type.
|
|
222
|
+
*/
|
|
223
|
+
export type ExtractEntityFromSK<T extends DynaRecord, SK> = SK extends {
|
|
224
|
+
$beginsWith: infer V extends PartitionEntityNames<T>;
|
|
225
|
+
} ? V : SK extends PartitionEntityNames<T> ? SK : never;
|
|
226
|
+
/**
|
|
227
|
+
* Extracts string values from a type that may be a string or an array of strings.
|
|
228
|
+
* Returns the literal string if single value, array element types if array, or `never`.
|
|
229
|
+
*
|
|
230
|
+
* @template V - The value to extract strings from.
|
|
231
|
+
*/
|
|
232
|
+
type ExtractStringOrArrayStrings<V> = V extends string ? V : V extends Array<infer U extends string> ? U : never;
|
|
233
|
+
/**
|
|
234
|
+
* Extracts the `type` value from a filter object.
|
|
235
|
+
* Returns the literal string if single value, array element types if array, or `never`.
|
|
236
|
+
*
|
|
237
|
+
* @template F - The filter object to extract from.
|
|
238
|
+
*/
|
|
239
|
+
export type ExtractTypeFromFilter<F> = F extends {
|
|
240
|
+
type: infer V;
|
|
241
|
+
} ? ExtractStringOrArrayStrings<V> : never;
|
|
242
|
+
/**
|
|
243
|
+
* Maps entity name string → entity type.
|
|
244
|
+
*
|
|
245
|
+
* @template T - The root entity being queried.
|
|
246
|
+
* @template Name - The entity name string literal to resolve.
|
|
247
|
+
*/
|
|
248
|
+
export type ResolveEntityByName<T extends DynaRecord, Name extends string> = Extract<PartitionEntities<T>, {
|
|
249
|
+
type: Name;
|
|
250
|
+
}>;
|
|
251
|
+
/**
|
|
252
|
+
* Distributes EntityAttributesInstance over a union of DynaRecord types.
|
|
253
|
+
*/
|
|
254
|
+
type DistributeEntityAttributes<E> = E extends DynaRecord ? EntityAttributesInstance<E> : never;
|
|
255
|
+
/**
|
|
256
|
+
* Narrows query results to specific entity types identified by name.
|
|
257
|
+
* Falls back to QueryResults<T> if names don't resolve to known entities.
|
|
258
|
+
*
|
|
259
|
+
* @template T - The root entity being queried.
|
|
260
|
+
* @template Names - Union of entity name string literals to narrow to.
|
|
261
|
+
*/
|
|
262
|
+
type NarrowByNames<T extends DynaRecord, Names extends string> = [
|
|
263
|
+
ResolveEntityByName<T, Names>
|
|
264
|
+
] extends [never] ? QueryResults<T> : Array<DistributeEntityAttributes<ResolveEntityByName<T, Names>>>;
|
|
265
|
+
/**
|
|
266
|
+
* Narrows query results based on the `type` value extracted from a filter object.
|
|
267
|
+
* If the filter's `type` resolves to specific entity names, returns an array of
|
|
268
|
+
* those entity attribute types. Otherwise falls back to the full `QueryResults<T>` union.
|
|
269
|
+
*
|
|
270
|
+
* @template T - The root entity being queried.
|
|
271
|
+
* @template F - The filter object from which `type` is extracted.
|
|
272
|
+
*/
|
|
273
|
+
export type NarrowedQueryResults<T extends DynaRecord, F> = ExtractTypeFromFilter<F> extends infer Names extends string ? NarrowByNames<T, Names> : QueryResults<T>;
|
|
274
|
+
/**
|
|
275
|
+
* Extracts non-special filter keys from a filter object (excludes `type` and `$or`).
|
|
276
|
+
*
|
|
277
|
+
* @template F - The filter object to extract keys from.
|
|
278
|
+
*/
|
|
279
|
+
type FilterKeysOf<F> = Exclude<keyof F & string, "type" | "$or">;
|
|
280
|
+
/**
|
|
281
|
+
* Finds partition entities that have ALL the specified filter keys as filterable attributes.
|
|
282
|
+
* Returns the full `PartitionEntities` when Keys is `never` (no filter keys specified).
|
|
283
|
+
*
|
|
284
|
+
* @template T - The root entity being queried.
|
|
285
|
+
* @template Keys - Union of filter key strings that must all be present on the entity.
|
|
286
|
+
*/
|
|
287
|
+
type EntitiesWithAllKeys<T extends DynaRecord, Keys extends string> = [
|
|
288
|
+
Keys
|
|
289
|
+
] extends [never] ? PartitionEntities<T> : PartitionEntities<T> extends infer E ? E extends DynaRecord ? [Keys] extends [EntityFilterableKeys<E>] ? E : never : never : never;
|
|
290
|
+
/**
|
|
291
|
+
* Resolves the entity name strings for entities that have ALL the specified filter keys.
|
|
292
|
+
*
|
|
293
|
+
* @template T - The root entity being queried.
|
|
294
|
+
* @template Keys - Union of filter key strings.
|
|
295
|
+
*/
|
|
296
|
+
type EntityNamesFromKeys<T extends DynaRecord, Keys extends string> = EntitiesWithAllKeys<T, Keys>["type"];
|
|
297
|
+
/**
|
|
298
|
+
* Resolves a single filter block to entity name strings.
|
|
299
|
+
* If the block has a `type` field with specific entity names, uses those.
|
|
300
|
+
* Otherwise, narrows by finding entities that have ALL the block's non-special filter keys.
|
|
301
|
+
*
|
|
302
|
+
* @template T - The root entity being queried.
|
|
303
|
+
* @template Block - The filter block object.
|
|
304
|
+
*/
|
|
305
|
+
type ResolveBlockEntityNames<T extends DynaRecord, Block> = IsAny<ExtractTypeFromFilter<Block>> extends true ? EntityNamesFromKeys<T, FilterKeysOf<Block>> : [ExtractTypeFromFilter<Block>] extends [never] ? EntityNamesFromKeys<T, FilterKeysOf<Block>> : ExtractTypeFromFilter<Block>;
|
|
306
|
+
/**
|
|
307
|
+
* Resolves `$or` blocks to entity name strings. For each `$or` element, resolves
|
|
308
|
+
* to entity names by `type` (if present) or by filter keys (if no `type`).
|
|
309
|
+
* Returns the union of entity names across all `$or` blocks.
|
|
310
|
+
*
|
|
311
|
+
* @template T - The root entity being queried.
|
|
312
|
+
* @template F - The filter object containing `$or`.
|
|
313
|
+
*/
|
|
314
|
+
type ResolveOrBlockEntityNames<T extends DynaRecord, F> = F extends {
|
|
315
|
+
$or?: Array<infer OrElement>;
|
|
316
|
+
} ? OrElement extends infer Block extends object ? ResolveBlockEntityNames<T, Block> : never : never;
|
|
317
|
+
/**
|
|
318
|
+
* Determines whether `Names` represents a meaningful narrowing of the partition.
|
|
319
|
+
* Returns `true` if `Names` is a specific subset of partition entity names,
|
|
320
|
+
* `false` otherwise.
|
|
321
|
+
*
|
|
322
|
+
* A narrowing is meaningful when `Names` is:
|
|
323
|
+
* - Not `any` (from AWS SDK's `NativeAttributeValue` propagation)
|
|
324
|
+
* - Not `never` (no resolution)
|
|
325
|
+
* - Not the full partition union (no narrowing effect)
|
|
326
|
+
*
|
|
327
|
+
* This guard is shared across the inference chain to avoid duplicating the
|
|
328
|
+
* three-check pattern (IsAny / never / full-union) at each fallback level.
|
|
329
|
+
*
|
|
330
|
+
* @template T - The root entity being queried.
|
|
331
|
+
* @template Names - The resolved entity name union to check.
|
|
332
|
+
*/
|
|
333
|
+
type ShouldNarrow<T extends DynaRecord, Names> = IsAny<Names> extends true ? false : [Names] extends [never] ? false : [Names] extends [string] ? [PartitionEntityNames<T>] extends [Names] ? false : true : false;
|
|
334
|
+
/**
|
|
335
|
+
* Falls back to SK narrowing, then to full union.
|
|
336
|
+
*/
|
|
337
|
+
type FallbackToSK<T extends DynaRecord, SK> = ExtractEntityFromSK<T, SK> extends infer Names ? ShouldNarrow<T, Names> extends true ? NarrowByNames<T, Names & string> : QueryResults<T> : QueryResults<T>;
|
|
338
|
+
/**
|
|
339
|
+
* Narrows by names, but returns `never[]` when names resolve to no known entities.
|
|
340
|
+
* Unlike {@link NarrowByNames} which falls back to `QueryResults<T>` when names
|
|
341
|
+
* don't resolve, this returns an empty array type — used when an intersection of
|
|
342
|
+
* AND-combined narrowing signals is empty (no entity can satisfy all conditions).
|
|
343
|
+
*/
|
|
344
|
+
type StrictNarrowByNames<T extends DynaRecord, Names extends string> = [
|
|
345
|
+
ResolveEntityByName<T, Names>
|
|
346
|
+
] extends [never] ? never[] : Array<DistributeEntityAttributes<ResolveEntityByName<T, Names>>>;
|
|
347
|
+
/**
|
|
348
|
+
* When top-level filter keys narrow to `KeyNames`, also checks if `$or` blocks
|
|
349
|
+
* narrow independently. Since DynamoDB ANDs top-level conditions with `$or`,
|
|
350
|
+
* a record must satisfy both — so the matching entities are the intersection.
|
|
351
|
+
*
|
|
352
|
+
* - If `$or` also narrows → intersect with `KeyNames`. Empty intersection → `never[]`.
|
|
353
|
+
* - If `$or` does not narrow → use `KeyNames` alone.
|
|
354
|
+
*/
|
|
355
|
+
type IntersectKeysWithOr<T extends DynaRecord, KeyNames extends string, F> = ResolveOrBlockEntityNames<T, F> extends infer OrNames ? ShouldNarrow<T, OrNames> extends true ? StrictNarrowByNames<T, Extract<KeyNames, OrNames & string>> : NarrowByNames<T, KeyNames> : NarrowByNames<T, KeyNames>;
|
|
356
|
+
/**
|
|
357
|
+
* Falls back to `$or` block resolution (by type or filter keys), then SK, then full union.
|
|
358
|
+
*/
|
|
359
|
+
type FallbackToOrBlocks<T extends DynaRecord, F, SK> = ResolveOrBlockEntityNames<T, F> extends infer Names ? ShouldNarrow<T, Names> extends true ? NarrowByNames<T, Names & string> : FallbackToSK<T, SK> : FallbackToSK<T, SK>;
|
|
360
|
+
/**
|
|
361
|
+
* Falls back to top-level filter key resolution, then `$or`, then SK, then full union.
|
|
362
|
+
*
|
|
363
|
+
* When top-level keys narrow, also intersects with `$or` block narrowing (if any)
|
|
364
|
+
* because DynamoDB ANDs them — a record must satisfy both the top-level filter
|
|
365
|
+
* and at least one `$or` block.
|
|
366
|
+
*/
|
|
367
|
+
type FallbackToFilterKeys<T extends DynaRecord, F, SK> = EntityNamesFromKeys<T, FilterKeysOf<F>> extends infer Names ? ShouldNarrow<T, Names> extends true ? IntersectKeysWithOr<T, Names & string, F> : FallbackToOrBlocks<T, F, SK> : FallbackToOrBlocks<T, F, SK>;
|
|
368
|
+
/**
|
|
369
|
+
* When a top-level `type` filter narrows, also checks if `$or` blocks narrow
|
|
370
|
+
* to a disjoint set. Since DynamoDB ANDs them, the result is the intersection.
|
|
371
|
+
*/
|
|
372
|
+
type IntersectTypeWithOr<T extends DynaRecord, F> = ResolveOrBlockEntityNames<T, F> extends infer OrNames ? ShouldNarrow<T, OrNames> extends true ? StrictNarrowByNames<T, Extract<ExtractTypeFromFilter<F> & string, OrNames & string>> : NarrowedQueryResults<T, F> : NarrowedQueryResults<T, F>;
|
|
373
|
+
/**
|
|
374
|
+
* Infers query results from filter and SK for the non-index query overload.
|
|
375
|
+
*
|
|
376
|
+
* Narrowing strategy (respects DynamoDB's AND semantics):
|
|
377
|
+
* 1. If the filter specifies a top-level `type` value, narrow by that — then intersect
|
|
378
|
+
* with `$or` narrowing if present (since DynamoDB ANDs them).
|
|
379
|
+
* 2. Otherwise, if top-level filter keys narrow to specific entities, use that — then
|
|
380
|
+
* intersect with `$or` narrowing if present.
|
|
381
|
+
* 3. Otherwise, if `$or` blocks resolve to specific entities (by type or keys), use that.
|
|
382
|
+
* 4. Otherwise, if `skCondition` matches an exact entity name or `$beginsWith` an entity name, narrow by that.
|
|
383
|
+
* 5. Otherwise, return the full `QueryResults<T>` union.
|
|
384
|
+
*
|
|
385
|
+
* When both top-level (type or keys) and `$or` narrow to different entity sets,
|
|
386
|
+
* the intersection is taken. An empty intersection produces `never[]`, reflecting
|
|
387
|
+
* that no DynamoDB record can satisfy both AND-combined conditions.
|
|
388
|
+
*
|
|
389
|
+
* @template T - The root entity being queried.
|
|
390
|
+
* @template F - The inferred filter type (captured via `const` generic).
|
|
391
|
+
* @template SK - The inferred sort key condition type.
|
|
392
|
+
*/
|
|
393
|
+
export type InferQueryResults<T extends DynaRecord, F, SK = unknown> = ExtractTypeFromFilter<F> extends infer Names ? ShouldNarrow<T, Names> extends true ? IntersectTypeWithOr<T, F> : FallbackToFilterKeys<T, F, SK> : FallbackToFilterKeys<T, F, SK>;
|
|
394
|
+
export {};
|
|
100
395
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/operations/Query/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EACV,aAAa,IAAI,kBAAkB,EACnC,YAAY,IAAI,mBAAmB,EACnC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/operations/Query/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAC/C,OAAO,KAAK,EACV,aAAa,IAAI,kBAAkB,EACnC,YAAY,IAAI,mBAAmB,EACnC,WAAW,EACX,gBAAgB,EACjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAChE,OAAO,KAAK,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAE/E;;;;;GAKG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C,CAAC,SAAS,MAAM,KAAK,GACvD,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,IAAI,GACjC,mBAAmB,CAAC,CAAC,EAAE,KAAK,GAAG,MAAM,EAAE,CAAC,CAAC,GACzC,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAC9B,kBAAkB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;AAEnC;;;GAGG;AACH,KAAK,mBAAmB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,IAC9C,yBAAyB,CAAC,CAAC,EAAE,CAAC,CAAC,SAAS,MAAM,OAAO,GACjD,YAAY,CAAC,CAAC,EAAE,OAAO,CAAC,SAAS,IAAI,GACnC,mBAAmB,CACjB,CAAC,EACD,OAAO,CAAC,qBAAqB,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,OAAO,GAAG,MAAM,CAAC,CAC7D,GACD,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,GAC5B,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;AAEjC;;;;;;;;;;;;;;;;;;;GAmBG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,UAAU,EAAE,CAAC,EAAE,EAAE,GAAG,OAAO,IACjE,qBAAqB,CAAC,CAAC,CAAC,SAAS,MAAM,KAAK,GACxC,YAAY,CAAC,CAAC,EAAE,KAAK,CAAC,SAAS,IAAI,GACjC,mBAAmB,CAAC,CAAC,EAAE,CAAC,CAAC,GACzB,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,GAChC,oBAAoB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -66,4 +66,47 @@ export type EntityAttributeDefaultFields = Pick<DynaRecord, Extract<keyof DynaRe
|
|
|
66
66
|
* - Functions defined on the entity
|
|
67
67
|
*/
|
|
68
68
|
export type EntityDefinedAttributes<T extends DynaRecord> = Omit<ForeignKeyToValue<T>, keyof DynaRecord | RelationshipAttributeNames<T> | FunctionFields<T> | PartitionKeyAttribute<T> | SortKeyAttribute<T>>;
|
|
69
|
+
/**
|
|
70
|
+
* Types that terminate dot-path recursion. These are considered leaf types
|
|
71
|
+
* that should not be recursed into when generating filter key paths.
|
|
72
|
+
*/
|
|
73
|
+
export type NonRecursiveLeaf = Date | unknown[] | DynaRecord | ((...args: never[]) => unknown);
|
|
74
|
+
/**
|
|
75
|
+
* Maximum recursion depth for {@link DotPathKeys}.
|
|
76
|
+
* Set to 5 to cover realistic DynamoDB Map attribute nesting (typically 2-3 levels)
|
|
77
|
+
* while staying well below TypeScript's internal instantiation depth limit of 50.
|
|
78
|
+
* Higher values risk combinatorial explosion with wide object schemas.
|
|
79
|
+
*/
|
|
80
|
+
type MaxDotPathDepth = 5;
|
|
81
|
+
/**
|
|
82
|
+
* Recursively generates dot-separated key paths for plain object types.
|
|
83
|
+
* Stops recursion at {@link NonRecursiveLeaf} types and at {@link MaxDotPathDepth} levels
|
|
84
|
+
* to prevent "Type instantiation is excessively deep" errors.
|
|
85
|
+
*
|
|
86
|
+
* @template T - The object type to generate paths for.
|
|
87
|
+
* @template Depth - Internal depth counter (tuple). Do not provide externally.
|
|
88
|
+
*/
|
|
89
|
+
export type DotPathKeys<T, Depth extends unknown[] = []> = Depth["length"] extends MaxDotPathDepth ? never : T extends NonRecursiveLeaf ? never : T extends object ? {
|
|
90
|
+
[K in keyof T & string]: K | (DotPathKeys<T[K], [...Depth, unknown]> extends infer D extends string ? `${K}.${D}` : never);
|
|
91
|
+
}[keyof T & string] : never;
|
|
92
|
+
/**
|
|
93
|
+
* For a given entity, produces all dot-path keys for its ObjectAttribute fields.
|
|
94
|
+
* Checks each property: if it's a plain object (not a {@link NonRecursiveLeaf}),
|
|
95
|
+
* generates "propName.nestedKey" paths.
|
|
96
|
+
*/
|
|
97
|
+
export type ObjectDotPaths<T extends DynaRecord> = {
|
|
98
|
+
[K in keyof T & string]: Exclude<T[K], undefined> extends infer V ? V extends NonRecursiveLeaf ? never : V extends object ? DotPathKeys<V> extends infer D extends string ? `${K}.${D}` : never : never : never;
|
|
99
|
+
}[keyof T & string];
|
|
100
|
+
/**
|
|
101
|
+
* Union of: non-relationship/non-function/non-key attribute names + ObjectDotPaths.
|
|
102
|
+
* This is the complete set of valid filter keys for a single entity.
|
|
103
|
+
*
|
|
104
|
+
* Excludes:
|
|
105
|
+
* - Relationship properties (via {@link EntityAttributesOnly})
|
|
106
|
+
* - Function fields (via {@link EntityAttributesOnly})
|
|
107
|
+
* - PartitionKeyAttribute and SortKeyAttribute
|
|
108
|
+
* - `type` (handled separately by {@link TypedAndFilter} for discriminated union narrowing)
|
|
109
|
+
*/
|
|
110
|
+
export type EntityFilterableKeys<T extends DynaRecord> = Exclude<keyof EntityAttributesOnly<T> & string, PartitionKeyAttribute<T> | SortKeyAttribute<T> | "type"> | ObjectDotPaths<T>;
|
|
111
|
+
export {};
|
|
69
112
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/operations/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,UAAU,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,KAAK,EACV,UAAU,EACV,kBAAkB,EAClB,QAAQ,EACR,YAAY,EACZ,OAAO,EACR,MAAM,UAAU,CAAC;AAElB;;;;;GAKG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,IAAI;KACpC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,YAAY,GAAG,CAAC,GAAG,KAAK;CACtD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;;;;GAKG;AACH,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI;KAC/B,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,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MAAM,CACxD,GACD,cAAc,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["../../../src/query-utils/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO/D,OAAO,KAAK,EAUV,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAgBjB;;;;GAIG;AACH,cAAM,YAAY;;gBASJ,KAAK,EAAE,iBAAiB;IAmBpC;;;OAGG;IACI,KAAK,IAAI,iBAAiB;IAwBjC;;;;;OAKG;IACH,OAAO,CAAC,8BAA8B;IAgBtC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAgChC;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY;IAWpB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAejB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAkCpB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;
|
|
1
|
+
{"version":3,"file":"QueryBuilder.d.ts","sourceRoot":"","sources":["../../../src/query-utils/QueryBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAO/D,OAAO,KAAK,EAUV,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAgBjB;;;;GAIG;AACH,cAAM,YAAY;;gBASJ,KAAK,EAAE,iBAAiB;IAmBpC;;;OAGG;IACI,KAAK,IAAI,iBAAiB;IAwBjC;;;;;OAKG;IACH,OAAO,CAAC,8BAA8B;IAgBtC;;;OAGG;IACH,OAAO,CAAC,wBAAwB;IAgChC;;;;;;;;;OASG;IACH,OAAO,CAAC,YAAY;IAWpB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IASnB;;;;OAIG;IACH,OAAO,CAAC,SAAS;IAejB;;;;;;;OAOG;IACH,OAAO,CAAC,YAAY;IAkCpB;;;;;;;;;OASG;IACH,OAAO,CAAC,eAAe;IAkCvB;;;;OAIG;IACH,OAAO,CAAC,QAAQ;IAehB;;;;OAIG;IACH,OAAO,CAAC,WAAW;IAUnB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IAI1B;;;;OAIG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;;;OAIG;IACH,OAAO,CAAC,aAAa;IAIrB;;;;OAIG;IACH,OAAO,CAAC,UAAU;CAGnB;AAED,eAAe,YAAY,CAAC"}
|
|
@@ -190,6 +190,10 @@ class QueryBuilder {
|
|
|
190
190
|
resolveAttrPath(key) {
|
|
191
191
|
const segments = key.split(".");
|
|
192
192
|
const topLevelKey = segments[0];
|
|
193
|
+
if (!(topLevelKey in this.#attributeMetadata)) {
|
|
194
|
+
throw new Error(`Invalid filter key "${key}": attribute "${topLevelKey}" does not exist on this entity. ` +
|
|
195
|
+
`Valid attributes are: ${Object.keys(this.#attributeMetadata).join(", ")}`);
|
|
196
|
+
}
|
|
193
197
|
const tableKey = this.#attributeMetadata[topLevelKey].alias;
|
|
194
198
|
const names = { [`#${tableKey}`]: tableKey };
|
|
195
199
|
if (segments.length === 1) {
|
package/dist/src/types.d.ts
CHANGED
|
@@ -69,7 +69,16 @@ export interface RelationshipMetaObj {
|
|
|
69
69
|
*/
|
|
70
70
|
export type MakeOptional<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>;
|
|
71
71
|
/**
|
|
72
|
-
*
|
|
72
|
+
* Detects the `any` type. Resolves to `true` when T is `any`, `false` otherwise.
|
|
73
|
+
* Used internally to guard against `any` propagation from AWS SDK's `NativeAttributeValue`.
|
|
74
|
+
*/
|
|
75
|
+
export type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
76
|
+
/**
|
|
77
|
+
* Represents the constructor type of a class decorated with the `@Entity` decorator.
|
|
78
|
+
*
|
|
79
|
+
* The `@Entity` decorator enforces at compile time that each entity declares
|
|
80
|
+
* `readonly type` as a string literal matching the class name. If the declaration
|
|
81
|
+
* is missing, the decorator produces a type error. See {@link Entity} for details.
|
|
73
82
|
*/
|
|
74
83
|
export type EntityClass<T> = (new () => T) & typeof DynaRecord;
|
|
75
84
|
/**
|
package/dist/src/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC9E,OAAO,KAAK,UAAU,MAAM,cAAc,CAAC;AAE3C;;GAEG;AACH,MAAM,MAAM,KAAK,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,OAAO,GAAG,KAAK,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;AAEzD;;;;GAIG;AACH,MAAM,MAAM,UAAU,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI,KAAK,CAC/D,MAAM,EACN;IAAE,IAAI,EAAE,YAAY,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAClC,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,kBAAkB,CAAC,CAAC,SAAS,UAAU,GAAG,UAAU,IAAI,QAAQ,CAC1E,KAAK,CAAC,MAAM,EAAE;IAAE,IAAI,EAAE,oBAAoB,CAAC;IAAC,MAAM,EAAE,CAAC,CAAA;CAAE,CAAC,CACzD,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG,MAAM,UAAU,GAAG,UAAU,CAAC;AAE/D;;GAEG;AACH,MAAM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