{"_id":"@block65/dynamodb-data-mapper-annotations","_rev":"5-1e2d4898d2a86989235a6c03ecaba623","name":"@block65/dynamodb-data-mapper-annotations","dist-tags":{"latest":"0.7.4-alpha.2"},"versions":{"0.7.4-alpha.2":{"name":"@block65/dynamodb-data-mapper-annotations","version":"0.7.4-alpha.2","keywords":["aws","dynamodb"],"author":{"name":"AWS SDK for JavaScript Team","email":"aws-sdk-js@amazon.com"},"license":"Apache-2.0","_id":"@block65/dynamodb-data-mapper-annotations@0.7.4-alpha.2","maintainers":[{"name":"maxholman","email":"max@holmn.com"}],"homepage":"https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper-annotations/","bugs":{"url":"https://github.com/awslabs/dynamodb-data-mapper-js/issues"},"dist":{"shasum":"a73ecf94da3f3a67943baf76d33ce88df5fa26cc","tarball":"https://registry.npmjs.org/@block65/dynamodb-data-mapper-annotations/-/dynamodb-data-mapper-annotations-0.7.4-alpha.2.tgz","fileCount":33,"integrity":"sha512-ZSleRRqw2M2ZYLZ25T9vF/aTzvxE0oQXk8fVMIoR5nSbdBJOAbooR7k7ym6NnjGPgrWKKJvCD152awQPZtDVeQ==","signatures":[{"sig":"MEQCIDoh0+kkz9BG3cc06mmhhuhkSqb5aMRNMqrNKrHjy4QsAiBgxC4dEmIsc/+BEps5XsY40ALZgoZfrFsL9pijk5gINQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":45795,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJe/sboCRA9TVsSAnZWagAARccP/iN+3JhTeyJe5fPGCZsx\nql8Rayn1RDtelwxjynb4uru3lTVOJ8QOXbMLg1XzHPG27FU1DkE6SlQQ+rE3\nzKBleUS0XZsas21E5Fb0JWPLlZjpMtzdjkp7SNZYVl3QLlT78MK6BLFgBnU+\nLhmRVVWjrT4FmJHVnJhInsephZo7rkYoa4XXzyHxu1RV4oJn6BtSQCPRXid4\niktKIytqt3mV0Bi7aPL1khPHwJVTMblLDLkrBFplfb7Gn8WaczF3AW0v0QI6\njXpweoXevjsUSL0NkJyNHubP2c/nW7i9jRn1nuLhyVeR9eu8yLuTxhuwBZkn\nPq+rI7RthdT/8f36vlDO1R0yb8uTyThWCn4KlQnBgmzukEeDT12z8OxFNgJF\ndDZLBGtfptIcxsM6Dw0UGp0pGpnib9EhhhOMcrYZ8aRI9zPOCu4ZdXNJk5JD\nxS0vLrW3oTWop+W+rIb4000aSWYq2BOWrzYuk2ZAv9/xvVT3NJZvQVvveora\nYinQRk+kEOSZ2eBVa8U466ZUmcxotkZFfI/sziKlXJ6c8n8cm2a/uP17lLRu\n2Gfy9RwPxzf3nolZ8Y/3dfGxq5uRbQbmGDjZCyis5pcuj9pcW3HrRhyrxDnA\npLxPTwLmQ/2rht5/FSZrRe+KDuVrAEMg67lTX3NrMkGIQ3yGSLg5iK/gQeKz\nabjX\r\n=mwFt\r\n-----END PGP SIGNATURE-----\r\n"},"main":"./build/index.js","types":"./build/index.d.ts","gitHead":"93d0f0f9ee8323106eda6e0e8383923f3e6f3b9a","scripts":{"docs":"typedoc src","test":"jest \"build/(.+).spec.js\"","build":"tsc","integ":"npm run pretest && jest --config=jest.integration.js","pretest":"tsc -p tsconfig.test.json","prepublishOnly":"npm run build"},"_npmUser":{"name":"maxholman","email":"max@holmn.com"},"deprecated":"This package is no longer maintained.","repository":{"url":"git+https://github.com/block65/dynamodb-data-mapper-js.git","type":"git"},"_npmVersion":"lerna/3.22.1/node@v14.5.0+x64 (linux)","description":"Annotations providing easy integration between TypeScript domain objects and the @block65/dynamodb-data-mapper library","directories":{},"_nodeVersion":"14.5.0","dependencies":{"uuid":"^3.0.0","tslib":"^1.9","reflect-metadata":"^0.1.10","@block65/dynamodb-data-mapper":"^0.7.4-alpha.2","@block65/dynamodb-auto-marshaller":"^0.7.4-alpha.2","@block65/dynamodb-data-marshaller":"^0.7.4-alpha.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"jest":"^24","aws-sdk":"^2.7.0","typedoc":"^0.14.0","typescript":"^3.4","@types/jest":"^24","@types/node":"^8.0.4","@types/uuid":"^3.0.0"},"_npmOperationalInternal":{"tmp":"tmp/dynamodb-data-mapper-annotations_0.7.4-alpha.2_1593755367993_0.45121092304060073","host":"s3://npm-registry-packages"}}},"time":{"created":"2020-07-03T05:49:27.839Z","modified":"2026-09-15T09:40:09.503Z","0.7.4-alpha.2":"2020-07-03T05:49:28.131Z"},"bugs":{"url":"https://github.com/awslabs/dynamodb-data-mapper-js/issues"},"author":{"name":"AWS SDK for JavaScript Team","email":"aws-sdk-js@amazon.com"},"license":"Apache-2.0","homepage":"https://awslabs.github.io/dynamodb-data-mapper-js/packages/dynamodb-data-mapper-annotations/","keywords":["aws","dynamodb"],"repository":{"url":"git+https://github.com/block65/dynamodb-data-mapper-js.git","type":"git"},"description":"Annotations providing easy integration between TypeScript domain objects and the @block65/dynamodb-data-mapper library","maintainers":[{"email":"max@holmn.com","name":"maxholman"}],"readme":"# Amazon DynamoDB DataMapper Annotations\n\n[![Apache 2 License](https://img.shields.io/github/license/awslabs/dynamodb-data-mapper-js.svg?style=flat)](http://aws.amazon.com/apache-2-0/)\n\nThis library provides annotations to allow easy integration of domain classes\nwith the `DataMapper` defined in `@block65/dynamodb-data-mapper`. These annotations\nare provided in a separate NPM package because they rely on two experimental\nfeatures of TypeScript (decorators and metadata decoration) and depend on the\n`reflect-metadata` package.\n\n## Getting started\n\nTo use the annotations, you will first need to enable two TypeScript compiler\nsettings: `experimentalDecorators` and `emitDecoratorMetadata`. The former\nenables the use of annotations in your project, and the latter emits type\ninformation about declared property classes.\n\nNext, start adding `table` annotations to the domain models that represent\nrecords in your DynamoDB tables and attribute annotations to the declared\nproperties that map to attributes of those records:\n\n```typescript\nimport {\n    attribute,\n    autoGeneratedHashKey,\n    rangeKey,\n    table,\n    versionAttribute,\n} from '@block65/dynamodb-data-mapper-annotations';\nimport uuidV4 = require('uuid/v4');\n\n@table('my_table')\nclass MyDomainClass {\n    @autoGeneratedHashKey()\n    id: string;\n\n    @rangeKey({defaultProvider: () => new Date()})\n    createdAt: Date;\n\n    @versionAttribute()\n    version: number;\n\n    @attribute()\n    toggle?: boolean;\n\n    @attribute({memberType: 'String'})\n    tags?: Set<string>;\n    \n    // This property will not be saved to DynamoDB.\n    notPersistedToDynamoDb: string;\n}\n```\n\nUsing these annotations will automatically define properties at the\n`DynamoDbSchema` and `DynamoDbTable` symbols on the class prototype, meaning\nthat you can pass instances of the class directly to a `DataMapper` instance. No\nneed to define a schema separately; your class's property type declarations are\nthe schema.\n\nTo declare a class corresponding to a map attribute value in a DynamoDB record,\nsimply omit the `table` annotation:\n\n```typescript\nimport {\n    attribute, \n    hashKey,\n    table,\n} from '@block65/dynamodb-data-mapper-annotations';\nimport {embed} from '@block65/dynamodb-data-mapper';\n\nclass Comment {\n    @attribute()\n    author?: string;\n\n    @attribute()\n    postedAt?: Date;\n\n    @attribute()\n    text?: string;\n}\n\n@table('posts')\nclass BlogPost {\n    @hashKey()\n    id: string;\n\n    @attribute()\n    author?: string;\n\n    @attribute()\n    postedAt?: Date;\n\n    @attribute()\n    text?: string;\n    \n    @attribute({memberType: embed(Comment)})\n    replies?: Array<Comment>\n}\n```\n\n## Supported Annotations\n\n### `attribute`\n\nMarks a property as an attribute in the mapped DynamoDB record. The annotation\nwill attempt to infer the correct DynamoDB type from the TypeScript type\nmetadata, though no metadata will be available for any generic type parameters\nused.\n\n`attribute` must be called as a function and accepts an optional argument\ncontaining a partial or complete field schema definition.\n\n### `autoGeneratedHashKey`\n\nDesignates the property as representing the record's hash key. If no key is\ndefined, a V4 UUID will be used.\n\n`autoGeneratedHashKey` must be called as a function and accepts an optional\nargument containing a partial or complete field schema definition.\n\n### `hashKey`\n\nDesignates the property as representing the record's hash (partition) key.\n\n`hashKey` must be called as a function and accepts an optional argument\ncontaining a partial or complete field schema definition.\n\n### `rangeKey`\n\nDesignates the property as representing the record's range (sort) key.\n\n`rangeKey` must be called as a function and accepts an optional argument\ncontaining a partial or complete field schema definition.\n\n### `table`\n\nDesignates a class as representing a table in DynamoDB.\n\n`table` must be called as a function with that table name as the only argument.\n\n### `versionAttribute`\n\nDesignates the property as representing the record's version attribute. The data\nmapper will use optimistic locking by incrementing the version attribute during\n`put` and `update` operations and sending a condition expression with all `put`,\n`update`, and `delete` operations that will cause the operation to fail if the\nrecord in the database has a version number that does not match the one held by\nthe client.\n\n`versionAttribute` must be called as a function and accepts an optional argument\ncontaining a partial or complete field schema definition.\n\n## Caveats\n\n### Reliance on experimental TypeScript features\n\nBecause this package relies on experimental TypeScript features, it is subject\nto change and should be considered beta software. Decorators are currently on\nthe ECMAScript standards track, but the accepted form may differ from that\nimplemented by TypeScript, which could cause the public interface presented by\nthis project to change.\n\n### Lack of type information in generics\n\nPlease note that TypeScript does not emit any metadata about the type parameters\nsupplied to generic types, so `Array<string>`, `[number, string]`, and \n`MyClass[]` are all exposed as `Array` via the emitted metadata. Without\nadditional metadata, this annotation will treat all encountered arrays as\ncollections of untyped data. You may supply either a `members` declaration or a\n`memberType` declaration to direct this annotation to treat a property as a\ntuple or typed list, respectively.\n\nMember type declarations are required for maps and sets, though the member type\nwill be automatically inferred if a property is declared as being of type\n`BinarySet` or `NumberValueSet` (from the `@block65/dynamodb-auto-marshaller`\npackage).\n","readmeFilename":"README.md"}