aws-dynamodb-data-mapper-annotations
Advanced tools
Comparing version 0.7.3-pull-request-167-3 to 0.7.3-pull-request-167-4
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
require("reflect-metadata"); | ||
var constants_1 = require("./constants"); | ||
var dynamodb_auto_marshaller_1 = require("@aws/dynamodb-auto-marshaller"); | ||
var dynamodb_data_mapper_1 = require("@aws/dynamodb-data-mapper"); | ||
const constants_1 = require("./constants"); | ||
const dynamodb_auto_marshaller_1 = require("@aws/dynamodb-auto-marshaller"); | ||
const dynamodb_data_mapper_1 = require("@aws/dynamodb-data-mapper"); | ||
/** | ||
@@ -53,5 +52,4 @@ * Declare a property in a TypeScript class to be part of a DynamoDB schema. | ||
*/ | ||
function attribute(parameters) { | ||
if (parameters === void 0) { parameters = {}; } | ||
return function (target, propertyKey) { | ||
function attribute(parameters = {}) { | ||
return (target, propertyKey) => { | ||
if (!Object.prototype.hasOwnProperty.call(target, dynamodb_data_mapper_1.DynamoDbSchema)) { | ||
@@ -61,3 +59,3 @@ Object.defineProperty(target, dynamodb_data_mapper_1.DynamoDbSchema, // TypeScript complains about the use of symbols here, though it should be allowed | ||
} | ||
var schemaType = metadataToSchemaType(Reflect.getMetadata(constants_1.METADATA_TYPE_KEY, target, propertyKey), parameters); | ||
const schemaType = metadataToSchemaType(Reflect.getMetadata(constants_1.METADATA_TYPE_KEY, target, propertyKey), parameters); | ||
if ((schemaType.keyType || | ||
@@ -72,3 +70,3 @@ schemaType.indexKeyConfigurations) && | ||
].indexOf(schemaType.type) < 0) { | ||
throw new Error("Properties of type " + schemaType.type + " may not be used as index or table keys. If you are relying on automatic type detection and have encountered this error, please ensure that the 'emitDecoratorMetadata' TypeScript compiler option is enabled. Please see https://www.typescriptlang.org/docs/handbook/decorators.html#metadata for more information on this compiler option."); | ||
throw new Error(`Properties of type ${schemaType.type} may not be used as index or table keys. If you are relying on automatic type detection and have encountered this error, please ensure that the 'emitDecoratorMetadata' TypeScript compiler option is enabled. Please see https://www.typescriptlang.org/docs/handbook/decorators.html#metadata for more information on this compiler option.`); | ||
} | ||
@@ -81,7 +79,10 @@ target[dynamodb_data_mapper_1.DynamoDbSchema][propertyKey] = schemaType; | ||
if (target && typeof target === 'object') { | ||
var prototype = Object.getPrototypeOf(target); | ||
const prototype = Object.getPrototypeOf(target); | ||
if (prototype) { | ||
return tslib_1.__assign(tslib_1.__assign({}, deriveBaseSchema(prototype)), Object.prototype.hasOwnProperty.call(prototype, dynamodb_data_mapper_1.DynamoDbSchema) | ||
? prototype[dynamodb_data_mapper_1.DynamoDbSchema] | ||
: {}); | ||
return { | ||
...deriveBaseSchema(prototype), | ||
...Object.prototype.hasOwnProperty.call(prototype, dynamodb_data_mapper_1.DynamoDbSchema) | ||
? prototype[dynamodb_data_mapper_1.DynamoDbSchema] | ||
: {} | ||
}; | ||
} | ||
@@ -92,3 +93,3 @@ } | ||
function metadataToSchemaType(ctor, declaration) { | ||
var type = declaration.type, rest = tslib_1.__rest(declaration, ["type"]); | ||
let { type, ...rest } = declaration; | ||
if (type === undefined) { | ||
@@ -157,3 +158,6 @@ if (ctor) { | ||
} | ||
return tslib_1.__assign(tslib_1.__assign({}, rest), { type: type }); | ||
return { | ||
...rest, | ||
type | ||
}; | ||
} | ||
@@ -160,0 +164,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var hashKey_1 = require("./hashKey"); | ||
var uuid_1 = require("uuid"); | ||
function autoGeneratedHashKey(parameters) { | ||
if (parameters === void 0) { parameters = {}; } | ||
return hashKey_1.hashKey(tslib_1.__assign(tslib_1.__assign({}, parameters), { type: 'String', defaultProvider: uuid_1.v4 })); | ||
const hashKey_1 = require("./hashKey"); | ||
const uuid_1 = require("uuid"); | ||
function autoGeneratedHashKey(parameters = {}) { | ||
return hashKey_1.hashKey({ | ||
...parameters, | ||
type: 'String', | ||
defaultProvider: uuid_1.v4, | ||
}); | ||
} | ||
exports.autoGeneratedHashKey = autoGeneratedHashKey; | ||
//# sourceMappingURL=autoGeneratedHashKey.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var _1 = require("./"); | ||
var dynamodb_data_mapper_1 = require("@aws/dynamodb-data-mapper"); | ||
var Author = /** @class */ (function () { | ||
function Author() { | ||
} | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Author.prototype, "name", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: { type: 'String' } }), | ||
tslib_1.__metadata("design:type", Map) | ||
], Author.prototype, "socialMediaHandles", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Uint8Array) | ||
], Author.prototype, "photo", void 0); | ||
return Author; | ||
}()); | ||
const tslib_1 = require("tslib"); | ||
const _1 = require("./"); | ||
const dynamodb_data_mapper_1 = require("@aws/dynamodb-data-mapper"); | ||
class Author { | ||
} | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Author.prototype, "name", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: { type: 'String' } }), | ||
tslib_1.__metadata("design:type", Map) | ||
], Author.prototype, "socialMediaHandles", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Uint8Array) | ||
], Author.prototype, "photo", void 0); | ||
exports.Author = Author; | ||
var Comment = /** @class */ (function () { | ||
function Comment() { | ||
} | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Date) | ||
], Comment.prototype, "timestamp", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Boolean) | ||
], Comment.prototype, "approved", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Comment.prototype, "subject", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Comment.prototype, "text", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Comment.prototype, "author", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Number) | ||
], Comment.prototype, "upvotes", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Number) | ||
], Comment.prototype, "downvotes", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: dynamodb_data_mapper_1.embed(Comment) }), | ||
tslib_1.__metadata("design:type", Array) | ||
], Comment.prototype, "replies", void 0); | ||
return Comment; | ||
}()); | ||
class Comment { | ||
} | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Date) | ||
], Comment.prototype, "timestamp", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Boolean) | ||
], Comment.prototype, "approved", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Comment.prototype, "subject", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Comment.prototype, "text", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Comment.prototype, "author", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Number) | ||
], Comment.prototype, "upvotes", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Number) | ||
], Comment.prototype, "downvotes", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: dynamodb_data_mapper_1.embed(Comment) }), | ||
tslib_1.__metadata("design:type", Array) | ||
], Comment.prototype, "replies", void 0); | ||
exports.Comment = Comment; | ||
var Post = /** @class */ (function () { | ||
function Post() { | ||
} | ||
tslib_1.__decorate([ | ||
_1.autoGeneratedHashKey(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "id", void 0); | ||
tslib_1.__decorate([ | ||
_1.rangeKey(), | ||
tslib_1.__metadata("design:type", Date) | ||
], Post.prototype, "createdAt", void 0); | ||
tslib_1.__decorate([ | ||
_1.versionAttribute(), | ||
tslib_1.__metadata("design:type", Number) | ||
], Post.prototype, "version", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Author) | ||
], Post.prototype, "author", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "content", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "title", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "subtitle", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "imageLink", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: { type: 'String' } }), | ||
tslib_1.__metadata("design:type", Array) | ||
], Post.prototype, "corrections", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: dynamodb_data_mapper_1.embed(Comment) }), | ||
tslib_1.__metadata("design:type", Array) | ||
], Post.prototype, "replies", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: 'String' }), | ||
tslib_1.__metadata("design:type", Set) | ||
], Post.prototype, "tags", void 0); | ||
Post = tslib_1.__decorate([ | ||
_1.table('Posts') | ||
], Post); | ||
return Post; | ||
}()); | ||
let Post = class Post { | ||
}; | ||
tslib_1.__decorate([ | ||
_1.autoGeneratedHashKey(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "id", void 0); | ||
tslib_1.__decorate([ | ||
_1.rangeKey(), | ||
tslib_1.__metadata("design:type", Date) | ||
], Post.prototype, "createdAt", void 0); | ||
tslib_1.__decorate([ | ||
_1.versionAttribute(), | ||
tslib_1.__metadata("design:type", Number) | ||
], Post.prototype, "version", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", Author) | ||
], Post.prototype, "author", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "content", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "title", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "subtitle", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute(), | ||
tslib_1.__metadata("design:type", String) | ||
], Post.prototype, "imageLink", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: { type: 'String' } }), | ||
tslib_1.__metadata("design:type", Array) | ||
], Post.prototype, "corrections", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: dynamodb_data_mapper_1.embed(Comment) }), | ||
tslib_1.__metadata("design:type", Array) | ||
], Post.prototype, "replies", void 0); | ||
tslib_1.__decorate([ | ||
_1.attribute({ memberType: 'String' }), | ||
tslib_1.__metadata("design:type", Set) | ||
], Post.prototype, "tags", void 0); | ||
Post = tslib_1.__decorate([ | ||
_1.table('Posts') | ||
], Post); | ||
exports.Post = Post; | ||
//# sourceMappingURL=exampleSchema.fixture.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var attribute_1 = require("./attribute"); | ||
function hashKey(parameters) { | ||
if (parameters === void 0) { parameters = {}; } | ||
return attribute_1.attribute(tslib_1.__assign(tslib_1.__assign({}, parameters), { keyType: 'HASH' })); | ||
const attribute_1 = require("./attribute"); | ||
function hashKey(parameters = {}) { | ||
return attribute_1.attribute({ | ||
...parameters, | ||
keyType: 'HASH', | ||
}); | ||
} | ||
exports.hashKey = hashKey; | ||
//# sourceMappingURL=hashKey.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
const tslib_1 = require("tslib"); | ||
tslib_1.__exportStar(require("./attribute"), exports); | ||
@@ -5,0 +5,0 @@ tslib_1.__exportStar(require("./autoGeneratedHashKey"), exports); |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var attribute_1 = require("./attribute"); | ||
function rangeKey(parameters) { | ||
if (parameters === void 0) { parameters = {}; } | ||
return attribute_1.attribute(tslib_1.__assign(tslib_1.__assign({}, parameters), { keyType: 'RANGE' })); | ||
const attribute_1 = require("./attribute"); | ||
function rangeKey(parameters = {}) { | ||
return attribute_1.attribute({ | ||
...parameters, | ||
keyType: 'RANGE', | ||
}); | ||
} | ||
exports.rangeKey = rangeKey; | ||
//# sourceMappingURL=rangeKey.js.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var dynamodb_data_mapper_1 = require("@aws/dynamodb-data-mapper"); | ||
const dynamodb_data_mapper_1 = require("@aws/dynamodb-data-mapper"); | ||
/** | ||
@@ -14,3 +14,3 @@ * Declare a TypeScript class to represent items in a table in a way that is | ||
function table(tableName) { | ||
return function (constructor) { | ||
return constructor => { | ||
constructor.prototype[dynamodb_data_mapper_1.DynamoDbTable] = tableName; | ||
@@ -17,0 +17,0 @@ }; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var attribute_1 = require("./attribute"); | ||
function versionAttribute(parameters) { | ||
if (parameters === void 0) { parameters = {}; } | ||
return attribute_1.attribute(tslib_1.__assign(tslib_1.__assign({}, parameters), { type: 'Number', versionAttribute: true })); | ||
const attribute_1 = require("./attribute"); | ||
function versionAttribute(parameters = {}) { | ||
return attribute_1.attribute({ | ||
...parameters, | ||
type: 'Number', | ||
versionAttribute: true, | ||
}); | ||
} | ||
exports.versionAttribute = versionAttribute; | ||
//# sourceMappingURL=versionAttribute.js.map |
{ | ||
"name": "aws-dynamodb-data-mapper-annotations", | ||
"version": "0.7.3-pull-request-167-3", | ||
"version": "0.7.3-pull-request-167-4", | ||
"description": "Annotations providing easy integration between TypeScript domain objects and the @aws/dynamodb-data-mapper library", | ||
@@ -49,3 +49,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "7cfb733e819ee0a5a3cfc7ee8f1f4222f0ac7954" | ||
"gitHead": "78e82a3c68facefa4d2daebc382340b99ac72954" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
506
44661