@piggly/ddd-toolkit
Advanced tools
Comparing version 3.0.3 to 3.0.4
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.schemaValidator = exports.splitAndTrim = exports.mountURL = exports.toRFC3339 = exports.toMoment = exports.toArray = exports.toJSON = exports.randomString = exports.removeIndex = exports.removeItem = exports.parseToJson = exports.preserve = exports.parseEmpty = exports.getTimestamp = exports.deleteKeys = exports.lastAvailableString = exports.commaStringAsArray = exports.DateParser = exports.BusinessRuleViolationError = exports.InvalidSchemaError = exports.RuntimeError = exports.ApplicationError = exports.DomainError = exports.UseCase = exports.ServiceProvider = exports.InfraService = exports.ApplicationService = exports.DomainService = exports.Service = exports.DomainEvent = exports.Adapter = exports.SchemaValidator = exports.CollectionOfRelatedEntity = exports.MapCollectionOfValueObjects = exports.CollectionOfValueObjects = exports.CollectionOfEntity = exports.AggregateRoot = exports.Result = exports.ValueObject = exports.EntityID = exports.Entity = void 0; | ||
exports.schemaValidator = exports.splitAndTrim = exports.mountURL = exports.toRFC3339 = exports.toMoment = exports.toArray = exports.toJSON = exports.randomString = exports.removeIndex = exports.removeItem = exports.parseToJson = exports.preserve = exports.parseEmpty = exports.getTimestamp = exports.deleteKeys = exports.lastAvailableString = exports.commaStringAsArray = exports.DateParser = exports.InvalidPayloadError = exports.BusinessRuleViolationError = exports.InvalidSchemaError = exports.RuntimeError = exports.ApplicationError = exports.DomainError = exports.UseCase = exports.ServiceProvider = exports.InfraService = exports.ApplicationService = exports.DomainService = exports.Service = exports.DomainEvent = exports.Adapter = exports.SchemaValidator = exports.CollectionOfRelatedEntity = exports.MapCollectionOfValueObjects = exports.CollectionOfValueObjects = exports.CollectionOfEntity = exports.AggregateRoot = exports.Result = exports.ValueObject = exports.EntityID = exports.Entity = void 0; | ||
var Entity_1 = require("./core/Entity.js"); | ||
@@ -50,2 +50,4 @@ Object.defineProperty(exports, "Entity", { enumerable: true, get: function () { return Entity_1.Entity; } }); | ||
Object.defineProperty(exports, "BusinessRuleViolationError", { enumerable: true, get: function () { return BusinessRuleViolationError_1.BusinessRuleViolationError; } }); | ||
var InvalidPayloadError_1 = require("./core/errors/InvalidPayloadError.js"); | ||
Object.defineProperty(exports, "InvalidPayloadError", { enumerable: true, get: function () { return InvalidPayloadError_1.InvalidPayloadError; } }); | ||
var DateParser_1 = require("./utils/parsers/DateParser.js"); | ||
@@ -52,0 +54,0 @@ Object.defineProperty(exports, "DateParser", { enumerable: true, get: function () { return DateParser_1.DateParser; } }); |
@@ -16,3 +16,3 @@ "use strict"; | ||
exports.commaStringAsArray = commaStringAsArray; | ||
const lastAvailableString = (entry, defaultValue) => { | ||
const lastAvailableString = (entry, defaultValue, separator = ',') => { | ||
if (!entry) { | ||
@@ -22,2 +22,8 @@ return defaultValue; | ||
if (Array.isArray(entry) === false) { | ||
if (entry.includes(separator)) { | ||
return (entry | ||
.split(separator) | ||
.map(s => s.trim()) | ||
.pop() ?? defaultValue); | ||
} | ||
return entry; | ||
@@ -24,0 +30,0 @@ } |
@@ -24,4 +24,5 @@ export { Entity } from './core/Entity.js'; | ||
export { BusinessRuleViolationError } from './core/errors/BusinessRuleViolationError.js'; | ||
export { InvalidPayloadError } from './core/errors/InvalidPayloadError.js'; | ||
export { DateParser } from './utils/parsers/DateParser.js'; | ||
export { commaStringAsArray, lastAvailableString, deleteKeys, getTimestamp, parseEmpty, preserve, parseToJson, removeItem, removeIndex, randomString, toJSON, toArray, toMoment, toRFC3339, mountURL, splitAndTrim, schemaValidator, } from './utils/index.js'; | ||
//# sourceMappingURL=index.js.map |
@@ -11,3 +11,3 @@ import moment from 'moment-timezone'; | ||
} | ||
export const lastAvailableString = (entry, defaultValue) => { | ||
export const lastAvailableString = (entry, defaultValue, separator = ',') => { | ||
if (!entry) { | ||
@@ -17,2 +17,8 @@ return defaultValue; | ||
if (Array.isArray(entry) === false) { | ||
if (entry.includes(separator)) { | ||
return (entry | ||
.split(separator) | ||
.map(s => s.trim()) | ||
.pop() ?? defaultValue); | ||
} | ||
return entry; | ||
@@ -19,0 +25,0 @@ } |
@@ -24,2 +24,3 @@ export { Entity } from './core/Entity'; | ||
export { BusinessRuleViolationError } from './core/errors/BusinessRuleViolationError'; | ||
export { InvalidPayloadError } from './core/errors/InvalidPayloadError'; | ||
export { DateParser } from './utils/parsers/DateParser'; | ||
@@ -26,0 +27,0 @@ export { commaStringAsArray, lastAvailableString, deleteKeys, getTimestamp, parseEmpty, preserve, parseToJson, removeItem, removeIndex, randomString, toJSON, toArray, toMoment, toRFC3339, mountURL, splitAndTrim, schemaValidator, } from './utils'; |
@@ -7,3 +7,3 @@ import Joi from 'joi'; | ||
export declare function commaStringAsArray(str?: string): Array<string>; | ||
export declare const lastAvailableString: (entry: string[] | string, defaultValue: string) => string; | ||
export declare const lastAvailableString: (entry: string[] | string, defaultValue: string, separator?: string) => string; | ||
export declare function deleteKeys<T extends Record<string, any>>(obj: T, keys: string[]): Partial<T>; | ||
@@ -10,0 +10,0 @@ export declare function getTimestamp(native?: boolean): number; |
{ | ||
"name": "@piggly/ddd-toolkit", | ||
"version": "3.0.3", | ||
"version": "3.0.4", | ||
"description": "A bunch of tools to use Model-Driven Design and Domain-Driven Design architecture in a back-end application.", | ||
@@ -90,4 +90,4 @@ "scripts": { | ||
"shallow-equal-object": "^1.1.1", | ||
"uuid": "^9.0.1" | ||
"uuid": "^10.0.0" | ||
} | ||
} |
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
251113
154
6576
+ Addeduuid@10.0.0(transitive)
- Removeduuid@9.0.1(transitive)
Updateduuid@^10.0.0