@teardown/types 0.1.22 → 0.1.24
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/package.json +9 -14
- package/src/generated-consts.ts +69 -0
- package/src/generated-types.ts +1207 -0
- package/{dist/index.d.ts → src/index.ts} +12 -4
- package/src/interfaces/service.interface.ts +66 -0
- package/dist/generated-consts.d.ts +0 -61
- package/dist/generated-consts.js +0 -70
- package/dist/generated-types.d.ts +0 -1086
- package/dist/generated-types.js +0 -42
- package/dist/index.js +0 -3
- package/dist/interfaces/service.interface.d.ts +0 -33
- package/dist/interfaces/service.interface.js +0 -56
- package/dist/tsconfig.lib.tsbuildinfo +0 -1
|
@@ -1,29 +1,34 @@
|
|
|
1
1
|
import type { Database, Enums, Json, TablesInsert, TablesUpdate } from "./generated-types";
|
|
2
|
+
|
|
2
3
|
export * from "./generated-consts";
|
|
3
4
|
export type { Database, Enums, Json };
|
|
5
|
+
|
|
4
6
|
export type Tables = Database["public"]["Tables"];
|
|
5
7
|
export type TableKeys = keyof Tables;
|
|
6
8
|
export type Table<T extends TableKeys> = Tables[T]["Row"];
|
|
7
9
|
export type Insert<T extends TableKeys> = TablesInsert<T>;
|
|
8
10
|
export type Update<T extends TableKeys> = TablesUpdate<T>;
|
|
11
|
+
|
|
9
12
|
/**
|
|
10
13
|
* A result of a successful operation
|
|
11
14
|
* @param Success - The success type
|
|
12
15
|
* @returns A {@link Success}
|
|
13
16
|
*/
|
|
14
17
|
export type SuccessResult<Success> = {
|
|
15
|
-
|
|
16
|
-
|
|
18
|
+
success: true;
|
|
19
|
+
data: Success;
|
|
17
20
|
};
|
|
21
|
+
|
|
18
22
|
/**
|
|
19
23
|
* A result of a failed operation
|
|
20
24
|
* @param Error - The error type
|
|
21
25
|
* @returns A {@link ErrorResult}
|
|
22
26
|
*/
|
|
23
27
|
export type ErrorResult<Error = string> = {
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
success: false;
|
|
29
|
+
error: Error;
|
|
26
30
|
};
|
|
31
|
+
|
|
27
32
|
/**
|
|
28
33
|
* A result of a successful or failed operation
|
|
29
34
|
* @param Success - The success type
|
|
@@ -31,6 +36,7 @@ export type ErrorResult<Error = string> = {
|
|
|
31
36
|
* @returns A {@link SuccessResult} or {@link ErrorResult}
|
|
32
37
|
*/
|
|
33
38
|
export type Result<Success, Error = string> = SuccessResult<Success> | ErrorResult<Error>;
|
|
39
|
+
|
|
34
40
|
/**
|
|
35
41
|
* A promise that resolves to a {@link Result}
|
|
36
42
|
* @param Success - The success type
|
|
@@ -38,4 +44,6 @@ export type Result<Success, Error = string> = SuccessResult<Success> | ErrorResu
|
|
|
38
44
|
* @returns A promise that resolves to a {@link Result}
|
|
39
45
|
*/
|
|
40
46
|
export type AsyncResult<Success, Error = string> = Promise<Result<Success, Error>>;
|
|
47
|
+
|
|
48
|
+
// Export Service class and related types
|
|
41
49
|
export { type LoggingContext, Service } from "./interfaces/service.interface";
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
export declare enum DevicePlatformEnum {
|
|
2
|
-
IOS = "IOS",
|
|
3
|
-
ANDROID = "ANDROID",
|
|
4
|
-
WEB = "WEB",
|
|
5
|
-
WINDOWS = "WINDOWS",
|
|
6
|
-
MACOS = "MACOS",
|
|
7
|
-
LINUX = "LINUX",
|
|
8
|
-
PHONE = "PHONE",
|
|
9
|
-
TABLET = "TABLET",
|
|
10
|
-
DESKTOP = "DESKTOP",
|
|
11
|
-
CONSOLE = "CONSOLE",
|
|
12
|
-
TV = "TV",
|
|
13
|
-
WEARABLE = "WEARABLE",
|
|
14
|
-
GAME_CONSOLE = "GAME_CONSOLE",
|
|
15
|
-
VR = "VR",
|
|
16
|
-
UNKNOWN = "UNKNOWN",
|
|
17
|
-
OTHER = "OTHER"
|
|
18
|
-
}
|
|
19
|
-
export declare enum EnvironmentTypeEnum {
|
|
20
|
-
DEVELOPMENT = "DEVELOPMENT",
|
|
21
|
-
STAGING = "STAGING",
|
|
22
|
-
PRODUCTION = "PRODUCTION"
|
|
23
|
-
}
|
|
24
|
-
export declare enum OrgRoleTypeEnum {
|
|
25
|
-
OWNER = "OWNER",
|
|
26
|
-
ADMIN = "ADMIN",
|
|
27
|
-
ENGINEER = "ENGINEER"
|
|
28
|
-
}
|
|
29
|
-
export declare enum OrgTypeEnum {
|
|
30
|
-
PERSONAL = "PERSONAL",
|
|
31
|
-
START_UP = "START_UP",
|
|
32
|
-
SCALE_UP = "SCALE_UP",
|
|
33
|
-
AGENCY = "AGENCY",
|
|
34
|
-
ENTERPRISE = "ENTERPRISE"
|
|
35
|
-
}
|
|
36
|
-
export declare enum ProjectApiKeyKindEnum {
|
|
37
|
-
publishable = "publishable",
|
|
38
|
-
secret = "secret"
|
|
39
|
-
}
|
|
40
|
-
export declare enum ProjectStatusEnum {
|
|
41
|
-
PENDING_SETUP = "PENDING_SETUP",
|
|
42
|
-
ACTIVE = "ACTIVE",
|
|
43
|
-
PAUSED = "PAUSED",
|
|
44
|
-
ARCHIVED = "ARCHIVED"
|
|
45
|
-
}
|
|
46
|
-
export declare enum ProjectTypeEnum {
|
|
47
|
-
REACT_NATIVE = "REACT_NATIVE",
|
|
48
|
-
EXPO = "EXPO"
|
|
49
|
-
}
|
|
50
|
-
export declare enum ProjectVersionStatusEnum {
|
|
51
|
-
SUPPORTED = "SUPPORTED",
|
|
52
|
-
UPDATE_AVAILABLE = "UPDATE_AVAILABLE",
|
|
53
|
-
UPDATE_RECOMMENDED = "UPDATE_RECOMMENDED",
|
|
54
|
-
UPDATE_REQUIRED = "UPDATE_REQUIRED"
|
|
55
|
-
}
|
|
56
|
-
export declare enum VersionBuildStatusEnum {
|
|
57
|
-
SUPPORTED = "SUPPORTED",
|
|
58
|
-
UPDATE_AVAILABLE = "UPDATE_AVAILABLE",
|
|
59
|
-
UPDATE_RECOMMENDED = "UPDATE_RECOMMENDED",
|
|
60
|
-
UPDATE_REQUIRED = "UPDATE_REQUIRED"
|
|
61
|
-
}
|
package/dist/generated-consts.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
export var DevicePlatformEnum;
|
|
2
|
-
(function (DevicePlatformEnum) {
|
|
3
|
-
DevicePlatformEnum["IOS"] = "IOS";
|
|
4
|
-
DevicePlatformEnum["ANDROID"] = "ANDROID";
|
|
5
|
-
DevicePlatformEnum["WEB"] = "WEB";
|
|
6
|
-
DevicePlatformEnum["WINDOWS"] = "WINDOWS";
|
|
7
|
-
DevicePlatformEnum["MACOS"] = "MACOS";
|
|
8
|
-
DevicePlatformEnum["LINUX"] = "LINUX";
|
|
9
|
-
DevicePlatformEnum["PHONE"] = "PHONE";
|
|
10
|
-
DevicePlatformEnum["TABLET"] = "TABLET";
|
|
11
|
-
DevicePlatformEnum["DESKTOP"] = "DESKTOP";
|
|
12
|
-
DevicePlatformEnum["CONSOLE"] = "CONSOLE";
|
|
13
|
-
DevicePlatformEnum["TV"] = "TV";
|
|
14
|
-
DevicePlatformEnum["WEARABLE"] = "WEARABLE";
|
|
15
|
-
DevicePlatformEnum["GAME_CONSOLE"] = "GAME_CONSOLE";
|
|
16
|
-
DevicePlatformEnum["VR"] = "VR";
|
|
17
|
-
DevicePlatformEnum["UNKNOWN"] = "UNKNOWN";
|
|
18
|
-
DevicePlatformEnum["OTHER"] = "OTHER";
|
|
19
|
-
})(DevicePlatformEnum || (DevicePlatformEnum = {}));
|
|
20
|
-
export var EnvironmentTypeEnum;
|
|
21
|
-
(function (EnvironmentTypeEnum) {
|
|
22
|
-
EnvironmentTypeEnum["DEVELOPMENT"] = "DEVELOPMENT";
|
|
23
|
-
EnvironmentTypeEnum["STAGING"] = "STAGING";
|
|
24
|
-
EnvironmentTypeEnum["PRODUCTION"] = "PRODUCTION";
|
|
25
|
-
})(EnvironmentTypeEnum || (EnvironmentTypeEnum = {}));
|
|
26
|
-
export var OrgRoleTypeEnum;
|
|
27
|
-
(function (OrgRoleTypeEnum) {
|
|
28
|
-
OrgRoleTypeEnum["OWNER"] = "OWNER";
|
|
29
|
-
OrgRoleTypeEnum["ADMIN"] = "ADMIN";
|
|
30
|
-
OrgRoleTypeEnum["ENGINEER"] = "ENGINEER";
|
|
31
|
-
})(OrgRoleTypeEnum || (OrgRoleTypeEnum = {}));
|
|
32
|
-
export var OrgTypeEnum;
|
|
33
|
-
(function (OrgTypeEnum) {
|
|
34
|
-
OrgTypeEnum["PERSONAL"] = "PERSONAL";
|
|
35
|
-
OrgTypeEnum["START_UP"] = "START_UP";
|
|
36
|
-
OrgTypeEnum["SCALE_UP"] = "SCALE_UP";
|
|
37
|
-
OrgTypeEnum["AGENCY"] = "AGENCY";
|
|
38
|
-
OrgTypeEnum["ENTERPRISE"] = "ENTERPRISE";
|
|
39
|
-
})(OrgTypeEnum || (OrgTypeEnum = {}));
|
|
40
|
-
export var ProjectApiKeyKindEnum;
|
|
41
|
-
(function (ProjectApiKeyKindEnum) {
|
|
42
|
-
ProjectApiKeyKindEnum["publishable"] = "publishable";
|
|
43
|
-
ProjectApiKeyKindEnum["secret"] = "secret";
|
|
44
|
-
})(ProjectApiKeyKindEnum || (ProjectApiKeyKindEnum = {}));
|
|
45
|
-
export var ProjectStatusEnum;
|
|
46
|
-
(function (ProjectStatusEnum) {
|
|
47
|
-
ProjectStatusEnum["PENDING_SETUP"] = "PENDING_SETUP";
|
|
48
|
-
ProjectStatusEnum["ACTIVE"] = "ACTIVE";
|
|
49
|
-
ProjectStatusEnum["PAUSED"] = "PAUSED";
|
|
50
|
-
ProjectStatusEnum["ARCHIVED"] = "ARCHIVED";
|
|
51
|
-
})(ProjectStatusEnum || (ProjectStatusEnum = {}));
|
|
52
|
-
export var ProjectTypeEnum;
|
|
53
|
-
(function (ProjectTypeEnum) {
|
|
54
|
-
ProjectTypeEnum["REACT_NATIVE"] = "REACT_NATIVE";
|
|
55
|
-
ProjectTypeEnum["EXPO"] = "EXPO";
|
|
56
|
-
})(ProjectTypeEnum || (ProjectTypeEnum = {}));
|
|
57
|
-
export var ProjectVersionStatusEnum;
|
|
58
|
-
(function (ProjectVersionStatusEnum) {
|
|
59
|
-
ProjectVersionStatusEnum["SUPPORTED"] = "SUPPORTED";
|
|
60
|
-
ProjectVersionStatusEnum["UPDATE_AVAILABLE"] = "UPDATE_AVAILABLE";
|
|
61
|
-
ProjectVersionStatusEnum["UPDATE_RECOMMENDED"] = "UPDATE_RECOMMENDED";
|
|
62
|
-
ProjectVersionStatusEnum["UPDATE_REQUIRED"] = "UPDATE_REQUIRED";
|
|
63
|
-
})(ProjectVersionStatusEnum || (ProjectVersionStatusEnum = {}));
|
|
64
|
-
export var VersionBuildStatusEnum;
|
|
65
|
-
(function (VersionBuildStatusEnum) {
|
|
66
|
-
VersionBuildStatusEnum["SUPPORTED"] = "SUPPORTED";
|
|
67
|
-
VersionBuildStatusEnum["UPDATE_AVAILABLE"] = "UPDATE_AVAILABLE";
|
|
68
|
-
VersionBuildStatusEnum["UPDATE_RECOMMENDED"] = "UPDATE_RECOMMENDED";
|
|
69
|
-
VersionBuildStatusEnum["UPDATE_REQUIRED"] = "UPDATE_REQUIRED";
|
|
70
|
-
})(VersionBuildStatusEnum || (VersionBuildStatusEnum = {}));
|