@atlantjs/arch 9.1.2 → 10.0.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/@tool-box/tests/{entity-builder.util.d.ts → builder.abstract.util.d.ts} +1 -1
- package/@tool-box/tests/{entity-builder.util.js → builder.abstract.util.js} +3 -6
- package/@tool-box/tests/builders/failures/dummies/failure.edge.dummy.d.ts +3 -0
- package/@tool-box/tests/builders/failures/dummies/failure.edge.dummy.js +3 -0
- package/@tool-box/tests/builders/failures/failure.edge.builder.d.ts +6 -0
- package/@tool-box/tests/builders/failures/failure.edge.builder.js +18 -0
- package/@tool-box/tests/builders/user/email.edge.builder.d.ts +6 -0
- package/@tool-box/tests/builders/user/email.edge.builder.js +11 -0
- package/@tool-box/tests/builders/user/person-name.edge.builder.d.ts +6 -0
- package/@tool-box/tests/builders/user/person-name.edge.builder.js +11 -0
- package/@tool-box/tests/builders/user/username.edge.builder.d.ts +6 -0
- package/@tool-box/tests/builders/user/username.edge.builder.js +11 -0
- package/@tool-box/tests/create-fake-command.d.ts +9 -0
- package/@tool-box/tests/create-fake-command.js +23 -0
- package/@tool-box/tests/faker/faker.js +7 -10
- package/@tool-box/utils/datatypes/boolean-utils.d.ts +1 -0
- package/@tool-box/utils/datatypes/boolean-utils.js +5 -2
- package/@tool-box/utils/datatypes/generic-types.d.ts +1 -1
- package/@tool-box/utils/datatypes/generic-types.js +1 -2
- package/@tool-box/utils/datatypes/string-utils.d.ts +1 -3
- package/@tool-box/utils/datatypes/string-utils.js +1 -10
- package/@tool-box/utils/ducts/common.js +7 -11
- package/@tool-box/utils/ducts/optional-type.d.ts +0 -1
- package/@tool-box/utils/ducts/optional-type.js +19 -22
- package/@tool-box/utils/ducts/return-type.d.ts +2 -2
- package/@tool-box/utils/ducts/return-type.js +21 -26
- package/@tool-box/utils/{arrays/extended-map.d.ts → map/map.abstract.d.ts} +1 -2
- package/@tool-box/utils/map/map.abstract.js +13 -0
- package/@tool-box/utils/random/random.d.ts +5 -0
- package/@tool-box/utils/{randoms/random-value.js → random/random.js} +4 -8
- package/@tool-box/utils/type-guard/guardian-exception.js +1 -5
- package/@tool-box/utils/type-guard/guardian.d.ts +11 -13
- package/@tool-box/utils/type-guard/guardian.js +19 -51
- package/@tool-box/utils/type-guard/guardian.type.js +1 -2
- package/README.md +0 -8
- package/index.d.ts +28 -37
- package/index.js +30 -81
- package/objects/@common/edges/email.edge.d.ts +6 -0
- package/{arch/modules/domain/entities/user/value-objects/email.js → objects/@common/edges/email.edge.js} +3 -6
- package/objects/@common/edges/person-name.edge.d.ts +7 -0
- package/objects/@common/edges/person-name.edge.js +14 -0
- package/objects/@common/edges/url.edge.d.ts +6 -0
- package/objects/@common/edges/url.edge.js +17 -0
- package/objects/@common/edges/username.edge.d.ts +3 -0
- package/objects/@common/edges/username.edge.js +3 -0
- package/{arch/modules/domain/entities/uuid.abstract.d.ts → objects/@common/edges/uuid.sketch.edge.d.ts} +2 -2
- package/objects/@common/edges/uuid.sketch.edge.js +18 -0
- package/{arch/modules/domain/enums → objects/@common/points}/header-token-name.enum.js +2 -5
- package/{arch/modules/domain/enums → objects/@common/points}/http-status-codes.enum.js +2 -5
- package/{arch/modules/domain/enums → objects/@common/points}/node-envs.enum.js +2 -5
- package/objects/datetime/edges/datetime.edge.d.ts +27 -0
- package/objects/datetime/edges/datetime.edge.js +133 -0
- package/objects/datetime/points/month-name.enum.d.ts +14 -0
- package/objects/datetime/points/month-name.enum.js +15 -0
- package/objects/datetime/points/week-day.enum.d.ts +9 -0
- package/objects/datetime/points/week-day.enum.js +10 -0
- package/objects/failure/edges/failure.sketch.edge.d.ts +8 -0
- package/objects/failure/edges/failure.sketch.edge.js +23 -0
- package/objects/failure/edges/failure.sketch.polygon.d.ts +9 -0
- package/objects/failure/edges/failure.sketch.polygon.js +1 -0
- package/objects/password/password.edge.d.ts +8 -0
- package/objects/password/password.edge.js +38 -0
- package/{arch/modules/domain/entities/user/password/password.abstract.type.d.ts → objects/password/password.polygon.d.ts} +1 -1
- package/objects/password/password.polygon.js +1 -0
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-consecutive-chars-step.js +3 -6
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-date-step.js +3 -6
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-phone-step.js +3 -6
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-repeated-chars-step.js +3 -6
- package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-string-step.js +3 -6
- package/objects/password/steps/not-allowing-these-chars-step.js +14 -0
- package/objects/password/steps/numeric-step.js +9 -0
- package/objects/password/steps/with-at-least-one-letter-step.js +10 -0
- package/objects/password/steps/with-at-least-one-number-digit-step.js +10 -0
- package/objects/password/steps/with-at-least-one-special-char-step.js +10 -0
- package/{arch/modules/domain/entities/user → objects}/password/steps/with-length-step.js +3 -6
- package/objects/password/validation-step.js +5 -0
- package/objects/password/validation-step.type.js +1 -0
- package/objects/primitives/boolean.edge.sketch.d.ts +7 -0
- package/objects/primitives/boolean.edge.sketch.js +18 -0
- package/objects/primitives/datetime.edge.sketch.d.ts +3 -0
- package/objects/primitives/datetime.edge.sketch.js +3 -0
- package/objects/primitives/number.edge.sketch.d.ts +13 -0
- package/{arch/modules/domain/entities/$number.abstract.js → objects/primitives/number.edge.sketch.js} +12 -15
- package/{arch/modules/domain/entities/$string.abstract.d.ts → objects/primitives/string.edge.sketch.d.ts} +1 -1
- package/{arch/modules/domain/entities/$string.abstract.js → objects/primitives/string.edge.sketch.js} +2 -5
- package/package.json +6 -11
- package/tsconfig.tsbuildinfo +1 -1
- package/@tool-box/tests/builders/failures/dummies/failure.dummy.d.ts +0 -3
- package/@tool-box/tests/builders/failures/dummies/failure.dummy.js +0 -7
- package/@tool-box/tests/builders/failures/failure.builder.d.ts +0 -6
- package/@tool-box/tests/builders/failures/failure.builder.js +0 -21
- package/@tool-box/tests/builders/generic/dummies/uuid.dummy.d.ts +0 -3
- package/@tool-box/tests/builders/generic/dummies/uuid.dummy.js +0 -7
- package/@tool-box/tests/builders/generic/uuid.builder.d.ts +0 -6
- package/@tool-box/tests/builders/generic/uuid.builder.js +0 -14
- package/@tool-box/tests/builders/user/email.builder.d.ts +0 -6
- package/@tool-box/tests/builders/user/email.builder.js +0 -15
- package/@tool-box/tests/builders/user/person-name.builder.d.ts +0 -6
- package/@tool-box/tests/builders/user/person-name.builder.js +0 -15
- package/@tool-box/tests/builders/user/user-id.builder.d.ts +0 -6
- package/@tool-box/tests/builders/user/user-id.builder.js +0 -14
- package/@tool-box/tests/builders/user/username.builder.d.ts +0 -6
- package/@tool-box/tests/builders/user/username.builder.js +0 -15
- package/@tool-box/tests/create-fake-usecase.d.ts +0 -9
- package/@tool-box/tests/create-fake-usecase.js +0 -26
- package/@tool-box/utils/arrays/extended-map.js +0 -22
- package/@tool-box/utils/http-client/http-client-exception.d.ts +0 -3
- package/@tool-box/utils/http-client/http-client-exception.js +0 -12
- package/@tool-box/utils/http-client/http-client-request.d.ts +0 -9
- package/@tool-box/utils/http-client/http-client-request.js +0 -2
- package/@tool-box/utils/http-client/http-client-response.d.ts +0 -18
- package/@tool-box/utils/http-client/http-client-response.get-header.failure.d.ts +0 -4
- package/@tool-box/utils/http-client/http-client-response.get-header.failure.js +0 -14
- package/@tool-box/utils/http-client/http-client-response.js +0 -39
- package/@tool-box/utils/http-client/http-client.d.ts +0 -9
- package/@tool-box/utils/http-client/http-client.js +0 -21
- package/@tool-box/utils/randoms/random-value.d.ts +0 -5
- package/arch/@atlantjs.json +0 -3
- package/arch/biome.json +0 -47
- package/arch/modules/application/failures/failure.abstract.d.ts +0 -9
- package/arch/modules/application/failures/failure.abstract.js +0 -24
- package/arch/modules/application/failures/failure.abstract.type.d.ts +0 -9
- package/arch/modules/application/failures/failure.abstract.type.js +0 -2
- package/arch/modules/application/failures/unknown-failure.d.ts +0 -15
- package/arch/modules/application/failures/unknown-failure.js +0 -16
- package/arch/modules/domain/entities/$array.abstract.d.ts +0 -2
- package/arch/modules/domain/entities/$array.abstract.js +0 -6
- package/arch/modules/domain/entities/$boolean.abstract.d.ts +0 -7
- package/arch/modules/domain/entities/$boolean.abstract.js +0 -21
- package/arch/modules/domain/entities/$date.abstract.d.ts +0 -2
- package/arch/modules/domain/entities/$date.abstract.js +0 -6
- package/arch/modules/domain/entities/$number.abstract.d.ts +0 -13
- package/arch/modules/domain/entities/$object.abstract.d.ts +0 -2
- package/arch/modules/domain/entities/$object.abstract.js +0 -6
- package/arch/modules/domain/entities/entity-frontend.abstract.d.ts +0 -6
- package/arch/modules/domain/entities/entity-frontend.abstract.js +0 -11
- package/arch/modules/domain/entities/solid.abstract.d.ts +0 -4
- package/arch/modules/domain/entities/solid.abstract.js +0 -6
- package/arch/modules/domain/entities/url.abstract.d.ts +0 -3
- package/arch/modules/domain/entities/url.abstract.js +0 -7
- package/arch/modules/domain/entities/user/password/password.abstract.d.ts +0 -8
- package/arch/modules/domain/entities/user/password/password.abstract.js +0 -41
- package/arch/modules/domain/entities/user/password/password.abstract.type.js +0 -2
- package/arch/modules/domain/entities/user/password/steps/not-allowing-these-chars-step.js +0 -17
- package/arch/modules/domain/entities/user/password/steps/numeric-step.js +0 -13
- package/arch/modules/domain/entities/user/password/steps/with-at-least-one-letter-step.js +0 -14
- package/arch/modules/domain/entities/user/password/steps/with-at-least-one-number-digit-step.js +0 -14
- package/arch/modules/domain/entities/user/password/steps/with-at-least-one-special-char-step.js +0 -14
- package/arch/modules/domain/entities/user/password/validation-step.js +0 -9
- package/arch/modules/domain/entities/user/password/validation-step.type.js +0 -2
- package/arch/modules/domain/entities/user/value-objects/email.d.ts +0 -6
- package/arch/modules/domain/entities/user/value-objects/person-name.d.ts +0 -7
- package/arch/modules/domain/entities/user/value-objects/person-name.js +0 -17
- package/arch/modules/domain/entities/user/value-objects/user-id.d.ts +0 -3
- package/arch/modules/domain/entities/user/value-objects/user-id.js +0 -7
- package/arch/modules/domain/entities/user/value-objects/username.d.ts +0 -3
- package/arch/modules/domain/entities/user/value-objects/username.js +0 -7
- package/arch/modules/domain/entities/uuid.abstract.js +0 -23
- package/arch/modules/domain/entities/value-object.abstract.d.ts +0 -3
- package/arch/modules/domain/entities/value-object.abstract.js +0 -7
- package/arch/modules/infrastructure/services/http-client.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/http-client.abstract.js +0 -1
- package/arch/modules/infrastructure/services/payloads/service.payload.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/payloads/service.payload.abstract.js +0 -1
- package/arch/modules/infrastructure/services/responses/service.response.abstract.d.ts +0 -0
- package/arch/modules/infrastructure/services/responses/service.response.abstract.js +0 -1
- package/arch/tsconfig-backend.json +0 -3
- package/arch/tsconfig-default.json +0 -45
- package/arch/tsconfig-frontend.json +0 -3
- package/arch/tsconfig-lib.json +0 -6
- package/arch/tsconfig-mobile.json +0 -3
- /package/{arch/modules/domain/enums → objects/@common/points}/header-token-name.enum.d.ts +0 -0
- /package/{arch/modules/domain/enums → objects/@common/points}/http-status-codes.enum.d.ts +0 -0
- /package/{arch/modules/domain/enums → objects/@common/points}/node-envs.enum.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-consecutive-chars-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-date-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-phone-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-repeated-chars-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-string-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/not-allowing-these-chars-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/numeric-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-letter-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-number-digit-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/with-at-least-one-special-char-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/steps/with-length-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/validation-step.d.ts +0 -0
- /package/{arch/modules/domain/entities/user → objects}/password/validation-step.type.d.ts +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
type ModifierCallback<T> = (dataToModify: T) => void;
|
|
2
|
-
export declare abstract class
|
|
2
|
+
export declare abstract class BuilderAbstract<T, TBuilder extends BuilderAbstract<T, TBuilder>> {
|
|
3
3
|
private readonly innerType;
|
|
4
4
|
protected modifiers: Array<ModifierCallback<T>>;
|
|
5
5
|
protected constructor(innerType: new (...args: any[]) => TBuilder);
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
class EntityBuilder {
|
|
1
|
+
export class BuilderAbstract {
|
|
2
|
+
innerType;
|
|
3
|
+
modifiers = [];
|
|
5
4
|
constructor(innerType) {
|
|
6
5
|
this.innerType = innerType;
|
|
7
|
-
this.modifiers = [];
|
|
8
6
|
}
|
|
9
7
|
build() {
|
|
10
8
|
const instance = this.buildDefault();
|
|
@@ -36,4 +34,3 @@ class EntityBuilder {
|
|
|
36
34
|
return newBuilder;
|
|
37
35
|
}
|
|
38
36
|
}
|
|
39
|
-
exports.EntityBuilder = EntityBuilder;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { FailureEdgeDummy } from "./dummies/failure.edge.dummy";
|
|
2
|
+
import { BuilderAbstract } from "../../builder.abstract.util";
|
|
3
|
+
import { faker } from "../../faker/faker";
|
|
4
|
+
export class FailureEdgeBuilder extends BuilderAbstract {
|
|
5
|
+
instance;
|
|
6
|
+
constructor(entityClass) {
|
|
7
|
+
super(FailureEdgeBuilder);
|
|
8
|
+
this.instance = entityClass;
|
|
9
|
+
}
|
|
10
|
+
buildDefault() {
|
|
11
|
+
const dummy = new FailureEdgeDummy({
|
|
12
|
+
failureClass: FailureEdgeBuilder,
|
|
13
|
+
message: faker.lorem.words(),
|
|
14
|
+
});
|
|
15
|
+
Object.assign(dummy, this.instance);
|
|
16
|
+
return dummy;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BuilderAbstract } from "../../builder.abstract.util";
|
|
2
|
+
import { EmailEdge } from "../../../../objects/@common/edges/email.edge";
|
|
3
|
+
export declare class EmailEdgeBuilder extends BuilderAbstract<EmailEdge, EmailEdgeBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): EmailEdge;
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BuilderAbstract } from "../../builder.abstract.util";
|
|
2
|
+
import { faker } from "../../faker/faker";
|
|
3
|
+
import { EmailEdge } from "../../../../objects/@common/edges/email.edge";
|
|
4
|
+
export class EmailEdgeBuilder extends BuilderAbstract {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(EmailEdgeBuilder);
|
|
7
|
+
}
|
|
8
|
+
buildDefault() {
|
|
9
|
+
return new EmailEdge(faker.internet.email());
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BuilderAbstract } from "../../builder.abstract.util";
|
|
2
|
+
import { PersonNameEdge } from "../../../../objects/@common/edges/person-name.edge";
|
|
3
|
+
export declare class PersonNameEdgeBuilder extends BuilderAbstract<PersonNameEdge, PersonNameEdgeBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): PersonNameEdge;
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BuilderAbstract } from "../../builder.abstract.util";
|
|
2
|
+
import { faker } from "../../faker/faker";
|
|
3
|
+
import { PersonNameEdge } from "../../../../objects/@common/edges/person-name.edge";
|
|
4
|
+
export class PersonNameEdgeBuilder extends BuilderAbstract {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(PersonNameEdgeBuilder);
|
|
7
|
+
}
|
|
8
|
+
buildDefault() {
|
|
9
|
+
return new PersonNameEdge(faker.person.fullName());
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BuilderAbstract } from "../../builder.abstract.util";
|
|
2
|
+
import { UsernameEdge } from "../../../../objects/@common/edges/username.edge";
|
|
3
|
+
export declare class UsernameEdgeBuilder extends BuilderAbstract<UsernameEdge, UsernameEdgeBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): UsernameEdge;
|
|
6
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BuilderAbstract } from "../../builder.abstract.util";
|
|
2
|
+
import { faker } from "../../faker/faker";
|
|
3
|
+
import { UsernameEdge } from "../../../../objects/@common/edges/username.edge";
|
|
4
|
+
export class UsernameEdgeBuilder extends BuilderAbstract {
|
|
5
|
+
constructor() {
|
|
6
|
+
super(UsernameEdgeBuilder);
|
|
7
|
+
}
|
|
8
|
+
buildDefault() {
|
|
9
|
+
return new UsernameEdge(faker.internet.username());
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Return } from "../utils/ducts/return-type";
|
|
2
|
+
import { FailureSketchEdge } from "../../objects/failure/edges/failure.sketch.edge";
|
|
3
|
+
export declare class CreateFakeCommand {
|
|
4
|
+
private _response;
|
|
5
|
+
static new<UsecaseStub>(): UsecaseStub & CreateFakeCommand;
|
|
6
|
+
protected execute(): Promise<Return<unknown, unknown>>;
|
|
7
|
+
withSuccess(response: unknown): this;
|
|
8
|
+
withFailure(response?: FailureSketchEdge): this;
|
|
9
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { FailureEdgeDummy } from "./builders/failures/dummies/failure.edge.dummy";
|
|
2
|
+
import { FailureEdgeBuilder } from "./builders/failures/failure.edge.builder";
|
|
3
|
+
import { Failure, Success } from "../utils/ducts/return-type";
|
|
4
|
+
export class CreateFakeCommand {
|
|
5
|
+
_response;
|
|
6
|
+
static new() {
|
|
7
|
+
const instance = new CreateFakeCommand();
|
|
8
|
+
return instance;
|
|
9
|
+
}
|
|
10
|
+
async execute() {
|
|
11
|
+
if (this._response.hasFailure())
|
|
12
|
+
return Failure(this._response.unwrapFail());
|
|
13
|
+
return Success(this._response.unwrap());
|
|
14
|
+
}
|
|
15
|
+
withSuccess(response) {
|
|
16
|
+
this._response = Success(response);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
withFailure(response) {
|
|
20
|
+
this._response = Failure(response ?? new FailureEdgeBuilder(FailureEdgeDummy).build());
|
|
21
|
+
return this;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.faker = void 0;
|
|
4
|
-
exports.faker = {
|
|
1
|
+
export const faker = {
|
|
5
2
|
date: {
|
|
6
3
|
past: ({ yearsAgo = 1 } = {}) => {
|
|
7
4
|
const date = new Date();
|
|
@@ -35,15 +32,15 @@ exports.faker = {
|
|
|
35
32
|
productDescription: ({ lines = 3 } = {}) => {
|
|
36
33
|
const result = [];
|
|
37
34
|
for (let i = 0; i < lines; i++) {
|
|
38
|
-
result.push(
|
|
35
|
+
result.push(faker.lorem.paragraph());
|
|
39
36
|
}
|
|
40
37
|
return result.join("\n");
|
|
41
38
|
}
|
|
42
39
|
},
|
|
43
40
|
image: {
|
|
44
41
|
url: () => {
|
|
45
|
-
const width =
|
|
46
|
-
const height =
|
|
42
|
+
const width = faker.number.int({ min: 100, max: 1000 });
|
|
43
|
+
const height = faker.number.int({ min: 100, max: 1000 });
|
|
47
44
|
return `https://via.placeholder.com/${width}x${height}`;
|
|
48
45
|
}
|
|
49
46
|
},
|
|
@@ -81,7 +78,7 @@ exports.faker = {
|
|
|
81
78
|
return lastNames[Math.floor(Math.random() * lastNames.length)];
|
|
82
79
|
},
|
|
83
80
|
fullName: () => {
|
|
84
|
-
return `${
|
|
81
|
+
return `${faker.person.firstName()} ${faker.person.lastName()}`;
|
|
85
82
|
},
|
|
86
83
|
},
|
|
87
84
|
internet: {
|
|
@@ -91,7 +88,7 @@ exports.faker = {
|
|
|
91
88
|
},
|
|
92
89
|
email: () => {
|
|
93
90
|
const domains = ["example.com", "test.com", "demo.com", "sample.com"];
|
|
94
|
-
return `${
|
|
91
|
+
return `${faker.internet.username()}@${domains[Math.floor(Math.random() * domains.length)]}`;
|
|
95
92
|
},
|
|
96
93
|
url: () => {
|
|
97
94
|
const protocols = ["http", "https"];
|
|
@@ -117,7 +114,7 @@ exports.faker = {
|
|
|
117
114
|
paragraph: ({ sentences = 5 } = {}) => {
|
|
118
115
|
const result = [];
|
|
119
116
|
for (let i = 0; i < sentences; i++) {
|
|
120
|
-
result.push(
|
|
117
|
+
result.push(faker.lorem.words({ count: Math.floor(Math.random() * 10) + 5 }));
|
|
121
118
|
}
|
|
122
119
|
return result.join(". ") + ".";
|
|
123
120
|
}
|
|
@@ -9,11 +9,14 @@ Boolean.prototype.not = function () {
|
|
|
9
9
|
return !this.valueOf();
|
|
10
10
|
};
|
|
11
11
|
Boolean.prototype.and = function (value) {
|
|
12
|
-
return this.valueOf() && value;
|
|
12
|
+
return this.valueOf() === true && value === true;
|
|
13
13
|
};
|
|
14
14
|
Boolean.prototype.or = function (value) {
|
|
15
|
-
return this.valueOf() || value;
|
|
15
|
+
return this.valueOf() === true || value === true;
|
|
16
16
|
};
|
|
17
17
|
Boolean.prototype.equal = function (value) {
|
|
18
18
|
return this === value;
|
|
19
19
|
};
|
|
20
|
+
Boolean.prototype.different = function (value) {
|
|
21
|
+
return this !== value;
|
|
22
|
+
};
|
|
@@ -2,14 +2,12 @@ interface String {
|
|
|
2
2
|
toKebabCase(): string;
|
|
3
3
|
toSnakeCase(): string;
|
|
4
4
|
toPascalCase(): string;
|
|
5
|
-
|
|
6
|
-
trimSpaces(): string;
|
|
5
|
+
sanitize(): string;
|
|
7
6
|
capitalize(): string;
|
|
8
7
|
toTitleCase(): string;
|
|
9
8
|
contains(substring: string): boolean;
|
|
10
9
|
truncate(length: number): String;
|
|
11
10
|
removeWhitespace(): string;
|
|
12
|
-
toArray(): string[];
|
|
13
11
|
isEmpty(): boolean;
|
|
14
12
|
fromBase64(): string;
|
|
15
13
|
}
|
|
@@ -8,10 +8,7 @@ String.prototype.toSnakeCase = function () {
|
|
|
8
8
|
String.prototype.toPascalCase = function () {
|
|
9
9
|
return this.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g, (match) => match.toUpperCase()).replace(/\s+/g, "");
|
|
10
10
|
};
|
|
11
|
-
String.prototype.
|
|
12
|
-
return this.split("").reverse().join("");
|
|
13
|
-
};
|
|
14
|
-
String.prototype.trimSpaces = function () {
|
|
11
|
+
String.prototype.sanitize = function () {
|
|
15
12
|
return this.replace(/\s+/g, " ").trim();
|
|
16
13
|
};
|
|
17
14
|
String.prototype.capitalize = function () {
|
|
@@ -19,9 +16,6 @@ String.prototype.capitalize = function () {
|
|
|
19
16
|
.map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
|
|
20
17
|
.join(" ");
|
|
21
18
|
};
|
|
22
|
-
String.prototype.toTitleCase = function () {
|
|
23
|
-
return this.replace(/\w\S*/g, (word) => word.charAt(0).toUpperCase() + word.substr(1).toLowerCase());
|
|
24
|
-
};
|
|
25
19
|
String.prototype.contains = function (substring) {
|
|
26
20
|
return this.indexOf(substring) !== -1;
|
|
27
21
|
};
|
|
@@ -33,9 +27,6 @@ String.prototype.truncate = function (length) {
|
|
|
33
27
|
String.prototype.removeWhitespace = function () {
|
|
34
28
|
return this.replace(/\s+/g, "");
|
|
35
29
|
};
|
|
36
|
-
String.prototype.toArray = function () {
|
|
37
|
-
return this.split("");
|
|
38
|
-
};
|
|
39
30
|
String.prototype.isEmpty = function () {
|
|
40
31
|
return this.length === 0;
|
|
41
32
|
};
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
exports.ValueReturn = Symbol("ValueReturn");
|
|
8
|
-
exports.FnVal = Symbol("FnVal");
|
|
9
|
-
exports.EmptyArray = Object.freeze([]);
|
|
10
|
-
function isTruthy(val) {
|
|
1
|
+
import { _ } from "../type-guard/guardian";
|
|
2
|
+
export const SuccessReturn = Symbol("SuccessReturn");
|
|
3
|
+
export const ValueReturn = Symbol("ValueReturn");
|
|
4
|
+
export const FnVal = Symbol("FnVal");
|
|
5
|
+
export const EmptyArray = Object.freeze([]);
|
|
6
|
+
export function isTruthy(val) {
|
|
11
7
|
return val instanceof Date
|
|
12
|
-
?
|
|
8
|
+
? _.isEqual(val.getTime(), val.getTime())
|
|
13
9
|
: !!val;
|
|
14
10
|
}
|
|
@@ -20,6 +20,5 @@ declare class OptionalType<T> {
|
|
|
20
20
|
unpackOrElse(this: Optional<T>, f: () => T): T;
|
|
21
21
|
}
|
|
22
22
|
export declare function Optional<T>(val: T): Optional<From<T>>;
|
|
23
|
-
export declare function Something<T>(val: T): Something<T>;
|
|
24
23
|
export declare const Nothing: Readonly<OptionalType<never>>;
|
|
25
24
|
export {};
|
|
@@ -1,50 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Nothing = void 0;
|
|
4
|
-
exports.Optional = Optional;
|
|
5
|
-
exports.Something = Something;
|
|
6
|
-
const common_1 = require("./common");
|
|
1
|
+
import { EmptyArray, SuccessReturn, ValueReturn, isTruthy, } from "./common";
|
|
7
2
|
class OptionalType {
|
|
3
|
+
[SuccessReturn];
|
|
4
|
+
[ValueReturn];
|
|
8
5
|
constructor(val, something) {
|
|
9
|
-
this[
|
|
10
|
-
this[
|
|
6
|
+
this[SuccessReturn] = something;
|
|
7
|
+
this[ValueReturn] = val;
|
|
11
8
|
}
|
|
12
9
|
[Symbol.iterator]() {
|
|
13
|
-
return this[
|
|
14
|
-
? this[
|
|
15
|
-
:
|
|
10
|
+
return this[SuccessReturn]
|
|
11
|
+
? this[ValueReturn][Symbol.iterator]()
|
|
12
|
+
: EmptyArray[Symbol.iterator]();
|
|
16
13
|
}
|
|
17
14
|
hasSomething() {
|
|
18
|
-
return this[
|
|
15
|
+
return this[SuccessReturn];
|
|
19
16
|
}
|
|
20
17
|
hasNothing() {
|
|
21
|
-
return !this[
|
|
18
|
+
return !this[SuccessReturn];
|
|
22
19
|
}
|
|
23
20
|
unpack() {
|
|
24
|
-
if (this[
|
|
25
|
-
return this[
|
|
21
|
+
if (this[SuccessReturn]) {
|
|
22
|
+
return this[ValueReturn];
|
|
26
23
|
}
|
|
27
24
|
throw new Error("Failed to unpack optional value. There is nothing in here");
|
|
28
25
|
}
|
|
29
26
|
unpackAnyway() {
|
|
30
|
-
return this[
|
|
27
|
+
return this[ValueReturn];
|
|
31
28
|
}
|
|
32
29
|
unpackOr(def) {
|
|
33
|
-
return this[
|
|
30
|
+
return this[SuccessReturn] ? this[ValueReturn] : def;
|
|
34
31
|
}
|
|
35
32
|
unpackOrElse(f) {
|
|
36
|
-
return this[
|
|
33
|
+
return this[SuccessReturn] ? this[ValueReturn] : f();
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
|
-
function Optional(val) {
|
|
36
|
+
export function Optional(val) {
|
|
40
37
|
return from(val);
|
|
41
38
|
}
|
|
42
39
|
function Something(val) {
|
|
43
40
|
return new OptionalType(val, true);
|
|
44
41
|
}
|
|
45
|
-
|
|
42
|
+
export const Nothing = Object.freeze(new OptionalType(undefined, false));
|
|
46
43
|
function from(val) {
|
|
47
|
-
return
|
|
44
|
+
return isTruthy(val) && !(val instanceof Error)
|
|
48
45
|
? Something(val)
|
|
49
|
-
:
|
|
46
|
+
: Nothing;
|
|
50
47
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FailureAbstract } from "../../../arch/modules/application/failures/failure.abstract";
|
|
2
1
|
import { FalseyValues, IterType, SuccessReturn, ValueReturn } from "./common";
|
|
2
|
+
import { FailureSketchEdge } from "../../../objects/failure/edges/failure.sketch.edge";
|
|
3
3
|
export type Success<SuccessReturn> = ReturnType<SuccessReturn, never>;
|
|
4
4
|
export type Failure<FailureReturn> = ReturnType<never, FailureReturn>;
|
|
5
5
|
export type Return<T, E> = ReturnType<T, E>;
|
|
@@ -18,5 +18,5 @@ export declare class ReturnType<SuccessReturn, FailureReturn> {
|
|
|
18
18
|
}
|
|
19
19
|
export declare function Return<T>(val: T): Return<From<T>, (T extends Error ? T : never) | (Extract<FalseyValues, T> extends never ? never : null)>;
|
|
20
20
|
export declare function Success<SuccessReturn>(successValue?: SuccessReturn): Success<SuccessReturn>;
|
|
21
|
-
export declare function Failure<FailureReturn extends
|
|
21
|
+
export declare function Failure<FailureReturn extends FailureSketchEdge | null | undefined>(failureValue?: FailureReturn): Failure<FailureReturn>;
|
|
22
22
|
export {};
|
|
@@ -1,57 +1,52 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
exports.Success = Success;
|
|
6
|
-
exports.Failure = Failure;
|
|
7
|
-
const common_1 = require("./common");
|
|
8
|
-
class ReturnType {
|
|
1
|
+
import { EmptyArray, SuccessReturn, ValueReturn, isTruthy, } from "./common";
|
|
2
|
+
export class ReturnType {
|
|
3
|
+
[SuccessReturn];
|
|
4
|
+
[ValueReturn];
|
|
9
5
|
constructor(value, hasSuccess) {
|
|
10
|
-
this[
|
|
11
|
-
this[
|
|
6
|
+
this[ValueReturn] = value;
|
|
7
|
+
this[SuccessReturn] = hasSuccess;
|
|
12
8
|
}
|
|
13
9
|
[Symbol.iterator]() {
|
|
14
|
-
return this[
|
|
15
|
-
? this[
|
|
16
|
-
:
|
|
10
|
+
return this[SuccessReturn]
|
|
11
|
+
? this[ValueReturn][Symbol.iterator]()
|
|
12
|
+
: EmptyArray[Symbol.iterator]();
|
|
17
13
|
}
|
|
18
14
|
hasSuccess() {
|
|
19
|
-
return this[
|
|
15
|
+
return this[SuccessReturn];
|
|
20
16
|
}
|
|
21
17
|
hasFailure() {
|
|
22
|
-
return !this[
|
|
18
|
+
return !this[SuccessReturn];
|
|
23
19
|
}
|
|
24
20
|
unwrap() {
|
|
25
|
-
if (this[
|
|
26
|
-
return this[
|
|
21
|
+
if (this[SuccessReturn]) {
|
|
22
|
+
return this[ValueReturn];
|
|
27
23
|
}
|
|
28
24
|
throw new Error("Failed to unwrap Return. There is failure in here");
|
|
29
25
|
}
|
|
30
26
|
unwrapFail() {
|
|
31
|
-
if (this[
|
|
27
|
+
if (this[SuccessReturn]) {
|
|
32
28
|
throw new Error("Failed to unwrapFail Return. There is success in here");
|
|
33
29
|
}
|
|
34
|
-
return this[
|
|
30
|
+
return this[ValueReturn];
|
|
35
31
|
}
|
|
36
32
|
unwrapOr(def) {
|
|
37
|
-
return this[
|
|
33
|
+
return this[SuccessReturn] ? this[ValueReturn] : def;
|
|
38
34
|
}
|
|
39
35
|
unwrapAnyway() {
|
|
40
|
-
return this[
|
|
36
|
+
return this[ValueReturn];
|
|
41
37
|
}
|
|
42
38
|
}
|
|
43
|
-
|
|
44
|
-
function Return(val) {
|
|
39
|
+
export function Return(val) {
|
|
45
40
|
return from(val);
|
|
46
41
|
}
|
|
47
|
-
function Success(successValue) {
|
|
42
|
+
export function Success(successValue) {
|
|
48
43
|
return new ReturnType(successValue, true);
|
|
49
44
|
}
|
|
50
|
-
function Failure(failureValue) {
|
|
45
|
+
export function Failure(failureValue) {
|
|
51
46
|
return new ReturnType(failureValue, false);
|
|
52
47
|
}
|
|
53
48
|
function from(val) {
|
|
54
|
-
return
|
|
49
|
+
return isTruthy(val)
|
|
55
50
|
? new ReturnType(val, !(val instanceof Error))
|
|
56
51
|
: Failure(null);
|
|
57
52
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { _ } from "../type-guard/guardian";
|
|
2
|
+
export class MapAbstract extends Map {
|
|
3
|
+
getOrDefault(key, defaultValue) {
|
|
4
|
+
return this.get(key) ?? defaultValue;
|
|
5
|
+
}
|
|
6
|
+
getOrThrow(key, errorMessage = "Key not mapped") {
|
|
7
|
+
const value = this.get(key);
|
|
8
|
+
if (_.isUndefined(value)) {
|
|
9
|
+
throw Error(errorMessage);
|
|
10
|
+
}
|
|
11
|
+
return value;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.RandomValue = void 0;
|
|
4
|
-
class RandomValue {
|
|
5
|
-
static randomNumber(min, max) {
|
|
1
|
+
export class Random {
|
|
2
|
+
static number(min, max) {
|
|
6
3
|
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
7
4
|
}
|
|
8
|
-
static
|
|
5
|
+
static enum(anEnum) {
|
|
9
6
|
const keys = Object.keys(anEnum).filter((x) => Number.isNaN(Number(x)));
|
|
10
7
|
const randomKeyIndex = Math.floor(Math.random() * keys.length);
|
|
11
8
|
const randomKey = keys[randomKeyIndex];
|
|
12
9
|
return anEnum[randomKey];
|
|
13
10
|
}
|
|
14
|
-
static
|
|
11
|
+
static enumExcluding(anEnum, excepts) {
|
|
15
12
|
const exceptKeys = excepts.map((value) => Object.keys(anEnum).find((key) => anEnum[key] === value));
|
|
16
13
|
const validKeys = Object.keys(anEnum).filter((key) => Number.isNaN(Number(key)) && !exceptKeys.includes(key));
|
|
17
14
|
if (validKeys.length === 0) {
|
|
@@ -22,4 +19,3 @@ class RandomValue {
|
|
|
22
19
|
return anEnum[randomKey];
|
|
23
20
|
}
|
|
24
21
|
}
|
|
25
|
-
exports.RandomValue = RandomValue;
|
|
@@ -1,31 +1,29 @@
|
|
|
1
1
|
import { PrimitiveType } from "./guardian.type";
|
|
2
|
-
|
|
2
|
+
declare class Guardian {
|
|
3
3
|
static and(...args: boolean[]): boolean;
|
|
4
4
|
static or(...args: boolean[]): boolean;
|
|
5
5
|
static greaterThan(value: number, reference: number): boolean;
|
|
6
6
|
static lessThan(value: number, reference: number): boolean;
|
|
7
|
-
static
|
|
8
|
-
static
|
|
9
|
-
static
|
|
10
|
-
static
|
|
7
|
+
static isEmptyArray<T>(value: T[] | null | undefined): value is T[];
|
|
8
|
+
static isFilledArray<T>(value: T[] | null | undefined): value is T[];
|
|
9
|
+
static isLengthArray<T>(value: T[] | null | undefined, reference: number): value is T[];
|
|
10
|
+
private static isEmpty;
|
|
11
11
|
static isUndefined(value: unknown): value is undefined;
|
|
12
12
|
static isNotUndefined(value: unknown): value is boolean;
|
|
13
13
|
static isNull(value: unknown): value is null;
|
|
14
14
|
static isNotNull(value: unknown): value is boolean;
|
|
15
15
|
static isEqual(valueA: unknown, valueB: unknown): boolean;
|
|
16
|
-
static isAnyOf(reference: unknown, anyValues: unknown[]): boolean;
|
|
17
16
|
static isDifferent(valueA: unknown, valueB: unknown): boolean;
|
|
18
|
-
static
|
|
19
|
-
static isFalsy(value: boolean | undefined): boolean;
|
|
17
|
+
static isAnyOf(reference: unknown, anyValues: unknown[]): boolean;
|
|
20
18
|
static ternaryCondition<TTrue, TFalse>(condition: boolean, returnIfTrue: TTrue, returnIfFalse: TFalse): TTrue | TFalse;
|
|
21
19
|
static isBetween(value: number | string, min: number, max: number): boolean;
|
|
22
|
-
static isLengthEqual(value: unknown, length: number): boolean;
|
|
23
20
|
static isNullOrUndefined(value: unknown): value is null | undefined;
|
|
24
21
|
static isNotNullOrUndefined(value: unknown): value is boolean;
|
|
25
|
-
static isNumber
|
|
26
|
-
static isString
|
|
27
|
-
static isArray
|
|
28
|
-
static isObject
|
|
22
|
+
private static isNumber;
|
|
23
|
+
private static isString;
|
|
24
|
+
private static isArray;
|
|
25
|
+
private static isObject;
|
|
29
26
|
static isTypeOf<T>(value: unknown, type: PrimitiveType): value is T;
|
|
30
27
|
static isNotTypeOf<T>(value: unknown, type: PrimitiveType): value is T;
|
|
31
28
|
}
|
|
29
|
+
export { Guardian as _ };
|