@ahana-awesome-platform/ahana-electron-sdk 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/dist/cjs/controller/index.d.ts +12 -0
- package/dist/cjs/controller/index.d.ts.map +1 -0
- package/dist/cjs/controller/index.js +1 -0
- package/dist/cjs/ipc/IpcMain.d.ts +20 -0
- package/dist/cjs/ipc/IpcMain.d.ts.map +1 -0
- package/dist/cjs/ipc/IpcTypes.d.ts +24 -0
- package/dist/cjs/ipc/IpcTypes.d.ts.map +1 -0
- package/dist/cjs/ipc/index.d.ts +66 -0
- package/dist/cjs/ipc/index.d.ts.map +1 -0
- package/dist/cjs/ipc/index.js +1 -0
- package/dist/cjs/logger/String16.d.ts +11 -0
- package/dist/cjs/logger/String16.d.ts.map +1 -0
- package/dist/cjs/logger/index.d.ts +104 -0
- package/dist/cjs/logger/index.d.ts.map +1 -0
- package/dist/cjs/logger/index.js +1 -0
- package/dist/cjs/orm/common/logger.d.ts +4 -0
- package/dist/cjs/orm/common/logger.d.ts.map +1 -0
- package/dist/cjs/orm/index.d.ts +4 -0
- package/dist/cjs/orm/index.d.ts.map +1 -0
- package/dist/cjs/orm/index.js +1 -0
- package/dist/cjs/orm/orm/CheckHealth.d.ts +4 -0
- package/dist/cjs/orm/orm/CheckHealth.d.ts.map +1 -0
- package/dist/cjs/orm/orm/ExecuteInTransaction.d.ts +5 -0
- package/dist/cjs/orm/orm/ExecuteInTransaction.d.ts.map +1 -0
- package/dist/cjs/orm/orm/SafeAlterTable.d.ts +8 -0
- package/dist/cjs/orm/orm/SafeAlterTable.d.ts.map +1 -0
- package/dist/cjs/orm/orm/SqLiteConnection.d.ts +5 -0
- package/dist/cjs/orm/orm/SqLiteConnection.d.ts.map +1 -0
- package/dist/cjs/orm/sqlite/index.d.ts +10 -0
- package/dist/cjs/orm/sqlite/index.d.ts.map +1 -0
- package/dist/cjs/platform/index.d.ts +2 -0
- package/dist/cjs/platform/index.d.ts.map +1 -0
- package/dist/cjs/platform/index.js +1 -0
- package/dist/cjs/platform/platform/detector.d.ts +47 -0
- package/dist/cjs/platform/platform/detector.d.ts.map +1 -0
- package/dist/cjs/platform/platform/registry/index.d.ts +47 -0
- package/dist/cjs/platform/platform/registry/index.d.ts.map +1 -0
- package/dist/cjs/platform/platform/registry/kylin-registry.d.ts +31 -0
- package/dist/cjs/platform/platform/registry/kylin-registry.d.ts.map +1 -0
- package/dist/cjs/platform/platform/registry/registry.d.ts +89 -0
- package/dist/cjs/platform/platform/registry/registry.d.ts.map +1 -0
- package/dist/cjs/platform/platform/registry/windows-registry.d.ts +32 -0
- package/dist/cjs/platform/platform/registry/windows-registry.d.ts.map +1 -0
- package/dist/cjs/response-factory/factory/AppError.d.ts +8 -0
- package/dist/cjs/response-factory/factory/AppError.d.ts.map +1 -0
- package/dist/cjs/response-factory/factory/BusinessError.d.ts +70 -0
- package/dist/cjs/response-factory/factory/BusinessError.d.ts.map +1 -0
- package/dist/cjs/response-factory/index.d.ts +3 -0
- package/dist/cjs/response-factory/index.d.ts.map +1 -0
- package/dist/cjs/response-factory/index.js +1 -0
- package/dist/cjs/response-factory/response/Response.d.ts +15 -0
- package/dist/cjs/response-factory/response/Response.d.ts.map +1 -0
- package/dist/esm/_commonjsHelpers-Dm6U3U_N.js +35 -0
- package/dist/esm/controller/index.d.ts +12 -0
- package/dist/esm/controller/index.d.ts.map +1 -0
- package/dist/esm/controller/index.js +1128 -0
- package/dist/esm/events-CqhjgOaW.js +213 -0
- package/dist/esm/index-Dys2BW-7.js +256 -0
- package/dist/esm/index-xOyNRTcn.js +21640 -0
- package/dist/esm/ipc/IpcMain.d.ts +20 -0
- package/dist/esm/ipc/IpcMain.d.ts.map +1 -0
- package/dist/esm/ipc/IpcTypes.d.ts +24 -0
- package/dist/esm/ipc/IpcTypes.d.ts.map +1 -0
- package/dist/esm/ipc/index.d.ts +66 -0
- package/dist/esm/ipc/index.d.ts.map +1 -0
- package/dist/esm/ipc/index.js +137 -0
- package/dist/esm/kylin-registry-3nmgzi3s.js +249 -0
- package/dist/esm/logger/String16.d.ts +11 -0
- package/dist/esm/logger/String16.d.ts.map +1 -0
- package/dist/esm/logger/index.d.ts +104 -0
- package/dist/esm/logger/index.d.ts.map +1 -0
- package/dist/esm/logger/index.js +7 -0
- package/dist/esm/orm/common/logger.d.ts +4 -0
- package/dist/esm/orm/common/logger.d.ts.map +1 -0
- package/dist/esm/orm/index.d.ts +4 -0
- package/dist/esm/orm/index.d.ts.map +1 -0
- package/dist/esm/orm/index.js +50024 -0
- package/dist/esm/orm/orm/CheckHealth.d.ts +4 -0
- package/dist/esm/orm/orm/CheckHealth.d.ts.map +1 -0
- package/dist/esm/orm/orm/ExecuteInTransaction.d.ts +5 -0
- package/dist/esm/orm/orm/ExecuteInTransaction.d.ts.map +1 -0
- package/dist/esm/orm/orm/SafeAlterTable.d.ts +8 -0
- package/dist/esm/orm/orm/SafeAlterTable.d.ts.map +1 -0
- package/dist/esm/orm/orm/SqLiteConnection.d.ts +5 -0
- package/dist/esm/orm/orm/SqLiteConnection.d.ts.map +1 -0
- package/dist/esm/orm/sqlite/index.d.ts +10 -0
- package/dist/esm/orm/sqlite/index.d.ts.map +1 -0
- package/dist/esm/platform/index.d.ts +2 -0
- package/dist/esm/platform/index.d.ts.map +1 -0
- package/dist/esm/platform/index.js +8 -0
- package/dist/esm/platform/platform/detector.d.ts +47 -0
- package/dist/esm/platform/platform/detector.d.ts.map +1 -0
- package/dist/esm/platform/platform/registry/index.d.ts +47 -0
- package/dist/esm/platform/platform/registry/index.d.ts.map +1 -0
- package/dist/esm/platform/platform/registry/kylin-registry.d.ts +31 -0
- package/dist/esm/platform/platform/registry/kylin-registry.d.ts.map +1 -0
- package/dist/esm/platform/platform/registry/registry.d.ts +89 -0
- package/dist/esm/platform/platform/registry/registry.d.ts.map +1 -0
- package/dist/esm/platform/platform/registry/windows-registry.d.ts +32 -0
- package/dist/esm/platform/platform/registry/windows-registry.d.ts.map +1 -0
- package/dist/esm/response-factory/factory/AppError.d.ts +8 -0
- package/dist/esm/response-factory/factory/AppError.d.ts.map +1 -0
- package/dist/esm/response-factory/factory/BusinessError.d.ts +70 -0
- package/dist/esm/response-factory/factory/BusinessError.d.ts.map +1 -0
- package/dist/esm/response-factory/index.d.ts +3 -0
- package/dist/esm/response-factory/index.d.ts.map +1 -0
- package/dist/esm/response-factory/index.js +121 -0
- package/dist/esm/response-factory/response/Response.d.ts +15 -0
- package/dist/esm/response-factory/response/Response.d.ts.map +1 -0
- package/dist/esm/windows-registry-B92IgP1f.js +354 -0
- package/package.json +73 -0
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { AhanaSequelize, DatabaseHealthResult, Logger } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
declare const checkHealth: (customSequelize: AhanaSequelize, storagePath: string, logger: Logger | null) => () => Promise<DatabaseHealthResult>;
|
|
3
|
+
export { checkHealth };
|
|
4
|
+
//# sourceMappingURL=CheckHealth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CheckHealth.d.ts","sourceRoot":"","sources":["../../../../src/orm/orm/CheckHealth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,oBAAoB,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAIzG,QAAA,MAAM,WAAW,oBACG,cAAc,eAAe,MAAM,UAAU,MAAM,GAAG,IAAI,WAClE,QAAQ,oBAAoB,CA+DrC,CAAC;AAEJ,OAAO,EAAE,WAAW,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AhanaSequelize, GlobalConfig, Logger } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
import { Transaction } from 'sequelize';
|
|
3
|
+
declare const executeInTransaction: (customSequelize: AhanaSequelize, GLOBAL_CONFIG: GlobalConfig, logger: Logger | null) => <T>(callback: (t: Transaction) => Promise<T>, isolationLevel?: Transaction.ISOLATION_LEVELS) => Promise<T>;
|
|
4
|
+
export { executeInTransaction };
|
|
5
|
+
//# sourceMappingURL=ExecuteInTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ExecuteInTransaction.d.ts","sourceRoot":"","sources":["../../../../src/orm/orm/ExecuteInTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AACjG,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAGxC,QAAA,MAAM,oBAAoB,oBACN,cAAc,iBAAiB,YAAY,UAAU,MAAM,GAAG,IAAI,uBAC5D,WAAW,kCAAkC,YAAY,gBAAgB,eAyBhG,CAAC;AAEJ,OAAO,EAAE,oBAAoB,EAAE,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ModelStatic, Model } from 'sequelize';
|
|
2
|
+
import type { AhanaSequelize, Logger } from '@ahana-awesome-platform/shared-types';
|
|
3
|
+
declare const safeAlterTable: (customSequelize: AhanaSequelize, logger: Logger | null) => (model: ModelStatic<Model>, options?: {
|
|
4
|
+
isDropColumns?: boolean;
|
|
5
|
+
ignoreColumns?: string[];
|
|
6
|
+
}) => Promise<void>;
|
|
7
|
+
export { safeAlterTable };
|
|
8
|
+
//# sourceMappingURL=SafeAlterTable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SafeAlterTable.d.ts","sourceRoot":"","sources":["../../../../src/orm/orm/SafeAlterTable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkB,KAAK,EAA4C,MAAM,WAAW,CAAC;AAC9G,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,EAAE,MAAM,sCAAsC,CAAC;AA0IxG,QAAA,MAAM,cAAc,oBACA,cAAc,UAAU,MAAM,GAAG,IAAI,aAE9C,YAAY,KAAK,CAAC,YAChB;IACP,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;CAC1B,KACA,QAAQ,IAAI,CA8Ed,CAAC;AAEJ,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { AhanaSequelize, GlobalConfig, Logger } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
declare const testSQLiteConnection: (customSequelize: AhanaSequelize, logger: Logger | null) => () => Promise<void>;
|
|
3
|
+
declare const closeSQLiteConnection: (customSequelize: AhanaSequelize, GLOBAL_CONFIG: GlobalConfig, logger: Logger | null) => () => Promise<void>;
|
|
4
|
+
export { testSQLiteConnection, closeSQLiteConnection };
|
|
5
|
+
//# sourceMappingURL=SqLiteConnection.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SqLiteConnection.d.ts","sourceRoot":"","sources":["../../../../src/orm/orm/SqLiteConnection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAGjG,QAAA,MAAM,oBAAoB,oBAAqB,cAAc,UAAU,MAAM,GAAG,IAAI,WAAe,QAAQ,IAAI,CAQ9G,CAAC;AAGF,QAAA,MAAM,qBAAqB,oBACP,cAAc,iBAAiB,YAAY,UAAU,MAAM,GAAG,IAAI,WAAe,QAAQ,IAAI,CAQ9G,CAAC;AAEJ,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AhanaSequelize, SQLiteConfig, LoggerConfig } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
declare const getSqliteDatabase: (sqliteDatabaseConfig: {
|
|
3
|
+
config: Partial<SQLiteConfig>;
|
|
4
|
+
logConfig: LoggerConfig;
|
|
5
|
+
isdev: boolean;
|
|
6
|
+
appName: string;
|
|
7
|
+
version: string;
|
|
8
|
+
}) => Promise<AhanaSequelize>;
|
|
9
|
+
export { getSqliteDatabase };
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/orm/sqlite/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,cAAc,EACd,YAAY,EAEZ,YAAY,EAEb,MAAM,sCAAsC,CAAC;AAgP9C,QAAA,MAAM,iBAAiB,yBAAgC;IACrD,MAAM,EAAE,QAAQ,YAAY,CAAC,CAAC;IAC9B,SAAS,EAAE,YAAY,CAAC;IACxB,KAAK,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB,KAAG,QAAQ,cAAc,CAqBzB,CAAC;AAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/platform/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PlatformType } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
/**
|
|
3
|
+
* 平台检测器
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* 平台信息接口
|
|
7
|
+
*/
|
|
8
|
+
interface PlatformInfo {
|
|
9
|
+
type: string;
|
|
10
|
+
platform: string;
|
|
11
|
+
arch: string;
|
|
12
|
+
release: string;
|
|
13
|
+
version: string;
|
|
14
|
+
hostname: string;
|
|
15
|
+
cpus: number;
|
|
16
|
+
totalMemory: number;
|
|
17
|
+
freeMemory: number;
|
|
18
|
+
uptime: number;
|
|
19
|
+
}
|
|
20
|
+
export declare class PlatformDetector {
|
|
21
|
+
/**
|
|
22
|
+
* 检测当前平台
|
|
23
|
+
*/
|
|
24
|
+
static detect(): PlatformType;
|
|
25
|
+
/**
|
|
26
|
+
* 检测是否为麒麟系统
|
|
27
|
+
*/
|
|
28
|
+
private static isKylinOS;
|
|
29
|
+
/**
|
|
30
|
+
* 通过文件检测麒麟系统
|
|
31
|
+
*/
|
|
32
|
+
private static checkKylinByFiles;
|
|
33
|
+
/**
|
|
34
|
+
* 通过命令检测麒麟系统
|
|
35
|
+
*/
|
|
36
|
+
private static checkKylinByCommand;
|
|
37
|
+
/**
|
|
38
|
+
* 获取平台详细信息
|
|
39
|
+
*/
|
|
40
|
+
static getPlatformInfo(): PlatformInfo;
|
|
41
|
+
/**
|
|
42
|
+
* 检查是否支持当前平台
|
|
43
|
+
*/
|
|
44
|
+
static isSupported(): boolean;
|
|
45
|
+
}
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=detector.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detector.d.ts","sourceRoot":"","sources":["../../../../src/platform/platform/detector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAKzE;;GAEG;AACH;;GAEG;AACH,UAAU,YAAY;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,qBAAa,gBAAgB;IAC3B;;OAEG;IACH,MAAM,CAAC,MAAM,IAAI,YAAY;IAiB7B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAkBxB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAmBhC;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,mBAAmB;IAsBlC;;OAEG;IACH,MAAM,CAAC,eAAe,IAAI,YAAY;IAetC;;OAEG;IACH,MAAM,CAAC,WAAW,IAAI,OAAO;CAI9B"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { PlatformType, RegistryValueResult, RegistryOptions, RegistryValue } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
import { WINHKLM, KYLINHKEY } from './registry';
|
|
3
|
+
/**
|
|
4
|
+
* 平台工厂
|
|
5
|
+
*/
|
|
6
|
+
declare class RegistryDetector {
|
|
7
|
+
/**
|
|
8
|
+
* 读取注册表值
|
|
9
|
+
*/
|
|
10
|
+
static getValue(hive: WINHKLM | KYLINHKEY, key: string, valueName: string, options?: RegistryOptions): Promise<RegistryValueResult>;
|
|
11
|
+
/**
|
|
12
|
+
* 设置注册表值
|
|
13
|
+
*/
|
|
14
|
+
static setValue(registryOptions: {
|
|
15
|
+
hive: WINHKLM | KYLINHKEY;
|
|
16
|
+
key: string;
|
|
17
|
+
valueName: string;
|
|
18
|
+
value: RegistryValue;
|
|
19
|
+
options: RegistryOptions;
|
|
20
|
+
}): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* 删除注册表值
|
|
23
|
+
*/
|
|
24
|
+
static deleteValue(hive: WINHKLM | KYLINHKEY, key: string, valueName: string, options?: RegistryOptions): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* 获取当前平台类型
|
|
27
|
+
*/
|
|
28
|
+
static getCurrentPlatform(): PlatformType;
|
|
29
|
+
/**
|
|
30
|
+
* 检查是否是Windows
|
|
31
|
+
*/
|
|
32
|
+
static isWindows(): boolean;
|
|
33
|
+
/**
|
|
34
|
+
* 检查是否是麒麟系统
|
|
35
|
+
*/
|
|
36
|
+
static isKylin(): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* 检查是否是Linux
|
|
39
|
+
*/
|
|
40
|
+
static isLinux(): boolean;
|
|
41
|
+
}
|
|
42
|
+
declare const getRegistryValue: typeof RegistryDetector.getValue;
|
|
43
|
+
declare const setRegistryValue: typeof RegistryDetector.setValue;
|
|
44
|
+
declare const deleteRegistryValue: typeof RegistryDetector.deleteValue;
|
|
45
|
+
export { WINHKLM, KYLINHKEY };
|
|
46
|
+
export { getRegistryValue, setRegistryValue, deleteRegistryValue };
|
|
47
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/platform/platform/registry/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,aAAa,EACd,MAAM,sCAAsC,CAAC;AAG9C,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAGhD;;GAEG;AACH,cAAM,gBAAgB;IACpB;;OAEG;WACU,QAAQ,CACnB,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,GAAG,EAAE,MAAM,EAEX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC;IAgB/B;;OAEG;WACU,QAAQ,CAAC,eAAe,EAAE;QACrC,IAAI,EAAE,OAAO,GAAG,SAAS,CAAC;QAC1B,GAAG,EAAE,MAAM,CAAC;QAEZ,SAAS,EAAE,MAAM,CAAC;QAClB,KAAK,EAAE,aAAa,CAAC;QACrB,OAAO,EAAE,eAAe,CAAC;KAC1B,GAAG,OAAO,CAAC,IAAI,CAAC;IAiBjB;;OAEG;WACU,WAAW,CACtB,IAAI,EAAE,OAAO,GAAG,SAAS,EACzB,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;IAgBhB;;OAEG;IACH,MAAM,CAAC,kBAAkB,IAAI,YAAY;IAIzC;;OAEG;IACH,MAAM,CAAC,SAAS,IAAI,OAAO;IAI3B;;OAEG;IACH,MAAM,CAAC,OAAO,IAAI,OAAO;IAIzB;;OAEG;IACH,MAAM,CAAC,OAAO,IAAI,OAAO;CAI1B;AACD,QAAA,MAAM,gBAAgB,kCAA4B,CAAC;AACnD,QAAA,MAAM,gBAAgB,kCAA4B,CAAC;AACnD,QAAA,MAAM,mBAAmB,qCAA+B,CAAC;AAIzD,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,CAAC;AAC9B,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { RegistryValueResult, RegistryOptions, RegistryValue, RegistryKeyInfo } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
import { KYLINHKEY } from './registry';
|
|
3
|
+
export declare class KylinRegistry {
|
|
4
|
+
private static instance;
|
|
5
|
+
private static readonly valueBackupCache;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): KylinRegistry;
|
|
8
|
+
private static mapRegistryToConfigPath;
|
|
9
|
+
private static ensureConfigDir;
|
|
10
|
+
private static safeOperation;
|
|
11
|
+
private static delay;
|
|
12
|
+
static getValue(hive: KYLINHKEY, key: string, valueName: string, options?: RegistryOptions): Promise<RegistryValueResult>;
|
|
13
|
+
static setValue(hive: KYLINHKEY, key: string, valueName: string, value: RegistryValue, options?: RegistryOptions): Promise<void>;
|
|
14
|
+
static deleteValue(hive: KYLINHKEY, key: string, valueName: string, options?: RegistryOptions): Promise<void>;
|
|
15
|
+
static createKey(hive: KYLINHKEY, key: string, options?: RegistryOptions): Promise<void>;
|
|
16
|
+
static deleteKey(hive: KYLINHKEY, key: string, options?: RegistryOptions): Promise<void>;
|
|
17
|
+
static listKeys(hive: KYLINHKEY, key: string, options?: RegistryOptions): Promise<string[]>;
|
|
18
|
+
static listValues(hive: KYLINHKEY, key: string, options?: RegistryOptions): Promise<Array<{
|
|
19
|
+
name: string;
|
|
20
|
+
value: RegistryValue;
|
|
21
|
+
}>>;
|
|
22
|
+
static getKeyInfo(hive: KYLINHKEY, key: string, options?: RegistryOptions): Promise<RegistryKeyInfo>;
|
|
23
|
+
static batchSetValues(hive: KYLINHKEY, key: string, values: Record<string, {
|
|
24
|
+
value: RegistryValue;
|
|
25
|
+
}>, options?: RegistryOptions): Promise<void>;
|
|
26
|
+
static keyExists(hive: KYLINHKEY, key: string): Promise<boolean>;
|
|
27
|
+
static valueExists(hive: KYLINHKEY, key: string, valueName: string, options?: RegistryOptions): Promise<boolean>;
|
|
28
|
+
setConfigBaseDir(baseDir: string): void;
|
|
29
|
+
getConfigBaseDir(): string;
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=kylin-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"kylin-registry.d.ts","sourceRoot":"","sources":["../../../../../src/platform/platform/registry/kylin-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,eAAe,EAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAqBvC,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAA8B;IAErD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAA0C;IAElF,OAAO;IAIP,MAAM,CAAC,WAAW,IAAI,aAAa;IAQnC,OAAO,CAAC,MAAM,CAAC,uBAAuB;mBAKjB,eAAe;mBAIf,aAAa;IAuBlC,OAAO,CAAC,MAAM,CAAC,KAAK;WAKP,QAAQ,CACnB,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC;WA2BlB,QAAQ,CACnB,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;WA+BH,WAAW,CACtB,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;WAkCH,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;WAYrF,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;WAiBrF,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;WAoBxF,UAAU,CACrB,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;WAoB5C,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;WAqBjG,cAAc,CACzB,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,CAAC,EAChD,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;WA2BH,SAAS,CAAC,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAYzD,WAAW,CACtB,IAAI,EAAE,SAAS,EACf,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC;IASnB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIvC,gBAAgB,IAAI,MAAM;CAG3B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HKEY_LOCAL_MACHINE:系统级配置,全局生效
|
|
3
|
+
Software:软件配置的标准位置
|
|
4
|
+
ahana-electron-app:你的应用专属配置键
|
|
5
|
+
dbName:具体的配置值
|
|
6
|
+
*/
|
|
7
|
+
export declare enum WINHKEY {
|
|
8
|
+
/**
|
|
9
|
+
* 本地机器配置 - 整个计算机的全局设置
|
|
10
|
+
* 包含操作系统、硬件、已安装软件的系统级配置
|
|
11
|
+
* 适用于计算机上所有用户,修改通常需要管理员权限
|
|
12
|
+
*/
|
|
13
|
+
HKLM = "HKEY_LOCAL_MACHINE",
|
|
14
|
+
/**
|
|
15
|
+
* 当前用户配置 - 当前登录用户的个人设置
|
|
16
|
+
* 包含用户个性化设置、应用程序用户配置等
|
|
17
|
+
* 仅对当前登录用户有效,用户可直接修改
|
|
18
|
+
*/
|
|
19
|
+
HKCU = "HKEY_CURRENT_USER",
|
|
20
|
+
/**
|
|
21
|
+
* 类根配置 - 文件类型关联和COM对象注册
|
|
22
|
+
* 包含文件扩展名关联、COM类、接口配置等
|
|
23
|
+
* 实际上是 HKLM\Software\Classes 和 HKCU\Software\Classes 的合并视图
|
|
24
|
+
*/
|
|
25
|
+
HKCR = "HKEY_CLASSES_ROOT",
|
|
26
|
+
/**
|
|
27
|
+
* 用户配置 - 计算机上所有用户的配置
|
|
28
|
+
* 包含系统上所有用户的配置文件
|
|
29
|
+
* 每个用户有一个以其SID命名的子键
|
|
30
|
+
*/
|
|
31
|
+
HKU = "HKEY_USERS",
|
|
32
|
+
/**
|
|
33
|
+
* 当前配置 - 当前硬件配置文件
|
|
34
|
+
* 包含当前系统启动时加载的硬件配置
|
|
35
|
+
* 通常是 HKLM\System\CurrentControlSet\Hardware Profiles\Current 的镜像
|
|
36
|
+
*/
|
|
37
|
+
HKCC = "HKEY_CURRENT_CONFIG"
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Windows 注册表一级子键(按配置单元分类)
|
|
41
|
+
*/
|
|
42
|
+
export declare enum WINHKLM {
|
|
43
|
+
SOFTWARE = "HKEY_LOCAL_MACHINE:Software",
|
|
44
|
+
SYSTEM = "HKEY_LOCAL_MACHINE:System",
|
|
45
|
+
HARDWARE = "HKEY_LOCAL_MACHINE:Hardware",
|
|
46
|
+
SECURITY = "HKEY_LOCAL_MACHINE:Security",
|
|
47
|
+
SAM = "HKEY_LOCAL_MACHINE:SAM",
|
|
48
|
+
COMPONENTS = "HKEY_LOCAL_MACHINE:Components",
|
|
49
|
+
DRIVERS = "HKEY_LOCAL_MACHINE:Drivers",
|
|
50
|
+
ENUM = "HKEY_LOCAL_MACHINE:Enum",
|
|
51
|
+
BCD = "HKEY_LOCAL_MACHINE:BCD"
|
|
52
|
+
}
|
|
53
|
+
export declare enum WINHKCU {
|
|
54
|
+
SOFTWARE = "HKEY_CURRENT_USER:Software",
|
|
55
|
+
CONTROL_PANEL = "HKEY_CURRENT_USER:Control Panel",
|
|
56
|
+
ENVIRONMENT = "HKEY_CURRENT_USER:Environment",
|
|
57
|
+
CONSOLE = "HKEY_CURRENT_USER:Console",
|
|
58
|
+
NETWORK = "HKEY_CURRENT_USER:Network",
|
|
59
|
+
PRINTERS = "HKEY_CURRENT_USER:Printers",
|
|
60
|
+
SESSION_INFO = "HKEY_CURRENT_USER:SessionInformation"
|
|
61
|
+
}
|
|
62
|
+
export declare enum WINHKCR {
|
|
63
|
+
CLSID = "HKEY_CURRENT_USER:CLSID",
|
|
64
|
+
INTERFACE = "HKEY_CURRENT_USER:Interface",
|
|
65
|
+
TYPELIB = "HKEY_CURRENT_USER:TypeLib",
|
|
66
|
+
APPID = "HKEY_CURRENT_USER:AppID",
|
|
67
|
+
COMPONENT_CATEGORIES = "HKEY_CURRENT_USER:Component Categories",
|
|
68
|
+
PROTOCOLS = "HKEY_CURRENT_USER:Protocols"
|
|
69
|
+
}
|
|
70
|
+
export declare enum WINHKU {
|
|
71
|
+
DEFAULT = "HKEY_USERS:.DEFAULT"
|
|
72
|
+
}
|
|
73
|
+
export declare enum WINHKCC {
|
|
74
|
+
SOFTWARE = "HKEY_CURRENT_CONFIG:Software",
|
|
75
|
+
SYSTEM = "HKEY_CURRENT_CONFIG:System"
|
|
76
|
+
}
|
|
77
|
+
export declare enum KYLINHKEY {
|
|
78
|
+
ETC_APP = "/etc/applications",
|
|
79
|
+
USR_SHARE_APP = "/usr/share/applications",
|
|
80
|
+
CONFIG_APPS = "~/.config/applications",
|
|
81
|
+
ICONS = "/usr/share/icons",
|
|
82
|
+
THEMES = "/usr/share/themes",
|
|
83
|
+
FONTS = "/usr/share/fonts",
|
|
84
|
+
DOC = "/usr/share/doc",
|
|
85
|
+
MAN = "/usr/share/man",
|
|
86
|
+
LOCALE = "/usr/share/locale"
|
|
87
|
+
}
|
|
88
|
+
export declare const normalizeRegistryPathAdvanced: (path: string) => string;
|
|
89
|
+
//# sourceMappingURL=registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../../../src/platform/platform/registry/registry.ts"],"names":[],"mappings":"AAAA;;;;;EAKE;AACF,oBAAY,OAAO;IACjB;;;;OAIG;IACH,IAAI,uBAAuB;IAE3B;;;;OAIG;IACH,IAAI,sBAAsB;IAE1B;;;;OAIG;IACH,IAAI,sBAAsB;IAE1B;;;;OAIG;IACH,GAAG,eAAe;IAElB;;;;OAIG;IACH,IAAI,wBAAwB;CAC7B;AAED;;GAEG;AAEH,oBAAY,OAAO;IACjB,QAAQ,gCAAgC;IACxC,MAAM,8BAA8B;IACpC,QAAQ,gCAAgC;IACxC,QAAQ,gCAAgC;IACxC,GAAG,2BAA2B;IAC9B,UAAU,kCAAkC;IAC5C,OAAO,+BAA+B;IACtC,IAAI,4BAA4B;IAChC,GAAG,2BAA2B;CAC/B;AAGD,oBAAY,OAAO;IACjB,QAAQ,+BAA+B;IACvC,aAAa,oCAAoC;IACjD,WAAW,kCAAkC;IAC7C,OAAO,8BAA8B;IACrC,OAAO,8BAA8B;IACrC,QAAQ,+BAA+B;IACvC,YAAY,yCAAyC;CACtD;AAGD,oBAAY,OAAO;IACjB,KAAK,4BAA4B;IACjC,SAAS,gCAAgC;IACzC,OAAO,8BAA8B;IACrC,KAAK,4BAA4B;IACjC,oBAAoB,2CAA2C;IAC/D,SAAS,gCAAgC;CAC1C;AAGD,oBAAY,MAAM;IAChB,OAAO,wBAAwB;CAChC;AAGD,oBAAY,OAAO;IACjB,QAAQ,iCAAiC;IACzC,MAAM,+BAA+B;CACtC;AAED,oBAAY,SAAS;IAEnB,OAAO,sBAAsB;IAG7B,aAAa,4BAA4B;IAGzC,WAAW,2BAA2B;IAMtC,KAAK,qBAAqB;IAG1B,MAAM,sBAAsB;IAG5B,KAAK,qBAAqB;IAG1B,GAAG,mBAAmB;IAGtB,GAAG,mBAAmB;IAGtB,MAAM,sBAAsB;CAC7B;AAED,eAAO,MAAM,6BAA6B,SAAU,MAAM,KAAG,MASjC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { RegistryValue, RegistryOptions, RegistryValueResult, RegistryKeyInfo } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
import { WINHKLM } from './registry';
|
|
3
|
+
export declare class WindowsRegistry {
|
|
4
|
+
private static instance;
|
|
5
|
+
private static readonly valueBackupCache;
|
|
6
|
+
private constructor();
|
|
7
|
+
static getInstance(): WindowsRegistry;
|
|
8
|
+
private static buildRegPath;
|
|
9
|
+
private static convertToRegType;
|
|
10
|
+
private static parseRegValue;
|
|
11
|
+
private static safeOperation;
|
|
12
|
+
private static delay;
|
|
13
|
+
static getValue(hive: WINHKLM, key: string, valueName: string, options?: RegistryOptions): Promise<RegistryValueResult>;
|
|
14
|
+
static setValue(hive: WINHKLM, key: string, valueName: string, value: RegistryValue, options?: RegistryOptions): Promise<void>;
|
|
15
|
+
static deleteValue(hive: WINHKLM, key: string, valueName: string, options?: RegistryOptions): Promise<void>;
|
|
16
|
+
static createKey(hive: WINHKLM, key: string, options?: RegistryOptions): Promise<void>;
|
|
17
|
+
static deleteKey(hive: WINHKLM, key: string, options?: RegistryOptions): Promise<void>;
|
|
18
|
+
static listKeys(hive: WINHKLM, key: string, options?: RegistryOptions): Promise<string[]>;
|
|
19
|
+
private static parseRegistryKeysSimple;
|
|
20
|
+
static listValues(hive: WINHKLM, key: string, options?: RegistryOptions): Promise<Array<{
|
|
21
|
+
name: string;
|
|
22
|
+
value: RegistryValue;
|
|
23
|
+
}>>;
|
|
24
|
+
static getKeyInfo(hive: WINHKLM, key: string, options?: RegistryOptions): Promise<RegistryKeyInfo>;
|
|
25
|
+
static batchSetValues(hive: WINHKLM, key: string, values: Record<string, {
|
|
26
|
+
value: RegistryValue;
|
|
27
|
+
}>, options?: RegistryOptions): Promise<void>;
|
|
28
|
+
static keyExists(hive: WINHKLM, key: string): Promise<boolean>;
|
|
29
|
+
static valueExists(hive: WINHKLM, key: string, valueName: string, options?: RegistryOptions): Promise<boolean>;
|
|
30
|
+
static restoreBackup(hive: WINHKLM, key: string, valueName: string): Promise<boolean>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=windows-registry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windows-registry.d.ts","sourceRoot":"","sources":["../../../../../src/platform/platform/registry/windows-registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,eAAe,EAChB,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAwCrC,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAgC;IACvD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,gBAAgB,CAA0C;IAElF,OAAO;IAEP,MAAM,CAAC,WAAW,IAAI,eAAe;IAQrC,OAAO,CAAC,MAAM,CAAC,YAAY;IAM3B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAwB/B,OAAO,CAAC,MAAM,CAAC,aAAa;mBAiCP,aAAa;IAuBlC,OAAO,CAAC,MAAM,CAAC,KAAK;WAKP,QAAQ,CACnB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC;WAgClB,QAAQ,CACnB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,aAAa,EACpB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;WA0BH,WAAW,CACtB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;WAmCH,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;WAqBnF,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,IAAI,CAAC;WA6BnF,QAAQ,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IA+BnG,OAAO,CAAC,MAAM,CAAC,uBAAuB;WAmBzB,UAAU,CACrB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;WAwD5C,UAAU,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAAG,OAAO,CAAC,eAAe,CAAC;WAoB/F,cAAc,CACzB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,CAAC,EAChD,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC;WAaH,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;WAavD,WAAW,CACtB,IAAI,EAAE,OAAO,EACb,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,MAAM,EACjB,OAAO,GAAE,eAAoB,GAC5B,OAAO,CAAC,OAAO,CAAC;WAUN,aAAa,CAAC,IAAI,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAgB5F"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ApiError } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
export declare class AppError extends Error {
|
|
3
|
+
readonly statusCode: string;
|
|
4
|
+
readonly code: number;
|
|
5
|
+
constructor(message: string, code?: number, statusCode?: string);
|
|
6
|
+
toJSON(): ApiError;
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=AppError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppError.d.ts","sourceRoot":"","sources":["../../../../src/response-factory/factory/AppError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sCAAsC,CAAC;AAGrE,qBAAa,QAAS,SAAQ,KAAK;IACjC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,IAAI,EAAE,MAAM,CAAC;gBAEjB,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAY,EAAE,UAAU,GAAE,MAAoB;IAcjF,MAAM,IAAI,QAAQ;CAOnB"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { AppError } from './AppError';
|
|
2
|
+
/**
|
|
3
|
+
* 基础业务错误类
|
|
4
|
+
*/
|
|
5
|
+
export declare class BusinessError extends AppError {
|
|
6
|
+
constructor(message: string, code?: number, statusCode?: string);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* 资源未找到错误
|
|
10
|
+
*/
|
|
11
|
+
export declare class NotFoundError extends BusinessError {
|
|
12
|
+
constructor(resource: string, id?: string | number);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* 未授权访问错误
|
|
16
|
+
*/
|
|
17
|
+
export declare class UnauthorizedError extends BusinessError {
|
|
18
|
+
constructor(message?: string);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 禁止访问错误
|
|
22
|
+
*/
|
|
23
|
+
export declare class ForbiddenError extends BusinessError {
|
|
24
|
+
constructor(message?: string);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 请求验证错误
|
|
28
|
+
*/
|
|
29
|
+
export declare class ValidationError extends BusinessError {
|
|
30
|
+
constructor(message?: string);
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 冲突错误 (如资源已存在)
|
|
34
|
+
*/
|
|
35
|
+
export declare class ConflictError extends BusinessError {
|
|
36
|
+
constructor(message?: string);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* 请求限制错误
|
|
40
|
+
*/
|
|
41
|
+
export declare class RateLimitError extends BusinessError {
|
|
42
|
+
constructor(message?: string);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* 内部服务器错误
|
|
46
|
+
*/
|
|
47
|
+
export declare class InternalServerError extends AppError {
|
|
48
|
+
constructor(message?: string);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 网络错误
|
|
52
|
+
*/
|
|
53
|
+
export declare class NetworkError extends AppError {
|
|
54
|
+
constructor(message?: string);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* 业务逻辑错误集合
|
|
58
|
+
*/
|
|
59
|
+
export declare const BusinessErrors: {
|
|
60
|
+
400: typeof BusinessError;
|
|
61
|
+
404: typeof NotFoundError;
|
|
62
|
+
401: typeof UnauthorizedError;
|
|
63
|
+
403: typeof ForbiddenError;
|
|
64
|
+
422: typeof ValidationError;
|
|
65
|
+
409: typeof ConflictError;
|
|
66
|
+
429: typeof RateLimitError;
|
|
67
|
+
500: typeof InternalServerError;
|
|
68
|
+
503: typeof NetworkError;
|
|
69
|
+
};
|
|
70
|
+
//# sourceMappingURL=BusinessError.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BusinessError.d.ts","sourceRoot":"","sources":["../../../../src/response-factory/factory/BusinessError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;GAEG;AACH,qBAAa,aAAc,SAAQ,QAAQ;gBAC7B,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,MAAY,EAAE,UAAU,GAAE,MAAyB;CAIvF;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,aAAa;gBAClC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM;CAKnD;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,aAAa;gBACtC,OAAO,GAAE,MAAgB;CAItC;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,aAAa;gBACnC,OAAO,GAAE,MAAe;CAIrC;AAED;;GAEG;AACH,qBAAa,eAAgB,SAAQ,aAAa;gBACpC,OAAO,GAAE,MAAe;CAIrC;AAED;;GAEG;AACH,qBAAa,aAAc,SAAQ,aAAa;gBAClC,OAAO,GAAE,MAAgB;CAItC;AAED;;GAEG;AACH,qBAAa,cAAe,SAAQ,aAAa;gBACnC,OAAO,GAAE,MAAiB;CAIvC;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,QAAQ;gBACnC,OAAO,GAAE,MAAkB;CAIxC;AAED;;GAEG;AACH,qBAAa,YAAa,SAAQ,QAAQ;gBAC5B,OAAO,GAAE,MAAe;CAIrC;AAED;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;;;;CAU1B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/response-factory/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,eAAe,eAAe,CAAC"}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __publicField = (obj, key, value) => {
|
|
4
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
5
|
+
return value;
|
|
6
|
+
};
|
|
7
|
+
import { L as LoggerService } from "../index-xOyNRTcn.js";
|
|
8
|
+
class AppError extends Error {
|
|
9
|
+
constructor(message, code = 500, statusCode = "APP_ERROR") {
|
|
10
|
+
super(message);
|
|
11
|
+
__publicField(this, "statusCode");
|
|
12
|
+
__publicField(this, "code");
|
|
13
|
+
this.statusCode = statusCode;
|
|
14
|
+
this.code = code;
|
|
15
|
+
Object.setPrototypeOf(this, AppError.prototype);
|
|
16
|
+
}
|
|
17
|
+
toJSON() {
|
|
18
|
+
return {
|
|
19
|
+
message: this.message,
|
|
20
|
+
code: this.code,
|
|
21
|
+
statusCode: this.statusCode
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class BusinessError extends AppError {
|
|
26
|
+
constructor(message, code = 400, statusCode = "BUSINESS_ERROR") {
|
|
27
|
+
super(message, code, statusCode);
|
|
28
|
+
Object.setPrototypeOf(this, BusinessError.prototype);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
class NotFoundError extends BusinessError {
|
|
32
|
+
constructor(resource, id) {
|
|
33
|
+
const message = id ? `${resource} (ID: ${id}) 未找到` : `${resource} 未找到`;
|
|
34
|
+
super(message, 404, "NOT_FOUND");
|
|
35
|
+
Object.setPrototypeOf(this, NotFoundError.prototype);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
class UnauthorizedError extends BusinessError {
|
|
39
|
+
constructor(message = "未授权访问") {
|
|
40
|
+
super(message, 401, "UNAUTHORIZED");
|
|
41
|
+
Object.setPrototypeOf(this, UnauthorizedError.prototype);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
class ForbiddenError extends BusinessError {
|
|
45
|
+
constructor(message = "禁止访问") {
|
|
46
|
+
super(message, 403, "FORBIDDEN");
|
|
47
|
+
Object.setPrototypeOf(this, ForbiddenError.prototype);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class ValidationError extends BusinessError {
|
|
51
|
+
constructor(message = "验证失败") {
|
|
52
|
+
super(message, 422, "VALIDATION_ERROR");
|
|
53
|
+
Object.setPrototypeOf(this, ValidationError.prototype);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
class ConflictError extends BusinessError {
|
|
57
|
+
constructor(message = "资源已存在") {
|
|
58
|
+
super(message, 409, "CONFLICT");
|
|
59
|
+
Object.setPrototypeOf(this, ConflictError.prototype);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
class RateLimitError extends BusinessError {
|
|
63
|
+
constructor(message = "请求过于频繁") {
|
|
64
|
+
super(message, 429, "RATE_LIMIT_EXCEEDED");
|
|
65
|
+
Object.setPrototypeOf(this, RateLimitError.prototype);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
class InternalServerError extends AppError {
|
|
69
|
+
constructor(message = "内部服务器错误") {
|
|
70
|
+
super(message, 500, "INTERNAL_SERVER_ERROR");
|
|
71
|
+
Object.setPrototypeOf(this, InternalServerError.prototype);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
class NetworkError extends AppError {
|
|
75
|
+
constructor(message = "网络错误") {
|
|
76
|
+
super(message, 503, "NETWORK_ERROR");
|
|
77
|
+
Object.setPrototypeOf(this, NetworkError.prototype);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
const BusinessErrors = {
|
|
81
|
+
400: BusinessError,
|
|
82
|
+
404: NotFoundError,
|
|
83
|
+
401: UnauthorizedError,
|
|
84
|
+
403: ForbiddenError,
|
|
85
|
+
422: ValidationError,
|
|
86
|
+
409: ConflictError,
|
|
87
|
+
429: RateLimitError,
|
|
88
|
+
500: InternalServerError,
|
|
89
|
+
503: NetworkError
|
|
90
|
+
};
|
|
91
|
+
class ResponseFactory {
|
|
92
|
+
constructor(sqliteDatabaseConfig) {
|
|
93
|
+
__publicField(this, "logger");
|
|
94
|
+
__publicField(this, "logConfig");
|
|
95
|
+
this.logger = null;
|
|
96
|
+
this.logConfig = sqliteDatabaseConfig;
|
|
97
|
+
}
|
|
98
|
+
registerogger() {
|
|
99
|
+
this.logger = new LoggerService(this.logConfig);
|
|
100
|
+
}
|
|
101
|
+
success(data, message = "操作成功", code = 200) {
|
|
102
|
+
return {
|
|
103
|
+
code,
|
|
104
|
+
message,
|
|
105
|
+
data,
|
|
106
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
error(error, statusCode = 500) {
|
|
110
|
+
if (!this.logger)
|
|
111
|
+
this.registerogger();
|
|
112
|
+
const BusinessError2 = BusinessErrors[statusCode] ? BusinessErrors[statusCode] : BusinessErrors[500];
|
|
113
|
+
const message = typeof error === "string" ? error : error.message || "操作失败";
|
|
114
|
+
const errorResponse = new BusinessError2(String(message));
|
|
115
|
+
this.logger && this.logger.error(String(message));
|
|
116
|
+
return errorResponse.toJSON();
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
export {
|
|
120
|
+
ResponseFactory as default
|
|
121
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Logger, LoggerConfig, ResponseError } from '@ahana-awesome-platform/shared-types';
|
|
2
|
+
export declare class ResponseFactory {
|
|
3
|
+
logger: Logger | null;
|
|
4
|
+
logConfig: LoggerConfig;
|
|
5
|
+
constructor(sqliteDatabaseConfig: LoggerConfig);
|
|
6
|
+
registerogger(): void;
|
|
7
|
+
success<T>(data: T, message?: string, code?: number): {
|
|
8
|
+
code: number;
|
|
9
|
+
message: string;
|
|
10
|
+
data: T;
|
|
11
|
+
timestamp: string;
|
|
12
|
+
};
|
|
13
|
+
error(error: ResponseError, statusCode?: number): import("@ahana-awesome-platform/shared-types").ApiError;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=Response.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Response.d.ts","sourceRoot":"","sources":["../../../../src/response-factory/response/Response.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,sCAAsC,CAAC;AAIhG,qBAAa,eAAe;IAC1B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,YAAY,CAAC;gBAEZ,oBAAoB,EAAE,YAAY;IAKvC,aAAa;IAIpB,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,OAAO,SAAS,EAAE,IAAI,SAAM;;;;;;IAShD,KAAK,CAAC,KAAK,EAAE,aAAa,EAAE,UAAU,SAAM;CAU7C"}
|