@libs-for-dev/nestjs-ddd-library 1.0.0 → 1.1.1

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/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ let e=require(`class-validator`),t=require(`oxide.ts`),n=require(`fast-equals`),r=require(`ui7`),i=require(`@nestjs/cqrs`);var a=class extends Error{static name=`NotAMoneyError`;constructor(e,t){super(`Amount ${e} with currency ${t} is not valid money`)}},o=class extends Error{static name=`NotAPhoneNumberError`;constructor(e){super(`${e} is not a valid phone number`)}},s=class extends Error{static name=`NotAnEmailError`;constructor(e){super(`${e} is not a valid email`)}},c=class extends Error{static name=`NotAnUrlError`;constructor(e){super(`${e} is not a valid URL`)}},l=class extends Error{static name=`NotAnUuidError`;constructor(e){super(`${e} is not a valid UUID`)}},u=class{constructor(e){this.props=e}equals(e){return this.constructor.name===e.constructor.name?(0,n.deepEqual)(e.props,this.props):!1}},d=class n extends u{get value(){return this.props.value}static create(e){return this.isValid(e)?(0,t.Ok)(new n({value:e})):(0,t.Err)(new s(e))}static isValid(t){return(0,e.isEmail)(t)}},f=class e extends u{get amount(){return this.props.amount}get currency(){return this.props.currency}get value(){return{amount:this.amount,currency:this.currency}}static create(n,r){return this.isValid(n,r)?(0,t.Ok)(new e({amount:n,currency:r})):(0,t.Err)(new a(n,r))}static isValid(e,t){return!(e<0||!Number.isFinite(e)||!/^[A-Z]{3}$/u.test(t))}},p=class n extends u{get value(){return this.props.value}static create(e){return this.isValid(e)?(0,t.Ok)(new n({value:e})):(0,t.Err)(new o(e))}static isValid(t){return(0,e.isMobilePhone)(t)}},m=class n extends u{get value(){return this.props.value}static create(e){return this.isValid(e)?(0,t.Ok)(new n({value:e})):(0,t.Err)(new c(e))}static isValid(t){return(0,e.isURL)(t,{require_protocol:!0})}},h=class n extends u{get value(){return this.props.value}static create(r){return(0,e.isUUID)(r)?(0,t.Ok)(new n({value:r})):(0,t.Err)(new l(r))}static generate(){return new n({value:(0,r.v7)()})}};const g=e=>{let t=Object.getOwnPropertyNames(e);for(let n of t){let t=e[n];t!==void 0&&typeof t==`object`&&g(t)}return Object.freeze(e)};var _=class extends i.AggregateRoot{id;get props(){return g(this.propsData.props)}propsData;constructor(e,t){super(),this.id=e,this.propsData={props:t}}equals(e){return this.constructor.name===e.constructor.name?this.id===e.id:!1}};exports.AbstractEntity=_,exports.AbstractValueObject=u,exports.Email=d,exports.Money=f,exports.NotAMoneyError=a,exports.NotAPhoneNumberError=o,exports.NotAnEmailError=s,exports.NotAnUrlError=c,exports.NotAnUuidError=l,exports.PhoneNumber=p,exports.Url=m,exports.Uuid=h,exports.deepReadonly=g;
@@ -0,0 +1,103 @@
1
+ import { Result } from "oxide.ts";
2
+ import { AggregateRoot, IEvent } from "@nestjs/cqrs";
3
+
4
+ //#region src/value-objects/errors/not-a-money.error.d.ts
5
+ declare class NotAMoneyError extends Error {
6
+ static readonly name = "NotAMoneyError";
7
+ constructor(amount: number, currency: string);
8
+ }
9
+ //#endregion
10
+ //#region src/value-objects/errors/not-a-phone-number.error.d.ts
11
+ declare class NotAPhoneNumberError extends Error {
12
+ static readonly name = "NotAPhoneNumberError";
13
+ constructor(phoneNumber: string);
14
+ }
15
+ //#endregion
16
+ //#region src/value-objects/errors/not-an-email.error.d.ts
17
+ declare class NotAnEmailError extends Error {
18
+ static readonly name = "NotAnEmailError";
19
+ constructor(email: string);
20
+ }
21
+ //#endregion
22
+ //#region src/value-objects/errors/not-an-url.error.d.ts
23
+ declare class NotAnUrlError extends Error {
24
+ static readonly name = "NotAnUrlError";
25
+ constructor(url: string);
26
+ }
27
+ //#endregion
28
+ //#region src/value-objects/errors/not-an-uuid.error.d.ts
29
+ declare class NotAnUuidError extends Error {
30
+ static readonly name = "NotAnUuidError";
31
+ constructor(uuid: string);
32
+ }
33
+ //#endregion
34
+ //#region src/abstract-value-object.d.ts
35
+ interface PrimitiveInterface<T extends Date | Primitives> {
36
+ value: T;
37
+ }
38
+ type Primitives = boolean | null | number | string;
39
+ type ValueObjectProps<T> = T extends Date | Primitives ? PrimitiveInterface<T> : T;
40
+ declare abstract class AbstractValueObject<T> {
41
+ readonly props: Readonly<ValueObjectProps<T>>;
42
+ protected constructor(props: Readonly<ValueObjectProps<T>>);
43
+ equals(valueObject: AbstractValueObject<T>): boolean;
44
+ }
45
+ //#endregion
46
+ //#region src/value-objects/email.d.ts
47
+ declare class Email extends AbstractValueObject<string> {
48
+ get value(): string;
49
+ static create(email: string): Result<Email, Error>;
50
+ private static isValid;
51
+ }
52
+ //#endregion
53
+ //#region src/value-objects/money.d.ts
54
+ interface MoneyPropsInterface {
55
+ amount: number;
56
+ currency: string;
57
+ }
58
+ declare class Money extends AbstractValueObject<MoneyPropsInterface> {
59
+ get amount(): number;
60
+ get currency(): string;
61
+ get value(): MoneyPropsInterface;
62
+ static create(amount: number, currency: string): Result<Money, Error>;
63
+ private static isValid;
64
+ }
65
+ //#endregion
66
+ //#region src/value-objects/phone-number.d.ts
67
+ declare class PhoneNumber extends AbstractValueObject<string> {
68
+ get value(): string;
69
+ static create(phoneNumber: string): Result<PhoneNumber, NotAPhoneNumberError>;
70
+ private static isValid;
71
+ }
72
+ //#endregion
73
+ //#region src/value-objects/url.d.ts
74
+ declare class Url extends AbstractValueObject<string> {
75
+ get value(): string;
76
+ static create(url: string): Result<Url, NotAnUrlError>;
77
+ private static isValid;
78
+ }
79
+ //#endregion
80
+ //#region src/value-objects/uuid.d.ts
81
+ declare class Uuid extends AbstractValueObject<string> {
82
+ get value(): string;
83
+ static create(uuid: string): Result<Uuid, Error>;
84
+ static generate(): Uuid;
85
+ }
86
+ //#endregion
87
+ //#region src/deep-readonly.d.ts
88
+ type DeepReadonly<T> = Readonly<{ [K in keyof T]: T[K] extends (number | string | symbol) ? Readonly<T[K]> : T[K] extends (infer A)[] ? readonly DeepReadonly<A>[] : DeepReadonly<T[K]> }>;
89
+ declare const deepReadonly: <T>(object: T) => DeepReadonly<T>;
90
+ //#endregion
91
+ //#region src/abstract-entity.d.ts
92
+ interface EntityPropsInterface<T> {
93
+ props: T;
94
+ }
95
+ declare abstract class AbstractEntity<Id, Props, Event extends IEvent = IEvent> extends AggregateRoot<Event> {
96
+ readonly id: Id;
97
+ get props(): DeepReadonly<Props>;
98
+ protected propsData: EntityPropsInterface<Props>;
99
+ protected constructor(id: Id, props: Props);
100
+ equals(object: AbstractEntity<Id, Props>): boolean;
101
+ }
102
+ //#endregion
103
+ export { AbstractEntity, AbstractValueObject, DeepReadonly, Email, EntityPropsInterface, Money, MoneyPropsInterface, NotAMoneyError, NotAPhoneNumberError, NotAnEmailError, NotAnUrlError, NotAnUuidError, PhoneNumber, PrimitiveInterface, Primitives, Url, Uuid, deepReadonly };
@@ -0,0 +1,103 @@
1
+ import { Result } from "oxide.ts";
2
+ import { AggregateRoot, IEvent } from "@nestjs/cqrs";
3
+
4
+ //#region src/value-objects/errors/not-a-money.error.d.ts
5
+ declare class NotAMoneyError extends Error {
6
+ static readonly name = "NotAMoneyError";
7
+ constructor(amount: number, currency: string);
8
+ }
9
+ //#endregion
10
+ //#region src/value-objects/errors/not-a-phone-number.error.d.ts
11
+ declare class NotAPhoneNumberError extends Error {
12
+ static readonly name = "NotAPhoneNumberError";
13
+ constructor(phoneNumber: string);
14
+ }
15
+ //#endregion
16
+ //#region src/value-objects/errors/not-an-email.error.d.ts
17
+ declare class NotAnEmailError extends Error {
18
+ static readonly name = "NotAnEmailError";
19
+ constructor(email: string);
20
+ }
21
+ //#endregion
22
+ //#region src/value-objects/errors/not-an-url.error.d.ts
23
+ declare class NotAnUrlError extends Error {
24
+ static readonly name = "NotAnUrlError";
25
+ constructor(url: string);
26
+ }
27
+ //#endregion
28
+ //#region src/value-objects/errors/not-an-uuid.error.d.ts
29
+ declare class NotAnUuidError extends Error {
30
+ static readonly name = "NotAnUuidError";
31
+ constructor(uuid: string);
32
+ }
33
+ //#endregion
34
+ //#region src/abstract-value-object.d.ts
35
+ interface PrimitiveInterface<T extends Date | Primitives> {
36
+ value: T;
37
+ }
38
+ type Primitives = boolean | null | number | string;
39
+ type ValueObjectProps<T> = T extends Date | Primitives ? PrimitiveInterface<T> : T;
40
+ declare abstract class AbstractValueObject<T> {
41
+ readonly props: Readonly<ValueObjectProps<T>>;
42
+ protected constructor(props: Readonly<ValueObjectProps<T>>);
43
+ equals(valueObject: AbstractValueObject<T>): boolean;
44
+ }
45
+ //#endregion
46
+ //#region src/value-objects/email.d.ts
47
+ declare class Email extends AbstractValueObject<string> {
48
+ get value(): string;
49
+ static create(email: string): Result<Email, Error>;
50
+ private static isValid;
51
+ }
52
+ //#endregion
53
+ //#region src/value-objects/money.d.ts
54
+ interface MoneyPropsInterface {
55
+ amount: number;
56
+ currency: string;
57
+ }
58
+ declare class Money extends AbstractValueObject<MoneyPropsInterface> {
59
+ get amount(): number;
60
+ get currency(): string;
61
+ get value(): MoneyPropsInterface;
62
+ static create(amount: number, currency: string): Result<Money, Error>;
63
+ private static isValid;
64
+ }
65
+ //#endregion
66
+ //#region src/value-objects/phone-number.d.ts
67
+ declare class PhoneNumber extends AbstractValueObject<string> {
68
+ get value(): string;
69
+ static create(phoneNumber: string): Result<PhoneNumber, NotAPhoneNumberError>;
70
+ private static isValid;
71
+ }
72
+ //#endregion
73
+ //#region src/value-objects/url.d.ts
74
+ declare class Url extends AbstractValueObject<string> {
75
+ get value(): string;
76
+ static create(url: string): Result<Url, NotAnUrlError>;
77
+ private static isValid;
78
+ }
79
+ //#endregion
80
+ //#region src/value-objects/uuid.d.ts
81
+ declare class Uuid extends AbstractValueObject<string> {
82
+ get value(): string;
83
+ static create(uuid: string): Result<Uuid, Error>;
84
+ static generate(): Uuid;
85
+ }
86
+ //#endregion
87
+ //#region src/deep-readonly.d.ts
88
+ type DeepReadonly<T> = Readonly<{ [K in keyof T]: T[K] extends (number | string | symbol) ? Readonly<T[K]> : T[K] extends (infer A)[] ? readonly DeepReadonly<A>[] : DeepReadonly<T[K]> }>;
89
+ declare const deepReadonly: <T>(object: T) => DeepReadonly<T>;
90
+ //#endregion
91
+ //#region src/abstract-entity.d.ts
92
+ interface EntityPropsInterface<T> {
93
+ props: T;
94
+ }
95
+ declare abstract class AbstractEntity<Id, Props, Event extends IEvent = IEvent> extends AggregateRoot<Event> {
96
+ readonly id: Id;
97
+ get props(): DeepReadonly<Props>;
98
+ protected propsData: EntityPropsInterface<Props>;
99
+ protected constructor(id: Id, props: Props);
100
+ equals(object: AbstractEntity<Id, Props>): boolean;
101
+ }
102
+ //#endregion
103
+ export { AbstractEntity, AbstractValueObject, DeepReadonly, Email, EntityPropsInterface, Money, MoneyPropsInterface, NotAMoneyError, NotAPhoneNumberError, NotAnEmailError, NotAnUrlError, NotAnUuidError, PhoneNumber, PrimitiveInterface, Primitives, Url, Uuid, deepReadonly };
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ import{isEmail as e,isMobilePhone as t,isURL as n,isUUID as r}from"class-validator";import{Err as i,Ok as a}from"oxide.ts";import{deepEqual as o}from"fast-equals";import{v7 as s}from"ui7";import{AggregateRoot as c}from"@nestjs/cqrs";var l=class extends Error{static name=`NotAMoneyError`;constructor(e,t){super(`Amount ${e} with currency ${t} is not valid money`)}},u=class extends Error{static name=`NotAPhoneNumberError`;constructor(e){super(`${e} is not a valid phone number`)}},d=class extends Error{static name=`NotAnEmailError`;constructor(e){super(`${e} is not a valid email`)}},f=class extends Error{static name=`NotAnUrlError`;constructor(e){super(`${e} is not a valid URL`)}},p=class extends Error{static name=`NotAnUuidError`;constructor(e){super(`${e} is not a valid UUID`)}},m=class{constructor(e){this.props=e}equals(e){return this.constructor.name===e.constructor.name?o(e.props,this.props):!1}},h=class t extends m{get value(){return this.props.value}static create(e){return this.isValid(e)?a(new t({value:e})):i(new d(e))}static isValid(t){return e(t)}},g=class e extends m{get amount(){return this.props.amount}get currency(){return this.props.currency}get value(){return{amount:this.amount,currency:this.currency}}static create(t,n){return this.isValid(t,n)?a(new e({amount:t,currency:n})):i(new l(t,n))}static isValid(e,t){return!(e<0||!Number.isFinite(e)||!/^[A-Z]{3}$/u.test(t))}},_=class e extends m{get value(){return this.props.value}static create(t){return this.isValid(t)?a(new e({value:t})):i(new u(t))}static isValid(e){return t(e)}},v=class e extends m{get value(){return this.props.value}static create(t){return this.isValid(t)?a(new e({value:t})):i(new f(t))}static isValid(e){return n(e,{require_protocol:!0})}},y=class e extends m{get value(){return this.props.value}static create(t){return r(t)?a(new e({value:t})):i(new p(t))}static generate(){return new e({value:s()})}};const b=e=>{let t=Object.getOwnPropertyNames(e);for(let n of t){let t=e[n];t!==void 0&&typeof t==`object`&&b(t)}return Object.freeze(e)};var x=class extends c{id;get props(){return b(this.propsData.props)}propsData;constructor(e,t){super(),this.id=e,this.propsData={props:t}}equals(e){return this.constructor.name===e.constructor.name?this.id===e.id:!1}};export{x as AbstractEntity,m as AbstractValueObject,h as Email,g as Money,l as NotAMoneyError,u as NotAPhoneNumberError,d as NotAnEmailError,f as NotAnUrlError,p as NotAnUuidError,_ as PhoneNumber,v as Url,y as Uuid,b as deepReadonly};
package/package.json CHANGED
@@ -1,28 +1,36 @@
1
1
  {
2
2
  "name": "@libs-for-dev/nestjs-ddd-library",
3
- "version": "1.0.0",
3
+ "version": "1.1.1",
4
4
  "description": "NestJS DDD library",
5
5
  "keywords": [
6
6
  "ddd-library",
7
7
  "nestjs"
8
8
  ],
9
+ "bugs": "https://gitlab.com/libs-for-dev/nestjs/nestjs-ddd-library/-/issues",
9
10
  "repository": "https://gitlab.com/libs-for-dev/nestjs/nestjs-ddd-library",
10
11
  "license": "MIT",
11
12
  "author": {
12
13
  "name": "libs-for-dev"
13
14
  },
14
- "main": "dist/index.js",
15
- "types": "dist/index.d.ts",
15
+ "type": "module",
16
+ "exports": {
17
+ ".": {
18
+ "import": "./dist/index.mjs",
19
+ "require": "./dist/index.cjs"
20
+ }
21
+ },
22
+ "main": "dist/index.mjs",
23
+ "types": "dist/index.d.mts",
16
24
  "files": [
17
25
  "dist"
18
26
  ],
19
27
  "scripts": {
20
- "build": "rm -rf ./dist && cti create ./src && tsc --project tsconfig.build.json && tsc-alias --project tsconfig.build.json && cti clean ./src",
28
+ "build": "rm -rf ./dist && cti create ./src && tsdown && cti clean ./src",
21
29
  "dev:quality": "yarn concurrently --timings --kill-others-on-fail 'yarn lint' 'yarn test'",
22
30
  "dev:test:watch": "vitest",
23
31
  "lint": "yarn concurrently --timings 'yarn:lint:*'",
24
32
  "lint:audit": "yarn npm audit",
25
- "lint:depcheck": "depcheck",
33
+ "lint:depcheck": "knip",
26
34
  "lint:eslint": "eslint --cache --cache-location /tmp .",
27
35
  "lint:scriptlint": "scriptlint",
28
36
  "lint:tsc": "tsc --noEmit --pretty --project .",
@@ -31,28 +39,28 @@
31
39
  "test:unit": "vitest run"
32
40
  },
33
41
  "devDependencies": {
34
- "@libs-for-dev/eslint-rules": "2.3.3",
35
- "@nestjs/common": "^11.1.0",
36
- "@nestjs/core": "^11.1.0",
42
+ "@libs-for-dev/eslint-rules": "2.4.0",
43
+ "@nestjs/common": "^11.1.11",
44
+ "@nestjs/core": "^11.1.11",
37
45
  "@nestjs/cqrs": "^11.0.3",
38
- "@stryker-mutator/core": "^8.7.1",
39
- "@stryker-mutator/vitest-runner": "^8.7.1",
40
- "@types/node": "^22.15.3",
41
- "@vitest/coverage-v8": "^3.1.2",
42
- "class-validator": "^0.14.1",
43
- "concurrently": "^9.1.2",
46
+ "@stryker-mutator/core": "^9.4.0",
47
+ "@stryker-mutator/vitest-runner": "^9.4.0",
48
+ "@types/node": "^25.0.3",
49
+ "@vitest/coverage-v8": "^4.0.16",
50
+ "class-validator": "^0.14.3",
51
+ "concurrently": "^9.2.1",
44
52
  "create-ts-index": "^1.14.0",
45
- "depcheck": "^1.4.7",
46
- "eslint": "^9.25.1",
47
- "fast-equals": "^5.2.2",
48
- "jiti": "^2.4.2",
53
+ "eslint": "9.39.2",
54
+ "fast-equals": "^6.0.0",
55
+ "jiti": "^2.6.1",
56
+ "knip": "^5.78.0",
49
57
  "oxide.ts": "^1.1.0",
50
58
  "reflect-metadata": "^0.2.2",
51
59
  "scriptlint": "^3.0.0",
52
- "tsc-alias": "^1.8.15",
53
- "typescript": "^5.8.3",
60
+ "tsdown": "0.18.4",
61
+ "typescript": "^5.9.3",
54
62
  "ui7": "^0.2.3",
55
- "vitest": "^3.1.2",
63
+ "vitest": "^4.0.16",
56
64
  "yarn-audit-fix": "^10.1.1"
57
65
  },
58
66
  "peerDependencies": {
@@ -62,7 +70,8 @@
62
70
  "oxide.ts": ">=1.0.0 <2.0.0",
63
71
  "ui7": ">=0.2.0 <0.3.0"
64
72
  },
65
- "packageManager": "yarn@4.9.1",
73
+ "bundleDependencies": false,
74
+ "packageManager": "yarn@4.9.4",
66
75
  "engines": {
67
76
  "node": "^23.11.0"
68
77
  }
@@ -1,12 +0,0 @@
1
- import type { IEvent } from '@nestjs/cqrs';
2
- import { AggregateRoot } from '@nestjs/cqrs';
3
- export interface EntityPropsInterface<T> {
4
- props: T;
5
- }
6
- export declare abstract class AbstractEntity<Id, Props, Event extends IEvent = IEvent> extends AggregateRoot<Event> {
7
- readonly id: Id;
8
- get props(): Props;
9
- protected propsData: EntityPropsInterface<Props>;
10
- protected constructor(id: Id, props: Props);
11
- equals(object: AbstractEntity<Id, Props>): boolean;
12
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractEntity = void 0;
4
- const cqrs_1 = require("@nestjs/cqrs");
5
- class AbstractEntity extends cqrs_1.AggregateRoot {
6
- id;
7
- get props() {
8
- return Object.freeze(this.propsData.props);
9
- }
10
- propsData;
11
- constructor(id, props) {
12
- super();
13
- this.id = id;
14
- this.propsData = { props };
15
- }
16
- equals(object) {
17
- if (this.constructor.name !== object.constructor.name) {
18
- return false;
19
- }
20
- return this.id === object.id;
21
- }
22
- }
23
- exports.AbstractEntity = AbstractEntity;
@@ -1,11 +0,0 @@
1
- export interface PrimitiveInterface<T extends Date | Primitives> {
2
- value: T;
3
- }
4
- export type Primitives = boolean | null | number | string;
5
- type ValueObjectProps<T> = T extends Date | Primitives ? PrimitiveInterface<T> : T;
6
- export declare abstract class AbstractValueObject<T> {
7
- readonly props: Readonly<ValueObjectProps<T>>;
8
- protected constructor(props: Readonly<ValueObjectProps<T>>);
9
- equals(valueObject: AbstractValueObject<T>): boolean;
10
- }
11
- export {};
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.AbstractValueObject = void 0;
4
- const fast_equals_1 = require("fast-equals");
5
- class AbstractValueObject {
6
- props;
7
- constructor(props) {
8
- this.props = props;
9
- }
10
- equals(valueObject) {
11
- if (this.constructor.name !== valueObject.constructor.name) {
12
- return false;
13
- }
14
- return (0, fast_equals_1.deepEqual)(valueObject.props, this.props);
15
- }
16
- }
17
- exports.AbstractValueObject = AbstractValueObject;
package/dist/index.d.ts DELETED
@@ -1,3 +0,0 @@
1
- export * from './value-objects';
2
- export * from './abstract-entity';
3
- export * from './abstract-value-object';
package/dist/index.js DELETED
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./value-objects"), exports);
18
- __exportStar(require("./abstract-entity"), exports);
19
- __exportStar(require("./abstract-value-object"), exports);
@@ -1,7 +0,0 @@
1
- import type { Result } from 'oxide.ts';
2
- import { AbstractValueObject } from '../abstract-value-object';
3
- export declare class Email extends AbstractValueObject<string> {
4
- get value(): string;
5
- static create(email: string): Result<Email, Error>;
6
- private static isValid;
7
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Email = void 0;
4
- const class_validator_1 = require("class-validator");
5
- const oxide_ts_1 = require("oxide.ts");
6
- const abstract_value_object_1 = require("../abstract-value-object");
7
- const not_an_email_error_1 = require("../value-objects/errors/not-an-email.error");
8
- class Email extends abstract_value_object_1.AbstractValueObject {
9
- get value() {
10
- return this.props.value;
11
- }
12
- static create(email) {
13
- if (!this.isValid(email)) {
14
- return (0, oxide_ts_1.Err)(new not_an_email_error_1.NotAnEmailError(email));
15
- }
16
- return (0, oxide_ts_1.Ok)(new Email({ value: email }));
17
- }
18
- static isValid(email) {
19
- return (0, class_validator_1.isEmail)(email);
20
- }
21
- }
22
- exports.Email = Email;
@@ -1,2 +0,0 @@
1
- export * from './not-an-email.error';
2
- export * from './not-an-uuid.error';
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./not-an-email.error"), exports);
18
- __exportStar(require("./not-an-uuid.error"), exports);
@@ -1,4 +0,0 @@
1
- export declare class NotAnEmailError extends Error {
2
- static readonly name = "NotAnEmailError";
3
- constructor(email: string);
4
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotAnEmailError = void 0;
4
- class NotAnEmailError extends Error {
5
- static name = 'NotAnEmailError';
6
- constructor(email) {
7
- super(`${email} is not a valid email`);
8
- }
9
- }
10
- exports.NotAnEmailError = NotAnEmailError;
@@ -1,4 +0,0 @@
1
- export declare class NotAnUuidError extends Error {
2
- static readonly name = "NotAnUuidError";
3
- constructor(uuid: string);
4
- }
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.NotAnUuidError = void 0;
4
- class NotAnUuidError extends Error {
5
- static name = 'NotAnUuidError';
6
- constructor(uuid) {
7
- super(`${uuid} is not a valid UUID`);
8
- }
9
- }
10
- exports.NotAnUuidError = NotAnUuidError;
@@ -1,3 +0,0 @@
1
- export * from './errors';
2
- export * from './email';
3
- export * from './uuid';
@@ -1,19 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./errors"), exports);
18
- __exportStar(require("./email"), exports);
19
- __exportStar(require("./uuid"), exports);
@@ -1,7 +0,0 @@
1
- import type { Result } from 'oxide.ts';
2
- import { AbstractValueObject } from '../abstract-value-object';
3
- export declare class Uuid extends AbstractValueObject<string> {
4
- get value(): string;
5
- static create(uuid: string): Result<Uuid, Error>;
6
- static generate(): Uuid;
7
- }
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Uuid = void 0;
4
- const class_validator_1 = require("class-validator");
5
- const oxide_ts_1 = require("oxide.ts");
6
- const ui7_1 = require("ui7");
7
- const abstract_value_object_1 = require("../abstract-value-object");
8
- const not_an_uuid_error_1 = require("../value-objects/errors/not-an-uuid.error");
9
- class Uuid extends abstract_value_object_1.AbstractValueObject {
10
- get value() {
11
- return this.props.value;
12
- }
13
- static create(uuid) {
14
- if (!(0, class_validator_1.isUUID)(uuid)) {
15
- return (0, oxide_ts_1.Err)(new not_an_uuid_error_1.NotAnUuidError(uuid));
16
- }
17
- return (0, oxide_ts_1.Ok)(new Uuid({ value: uuid }));
18
- }
19
- static generate() {
20
- return new Uuid({ value: (0, ui7_1.v7)() });
21
- }
22
- }
23
- exports.Uuid = Uuid;