UNPKG

@mbc-cqrs-serverless/import

Version:
34 lines 1.09 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ImportEvent = exports.IMPORT_EVENT_ACTION = void 0; const util_dynamodb_1 = require("@aws-sdk/util-dynamodb"); const core_1 = require("@mbc-cqrs-serverless/core"); exports.IMPORT_EVENT_ACTION = 'import-execute'; class ImportEvent { constructor(event) { Object.assign(this, event); } get tableName() { return (0, core_1.getResourceNameFromArn)(this.source); } fromDynamoDBRecord(record) { Object.assign(this, record, { source: record.eventSourceARN, }); return this; } get importEntity() { if (!this._importEntity) { this._importEntity = (0, util_dynamodb_1.unmarshall)(this.dynamodb?.NewImage); } return this._importEntity; } get importKey() { if (!this._importKey) { this._importKey = (0, util_dynamodb_1.unmarshall)(this.dynamodb?.Keys); } return this._importKey; } } exports.ImportEvent = ImportEvent; //# sourceMappingURL=import.event.js.map