@flowlist/js-core 4.0.5-beta.0 → 4.0.7-beta.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/index.d.mts +65 -52
- package/dist/index.d.ts +65 -52
- package/dist/index.global.js +172 -100
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +172 -100
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +172 -100
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -39,7 +39,6 @@ interface RequestParams {
|
|
|
39
39
|
[key: string]: any;
|
|
40
40
|
__refresh__?: boolean;
|
|
41
41
|
__reload__?: boolean;
|
|
42
|
-
is_up?: 0 | 1 | boolean;
|
|
43
42
|
page?: number;
|
|
44
43
|
sinceId?: ObjectKey;
|
|
45
44
|
}
|
|
@@ -58,6 +57,7 @@ interface ApiContract<TParams extends RequestParams, TResponse> {
|
|
|
58
57
|
*/
|
|
59
58
|
readonly id: string;
|
|
60
59
|
readonly type: FetchType;
|
|
60
|
+
readonly is_up: boolean;
|
|
61
61
|
readonly uniqueKey: string;
|
|
62
62
|
readonly paramsIgnore: string[];
|
|
63
63
|
}
|
|
@@ -94,6 +94,7 @@ interface GenerateParamsResp extends RequestParams {
|
|
|
94
94
|
interface GenerateParamsType {
|
|
95
95
|
readonly field: DefaultField;
|
|
96
96
|
readonly uniqueKey?: string;
|
|
97
|
+
readonly is_up?: boolean;
|
|
97
98
|
readonly query?: KeyMap;
|
|
98
99
|
readonly type: FetchType;
|
|
99
100
|
}
|
|
@@ -105,78 +106,90 @@ type FetchResultCallback<TParams, TResponse> = (obj: {
|
|
|
105
106
|
data: BaseApiResponse<TResponse>;
|
|
106
107
|
refresh: boolean;
|
|
107
108
|
}) => void;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
interface SetDataType {
|
|
110
|
+
readonly getter: FieldGetter;
|
|
111
|
+
readonly setter: FieldSetter;
|
|
112
|
+
readonly data: BaseApiResponse;
|
|
113
|
+
readonly fieldName: string;
|
|
114
|
+
readonly type: FetchType;
|
|
115
|
+
readonly page: number;
|
|
116
|
+
readonly insertBefore: boolean;
|
|
117
|
+
}
|
|
118
|
+
interface SetErrorType {
|
|
119
|
+
readonly setter: FieldSetter;
|
|
120
|
+
readonly fieldName: string;
|
|
121
|
+
readonly error: Error | null;
|
|
116
122
|
}
|
|
117
123
|
/**
|
|
118
|
-
*
|
|
124
|
+
* 初始化状态的外部参数
|
|
119
125
|
*/
|
|
120
|
-
interface
|
|
121
|
-
|
|
126
|
+
interface InitStateParams<P extends RequestParams = RequestParams, R = any> {
|
|
127
|
+
readonly func: ApiContract<P, R>;
|
|
128
|
+
readonly query?: P;
|
|
129
|
+
readonly opts?: Partial<DefaultField<R>>;
|
|
122
130
|
}
|
|
123
131
|
/**
|
|
124
|
-
*
|
|
132
|
+
* 初始化数据的外部参数
|
|
125
133
|
*/
|
|
126
|
-
interface
|
|
127
|
-
|
|
134
|
+
interface InitDataParams<P extends RequestParams = RequestParams, R = any> {
|
|
135
|
+
readonly func: ApiContract<P, R>;
|
|
136
|
+
readonly query?: P;
|
|
137
|
+
readonly callback?: FetchResultCallback<P, R>;
|
|
128
138
|
}
|
|
129
139
|
/**
|
|
130
|
-
*
|
|
140
|
+
* 加载更多的外部参数
|
|
131
141
|
*/
|
|
132
|
-
interface
|
|
133
|
-
|
|
134
|
-
|
|
142
|
+
interface LoadMoreParams<P extends RequestParams = RequestParams, R = any> {
|
|
143
|
+
readonly func: ApiContract<P, R>;
|
|
144
|
+
readonly query?: P;
|
|
145
|
+
readonly errorRetry?: boolean;
|
|
146
|
+
readonly callback?: FetchResultCallback<P, R>;
|
|
135
147
|
}
|
|
136
148
|
/**
|
|
137
|
-
*
|
|
138
|
-
* 这里的 TValue 尝试对更新的值进行约束
|
|
149
|
+
* 更新状态的外部参数
|
|
139
150
|
*/
|
|
140
|
-
interface
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
changeKey?: string;
|
|
151
|
+
interface UpdateStateParams<P extends RequestParams = RequestParams, R = any> {
|
|
152
|
+
readonly func: ApiContract<P, R>;
|
|
153
|
+
readonly query?: P;
|
|
154
|
+
readonly method: string;
|
|
155
|
+
readonly value: any;
|
|
156
|
+
readonly id?: ObjectKey | ObjectKey[];
|
|
157
|
+
readonly changeKey?: string;
|
|
158
|
+
readonly uniqueKey?: string;
|
|
149
159
|
}
|
|
150
|
-
interface
|
|
160
|
+
interface InitStateType<P extends RequestParams, R> extends InitStateParams<P, R> {
|
|
151
161
|
readonly getter: FieldGetter;
|
|
152
162
|
readonly setter: FieldSetter;
|
|
153
|
-
readonly data: BaseApiResponse;
|
|
154
|
-
readonly fieldName: string;
|
|
155
|
-
readonly type: FetchType;
|
|
156
|
-
readonly page: number;
|
|
157
|
-
readonly insertBefore: boolean;
|
|
158
163
|
}
|
|
159
|
-
interface
|
|
164
|
+
interface InitDataType<P extends RequestParams, R> extends InitDataParams<P, R> {
|
|
165
|
+
readonly getter: FieldGetter;
|
|
166
|
+
readonly setter: FieldSetter;
|
|
167
|
+
}
|
|
168
|
+
interface LoadMoreType<P extends RequestParams, R> extends LoadMoreParams<P, R> {
|
|
169
|
+
readonly getter: FieldGetter;
|
|
170
|
+
readonly setter: FieldSetter;
|
|
171
|
+
}
|
|
172
|
+
interface UpdateStateType<P extends RequestParams, R> extends UpdateStateParams<P, R> {
|
|
173
|
+
readonly getter: FieldGetter;
|
|
160
174
|
readonly setter: FieldSetter;
|
|
161
|
-
readonly fieldName: string;
|
|
162
|
-
readonly error: Error | null;
|
|
163
175
|
}
|
|
164
176
|
|
|
165
|
-
declare const initState: <P extends RequestParams, R>({ getter, setter, func, query, opts }: InitStateType<P, R>) => Promise<void>;
|
|
166
|
-
declare const initData: <P extends RequestParams, R>({ getter, setter, func, query, callback }: InitDataType<P, R>) => Promise<void>;
|
|
167
|
-
declare const loadMore: <P extends RequestParams, R>({ getter, setter, query, func, errorRetry, callback }: LoadMoreType<P, R>) => Promise<void>;
|
|
168
|
-
declare const updateState: <P extends RequestParams, R>({ getter, setter, func, query, method, id, value, changeKey }: UpdateStateType<P, R>) => Promise<unknown>;
|
|
169
|
-
declare const createApi: <TParams extends RequestParams, TResponse>(options: {
|
|
170
|
-
id: string;
|
|
171
|
-
type?: FetchType;
|
|
172
|
-
uniqueKey?: string;
|
|
173
|
-
paramsIgnore?: string[];
|
|
174
|
-
fetcher: (params: TParams) => Promise<BaseApiResponse<TResponse>>;
|
|
175
|
-
}) => ApiContract<TParams, TResponse>;
|
|
176
177
|
declare const generateFieldName$1: <P extends RequestParams, R>({ func, query }: {
|
|
177
178
|
func: ApiContract<P, R>;
|
|
178
179
|
query?: P;
|
|
179
180
|
}) => string;
|
|
181
|
+
declare const createApi: <P extends RequestParams, R>(options: {
|
|
182
|
+
id: string;
|
|
183
|
+
type?: FetchType;
|
|
184
|
+
uniqueKey?: string;
|
|
185
|
+
is_up?: boolean;
|
|
186
|
+
paramsIgnore?: string[];
|
|
187
|
+
fetcher: (params: P) => Promise<BaseApiResponse<R>>;
|
|
188
|
+
}) => ApiContract<P, R>;
|
|
189
|
+
declare const initState: <P extends RequestParams, R>({ getter, setter, func, query, opts }: InitStateType<P, R>) => Promise<void>;
|
|
190
|
+
declare const initData: <P extends RequestParams, R>({ getter, setter, func, query, callback }: InitDataType<P, R>) => Promise<void>;
|
|
191
|
+
declare const loadMore: <P extends RequestParams, R>({ getter, setter, query, func, errorRetry, callback }: LoadMoreType<P, R>) => Promise<void>;
|
|
192
|
+
declare const updateState: <P extends RequestParams, R>({ getter, setter, func, query, method, id, value, changeKey }: UpdateStateType<P, R>) => Promise<unknown>;
|
|
180
193
|
|
|
181
194
|
declare const isArray: (data: unknown) => data is any[];
|
|
182
195
|
/**
|
|
@@ -213,7 +226,7 @@ declare const computeMatchedItemIndex: (itemId: ObjectKey, fieldArr: any[], chan
|
|
|
213
226
|
declare const combineArrayData: (fieldArray: any[], value: any[] | Record<ObjectKey, KeyMap>, changingKey: string) => void;
|
|
214
227
|
declare const setReactivityField: (field: DefaultField, key: FieldKeys, value: unknown, type: FetchType, insertBefore: boolean) => void;
|
|
215
228
|
declare const computeResultLength: (data: unknown) => number;
|
|
216
|
-
declare const generateRequestParams: ({ field, uniqueKey, query, type }: GenerateParamsType) => GenerateParamsResp;
|
|
229
|
+
declare const generateRequestParams: ({ field, uniqueKey, query, is_up, type }: GenerateParamsType) => GenerateParamsResp;
|
|
217
230
|
declare const toObjectKey: (id: ObjectKey | ObjectKey[] | undefined) => ObjectKey | undefined;
|
|
218
231
|
declare const getResultAsArray: (field: DefaultField) => any[] | null;
|
|
219
232
|
declare const updateArrayItem: (arr: any[], index: number, updater: (item: KeyMap) => KeyMap) => void;
|
|
@@ -275,4 +288,4 @@ declare const _default: {
|
|
|
275
288
|
readonly DEFAULT_UNIQUE_KEY_NAME: "id";
|
|
276
289
|
};
|
|
277
290
|
|
|
278
|
-
export { type ApiContract, type BaseApiResponse, type DefaultField, _default as ENUM, type FetchResultCallback, type FetchType, type FieldGetter, type FieldKeys, type FieldSetter, type GenerateParamsResp, type GenerateParamsType, type InitDataType, type InitStateType, type KeyMap, type LoadMoreType, type ObjectKey, type RequestParams, type SetDataType, type SetErrorType, type SetterFuncParams, type UpdateStateType, createApi, generateFieldName$1 as generateFieldName, initData, initState, loadMore, updateState, utils };
|
|
291
|
+
export { type ApiContract, type BaseApiResponse, type DefaultField, _default as ENUM, type FetchResultCallback, type FetchType, type FieldGetter, type FieldKeys, type FieldSetter, type GenerateParamsResp, type GenerateParamsType, type InitDataParams, type InitDataType, type InitStateParams, type InitStateType, type KeyMap, type LoadMoreParams, type LoadMoreType, type ObjectKey, type RequestParams, type SetDataType, type SetErrorType, type SetterFuncParams, type UpdateStateParams, type UpdateStateType, createApi, generateFieldName$1 as generateFieldName, initData, initState, loadMore, updateState, utils };
|
package/dist/index.d.ts
CHANGED
|
@@ -39,7 +39,6 @@ interface RequestParams {
|
|
|
39
39
|
[key: string]: any;
|
|
40
40
|
__refresh__?: boolean;
|
|
41
41
|
__reload__?: boolean;
|
|
42
|
-
is_up?: 0 | 1 | boolean;
|
|
43
42
|
page?: number;
|
|
44
43
|
sinceId?: ObjectKey;
|
|
45
44
|
}
|
|
@@ -58,6 +57,7 @@ interface ApiContract<TParams extends RequestParams, TResponse> {
|
|
|
58
57
|
*/
|
|
59
58
|
readonly id: string;
|
|
60
59
|
readonly type: FetchType;
|
|
60
|
+
readonly is_up: boolean;
|
|
61
61
|
readonly uniqueKey: string;
|
|
62
62
|
readonly paramsIgnore: string[];
|
|
63
63
|
}
|
|
@@ -94,6 +94,7 @@ interface GenerateParamsResp extends RequestParams {
|
|
|
94
94
|
interface GenerateParamsType {
|
|
95
95
|
readonly field: DefaultField;
|
|
96
96
|
readonly uniqueKey?: string;
|
|
97
|
+
readonly is_up?: boolean;
|
|
97
98
|
readonly query?: KeyMap;
|
|
98
99
|
readonly type: FetchType;
|
|
99
100
|
}
|
|
@@ -105,78 +106,90 @@ type FetchResultCallback<TParams, TResponse> = (obj: {
|
|
|
105
106
|
data: BaseApiResponse<TResponse>;
|
|
106
107
|
refresh: boolean;
|
|
107
108
|
}) => void;
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
109
|
+
interface SetDataType {
|
|
110
|
+
readonly getter: FieldGetter;
|
|
111
|
+
readonly setter: FieldSetter;
|
|
112
|
+
readonly data: BaseApiResponse;
|
|
113
|
+
readonly fieldName: string;
|
|
114
|
+
readonly type: FetchType;
|
|
115
|
+
readonly page: number;
|
|
116
|
+
readonly insertBefore: boolean;
|
|
117
|
+
}
|
|
118
|
+
interface SetErrorType {
|
|
119
|
+
readonly setter: FieldSetter;
|
|
120
|
+
readonly fieldName: string;
|
|
121
|
+
readonly error: Error | null;
|
|
116
122
|
}
|
|
117
123
|
/**
|
|
118
|
-
*
|
|
124
|
+
* 初始化状态的外部参数
|
|
119
125
|
*/
|
|
120
|
-
interface
|
|
121
|
-
|
|
126
|
+
interface InitStateParams<P extends RequestParams = RequestParams, R = any> {
|
|
127
|
+
readonly func: ApiContract<P, R>;
|
|
128
|
+
readonly query?: P;
|
|
129
|
+
readonly opts?: Partial<DefaultField<R>>;
|
|
122
130
|
}
|
|
123
131
|
/**
|
|
124
|
-
*
|
|
132
|
+
* 初始化数据的外部参数
|
|
125
133
|
*/
|
|
126
|
-
interface
|
|
127
|
-
|
|
134
|
+
interface InitDataParams<P extends RequestParams = RequestParams, R = any> {
|
|
135
|
+
readonly func: ApiContract<P, R>;
|
|
136
|
+
readonly query?: P;
|
|
137
|
+
readonly callback?: FetchResultCallback<P, R>;
|
|
128
138
|
}
|
|
129
139
|
/**
|
|
130
|
-
*
|
|
140
|
+
* 加载更多的外部参数
|
|
131
141
|
*/
|
|
132
|
-
interface
|
|
133
|
-
|
|
134
|
-
|
|
142
|
+
interface LoadMoreParams<P extends RequestParams = RequestParams, R = any> {
|
|
143
|
+
readonly func: ApiContract<P, R>;
|
|
144
|
+
readonly query?: P;
|
|
145
|
+
readonly errorRetry?: boolean;
|
|
146
|
+
readonly callback?: FetchResultCallback<P, R>;
|
|
135
147
|
}
|
|
136
148
|
/**
|
|
137
|
-
*
|
|
138
|
-
* 这里的 TValue 尝试对更新的值进行约束
|
|
149
|
+
* 更新状态的外部参数
|
|
139
150
|
*/
|
|
140
|
-
interface
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
changeKey?: string;
|
|
151
|
+
interface UpdateStateParams<P extends RequestParams = RequestParams, R = any> {
|
|
152
|
+
readonly func: ApiContract<P, R>;
|
|
153
|
+
readonly query?: P;
|
|
154
|
+
readonly method: string;
|
|
155
|
+
readonly value: any;
|
|
156
|
+
readonly id?: ObjectKey | ObjectKey[];
|
|
157
|
+
readonly changeKey?: string;
|
|
158
|
+
readonly uniqueKey?: string;
|
|
149
159
|
}
|
|
150
|
-
interface
|
|
160
|
+
interface InitStateType<P extends RequestParams, R> extends InitStateParams<P, R> {
|
|
151
161
|
readonly getter: FieldGetter;
|
|
152
162
|
readonly setter: FieldSetter;
|
|
153
|
-
readonly data: BaseApiResponse;
|
|
154
|
-
readonly fieldName: string;
|
|
155
|
-
readonly type: FetchType;
|
|
156
|
-
readonly page: number;
|
|
157
|
-
readonly insertBefore: boolean;
|
|
158
163
|
}
|
|
159
|
-
interface
|
|
164
|
+
interface InitDataType<P extends RequestParams, R> extends InitDataParams<P, R> {
|
|
165
|
+
readonly getter: FieldGetter;
|
|
166
|
+
readonly setter: FieldSetter;
|
|
167
|
+
}
|
|
168
|
+
interface LoadMoreType<P extends RequestParams, R> extends LoadMoreParams<P, R> {
|
|
169
|
+
readonly getter: FieldGetter;
|
|
170
|
+
readonly setter: FieldSetter;
|
|
171
|
+
}
|
|
172
|
+
interface UpdateStateType<P extends RequestParams, R> extends UpdateStateParams<P, R> {
|
|
173
|
+
readonly getter: FieldGetter;
|
|
160
174
|
readonly setter: FieldSetter;
|
|
161
|
-
readonly fieldName: string;
|
|
162
|
-
readonly error: Error | null;
|
|
163
175
|
}
|
|
164
176
|
|
|
165
|
-
declare const initState: <P extends RequestParams, R>({ getter, setter, func, query, opts }: InitStateType<P, R>) => Promise<void>;
|
|
166
|
-
declare const initData: <P extends RequestParams, R>({ getter, setter, func, query, callback }: InitDataType<P, R>) => Promise<void>;
|
|
167
|
-
declare const loadMore: <P extends RequestParams, R>({ getter, setter, query, func, errorRetry, callback }: LoadMoreType<P, R>) => Promise<void>;
|
|
168
|
-
declare const updateState: <P extends RequestParams, R>({ getter, setter, func, query, method, id, value, changeKey }: UpdateStateType<P, R>) => Promise<unknown>;
|
|
169
|
-
declare const createApi: <TParams extends RequestParams, TResponse>(options: {
|
|
170
|
-
id: string;
|
|
171
|
-
type?: FetchType;
|
|
172
|
-
uniqueKey?: string;
|
|
173
|
-
paramsIgnore?: string[];
|
|
174
|
-
fetcher: (params: TParams) => Promise<BaseApiResponse<TResponse>>;
|
|
175
|
-
}) => ApiContract<TParams, TResponse>;
|
|
176
177
|
declare const generateFieldName$1: <P extends RequestParams, R>({ func, query }: {
|
|
177
178
|
func: ApiContract<P, R>;
|
|
178
179
|
query?: P;
|
|
179
180
|
}) => string;
|
|
181
|
+
declare const createApi: <P extends RequestParams, R>(options: {
|
|
182
|
+
id: string;
|
|
183
|
+
type?: FetchType;
|
|
184
|
+
uniqueKey?: string;
|
|
185
|
+
is_up?: boolean;
|
|
186
|
+
paramsIgnore?: string[];
|
|
187
|
+
fetcher: (params: P) => Promise<BaseApiResponse<R>>;
|
|
188
|
+
}) => ApiContract<P, R>;
|
|
189
|
+
declare const initState: <P extends RequestParams, R>({ getter, setter, func, query, opts }: InitStateType<P, R>) => Promise<void>;
|
|
190
|
+
declare const initData: <P extends RequestParams, R>({ getter, setter, func, query, callback }: InitDataType<P, R>) => Promise<void>;
|
|
191
|
+
declare const loadMore: <P extends RequestParams, R>({ getter, setter, query, func, errorRetry, callback }: LoadMoreType<P, R>) => Promise<void>;
|
|
192
|
+
declare const updateState: <P extends RequestParams, R>({ getter, setter, func, query, method, id, value, changeKey }: UpdateStateType<P, R>) => Promise<unknown>;
|
|
180
193
|
|
|
181
194
|
declare const isArray: (data: unknown) => data is any[];
|
|
182
195
|
/**
|
|
@@ -213,7 +226,7 @@ declare const computeMatchedItemIndex: (itemId: ObjectKey, fieldArr: any[], chan
|
|
|
213
226
|
declare const combineArrayData: (fieldArray: any[], value: any[] | Record<ObjectKey, KeyMap>, changingKey: string) => void;
|
|
214
227
|
declare const setReactivityField: (field: DefaultField, key: FieldKeys, value: unknown, type: FetchType, insertBefore: boolean) => void;
|
|
215
228
|
declare const computeResultLength: (data: unknown) => number;
|
|
216
|
-
declare const generateRequestParams: ({ field, uniqueKey, query, type }: GenerateParamsType) => GenerateParamsResp;
|
|
229
|
+
declare const generateRequestParams: ({ field, uniqueKey, query, is_up, type }: GenerateParamsType) => GenerateParamsResp;
|
|
217
230
|
declare const toObjectKey: (id: ObjectKey | ObjectKey[] | undefined) => ObjectKey | undefined;
|
|
218
231
|
declare const getResultAsArray: (field: DefaultField) => any[] | null;
|
|
219
232
|
declare const updateArrayItem: (arr: any[], index: number, updater: (item: KeyMap) => KeyMap) => void;
|
|
@@ -275,4 +288,4 @@ declare const _default: {
|
|
|
275
288
|
readonly DEFAULT_UNIQUE_KEY_NAME: "id";
|
|
276
289
|
};
|
|
277
290
|
|
|
278
|
-
export { type ApiContract, type BaseApiResponse, type DefaultField, _default as ENUM, type FetchResultCallback, type FetchType, type FieldGetter, type FieldKeys, type FieldSetter, type GenerateParamsResp, type GenerateParamsType, type InitDataType, type InitStateType, type KeyMap, type LoadMoreType, type ObjectKey, type RequestParams, type SetDataType, type SetErrorType, type SetterFuncParams, type UpdateStateType, createApi, generateFieldName$1 as generateFieldName, initData, initState, loadMore, updateState, utils };
|
|
291
|
+
export { type ApiContract, type BaseApiResponse, type DefaultField, _default as ENUM, type FetchResultCallback, type FetchType, type FieldGetter, type FieldKeys, type FieldSetter, type GenerateParamsResp, type GenerateParamsType, type InitDataParams, type InitDataType, type InitStateParams, type InitStateType, type KeyMap, type LoadMoreParams, type LoadMoreType, type ObjectKey, type RequestParams, type SetDataType, type SetErrorType, type SetterFuncParams, type UpdateStateParams, type UpdateStateType, createApi, generateFieldName$1 as generateFieldName, initData, initState, loadMore, updateState, utils };
|