@carbonbox/domain 0.1.4 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/carbonbox/emission-calculation-process/calculation-processes/domain/entity/CalculationProcess.js +11 -0
- package/build/carbonbox/shared/either/domain/contracts/IEither.js +2 -0
- package/build/carbonbox/shared/either/domain/contracts/IFunctor.js +2 -0
- package/build/carbonbox/shared/either/domain/contracts/ILeftEither.js +2 -0
- package/build/carbonbox/shared/either/domain/contracts/IMonad.js +2 -0
- package/build/carbonbox/shared/either/domain/contracts/IRightEither.js +2 -0
- package/build/carbonbox/shared/either/domain/exceptions/FilterOperationNotImplementedError.js +17 -0
- package/build/carbonbox/shared/either/domain/exceptions/SwapOperationNotImplementedError.js +17 -0
- package/build/carbonbox/shared/either/domain/factories/EitherFactory.js +88 -0
- package/build/carbonbox/shared/either/domain/factories/ResultFactory.js +123 -0
- package/build/carbonbox/shared/either/domain/implementations/LeftEitherImpl.js +92 -0
- package/build/carbonbox/shared/either/domain/implementations/RightEitherImpl.js +97 -0
- package/build/carbonbox/shared/either/domain/implementations/RightEitherImplNew.js +97 -0
- package/build/carbonbox/shared/either/domain/implementations/RightEitherImplOld.js +89 -0
- package/build/carbonbox/shared/either/domain/types/Result.js +4 -4
- package/build/carbonbox/shared/either/domain/utils/EitherUtils.js +91 -0
- package/build/carbonbox/shared/either/index.js +81 -0
- package/build/main/index.js +20 -15
- package/build/types/carbonbox/shared/either/domain/contracts/Functor.d.ts +2 -2
- package/build/types/carbonbox/shared/either/domain/contracts/Functor.d.ts.map +1 -1
- package/build/types/carbonbox/shared/either/domain/contracts/IEither.d.ts +45 -0
- package/build/types/carbonbox/shared/either/domain/contracts/IEither.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/contracts/IFunctor.d.ts +4 -0
- package/build/types/carbonbox/shared/either/domain/contracts/IFunctor.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/contracts/ILeftEither.d.ts +22 -0
- package/build/types/carbonbox/shared/either/domain/contracts/ILeftEither.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/contracts/IMonad.d.ts +5 -0
- package/build/types/carbonbox/shared/either/domain/contracts/IMonad.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/contracts/IRightEither.d.ts +22 -0
- package/build/types/carbonbox/shared/either/domain/contracts/IRightEither.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/contracts/Monad.d.ts +10 -3
- package/build/types/carbonbox/shared/either/domain/contracts/Monad.d.ts.map +1 -1
- package/build/types/carbonbox/shared/either/domain/exceptions/FilterOperationNotImplementedError.d.ts +7 -0
- package/build/types/carbonbox/shared/either/domain/exceptions/FilterOperationNotImplementedError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/exceptions/SwapOperationNotImplementedError.d.ts +7 -0
- package/build/types/carbonbox/shared/either/domain/exceptions/SwapOperationNotImplementedError.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/factories/EitherFactory.d.ts +36 -0
- package/build/types/carbonbox/shared/either/domain/factories/EitherFactory.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/factories/ResultFactory.d.ts +44 -0
- package/build/types/carbonbox/shared/either/domain/factories/ResultFactory.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/implementations/LeftEitherImpl.d.ts +29 -0
- package/build/types/carbonbox/shared/either/domain/implementations/LeftEitherImpl.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/implementations/RightEitherImpl.d.ts +29 -0
- package/build/types/carbonbox/shared/either/domain/implementations/RightEitherImpl.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/implementations/RightEitherImplNew.d.ts +29 -0
- package/build/types/carbonbox/shared/either/domain/implementations/RightEitherImplNew.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/implementations/RightEitherImplOld.d.ts +29 -0
- package/build/types/carbonbox/shared/either/domain/implementations/RightEitherImplOld.d.ts.map +1 -0
- package/build/types/carbonbox/shared/either/domain/models/Either.d.ts.map +1 -1
- package/build/types/carbonbox/shared/either/domain/types/Result.d.ts +4 -4
- package/build/types/carbonbox/shared/either/domain/types/Result.d.ts.map +1 -1
- package/build/types/carbonbox/shared/either/domain/utils/EitherUtils.d.ts +31 -1
- package/build/types/carbonbox/shared/either/domain/utils/EitherUtils.d.ts.map +1 -1
- package/build/types/carbonbox/shared/either/index.d.ts +57 -0
- package/build/types/carbonbox/shared/either/index.d.ts.map +1 -0
- package/build/types/main/index.d.ts +8 -10
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var _RightEitherImpl_value;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.RightEitherImpl = void 0;
|
|
11
|
+
const CannotAccessLeftOnRightValueError_1 = require("../exceptions/CannotAccessLeftOnRightValueError");
|
|
12
|
+
/**
|
|
13
|
+
* Implementación concreta de RightEither
|
|
14
|
+
* Representa el estado de éxito en el patrón Either
|
|
15
|
+
*/
|
|
16
|
+
class RightEitherImpl {
|
|
17
|
+
constructor(value) {
|
|
18
|
+
this.state = 'right';
|
|
19
|
+
_RightEitherImpl_value.set(this, void 0);
|
|
20
|
+
__classPrivateFieldSet(this, _RightEitherImpl_value, value, "f");
|
|
21
|
+
}
|
|
22
|
+
// ─── Predicados tipo-seguros ─────────────────────────────────────────────────
|
|
23
|
+
get isLeft() {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
get isRight() {
|
|
27
|
+
return true;
|
|
28
|
+
}
|
|
29
|
+
// ─── Métodos de acceso seguros ───────────────────────────────────────────────
|
|
30
|
+
getLeft() {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
getRight() {
|
|
34
|
+
return this.value;
|
|
35
|
+
}
|
|
36
|
+
// ─── Métodos de acceso que lanzan excepción ──────────────────────────────────
|
|
37
|
+
left() {
|
|
38
|
+
throw CannotAccessLeftOnRightValueError_1.CannotAccessLeftOnRightValueError.create(this.value);
|
|
39
|
+
}
|
|
40
|
+
right() {
|
|
41
|
+
return this.value;
|
|
42
|
+
}
|
|
43
|
+
// ─── Transformaciones funcionales ────────────────────────────────────────────
|
|
44
|
+
map(fn) {
|
|
45
|
+
// Aplica la transformación al valor Right
|
|
46
|
+
return new RightEitherImpl(fn(this.value));
|
|
47
|
+
}
|
|
48
|
+
mapLeft(_fn) {
|
|
49
|
+
// No se ejecuta la transformación en Right, solo cambia el tipo
|
|
50
|
+
return new RightEitherImpl(this.value);
|
|
51
|
+
}
|
|
52
|
+
flatMap(fn) {
|
|
53
|
+
// Ejecuta la transformación monádica
|
|
54
|
+
return fn(this.value);
|
|
55
|
+
}
|
|
56
|
+
// ─── Métodos de utilidad ─────────────────────────────────────────────────────
|
|
57
|
+
fold(_onLeft, onRight) {
|
|
58
|
+
return onRight(this.value);
|
|
59
|
+
}
|
|
60
|
+
getOrElse(_fallback) {
|
|
61
|
+
// Retorna el valor Right directamente
|
|
62
|
+
return this.value;
|
|
63
|
+
}
|
|
64
|
+
// ─── Validaciones y filtros ──────────────────────────────────────────────────
|
|
65
|
+
filter(predicate, errorFactory) {
|
|
66
|
+
// Delegado a EitherUtils para evitar dependencia circular
|
|
67
|
+
const { EitherUtils } = require('../utils/EitherUtils');
|
|
68
|
+
return EitherUtils.filter(this, predicate, errorFactory);
|
|
69
|
+
}
|
|
70
|
+
chain(fn) {
|
|
71
|
+
// Alias para flatMap
|
|
72
|
+
return this.flatMap(fn);
|
|
73
|
+
}
|
|
74
|
+
// ─── Conversiones ────────────────────────────────────────────────────────────
|
|
75
|
+
toOptional() {
|
|
76
|
+
return this.value;
|
|
77
|
+
}
|
|
78
|
+
swap() {
|
|
79
|
+
// Delegado a EitherUtils para evitar dependencia circular
|
|
80
|
+
const { EitherUtils } = require('../utils/EitherUtils');
|
|
81
|
+
return EitherUtils.swap(this);
|
|
82
|
+
}
|
|
83
|
+
// ─── Debugging ───────────────────────────────────────────────────────────────
|
|
84
|
+
inspect() {
|
|
85
|
+
return `Right(${JSON.stringify(this.value)})`;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
exports.RightEitherImpl = RightEitherImpl;
|
|
89
|
+
_RightEitherImpl_value = new WeakMap();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Result = void 0;
|
|
4
|
-
const
|
|
4
|
+
const EitherFactory_1 = require("../factories/EitherFactory");
|
|
5
5
|
// eslint-disable-next-line @typescript-eslint/no-redeclare
|
|
6
6
|
var Result;
|
|
7
7
|
(function (Result) {
|
|
8
8
|
// Factory methods
|
|
9
9
|
function fail(error) {
|
|
10
|
-
return
|
|
10
|
+
return EitherFactory_1.EitherFactory.left({ type: 'single', error });
|
|
11
11
|
}
|
|
12
12
|
Result.fail = fail;
|
|
13
13
|
function failMultiple(errors) {
|
|
14
|
-
return
|
|
14
|
+
return EitherFactory_1.EitherFactory.left({ type: 'multiple', errors });
|
|
15
15
|
}
|
|
16
16
|
Result.failMultiple = failMultiple;
|
|
17
17
|
function ok(value) {
|
|
18
|
-
return
|
|
18
|
+
return EitherFactory_1.EitherFactory.right(value);
|
|
19
19
|
}
|
|
20
20
|
Result.ok = ok;
|
|
21
21
|
// Conversiones
|
|
@@ -1,2 +1,93 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EitherUtils = void 0;
|
|
4
|
+
const LeftEitherImpl_1 = require("../implementations/LeftEitherImpl");
|
|
5
|
+
const RightEitherImpl_1 = require("../implementations/RightEitherImpl");
|
|
6
|
+
/**
|
|
7
|
+
* Utilidades para operaciones Either que requieren crear instancias cruzadas
|
|
8
|
+
* Resuelve dependencias circulares centralizando la creación
|
|
9
|
+
*/
|
|
10
|
+
class EitherUtils {
|
|
11
|
+
// ─── Métodos de creación cruzada ─────────────────────────────────────────────
|
|
12
|
+
/** Intercambia Left y Right */
|
|
13
|
+
static swap(either) {
|
|
14
|
+
return either.fold((left) => new RightEitherImpl_1.RightEitherImpl(left), (right) => new LeftEitherImpl_1.LeftEitherImpl(right));
|
|
15
|
+
}
|
|
16
|
+
/** Aplica un filtro creando Left si no pasa */
|
|
17
|
+
static filter(either, predicate, errorFactory) {
|
|
18
|
+
if (either.isLeft === true) {
|
|
19
|
+
return either;
|
|
20
|
+
}
|
|
21
|
+
const value = either.right();
|
|
22
|
+
return predicate(value) === true
|
|
23
|
+
? either
|
|
24
|
+
: new LeftEitherImpl_1.LeftEitherImpl(errorFactory());
|
|
25
|
+
}
|
|
26
|
+
// ─── Métodos de combinación ──────────────────────────────────────────────────
|
|
27
|
+
/** Combina múltiples Either en uno solo - falla en el primer Left */
|
|
28
|
+
static sequence(eithers) {
|
|
29
|
+
const results = [];
|
|
30
|
+
for (const either of eithers) {
|
|
31
|
+
if (either.isLeft === true) {
|
|
32
|
+
return either;
|
|
33
|
+
}
|
|
34
|
+
results.push(either.right());
|
|
35
|
+
}
|
|
36
|
+
return new RightEitherImpl_1.RightEitherImpl(results);
|
|
37
|
+
}
|
|
38
|
+
/** Aplica una función que puede fallar a cada elemento */
|
|
39
|
+
static traverse(items, fn) {
|
|
40
|
+
return EitherUtils.sequence(items.map(fn));
|
|
41
|
+
}
|
|
42
|
+
/** Combina dos Either con una función */
|
|
43
|
+
static lift2(fn, eitherA, eitherB) {
|
|
44
|
+
return eitherA.flatMap((a) => eitherB.map((b) => fn(a, b)));
|
|
45
|
+
}
|
|
46
|
+
/** Combina tres Either con una función */
|
|
47
|
+
static lift3(fn, eitherA, eitherB, eitherC) {
|
|
48
|
+
return eitherA.flatMap((a) => eitherB.flatMap((b) => eitherC.map((c) => fn(a, b, c))));
|
|
49
|
+
}
|
|
50
|
+
/** Acumula errores en lugar de fallar en el primero */
|
|
51
|
+
static accumulate(eithers) {
|
|
52
|
+
const lefts = [];
|
|
53
|
+
const rights = [];
|
|
54
|
+
for (const either of eithers) {
|
|
55
|
+
either.fold((left) => lefts.push(left), (right) => rights.push(right));
|
|
56
|
+
}
|
|
57
|
+
return lefts.length > 0
|
|
58
|
+
? new LeftEitherImpl_1.LeftEitherImpl(lefts)
|
|
59
|
+
: new RightEitherImpl_1.RightEitherImpl(rights);
|
|
60
|
+
}
|
|
61
|
+
// ─── Métodos de validación y transformación ─────────────────────────────────
|
|
62
|
+
/** Ejecuta Either en paralelo y acumula todos los errores */
|
|
63
|
+
static async parallel(operations) {
|
|
64
|
+
const results = await Promise.all(operations.map((op) => op()));
|
|
65
|
+
return EitherUtils.accumulate(results);
|
|
66
|
+
}
|
|
67
|
+
/** Aplica una transformación solo si se cumple una condición */
|
|
68
|
+
static when(condition, transform) {
|
|
69
|
+
return (either) => {
|
|
70
|
+
if (condition !== true || either.isLeft === true) {
|
|
71
|
+
return either;
|
|
72
|
+
}
|
|
73
|
+
return either.flatMap(transform);
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/** Aplica una transformación solo si NO se cumple una condición */
|
|
77
|
+
static unless(condition, transform) {
|
|
78
|
+
return EitherUtils.when(condition !== true, transform);
|
|
79
|
+
}
|
|
80
|
+
// ─── Métodos de depuración ───────────────────────────────────────────────────
|
|
81
|
+
/** Ejecuta una función de side-effect sin afectar el Either */
|
|
82
|
+
static tap(either, onLeft, onRight) {
|
|
83
|
+
either.fold((left) => onLeft?.(left), (right) => onRight?.(right));
|
|
84
|
+
return either;
|
|
85
|
+
}
|
|
86
|
+
/** Log del estado del Either */
|
|
87
|
+
static log(either, prefix = 'Either') {
|
|
88
|
+
// eslint-disable-next-line no-console
|
|
89
|
+
console.log(`${prefix}:`, either.inspect());
|
|
90
|
+
return either;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.EitherUtils = EitherUtils;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// =============================================================================
|
|
3
|
+
// EITHER PATTERN - PUNTO DE ENTRADA PRINCIPAL
|
|
4
|
+
// =============================================================================
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.IS_REFACTORED = exports.EITHER_VERSION = exports.ResultUtils = exports.RightEither = exports.LeftEither = exports.Either = exports.CannotAccessRightOnLeftValueError = exports.CannotAccessLeftOnRightValueError = exports.ResultExtensions = exports.EitherUtils = exports.ResultFactory = exports.EitherFactory = exports.RightEitherImpl = exports.LeftEitherImpl = void 0;
|
|
7
|
+
exports.configureEither = configureEither;
|
|
8
|
+
exports.getEitherConfig = getEitherConfig;
|
|
9
|
+
// ─── Imports para compatibilidad ────────────────────────────────────────────
|
|
10
|
+
const ResultFactory_1 = require("./domain/factories/ResultFactory");
|
|
11
|
+
// ─── Implementaciones principales ────────────────────────────────────────────
|
|
12
|
+
var LeftEitherImpl_1 = require("./domain/implementations/LeftEitherImpl");
|
|
13
|
+
Object.defineProperty(exports, "LeftEitherImpl", { enumerable: true, get: function () { return LeftEitherImpl_1.LeftEitherImpl; } });
|
|
14
|
+
var RightEitherImpl_1 = require("./domain/implementations/RightEitherImpl");
|
|
15
|
+
Object.defineProperty(exports, "RightEitherImpl", { enumerable: true, get: function () { return RightEitherImpl_1.RightEitherImpl; } });
|
|
16
|
+
// ─── Factories ───────────────────────────────────────────────────────────────
|
|
17
|
+
var EitherFactory_1 = require("./domain/factories/EitherFactory");
|
|
18
|
+
Object.defineProperty(exports, "EitherFactory", { enumerable: true, get: function () { return EitherFactory_1.EitherFactory; } });
|
|
19
|
+
var ResultFactory_2 = require("./domain/factories/ResultFactory");
|
|
20
|
+
Object.defineProperty(exports, "ResultFactory", { enumerable: true, get: function () { return ResultFactory_2.ResultFactory; } });
|
|
21
|
+
// ─── Utilidades ──────────────────────────────────────────────────────────────
|
|
22
|
+
var EitherUtils_1 = require("./domain/utils/EitherUtils");
|
|
23
|
+
Object.defineProperty(exports, "EitherUtils", { enumerable: true, get: function () { return EitherUtils_1.EitherUtils; } });
|
|
24
|
+
var ResultExtensions_1 = require("./domain/utils/ResultExtensions");
|
|
25
|
+
Object.defineProperty(exports, "ResultExtensions", { enumerable: true, get: function () { return ResultExtensions_1.ResultExtensions; } });
|
|
26
|
+
// ─── Excepciones ─────────────────────────────────────────────────────────────
|
|
27
|
+
var CannotAccessLeftOnRightValueError_1 = require("./domain/exceptions/CannotAccessLeftOnRightValueError");
|
|
28
|
+
Object.defineProperty(exports, "CannotAccessLeftOnRightValueError", { enumerable: true, get: function () { return CannotAccessLeftOnRightValueError_1.CannotAccessLeftOnRightValueError; } });
|
|
29
|
+
var CannotAccessRightOnLeftValueError_1 = require("./domain/exceptions/CannotAccessRightOnLeftValueError");
|
|
30
|
+
Object.defineProperty(exports, "CannotAccessRightOnLeftValueError", { enumerable: true, get: function () { return CannotAccessRightOnLeftValueError_1.CannotAccessRightOnLeftValueError; } });
|
|
31
|
+
// =============================================================================
|
|
32
|
+
// COMPATIBILIDAD CON API EXISTENTE
|
|
33
|
+
// =============================================================================
|
|
34
|
+
// ─── Alias para mantener compatibilidad ─────────────────────────────────────
|
|
35
|
+
var EitherFactory_2 = require("./domain/factories/EitherFactory");
|
|
36
|
+
Object.defineProperty(exports, "Either", { enumerable: true, get: function () { return EitherFactory_2.EitherFactory; } });
|
|
37
|
+
var LeftEitherImpl_2 = require("./domain/implementations/LeftEitherImpl");
|
|
38
|
+
Object.defineProperty(exports, "LeftEither", { enumerable: true, get: function () { return LeftEitherImpl_2.LeftEitherImpl; } });
|
|
39
|
+
var RightEitherImpl_2 = require("./domain/implementations/RightEitherImpl");
|
|
40
|
+
Object.defineProperty(exports, "RightEither", { enumerable: true, get: function () { return RightEitherImpl_2.RightEitherImpl; } });
|
|
41
|
+
// ─── Namespace Result para compatibilidad ───────────────────────────────────
|
|
42
|
+
var ResultUtils;
|
|
43
|
+
(function (ResultUtils) {
|
|
44
|
+
ResultUtils.fail = ResultFactory_1.ResultFactory.fail;
|
|
45
|
+
ResultUtils.failMultiple = ResultFactory_1.ResultFactory.failMultiple;
|
|
46
|
+
ResultUtils.ok = ResultFactory_1.ResultFactory.ok;
|
|
47
|
+
ResultUtils.fromEither = ResultFactory_1.ResultFactory.fromEither;
|
|
48
|
+
ResultUtils.fromEitherMultiple = ResultFactory_1.ResultFactory.fromEitherMultiple;
|
|
49
|
+
ResultUtils.fromNullable = ResultFactory_1.ResultFactory.fromNullable;
|
|
50
|
+
ResultUtils.fromCondition = ResultFactory_1.ResultFactory.fromCondition;
|
|
51
|
+
ResultUtils.fromTryCatch = ResultFactory_1.ResultFactory.fromTryCatch;
|
|
52
|
+
ResultUtils.fromPromise = ResultFactory_1.ResultFactory.fromPromise;
|
|
53
|
+
ResultUtils.sequence = ResultFactory_1.ResultFactory.sequence;
|
|
54
|
+
ResultUtils.traverse = ResultFactory_1.ResultFactory.traverse;
|
|
55
|
+
ResultUtils.accumulate = ResultFactory_1.ResultFactory.accumulate;
|
|
56
|
+
ResultUtils.parallel = ResultFactory_1.ResultFactory.parallel;
|
|
57
|
+
ResultUtils.chain = ResultFactory_1.ResultFactory.chain;
|
|
58
|
+
ResultUtils.validate = ResultFactory_1.ResultFactory.validate;
|
|
59
|
+
ResultUtils.when = ResultFactory_1.ResultFactory.when;
|
|
60
|
+
ResultUtils.unless = ResultFactory_1.ResultFactory.unless;
|
|
61
|
+
})(ResultUtils || (exports.ResultUtils = ResultUtils = {}));
|
|
62
|
+
let globalConfig = {
|
|
63
|
+
enableLogging: false,
|
|
64
|
+
logPrefix: 'Either',
|
|
65
|
+
debugMode: false,
|
|
66
|
+
};
|
|
67
|
+
/** Configura el comportamiento global de Either */
|
|
68
|
+
function configureEither(config) {
|
|
69
|
+
globalConfig = { ...globalConfig, ...config };
|
|
70
|
+
}
|
|
71
|
+
/** Obtiene la configuración actual */
|
|
72
|
+
function getEitherConfig() {
|
|
73
|
+
return { ...globalConfig };
|
|
74
|
+
}
|
|
75
|
+
// =============================================================================
|
|
76
|
+
// EXPORTS FINALES
|
|
77
|
+
// =============================================================================
|
|
78
|
+
/** Versión del paquete Either */
|
|
79
|
+
exports.EITHER_VERSION = '2.0.0';
|
|
80
|
+
/** Flag para indicar que se está usando la versión refactorizada */
|
|
81
|
+
exports.IS_REFACTORED = true;
|
package/build/main/index.js
CHANGED
|
@@ -9,11 +9,11 @@ exports.EmissionFactorGreenhouseGasValues = exports.EmissionFactorDescription =
|
|
|
9
9
|
exports.EmissionCalculationStatus = exports.EmissionCalculationId = exports.GHGEmissionResult = exports.EmissionAggregation = exports.EmissionCalculation = exports.WorkflowTrigger = exports.WorkflowStatus = exports.ProcessStatus = exports.ProcessPriority = exports.JobType = exports.JobStatus = exports.CalculationWorkflowCarbonClient = exports.CalculationWorkflowFootprintType = exports.CalculationWorkflowIsAutomatic = exports.CalculationWorkflowTriggerType = exports.CalculationWorkflowStatus = exports.CalculationWorkflowDescription = exports.CalculationWorkflowName = exports.CalculationWorkflowCode = exports.CalculationWorkflowId = exports.CalculationProcessCarbonClient = exports.CalculationProcessFootprintConfiguration = exports.CalculationProcessCompletedAt = exports.CalculationProcessStartedAt = exports.CalculationProcessProgressPercentage = exports.CalculationProcessPriority = exports.CalculationProcessStatus = exports.CalculationProcessId = exports.CalculationJobSequenceOrder = exports.CalculationJobParentProcess = exports.CalculationJobCompletedAt = exports.CalculationJobStartedAt = exports.CalculationJobProgressPercentage = exports.CalculationJobStatus = exports.CalculationJobType = exports.CalculationJobId = exports.CalculationWorkflow = exports.CalculationProcess = exports.CalculationJob = exports.UnauthorizedFormulaCreationRoleError = exports.InvalidGreenhouseGasTypeError = exports.DuplicateGreenhouseGasError = exports.ResultUnit = exports.FormulaStatus = exports.GlobalWarmingPotentialGreenhouseGasPotentials = exports.GlobalWarmingPotentialValidityPeriod = exports.GlobalWarmingPotentialTimeHorizonYears = exports.GlobalWarmingPotentialProtocolVersion = exports.GlobalWarmingPotentialReferenceName = exports.GlobalWarmingPotentialId = void 0;
|
|
10
10
|
exports.ServiceCategory = exports.ServiceDescription = exports.ServiceName = exports.ServiceCode = exports.ServiceId = exports.PurchaseOrderTotalAmount = exports.PurchaseOrderSubtotalAmount = exports.PurchaseOrderPaymentStatus = exports.PurchaseOrderPaymentMethod = exports.PurchaseOrderDate = exports.PurchaseOrderCarbonClientId = exports.PurchaseOrderStatus = exports.PurchaseOrderCode = exports.PurchaseOrderId = exports.PurchaseContractCreatedByStakeholder = exports.PurchaseContractTotalContractValue = exports.PurchaseContractEndDate = exports.PurchaseContractStartDate = exports.PurchaseContractCarbonClientId = exports.PurchaseContractType = exports.PurchaseContractStatus = exports.PurchaseContractTitle = exports.PurchaseContractCode = exports.PurchaseContractId = exports.ServicePricing = exports.Service = exports.PurchaseOrder = exports.PurchaseContract = exports.UnknownGreenhouseGasCategoryError = exports.CalculationStatus = exports.GHGEmissionResultUnit = exports.GHGEmissionResultCo2Equivalent = exports.GHGEmissionResultRawEmission = exports.GHGEmissionResultGlobalWarmingPotential = exports.GHGEmissionResultEmissionFactor = exports.GHGEmissionResultActivityValue = exports.GHGEmissionResultGreenhouseGas = exports.GHGEmissionResultEmissionCalculation = exports.GHGEmissionResultId = exports.EmissionAggregationGhgBreakdown = exports.EmissionAggregationUncertaintyPercentage = exports.EmissionAggregationTotalCO2Equivalent = exports.EmissionAggregationEmissionSource = exports.EmissionAggregationEmissionCalculation = exports.EmissionAggregationId = exports.EmissionCalculationCalculatedByStakeholder = exports.EmissionCalculationCalculatedAt = exports.EmissionCalculationCarbonClient = exports.EmissionCalculationEmissionCalculationFormula = exports.EmissionCalculationActivityDataSubmission = void 0;
|
|
11
11
|
exports.InvalidMarkupPercentageError = exports.InvalidDiscountPercentageError = exports.InvalidUserRoleError = exports.InvalidServiceTypeError = exports.InvalidServiceStatusError = exports.InvalidServiceCategoryError = exports.InvalidReportTypeError = exports.InvalidExpertDedicationLevelError = exports.InvalidTotalAmountFactorError = exports.InvalidTaxAmountFactorError = exports.InvalidSubtotalAmountFactorError = exports.InvalidSubtotalAmountError = exports.InvalidPurchaseOrderStatusError = exports.InvalidPercentageRangeError = exports.InvalidPaymentStatusError = exports.InvalidPaymentMethodError = exports.InvalidMaximumSubtotalError = exports.InvalidFixedDiscountAmountError = exports.InvalidDiscountAmountFactorError = exports.InvalidTaxRateError = exports.InvalidPaymentTermsError = exports.InvalidPaymentScheduleError = exports.InvalidContractValueFactorError = exports.InvalidContractTypeError = exports.InvalidContractStatusError = exports.PricingStatus = exports.PricingModel = exports.UserRole = exports.ReportType = exports.ExpertDedicationLevel = exports.ServiceStatusEnum = exports.ServiceTypeEnum = exports.ServiceCategoryEnum = exports.PaymentStatus = exports.PaymentMethod = exports.OrderStatus = exports.PaymentTerms = exports.PaymentSchedule = exports.ContractDurationUnit = exports.ContractType = exports.ContractStatus = exports.ServicePricingCurrency = exports.ServicePricingPricePerUnit = exports.ServicePricingBasePrice = exports.ServicePricingPricingStatus = exports.ServicePricingPricingModel = exports.ServicePricingService = exports.ServicePricingId = exports.ServiceStatus = exports.ServiceType = void 0;
|
|
12
|
-
exports.
|
|
13
|
-
exports.
|
|
14
|
-
exports.
|
|
15
|
-
exports.
|
|
16
|
-
exports.DateTimeFormattingDomainService = exports.InvalidCarbonCoordinatorAvailabilityStatusError = exports.InvalidCarbonClientAccountTypeError = exports.InvalidStakeholderBusinessStatusError = exports.CarbonCoordinatorAvailabilityStatusEnum = void 0;
|
|
12
|
+
exports.StringList = exports.CodeList = exports.AggregateIdList = exports.TaxIdentification = exports.Gender = exports.Currency = exports.ColombiaNIT = exports.TaxIdentificationNumber = exports.ExecutionPeriod = exports.AggregateId = exports.Code = exports.Url = exports.Image = exports.Address = exports.Phone = exports.Email = exports.DateTimeString = exports.DateString = exports.Boolean = exports.Numeric = exports.PositiveInteger = exports.Integer = exports.String = exports.TaxIdentificationType = exports.SystemBoundary = exports.StakeholderRole = exports.ReportingStandard = exports.ISOCategory = exports.GreenhouseGas = exports.GenderType = exports.GHGSubScope = exports.GHGScope = exports.EmissionSourceType = exports.EmissionCategory = exports.DayOfWeek = exports.CurrencyCode = exports.CountryCode = exports.BusinessScale = exports.RootError = exports.ObjectValueObject = exports.PrimitiveValueObject = exports.ValueObject = exports.User = exports.DomainError = exports.AggregateRoot = exports.InvalidUnitsError = exports.InvalidTaxPercentageError = exports.InvalidPricingStatusError = exports.InvalidPricingModelError = exports.InvalidPricePerUnitError = void 0;
|
|
13
|
+
exports.ProductConfigurationCarbonFootprintSegmentReference = exports.ProductCarbonFootprintSegmentConfigurationReferences = exports.FacilityReference = exports.EventReference = exports.EventEditionReferences = exports.EventEditionReference = exports.EventEditionLifecycleStageReference = exports.EventEditionLifecycleStageConfigurationReferences = exports.EventEditionConfigurationCarbonFootprintSubsegmentReferences = exports.EventEditionConfigurationCarbonFootprintSubsegmentReference = exports.CorporateConfigurationCarbonFootprintSubsegmentReference = exports.CorporateConfigurationCarbonFootprintSegmentReference = exports.CorporateCarbonFootprintSegmentConfigurationReferences = exports.CollectionFieldReference = exports.CarbonFootprintSegmentReferences = exports.CarbonFootprintIntensityIndicatorReference = exports.CarbonFootprintConfigurationReference = exports.GlobalWarmingPotentialReference = exports.EmissionFactorReference = exports.EmissionCalculationFormulaReference = exports.EmissionCalculationReference = exports.CalculationVariableReferences = exports.CalculationProcessReference = exports.ActivityDataSubmissionReference = exports.EmissionSource = exports.EmissionSources = exports.CarbonClientReferences = exports.CarbonClientReference = exports.StakeholderReferences = exports.StakeholderReference = exports.UserLastAccessAt = exports.UserAvatar = exports.UserPassword = exports.UserDisplayName = exports.UserId = exports.UserEmail = exports.NullableProductConfigurationCarbonFootprintSubsegmentReference = exports.NullableEventEditionConfigurationCarbonFootprintSubsegmentReference = exports.NullableCorporateConfigurationCarbonFootprintSubsegmentReference = exports.NullableStakeholderReference = exports.NullableColombianNIT = exports.NullableTaxIdentificationNumber = exports.NullablePositiveInteger = exports.NullableNumeric = exports.NullableDateTimeString = exports.NullableDate = exports.NullableCode = exports.NullableString = exports.TaxIdentificationNumberList = exports.UrlList = void 0;
|
|
14
|
+
exports.InvalidMinutesDurationError = exports.InvalidMeasurementUnitOperationError = exports.InvalidManagedStakeholderRoleError = exports.InvalidDomainCodeError = exports.InvalidCountrySpecificTaxIdentificationNumberError = exports.InvalidCodeError = exports.InvalidAssignerRoleError = exports.InvalidAggregateIdError = exports.EmptyTaxIdentificationNumberError = exports.EmptySegmentNameError = exports.EmptySegmentCodeError = exports.EmptyDisplayNameError = exports.DateGreaterThanError = exports.DivisionByZeroError = exports.MoneyOverflowError = exports.NotIntegerError = exports.NegativeAmountError = exports.MinimumValueViolationError = exports.InvalidUrlListError = exports.InvalidCodeListError = exports.InvalidStringListError = exports.EmptyArrayNotAllowedError = exports.PasswordPolicyViolationError = exports.InvalidNationalNumberError = exports.InvalidFullInternationalNumberError = exports.InvalidEmailPolicyError = exports.InvalidCoordinatesError = exports.InvalidTimeFormatError = exports.InvalidDateRangeError = exports.InvalidDateFormatError = exports.InvalidColombianNITNumberError = exports.InvalidColombianNITCheckDigitError = exports.InvalidColombianNITFormatError = exports.InvalidTaxIdentificationTypeError = exports.InvalidStakeholderRoleTypeError = exports.InvalidGenderError = exports.InvalidCurrencyError = exports.InvalidCountryCodeError = exports.InvalidBusinessScaleError = exports.InvalidPropertyValueError = exports.InvalidPropertyTypeError = exports.InvalidValueObjectConfigurationError = exports.UndefinedValueError = exports.NullValueError = exports.MethodNotImplementedError = exports.CreateMethodNotImplementedError = exports.ServiceReference = exports.ProductReference = exports.ProductConfigurationSystemBoundaryReference = exports.ProductConfigurationCarbonFootprintSubsegmentReference = void 0;
|
|
15
|
+
exports.CarbonManagerId = exports.CarbonHostDisplayName = exports.CarbonHostEmail = exports.CarbonHostId = exports.CarbonCoordinatorManagedCarbonClients = exports.CarbonCoordinatorWeeklyWorkingSchedule = exports.CarbonCoordinatorGender = exports.CarbonCoordinatorAvailabilityStatus = exports.CarbonCoordinatorDisplayName = exports.CarbonCoordinatorEmail = exports.CarbonCoordinatorId = exports.CarbonClientPrimaryContactPhone = exports.CarbonClientPrimaryContactEmail = exports.CarbonClientLogo = exports.CarbonClientWebsiteUrl = exports.CarbonClientPhysicalAddress = exports.CarbonClientOrganizationSize = exports.CarbonClientIndustryType = exports.CarbonClientLegalBusinessName = exports.CarbonClientAccountType = exports.CarbonClientDisplayName = exports.CarbonClientEmail = exports.CarbonClientId = exports.StakeholderLastAccessAt = exports.StakeholderAvatar = exports.StakeholderTaxIdentification = exports.StakeholderRoleType = exports.StakeholderBusinessStatus = exports.StakeholderPassword = exports.StakeholderDisplayName = exports.StakeholderEmail = exports.StakeholderId = exports.CarbonManager = exports.CarbonHost = exports.CarbonCoordinator = exports.CarbonClient = exports.Stakeholder = exports.CannotAccessRightOnLeftValueError = exports.CannotAccessLeftOnRightValueError = exports.ResultExtensions = exports.EitherUtils = exports.ResultFactory = exports.EitherFactory = exports.RightEither = exports.LeftEither = exports.Either = exports.TaxIdentificationNumberWithControlCharactersError = exports.InvalidTaxIdentificationNumberLengthError = exports.InvalidTaxIdentificationNumberFormatError = exports.InvalidSupervisorRoleError = void 0;
|
|
16
|
+
exports.DateTimeFormattingDomainService = exports.InvalidCarbonCoordinatorAvailabilityStatusError = exports.InvalidCarbonClientAccountTypeError = exports.InvalidStakeholderBusinessStatusError = exports.CarbonCoordinatorAvailabilityStatusEnum = exports.CarbonClientAccount = exports.StakeholderBusinessStatusEnum = exports.CarbonManagerManagedStakeholders = exports.CarbonManagerDisplayName = exports.CarbonManagerEmail = void 0;
|
|
17
17
|
// ─── Entity Classes (For Application Layer) ─────────────────────────────────
|
|
18
18
|
var ActivityDataSubmission_1 = require("../carbonbox/activity-data-collection/activity-data-submissions/domain/entity/ActivityDataSubmission");
|
|
19
19
|
Object.defineProperty(exports, "ActivityDataSubmission", { enumerable: true, get: function () { return ActivityDataSubmission_1.ActivityDataSubmission; } });
|
|
@@ -735,6 +735,8 @@ var PrimitiveValueObject_1 = require("../carbonbox/shared/domain/value-objects/P
|
|
|
735
735
|
Object.defineProperty(exports, "PrimitiveValueObject", { enumerable: true, get: function () { return PrimitiveValueObject_1.PrimitiveValueObject; } });
|
|
736
736
|
var ObjectValueObject_1 = require("../carbonbox/shared/domain/value-objects/ObjectValueObject");
|
|
737
737
|
Object.defineProperty(exports, "ObjectValueObject", { enumerable: true, get: function () { return ObjectValueObject_1.ObjectValueObject; } });
|
|
738
|
+
var RootError_1 = require("../carbonbox/shared/domain/exceptions/RootError");
|
|
739
|
+
Object.defineProperty(exports, "RootError", { enumerable: true, get: function () { return RootError_1.RootError; } });
|
|
738
740
|
// ─── Shared Enums (Business Rules) ───────────────────────────────────────────
|
|
739
741
|
var BusinessScale_1 = require("../carbonbox/shared/domain/enums/BusinessScale");
|
|
740
742
|
Object.defineProperty(exports, "BusinessScale", { enumerable: true, get: function () { return BusinessScale_1.BusinessScale; } });
|
|
@@ -1035,17 +1037,20 @@ Object.defineProperty(exports, "InvalidTaxIdentificationNumberLengthError", { en
|
|
|
1035
1037
|
var TaxIdentificationNumberWithControlCharactersError_1 = require("../carbonbox/shared/domain/exceptions/TaxIdentificationNumberWithControlCharactersError");
|
|
1036
1038
|
Object.defineProperty(exports, "TaxIdentificationNumberWithControlCharactersError", { enumerable: true, get: function () { return TaxIdentificationNumberWithControlCharactersError_1.TaxIdentificationNumberWithControlCharactersError; } });
|
|
1037
1039
|
// ─── Either Pattern (Functional Exception Handling) ─────────────────────────
|
|
1038
|
-
var
|
|
1039
|
-
Object.defineProperty(exports, "Either", { enumerable: true, get: function () { return
|
|
1040
|
-
|
|
1041
|
-
Object.defineProperty(exports, "
|
|
1042
|
-
var
|
|
1043
|
-
Object.defineProperty(exports, "
|
|
1040
|
+
var either_1 = require("../carbonbox/shared/either");
|
|
1041
|
+
Object.defineProperty(exports, "Either", { enumerable: true, get: function () { return either_1.Either; } });
|
|
1042
|
+
Object.defineProperty(exports, "LeftEither", { enumerable: true, get: function () { return either_1.LeftEither; } });
|
|
1043
|
+
Object.defineProperty(exports, "RightEither", { enumerable: true, get: function () { return either_1.RightEither; } });
|
|
1044
|
+
var either_2 = require("../carbonbox/shared/either");
|
|
1045
|
+
Object.defineProperty(exports, "EitherFactory", { enumerable: true, get: function () { return either_2.EitherFactory; } });
|
|
1046
|
+
Object.defineProperty(exports, "ResultFactory", { enumerable: true, get: function () { return either_2.ResultFactory; } });
|
|
1047
|
+
var either_3 = require("../carbonbox/shared/either");
|
|
1048
|
+
Object.defineProperty(exports, "EitherUtils", { enumerable: true, get: function () { return either_3.EitherUtils; } });
|
|
1049
|
+
Object.defineProperty(exports, "ResultExtensions", { enumerable: true, get: function () { return either_3.ResultExtensions; } });
|
|
1044
1050
|
// Either Pattern Exceptions
|
|
1045
|
-
var
|
|
1046
|
-
Object.defineProperty(exports, "CannotAccessLeftOnRightValueError", { enumerable: true, get: function () { return
|
|
1047
|
-
|
|
1048
|
-
Object.defineProperty(exports, "CannotAccessRightOnLeftValueError", { enumerable: true, get: function () { return CannotAccessRightOnLeftValueError_1.CannotAccessRightOnLeftValueError; } });
|
|
1051
|
+
var either_4 = require("../carbonbox/shared/either");
|
|
1052
|
+
Object.defineProperty(exports, "CannotAccessLeftOnRightValueError", { enumerable: true, get: function () { return either_4.CannotAccessLeftOnRightValueError; } });
|
|
1053
|
+
Object.defineProperty(exports, "CannotAccessRightOnLeftValueError", { enumerable: true, get: function () { return either_4.CannotAccessRightOnLeftValueError; } });
|
|
1049
1054
|
var Stakeholder_1 = require("../carbonbox/stakeholders/shared/domain/entity/Stakeholder");
|
|
1050
1055
|
Object.defineProperty(exports, "Stakeholder", { enumerable: true, get: function () { return Stakeholder_1.Stakeholder; } });
|
|
1051
1056
|
var CarbonClient_1 = require("../carbonbox/stakeholders/carbon-clients/domain/entity/CarbonClient");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Functor.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/Functor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"Functor.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/Functor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;CAC1C"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { IMonad } from './IMonad';
|
|
2
|
+
import { EitherState } from '../types/EitherState';
|
|
3
|
+
/**
|
|
4
|
+
* Interface principal para el patrón Either
|
|
5
|
+
* Representa una computación que puede resultar en éxito (Right) o fallo (Left)
|
|
6
|
+
*/
|
|
7
|
+
export interface IEither<L, R> extends IMonad<R> {
|
|
8
|
+
/** Estado interno del Either (left o right) */
|
|
9
|
+
readonly state: EitherState;
|
|
10
|
+
/** Indica si este Either contiene un valor Left */
|
|
11
|
+
readonly isLeft: boolean;
|
|
12
|
+
/** Indica si este Either contiene un valor Right */
|
|
13
|
+
readonly isRight: boolean;
|
|
14
|
+
/** Obtiene el valor Left de forma segura (puede ser undefined) */
|
|
15
|
+
getLeft(): L | undefined;
|
|
16
|
+
/** Obtiene el valor Right de forma segura (puede ser undefined) */
|
|
17
|
+
getRight(): R | undefined;
|
|
18
|
+
/** Obtiene el valor Left (lanza excepción si es Right) */
|
|
19
|
+
left(): L;
|
|
20
|
+
/** Obtiene el valor Right (lanza excepción si es Left) */
|
|
21
|
+
right(): R;
|
|
22
|
+
/** Transforma el valor Right manteniendo Left intacto */
|
|
23
|
+
map<U>(fn: (value: R) => U): IEither<L, U>;
|
|
24
|
+
/** Transforma el valor Left manteniendo Right intacto */
|
|
25
|
+
mapLeft<U>(fn: (value: L) => U): IEither<U, R>;
|
|
26
|
+
/** Composición monádica - encadena operaciones Either */
|
|
27
|
+
flatMap<U>(fn: (value: R) => IEither<L, U>): IEither<L, U>;
|
|
28
|
+
/** Aplica una función según el estado del Either */
|
|
29
|
+
fold<U>(onLeft: (left: L) => U, onRight: (right: R) => U): U;
|
|
30
|
+
/** Obtiene el valor Right o un valor de fallback */
|
|
31
|
+
getOrElse(fallback: R): R;
|
|
32
|
+
getOrElse(fallback: () => R): R;
|
|
33
|
+
getOrElse(fallback: R | (() => R)): R;
|
|
34
|
+
/** Aplica un filtro al valor Right */
|
|
35
|
+
filter(predicate: (value: R) => boolean, errorFactory: () => L): IEither<L, R>;
|
|
36
|
+
/** Alias para flatMap (más semántico para validaciones) */
|
|
37
|
+
chain<U>(fn: (value: R) => IEither<L, U>): IEither<L, U>;
|
|
38
|
+
/** Convierte a Optional (undefined si es Left) */
|
|
39
|
+
toOptional(): R | undefined;
|
|
40
|
+
/** Intercambia Left y Right */
|
|
41
|
+
swap(): IEither<R, L>;
|
|
42
|
+
/** Representación string para debugging */
|
|
43
|
+
inspect(): string;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=IEither.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEither.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/IEither.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;GAGG;AACH,MAAM,WAAW,OAAO,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,MAAM,CAAC,CAAC,CAAC;IAC9C,+CAA+C;IAC/C,QAAQ,CAAC,KAAK,EAAE,WAAW,CAAC;IAE5B,mDAAmD;IACnD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IAEzB,oDAAoD;IACpD,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAI1B,kEAAkE;IAClE,OAAO,IAAI,CAAC,GAAG,SAAS,CAAC;IAEzB,mEAAmE;IACnE,QAAQ,IAAI,CAAC,GAAG,SAAS,CAAC;IAI1B,0DAA0D;IAC1D,IAAI,IAAI,CAAC,CAAC;IAEV,0DAA0D;IAC1D,KAAK,IAAI,CAAC,CAAC;IAIX,yDAAyD;IACzD,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE3C,yDAAyD;IACzD,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE/C,yDAAyD;IACzD,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAI3D,oDAAoD;IACpD,IAAI,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAE7D,oDAAoD;IACpD,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,CAAC;IAC1B,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC;IAChC,SAAS,CAAC,QAAQ,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC;IAItC,sCAAsC;IACtC,MAAM,CAAC,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,EAAE,YAAY,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAE/E,2DAA2D;IAC3D,KAAK,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAIzD,kDAAkD;IAClD,UAAU,IAAI,CAAC,GAAG,SAAS,CAAC;IAE5B,+BAA+B;IAC/B,IAAI,IAAI,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAItB,2CAA2C;IAC3C,OAAO,IAAI,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IFunctor.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/IFunctor.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,GAAG,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC;CAC1C"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IEither } from './IEither';
|
|
2
|
+
/**
|
|
3
|
+
* Interface específica para representar el estado Left del Either
|
|
4
|
+
* Contiene un valor de error o fallo
|
|
5
|
+
*/
|
|
6
|
+
export interface ILeftEither<L, R> extends IEither<L, R> {
|
|
7
|
+
/** Siempre true para LeftEither */
|
|
8
|
+
readonly isLeft: true;
|
|
9
|
+
/** Siempre false para LeftEither */
|
|
10
|
+
readonly isRight: false;
|
|
11
|
+
/** Obtiene el valor Left (nunca undefined en LeftEither) */
|
|
12
|
+
getLeft(): L;
|
|
13
|
+
/** Siempre undefined para LeftEither */
|
|
14
|
+
getRight(): undefined;
|
|
15
|
+
/** Obtiene el valor Left directamente */
|
|
16
|
+
left(): L;
|
|
17
|
+
/** Lanza excepción para LeftEither */
|
|
18
|
+
right(): never;
|
|
19
|
+
/** Siempre undefined para LeftEither */
|
|
20
|
+
toOptional(): undefined;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=ILeftEither.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ILeftEither.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/ILeftEither.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,WAAW,WAAW,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACtD,mCAAmC;IACnC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC;IAEtB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IAExB,4DAA4D;IAC5D,OAAO,IAAI,CAAC,CAAC;IAEb,wCAAwC;IACxC,QAAQ,IAAI,SAAS,CAAC;IAEtB,yCAAyC;IACzC,IAAI,IAAI,CAAC,CAAC;IAEV,sCAAsC;IACtC,KAAK,IAAI,KAAK,CAAC;IAEf,wCAAwC;IACxC,UAAU,IAAI,SAAS,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IMonad.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/IMonad.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,WAAW,MAAM,CAAC,CAAC,CAAE,SAAQ,QAAQ,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,MAAM,CAAC,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC;CACpD"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { IEither } from './IEither';
|
|
2
|
+
/**
|
|
3
|
+
* Interface específica para representar el estado Right del Either
|
|
4
|
+
* Contiene un valor de éxito
|
|
5
|
+
*/
|
|
6
|
+
export interface IRightEither<L, R> extends IEither<L, R> {
|
|
7
|
+
/** Siempre false para RightEither */
|
|
8
|
+
readonly isLeft: false;
|
|
9
|
+
/** Siempre true para RightEither */
|
|
10
|
+
readonly isRight: true;
|
|
11
|
+
/** Siempre undefined para RightEither */
|
|
12
|
+
getLeft(): undefined;
|
|
13
|
+
/** Obtiene el valor Right (nunca undefined en RightEither) */
|
|
14
|
+
getRight(): R;
|
|
15
|
+
/** Lanza excepción para RightEither */
|
|
16
|
+
left(): never;
|
|
17
|
+
/** Obtiene el valor Right directamente */
|
|
18
|
+
right(): R;
|
|
19
|
+
/** Obtiene el valor Right para RightEither */
|
|
20
|
+
toOptional(): R;
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=IRightEither.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IRightEither.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/IRightEither.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC;;;GAGG;AACH,MAAM,WAAW,YAAY,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC;IACvD,qCAAqC;IACrC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAC;IAEvB,oCAAoC;IACpC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IAEvB,yCAAyC;IACzC,OAAO,IAAI,SAAS,CAAC;IAErB,8DAA8D;IAC9D,QAAQ,IAAI,CAAC,CAAC;IAEd,uCAAuC;IACvC,IAAI,IAAI,KAAK,CAAC;IAEd,0CAA0C;IAC1C,KAAK,IAAI,CAAC,CAAC;IAEX,8CAA8C;IAC9C,UAAU,IAAI,CAAC,CAAC;CACjB"}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Interfaz para el patrón Monad
|
|
3
|
+
* Interfaz legacy para compatibilidad
|
|
4
|
+
*/
|
|
5
|
+
export interface Monad<R> {
|
|
6
|
+
/**
|
|
7
|
+
* Operación monádica para evitar anidamiento (flatMap/bind)
|
|
8
|
+
* Permite composición secuencial de operaciones que retornan monadas
|
|
9
|
+
*/
|
|
10
|
+
flatMap<U>(fn: (value: R) => Monad<U>): Monad<U>;
|
|
4
11
|
}
|
|
5
12
|
//# sourceMappingURL=Monad.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Monad.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/Monad.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"Monad.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/contracts/Monad.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,WAAW,KAAK,CAAC,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;CAClD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RootError } from '../../../domain/exceptions/RootError';
|
|
2
|
+
export declare class FilterOperationNotImplementedError extends RootError {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
static create(context?: string): FilterOperationNotImplementedError;
|
|
5
|
+
logError(): string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=FilterOperationNotImplementedError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FilterOperationNotImplementedError.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/exceptions/FilterOperationNotImplementedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEjE,qBAAa,kCAAmC,SAAQ,SAAS;gBACnD,OAAO,EAAE,MAAM;WAKJ,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,kCAAkC;IAMnE,QAAQ,IAAI,MAAM;CAGnC"}
|
package/build/types/carbonbox/shared/either/domain/exceptions/SwapOperationNotImplementedError.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RootError } from '../../../domain/exceptions/RootError';
|
|
2
|
+
export declare class SwapOperationNotImplementedError extends RootError {
|
|
3
|
+
constructor(message: string);
|
|
4
|
+
static create(context?: string): SwapOperationNotImplementedError;
|
|
5
|
+
logError(): string;
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=SwapOperationNotImplementedError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SwapOperationNotImplementedError.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/shared/either/domain/exceptions/SwapOperationNotImplementedError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sCAAsC,CAAC;AAEjE,qBAAa,gCAAiC,SAAQ,SAAS;gBACjD,OAAO,EAAE,MAAM;WAKJ,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,GAAG,gCAAgC;IAMjE,QAAQ,IAAI,MAAM;CAGnC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { IEither } from '../contracts/IEither';
|
|
2
|
+
/**
|
|
3
|
+
* Factory para crear instancias de Either
|
|
4
|
+
* Resuelve las dependencias circulares al separar la creación de la implementación
|
|
5
|
+
*/
|
|
6
|
+
export declare class EitherFactory {
|
|
7
|
+
/** Crea un Either Left que contiene un valor de error */
|
|
8
|
+
static left<L, R>(value: L): IEither<L, R>;
|
|
9
|
+
/** Crea un Either Right que contiene un valor de éxito */
|
|
10
|
+
static right<L, R>(value: R): IEither<L, R>;
|
|
11
|
+
/** Factory method para manejo seguro de operaciones que pueden fallar */
|
|
12
|
+
static fromTryCatch<L, R>(operation: () => R, errorMapper: (error: unknown) => L): IEither<L, R>;
|
|
13
|
+
/** Factory method para promesas */
|
|
14
|
+
static fromPromise<L, R>(promise: Promise<R>, errorMapper: (error: unknown) => L): Promise<IEither<L, R>>;
|
|
15
|
+
/** Factory method para valores que pueden ser null o undefined */
|
|
16
|
+
static fromNullable<L, R>(value: R | null | undefined, errorFactory: () => L): IEither<L, R>;
|
|
17
|
+
/** Factory method para operaciones condicionales */
|
|
18
|
+
static fromCondition<L, R>(condition: boolean, rightValue: () => R, leftValue: () => L): IEither<L, R>;
|
|
19
|
+
/** Combina múltiples Either en uno solo - falla en el primer Left */
|
|
20
|
+
static sequence<L, R>(eithers: IEither<L, R>[]): IEither<L, R[]>;
|
|
21
|
+
/** Aplica una función que puede fallar a cada elemento */
|
|
22
|
+
static traverse<L, R, U>(items: R[], fn: (item: R) => IEither<L, U>): IEither<L, U[]>;
|
|
23
|
+
/** Combina dos Either con una función */
|
|
24
|
+
static lift2<L, A, B, C>(fn: (a: A, b: B) => C, eitherA: IEither<L, A>, eitherB: IEither<L, B>): IEither<L, C>;
|
|
25
|
+
/** Combina tres Either con una función */
|
|
26
|
+
static lift3<L, A, B, C, D>(fn: (a: A, b: B, c: C) => D, eitherA: IEither<L, A>, eitherB: IEither<L, B>, eitherC: IEither<L, C>): IEither<L, D>;
|
|
27
|
+
/** Acumula errores en lugar de fallar en el primero */
|
|
28
|
+
static accumulate<L, R>(eithers: IEither<L, R>[]): IEither<L[], R[]>;
|
|
29
|
+
/** Ejecuta Either en paralelo y acumula todos los errores */
|
|
30
|
+
static parallel<L, R>(operations: (() => Promise<IEither<L, R>>)[]): Promise<IEither<L[], R[]>>;
|
|
31
|
+
/** Aplica una transformación solo si se cumple una condición */
|
|
32
|
+
static when<L, R>(condition: boolean, transform: (value: R) => IEither<L, R>): (either: IEither<L, R>) => IEither<L, R>;
|
|
33
|
+
/** Aplica una transformación solo si NO se cumple una condición */
|
|
34
|
+
static unless<L, R>(condition: boolean, transform: (value: R) => IEither<L, R>): (either: IEither<L, R>) => IEither<L, R>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=EitherFactory.d.ts.map
|