@teardown/types 0.0.2 → 0.0.3
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/generated-consts.d.ts +17 -3
- package/dist/generated-consts.js +21 -5
- package/dist/generated-types.d.ts +204 -6
- package/dist/generated-types.js +13 -1
- package/dist/index.d.ts +22 -0
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +12 -9
- package/biome.json +0 -8
- package/scripts/generate-constants.script.ts +0 -126
- package/scripts/generate-types.script.ts +0 -68
- package/src/generated-consts.ts +0 -53
- package/src/generated-types.ts +0 -976
- package/src/index.ts +0 -26
- package/src/interfaces/service.interface.ts +0 -66
- package/tsconfig.json +0 -10
- package/tsconfig.lib.json +0 -18
- package/tsconfig.scripts.json +0 -15
- package/turbo.jsonc +0 -18
package/src/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { Database, Enums, Json, TablesInsert, TablesUpdate } from "./generated-types";
|
|
2
|
-
|
|
3
|
-
export * from "./generated-consts";
|
|
4
|
-
export type { Database, Enums, Json };
|
|
5
|
-
|
|
6
|
-
export type Tables = Database["public"]["Tables"];
|
|
7
|
-
export type TableKeys = keyof Tables;
|
|
8
|
-
export type Table<T extends TableKeys> = Tables[T]["Row"];
|
|
9
|
-
export type Insert<T extends TableKeys> = TablesInsert<T>;
|
|
10
|
-
export type Update<T extends TableKeys> = TablesUpdate<T>;
|
|
11
|
-
|
|
12
|
-
export type SuccessResult<Success> = {
|
|
13
|
-
success: true;
|
|
14
|
-
data: Success;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export type ErrorResult<Error = string> = {
|
|
18
|
-
success: false;
|
|
19
|
-
error: Error;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type Result<Success, Error = string> = SuccessResult<Success> | ErrorResult<Error>;
|
|
23
|
-
export type AsyncResult<Success, Error = string> = Promise<Result<Success, Error>>;
|
|
24
|
-
|
|
25
|
-
// Export Service class and related types
|
|
26
|
-
export { type LoggingContext, Service } from "./interfaces/service.interface";
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
export type LoggingContext = Record<string, unknown> | string | number | boolean;
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Abstract base class for implementing singleton pattern in services with logging.
|
|
5
|
-
*
|
|
6
|
-
* @example
|
|
7
|
-
* ```ts
|
|
8
|
-
* class MyService extends Service {
|
|
9
|
-
* constructor() {
|
|
10
|
-
* super('MyService');
|
|
11
|
-
* }
|
|
12
|
-
*
|
|
13
|
-
* doSomething() {
|
|
14
|
-
* this.info('Doing something');
|
|
15
|
-
* return 'result';
|
|
16
|
-
* }
|
|
17
|
-
* }
|
|
18
|
-
*
|
|
19
|
-
* // Usage
|
|
20
|
-
* const service = MyService.instance<MyService>();
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export abstract class Service {
|
|
24
|
-
private static instances: Map<string, unknown> = new Map();
|
|
25
|
-
protected serviceName: string;
|
|
26
|
-
|
|
27
|
-
// Logging methods - initialized in constructor to preserve stack traces
|
|
28
|
-
protected debug!: (message: string, context?: LoggingContext) => void;
|
|
29
|
-
protected info!: (message: string, context?: LoggingContext) => void;
|
|
30
|
-
protected warn!: (message: string, context?: LoggingContext) => void;
|
|
31
|
-
protected error!: (message: string, context?: LoggingContext) => void;
|
|
32
|
-
|
|
33
|
-
constructor(serviceName?: string) {
|
|
34
|
-
this.serviceName = serviceName || this.constructor.name;
|
|
35
|
-
|
|
36
|
-
// Bind logging methods to preserve correct stack traces
|
|
37
|
-
const prefix = `[${this.serviceName}]`;
|
|
38
|
-
this.debug = console.debug.bind(console, prefix);
|
|
39
|
-
this.info = console.info.bind(console, prefix);
|
|
40
|
-
this.warn = console.warn.bind(console, prefix);
|
|
41
|
-
this.error = console.error.bind(console, prefix);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
// biome-ignore lint/suspicious/noExplicitAny: Allow private constructors in singleton pattern
|
|
45
|
-
public static instance<T>(this: any): T {
|
|
46
|
-
// biome-ignore lint/complexity/noThisInStatic: Accessing class name for singleton map
|
|
47
|
-
const className = this.name;
|
|
48
|
-
|
|
49
|
-
if (!Service.instances.has(className)) {
|
|
50
|
-
// biome-ignore lint/complexity/noThisInStatic: Creating instance of derived class
|
|
51
|
-
// biome-ignore lint/suspicious/noExplicitAny: Need to bypass constructor visibility
|
|
52
|
-
const instance = new (this as any)();
|
|
53
|
-
Service.instances.set(className, instance);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return Service.instances.get(className) as T;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
public static clearInstance(className: string): void {
|
|
60
|
-
Service.instances.delete(className);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
public static clearAllInstances(): void {
|
|
64
|
-
Service.instances.clear();
|
|
65
|
-
}
|
|
66
|
-
}
|
package/tsconfig.json
DELETED
package/tsconfig.lib.json
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@teardown/tsconfig/tsconfig.base.json",
|
|
3
|
-
"include": [
|
|
4
|
-
"src/**/*",
|
|
5
|
-
],
|
|
6
|
-
"exclude": [
|
|
7
|
-
"src/**/*.script.ts"
|
|
8
|
-
],
|
|
9
|
-
"compilerOptions": {
|
|
10
|
-
"module": "esnext",
|
|
11
|
-
"baseUrl": ".",
|
|
12
|
-
"rootDir": "src",
|
|
13
|
-
"outDir": "dist",
|
|
14
|
-
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
|
15
|
-
"forceConsistentCasingInFileNames": true
|
|
16
|
-
},
|
|
17
|
-
"references": [],
|
|
18
|
-
}
|
package/tsconfig.scripts.json
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "@teardown/tsconfig/tsconfig.base.json",
|
|
3
|
-
"include": [
|
|
4
|
-
"src/**/*.script.ts"
|
|
5
|
-
],
|
|
6
|
-
"compilerOptions": {
|
|
7
|
-
"module": "esnext",
|
|
8
|
-
"baseUrl": ".",
|
|
9
|
-
"rootDir": "src",
|
|
10
|
-
"outDir": "dist",
|
|
11
|
-
"tsBuildInfoFile": "dist/tsconfig.lib.tsbuildinfo",
|
|
12
|
-
"forceConsistentCasingInFileNames": true
|
|
13
|
-
},
|
|
14
|
-
"references": [],
|
|
15
|
-
}
|
package/turbo.jsonc
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://turbo.build/schema.json",
|
|
3
|
-
"extends": ["//"],
|
|
4
|
-
"tasks": {
|
|
5
|
-
"build": {
|
|
6
|
-
"cache": false,
|
|
7
|
-
"outputs": ["dist/**"]
|
|
8
|
-
},
|
|
9
|
-
"dev": {
|
|
10
|
-
"cache": false,
|
|
11
|
-
"persistent": true
|
|
12
|
-
},
|
|
13
|
-
"generate": {
|
|
14
|
-
"cache": false,
|
|
15
|
-
"outputs": ["src/generated-*.ts"]
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
}
|