UNPKG

@mbc-cqrs-serverless/task

Version:
34 lines 1.06 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TaskEvent = exports.TASK_EVENT_ACTION = void 0; const util_dynamodb_1 = require("@aws-sdk/util-dynamodb"); const core_1 = require("@mbc-cqrs-serverless/core"); exports.TASK_EVENT_ACTION = 'task-execute'; class TaskEvent { 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 taskEntity() { if (!this._taskEntity) { this._taskEntity = (0, util_dynamodb_1.unmarshall)(this.dynamodb?.NewImage); } return this._taskEntity; } get taskKey() { if (!this._taskKey) { this._taskKey = (0, util_dynamodb_1.unmarshall)(this.dynamodb?.Keys); } return this._taskKey; } } exports.TaskEvent = TaskEvent; //# sourceMappingURL=task.event.js.map