@node-ts/bus-mongodb
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -6,3 +6,2 @@ "use strict"; | ||
const error_1 = require("./error"); | ||
const lodash_mapkeys_1 = require("lodash.mapkeys"); | ||
/** | ||
@@ -65,3 +64,3 @@ * The name of the field that stores workflow state as JSON in the database row. | ||
return rows | ||
.map(row => (0, lodash_mapkeys_1.default)(row, (_, key) => denormalizeProperty(key))) | ||
.map(row => mapKeys(row, (key, _) => denormalizeProperty(key))) | ||
.filter(workflowState => workflowState !== undefined) | ||
@@ -78,3 +77,3 @@ .map(workflowState => this.coreDependencies.serializer.toClass(workflowState, workflowStateConstructor)); | ||
const newVersion = oldVersion + 1; | ||
const modifiedState = (0, lodash_mapkeys_1.default)(workflowState, (_, key) => normalizeProperty(key)); | ||
const modifiedState = mapKeys(workflowState, (key, _) => normalizeProperty(key)); | ||
const plainWorkflowState = Object.assign(Object.assign({}, this.coreDependencies.serializer.toPlain(modifiedState)), { __version: newVersion }); | ||
@@ -180,2 +179,9 @@ await this.upsertWorkflowState(collectionName, workflowState.$workflowId, plainWorkflowState, oldVersion, newVersion); | ||
exports.MongodbPersistence = MongodbPersistence; | ||
function mapKeys(obj, fn) { | ||
return Object.keys(obj).reduce((acc, oldKey) => { | ||
const newKey = fn(oldKey, obj[oldKey]); | ||
acc[newKey] = obj[oldKey]; | ||
return acc; | ||
}, {}); | ||
} | ||
/** | ||
@@ -182,0 +188,0 @@ * Returns a legal fully qualified schema + table name |
{ | ||
"name": "@node-ts/bus-mongodb", | ||
"description": "A Mongodb persistence adapter for workflow storage in @node-ts/bus-workflow.", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"license": "MIT", | ||
@@ -14,3 +14,2 @@ "main": "./dist/index.js", | ||
"@node-ts/bus-messages": "^1.0.4", | ||
"lodash.mapkeys": "^4.6.0", | ||
"mongodb": "^5.3.0", | ||
@@ -24,3 +23,2 @@ "tslib": "^1.9.3", | ||
"@types/amqplib": "^0.5.11", | ||
"@types/lodash.mapkeys": "^4.6.7", | ||
"@types/uuid": "^3.4.4", | ||
@@ -27,0 +25,0 @@ "reflect-metadata": "^0.1.13", |
@@ -13,3 +13,2 @@ import { | ||
import { WorkflowStateNotFound } from './error' | ||
import mapKeys from 'lodash.mapkeys' | ||
@@ -103,3 +102,3 @@ /** | ||
return rows | ||
.map(row => mapKeys(row, (_, key) => denormalizeProperty(key))) | ||
.map(row => mapKeys(row, (key, _) => denormalizeProperty(key))) | ||
.filter(workflowState => workflowState !== undefined) | ||
@@ -125,3 +124,3 @@ .map(workflowState => | ||
const newVersion = oldVersion + 1 | ||
const modifiedState = mapKeys(workflowState, (_, key) => | ||
const modifiedState = mapKeys(workflowState, (key, _) => | ||
normalizeProperty(key) | ||
@@ -269,3 +268,9 @@ ) | ||
} | ||
function mapKeys(obj: any, fn: (key: string, value: any) => string) { | ||
return Object.keys(obj).reduce((acc, oldKey) => { | ||
const newKey = fn(oldKey, obj[oldKey]) | ||
acc[newKey] = obj[oldKey] | ||
return acc | ||
}, {} as Record<string, unknown>) | ||
} | ||
/** | ||
@@ -272,0 +277,0 @@ * Returns a legal fully qualified schema + table name |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43048
5
7
816
- Removedlodash.mapkeys@^4.6.0
- Removedlodash.mapkeys@4.6.0(transitive)