@laiye_packages/uci 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/app/base/index.d.ts +80 -0
- package/dist/app/index.d.ts +14 -0
- package/dist/app/organization/api/department.d.ts +44 -0
- package/dist/app/organization/api/license.d.ts +60 -0
- package/dist/app/organization/api/notification.d.ts +98 -0
- package/dist/app/organization/api/oem.d.ts +39 -0
- package/dist/app/organization/api/open_api.d.ts +78 -0
- package/dist/app/organization/api/permission.d.ts +71 -0
- package/dist/app/organization/api/session.d.ts +51 -0
- package/dist/app/organization/api/sso.d.ts +0 -0
- package/dist/app/organization/api/user.d.ts +95 -0
- package/dist/app/organization/api/verificationCodes.d.ts +27 -0
- package/dist/app/organization/app/index.d.ts +30 -0
- package/dist/app/organization/authorizer/base.d.ts +35 -0
- package/dist/app/organization/authorizer/direct.d.ts +11 -0
- package/dist/app/organization/authorizer/gateway.d.ts +5 -0
- package/dist/app/organization/authorizer/redirect.d.ts +18 -0
- package/dist/app/organization/authorizer/web.d.ts +25 -0
- package/dist/app/organization/index.d.ts +1 -0
- package/dist/app/tenant/api/configuration.d.ts +8 -0
- package/dist/app/tenant/api/session.d.ts +23 -0
- package/dist/app/tenant/api/tenant.d.ts +25 -0
- package/dist/app/tenant/api/user.d.ts +27 -0
- package/dist/app/tenant/app/index.d.ts +20 -0
- package/dist/app/tenant/authorizer/index.d.ts +13 -0
- package/dist/app/tenant/index.d.ts +1 -0
- package/dist/app/tenant/session/index.d.ts +57 -0
- package/dist/config/address.d.ts +5 -0
- package/dist/config/app.d.ts +5 -0
- package/dist/config/base.d.ts +15 -0
- package/dist/config/crypto.d.ts +5 -0
- package/dist/config/http.d.ts +14 -0
- package/dist/config/index.d.ts +12 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/crypto/base.d.ts +14 -0
- package/dist/crypto/gm.d.ts +3 -0
- package/dist/crypto/index.d.ts +144 -0
- package/dist/crypto/sm.d.ts +17 -0
- package/dist/env/index.d.ts +76 -0
- package/dist/error/index.d.ts +16 -0
- package/dist/http/base.d.ts +52 -0
- package/dist/http/error.d.ts +34 -0
- package/dist/http/index.d.ts +170 -0
- package/dist/http/trace.d.ts +1 -0
- package/dist/i18n/index.d.ts +50 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +12194 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/index.d.ts +75 -0
- package/dist/object/index.d.ts +57 -0
- package/dist/observable/index.d.ts +14 -0
- package/dist/observable/serializeable.d.ts +86 -0
- package/dist/permission/index.d.ts +9 -0
- package/dist/session/index.d.ts +74 -0
- package/dist/storage/index.d.ts +98 -0
- package/package.json +87 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { type AxiosInstance } from 'axios';
|
|
2
|
+
import { LYObject } from '../object';
|
|
3
|
+
import { type LYHttpRetryConfig } from '../config/http';
|
|
4
|
+
export type LYHttpRequestConfig = {
|
|
5
|
+
method?: LYHttpRequestMethod;
|
|
6
|
+
url?: string;
|
|
7
|
+
baseURL?: string;
|
|
8
|
+
headers?: Record<string, string>;
|
|
9
|
+
params?: Record<string, any>;
|
|
10
|
+
data?: Record<string, any>;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
withCredentials?: boolean;
|
|
13
|
+
onUploadProgress?: (progress: number) => void;
|
|
14
|
+
onDownloadProgress?: (progress: number) => void;
|
|
15
|
+
signal?: AbortSignal;
|
|
16
|
+
responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text' | 'stream' | 'formdata';
|
|
17
|
+
};
|
|
18
|
+
export interface ILYHttpClient {
|
|
19
|
+
get<T>(url: string, query?: Record<string, any>): Promise<T>;
|
|
20
|
+
post<T>(url: string, data?: Record<string, any>): Promise<T>;
|
|
21
|
+
put<T>(url: string, data?: Record<string, any>): Promise<T>;
|
|
22
|
+
delete<T>(url: string, query?: Record<string, any>): Promise<T>;
|
|
23
|
+
patch<T>(url: string, data?: Record<string, any>): Promise<T>;
|
|
24
|
+
}
|
|
25
|
+
export type LYHttpRequestMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
26
|
+
export interface LYKeyConverter {
|
|
27
|
+
convert_request(key: string): string;
|
|
28
|
+
convert_response(key: string): string;
|
|
29
|
+
}
|
|
30
|
+
export declare class LYSnakeCaseDataConverter implements LYKeyConverter {
|
|
31
|
+
convert_request(key: string): string;
|
|
32
|
+
convert_response(key: string): string;
|
|
33
|
+
}
|
|
34
|
+
export declare class LYHttpClient extends LYObject implements ILYHttpClient {
|
|
35
|
+
private _baseUrl;
|
|
36
|
+
private _key_converter?;
|
|
37
|
+
protected _client: AxiosInstance;
|
|
38
|
+
constructor(baseUrl?: string);
|
|
39
|
+
get baseUrl(): string;
|
|
40
|
+
get key_converter(): LYKeyConverter | undefined;
|
|
41
|
+
set key_converter(converter: LYKeyConverter | undefined);
|
|
42
|
+
private _convert_request;
|
|
43
|
+
private _convert_response;
|
|
44
|
+
protected _get_headers(): Record<string, string> | undefined;
|
|
45
|
+
protected _request(config: LYHttpRequestConfig): Promise<any>;
|
|
46
|
+
withRetry(fn: (config: LYHttpRetryConfig) => LYHttpRetryConfig): Promise<this>;
|
|
47
|
+
get<TResponse = Record<string, any>, TQuery = Record<string, any>>(url: string, query?: TQuery, config?: LYHttpRequestConfig): Promise<TResponse>;
|
|
48
|
+
post<TResponse = Record<string, any>, TData = Record<string, any>>(url: string, data?: TData, config?: LYHttpRequestConfig): Promise<TResponse>;
|
|
49
|
+
put<TResponse = Record<string, any>, TData = Record<string, any>>(url: string, data?: TData, config?: LYHttpRequestConfig): Promise<TResponse>;
|
|
50
|
+
delete<TResponse = Record<string, any>, TQuery = Record<string, any>>(url: string, query?: TQuery, config?: LYHttpRequestConfig): Promise<TResponse>;
|
|
51
|
+
patch<TResponse = Record<string, any>, TData = Record<string, any>>(url: string, data?: TData, config?: LYHttpRequestConfig): Promise<TResponse>;
|
|
52
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LYError } from '../error';
|
|
2
|
+
export type LYBasicResultCode = 'success' | 'failed' | 'invalid_params' | 'exists' | 'not_exists' | 'forbidden' | 'timeout' | 'expired';
|
|
3
|
+
export declare class LYBaseHttpError extends LYError {
|
|
4
|
+
private _url;
|
|
5
|
+
private _method;
|
|
6
|
+
private _inner_error;
|
|
7
|
+
constructor(message: string, url: string, method: string, inner_error: Error);
|
|
8
|
+
get url(): string;
|
|
9
|
+
get method(): string;
|
|
10
|
+
get inner_error(): Error;
|
|
11
|
+
}
|
|
12
|
+
export declare class LYConfigError extends LYBaseHttpError {
|
|
13
|
+
}
|
|
14
|
+
export declare class LYNetworkError extends LYBaseHttpError {
|
|
15
|
+
}
|
|
16
|
+
export declare enum LYHttpStatus {
|
|
17
|
+
SUCCESS = 200,
|
|
18
|
+
BAD_REQUEST = 400,
|
|
19
|
+
UNAUTHORIZED = 401,
|
|
20
|
+
FORBIDDEN = 403,
|
|
21
|
+
NOT_FOUND = 404,
|
|
22
|
+
TOO_MANY_REQUESTS = 429,
|
|
23
|
+
INTERNAL_SERVER_ERROR = 500
|
|
24
|
+
}
|
|
25
|
+
export declare class LYHttpStatusError extends LYBaseHttpError {
|
|
26
|
+
private _status;
|
|
27
|
+
constructor(message: string, url: string, method: string, inner_error: Error, status: number);
|
|
28
|
+
get status(): number;
|
|
29
|
+
getStatus(): LYHttpStatus | undefined;
|
|
30
|
+
}
|
|
31
|
+
export declare class LYAppHttpError extends LYBaseHttpError {
|
|
32
|
+
constructor(message: string, url: string, method: string, inner_error: Error, code: string);
|
|
33
|
+
getCode<T extends LYBasicResultCode = LYBasicResultCode>(): T;
|
|
34
|
+
}
|
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import { LYEvents } from '../object';
|
|
2
|
+
import { type LYBasicResultCode } from './error';
|
|
3
|
+
import { LYHttpClient, LYHttpRequestConfig } from './base';
|
|
4
|
+
import { AxiosResponse } from 'axios';
|
|
5
|
+
export interface LYSSEConfig {
|
|
6
|
+
data?: Record<string, any>;
|
|
7
|
+
delimiter?: string;
|
|
8
|
+
signal?: AbortSignal;
|
|
9
|
+
headers?: Record<string, string>;
|
|
10
|
+
}
|
|
11
|
+
export type LYSortQueryParams = {
|
|
12
|
+
sort: string[];
|
|
13
|
+
};
|
|
14
|
+
export type LYRangeQueryParams = {
|
|
15
|
+
offset: number;
|
|
16
|
+
size: number;
|
|
17
|
+
sort: string[];
|
|
18
|
+
};
|
|
19
|
+
export interface LYBaseResponse {
|
|
20
|
+
}
|
|
21
|
+
export interface LYBaseDataResponse extends LYBaseResponse {
|
|
22
|
+
id: string;
|
|
23
|
+
created_at: string;
|
|
24
|
+
updated_at: string;
|
|
25
|
+
updated_by?: string;
|
|
26
|
+
}
|
|
27
|
+
interface LYRangeResponse extends LYBaseResponse {
|
|
28
|
+
offset: number;
|
|
29
|
+
size: number;
|
|
30
|
+
total?: number;
|
|
31
|
+
}
|
|
32
|
+
interface LYBaseResultResponse extends LYBaseResponse {
|
|
33
|
+
message: string;
|
|
34
|
+
tips?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface LYIdentifierResponse extends LYBaseResponse {
|
|
37
|
+
id: string;
|
|
38
|
+
}
|
|
39
|
+
export interface LYCountResponse extends LYBaseResponse {
|
|
40
|
+
count: number;
|
|
41
|
+
}
|
|
42
|
+
export interface LYResultResponse<T extends LYBaseResponse, C = LYBasicResultCode> extends LYBaseResultResponse {
|
|
43
|
+
code: C;
|
|
44
|
+
data?: T;
|
|
45
|
+
}
|
|
46
|
+
export interface LYListResponse<T extends LYBaseResponse> extends LYBaseResponse {
|
|
47
|
+
range?: LYRangeResponse;
|
|
48
|
+
list: T[];
|
|
49
|
+
}
|
|
50
|
+
export interface IHeaderProvider {
|
|
51
|
+
headers?: Record<string, string>;
|
|
52
|
+
}
|
|
53
|
+
export interface LYUploadResponse {
|
|
54
|
+
id: string;
|
|
55
|
+
state: LYUploadState;
|
|
56
|
+
}
|
|
57
|
+
export interface LYUploadParams {
|
|
58
|
+
id?: string;
|
|
59
|
+
ref_id?: string;
|
|
60
|
+
ref_type?: string;
|
|
61
|
+
expire?: number | string;
|
|
62
|
+
ignore_session?: boolean;
|
|
63
|
+
extra?: Record<string, any>;
|
|
64
|
+
encryption?: boolean;
|
|
65
|
+
state?: LYUploadState;
|
|
66
|
+
level?: 'default' | 'low';
|
|
67
|
+
chunk?: File;
|
|
68
|
+
total_size?: number;
|
|
69
|
+
}
|
|
70
|
+
type LYUploadState = {
|
|
71
|
+
bucket: string;
|
|
72
|
+
key: string;
|
|
73
|
+
completed_size: number;
|
|
74
|
+
upload_id: string;
|
|
75
|
+
part_number: number;
|
|
76
|
+
parts: {
|
|
77
|
+
PartNumber: number;
|
|
78
|
+
ETag: string;
|
|
79
|
+
}[];
|
|
80
|
+
};
|
|
81
|
+
export interface LYDeleteResponse {
|
|
82
|
+
count: number;
|
|
83
|
+
}
|
|
84
|
+
type LYUploadFailedEvent = {
|
|
85
|
+
file: File;
|
|
86
|
+
error: Error;
|
|
87
|
+
fileId: string;
|
|
88
|
+
state: LYUploadState;
|
|
89
|
+
params: LYUploadParams;
|
|
90
|
+
failedChunkIndex: number;
|
|
91
|
+
uploadedChunks: number;
|
|
92
|
+
};
|
|
93
|
+
type LYDownloadFailedEvent = {
|
|
94
|
+
error: Error;
|
|
95
|
+
fileId: string;
|
|
96
|
+
fileName?: string;
|
|
97
|
+
blob?: Blob;
|
|
98
|
+
};
|
|
99
|
+
type LYUploadEvents = {
|
|
100
|
+
upload_failed(event: LYUploadFailedEvent): void;
|
|
101
|
+
download_failed(event: LYDownloadFailedEvent): void;
|
|
102
|
+
};
|
|
103
|
+
export interface LYDownloadResult {
|
|
104
|
+
blob: Blob;
|
|
105
|
+
fileName: string;
|
|
106
|
+
contentType: string;
|
|
107
|
+
totalSize: number;
|
|
108
|
+
}
|
|
109
|
+
export declare class LYAppHttpClient extends LYHttpClient {
|
|
110
|
+
on: LYEvents<LYUploadEvents>['on'];
|
|
111
|
+
off: LYEvents<LYUploadEvents>['on'];
|
|
112
|
+
once: LYEvents<LYUploadEvents>['on'];
|
|
113
|
+
addListener: LYEvents<LYUploadEvents>['on'];
|
|
114
|
+
removeListener: LYEvents<LYUploadEvents>['on'];
|
|
115
|
+
emit: LYEvents<LYUploadEvents>['emit'];
|
|
116
|
+
private _headerProvider;
|
|
117
|
+
constructor(app_name: string, headerProvider: IHeaderProvider);
|
|
118
|
+
protected _getUrl(url: string): string;
|
|
119
|
+
protected _get_headers(): Record<string, string> | undefined;
|
|
120
|
+
_request<T extends LYBaseResponse>(config?: LYHttpRequestConfig): Promise<LYResultResponse<T> | AxiosResponse<any> | undefined>;
|
|
121
|
+
/**
|
|
122
|
+
* 上传文件
|
|
123
|
+
*/
|
|
124
|
+
uploadFile(params: LYUploadParams, config?: LYHttpRequestConfig): Promise<LYResultResponse<LYUploadResponse>>;
|
|
125
|
+
/**
|
|
126
|
+
* 分块上传文件
|
|
127
|
+
*/
|
|
128
|
+
uploadFileInChunks(params: LYUploadParams, config?: LYHttpRequestConfig & {
|
|
129
|
+
chunkSize?: number;
|
|
130
|
+
onProgress?: (progress: number) => void;
|
|
131
|
+
startChunkIndex?: number;
|
|
132
|
+
}): Promise<LYUploadResponse>;
|
|
133
|
+
download(fileId: string, fileName?: string, config?: LYHttpRequestConfig & {
|
|
134
|
+
chunkSize?: number;
|
|
135
|
+
onProgress?: (progress: number) => void;
|
|
136
|
+
resumeFromByte?: number;
|
|
137
|
+
}): Promise<LYDownloadResult>;
|
|
138
|
+
downloadFile(fileId: string, fileName?: string, config?: LYHttpRequestConfig): Promise<void>;
|
|
139
|
+
/**
|
|
140
|
+
* SSE流式请求 - 字符串格式
|
|
141
|
+
* @param url 请求URL
|
|
142
|
+
* @param config SSE配置选项
|
|
143
|
+
* @returns AsyncGenerator<string>,生成原始字符串数据
|
|
144
|
+
*/
|
|
145
|
+
stream(url: string, config?: LYSSEConfig): AsyncGenerator<string>;
|
|
146
|
+
/**
|
|
147
|
+
* SSE流式请求 - Uint8Array格式
|
|
148
|
+
* @param url 请求URL
|
|
149
|
+
* @param config SSE配置选项
|
|
150
|
+
* @returns AsyncGenerator<Uint8Array>,生成字节数组数据
|
|
151
|
+
*/
|
|
152
|
+
stream(url: string, config?: LYSSEConfig): AsyncGenerator<Uint8Array>;
|
|
153
|
+
/**
|
|
154
|
+
* SSE流式请求 - JSON格式
|
|
155
|
+
* @param url 请求URL
|
|
156
|
+
* @param config SSE配置选项
|
|
157
|
+
* @returns AsyncGenerator<T>,生成JSON解析后的数据
|
|
158
|
+
*/
|
|
159
|
+
stream<T>(url: string, config?: LYSSEConfig): AsyncGenerator<T>;
|
|
160
|
+
/**
|
|
161
|
+
* 智能解析数据块
|
|
162
|
+
* 根据调用上下文的泛型类型自动选择解析方式
|
|
163
|
+
*/
|
|
164
|
+
private parseChunk;
|
|
165
|
+
}
|
|
166
|
+
export declare class LYTenantHttpClient extends LYAppHttpClient {
|
|
167
|
+
static getTenantName(): string;
|
|
168
|
+
protected _getUrl(url: string): string;
|
|
169
|
+
}
|
|
170
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function initialize(attrs: Record<string, string>): void;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { TOptions } from 'i18next';
|
|
2
|
+
import type { ILYEvents, LYEvents } from '../object';
|
|
3
|
+
import { LYObject } from '../object';
|
|
4
|
+
type LYTranslateOptions = TOptions;
|
|
5
|
+
export type LYTranslateMethod = (key: string, options?: LYTranslateOptions) => string;
|
|
6
|
+
type LYi18nEvents = {
|
|
7
|
+
['lang-changed'](lang: string): void;
|
|
8
|
+
};
|
|
9
|
+
export declare enum LYLangEnum {
|
|
10
|
+
'zh-CN' = "\u7B80\u4F53\u4E2D\u6587",
|
|
11
|
+
'en-US' = "English"
|
|
12
|
+
}
|
|
13
|
+
export type LYKeyofLang = keyof typeof LYLangEnum;
|
|
14
|
+
export declare const langKeys: LYKeyofLang[];
|
|
15
|
+
export declare const languages: Partial<Record<LYKeyofLang, string>>;
|
|
16
|
+
export interface ILYi18n extends ILYEvents<LYi18nEvents> {
|
|
17
|
+
readonly lang: LYKeyofLang;
|
|
18
|
+
readonly languages: Partial<Record<LYKeyofLang, string>>;
|
|
19
|
+
getUrlResource(url: string): Promise<Object | undefined>;
|
|
20
|
+
loadResource(urlOrJson: string | object, lang?: LYKeyofLang): Promise<void>;
|
|
21
|
+
changeLanguage(lang: LYKeyofLang): Promise<void>;
|
|
22
|
+
t: LYTranslateMethod;
|
|
23
|
+
}
|
|
24
|
+
export declare const LANG_KEY = "lang";
|
|
25
|
+
export declare class LYi18n extends LYObject implements ILYi18n {
|
|
26
|
+
on: LYEvents<LYi18nEvents>['on'];
|
|
27
|
+
off: LYEvents<LYi18nEvents>['on'];
|
|
28
|
+
once: LYEvents<LYi18nEvents>['on'];
|
|
29
|
+
emit: LYEvents<LYi18nEvents>['emit'];
|
|
30
|
+
private _namespace;
|
|
31
|
+
private _lang;
|
|
32
|
+
constructor(namespace?: string);
|
|
33
|
+
get t(): LYTranslateMethod;
|
|
34
|
+
get lang(): LYKeyofLang;
|
|
35
|
+
get languages(): Partial<Record<LYKeyofLang, string>>;
|
|
36
|
+
get namespace(): string;
|
|
37
|
+
initialize(): Promise<void>;
|
|
38
|
+
private fallbackLng;
|
|
39
|
+
/**
|
|
40
|
+
* 解析当前环境语言
|
|
41
|
+
* @returns 解析得到的语言
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
private resolveLanguage;
|
|
45
|
+
loadResource(urlOrJson: string | object, lang?: LYKeyofLang, namespace?: string): Promise<void>;
|
|
46
|
+
getUrlResource(resourceUrl: string): Promise<object | undefined>;
|
|
47
|
+
changeLanguage(lang: LYKeyofLang): Promise<void>;
|
|
48
|
+
getResource(key: string, lang?: string): Record<string, string>;
|
|
49
|
+
}
|
|
50
|
+
export {};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './logger';
|
|
2
|
+
export * from './object';
|
|
3
|
+
export * from './error';
|
|
4
|
+
export * from './env';
|
|
5
|
+
export * from './config';
|
|
6
|
+
export * from './constants';
|
|
7
|
+
export * from './observable';
|
|
8
|
+
export * from './storage';
|
|
9
|
+
export * from './http';
|
|
10
|
+
export * from './i18n';
|
|
11
|
+
export * from './app';
|
|
12
|
+
export * from './permission';
|
|
13
|
+
export * from './session';
|
|
14
|
+
export * from './crypto';
|