Skip to content

Commit

Permalink
- Added @pristine-ts/metadata dependency.
Browse files Browse the repository at this point in the history
  • Loading branch information
etiennenoel committed Feb 2, 2024
1 parent 8371fdd commit b1740cc
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 29 deletions.
89 changes: 60 additions & 29 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
},
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.10.0",
"@pristine-ts/metadata": "^1.0.6",
"reflect-metadata": "^0.1.13"
},
"peerDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/dynamodb-data-mapper-annotations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"@awslabs-community-fork/dynamodb-auto-marshaller": "^0.7.14",
"@awslabs-community-fork/dynamodb-data-mapper": "^0.7.14",
"@awslabs-community-fork/dynamodb-data-marshaller": "^0.7.14",
"@pristine-ts/metadata": "^1.0.6",
"reflect-metadata": "^0.1.13",
"tslib": "^2.1.0",
"uuid": "^3.0.0"
Expand Down
4 changes: 4 additions & 0 deletions packages/dynamodb-data-mapper-annotations/src/attribute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
SchemaType,
SetType
} from "@awslabs-community-fork/dynamodb-data-marshaller";
import {PropertyMetadata} from "@pristine-ts/metadata";

/**
* Declare a property in a TypeScript class to be part of a DynamoDB schema.
Expand Down Expand Up @@ -60,6 +61,9 @@ export function attribute(
parameters: Partial<SchemaType> = {}
): PropertyAnnotation {
return (target, propertyKey) => {
// Mark the property as seen for @pristine-ts/metadata to automatically register the types.
PropertyMetadata.propertySeen(target, propertyKey);

if (!Object.prototype.hasOwnProperty.call(target, DynamoDbSchema)) {
Object.defineProperty(
target,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {v4} from 'uuid';
export function autoGeneratedHashKey(
parameters: Partial<StringType> = {}
): PropertyAnnotation {

return hashKey({
...parameters,
type: 'String',
Expand Down

0 comments on commit b1740cc

Please sign in to comment.