tshex-cli 1.0.28 → 1.0.30

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.
@@ -1,29 +1,17 @@
1
1
  import { type DataManager } from './managers.js'
2
- import { type DriverAdapter } from './drivers.js'
2
+
3
+ type Generic = Record<string, unknown>
3
4
 
4
5
  /**
5
6
  * @description Acts as an intermediary between plain source data and domain objects.
6
7
  * It transforms records into domain representations and can translate them back when needed.
7
8
  */
8
- export abstract class Repository<
9
- DataShape extends Record<string, unknown> = Record<string, unknown>,
10
- EntityShape extends Record<string, unknown> = Record<string, unknown>
11
- > {
9
+ export abstract class Repository<RawDataShape = Generic, EntityShape = Generic, M extends DataManager<RawDataShape> = DataManager<RawDataShape>> {
12
10
  [property: string]: unknown
13
11
 
14
- public constructor(public readonly driver: DriverAdapter<DataManager<DataShape>>) {}
15
-
16
- public async all(): Promise<Array<EntityShape>> {
17
- const connection = await this.driver.connect()
18
- const raw = await connection.all()
19
- const entities = this.transformList(raw)
20
- await this.driver.disconnect()
21
- return entities
22
- }
23
-
24
- protected transformList(data: Array<DataShape>): Array<EntityShape> {
25
- return data.map(this.transform)
26
- }
12
+ public constructor(
13
+ public readonly manager: M
14
+ ) {}
27
15
 
28
- protected abstract transform(data: DataShape): EntityShape
16
+ protected abstract transform(data: RawDataShape, ...args: unknown[]): EntityShape
29
17
  } //:: class
@@ -17,7 +17,7 @@ export abstract class Event {
17
17
  export abstract class EventHandler {
18
18
  [property: string]: unknown
19
19
 
20
- public abstract handle(event: Event): Promise<void>
20
+ public abstract handle(event: Event): void
21
21
  } //:: class
22
22
 
23
23
  /**
@@ -2,6 +2,8 @@
2
2
  * @description HTTP error with a specific status code and message.
3
3
  */
4
4
  export class HttpError extends Error {
5
+ [property: string]: unknown
6
+
5
7
  public static readonly messages: { [code: number]: string } = Object.freeze({
6
8
  400: 'Bad Request',
7
9
  401: 'Unauthorized',
@@ -1,6 +1,3 @@
1
- import { type TimeZone } from '../../types/timezones'
2
- import { type Locale } from '../../types/locales'
3
-
4
1
  export const DEBUG = 10
5
2
 
6
3
  export const INFO = 20
@@ -22,20 +19,6 @@ export abstract class Logger {
22
19
 
23
20
  public level: number = 0
24
21
 
25
- public datetimeLocales: Locale[] = ['en-GB']
26
-
27
- public datetimeFormatOptions: Intl.DateTimeFormatOptions & { timeZone: TimeZone } = {
28
- timeZone: 'UTC',
29
- year: 'numeric',
30
- month: '2-digit',
31
- day: '2-digit',
32
- hour: '2-digit',
33
- minute: '2-digit',
34
- second: '2-digit',
35
- fractionalSecondDigits: 3,
36
- hourCycle: 'h23'
37
- }
38
-
39
22
  public abstract debug(data: unknown): void
40
23
 
41
24
  public abstract info(data: unknown): void
@@ -45,8 +28,4 @@ export abstract class Logger {
45
28
  public abstract error(data: unknown): void
46
29
 
47
30
  public abstract critical(data: unknown): void
48
-
49
- protected getCurrentDatetime(): string {
50
- return new Date().toLocaleString(this.datetimeLocales, this.datetimeFormatOptions)
51
- }
52
31
  } //:: class
@@ -12,6 +12,6 @@ export abstract class Entity {
12
12
  }
13
13
 
14
14
  public toString(): string {
15
- return String(this.constructor.name)
15
+ return this.constructor.name
16
16
  }
17
17
  } //:: class
@@ -1,13 +0,0 @@
1
- /**
2
- * @description Http request handler to process incoming requests and generate responses.
3
- */
4
- export interface HttpRequestHandler {
5
- handle(request: Request): Response | Promise<Response>
6
- }
7
-
8
- /**
9
- * @description An HTTP middleware that pipes requests through handlers.
10
- */
11
- export interface HttpMiddleware {
12
- process(request: Request, handler: HttpRequestHandler): Response | Promise<Response>
13
- }