@atlantjs/arch 1.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/README.md +8 -0
- package/configs/env/env-vars.d.ts +3 -0
- package/configs/env/env-vars.js +20 -0
- package/external-files/biome.json +47 -0
- package/external-files/typescript/tsconfig-backend.json +3 -0
- package/external-files/typescript/tsconfig-default.json +42 -0
- package/external-files/typescript/tsconfig-frontend.json +3 -0
- package/external-files/typescript/tsconfig-lib.json +6 -0
- package/external-files/typescript/tsconfig-mobile.json +3 -0
- package/index.d.ts +51 -0
- package/index.js +106 -0
- package/objects/arch/application/errors/application-error.abstract.d.ts +8 -0
- package/objects/arch/application/errors/application-error.abstract.js +25 -0
- package/objects/arch/application/errors/application-error.abstract.type.d.ts +9 -0
- package/objects/arch/application/errors/application-error.abstract.type.js +2 -0
- package/objects/arch/application/errors/unknown-application-error.d.ts +15 -0
- package/objects/arch/application/errors/unknown-application-error.js +16 -0
- package/objects/arch/domain/entity.abstract.d.ts +3 -0
- package/objects/arch/domain/entity.abstract.js +6 -0
- package/objects/arch/domain/usecase.abstract.d.ts +4 -0
- package/objects/arch/domain/usecase.abstract.js +6 -0
- package/objects/arch/infrastructure/controller.abstract.d.ts +6 -0
- package/objects/arch/infrastructure/controller.abstract.js +6 -0
- package/objects/auth/entities/client/client-credentials.abstract.d.ts +13 -0
- package/objects/auth/entities/client/client-credentials.abstract.js +27 -0
- package/objects/auth/entities/client/client-credentials.abstract.type.d.ts +7 -0
- package/objects/auth/entities/client/client-credentials.abstract.type.js +2 -0
- package/objects/auth/entities/client/realm-credentials.abstract.d.ts +13 -0
- package/objects/auth/entities/client/realm-credentials.abstract.js +20 -0
- package/objects/auth/entities/token/access-token-signature.d.ts +10 -0
- package/objects/auth/entities/token/access-token-signature.js +58 -0
- package/objects/auth/entities/token/access-token.abstract.d.ts +10 -0
- package/objects/auth/entities/token/access-token.abstract.has-role.error.d.ts +4 -0
- package/objects/auth/entities/token/access-token.abstract.has-role.error.js +14 -0
- package/objects/auth/entities/token/access-token.abstract.js +25 -0
- package/objects/auth/entities/token/access-token.abstract.signature-verify.error.d.ts +4 -0
- package/objects/auth/entities/token/access-token.abstract.signature-verify.error.js +10 -0
- package/objects/auth/entities/token/access-token.abstract.type.d.ts +44 -0
- package/objects/auth/entities/token/access-token.abstract.type.js +2 -0
- package/objects/auth/entities/token/rotation.d.ts +12 -0
- package/objects/auth/entities/token/rotation.js +108 -0
- package/objects/auth/entities/token/rotation.type.d.ts +5 -0
- package/objects/auth/entities/token/rotation.type.js +2 -0
- package/objects/auth/entities/token/token.d.ts +16 -0
- package/objects/auth/entities/token/token.js +50 -0
- package/objects/auth/entities/token/token.type.d.ts +5 -0
- package/objects/auth/entities/token/token.type.js +2 -0
- package/objects/auth/entities/user/enums/user-status.enum.d.ts +4 -0
- package/objects/auth/entities/user/enums/user-status.enum.js +8 -0
- package/objects/auth/entities/user/password/password.abstract.d.ts +8 -0
- package/objects/auth/entities/user/password/password.abstract.js +41 -0
- package/objects/auth/entities/user/password/password.abstract.type.d.ts +5 -0
- package/objects/auth/entities/user/password/password.abstract.type.js +2 -0
- package/objects/auth/entities/user/password/steps/not-allowing-consecutive-chars-step.d.ts +11 -0
- package/objects/auth/entities/user/password/steps/not-allowing-consecutive-chars-step.js +34 -0
- package/objects/auth/entities/user/password/steps/not-allowing-date-step.d.ts +11 -0
- package/objects/auth/entities/user/password/steps/not-allowing-date-step.js +61 -0
- package/objects/auth/entities/user/password/steps/not-allowing-phone-step.d.ts +7 -0
- package/objects/auth/entities/user/password/steps/not-allowing-phone-step.js +27 -0
- package/objects/auth/entities/user/password/steps/not-allowing-repeated-chars-step.d.ts +11 -0
- package/objects/auth/entities/user/password/steps/not-allowing-repeated-chars-step.js +34 -0
- package/objects/auth/entities/user/password/steps/not-allowing-string-step.d.ts +7 -0
- package/objects/auth/entities/user/password/steps/not-allowing-string-step.js +19 -0
- package/objects/auth/entities/user/password/steps/not-allowing-these-chars-step.d.ts +10 -0
- package/objects/auth/entities/user/password/steps/not-allowing-these-chars-step.js +17 -0
- package/objects/auth/entities/user/password/steps/numeric-step.d.ts +5 -0
- package/objects/auth/entities/user/password/steps/numeric-step.js +13 -0
- package/objects/auth/entities/user/password/steps/with-at-least-one-letter-step.d.ts +5 -0
- package/objects/auth/entities/user/password/steps/with-at-least-one-letter-step.js +14 -0
- package/objects/auth/entities/user/password/steps/with-at-least-one-number-digit-step.d.ts +5 -0
- package/objects/auth/entities/user/password/steps/with-at-least-one-number-digit-step.js +14 -0
- package/objects/auth/entities/user/password/steps/with-at-least-one-special-char-step.d.ts +5 -0
- package/objects/auth/entities/user/password/steps/with-at-least-one-special-char-step.js +14 -0
- package/objects/auth/entities/user/password/steps/with-length-step.d.ts +11 -0
- package/objects/auth/entities/user/password/steps/with-length-step.js +18 -0
- package/objects/auth/entities/user/password/validation-step.d.ts +5 -0
- package/objects/auth/entities/user/password/validation-step.js +9 -0
- package/objects/auth/entities/user/password/validation-step.type.d.ts +4 -0
- package/objects/auth/entities/user/password/validation-step.type.js +2 -0
- package/objects/auth/entities/user/user-credentials.abstract.d.ts +9 -0
- package/objects/auth/entities/user/user-credentials.abstract.js +6 -0
- package/objects/auth/entities/user/user-tokens.abstract.d.ts +13 -0
- package/objects/auth/entities/user/user-tokens.abstract.js +27 -0
- package/objects/auth/entities/user/user-tokens.abstract.type.d.ts +5 -0
- package/objects/auth/entities/user/user-tokens.abstract.type.js +2 -0
- package/objects/auth/entities/user/user.abstract.d.ts +21 -0
- package/objects/auth/entities/user/user.abstract.js +29 -0
- package/objects/auth/entities/user/value-objects/email.d.ts +6 -0
- package/objects/auth/entities/user/value-objects/email.js +17 -0
- package/objects/auth/entities/user/value-objects/person-name.d.ts +7 -0
- package/objects/auth/entities/user/value-objects/person-name.js +17 -0
- package/objects/auth/entities/user/value-objects/user-id.d.ts +3 -0
- package/objects/auth/entities/user/value-objects/user-id.js +7 -0
- package/objects/auth/entities/user/value-objects/username.d.ts +3 -0
- package/objects/auth/entities/user/value-objects/username.js +7 -0
- package/objects/auth/enums/client.enum.d.ts +3 -0
- package/objects/auth/enums/client.enum.js +7 -0
- package/objects/auth/enums/realm.enum.d.ts +3 -0
- package/objects/auth/enums/realm.enum.js +7 -0
- package/objects/auth/enums/role-group.enum.d.ts +4 -0
- package/objects/auth/enums/role-group.enum.js +8 -0
- package/objects/auth/enums/role.enum.d.ts +17 -0
- package/objects/auth/enums/role.enum.js +21 -0
- package/objects/auth/enums/token-name-header.enum.d.ts +4 -0
- package/objects/auth/enums/token-name-header.enum.js +8 -0
- package/objects/configs/enums/node-envs.enum.d.ts +6 -0
- package/objects/configs/enums/node-envs.enum.js +10 -0
- package/objects/datatypes/entities/$boolean.abstract.d.ts +7 -0
- package/objects/datatypes/entities/$boolean.abstract.js +21 -0
- package/objects/datatypes/entities/$number.abstract.d.ts +13 -0
- package/objects/datatypes/entities/$number.abstract.js +60 -0
- package/objects/datatypes/entities/$string.abstract.d.ts +10 -0
- package/objects/datatypes/entities/$string.abstract.js +34 -0
- package/objects/datatypes/entities/uuid.abstract.d.ts +7 -0
- package/objects/datatypes/entities/uuid.abstract.js +20 -0
- package/package.json +66 -0
- package/tests/builders/auth/access-token-signature.builder.d.ts +6 -0
- package/tests/builders/auth/access-token-signature.builder.js +19 -0
- package/tests/builders/auth/access-token.builder.d.ts +6 -0
- package/tests/builders/auth/access-token.builder.js +15 -0
- package/tests/builders/auth/rotation.builder.d.ts +6 -0
- package/tests/builders/auth/rotation.builder.js +19 -0
- package/tests/builders/auth/token.builder.d.ts +7 -0
- package/tests/builders/auth/token.builder.js +15 -0
- package/tests/builders/auth/value-objects/client-credentials.builder.d.ts +6 -0
- package/tests/builders/auth/value-objects/client-credentials.builder.js +18 -0
- package/tests/builders/auth/value-objects/dummies/access-token.dummy.d.ts +3 -0
- package/tests/builders/auth/value-objects/dummies/access-token.dummy.js +7 -0
- package/tests/builders/auth/value-objects/dummies/client-credentials.dummy.d.ts +3 -0
- package/tests/builders/auth/value-objects/dummies/client-credentials.dummy.js +7 -0
- package/tests/builders/auth/value-objects/dummies/realm-credentials.dummy.d.ts +6 -0
- package/tests/builders/auth/value-objects/dummies/realm-credentials.dummy.js +12 -0
- package/tests/builders/auth/value-objects/dummies/user-tokens.dummy.d.ts +3 -0
- package/tests/builders/auth/value-objects/dummies/user-tokens.dummy.js +7 -0
- package/tests/builders/auth/value-objects/realm-credentials.builder.d.ts +6 -0
- package/tests/builders/auth/value-objects/realm-credentials.builder.js +17 -0
- package/tests/builders/auth/value-objects/user-tokens.builder.d.ts +7 -0
- package/tests/builders/auth/value-objects/user-tokens.builder.js +18 -0
- package/tests/builders/errors/application-error.builder.d.ts +6 -0
- package/tests/builders/errors/application-error.builder.js +21 -0
- package/tests/builders/errors/dummies/application-error.dummy.d.ts +3 -0
- package/tests/builders/errors/dummies/application-error.dummy.js +7 -0
- package/tests/builders/generic/dummies/uuid.dummy.d.ts +3 -0
- package/tests/builders/generic/dummies/uuid.dummy.js +7 -0
- package/tests/builders/generic/uuid.builder.d.ts +6 -0
- package/tests/builders/generic/uuid.builder.js +14 -0
- package/tests/builders/user/user-id.builder.d.ts +6 -0
- package/tests/builders/user/user-id.builder.js +15 -0
- package/tests/create-fake-stub.d.ts +8 -0
- package/tests/create-fake-stub.js +37 -0
- package/tests/entity-builder.util.d.ts +13 -0
- package/tests/entity-builder.util.js +39 -0
- package/tests/faker/faker.d.ts +2 -0
- package/tests/faker/faker.js +6 -0
- package/utils/arrays/extended-map.d.ts +5 -0
- package/utils/arrays/extended-map.js +23 -0
- package/utils/datatypes/generic-types.d.ts +7 -0
- package/utils/datatypes/generic-types.js +3 -0
- package/utils/datatypes/string-utils.d.ts +3 -0
- package/utils/datatypes/string-utils.js +4 -0
- package/utils/ducts/common.d.ts +9 -0
- package/utils/ducts/common.js +14 -0
- package/utils/ducts/optional-type.d.ts +25 -0
- package/utils/ducts/optional-type.js +50 -0
- package/utils/ducts/return-type.d.ts +22 -0
- package/utils/ducts/return-type.js +60 -0
- package/utils/randoms/random-enum-value.d.ts +2 -0
- package/utils/randoms/random-enum-value.js +20 -0
- package/utils/randoms/random-number.d.ts +6 -0
- package/utils/randoms/random-number.js +6 -0
- package/utils/type-guard/guardian-exception.d.ts +2 -0
- package/utils/type-guard/guardian-exception.js +6 -0
- package/utils/type-guard/guardian.d.ts +29 -0
- package/utils/type-guard/guardian.js +132 -0
- package/utils/type-guard/guardian.type.d.ts +1 -0
- package/utils/type-guard/guardian.type.js +2 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.$string = void 0;
|
|
4
|
+
class $string {
|
|
5
|
+
constructor(value) {
|
|
6
|
+
this.value = value;
|
|
7
|
+
this.sanitize();
|
|
8
|
+
this.validate();
|
|
9
|
+
}
|
|
10
|
+
toString() {
|
|
11
|
+
return this.value;
|
|
12
|
+
}
|
|
13
|
+
has(value) {
|
|
14
|
+
return !this.value.indexOf(value);
|
|
15
|
+
}
|
|
16
|
+
extract(start, end) {
|
|
17
|
+
const indexStartValue = this.value.indexOf(start);
|
|
18
|
+
const indexEndValue = this.value.lastIndexOf(end) + 1;
|
|
19
|
+
return this.value.substring(indexStartValue, indexEndValue);
|
|
20
|
+
}
|
|
21
|
+
remove(substrings) {
|
|
22
|
+
const regex = new RegExp(`[${substrings.join("")}]`, "g");
|
|
23
|
+
return this.value.replace(regex, "");
|
|
24
|
+
}
|
|
25
|
+
sanitize() {
|
|
26
|
+
this.value = this.value.trim();
|
|
27
|
+
}
|
|
28
|
+
validate() {
|
|
29
|
+
if (this.value.length <= 0) {
|
|
30
|
+
throw Error(`${this.constructor.name} should not be empty.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.$string = $string;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UuidAbstract = void 0;
|
|
4
|
+
const uuid_1 = require("uuid");
|
|
5
|
+
class UuidAbstract {
|
|
6
|
+
constructor(value = (0, uuid_1.v7)()) {
|
|
7
|
+
this.value = value;
|
|
8
|
+
if (!UuidAbstract.pattern.test(value)) {
|
|
9
|
+
throw new TypeError("The provided UUID is invalid. Please ensure it is in the correct format");
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
equals(uuid) {
|
|
13
|
+
return this.toString() === uuid.toString();
|
|
14
|
+
}
|
|
15
|
+
toString() {
|
|
16
|
+
return this.value;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.UuidAbstract = UuidAbstract;
|
|
20
|
+
UuidAbstract.pattern = /^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}$/;
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@atlantjs/arch",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"license": "UNLICENSED",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"registry": "https://registry.npmjs.org/"
|
|
8
|
+
},
|
|
9
|
+
"directories": {
|
|
10
|
+
"src": "src",
|
|
11
|
+
"test": "tests"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+ssh://git@github.com/MovingApp/lib-atlantjs-guardian.git"
|
|
16
|
+
},
|
|
17
|
+
"author": "movingapp",
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/MovingApp/lib-atlantjs-guardian/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/MovingApp/lib-atlantjs-guardian#readme",
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rm -rf dist && tsc --project tsconfig.json && tscpaths -p tsconfig.json -s ./src -o ./dist",
|
|
24
|
+
"lint": "npx biome check src --indent-style=tab ",
|
|
25
|
+
"lint:fix": "yarn lint --fix --unsafe --organize-imports-enabled=true",
|
|
26
|
+
"test": "yarn cross-env ENVIRONMENT=test jest --passWithNoTests --silent --noStackTrace --detectOpenHandles --bail",
|
|
27
|
+
"test:verbose": "yarn cross-env ENVIRONMENT=test jest --passWithNoTests --runInBand",
|
|
28
|
+
"test:unit": "yarn test -c jest-unit.config.js",
|
|
29
|
+
"test:unit:watch": "yarn test:unit --watch",
|
|
30
|
+
"test:unit:watch:staged": "yarn test:unit --watch --findRelatedTests",
|
|
31
|
+
"test:unit:watch:changed": "yarn test:unit --watch --onlyChanged",
|
|
32
|
+
"test:unit:cov": "yarn test:unit --coverage --runInBand"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@faker-js/faker": "^9.0.3",
|
|
36
|
+
"class-transformer": "^0.5.1",
|
|
37
|
+
"dotenv": "^16.4.5",
|
|
38
|
+
"env-var": "^7.5.0",
|
|
39
|
+
"express": "^4.21.1",
|
|
40
|
+
"jsonwebtoken": "^9.0.2",
|
|
41
|
+
"jwk-to-pem": "^2.0.6",
|
|
42
|
+
"module-alias": "^2.2.3",
|
|
43
|
+
"reflect-metadata": "^0.2.2",
|
|
44
|
+
"uuid": "^10.0.0"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@biomejs/biome": "1.8.3",
|
|
48
|
+
"@types/express": "^5.0.0",
|
|
49
|
+
"@types/jest": "^29.5.12",
|
|
50
|
+
"@types/jsonwebtoken": "^9.0.7",
|
|
51
|
+
"@types/jwk-to-pem": "^2.0.3",
|
|
52
|
+
"@types/uuid": "^10.0.0",
|
|
53
|
+
"copyfiles": "^2.4.1",
|
|
54
|
+
"cross-env": "^7.0.3",
|
|
55
|
+
"faker": "^5.5.3",
|
|
56
|
+
"jest": "^29.7.0",
|
|
57
|
+
"ts-jest": "^29.2.5",
|
|
58
|
+
"ts-node": "^10.9.1",
|
|
59
|
+
"ts-node-dev": "^2.0.0",
|
|
60
|
+
"ts-prune": "^0.10.3",
|
|
61
|
+
"tsconfig-paths": "^4.2.0",
|
|
62
|
+
"tscpaths": "^0.0.9",
|
|
63
|
+
"tslib": "^2.7.0",
|
|
64
|
+
"typescript": "^5.2.2"
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccessTokenSignature } from "../../../objects/auth/entities/token/access-token-signature";
|
|
2
|
+
import { EntityBuilder } from "../../entity-builder.util";
|
|
3
|
+
export declare class AccessTokenSignatureBuilder extends EntityBuilder<AccessTokenSignature, AccessTokenSignatureBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): AccessTokenSignature;
|
|
6
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccessTokenSignatureBuilder = void 0;
|
|
4
|
+
const access_token_signature_1 = require("../../../objects/auth/entities/token/access-token-signature");
|
|
5
|
+
const entity_builder_util_1 = require("../../entity-builder.util");
|
|
6
|
+
const _1 = require("@faker-js/faker/.");
|
|
7
|
+
class AccessTokenSignatureBuilder extends entity_builder_util_1.EntityBuilder {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(AccessTokenSignatureBuilder);
|
|
10
|
+
}
|
|
11
|
+
buildDefault() {
|
|
12
|
+
return new access_token_signature_1.AccessTokenSignature({
|
|
13
|
+
realmUrl: _1.faker.internet.url(),
|
|
14
|
+
minTimeBetweenJwksRequests: _1.faker.number.int(),
|
|
15
|
+
publicKey: _1.faker.string.uuid(),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.AccessTokenSignatureBuilder = AccessTokenSignatureBuilder;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AccessTokenDummy } from "./value-objects/dummies/access-token.dummy";
|
|
2
|
+
import { EntityBuilder } from "../../entity-builder.util";
|
|
3
|
+
export declare class AccessTokenBuilder extends EntityBuilder<AccessTokenDummy, AccessTokenBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): AccessTokenDummy;
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccessTokenBuilder = void 0;
|
|
4
|
+
const access_token_dummy_1 = require("./value-objects/dummies/access-token.dummy");
|
|
5
|
+
const entity_builder_util_1 = require("../../entity-builder.util");
|
|
6
|
+
const _1 = require("@faker-js/faker/.");
|
|
7
|
+
class AccessTokenBuilder extends entity_builder_util_1.EntityBuilder {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(AccessTokenBuilder);
|
|
10
|
+
}
|
|
11
|
+
buildDefault() {
|
|
12
|
+
return new access_token_dummy_1.AccessTokenDummy(_1.faker.string.uuid());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.AccessTokenBuilder = AccessTokenBuilder;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Rotation } from "../../../objects/auth/entities/token/rotation";
|
|
2
|
+
import { EntityBuilder } from "../../entity-builder.util";
|
|
3
|
+
export declare class RotationBuilder extends EntityBuilder<Rotation, RotationBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): Rotation;
|
|
6
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RotationBuilder = void 0;
|
|
4
|
+
const rotation_1 = require("../../../objects/auth/entities/token/rotation");
|
|
5
|
+
const entity_builder_util_1 = require("../../entity-builder.util");
|
|
6
|
+
const _1 = require("@faker-js/faker/.");
|
|
7
|
+
class RotationBuilder extends entity_builder_util_1.EntityBuilder {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(RotationBuilder);
|
|
10
|
+
}
|
|
11
|
+
buildDefault() {
|
|
12
|
+
return new rotation_1.Rotation({
|
|
13
|
+
realmUrl: _1.faker.internet.url(),
|
|
14
|
+
minTimeBetweenJwksRequests: _1.faker.number.int(),
|
|
15
|
+
publicKey: _1.faker.string.uuid(),
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.RotationBuilder = RotationBuilder;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Token } from "../../../objects/auth/entities/token/token";
|
|
2
|
+
import { EntityBuilder } from "../../entity-builder.util";
|
|
3
|
+
import { JwtPayload } from "jsonwebtoken";
|
|
4
|
+
export declare class TokenBuilder<T extends JwtPayload> extends EntityBuilder<Token<T>, TokenBuilder<T>> {
|
|
5
|
+
constructor();
|
|
6
|
+
protected buildDefault(): Token<T>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TokenBuilder = void 0;
|
|
4
|
+
const token_1 = require("../../../objects/auth/entities/token/token");
|
|
5
|
+
const entity_builder_util_1 = require("../../entity-builder.util");
|
|
6
|
+
const faker_1 = require("@faker-js/faker");
|
|
7
|
+
class TokenBuilder extends entity_builder_util_1.EntityBuilder {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(TokenBuilder);
|
|
10
|
+
}
|
|
11
|
+
buildDefault() {
|
|
12
|
+
return new token_1.Token(faker_1.faker.string.uuid());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.TokenBuilder = TokenBuilder;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ClientCredentialsDummy } from "./dummies/client-credentials.dummy";
|
|
2
|
+
import { EntityBuilder } from "../../../entity-builder.util";
|
|
3
|
+
export declare class ClientCredentialsBuilder extends EntityBuilder<ClientCredentialsDummy, ClientCredentialsBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): ClientCredentialsDummy;
|
|
6
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientCredentialsBuilder = void 0;
|
|
4
|
+
const faker_1 = require("@faker-js/faker");
|
|
5
|
+
const client_credentials_dummy_1 = require("./dummies/client-credentials.dummy");
|
|
6
|
+
const entity_builder_util_1 = require("../../../entity-builder.util");
|
|
7
|
+
const random_enum_value_1 = require("../../../../utils/randoms/random-enum-value");
|
|
8
|
+
const client_enum_1 = require("../../../../objects/auth/enums/client.enum");
|
|
9
|
+
const realm_enum_1 = require("../../../../objects/auth/enums/realm.enum");
|
|
10
|
+
class ClientCredentialsBuilder extends entity_builder_util_1.EntityBuilder {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(ClientCredentialsBuilder);
|
|
13
|
+
}
|
|
14
|
+
buildDefault() {
|
|
15
|
+
return new client_credentials_dummy_1.ClientCredentialsDummy((0, random_enum_value_1.randomEnumValue)(client_enum_1.ClientEnum), faker_1.faker.string.uuid(), (0, random_enum_value_1.randomEnumValue)(realm_enum_1.RealmEnum));
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.ClientCredentialsBuilder = ClientCredentialsBuilder;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccessTokenDummy = void 0;
|
|
4
|
+
const access_token_abstract_1 = require("../../../../../objects/auth/entities/token/access-token.abstract");
|
|
5
|
+
class AccessTokenDummy extends access_token_abstract_1.AccessTokenAbstract {
|
|
6
|
+
}
|
|
7
|
+
exports.AccessTokenDummy = AccessTokenDummy;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ClientCredentialsDummy = void 0;
|
|
4
|
+
const client_credentials_abstract_1 = require("../../../../../objects/auth/entities/client/client-credentials.abstract");
|
|
5
|
+
class ClientCredentialsDummy extends client_credentials_abstract_1.ClientCredentialsAbstract {
|
|
6
|
+
}
|
|
7
|
+
exports.ClientCredentialsDummy = ClientCredentialsDummy;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RealmCredentialsAbstract } from "../../../../../objects/auth/entities/client/realm-credentials.abstract";
|
|
2
|
+
import { ClientCredentialsDummy } from "./client-credentials.dummy";
|
|
3
|
+
import { Optional } from "../../../../../utils/ducts/optional-type";
|
|
4
|
+
export declare class RealmCredentialsDummy extends RealmCredentialsAbstract {
|
|
5
|
+
clientWrapped: Optional<ClientCredentialsDummy>;
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RealmCredentialsDummy = void 0;
|
|
4
|
+
const realm_credentials_abstract_1 = require("../../../../../objects/auth/entities/client/realm-credentials.abstract");
|
|
5
|
+
const optional_type_1 = require("../../../../../utils/ducts/optional-type");
|
|
6
|
+
class RealmCredentialsDummy extends realm_credentials_abstract_1.RealmCredentialsAbstract {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(...arguments);
|
|
9
|
+
this.clientWrapped = optional_type_1.Nothing;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
exports.RealmCredentialsDummy = RealmCredentialsDummy;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserTokensDummy = void 0;
|
|
4
|
+
const user_tokens_abstract_1 = require("../../../../../objects/auth/entities/user/user-tokens.abstract");
|
|
5
|
+
class UserTokensDummy extends user_tokens_abstract_1.UserTokensAbstract {
|
|
6
|
+
}
|
|
7
|
+
exports.UserTokensDummy = UserTokensDummy;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { RealmCredentialsDummy } from "./dummies/realm-credentials.dummy";
|
|
2
|
+
import { EntityBuilder } from "../../../entity-builder.util";
|
|
3
|
+
export declare class RealmCredentialsBuilder extends EntityBuilder<RealmCredentialsDummy, RealmCredentialsBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): RealmCredentialsDummy;
|
|
6
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RealmCredentialsBuilder = void 0;
|
|
4
|
+
const realm_enum_1 = require("../../../../objects/auth/enums/realm.enum");
|
|
5
|
+
const realm_credentials_dummy_1 = require("./dummies/realm-credentials.dummy");
|
|
6
|
+
const entity_builder_util_1 = require("../../../entity-builder.util");
|
|
7
|
+
const random_enum_value_1 = require("../../../../utils/randoms/random-enum-value");
|
|
8
|
+
const _1 = require("@faker-js/faker/.");
|
|
9
|
+
class RealmCredentialsBuilder extends entity_builder_util_1.EntityBuilder {
|
|
10
|
+
constructor() {
|
|
11
|
+
super(RealmCredentialsBuilder);
|
|
12
|
+
}
|
|
13
|
+
buildDefault() {
|
|
14
|
+
return new realm_credentials_dummy_1.RealmCredentialsDummy((0, random_enum_value_1.randomEnumValue)(realm_enum_1.RealmEnum), _1.faker.word.noun(), _1.faker.string.hexadecimal());
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
exports.RealmCredentialsBuilder = RealmCredentialsBuilder;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { UserTokensAbstract } from "../../../../objects/auth/entities/user/user-tokens.abstract";
|
|
2
|
+
import { EntityBuilder } from "../../../entity-builder.util";
|
|
3
|
+
export declare class UserTokensBuilder<T extends UserTokensAbstract> extends EntityBuilder<UserTokensAbstract, UserTokensBuilder<T>> {
|
|
4
|
+
private instance;
|
|
5
|
+
constructor(entityClass: new (...args: any[]) => T);
|
|
6
|
+
protected buildDefault(): T;
|
|
7
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserTokensBuilder = void 0;
|
|
4
|
+
const token_builder_1 = require("../token.builder");
|
|
5
|
+
const user_tokens_dummy_1 = require("./dummies/user-tokens.dummy");
|
|
6
|
+
const entity_builder_util_1 = require("../../../entity-builder.util");
|
|
7
|
+
class UserTokensBuilder extends entity_builder_util_1.EntityBuilder {
|
|
8
|
+
constructor(entityClass) {
|
|
9
|
+
super(UserTokensBuilder);
|
|
10
|
+
this.instance = entityClass;
|
|
11
|
+
}
|
|
12
|
+
buildDefault() {
|
|
13
|
+
const dummy = new user_tokens_dummy_1.UserTokensDummy(new token_builder_1.TokenBuilder().build(), new token_builder_1.TokenBuilder().build(), new Date(Date.now()));
|
|
14
|
+
Object.assign(dummy, this.instance);
|
|
15
|
+
return dummy;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.UserTokensBuilder = UserTokensBuilder;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EntityBuilder } from "../../entity-builder.util";
|
|
2
|
+
export declare class ApplicationErrorBuilder<T> extends EntityBuilder<T, ApplicationErrorBuilder<T>> {
|
|
3
|
+
private instance;
|
|
4
|
+
constructor(entityClass: new (...args: any[]) => T);
|
|
5
|
+
protected buildDefault(): T;
|
|
6
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationErrorBuilder = void 0;
|
|
4
|
+
const faker_1 = require("@faker-js/faker");
|
|
5
|
+
const application_error_dummy_1 = require("./dummies/application-error.dummy");
|
|
6
|
+
const entity_builder_util_1 = require("../../entity-builder.util");
|
|
7
|
+
class ApplicationErrorBuilder extends entity_builder_util_1.EntityBuilder {
|
|
8
|
+
constructor(entityClass) {
|
|
9
|
+
super(ApplicationErrorBuilder);
|
|
10
|
+
this.instance = entityClass;
|
|
11
|
+
}
|
|
12
|
+
buildDefault() {
|
|
13
|
+
const dummy = new application_error_dummy_1.ApplicationErrorDummy({
|
|
14
|
+
className: faker_1.faker.string.alphanumeric(),
|
|
15
|
+
message: faker_1.faker.lorem.words(),
|
|
16
|
+
});
|
|
17
|
+
Object.assign(dummy, this.instance);
|
|
18
|
+
return dummy;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.ApplicationErrorBuilder = ApplicationErrorBuilder;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ApplicationErrorDummy = void 0;
|
|
4
|
+
const application_error_abstract_1 = require("../../../../objects/arch/application/errors/application-error.abstract");
|
|
5
|
+
class ApplicationErrorDummy extends application_error_abstract_1.ApplicationErrorAbstract {
|
|
6
|
+
}
|
|
7
|
+
exports.ApplicationErrorDummy = ApplicationErrorDummy;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UuidDummy = void 0;
|
|
4
|
+
const uuid_abstract_1 = require("../../../../objects/datatypes/entities/uuid.abstract");
|
|
5
|
+
class UuidDummy extends uuid_abstract_1.UuidAbstract {
|
|
6
|
+
}
|
|
7
|
+
exports.UuidDummy = UuidDummy;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UuidBuilder = void 0;
|
|
4
|
+
const uuid_dummy_1 = require("./dummies/uuid.dummy");
|
|
5
|
+
const entity_builder_util_1 = require("../../entity-builder.util");
|
|
6
|
+
class UuidBuilder extends entity_builder_util_1.EntityBuilder {
|
|
7
|
+
constructor() {
|
|
8
|
+
super(UuidBuilder);
|
|
9
|
+
}
|
|
10
|
+
buildDefault() {
|
|
11
|
+
return new uuid_dummy_1.UuidDummy();
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.UuidBuilder = UuidBuilder;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { UserId } from "../../../objects/auth/entities/user/value-objects/user-id";
|
|
2
|
+
import { EntityBuilder } from "../../entity-builder.util";
|
|
3
|
+
export declare class UserIdBuilder extends EntityBuilder<UserId, UserIdBuilder> {
|
|
4
|
+
constructor();
|
|
5
|
+
protected buildDefault(): UserId;
|
|
6
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UserIdBuilder = void 0;
|
|
4
|
+
const user_id_1 = require("../../../objects/auth/entities/user/value-objects/user-id");
|
|
5
|
+
const uuid_builder_1 = require("../generic/uuid.builder");
|
|
6
|
+
const entity_builder_util_1 = require("../../entity-builder.util");
|
|
7
|
+
class UserIdBuilder extends entity_builder_util_1.EntityBuilder {
|
|
8
|
+
constructor() {
|
|
9
|
+
super(UserIdBuilder);
|
|
10
|
+
}
|
|
11
|
+
buildDefault() {
|
|
12
|
+
return new user_id_1.UserId(new uuid_builder_1.UuidBuilder().build().toString());
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
exports.UserIdBuilder = UserIdBuilder;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Return } from "../utils/ducts/return-type";
|
|
2
|
+
export declare class CreateFakeUsecase {
|
|
3
|
+
private _response;
|
|
4
|
+
static new<UsecaseStub>(): UsecaseStub & CreateFakeUsecase;
|
|
5
|
+
protected execute(): Promise<Return<unknown, unknown>>;
|
|
6
|
+
withSuccess(response: unknown): this;
|
|
7
|
+
withError(response?: unknown): this;
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.CreateFakeUsecase = void 0;
|
|
13
|
+
const application_error_builder_1 = require("./builders/errors/application-error.builder");
|
|
14
|
+
const application_error_dummy_1 = require("./builders/errors/dummies/application-error.dummy");
|
|
15
|
+
const return_type_1 = require("../utils/ducts/return-type");
|
|
16
|
+
class CreateFakeUsecase {
|
|
17
|
+
static new() {
|
|
18
|
+
const instance = new CreateFakeUsecase();
|
|
19
|
+
return instance;
|
|
20
|
+
}
|
|
21
|
+
execute() {
|
|
22
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
23
|
+
if (this._response.isFailure())
|
|
24
|
+
return (0, return_type_1.Failure)(this._response.unwrapErr());
|
|
25
|
+
return (0, return_type_1.Success)(this._response.unwrap());
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
withSuccess(response) {
|
|
29
|
+
this._response = (0, return_type_1.Success)(response);
|
|
30
|
+
return this;
|
|
31
|
+
}
|
|
32
|
+
withError(response) {
|
|
33
|
+
this._response = (0, return_type_1.Failure)(response !== null && response !== void 0 ? response : new application_error_builder_1.ApplicationErrorBuilder(application_error_dummy_1.ApplicationErrorDummy).build());
|
|
34
|
+
return this;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
exports.CreateFakeUsecase = CreateFakeUsecase;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
type ModifierCallback<T> = (dataToModify: T) => void;
|
|
2
|
+
export declare abstract class EntityBuilder<T, TBuilder extends EntityBuilder<T, TBuilder>> {
|
|
3
|
+
private readonly innerType;
|
|
4
|
+
protected modifiers: Array<ModifierCallback<T>>;
|
|
5
|
+
protected constructor(innerType: new (...args: any[]) => TBuilder);
|
|
6
|
+
build(): T;
|
|
7
|
+
with<K extends keyof T>(key: K, value: T[K]): TBuilder;
|
|
8
|
+
buildMany(quantity?: number): T[];
|
|
9
|
+
protected applyModifiers(instance: T): void;
|
|
10
|
+
protected newBuilder(modifier: ModifierCallback<T>): TBuilder;
|
|
11
|
+
protected abstract buildDefault(): T;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EntityBuilder = void 0;
|
|
4
|
+
class EntityBuilder {
|
|
5
|
+
constructor(innerType) {
|
|
6
|
+
this.innerType = innerType;
|
|
7
|
+
this.modifiers = [];
|
|
8
|
+
}
|
|
9
|
+
build() {
|
|
10
|
+
const instance = this.buildDefault();
|
|
11
|
+
this.applyModifiers(instance);
|
|
12
|
+
return instance;
|
|
13
|
+
}
|
|
14
|
+
with(key, value) {
|
|
15
|
+
return this.newBuilder((entity) => {
|
|
16
|
+
entity[key] = value;
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
buildMany(quantity) {
|
|
20
|
+
let calculatedQuantity = quantity;
|
|
21
|
+
if (calculatedQuantity === undefined) {
|
|
22
|
+
const min = 2;
|
|
23
|
+
const max = 6;
|
|
24
|
+
calculatedQuantity = Math.floor(Math.random() * (max - min + 1) + min);
|
|
25
|
+
}
|
|
26
|
+
return Array.from({ length: calculatedQuantity }, () => this.build());
|
|
27
|
+
}
|
|
28
|
+
applyModifiers(instance) {
|
|
29
|
+
for (const modifier of this.modifiers) {
|
|
30
|
+
modifier(instance);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
newBuilder(modifier) {
|
|
34
|
+
const newBuilder = new this.innerType();
|
|
35
|
+
newBuilder.modifiers = [...this.modifiers, modifier];
|
|
36
|
+
return newBuilder;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.EntityBuilder = EntityBuilder;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExtendedMap = void 0;
|
|
4
|
+
const guardian_1 = require("../type-guard/guardian");
|
|
5
|
+
class ExtendedMap extends Map {
|
|
6
|
+
getOrDefault(key, defaultValue) {
|
|
7
|
+
var _a;
|
|
8
|
+
return (_a = this.get(key)) !== null && _a !== void 0 ? _a : defaultValue;
|
|
9
|
+
}
|
|
10
|
+
getOrThrow(key, errorMessage = "Key not mapped") {
|
|
11
|
+
const value = this.get(key);
|
|
12
|
+
if (guardian_1.Guardian.isUndefined(value)) {
|
|
13
|
+
throw Error(errorMessage);
|
|
14
|
+
}
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
invert() {
|
|
18
|
+
const inverted = new ExtendedMap();
|
|
19
|
+
this.forEach((value, key) => inverted.set(value, key));
|
|
20
|
+
return inverted;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.ExtendedMap = ExtendedMap;
|