as-model 0.1.11 → 0.1.14
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/index.d.ts +28 -26
- package/package.json +1 -1
package/index.d.ts
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
1
|
declare interface ModelInstance {
|
|
2
|
-
[key: string]:
|
|
3
|
-
[key: number]:
|
|
2
|
+
[key: string]: any;
|
|
3
|
+
[key: number]: any;
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
+
declare type FieldStructure<R = any> = {
|
|
7
|
+
callback: () => R;
|
|
8
|
+
deps: any[] | undefined;
|
|
9
|
+
identifier: (d: any) => d is FieldStructure<R>;
|
|
10
|
+
value: R;
|
|
11
|
+
get: () => R;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
declare type MethodStructure<
|
|
15
|
+
R extends (...args: any[]) => any = (...args: any[]) => any
|
|
16
|
+
> = R & {
|
|
17
|
+
identifier: (d: any) => d is MethodStructure;
|
|
18
|
+
};
|
|
19
|
+
|
|
6
20
|
declare type ValidInstance<S, T extends ModelInstance> = {
|
|
7
|
-
[K in keyof T]: T[K] extends
|
|
21
|
+
[K in keyof T]: T[K] extends
|
|
22
|
+
| ((...args: any[]) => S)
|
|
23
|
+
| (((...args: any[]) => any) & { identifier: (d: any) => boolean })
|
|
8
24
|
? T[K]
|
|
9
|
-
: T[K] extends (...args:
|
|
25
|
+
: T[K] extends (...args: any[]) => any
|
|
10
26
|
? never
|
|
11
27
|
: T[K];
|
|
12
28
|
};
|
|
@@ -25,7 +41,7 @@ export declare type Action<S = any, T extends ModelInstance = ModelInstance> = {
|
|
|
25
41
|
prevInstance?: T;
|
|
26
42
|
};
|
|
27
43
|
|
|
28
|
-
declare type Dispatch = (action: Action) =>
|
|
44
|
+
declare type Dispatch = (action: Action) => any;
|
|
29
45
|
|
|
30
46
|
export declare interface Key<
|
|
31
47
|
S = any,
|
|
@@ -78,7 +94,7 @@ export declare interface Store<
|
|
|
78
94
|
> extends StoreIndex<S, T, R> {
|
|
79
95
|
subscribe: (dispatcher: Dispatch) => () => void;
|
|
80
96
|
getInstance: () => T;
|
|
81
|
-
update: (args?: { model?: Model<S, T>; state?: S }) => void;
|
|
97
|
+
update: (args?: { model?: Model<S, T>; initialState?: S; state?: S }) => void;
|
|
82
98
|
destroy: () => void;
|
|
83
99
|
payload: <P>(
|
|
84
100
|
callback?: (payload: P | undefined) => P | undefined
|
|
@@ -152,20 +168,6 @@ export declare interface ModelUsage<
|
|
|
152
168
|
extends: <E extends Record<string, any>>(e: E) => ModelUsage<S, T, R> & E;
|
|
153
169
|
}
|
|
154
170
|
|
|
155
|
-
declare type FieldStructure<R = any> = {
|
|
156
|
-
callback: () => R;
|
|
157
|
-
deps: unknown[] | undefined;
|
|
158
|
-
identifier: (d: unknown) => d is FieldStructure<R>;
|
|
159
|
-
value: R;
|
|
160
|
-
get: () => R;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
declare type MethodStructure<
|
|
164
|
-
R extends (...args: any[]) => any = (...args: any[]) => any
|
|
165
|
-
> = R & {
|
|
166
|
-
identifier: (d: unknown) => d is MethodStructure;
|
|
167
|
-
};
|
|
168
|
-
|
|
169
171
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
170
172
|
export declare interface model {
|
|
171
173
|
<
|
|
@@ -178,7 +180,7 @@ export declare interface model {
|
|
|
178
180
|
): ModelUsage<S, T, R>;
|
|
179
181
|
createField: <P extends () => any>(
|
|
180
182
|
callback: P,
|
|
181
|
-
deps?:
|
|
183
|
+
deps?: any[]
|
|
182
184
|
) => FieldStructure<ReturnType<P>>;
|
|
183
185
|
createMethod: <P extends (...args: any[]) => any = (...args: any[]) => any>(
|
|
184
186
|
method: P
|
|
@@ -268,29 +270,29 @@ export declare function config(configuration: Config): {
|
|
|
268
270
|
|
|
269
271
|
/** validations * */
|
|
270
272
|
export declare const validations: {
|
|
271
|
-
isInstanceFromNoStateModel: (instance:
|
|
273
|
+
isInstanceFromNoStateModel: (instance: any) => boolean;
|
|
272
274
|
isModelKey: <
|
|
273
275
|
S,
|
|
274
276
|
T extends ModelInstance,
|
|
275
277
|
R extends (ins: () => T) => any = (ins: () => T) => T
|
|
276
278
|
>(
|
|
277
|
-
data:
|
|
279
|
+
data: any
|
|
278
280
|
) => data is ModelKey<S, T, R>;
|
|
279
281
|
isModelStore: <
|
|
280
282
|
S,
|
|
281
283
|
T extends ModelInstance,
|
|
282
284
|
R extends (ins: () => T) => any = (ins: () => T) => T
|
|
283
285
|
>(
|
|
284
|
-
data:
|
|
286
|
+
data: any
|
|
285
287
|
) => data is Store<S, T, R>;
|
|
286
288
|
isModelUsage: <
|
|
287
289
|
S,
|
|
288
290
|
T extends ModelInstance,
|
|
289
291
|
R extends (ins: () => T) => any = (ins: () => T) => T
|
|
290
292
|
>(
|
|
291
|
-
data:
|
|
293
|
+
data: any
|
|
292
294
|
) => data is ModelUsage<S, T, R>;
|
|
293
295
|
};
|
|
294
296
|
|
|
295
297
|
/** tools * */
|
|
296
|
-
export declare function shallowEqual(prev:
|
|
298
|
+
export declare function shallowEqual(prev: any, current: any): boolean;
|