Skip to content

Commit

Permalink
Merge branch 'stage'
Browse files Browse the repository at this point in the history
  • Loading branch information
Necrelox committed Jul 12, 2024
2 parents 70f52ce + 2598cf5 commit 3c456cd
Show file tree
Hide file tree
Showing 51 changed files with 1,862 additions and 5,997 deletions.
192 changes: 101 additions & 91 deletions .eslintrc

Large diffs are not rendered by default.

31 changes: 0 additions & 31 deletions .github/workflows/coverage.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .github/workflows/docs-and-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 21.7.1
node-version: 22.4.1

- name: Install Dependencies
run: npm install
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/release-and-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,15 @@ jobs:
- name: Publish
uses: actions/setup-node@v4
with:
node-version: 21.7.1
node-version: 22.4.1
registry-url: 'https://registry.npmjs.org'
if: ${{ steps.release.outputs.release_created }}
- run: npm install
if: ${{ steps.release.outputs.release_created }}
- run: npm run pkg::build
if: ${{ steps.release.outputs.release_created }}
- run: npm ci
- run: npm run build
if: ${{ steps.release.outputs.release_created }}
- run: npm publish --access public
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
if: ${{ steps.release.outputs.release_created }}

4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.idea
Build
coverage
node_modules
docs/
coverage
tsconfig.tsbuildinfo
3 changes: 1 addition & 2 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
.vscode
coverage/
docs/
esbuild.config.ts
Configs/
Source/
Tests/
tsconfig.json
tsconfig.tsbuildinfo
jest.config.json
CHANGELOG.md
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v21.7.1
v22.4.1
27 changes: 27 additions & 0 deletions Configs/esbuild.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import esbuild from 'esbuild';

import pkg from '../package.json' with { type: 'json' };

const safePkg = pkg;
const dependencies = safePkg.dependencies ? Object.keys(safePkg.dependencies) : undefined;
const devDependencies = safePkg.devDependencies ? Object.keys(safePkg.devDependencies) : undefined;

const external = [...(dependencies || []), ...(devDependencies || [])];

const options = {
bundle: true,
color: true,
entryPoints: ['./Source/App.ts'],
external,
format: 'esm',
keepNames: true,
loader: { '.ts': 'ts' },
minify: true,
outfile: './Build/App.js',
platform: 'node',
sourcemap: 'linked',
treeShaking: true,
tsconfig: './tsconfig.json',
};

esbuild.build(options);
11 changes: 7 additions & 4 deletions Source/App.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
export * from './Common/Errors';
export * from './Domain/Services/Data';
export * from './Domain/Services/Data/TransformerStrategies';
export * from './Domain/Services/Security';
export * from '@/Common/Error/Enum/index.js';
export * from '@/Common/Error/index.js';
export * from '@/Common/Interface/index.js';
export * from '@/Domain/Service/Data/index.js';
export * from '@/Domain/Service/Data/Interface/index.js';
export * from '@/Domain/Service/Data/TransformerStrategies/index.js';
export * from '@/Domain/Service/Security/index.js';
Original file line number Diff line number Diff line change
@@ -1,72 +1,82 @@
import { randomUUID } from 'crypto';

import type { IBasaltErrorOptions } from '@/Common/Interface/index.js';

/**
* ErrorEntity is a class that represents an error entity with a unique identifier.
* BasaltError is a class that represents an error entity with a unique identifier.
*/
export class ErrorEntity extends Error {
export class BasaltError extends Error {
/**
* The unique identifier of the error.
* This identifier is used to track the error in the logs.
* @readonly
*/
private readonly _uuidError: string = randomUUID();

/**
* The name of the error entity.
* The date when the error was created.
* @readonly
*/
private readonly _name: string;
private readonly _date: Date = new Date();

/**
* The error code.
* @readonly
*/
private readonly _code: string;
private readonly _code: number;
/**
* The error detail.
* @readonly
*/
private readonly _detail?: unknown;
private readonly _detail: unknown;

/**
* Creates a new instance of the ErrorEntity class.
*
* @param code - The error code.
* @param detail - The error detail.
* @param basaltErrorOptions - The options to create the error entity. ({@link IBasaltErrorOptions})
*/
public constructor(code: string, detail?: unknown) {
public constructor(basaltErrorOptions: Readonly<IBasaltErrorOptions>) {
super();
this._name = this.constructor.name;
this._code = code;
this.message = code;
this._detail = detail;
this._code = basaltErrorOptions.code ?? 500;
this.message = basaltErrorOptions.messageKey;
this._detail = basaltErrorOptions.detail;
if (Error.captureStackTrace)
Error.captureStackTrace(this, this.constructor);
}

/**
* Gets the error code.
* @returns The error code.
* Gets the unique identifier of the error.
* @readonly
* @returns The unique identifier of the error.
*/
public get code(): string {
return this._code;
public get uuidError(): string {
return this._uuidError;
}

/**
* Gets the error name.
* @returns The error name.
* Gets the date when the error was created.
* @readonly
* @returns The date when the error was created.
*/
public override get name(): string {
return this._name;
public get date(): Date {
return this._date;
}

/**
* Gets the error detail.
* @returns The error detail.
* Gets the error code.
* @readonly
* @returns The error code.
*/
public get detail(): unknown {
return this._detail;
public get code(): number {
return this._code;
}

/**
* Gets the unique identifier of the error.
* @returns The unique identifier of the error.
* Gets the error detail.
* @readonly
* @returns The error detail.
*/
public get uuidError(): string {
return this._uuidError;
public get detail(): unknown {
return this._detail;
}
}
11 changes: 11 additions & 0 deletions Source/Common/Error/Enum/ServiceErrorKeys.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* ServiceErrorKeys is an enum that contains the error codes for the Service layer
*/
export enum ServiceErrorKeys {
PASSWORD_EMPTY = 'error.domain.service.security.basaltPassword.passwordEmpty',
PASSWORD_HASHING_FAILED = 'error.domain.service.security.basaltPassword.passwordHashingFailed',
PASSWORD_VERIFICATION_FAILED = 'error.domain.service.security.basaltPassword.passwordVerificationFailed',
DATA_NULL = 'error.domain.service.data.basaltData.dataNull',
DATA_MUST_BE_PLAIN_OBJECT = 'error.domain.service.data.basaltData.dataMustBePlainObject',
DATA_EMPTY_KEYS = 'error.domain.service.data.basaltData.dataEmptyKeys',
}
1 change: 1 addition & 0 deletions Source/Common/Error/Enum/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ServiceErrorKeys.js';
2 changes: 2 additions & 0 deletions Source/Common/Error/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './BasaltError.js';

24 changes: 0 additions & 24 deletions Source/Common/Errors/ErrorBasaltData.ts

This file was deleted.

25 changes: 0 additions & 25 deletions Source/Common/Errors/ErrorBasaltSecurity.ts

This file was deleted.

4 changes: 0 additions & 4 deletions Source/Common/Errors/index.ts

This file was deleted.

19 changes: 19 additions & 0 deletions Source/Common/Interface/IBasaltErrorOptions.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/**
* Represents the options for the Basalt error.
*/
export interface IBasaltErrorOptions {
/**
* The error key.
*/
messageKey: string;

/**
* The status code.
*/
code?: number;

/**
* The error detail.
*/
detail?: unknown;
}
1 change: 1 addition & 0 deletions Source/Common/Interface/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './IBasaltErrorOptions.js';
Loading

0 comments on commit 3c456cd

Please sign in to comment.