dyna-record 0.6.7 → 0.7.1
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 +23 -7
- package/dist/index.d.ts +12 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +13 -22
- package/dist/src/DynaRecord.d.ts +3 -3
- package/dist/src/DynaRecord.d.ts.map +1 -1
- package/dist/src/DynaRecord.js +24 -59
- package/dist/src/Logger.js +1 -3
- package/dist/src/decorators/Entity.d.ts +1 -1
- package/dist/src/decorators/Entity.d.ts.map +1 -1
- package/dist/src/decorators/Entity.js +3 -8
- package/dist/src/decorators/Table.d.ts +2 -2
- package/dist/src/decorators/Table.d.ts.map +1 -1
- package/dist/src/decorators/Table.js +3 -8
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/BooleanAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/BooleanAttribute.js +5 -10
- package/dist/src/decorators/attributes/DateAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/DateAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/DateAttribute.js +7 -12
- package/dist/src/decorators/attributes/EnumAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/EnumAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/EnumAttribute.js +5 -10
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/ForeignKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ForeignKeyAttribute.js +5 -10
- package/dist/src/decorators/attributes/IdAttribute.d.ts +1 -1
- package/dist/src/decorators/attributes/IdAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/IdAttribute.js +3 -8
- package/dist/src/decorators/attributes/NumberAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/NumberAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/NumberAttribute.js +5 -10
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/ObjectAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/ObjectAttribute.js +16 -21
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/PartitionKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/PartitionKeyAttribute.js +5 -10
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts +3 -3
- package/dist/src/decorators/attributes/SortKeyAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/SortKeyAttribute.js +5 -10
- package/dist/src/decorators/attributes/StringAttribute.d.ts +2 -2
- package/dist/src/decorators/attributes/StringAttribute.d.ts.map +1 -1
- package/dist/src/decorators/attributes/StringAttribute.js +5 -10
- package/dist/src/decorators/attributes/index.d.ts +13 -13
- package/dist/src/decorators/attributes/index.d.ts.map +1 -1
- package/dist/src/decorators/attributes/index.js +11 -41
- package/dist/src/decorators/attributes/serializers.d.ts +2 -2
- package/dist/src/decorators/attributes/serializers.d.ts.map +1 -1
- package/dist/src/decorators/attributes/serializers.js +5 -12
- package/dist/src/decorators/attributes/types.js +1 -2
- package/dist/src/decorators/index.d.ts +5 -5
- package/dist/src/decorators/index.d.ts.map +1 -1
- package/dist/src/decorators/index.js +5 -27
- package/dist/src/decorators/relationships/BelongsTo.d.ts +4 -4
- package/dist/src/decorators/relationships/BelongsTo.d.ts.map +1 -1
- package/dist/src/decorators/relationships/BelongsTo.js +3 -8
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts +3 -3
- package/dist/src/decorators/relationships/HasAndBelongsToMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasAndBelongsToMany.js +4 -9
- package/dist/src/decorators/relationships/HasMany.d.ts +3 -3
- package/dist/src/decorators/relationships/HasMany.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasMany.js +4 -9
- package/dist/src/decorators/relationships/HasOne.d.ts +3 -3
- package/dist/src/decorators/relationships/HasOne.d.ts.map +1 -1
- package/dist/src/decorators/relationships/HasOne.js +3 -8
- package/dist/src/decorators/relationships/index.d.ts +5 -5
- package/dist/src/decorators/relationships/index.d.ts.map +1 -1
- package/dist/src/decorators/relationships/index.js +5 -29
- package/dist/src/decorators/relationships/types.d.ts +3 -3
- package/dist/src/decorators/relationships/types.d.ts.map +1 -1
- package/dist/src/decorators/relationships/types.js +1 -2
- package/dist/src/decorators/types.d.ts +3 -3
- package/dist/src/decorators/types.d.ts.map +1 -1
- package/dist/src/decorators/types.js +1 -2
- package/dist/src/dynamo-utils/DynamoClient.d.ts +1 -1
- package/dist/src/dynamo-utils/DynamoClient.d.ts.map +1 -1
- package/dist/src/dynamo-utils/DynamoClient.js +13 -18
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts +1 -1
- package/dist/src/dynamo-utils/TransactGetBuilder.d.ts.map +1 -1
- package/dist/src/dynamo-utils/TransactGetBuilder.js +5 -10
- package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts +1 -1
- package/dist/src/dynamo-utils/TransactWriteBuilder.d.ts.map +1 -1
- package/dist/src/dynamo-utils/TransactWriteBuilder.js +11 -16
- package/dist/src/dynamo-utils/errors.js +2 -7
- package/dist/src/dynamo-utils/index.d.ts +7 -7
- package/dist/src/dynamo-utils/index.d.ts.map +1 -1
- package/dist/src/dynamo-utils/index.js +7 -30
- package/dist/src/dynamo-utils/types.js +1 -2
- package/dist/src/errors.js +3 -9
- package/dist/src/id.d.ts +12 -0
- package/dist/src/id.d.ts.map +1 -0
- package/dist/src/id.js +11 -0
- package/dist/src/index.d.ts +8 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +4 -20
- package/dist/src/metadata/AttributeMetadata.d.ts +4 -4
- package/dist/src/metadata/AttributeMetadata.d.ts.map +1 -1
- package/dist/src/metadata/AttributeMetadata.js +1 -3
- package/dist/src/metadata/EntityMetadata.d.ts +3 -3
- package/dist/src/metadata/EntityMetadata.d.ts.map +1 -1
- package/dist/src/metadata/EntityMetadata.js +18 -23
- package/dist/src/metadata/JoinTableMetadata.d.ts +3 -3
- package/dist/src/metadata/JoinTableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/JoinTableMetadata.js +1 -3
- package/dist/src/metadata/MetadataStorage.d.ts +7 -7
- package/dist/src/metadata/MetadataStorage.d.ts.map +1 -1
- package/dist/src/metadata/MetadataStorage.js +12 -17
- package/dist/src/metadata/TableMetadata.d.ts +3 -3
- package/dist/src/metadata/TableMetadata.d.ts.map +1 -1
- package/dist/src/metadata/TableMetadata.js +17 -20
- package/dist/src/metadata/index.d.ts +9 -9
- package/dist/src/metadata/index.d.ts.map +1 -1
- package/dist/src/metadata/index.js +11 -34
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/BelongsToRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts +1 -1
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasAndBelongsToManyRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasManyRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/HasOneRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/OwnedByRelationship.js +3 -8
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts +2 -2
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/RelationshipMetadata.js +1 -3
- package/dist/src/metadata/relationship-metadata/index.d.ts +6 -6
- package/dist/src/metadata/relationship-metadata/index.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/index.js +7 -31
- package/dist/src/metadata/relationship-metadata/types.d.ts +5 -5
- package/dist/src/metadata/relationship-metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/types.js +1 -2
- package/dist/src/metadata/relationship-metadata/utils.d.ts +1 -1
- package/dist/src/metadata/relationship-metadata/utils.d.ts.map +1 -1
- package/dist/src/metadata/relationship-metadata/utils.js +11 -18
- package/dist/src/metadata/schemas.d.ts +3 -3
- package/dist/src/metadata/schemas.d.ts.map +1 -1
- package/dist/src/metadata/schemas.js +34 -37
- package/dist/src/metadata/types.d.ts +4 -4
- package/dist/src/metadata/types.d.ts.map +1 -1
- package/dist/src/metadata/types.js +1 -2
- package/dist/src/metadata/utils.d.ts +5 -5
- package/dist/src/metadata/utils.d.ts.map +1 -1
- package/dist/src/metadata/utils.js +14 -29
- package/dist/src/operations/Create/Create.d.ts +5 -5
- package/dist/src/operations/Create/Create.d.ts.map +1 -1
- package/dist/src/operations/Create/Create.js +18 -23
- package/dist/src/operations/Create/index.d.ts +2 -2
- package/dist/src/operations/Create/index.d.ts.map +1 -1
- package/dist/src/operations/Create/index.js +2 -23
- package/dist/src/operations/Create/types.d.ts +2 -2
- package/dist/src/operations/Create/types.d.ts.map +1 -1
- package/dist/src/operations/Create/types.js +1 -2
- package/dist/src/operations/Delete/Delete.d.ts +3 -3
- package/dist/src/operations/Delete/Delete.d.ts.map +1 -1
- package/dist/src/operations/Delete/Delete.js +28 -33
- package/dist/src/operations/Delete/index.d.ts +1 -1
- package/dist/src/operations/Delete/index.d.ts.map +1 -1
- package/dist/src/operations/Delete/index.js +1 -8
- package/dist/src/operations/Delete/types.js +1 -2
- package/dist/src/operations/FindById/FindById.d.ts +4 -4
- package/dist/src/operations/FindById/FindById.d.ts.map +1 -1
- package/dist/src/operations/FindById/FindById.js +17 -22
- package/dist/src/operations/FindById/index.d.ts +2 -2
- package/dist/src/operations/FindById/index.d.ts.map +1 -1
- package/dist/src/operations/FindById/index.js +2 -23
- package/dist/src/operations/FindById/types.d.ts +3 -3
- package/dist/src/operations/FindById/types.d.ts.map +1 -1
- package/dist/src/operations/FindById/types.js +1 -2
- package/dist/src/operations/OperationBase.d.ts +3 -3
- package/dist/src/operations/OperationBase.d.ts.map +1 -1
- package/dist/src/operations/OperationBase.js +4 -9
- package/dist/src/operations/Query/Query.d.ts +4 -4
- package/dist/src/operations/Query/Query.d.ts.map +1 -1
- package/dist/src/operations/Query/Query.js +15 -20
- package/dist/src/operations/Query/index.d.ts +2 -2
- package/dist/src/operations/Query/index.d.ts.map +1 -1
- package/dist/src/operations/Query/index.js +2 -23
- package/dist/src/operations/Query/types.d.ts +8 -8
- package/dist/src/operations/Query/types.d.ts.map +1 -1
- package/dist/src/operations/Query/types.js +1 -2
- package/dist/src/operations/Update/Update.d.ts +5 -5
- package/dist/src/operations/Update/Update.d.ts.map +1 -1
- package/dist/src/operations/Update/Update.js +37 -42
- package/dist/src/operations/Update/UpdateDryRun.d.ts +2 -2
- package/dist/src/operations/Update/UpdateDryRun.d.ts.map +1 -1
- package/dist/src/operations/Update/UpdateDryRun.js +3 -8
- package/dist/src/operations/Update/index.d.ts +3 -3
- package/dist/src/operations/Update/index.d.ts.map +1 -1
- package/dist/src/operations/Update/index.js +3 -25
- package/dist/src/operations/Update/types.d.ts +2 -2
- package/dist/src/operations/Update/types.d.ts.map +1 -1
- package/dist/src/operations/Update/types.js +1 -2
- package/dist/src/operations/index.d.ts +6 -6
- package/dist/src/operations/index.d.ts.map +1 -1
- package/dist/src/operations/index.js +6 -22
- package/dist/src/operations/types.d.ts +3 -3
- package/dist/src/operations/types.d.ts.map +1 -1
- package/dist/src/operations/types.js +1 -2
- package/dist/src/operations/utils/expressionBuilder.d.ts +2 -2
- package/dist/src/operations/utils/expressionBuilder.d.ts.map +1 -1
- package/dist/src/operations/utils/expressionBuilder.js +1 -5
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts +2 -2
- package/dist/src/operations/utils/flattenObjectForUpdate.d.ts.map +1 -1
- package/dist/src/operations/utils/flattenObjectForUpdate.js +3 -6
- package/dist/src/operations/utils/index.d.ts +5 -5
- package/dist/src/operations/utils/index.d.ts.map +1 -1
- package/dist/src/operations/utils/index.js +5 -21
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts +1 -1
- package/dist/src/operations/utils/mergePartialObjectAttributes.d.ts.map +1 -1
- package/dist/src/operations/utils/mergePartialObjectAttributes.js +1 -4
- package/dist/src/operations/utils/types.js +1 -2
- package/dist/src/operations/utils/utils.d.ts +4 -4
- package/dist/src/operations/utils/utils.d.ts.map +1 -1
- package/dist/src/operations/utils/utils.js +13 -23
- package/dist/src/query-utils/Filters.d.ts +2 -2
- package/dist/src/query-utils/Filters.d.ts.map +1 -1
- package/dist/src/query-utils/Filters.js +1 -4
- package/dist/src/query-utils/QueryBuilder.d.ts +1 -1
- package/dist/src/query-utils/QueryBuilder.d.ts.map +1 -1
- package/dist/src/query-utils/QueryBuilder.js +8 -13
- package/dist/src/query-utils/index.d.ts +2 -2
- package/dist/src/query-utils/index.d.ts.map +1 -1
- package/dist/src/query-utils/index.js +2 -23
- package/dist/src/query-utils/types.js +1 -2
- package/dist/src/relationships/JoinTable.d.ts +2 -2
- package/dist/src/relationships/JoinTable.d.ts.map +1 -1
- package/dist/src/relationships/JoinTable.js +14 -19
- package/dist/src/relationships/index.d.ts +1 -1
- package/dist/src/relationships/index.d.ts.map +1 -1
- package/dist/src/relationships/index.js +1 -8
- package/dist/src/types.d.ts +2 -2
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/types.js +1 -2
- package/dist/src/utils.d.ts +3 -3
- package/dist/src/utils.d.ts.map +1 -1
- package/dist/src/utils.js +16 -31
- package/package.json +28 -24
package/README.md
CHANGED
|
@@ -33,18 +33,34 @@ Note: ACID compliant according to DynamoDB [limitations](https://docs.aws.amazon
|
|
|
33
33
|
|
|
34
34
|
### Installation
|
|
35
35
|
|
|
36
|
-
|
|
36
|
+
Requires Node.js `>=22` and TypeScript `>=6`.
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
39
|
npm install dyna-record
|
|
40
|
+
# or
|
|
41
|
+
yarn add dyna-record
|
|
42
|
+
# or
|
|
43
|
+
pnpm add dyna-record
|
|
40
44
|
```
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
dyna-record is **ESM-only** as of 0.7.0:
|
|
43
47
|
|
|
44
|
-
```
|
|
45
|
-
|
|
48
|
+
```ts
|
|
49
|
+
// ESM
|
|
50
|
+
import DynaRecord, { Entity, Table } from "dyna-record";
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
If your project is still on CommonJS, use a dynamic import:
|
|
54
|
+
|
|
55
|
+
```js
|
|
56
|
+
// CommonJS (any modern Node) via dynamic import
|
|
57
|
+
const { default: DynaRecord, Entity, Table } = await import("dyna-record");
|
|
46
58
|
```
|
|
47
59
|
|
|
60
|
+
Direct `require("dyna-record")` only works on Node 22.12+ via Node's stabilized `require(esm)` and is not an officially supported contract — prefer dynamic `import()` for portability.
|
|
61
|
+
|
|
62
|
+
> dyna-record uses **TC39 Stage 3 decorators** (the TypeScript 5+/6 default). Do **not** enable `experimentalDecorators` in your `tsconfig.json`.
|
|
63
|
+
|
|
48
64
|
## Defining Entities
|
|
49
65
|
|
|
50
66
|
Entities in Dyna-Record represent your DynamoDB table structure and relationships. Think of each entity as a table in a relational database, even though they will be represented on a single table.
|
|
@@ -118,7 +134,7 @@ By default, each entity will have [default attributes](https://docs.dyna-record.
|
|
|
118
134
|
|
|
119
135
|
- The partition key defined on the [table](#table) class
|
|
120
136
|
- The sort key defined on the [table](#table) class
|
|
121
|
-
- [id](https://docs.dyna-record.com/classes/default.html#id) - The id for the model. This will be an autogenerated
|
|
137
|
+
- [id](https://docs.dyna-record.com/classes/default.html#id) - The id for the model. This will be an autogenerated UUID (v4, via Node's built-in `crypto.randomUUID()`) unless [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set on a non-nullable entity attribute.
|
|
122
138
|
- [type](https://docs.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
139
|
- [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) - The timestamp of when the entity was created
|
|
124
140
|
- [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) - Timestamp of when the entity was updated last
|
|
@@ -513,7 +529,7 @@ class Student extends OtherTable {
|
|
|
513
529
|
|
|
514
530
|
[Docs](https://docs.dyna-record.com/classes/default.html#create)
|
|
515
531
|
|
|
516
|
-
The create method is used to insert a new record into a DynamoDB table. This method automatically handles key generation (using UUIDs or custom id field if [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set), timestamps for [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) fields, and the management of relationships between entities. It leverages AWS SDK's [TransactWriteCommand](https://www.google.com/search?q=aws+transact+write+command&oq=aws+transact+write+command&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg7MgYIAhBFGDvSAQgzMjAzajBqN6gCALACAA&sourceid=chrome&ie=UTF-8) for transactional integrity, ensuring either complete success or rollback in case of any failure. The method handles conditional checks to ensure data integrity and consistency during creation. If a foreignKey is set on create, dyna-record will de-normalize the data required in order to support the relationship
|
|
532
|
+
The create method is used to insert a new record into a DynamoDB table. This method automatically handles key generation (using v4 UUIDs or a custom id field if [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) is set), timestamps for [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) fields, and the management of relationships between entities. It leverages AWS SDK's [TransactWriteCommand](https://www.google.com/search?q=aws+transact+write+command&oq=aws+transact+write+command&gs_lcrp=EgZjaHJvbWUyBggAEEUYOTIGCAEQRRg7MgYIAhBFGDvSAQgzMjAzajBqN6gCALACAA&sourceid=chrome&ie=UTF-8) for transactional integrity, ensuring either complete success or rollback in case of any failure. The method handles conditional checks to ensure data integrity and consistency during creation. If a foreignKey is set on create, dyna-record will de-normalize the data required in order to support the relationship
|
|
517
533
|
|
|
518
534
|
To use the create method, call it on the model class you wish to create a new record for. Pass the properties of the new record as an object argument to the method. Only attributes defined on the model can be configured, and will be enforced via types and runtime schema validation.
|
|
519
535
|
|
|
@@ -563,7 +579,7 @@ The method is designed to throw errors under various conditions, such as transac
|
|
|
563
579
|
#### Notes
|
|
564
580
|
|
|
565
581
|
- Automatic Timestamp Management: The [createdAt](https://docs.dyna-record.com/classes/default.html#createdAt) and [updatedAt](https://docs.dyna-record.com/classes/default.html#updatedAt) fields are managed automatically and reflect the time of creation and the last update, respectively.
|
|
566
|
-
- Automatic ID Generation: Each entity created gets a unique [id](https://docs.dyna-record.com/classes/default.html#id)
|
|
582
|
+
- Automatic ID Generation: Each entity created gets a unique [id](https://docs.dyna-record.com/classes/default.html#id) as a v4 uuid.
|
|
567
583
|
- This can be customized [IdAttribute](<(https://docs.dyna-record.com/functions/IdAttribute.html)>) to support custom id attributes
|
|
568
584
|
- Relationship Management: The ORM manages entity relationships through DynamoDB's single-table design patterns, creating and maintaining the necessary links between related entities.
|
|
569
585
|
- Conditional Checks: To ensure data integrity, the create method performs various conditional checks, such as verifying the existence of entities that new records relate to.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* dyna-record — strongly-typed DynamoDB ORM with single-table relational
|
|
3
|
+
* modeling.
|
|
4
|
+
*
|
|
5
|
+
* The default export is the {@link DynaRecord} base class; all entity
|
|
6
|
+
* decorators, relationship decorators, utility types, and error classes are
|
|
7
|
+
* re-exported from `./src`.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import DynaRecord from "./src/DynaRecord.js";
|
|
2
12
|
export default DynaRecord;
|
|
3
|
-
export * from "./src";
|
|
13
|
+
export * from "./src/index.js";
|
|
4
14
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,UAAU,MAAM,qBAAqB,CAAC;AAE7C,eAAe,UAAU,CAAC;AAC1B,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,22 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
const DynaRecord_1 = __importDefault(require("./src/DynaRecord"));
|
|
21
|
-
exports.default = DynaRecord_1.default;
|
|
22
|
-
__exportStar(require("./src"), exports);
|
|
1
|
+
/**
|
|
2
|
+
* dyna-record — strongly-typed DynamoDB ORM with single-table relational
|
|
3
|
+
* modeling.
|
|
4
|
+
*
|
|
5
|
+
* The default export is the {@link DynaRecord} base class; all entity
|
|
6
|
+
* decorators, relationship decorators, utility types, and error classes are
|
|
7
|
+
* re-exported from `./src`.
|
|
8
|
+
*
|
|
9
|
+
* @packageDocumentation
|
|
10
|
+
*/
|
|
11
|
+
import DynaRecord from "./src/DynaRecord.js";
|
|
12
|
+
export default DynaRecord;
|
|
13
|
+
export * from "./src/index.js";
|
package/dist/src/DynaRecord.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
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, type TypedFilterParams, type TypedSortKeyCondition, type InferQueryResults, type SKScopedFilterParams } from "./operations";
|
|
3
|
-
import type { DynamoTableItem, EntityClass, Optional } from "./types";
|
|
1
|
+
import { type TableMetadata } from "./metadata/index.js";
|
|
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, type SKScopedFilterParams } from "./operations/index.js";
|
|
3
|
+
import type { DynamoTableItem, EntityClass, Optional } from "./types.js";
|
|
4
4
|
interface DynaRecordBase {
|
|
5
5
|
id: string;
|
|
6
6
|
type: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynaRecord.d.ts","sourceRoot":"","sources":["../../src/DynaRecord.ts"],"names":[],"mappings":"AAAA,OAAiB,
|
|
1
|
+
{"version":3,"file":"DynaRecord.d.ts","sourceRoot":"","sources":["../../src/DynaRecord.ts"],"names":[],"mappings":"AAAA,OAAiB,EAEf,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAEL,KAAK,eAAe,EACpB,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B,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
|
@@ -1,20 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
1
|
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
19
2
|
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
20
3
|
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
@@ -49,29 +32,11 @@ var __runInitializers = (this && this.__runInitializers) || function (thisArg, i
|
|
|
49
32
|
}
|
|
50
33
|
return useValue ? value : void 0;
|
|
51
34
|
};
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
return ar;
|
|
58
|
-
};
|
|
59
|
-
return ownKeys(o);
|
|
60
|
-
};
|
|
61
|
-
return function (mod) {
|
|
62
|
-
if (mod && mod.__esModule) return mod;
|
|
63
|
-
var result = {};
|
|
64
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
65
|
-
__setModuleDefault(result, mod);
|
|
66
|
-
return result;
|
|
67
|
-
};
|
|
68
|
-
})();
|
|
69
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
70
|
-
const metadata_1 = __importStar(require("./metadata"));
|
|
71
|
-
const decorators_1 = require("./decorators");
|
|
72
|
-
const operations_1 = require("./operations");
|
|
73
|
-
const utils_1 = require("./operations/utils");
|
|
74
|
-
const utils_2 = require("./utils");
|
|
35
|
+
import Metadata, { tableDefaultFields } from "./metadata/index.js";
|
|
36
|
+
import { DateAttribute, StringAttribute } from "./decorators/index.js";
|
|
37
|
+
import { FindById, Query, Create, Update, Delete } from "./operations/index.js";
|
|
38
|
+
import { mergePartialObjectAttributes } from "./operations/utils/index.js";
|
|
39
|
+
import { createInstance, tableItemToEntity } from "./utils.js";
|
|
75
40
|
/**
|
|
76
41
|
* Serves as an abstract base class for entities in the ORM system. It defines standard fields such as `id`, `type`, `createdAt`, and `updatedAt`, and provides static methods for CRUD operations and queries. This class encapsulates common behaviors and properties that all entities share, leveraging decorators for attribute metadata and supporting operations like finding, creating, updating, and deleting entities.
|
|
77
42
|
*
|
|
@@ -112,10 +77,10 @@ let DynaRecord = (() => {
|
|
|
112
77
|
return class DynaRecord {
|
|
113
78
|
static {
|
|
114
79
|
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
115
|
-
_id_decorators = [
|
|
116
|
-
_type_decorators = [
|
|
117
|
-
_createdAt_decorators = [
|
|
118
|
-
_updatedAt_decorators = [
|
|
80
|
+
_id_decorators = [StringAttribute({ alias: tableDefaultFields.id.alias })];
|
|
81
|
+
_type_decorators = [StringAttribute({ alias: tableDefaultFields.type.alias })];
|
|
82
|
+
_createdAt_decorators = [DateAttribute({ alias: tableDefaultFields.createdAt.alias })];
|
|
83
|
+
_updatedAt_decorators = [DateAttribute({ alias: tableDefaultFields.updatedAt.alias })];
|
|
119
84
|
__esDecorate(null, null, _id_decorators, { kind: "field", name: "id", static: false, private: false, access: { has: obj => "id" in obj, get: obj => obj.id, set: (obj, value) => { obj.id = value; } }, metadata: _metadata }, _id_initializers, _id_extraInitializers);
|
|
120
85
|
__esDecorate(null, null, _type_decorators, { kind: "field", name: "type", static: false, private: false, access: { has: obj => "type" in obj, get: obj => obj.type, set: (obj, value) => { obj.type = value; } }, metadata: _metadata }, _type_initializers, _type_extraInitializers);
|
|
121
86
|
__esDecorate(null, null, _createdAt_decorators, { kind: "field", name: "createdAt", static: false, private: false, access: { has: obj => "createdAt" in obj, get: obj => obj.createdAt, set: (obj, value) => { obj.createdAt = value; } }, metadata: _metadata }, _createdAt_initializers, _createdAt_extraInitializers);
|
|
@@ -143,11 +108,11 @@ let DynaRecord = (() => {
|
|
|
143
108
|
*/
|
|
144
109
|
updatedAt = (__runInitializers(this, _createdAt_extraInitializers), __runInitializers(this, _updatedAt_initializers, void 0));
|
|
145
110
|
static async findById(id, options) {
|
|
146
|
-
const op = new
|
|
111
|
+
const op = new FindById(this);
|
|
147
112
|
return await op.run(id, options);
|
|
148
113
|
}
|
|
149
114
|
static async query(key, options) {
|
|
150
|
-
const op = new
|
|
115
|
+
const op = new Query(this);
|
|
151
116
|
return await op.run(key, options);
|
|
152
117
|
}
|
|
153
118
|
/**
|
|
@@ -170,7 +135,7 @@ let DynaRecord = (() => {
|
|
|
170
135
|
* ```
|
|
171
136
|
*/
|
|
172
137
|
static async create(attributes, options) {
|
|
173
|
-
const op = new
|
|
138
|
+
const op = new Create(this);
|
|
174
139
|
return await op.run(attributes, options);
|
|
175
140
|
}
|
|
176
141
|
/**
|
|
@@ -208,7 +173,7 @@ let DynaRecord = (() => {
|
|
|
208
173
|
* ```
|
|
209
174
|
*/
|
|
210
175
|
static async update(id, attributes, options) {
|
|
211
|
-
const op = new
|
|
176
|
+
const op = new Update(this);
|
|
212
177
|
await op.run(id, attributes, options);
|
|
213
178
|
}
|
|
214
179
|
/**
|
|
@@ -245,15 +210,15 @@ let DynaRecord = (() => {
|
|
|
245
210
|
*/
|
|
246
211
|
async update(attributes, options) {
|
|
247
212
|
const InstanceClass = this.constructor;
|
|
248
|
-
const op = new
|
|
213
|
+
const op = new Update(InstanceClass);
|
|
249
214
|
const updatedAttributes = await op.run(this.id, attributes, options);
|
|
250
215
|
const clone = structuredClone(this);
|
|
251
|
-
const entityAttrs =
|
|
216
|
+
const entityAttrs = Metadata.getEntityAttributes(InstanceClass.name);
|
|
252
217
|
// Deep merge ObjectAttributes, shallow assign everything else
|
|
253
|
-
|
|
218
|
+
mergePartialObjectAttributes(clone, updatedAttributes, entityAttrs);
|
|
254
219
|
const updatedInstance = Object.fromEntries(Object.entries(clone).filter(([_, value]) => value !== null));
|
|
255
220
|
// Return the updated instance, which is of type `this`
|
|
256
|
-
return
|
|
221
|
+
return createInstance(InstanceClass, updatedInstance);
|
|
257
222
|
}
|
|
258
223
|
/**
|
|
259
224
|
* Delete an entity by ID
|
|
@@ -267,7 +232,7 @@ let DynaRecord = (() => {
|
|
|
267
232
|
* ```
|
|
268
233
|
*/
|
|
269
234
|
static async delete(id) {
|
|
270
|
-
const op = new
|
|
235
|
+
const op = new Delete(this);
|
|
271
236
|
await op.run(id);
|
|
272
237
|
}
|
|
273
238
|
/**
|
|
@@ -281,19 +246,19 @@ let DynaRecord = (() => {
|
|
|
281
246
|
* ```
|
|
282
247
|
*/
|
|
283
248
|
static partitionKeyValue(id) {
|
|
284
|
-
const { delimiter } =
|
|
249
|
+
const { delimiter } = Metadata.getEntityTable(this.name);
|
|
285
250
|
return `${this.name}${delimiter}${id}`;
|
|
286
251
|
}
|
|
287
252
|
/**
|
|
288
253
|
* Takes a table item and serializes it to an entity instance
|
|
289
254
|
*/
|
|
290
255
|
static tableItemToEntity(tableItem) {
|
|
291
|
-
const tableMeta =
|
|
256
|
+
const tableMeta = Metadata.getEntityTable(this.name);
|
|
292
257
|
const typeAlias = tableMeta.defaultAttributes.type.alias;
|
|
293
258
|
if (tableItem[typeAlias] !== this.name) {
|
|
294
259
|
throw new Error("Unable to convert dynamo item to entity. Invalid type");
|
|
295
260
|
}
|
|
296
|
-
return
|
|
261
|
+
return tableItemToEntity(this, tableItem);
|
|
297
262
|
}
|
|
298
263
|
/**
|
|
299
264
|
* Get the partition key for an entity
|
|
@@ -316,8 +281,8 @@ let DynaRecord = (() => {
|
|
|
316
281
|
* ```
|
|
317
282
|
*/
|
|
318
283
|
static metadata() {
|
|
319
|
-
const tableMetadata =
|
|
320
|
-
const entities =
|
|
284
|
+
const tableMetadata = Metadata.getTable(this.name);
|
|
285
|
+
const entities = Metadata.getEntitiesForTable(this.name);
|
|
321
286
|
return tableMetadata.toJSON(entities);
|
|
322
287
|
}
|
|
323
288
|
constructor() {
|
|
@@ -325,4 +290,4 @@ let DynaRecord = (() => {
|
|
|
325
290
|
}
|
|
326
291
|
};
|
|
327
292
|
})();
|
|
328
|
-
|
|
293
|
+
export default DynaRecord;
|
package/dist/src/Logger.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* eslint-disable @typescript-eslint/no-extraneous-class */
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
2
|
/**
|
|
5
3
|
* Facilitates logging throughout the ORM system with support for different log levels: log, warn, error, and info. Logging can be toggled through the `DYNA_RECORD_LOGGING_ENABLED` environment variable. When enabled, logs are output to the console, allowing for easy tracking and debugging of the system's operations.
|
|
6
4
|
*
|
|
@@ -53,4 +51,4 @@ class Logger {
|
|
|
53
51
|
this._log("info", ...messages);
|
|
54
52
|
}
|
|
55
53
|
}
|
|
56
|
-
|
|
54
|
+
export default Logger;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type DynaRecord from "../DynaRecord";
|
|
1
|
+
import type DynaRecord from "../DynaRecord.js";
|
|
2
2
|
/**
|
|
3
3
|
* A class decorator for marking a class as an entity within the context of the ORM system. This decorator is essential for registering the class as a distinct entity in the ORM's metadata system, enabling the ORM to recognize and manage instances of this class as part of its data model. By designating classes as entities, it facilitates their integration into the ORM framework, allowing for operations such as querying, persisting, and managing relationships between entities.
|
|
4
4
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/decorators/Entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"Entity.d.ts","sourceRoot":"","sources":["../../../src/decorators/Entity.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;;;;;;;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"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const metadata_1 = __importDefault(require("../metadata"));
|
|
1
|
+
import Metadata from "../metadata/index.js";
|
|
7
2
|
/**
|
|
8
3
|
* A class decorator for marking a class as an entity within the context of the ORM system. This decorator is essential for registering the class as a distinct entity in the ORM's metadata system, enabling the ORM to recognize and manage instances of this class as part of its data model. By designating classes as entities, it facilitates their integration into the ORM framework, allowing for operations such as querying, persisting, and managing relationships between entities.
|
|
9
4
|
*
|
|
@@ -29,6 +24,6 @@ const metadata_1 = __importDefault(require("../metadata"));
|
|
|
29
24
|
*/
|
|
30
25
|
function Entity(target, _context) {
|
|
31
26
|
const tableClassName = Object.getPrototypeOf(target).name;
|
|
32
|
-
|
|
27
|
+
Metadata.addEntity(target, tableClassName);
|
|
33
28
|
}
|
|
34
|
-
|
|
29
|
+
export default Entity;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { type TableMetadataOptions } from "../metadata";
|
|
2
|
-
import type DynaRecord from "../DynaRecord";
|
|
1
|
+
import { type TableMetadataOptions } from "../metadata/index.js";
|
|
2
|
+
import type DynaRecord from "../DynaRecord.js";
|
|
3
3
|
/**
|
|
4
4
|
* A class decorator for defining and customizing the table metadata associated with an entity class within the ORM system. This decorator enriches the entity with additional metadata, specifying how the entity relates to the underlying database table. By providing custom table options, such as table names or schema definitions, this decorator plays a crucial role in bridging the gap between the ORM's abstract entities and their concrete database representations.
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/decorators/Table.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"Table.d.ts","sourceRoot":"","sources":["../../../src/decorators/Table.ts"],"names":[],"mappings":"AAAA,OAAiB,EAAE,KAAK,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC3E,OAAO,KAAK,UAAU,MAAM,kBAAkB,CAAC;AAE/C;;;;;;;;;;;;;;;;GAgBG;AACH,iBAAS,KAAK,CAAC,KAAK,EAAE,oBAAoB,IACvB,QAAQ,OAAO,UAAU,EAAE,UAAU,qBAAqB,UAG5E;AAED,eAAe,KAAK,CAAC"}
|
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const metadata_1 = __importDefault(require("../metadata"));
|
|
1
|
+
import Metadata from "../metadata/index.js";
|
|
7
2
|
/**
|
|
8
3
|
* A class decorator for defining and customizing the table metadata associated with an entity class within the ORM system. This decorator enriches the entity with additional metadata, specifying how the entity relates to the underlying database table. By providing custom table options, such as table names or schema definitions, this decorator plays a crucial role in bridging the gap between the ORM's abstract entities and their concrete database representations.
|
|
9
4
|
*
|
|
@@ -23,7 +18,7 @@ const metadata_1 = __importDefault(require("../metadata"));
|
|
|
23
18
|
*/
|
|
24
19
|
function Table(props) {
|
|
25
20
|
return function (target, _context) {
|
|
26
|
-
|
|
21
|
+
Metadata.addTable(target.name, props);
|
|
27
22
|
};
|
|
28
23
|
}
|
|
29
|
-
|
|
24
|
+
export default Table;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type DynaRecord from "../../DynaRecord";
|
|
2
|
-
import type { AttributeDecoratorContext, AttributeOptions } from "../types";
|
|
1
|
+
import type DynaRecord from "../../DynaRecord.js";
|
|
2
|
+
import type { AttributeDecoratorContext, AttributeOptions } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* A decorator for marking class fields as boolean attributes within the context of a single-table design entity
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BooleanAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/BooleanAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"BooleanAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/BooleanAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,iBAAS,gBAAgB,CACvB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,OAAO,EACjB,CAAC,SAAS,gBAAgB,EAC1B,KAAK,CAAC,EAAE,CAAC,IAEP,QAAQ,SAAS,EACjB,SAAS,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAY9C;AAED,eAAe,gBAAgB,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const metadata_1 = __importDefault(require("../../metadata"));
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import Metadata from "../../metadata/index.js";
|
|
8
3
|
/**
|
|
9
4
|
* A decorator for marking class fields as boolean attributes within the context of a single-table design entity
|
|
10
5
|
*
|
|
@@ -31,14 +26,14 @@ const metadata_1 = __importDefault(require("../../metadata"));
|
|
|
31
26
|
function BooleanAttribute(props) {
|
|
32
27
|
return function (_value, context) {
|
|
33
28
|
context.addInitializer(function () {
|
|
34
|
-
|
|
29
|
+
Metadata.addEntityAttribute(this.constructor.name, {
|
|
35
30
|
attributeName: context.name.toString(),
|
|
36
31
|
kind: "boolean",
|
|
37
32
|
nullable: props?.nullable,
|
|
38
|
-
type:
|
|
33
|
+
type: z.boolean(),
|
|
39
34
|
...props
|
|
40
35
|
});
|
|
41
36
|
});
|
|
42
37
|
};
|
|
43
38
|
}
|
|
44
|
-
|
|
39
|
+
export default BooleanAttribute;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type DynaRecord from "../../DynaRecord";
|
|
2
|
-
import type { AttributeDecoratorContext, AttributeOptions } from "../types";
|
|
1
|
+
import type DynaRecord from "../../DynaRecord.js";
|
|
2
|
+
import type { AttributeDecoratorContext, AttributeOptions } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* A decorator for marking class fields as date attributes within the context of a single-table design entity
|
|
5
5
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/DateAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"DateAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/DateAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAG/E;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,iBAAS,aAAa,CACpB,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,IAAI,EACd,CAAC,SAAS,gBAAgB,EAC1B,KAAK,CAAC,EAAE,CAAC,IAEP,QAAQ,SAAS,EACjB,SAAS,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAa9C;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const metadata_1 = __importDefault(require("../../metadata"));
|
|
8
|
-
const serializers_1 = require("./serializers");
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import Metadata from "../../metadata/index.js";
|
|
3
|
+
import { dateSerializer } from "./serializers.js";
|
|
9
4
|
/**
|
|
10
5
|
* A decorator for marking class fields as date attributes within the context of a single-table design entity
|
|
11
6
|
*
|
|
@@ -34,15 +29,15 @@ const serializers_1 = require("./serializers");
|
|
|
34
29
|
function DateAttribute(props) {
|
|
35
30
|
return function (_value, context) {
|
|
36
31
|
context.addInitializer(function () {
|
|
37
|
-
|
|
32
|
+
Metadata.addEntityAttribute(this.constructor.name, {
|
|
38
33
|
attributeName: context.name.toString(),
|
|
39
34
|
kind: "date",
|
|
40
35
|
nullable: props?.nullable,
|
|
41
|
-
serializers:
|
|
42
|
-
type:
|
|
36
|
+
serializers: dateSerializer,
|
|
37
|
+
type: z.date(),
|
|
43
38
|
...props
|
|
44
39
|
});
|
|
45
40
|
});
|
|
46
41
|
};
|
|
47
42
|
}
|
|
48
|
-
|
|
43
|
+
export default DateAttribute;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type DynaRecord from "../../DynaRecord";
|
|
2
|
-
import type { AttributeDecoratorContext, AttributeOptions } from "../types";
|
|
1
|
+
import type DynaRecord from "../../DynaRecord.js";
|
|
2
|
+
import type { AttributeDecoratorContext, AttributeOptions } from "../types.js";
|
|
3
3
|
/**
|
|
4
4
|
* Extends {@link AttributeOptions} but requires that the allowed values are set on `values`
|
|
5
5
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EnumAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/EnumAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"EnumAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/EnumAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAG5D,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,CAAC;CAC/B;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,iBAAS,aAAa,CACpB,CAAC,SAAS,UAAU,EACpB,KAAK,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,EACnC,KAAK,CAAC,CAAC,SAAS,oBAAoB,EACpC,KAAK,EAAE,CAAC,IAEN,QAAQ,SAAS,EACjB,SAAS,yBAAyB,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,UAa9C;AAED,eAAe,aAAa,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const metadata_1 = __importDefault(require("../../metadata"));
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import Metadata from "../../metadata/index.js";
|
|
8
3
|
/**
|
|
9
4
|
* A decorator for marking class fields as enum attributes within the context of a single-table design entity. Only the types specified in `values` are allowed via both the type system and runtime schema checks.
|
|
10
5
|
*
|
|
@@ -29,15 +24,15 @@ const metadata_1 = __importDefault(require("../../metadata"));
|
|
|
29
24
|
function EnumAttribute(props) {
|
|
30
25
|
return function (_value, context) {
|
|
31
26
|
context.addInitializer(function () {
|
|
32
|
-
|
|
27
|
+
Metadata.addEntityAttribute(this.constructor.name, {
|
|
33
28
|
attributeName: context.name.toString(),
|
|
34
29
|
kind: "enum",
|
|
35
30
|
nullable: props.nullable,
|
|
36
|
-
type:
|
|
31
|
+
type: z.enum(props.values),
|
|
37
32
|
enumValues: props.values,
|
|
38
33
|
...props
|
|
39
34
|
});
|
|
40
35
|
});
|
|
41
36
|
};
|
|
42
37
|
}
|
|
43
|
-
|
|
38
|
+
export default EnumAttribute;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type DynaRecord from "../../DynaRecord";
|
|
2
|
-
import type { EntityClass, ForeignKey, NullableForeignKey } from "../../types";
|
|
3
|
-
import type { AttributeDecoratorContext, AttributeOptions } from "../types";
|
|
1
|
+
import type DynaRecord from "../../DynaRecord.js";
|
|
2
|
+
import type { EntityClass, ForeignKey, NullableForeignKey } from "../../types.js";
|
|
3
|
+
import type { AttributeDecoratorContext, AttributeOptions } from "../types.js";
|
|
4
4
|
/**
|
|
5
5
|
* A decorator for annotating class fields as foreign keys within the context of a single-table design entity, aimed at establishing and managing relationships between different entities in a relational manner. This decorator enables the clear and explicit declaration of foreign key relationships, contributing to the ORM's ability to navigate and resolve these associations efficiently.
|
|
6
6
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ForeignKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/ForeignKeyAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"ForeignKeyAttribute.d.ts","sourceRoot":"","sources":["../../../../src/decorators/attributes/ForeignKeyAttribute.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,UAAU,MAAM,qBAAqB,CAAC;AAElD,OAAO,KAAK,EACV,WAAW,EACX,UAAU,EACV,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiCG;AACH,iBAAS,mBAAmB,CAC1B,YAAY,SAAS,UAAU,EAC/B,CAAC,SAAS,UAAU,EACpB,CAAC,SAAS,gBAAgB,EAC1B,SAAS,EAAE,MAAM,WAAW,CAAC,YAAY,CAAC,EAAE,KAAK,CAAC,EAAE,CAAC,IAEnD,QAAQ,SAAS,EACjB,SAAS,yBAAyB,CAChC,CAAC,EACD,CAAC,CAAC,UAAU,CAAC,SAAS,IAAI,GACtB,kBAAkB,CAAC,YAAY,CAAC,GAChC,UAAU,CAAC,YAAY,CAAC,EAC5B,CAAC,CACF,UAeJ;AAED,eAAe,mBAAmB,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const zod_1 = require("zod");
|
|
7
|
-
const metadata_1 = __importDefault(require("../../metadata"));
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import Metadata from "../../metadata/index.js";
|
|
8
3
|
/**
|
|
9
4
|
* A decorator for annotating class fields as foreign keys within the context of a single-table design entity, aimed at establishing and managing relationships between different entities in a relational manner. This decorator enables the clear and explicit declaration of foreign key relationships, contributing to the ORM's ability to navigate and resolve these associations efficiently.
|
|
10
5
|
*
|
|
@@ -43,15 +38,15 @@ function ForeignKeyAttribute(getTarget, props) {
|
|
|
43
38
|
return function (_value, context) {
|
|
44
39
|
context.addInitializer(function () {
|
|
45
40
|
const targetEntity = getTarget();
|
|
46
|
-
|
|
41
|
+
Metadata.addEntityAttribute(this.constructor.name, {
|
|
47
42
|
attributeName: context.name.toString(),
|
|
48
43
|
kind: "foreignKey",
|
|
49
44
|
nullable: props?.nullable,
|
|
50
|
-
type:
|
|
45
|
+
type: z.string(),
|
|
51
46
|
foreignKeyTarget: targetEntity,
|
|
52
47
|
...props
|
|
53
48
|
});
|
|
54
49
|
});
|
|
55
50
|
};
|
|
56
51
|
}
|
|
57
|
-
|
|
52
|
+
export default ForeignKeyAttribute;
|