@onerb/core 2.0.0 → 2.0.2
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/README.md +31 -0
- package/dist/index.cjs +3 -74
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -32
- package/dist/index.d.ts +1 -32
- package/dist/index.js +2 -64
- package/dist/index.js.map +1 -1
- package/package.json +4 -1
package/README.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# @onerb/core
|
|
2
|
+
|
|
3
|
+
Pacote principal do ecossistema Onerb. Ele agrega os subpacotes oficiais e reexporta suas APIs, permitindo instalar tudo com uma única dependência.
|
|
4
|
+
|
|
5
|
+
## Instalação
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @onerb/core
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
yarn add @onerb/core
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @onerb/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Subpacotes
|
|
20
|
+
|
|
21
|
+
- `@onerb/error`: utilitários de erro e `Either`. Veja o README em [`packages/error/README.md`](../error/README.md).
|
|
22
|
+
|
|
23
|
+
## Reexportações
|
|
24
|
+
|
|
25
|
+
O `@onerb/core` reexporta todo o conteúdo de `@onerb/error`. Se você já usa `@onerb/core`, não precisa instalar o pacote de erro separadamente.
|
|
26
|
+
|
|
27
|
+
## Importação
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { AppError, Either, left, right } from '@onerb/core';
|
|
31
|
+
```
|
package/dist/index.cjs
CHANGED
|
@@ -3,10 +3,6 @@ var __defProp = Object.defineProperty;
|
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
6
|
var __copyProps = (to, from, except, desc) => {
|
|
11
7
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
8
|
for (let key of __getOwnPropNames(from))
|
|
@@ -15,82 +11,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
11
|
}
|
|
16
12
|
return to;
|
|
17
13
|
};
|
|
14
|
+
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
18
15
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
16
|
|
|
20
17
|
// src/index.ts
|
|
21
18
|
var index_exports = {};
|
|
22
|
-
__export(index_exports, {
|
|
23
|
-
AppError: () => AppError,
|
|
24
|
-
Left: () => Left,
|
|
25
|
-
Right: () => Right,
|
|
26
|
-
left: () => left,
|
|
27
|
-
right: () => right
|
|
28
|
-
});
|
|
29
19
|
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
|
|
31
|
-
// src/errors/app-error.ts
|
|
32
|
-
var AppError = class extends Error {
|
|
33
|
-
code;
|
|
34
|
-
detail;
|
|
35
|
-
constructor(message, options) {
|
|
36
|
-
super(message);
|
|
37
|
-
this.name = "AppError";
|
|
38
|
-
this.code = options.code;
|
|
39
|
-
this.detail = options.detail;
|
|
40
|
-
}
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
// src/errors/either.ts
|
|
44
|
-
var Left = class _Left {
|
|
45
|
-
_value;
|
|
46
|
-
constructor(value) {
|
|
47
|
-
this._value = value;
|
|
48
|
-
}
|
|
49
|
-
isLeft() {
|
|
50
|
-
return true;
|
|
51
|
-
}
|
|
52
|
-
isRight() {
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
map(_fn) {
|
|
56
|
-
return new _Left(this._value);
|
|
57
|
-
}
|
|
58
|
-
mapLeft(fn) {
|
|
59
|
-
return new _Left(fn(this._value));
|
|
60
|
-
}
|
|
61
|
-
fold(fl, _fr) {
|
|
62
|
-
return fl(this._value);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
var Right = class _Right {
|
|
66
|
-
_value;
|
|
67
|
-
constructor(value) {
|
|
68
|
-
this._value = value;
|
|
69
|
-
}
|
|
70
|
-
isLeft() {
|
|
71
|
-
return false;
|
|
72
|
-
}
|
|
73
|
-
isRight() {
|
|
74
|
-
return true;
|
|
75
|
-
}
|
|
76
|
-
map(fn) {
|
|
77
|
-
return new _Right(fn(this._value));
|
|
78
|
-
}
|
|
79
|
-
mapLeft(_fn) {
|
|
80
|
-
return new _Right(this._value);
|
|
81
|
-
}
|
|
82
|
-
fold(_fl, fr) {
|
|
83
|
-
return fr(this._value);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var left = (l) => new Left(l);
|
|
87
|
-
var right = (r) => new Right(r);
|
|
20
|
+
__reExport(index_exports, require("@onerb/error"), module.exports);
|
|
88
21
|
// Annotate the CommonJS export names for ESM import in node:
|
|
89
22
|
0 && (module.exports = {
|
|
90
|
-
|
|
91
|
-
Left,
|
|
92
|
-
Right,
|
|
93
|
-
left,
|
|
94
|
-
right
|
|
23
|
+
...require("@onerb/error")
|
|
95
24
|
});
|
|
96
25
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from '@onerb/error';\n"],"mappings":";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA,0BAAc,yBAAd;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
readonly code: string;
|
|
3
|
-
readonly detail?: string;
|
|
4
|
-
constructor(message: string, options: {
|
|
5
|
-
code: string;
|
|
6
|
-
detail?: string;
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type Either<L, R> = Left<L, R> | Right<R, L>;
|
|
11
|
-
declare class Left<L, R = never> {
|
|
12
|
-
private readonly _value;
|
|
13
|
-
constructor(value: L);
|
|
14
|
-
isLeft(): this is Left<L, R>;
|
|
15
|
-
isRight(): this is Left<L, R>;
|
|
16
|
-
map<T>(_fn: (v: R) => T): Left<L, T>;
|
|
17
|
-
mapLeft<T>(fn: (l: L) => T): Left<T, R>;
|
|
18
|
-
fold<T>(fl: (l: L) => T, _fr: (r: R) => R): T;
|
|
19
|
-
}
|
|
20
|
-
declare class Right<R, L = never> {
|
|
21
|
-
private readonly _value;
|
|
22
|
-
constructor(value: R);
|
|
23
|
-
isLeft(): this is Right<R, L>;
|
|
24
|
-
isRight(): this is Right<R, L>;
|
|
25
|
-
map<T>(fn: (v: R) => T): Right<T, L>;
|
|
26
|
-
mapLeft<T>(_fn: (l: L) => T): Right<R, T>;
|
|
27
|
-
fold<T>(_fl: (l: L) => L, fr: (r: R) => T): T;
|
|
28
|
-
}
|
|
29
|
-
declare const left: <L, R = never>(l: L) => Left<L, R>;
|
|
30
|
-
declare const right: <R, L = never>(r: R) => Right<R, L>;
|
|
31
|
-
|
|
32
|
-
export { AppError, type Either, Left, Right, left, right };
|
|
1
|
+
export * from '@onerb/error';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
readonly code: string;
|
|
3
|
-
readonly detail?: string;
|
|
4
|
-
constructor(message: string, options: {
|
|
5
|
-
code: string;
|
|
6
|
-
detail?: string;
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
type Either<L, R> = Left<L, R> | Right<R, L>;
|
|
11
|
-
declare class Left<L, R = never> {
|
|
12
|
-
private readonly _value;
|
|
13
|
-
constructor(value: L);
|
|
14
|
-
isLeft(): this is Left<L, R>;
|
|
15
|
-
isRight(): this is Left<L, R>;
|
|
16
|
-
map<T>(_fn: (v: R) => T): Left<L, T>;
|
|
17
|
-
mapLeft<T>(fn: (l: L) => T): Left<T, R>;
|
|
18
|
-
fold<T>(fl: (l: L) => T, _fr: (r: R) => R): T;
|
|
19
|
-
}
|
|
20
|
-
declare class Right<R, L = never> {
|
|
21
|
-
private readonly _value;
|
|
22
|
-
constructor(value: R);
|
|
23
|
-
isLeft(): this is Right<R, L>;
|
|
24
|
-
isRight(): this is Right<R, L>;
|
|
25
|
-
map<T>(fn: (v: R) => T): Right<T, L>;
|
|
26
|
-
mapLeft<T>(_fn: (l: L) => T): Right<R, T>;
|
|
27
|
-
fold<T>(_fl: (l: L) => L, fr: (r: R) => T): T;
|
|
28
|
-
}
|
|
29
|
-
declare const left: <L, R = never>(l: L) => Left<L, R>;
|
|
30
|
-
declare const right: <R, L = never>(r: R) => Right<R, L>;
|
|
31
|
-
|
|
32
|
-
export { AppError, type Either, Left, Right, left, right };
|
|
1
|
+
export * from '@onerb/error';
|
package/dist/index.js
CHANGED
|
@@ -1,65 +1,3 @@
|
|
|
1
|
-
// src/
|
|
2
|
-
|
|
3
|
-
code;
|
|
4
|
-
detail;
|
|
5
|
-
constructor(message, options) {
|
|
6
|
-
super(message);
|
|
7
|
-
this.name = "AppError";
|
|
8
|
-
this.code = options.code;
|
|
9
|
-
this.detail = options.detail;
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
// src/errors/either.ts
|
|
14
|
-
var Left = class _Left {
|
|
15
|
-
_value;
|
|
16
|
-
constructor(value) {
|
|
17
|
-
this._value = value;
|
|
18
|
-
}
|
|
19
|
-
isLeft() {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
isRight() {
|
|
23
|
-
return false;
|
|
24
|
-
}
|
|
25
|
-
map(_fn) {
|
|
26
|
-
return new _Left(this._value);
|
|
27
|
-
}
|
|
28
|
-
mapLeft(fn) {
|
|
29
|
-
return new _Left(fn(this._value));
|
|
30
|
-
}
|
|
31
|
-
fold(fl, _fr) {
|
|
32
|
-
return fl(this._value);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
var Right = class _Right {
|
|
36
|
-
_value;
|
|
37
|
-
constructor(value) {
|
|
38
|
-
this._value = value;
|
|
39
|
-
}
|
|
40
|
-
isLeft() {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
isRight() {
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
map(fn) {
|
|
47
|
-
return new _Right(fn(this._value));
|
|
48
|
-
}
|
|
49
|
-
mapLeft(_fn) {
|
|
50
|
-
return new _Right(this._value);
|
|
51
|
-
}
|
|
52
|
-
fold(_fl, fr) {
|
|
53
|
-
return fr(this._value);
|
|
54
|
-
}
|
|
55
|
-
};
|
|
56
|
-
var left = (l) => new Left(l);
|
|
57
|
-
var right = (r) => new Right(r);
|
|
58
|
-
export {
|
|
59
|
-
AppError,
|
|
60
|
-
Left,
|
|
61
|
-
Right,
|
|
62
|
-
left,
|
|
63
|
-
right
|
|
64
|
-
};
|
|
1
|
+
// src/index.ts
|
|
2
|
+
export * from "@onerb/error";
|
|
65
3
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["export * from '@onerb/error';\n"],"mappings":";AAAA,cAAc;","names":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onerb/core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "Core utilities for Onerb projects.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -15,6 +15,9 @@
|
|
|
15
15
|
"require": "./dist/index.cjs"
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@onerb/error": "^2.0.0"
|
|
20
|
+
},
|
|
18
21
|
"files": ["dist"],
|
|
19
22
|
"scripts": {
|
|
20
23
|
"build": "tsup",
|