akanjs 2.3.5-rc.0 → 2.3.5-rc.2
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/fetch/fetchType/buildFetch.type.ts +8 -2
- package/fetch/fetchType/endpointFetch.type.ts +84 -49
- package/fetch/fetchType/sliceFetch.type.ts +130 -76
- package/fetch/types.ts +4 -17
- package/package.json +1 -1
- package/types/fetch/fetchType/buildFetch.type.d.ts +3 -2
- package/types/fetch/fetchType/endpointFetch.type.d.ts +34 -16
- package/types/fetch/fetchType/sliceFetch.type.d.ts +53 -30
- package/types/fetch/types.d.ts +2 -9
- package/ui/More.tsx +1 -3
|
@@ -18,10 +18,16 @@ export type FetchProxySignalInput<
|
|
|
18
18
|
|
|
19
19
|
export type FetchSignalInput = FetchProxySignalInput | DatabaseSignal | ServiceSignal;
|
|
20
20
|
|
|
21
|
+
type MergeFetchParts<First, Second> = [First] extends [never]
|
|
22
|
+
? Second
|
|
23
|
+
: [Second] extends [never]
|
|
24
|
+
? First
|
|
25
|
+
: Assign<First, Second>;
|
|
26
|
+
|
|
21
27
|
export type FetchTypeOfSignal<Signal extends FetchSignalInput> = Signal extends { _FetchType: infer FetchType }
|
|
22
28
|
? FetchType
|
|
23
29
|
: Signal extends DatabaseSignal<infer _IntlCls, infer EndpCls, infer SlceCls, infer _SrvrCls>
|
|
24
|
-
? GetFetchTypeFromEndpoint<EndpCls, SlceCls
|
|
30
|
+
? MergeFetchParts<GetFetchTypeFromEndpoint<EndpCls, SlceCls>, GetFetchTypeFromSlice<SlceCls>>
|
|
25
31
|
: Signal extends ServiceSignal<infer _IntlCls, infer EndpCls, infer _SrvrCls>
|
|
26
32
|
? GetFetchTypeFromEndpoint<EndpCls>
|
|
27
33
|
: unknown;
|
|
@@ -41,7 +47,7 @@ type MergeDirectFetchTypes<
|
|
|
41
47
|
> = Signals extends readonly [infer First extends FetchSignalInput, ...infer Rest extends readonly FetchSignalInput[]]
|
|
42
48
|
? First extends { _FetchType: unknown }
|
|
43
49
|
? MergeDirectFetchTypes<Rest, Acc>
|
|
44
|
-
: MergeDirectFetchTypes<Rest,
|
|
50
|
+
: MergeDirectFetchTypes<Rest, MergeFetchParts<Acc, FetchTypeOfSignal<First>>>
|
|
45
51
|
: Acc;
|
|
46
52
|
|
|
47
53
|
export type MergeAllFetchTypes<Signals extends readonly FetchSignalInput[]> =
|
|
@@ -10,81 +10,116 @@ import type {
|
|
|
10
10
|
SliceCls,
|
|
11
11
|
} from "akanjs/signal";
|
|
12
12
|
|
|
13
|
-
type
|
|
14
|
-
|
|
15
|
-
:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
export type EndpointReturnContext<Full = unknown, Light = unknown, Insight = unknown> = {
|
|
14
|
+
full: Full;
|
|
15
|
+
light: Light;
|
|
16
|
+
insight: Insight;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
type EndpointReturnContextOf<SlceCls extends SliceCls | never> = [SlceCls] extends [never]
|
|
20
|
+
? never
|
|
21
|
+
: SlceCls extends SliceCls
|
|
22
|
+
? EndpointReturnContext<
|
|
23
|
+
SlceCls["srv"]["cnst"]["_Full"],
|
|
24
|
+
SlceCls["srv"]["cnst"]["_Light"],
|
|
25
|
+
SlceCls["srv"]["cnst"]["_Insight"]
|
|
26
|
+
>
|
|
27
|
+
: never;
|
|
28
|
+
|
|
29
|
+
type ExtendedEndpointReturn<ClientReturns, Context> = ClientReturns extends (infer R)[]
|
|
30
|
+
? ExtendedEndpointReturn<R, Context>[]
|
|
31
|
+
: Context extends EndpointReturnContext<infer Full, infer Light, infer Insight>
|
|
32
|
+
? Full extends ClientReturns
|
|
33
|
+
? Full
|
|
34
|
+
: Light extends ClientReturns
|
|
35
|
+
? Light
|
|
36
|
+
: Insight extends ClientReturns
|
|
37
|
+
? Insight
|
|
38
|
+
: ClientReturns
|
|
39
|
+
: ClientReturns;
|
|
40
|
+
|
|
41
|
+
type EndpointClientReturns<E, Context> = [Context] extends [never]
|
|
24
42
|
? EndpInfoClientReturns<E>
|
|
25
|
-
: ExtendedEndpointReturn<
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
SlceCls["srv"]["cnst"]["_Insight"]
|
|
30
|
-
>;
|
|
31
|
-
|
|
32
|
-
type EndpInfoReturns<E, SlceCls extends SliceCls | never> =
|
|
33
|
-
| EndpointClientReturns<E, SlceCls>
|
|
43
|
+
: ExtendedEndpointReturn<EndpInfoClientReturns<E>, Context>;
|
|
44
|
+
|
|
45
|
+
type EndpInfoReturns<E, Context> =
|
|
46
|
+
| EndpointClientReturns<E, Context>
|
|
34
47
|
| (EndpInfoNullable<E> extends true ? null : never);
|
|
35
48
|
|
|
36
|
-
type QueryOrMutationFetchFn<E,
|
|
49
|
+
type QueryOrMutationFetchFn<E, Context> = (
|
|
37
50
|
...args: [...EndpInfoArgs<E>, fetchPolicy?: FetchPolicy]
|
|
38
|
-
) => Promise<EndpInfoReturns<E,
|
|
51
|
+
) => Promise<EndpInfoReturns<E, Context>>;
|
|
39
52
|
|
|
40
|
-
type MessageEmitFn<E,
|
|
53
|
+
type MessageEmitFn<E, Context> = (...args: EndpInfoArgs<E>) => EndpInfoReturns<E, Context>;
|
|
41
54
|
|
|
42
|
-
type MessageListenFn<E,
|
|
43
|
-
handleEvent: (data: EndpInfoReturns<E,
|
|
55
|
+
type MessageListenFn<E, Context> = (
|
|
56
|
+
handleEvent: (data: EndpInfoReturns<E, Context>) => PromiseOrObject<void>,
|
|
44
57
|
options?: FetchPolicy,
|
|
45
58
|
) => () => void;
|
|
46
59
|
|
|
47
|
-
type PubsubSubscribeFn<E,
|
|
60
|
+
type PubsubSubscribeFn<E, Context> = (
|
|
48
61
|
...args: [
|
|
49
62
|
...EndpInfoArgs<E>,
|
|
50
|
-
handleEvent: (data: EndpInfoReturns<E,
|
|
63
|
+
handleEvent: (data: EndpInfoReturns<E, Context>) => PromiseOrObject<void>,
|
|
51
64
|
options?: FetchPolicy,
|
|
52
65
|
]
|
|
53
66
|
) => () => void;
|
|
54
67
|
|
|
55
|
-
type PrimaryFetchFn<E,
|
|
56
|
-
|
|
57
|
-
? QueryOrMutationFetchFn<E,
|
|
58
|
-
:
|
|
59
|
-
? MessageEmitFn<E,
|
|
68
|
+
type PrimaryFetchFn<E, Context, ReqType = EndpInfoReqType<E>> =
|
|
69
|
+
ReqType extends "query" | "mutation"
|
|
70
|
+
? QueryOrMutationFetchFn<E, Context>
|
|
71
|
+
: ReqType extends "message"
|
|
72
|
+
? MessageEmitFn<E, Context>
|
|
60
73
|
: never;
|
|
61
74
|
|
|
62
|
-
type
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
75
|
+
type UploadLikeArg = FileList | File | File[];
|
|
76
|
+
type HasUploadLikeArg<Args extends readonly unknown[]> = Extract<Args[number], UploadLikeArg> extends never ? false : true;
|
|
77
|
+
type RestApiArg<Arg> = Arg extends FileList ? FileList : Arg extends File | File[] ? FileList : Arg;
|
|
78
|
+
type RestApiArgs<Args extends readonly unknown[]> = {
|
|
79
|
+
[K in keyof Args]: RestApiArg<Args[K]>;
|
|
80
|
+
};
|
|
81
|
+
type UploadRestApiFetchFn<E, Context> = (
|
|
82
|
+
...args: [...RestApiArgs<EndpInfoArgs<E>>, fetchPolicy?: FetchPolicy]
|
|
83
|
+
) => Promise<EndpInfoReturns<E, Context>>;
|
|
84
|
+
|
|
85
|
+
type PrimaryFetchType<EInfoObj extends { [key: string]: EndpointInfo }, Context> = {
|
|
86
|
+
[K in keyof EInfoObj as Extract<EndpInfoReqType<EInfoObj[K]>, "query" | "mutation" | "message"> extends never
|
|
87
|
+
? never
|
|
88
|
+
: K]: PrimaryFetchFn<EInfoObj[K], Context>;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
type UploadRestApiFetchType<EInfoObj extends { [key: string]: EndpointInfo }, Context> = {
|
|
92
|
+
[K in keyof EInfoObj as Extract<EndpInfoReqType<EInfoObj[K]>, "mutation"> extends never
|
|
93
|
+
? never
|
|
94
|
+
: HasUploadLikeArg<EndpInfoArgs<EInfoObj[K]>> extends true
|
|
95
|
+
? K extends string
|
|
96
|
+
? `${K}RestApi`
|
|
97
|
+
: never
|
|
98
|
+
: never]: UploadRestApiFetchFn<EInfoObj[K], Context>;
|
|
66
99
|
};
|
|
67
100
|
|
|
68
|
-
type PubsubFetchType<EInfoObj extends { [key: string]: EndpointInfo },
|
|
69
|
-
[K in keyof EInfoObj as EndpInfoReqType<EInfoObj[K]> extends
|
|
70
|
-
?
|
|
101
|
+
type PubsubFetchType<EInfoObj extends { [key: string]: EndpointInfo }, Context> = {
|
|
102
|
+
[K in keyof EInfoObj as Extract<EndpInfoReqType<EInfoObj[K]>, "pubsub"> extends never
|
|
103
|
+
? never
|
|
104
|
+
: K extends string
|
|
71
105
|
? `subscribe${Capitalize<K>}`
|
|
72
|
-
: never
|
|
73
|
-
: never]: PubsubSubscribeFn<EInfoObj[K], SlceCls>;
|
|
106
|
+
: never]: PubsubSubscribeFn<EInfoObj[K], Context>;
|
|
74
107
|
};
|
|
75
108
|
|
|
76
|
-
type MessageListenFetchType<EInfoObj extends { [key: string]: EndpointInfo },
|
|
77
|
-
[K in keyof EInfoObj as EndpInfoReqType<EInfoObj[K]> extends
|
|
78
|
-
?
|
|
109
|
+
type MessageListenFetchType<EInfoObj extends { [key: string]: EndpointInfo }, Context> = {
|
|
110
|
+
[K in keyof EInfoObj as Extract<EndpInfoReqType<EInfoObj[K]>, "message"> extends never
|
|
111
|
+
? never
|
|
112
|
+
: K extends string
|
|
79
113
|
? `listen${Capitalize<K>}`
|
|
80
|
-
: never
|
|
81
|
-
: never]: MessageListenFn<EInfoObj[K], SlceCls>;
|
|
114
|
+
: never]: MessageListenFn<EInfoObj[K], Context>;
|
|
82
115
|
};
|
|
83
116
|
|
|
84
117
|
export type GetFetchTypeFromEndpoint<
|
|
85
118
|
EndpCls extends EndpointCls,
|
|
86
119
|
SlceCls extends SliceCls | never = never,
|
|
87
120
|
_EndpointInfoObj extends { [key: string]: EndpointInfo } = EndpCls[typeof ENDPOINT_META],
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
121
|
+
_ReturnContext = EndpointReturnContextOf<SlceCls>,
|
|
122
|
+
> = PrimaryFetchType<_EndpointInfoObj, _ReturnContext> &
|
|
123
|
+
UploadRestApiFetchType<_EndpointInfoObj, _ReturnContext> &
|
|
124
|
+
PubsubFetchType<_EndpointInfoObj, _ReturnContext> &
|
|
125
|
+
MessageListenFetchType<_EndpointInfoObj, _ReturnContext>;
|
|
@@ -1,104 +1,158 @@
|
|
|
1
1
|
import type { GetStateObject, SLICE_META } from "akanjs/base";
|
|
2
2
|
import type { FetchPolicy } from "akanjs/common";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { SliceCls, SliceInfoArgs } from "akanjs/signal";
|
|
3
|
+
import type { DefaultOf, ProtoFile, PurifiedModel } from "akanjs/constant";
|
|
4
|
+
import type { ExtractSort, FilterInstance } from "akanjs/document";
|
|
5
|
+
import type { SliceCls, SliceInfo, SliceInfoArgs } from "akanjs/signal";
|
|
6
6
|
import type { ClientEdit, ClientInit, ClientView, EditReturn, InitReturn, ViewReturn } from "./appliedReturn.type";
|
|
7
7
|
|
|
8
|
-
type
|
|
9
|
-
type
|
|
10
|
-
type _Cap<S extends SliceCls> = S["srv"]["cnst"]["_CapitalizedRefName"];
|
|
11
|
-
type _Input<S extends SliceCls> = S["srv"]["cnst"]["_Input"];
|
|
12
|
-
type _Full<S extends SliceCls> = S["srv"]["cnst"]["_Full"];
|
|
13
|
-
type _Light<S extends SliceCls> = S["srv"]["cnst"]["_Light"];
|
|
14
|
-
type _Insight<S extends SliceCls> = S["srv"]["cnst"]["_Insight"];
|
|
15
|
-
type _PurifiedInput<S extends SliceCls> = S["srv"]["cnst"]["_PurifiedInput"];
|
|
16
|
-
type _DefaultInput<S extends SliceCls> = S["srv"]["cnst"]["_DefaultInput"];
|
|
17
|
-
type _StateLight<S extends SliceCls> = S["srv"]["cnst"]["_StateLight"];
|
|
18
|
-
type _StateInsight<S extends SliceCls> = S["srv"]["cnst"]["_StateInsight"];
|
|
19
|
-
type _Filter<S extends SliceCls> = S["srv"]["db"]["_Filter"];
|
|
20
|
-
type _Sort<S extends SliceCls> = S["srv"]["db"]["_Sort"];
|
|
21
|
-
type _LightWithId<S extends SliceCls> = _Light<S> extends { id: string } ? _Light<S> : { id: string };
|
|
22
|
-
type _SliceFetchInitOption<S extends SliceCls> = FetchInitOption<_Input<S>, _Filter<S>, _DefaultInput<S>, _Sort<S>>;
|
|
8
|
+
type SliceInfoMap = { [key: string]: SliceInfo };
|
|
9
|
+
type LightWithId<Light> = Light extends { id: string } ? Light : { id: string };
|
|
23
10
|
|
|
24
|
-
type
|
|
25
|
-
|
|
11
|
+
export type SliceFetchDescriptor<
|
|
12
|
+
SliceMap extends SliceInfoMap = SliceInfoMap,
|
|
13
|
+
RefName extends string = string,
|
|
14
|
+
CapRefName extends string = Capitalize<RefName>,
|
|
15
|
+
Input = unknown,
|
|
16
|
+
Full = unknown,
|
|
17
|
+
Light = unknown,
|
|
18
|
+
Insight = unknown,
|
|
19
|
+
PurifiedInput = unknown,
|
|
20
|
+
DefaultInput = unknown,
|
|
21
|
+
StateLight = unknown,
|
|
22
|
+
StateInsight = unknown,
|
|
23
|
+
Filter extends FilterInstance = FilterInstance,
|
|
24
|
+
Sort = unknown,
|
|
25
|
+
> = {
|
|
26
|
+
sliceMap: SliceMap;
|
|
27
|
+
refName: RefName;
|
|
28
|
+
capRefName: CapRefName;
|
|
29
|
+
input: Input;
|
|
30
|
+
full: Full;
|
|
31
|
+
light: Light;
|
|
32
|
+
insight: Insight;
|
|
33
|
+
purifiedInput: PurifiedInput;
|
|
34
|
+
defaultInput: DefaultInput;
|
|
35
|
+
stateLight: StateLight;
|
|
36
|
+
stateInsight: StateInsight;
|
|
37
|
+
filter: Filter;
|
|
38
|
+
sort: Sort;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export type SliceFetchDescriptorOf<SlceCls extends SliceCls> = SliceFetchDescriptor<
|
|
42
|
+
SlceCls[typeof SLICE_META],
|
|
43
|
+
SlceCls["baseName"],
|
|
44
|
+
SlceCls["srv"]["cnst"]["_CapitalizedRefName"],
|
|
45
|
+
SlceCls["srv"]["cnst"]["_Input"],
|
|
46
|
+
SlceCls["srv"]["cnst"]["_Full"],
|
|
47
|
+
SlceCls["srv"]["cnst"]["_Light"],
|
|
48
|
+
SlceCls["srv"]["cnst"]["_Insight"],
|
|
49
|
+
SlceCls["srv"]["cnst"]["_PurifiedInput"],
|
|
50
|
+
SlceCls["srv"]["cnst"]["_DefaultInput"],
|
|
51
|
+
GetStateObject<LightWithId<SlceCls["srv"]["cnst"]["_Light"]>>,
|
|
52
|
+
GetStateObject<SlceCls["srv"]["cnst"]["_Insight"]>,
|
|
53
|
+
SlceCls["srv"]["db"]["_Filter"],
|
|
54
|
+
SlceCls["srv"]["db"]["_Sort"]
|
|
55
|
+
>;
|
|
56
|
+
|
|
57
|
+
type _SliceMap<D extends SliceFetchDescriptor> = D["sliceMap"];
|
|
58
|
+
type _RefName<D extends SliceFetchDescriptor> = D["refName"];
|
|
59
|
+
type _Cap<D extends SliceFetchDescriptor> = D["capRefName"];
|
|
60
|
+
type _Input<D extends SliceFetchDescriptor> = D["input"];
|
|
61
|
+
type _Full<D extends SliceFetchDescriptor> = D["full"];
|
|
62
|
+
type _Light<D extends SliceFetchDescriptor> = D["light"];
|
|
63
|
+
type _Insight<D extends SliceFetchDescriptor> = D["insight"];
|
|
64
|
+
type _PurifiedInput<D extends SliceFetchDescriptor> = D["purifiedInput"];
|
|
65
|
+
type _DefaultInput<D extends SliceFetchDescriptor> = D["defaultInput"];
|
|
66
|
+
type _StateLight<D extends SliceFetchDescriptor> = D["stateLight"];
|
|
67
|
+
type _StateInsight<D extends SliceFetchDescriptor> = D["stateInsight"];
|
|
68
|
+
type _Filter<D extends SliceFetchDescriptor> = D["filter"];
|
|
69
|
+
type _Sort<D extends SliceFetchDescriptor> = D["sort"];
|
|
70
|
+
type _LightWithId<D extends SliceFetchDescriptor> = LightWithId<_Light<D>>;
|
|
71
|
+
type _SliceFetchInitOption<D extends SliceFetchDescriptor> = FetchInitOption<
|
|
72
|
+
_Input<D>,
|
|
73
|
+
_Filter<D>,
|
|
74
|
+
_DefaultInput<D>,
|
|
75
|
+
_Sort<D>
|
|
76
|
+
>;
|
|
77
|
+
|
|
78
|
+
type SliceListFetch<D extends SliceFetchDescriptor> = {
|
|
79
|
+
[Suffix in keyof _SliceMap<D> as Suffix extends string ? `${_RefName<D>}List${Capitalize<Suffix>}` : never]: (
|
|
26
80
|
...args: [
|
|
27
|
-
...SliceInfoArgs<_SliceMap<
|
|
81
|
+
...SliceInfoArgs<_SliceMap<D>[Suffix]>,
|
|
28
82
|
skip?: number | null,
|
|
29
83
|
limit?: number | null,
|
|
30
|
-
sort?: _Sort<
|
|
84
|
+
sort?: _Sort<D> | null,
|
|
31
85
|
fetchPolicy?: FetchPolicy,
|
|
32
86
|
]
|
|
33
|
-
) => Promise<_Light<
|
|
87
|
+
) => Promise<_Light<D>[]>;
|
|
34
88
|
};
|
|
35
89
|
|
|
36
|
-
type SliceInsightFetch<
|
|
37
|
-
[Suffix in keyof _SliceMap<
|
|
38
|
-
...args: [...SliceInfoArgs<_SliceMap<
|
|
39
|
-
) => Promise<_Insight<
|
|
90
|
+
type SliceInsightFetch<D extends SliceFetchDescriptor> = {
|
|
91
|
+
[Suffix in keyof _SliceMap<D> as Suffix extends string ? `${_RefName<D>}Insight${Capitalize<Suffix>}` : never]: (
|
|
92
|
+
...args: [...SliceInfoArgs<_SliceMap<D>[Suffix]>, fetchPolicy?: FetchPolicy]
|
|
93
|
+
) => Promise<_Insight<D>>;
|
|
40
94
|
};
|
|
41
95
|
|
|
42
|
-
type SliceInitFetch<
|
|
43
|
-
[Suffix in keyof _SliceMap<
|
|
44
|
-
...args: [...SliceInfoArgs<_SliceMap<
|
|
96
|
+
type SliceInitFetch<D extends SliceFetchDescriptor> = {
|
|
97
|
+
[Suffix in keyof _SliceMap<D> as Suffix extends string ? `init${_Cap<D>}${Capitalize<Suffix>}` : never]: (
|
|
98
|
+
...args: [...SliceInfoArgs<_SliceMap<D>[Suffix]>, option?: _SliceFetchInitOption<D>]
|
|
45
99
|
) => Promise<
|
|
46
100
|
InitReturn<
|
|
47
|
-
_RefName<
|
|
101
|
+
_RefName<D>,
|
|
48
102
|
Suffix & string,
|
|
49
|
-
_Light<
|
|
50
|
-
_Insight<
|
|
51
|
-
SliceInfoArgs<_SliceMap<
|
|
52
|
-
_Filter<
|
|
53
|
-
_Cap<
|
|
103
|
+
_Light<D>,
|
|
104
|
+
_Insight<D>,
|
|
105
|
+
SliceInfoArgs<_SliceMap<D>[Suffix]>,
|
|
106
|
+
_Filter<D>,
|
|
107
|
+
_Cap<D>,
|
|
54
108
|
Suffix extends string ? Capitalize<Suffix> : never,
|
|
55
|
-
_LightWithId<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
_Sort<
|
|
109
|
+
_LightWithId<D>,
|
|
110
|
+
_StateLight<D>,
|
|
111
|
+
_StateInsight<D>,
|
|
112
|
+
_Sort<D>
|
|
59
113
|
>
|
|
60
114
|
>;
|
|
61
115
|
};
|
|
62
116
|
|
|
63
|
-
type SliceGetInitFetch<
|
|
64
|
-
[Suffix in keyof _SliceMap<
|
|
65
|
-
...args: [...SliceInfoArgs<_SliceMap<
|
|
117
|
+
type SliceGetInitFetch<D extends SliceFetchDescriptor> = {
|
|
118
|
+
[Suffix in keyof _SliceMap<D> as Suffix extends string ? `get${_Cap<D>}Init${Capitalize<Suffix>}` : never]: (
|
|
119
|
+
...args: [...SliceInfoArgs<_SliceMap<D>[Suffix]>, option?: _SliceFetchInitOption<D>]
|
|
66
120
|
) => ClientInit<
|
|
67
|
-
_RefName<
|
|
68
|
-
_Light<
|
|
69
|
-
_Insight<
|
|
70
|
-
SliceInfoArgs<_SliceMap<
|
|
71
|
-
_Filter<
|
|
72
|
-
_Cap<
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_Sort<
|
|
121
|
+
_RefName<D>,
|
|
122
|
+
_Light<D>,
|
|
123
|
+
_Insight<D>,
|
|
124
|
+
SliceInfoArgs<_SliceMap<D>[Suffix]>,
|
|
125
|
+
_Filter<D>,
|
|
126
|
+
_Cap<D>,
|
|
127
|
+
_StateLight<D>,
|
|
128
|
+
_StateInsight<D>,
|
|
129
|
+
_Sort<D>
|
|
76
130
|
>;
|
|
77
131
|
};
|
|
78
132
|
|
|
79
|
-
export type
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
133
|
+
export type GetFetchTypeFromSliceDescriptor<Descriptor extends SliceFetchDescriptor> = SliceListFetch<Descriptor> &
|
|
134
|
+
SliceInsightFetch<Descriptor> &
|
|
135
|
+
SliceInitFetch<Descriptor> &
|
|
136
|
+
SliceGetInitFetch<Descriptor> &
|
|
137
|
+
RawBaseSliceFetchType<
|
|
138
|
+
_RefName<Descriptor>,
|
|
139
|
+
_Input<Descriptor>,
|
|
140
|
+
_Full<Descriptor>,
|
|
141
|
+
_Light<Descriptor>,
|
|
142
|
+
_Cap<Descriptor>,
|
|
143
|
+
_PurifiedInput<Descriptor>
|
|
144
|
+
> &
|
|
145
|
+
AppliedBaseSliceFetchType<
|
|
146
|
+
_RefName<Descriptor>,
|
|
147
|
+
_Input<Descriptor>,
|
|
148
|
+
_Full<Descriptor>,
|
|
149
|
+
_Cap<Descriptor>,
|
|
150
|
+
_PurifiedInput<Descriptor>
|
|
151
|
+
>;
|
|
152
|
+
|
|
153
|
+
export type GetFetchTypeFromSlice<SlceCls extends SliceCls> = GetFetchTypeFromSliceDescriptor<
|
|
154
|
+
SliceFetchDescriptorOf<SlceCls>
|
|
155
|
+
>;
|
|
102
156
|
|
|
103
157
|
type RawBaseSliceFetchType<
|
|
104
158
|
RefName extends string,
|
|
@@ -120,7 +174,7 @@ type RawBaseSliceFetchType<
|
|
|
120
174
|
fetchPolicy?: FetchPolicy,
|
|
121
175
|
) => Promise<Full>;
|
|
122
176
|
} & {
|
|
123
|
-
[K in `remove${_CapitalizedRefName}`]: (id: string, fetchPolicy?: FetchPolicy) => Promise<
|
|
177
|
+
[K in `remove${_CapitalizedRefName}`]: (id: string, fetchPolicy?: FetchPolicy) => Promise<Full>;
|
|
124
178
|
};
|
|
125
179
|
|
|
126
180
|
type AppliedBaseSliceFetchType<
|
package/fetch/types.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { DatabaseSignal } from "akanjs/signal";
|
|
1
|
+
import { type Environment, getEnv } from "akanjs/base";
|
|
3
2
|
import type { SliceMeta } from "./fetchType/appliedReturn.type";
|
|
4
3
|
|
|
5
4
|
/** Account data made available to services for the current app/environment. */
|
|
@@ -12,18 +11,6 @@ export const getDefaultAccount = (): Account => {
|
|
|
12
11
|
return { appName: env.appName, environment: env.environment };
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
? SliceMetaObj
|
|
19
|
-
: Signal extends DatabaseSignal<infer _IntlCls, infer _EndpCls, infer SlceCls, infer _SrvrCls>
|
|
20
|
-
? {
|
|
21
|
-
[K in `${SlceCls["baseName"]}${Capitalize<keyof SlceCls[typeof SLICE_META] & string>}`]: SliceMeta;
|
|
22
|
-
}
|
|
23
|
-
: Record<never, never>;
|
|
24
|
-
export type GetSliceMetaObjFromDatabaseSignals<
|
|
25
|
-
Signals extends readonly unknown[],
|
|
26
|
-
Acc extends Record<string, SliceMeta> = Record<never, never>,
|
|
27
|
-
> = Signals extends readonly [infer First, ...infer Rest]
|
|
28
|
-
? GetSliceMetaObjFromDatabaseSignals<Rest, Assign<Acc, GetSliceMetaObjFromSignal<First>>>
|
|
29
|
-
: Acc;
|
|
14
|
+
export type GetSliceMetaObjFromDatabaseSignals<Signals extends readonly unknown[]> = Signals extends readonly []
|
|
15
|
+
? Record<never, never>
|
|
16
|
+
: Record<string, SliceMeta>;
|
package/package.json
CHANGED
|
@@ -12,15 +12,16 @@ export type FetchProxySignalInput<FetchType = unknown, SliceMetaObj extends Reco
|
|
|
12
12
|
_SliceMetaObj: SliceMetaObj;
|
|
13
13
|
};
|
|
14
14
|
export type FetchSignalInput = FetchProxySignalInput | DatabaseSignal | ServiceSignal;
|
|
15
|
+
type MergeFetchParts<First, Second> = [First] extends [never] ? Second : [Second] extends [never] ? First : Assign<First, Second>;
|
|
15
16
|
export type FetchTypeOfSignal<Signal extends FetchSignalInput> = Signal extends {
|
|
16
17
|
_FetchType: infer FetchType;
|
|
17
|
-
} ? FetchType : Signal extends DatabaseSignal<infer _IntlCls, infer EndpCls, infer SlceCls, infer _SrvrCls> ? GetFetchTypeFromEndpoint<EndpCls, SlceCls
|
|
18
|
+
} ? FetchType : Signal extends DatabaseSignal<infer _IntlCls, infer EndpCls, infer SlceCls, infer _SrvrCls> ? MergeFetchParts<GetFetchTypeFromEndpoint<EndpCls, SlceCls>, GetFetchTypeFromSlice<SlceCls>> : Signal extends ServiceSignal<infer _IntlCls, infer EndpCls, infer _SrvrCls> ? GetFetchTypeFromEndpoint<EndpCls> : unknown;
|
|
18
19
|
type MergeProxyFetchTypes<Signals extends readonly FetchSignalInput[], Acc = Record<never, never>> = Signals extends readonly [infer First extends FetchSignalInput, ...infer Rest extends readonly FetchSignalInput[]] ? First extends {
|
|
19
20
|
_FetchType: infer FetchType;
|
|
20
21
|
} ? MergeProxyFetchTypes<Rest, Assign<Acc, FetchType>> : MergeProxyFetchTypes<Rest, Acc> : Acc;
|
|
21
22
|
type MergeDirectFetchTypes<Signals extends readonly FetchSignalInput[], Acc = Record<never, never>> = Signals extends readonly [infer First extends FetchSignalInput, ...infer Rest extends readonly FetchSignalInput[]] ? First extends {
|
|
22
23
|
_FetchType: unknown;
|
|
23
|
-
} ? MergeDirectFetchTypes<Rest, Acc> : MergeDirectFetchTypes<Rest,
|
|
24
|
+
} ? MergeDirectFetchTypes<Rest, Acc> : MergeDirectFetchTypes<Rest, MergeFetchParts<Acc, FetchTypeOfSignal<First>>> : Acc;
|
|
24
25
|
export type MergeAllFetchTypes<Signals extends readonly FetchSignalInput[]> = MergeProxyFetchTypes<Signals> extends infer ProxyFetch ? MergeDirectFetchTypes<Signals> extends infer DirectFetch ? Assign<ProxyFetch, DirectFetch> : never : never;
|
|
25
26
|
export type FetchClientType<Signals extends readonly FetchSignalInput[]> = FetchProxy<MergeAllFetchTypes<Signals>, GetSliceMetaObjFromDatabaseSignals<Signals>>;
|
|
26
27
|
export {};
|
|
@@ -1,34 +1,52 @@
|
|
|
1
1
|
import type { ENDPOINT_META, PromiseOrObject } from "akanjs/base";
|
|
2
2
|
import type { FetchPolicy } from "akanjs/common";
|
|
3
3
|
import type { EndpInfoArgs, EndpInfoClientReturns, EndpInfoNullable, EndpInfoReqType, EndpointCls, EndpointInfo, SliceCls } from "akanjs/signal";
|
|
4
|
-
type
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
type
|
|
4
|
+
export type EndpointReturnContext<Full = unknown, Light = unknown, Insight = unknown> = {
|
|
5
|
+
full: Full;
|
|
6
|
+
light: Light;
|
|
7
|
+
insight: Insight;
|
|
8
|
+
};
|
|
9
|
+
type EndpointReturnContextOf<SlceCls extends SliceCls | never> = [SlceCls] extends [never] ? never : SlceCls extends SliceCls ? EndpointReturnContext<SlceCls["srv"]["cnst"]["_Full"], SlceCls["srv"]["cnst"]["_Light"], SlceCls["srv"]["cnst"]["_Insight"]> : never;
|
|
10
|
+
type ExtendedEndpointReturn<ClientReturns, Context> = ClientReturns extends (infer R)[] ? ExtendedEndpointReturn<R, Context>[] : Context extends EndpointReturnContext<infer Full, infer Light, infer Insight> ? Full extends ClientReturns ? Full : Light extends ClientReturns ? Light : Insight extends ClientReturns ? Insight : ClientReturns : ClientReturns;
|
|
11
|
+
type EndpointClientReturns<E, Context> = [Context] extends [never] ? EndpInfoClientReturns<E> : ExtendedEndpointReturn<EndpInfoClientReturns<E>, Context>;
|
|
12
|
+
type EndpInfoReturns<E, Context> = EndpointClientReturns<E, Context> | (EndpInfoNullable<E> extends true ? null : never);
|
|
13
|
+
type QueryOrMutationFetchFn<E, Context> = (...args: [...EndpInfoArgs<E>, fetchPolicy?: FetchPolicy]) => Promise<EndpInfoReturns<E, Context>>;
|
|
14
|
+
type MessageEmitFn<E, Context> = (...args: EndpInfoArgs<E>) => EndpInfoReturns<E, Context>;
|
|
15
|
+
type MessageListenFn<E, Context> = (handleEvent: (data: EndpInfoReturns<E, Context>) => PromiseOrObject<void>, options?: FetchPolicy) => () => void;
|
|
16
|
+
type PubsubSubscribeFn<E, Context> = (...args: [
|
|
11
17
|
...EndpInfoArgs<E>,
|
|
12
|
-
handleEvent: (data: EndpInfoReturns<E,
|
|
18
|
+
handleEvent: (data: EndpInfoReturns<E, Context>) => PromiseOrObject<void>,
|
|
13
19
|
options?: FetchPolicy
|
|
14
20
|
]) => () => void;
|
|
15
|
-
type PrimaryFetchFn<E,
|
|
21
|
+
type PrimaryFetchFn<E, Context, ReqType = EndpInfoReqType<E>> = ReqType extends "query" | "mutation" ? QueryOrMutationFetchFn<E, Context> : ReqType extends "message" ? MessageEmitFn<E, Context> : never;
|
|
22
|
+
type UploadLikeArg = FileList | File | File[];
|
|
23
|
+
type HasUploadLikeArg<Args extends readonly unknown[]> = Extract<Args[number], UploadLikeArg> extends never ? false : true;
|
|
24
|
+
type RestApiArg<Arg> = Arg extends FileList ? FileList : Arg extends File | File[] ? FileList : Arg;
|
|
25
|
+
type RestApiArgs<Args extends readonly unknown[]> = {
|
|
26
|
+
[K in keyof Args]: RestApiArg<Args[K]>;
|
|
27
|
+
};
|
|
28
|
+
type UploadRestApiFetchFn<E, Context> = (...args: [...RestApiArgs<EndpInfoArgs<E>>, fetchPolicy?: FetchPolicy]) => Promise<EndpInfoReturns<E, Context>>;
|
|
16
29
|
type PrimaryFetchType<EInfoObj extends {
|
|
17
30
|
[key: string]: EndpointInfo;
|
|
18
|
-
},
|
|
19
|
-
[K in keyof EInfoObj as EndpInfoReqType<EInfoObj[K]
|
|
31
|
+
}, Context> = {
|
|
32
|
+
[K in keyof EInfoObj as Extract<EndpInfoReqType<EInfoObj[K]>, "query" | "mutation" | "message"> extends never ? never : K]: PrimaryFetchFn<EInfoObj[K], Context>;
|
|
33
|
+
};
|
|
34
|
+
type UploadRestApiFetchType<EInfoObj extends {
|
|
35
|
+
[key: string]: EndpointInfo;
|
|
36
|
+
}, Context> = {
|
|
37
|
+
[K in keyof EInfoObj as Extract<EndpInfoReqType<EInfoObj[K]>, "mutation"> extends never ? never : HasUploadLikeArg<EndpInfoArgs<EInfoObj[K]>> extends true ? K extends string ? `${K}RestApi` : never : never]: UploadRestApiFetchFn<EInfoObj[K], Context>;
|
|
20
38
|
};
|
|
21
39
|
type PubsubFetchType<EInfoObj extends {
|
|
22
40
|
[key: string]: EndpointInfo;
|
|
23
|
-
},
|
|
24
|
-
[K in keyof EInfoObj as EndpInfoReqType<EInfoObj[K]
|
|
41
|
+
}, Context> = {
|
|
42
|
+
[K in keyof EInfoObj as Extract<EndpInfoReqType<EInfoObj[K]>, "pubsub"> extends never ? never : K extends string ? `subscribe${Capitalize<K>}` : never]: PubsubSubscribeFn<EInfoObj[K], Context>;
|
|
25
43
|
};
|
|
26
44
|
type MessageListenFetchType<EInfoObj extends {
|
|
27
45
|
[key: string]: EndpointInfo;
|
|
28
|
-
},
|
|
29
|
-
[K in keyof EInfoObj as EndpInfoReqType<EInfoObj[K]
|
|
46
|
+
}, Context> = {
|
|
47
|
+
[K in keyof EInfoObj as Extract<EndpInfoReqType<EInfoObj[K]>, "message"> extends never ? never : K extends string ? `listen${Capitalize<K>}` : never]: MessageListenFn<EInfoObj[K], Context>;
|
|
30
48
|
};
|
|
31
49
|
export type GetFetchTypeFromEndpoint<EndpCls extends EndpointCls, SlceCls extends SliceCls | never = never, _EndpointInfoObj extends {
|
|
32
50
|
[key: string]: EndpointInfo;
|
|
33
|
-
} = EndpCls[typeof ENDPOINT_META]
|
|
51
|
+
} = EndpCls[typeof ENDPOINT_META], _ReturnContext = EndpointReturnContextOf<SlceCls>> = PrimaryFetchType<_EndpointInfoObj, _ReturnContext> & UploadRestApiFetchType<_EndpointInfoObj, _ReturnContext> & PubsubFetchType<_EndpointInfoObj, _ReturnContext> & MessageListenFetchType<_EndpointInfoObj, _ReturnContext>;
|
|
34
52
|
export {};
|
|
@@ -1,45 +1,68 @@
|
|
|
1
1
|
import type { GetStateObject, SLICE_META } from "akanjs/base";
|
|
2
2
|
import type { FetchPolicy } from "akanjs/common";
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type { SliceCls, SliceInfoArgs } from "akanjs/signal";
|
|
3
|
+
import type { DefaultOf, ProtoFile, PurifiedModel } from "akanjs/constant";
|
|
4
|
+
import type { ExtractSort, FilterInstance } from "akanjs/document";
|
|
5
|
+
import type { SliceCls, SliceInfo, SliceInfoArgs } from "akanjs/signal";
|
|
6
6
|
import type { ClientEdit, ClientInit, ClientView, EditReturn, InitReturn, ViewReturn } from "./appliedReturn.type";
|
|
7
|
-
type
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
type
|
|
11
|
-
type _Full<S extends SliceCls> = S["srv"]["cnst"]["_Full"];
|
|
12
|
-
type _Light<S extends SliceCls> = S["srv"]["cnst"]["_Light"];
|
|
13
|
-
type _Insight<S extends SliceCls> = S["srv"]["cnst"]["_Insight"];
|
|
14
|
-
type _PurifiedInput<S extends SliceCls> = S["srv"]["cnst"]["_PurifiedInput"];
|
|
15
|
-
type _DefaultInput<S extends SliceCls> = S["srv"]["cnst"]["_DefaultInput"];
|
|
16
|
-
type _Filter<S extends SliceCls> = S["srv"]["db"]["_Filter"];
|
|
17
|
-
type _Sort<S extends SliceCls> = S["srv"]["db"]["_Sort"];
|
|
18
|
-
type _LightWithId<S extends SliceCls> = _Light<S> extends {
|
|
7
|
+
type SliceInfoMap = {
|
|
8
|
+
[key: string]: SliceInfo;
|
|
9
|
+
};
|
|
10
|
+
type LightWithId<Light> = Light extends {
|
|
19
11
|
id: string;
|
|
20
|
-
} ?
|
|
12
|
+
} ? Light : {
|
|
21
13
|
id: string;
|
|
22
14
|
};
|
|
23
|
-
type
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
export type SliceFetchDescriptor<SliceMap extends SliceInfoMap = SliceInfoMap, RefName extends string = string, CapRefName extends string = Capitalize<RefName>, Input = unknown, Full = unknown, Light = unknown, Insight = unknown, PurifiedInput = unknown, DefaultInput = unknown, StateLight = unknown, StateInsight = unknown, Filter extends FilterInstance = FilterInstance, Sort = unknown> = {
|
|
16
|
+
sliceMap: SliceMap;
|
|
17
|
+
refName: RefName;
|
|
18
|
+
capRefName: CapRefName;
|
|
19
|
+
input: Input;
|
|
20
|
+
full: Full;
|
|
21
|
+
light: Light;
|
|
22
|
+
insight: Insight;
|
|
23
|
+
purifiedInput: PurifiedInput;
|
|
24
|
+
defaultInput: DefaultInput;
|
|
25
|
+
stateLight: StateLight;
|
|
26
|
+
stateInsight: StateInsight;
|
|
27
|
+
filter: Filter;
|
|
28
|
+
sort: Sort;
|
|
29
|
+
};
|
|
30
|
+
export type SliceFetchDescriptorOf<SlceCls extends SliceCls> = SliceFetchDescriptor<SlceCls[typeof SLICE_META], SlceCls["baseName"], SlceCls["srv"]["cnst"]["_CapitalizedRefName"], SlceCls["srv"]["cnst"]["_Input"], SlceCls["srv"]["cnst"]["_Full"], SlceCls["srv"]["cnst"]["_Light"], SlceCls["srv"]["cnst"]["_Insight"], SlceCls["srv"]["cnst"]["_PurifiedInput"], SlceCls["srv"]["cnst"]["_DefaultInput"], GetStateObject<LightWithId<SlceCls["srv"]["cnst"]["_Light"]>>, GetStateObject<SlceCls["srv"]["cnst"]["_Insight"]>, SlceCls["srv"]["db"]["_Filter"], SlceCls["srv"]["db"]["_Sort"]>;
|
|
31
|
+
type _SliceMap<D extends SliceFetchDescriptor> = D["sliceMap"];
|
|
32
|
+
type _RefName<D extends SliceFetchDescriptor> = D["refName"];
|
|
33
|
+
type _Cap<D extends SliceFetchDescriptor> = D["capRefName"];
|
|
34
|
+
type _Input<D extends SliceFetchDescriptor> = D["input"];
|
|
35
|
+
type _Full<D extends SliceFetchDescriptor> = D["full"];
|
|
36
|
+
type _Light<D extends SliceFetchDescriptor> = D["light"];
|
|
37
|
+
type _Insight<D extends SliceFetchDescriptor> = D["insight"];
|
|
38
|
+
type _PurifiedInput<D extends SliceFetchDescriptor> = D["purifiedInput"];
|
|
39
|
+
type _DefaultInput<D extends SliceFetchDescriptor> = D["defaultInput"];
|
|
40
|
+
type _StateLight<D extends SliceFetchDescriptor> = D["stateLight"];
|
|
41
|
+
type _StateInsight<D extends SliceFetchDescriptor> = D["stateInsight"];
|
|
42
|
+
type _Filter<D extends SliceFetchDescriptor> = D["filter"];
|
|
43
|
+
type _Sort<D extends SliceFetchDescriptor> = D["sort"];
|
|
44
|
+
type _LightWithId<D extends SliceFetchDescriptor> = LightWithId<_Light<D>>;
|
|
45
|
+
type _SliceFetchInitOption<D extends SliceFetchDescriptor> = FetchInitOption<_Input<D>, _Filter<D>, _DefaultInput<D>, _Sort<D>>;
|
|
46
|
+
type SliceListFetch<D extends SliceFetchDescriptor> = {
|
|
47
|
+
[Suffix in keyof _SliceMap<D> as Suffix extends string ? `${_RefName<D>}List${Capitalize<Suffix>}` : never]: (...args: [
|
|
48
|
+
...SliceInfoArgs<_SliceMap<D>[Suffix]>,
|
|
27
49
|
skip?: number | null,
|
|
28
50
|
limit?: number | null,
|
|
29
|
-
sort?: _Sort<
|
|
51
|
+
sort?: _Sort<D> | null,
|
|
30
52
|
fetchPolicy?: FetchPolicy
|
|
31
|
-
]) => Promise<_Light<
|
|
53
|
+
]) => Promise<_Light<D>[]>;
|
|
32
54
|
};
|
|
33
|
-
type SliceInsightFetch<
|
|
34
|
-
[Suffix in keyof _SliceMap<
|
|
55
|
+
type SliceInsightFetch<D extends SliceFetchDescriptor> = {
|
|
56
|
+
[Suffix in keyof _SliceMap<D> as Suffix extends string ? `${_RefName<D>}Insight${Capitalize<Suffix>}` : never]: (...args: [...SliceInfoArgs<_SliceMap<D>[Suffix]>, fetchPolicy?: FetchPolicy]) => Promise<_Insight<D>>;
|
|
35
57
|
};
|
|
36
|
-
type SliceInitFetch<
|
|
37
|
-
[Suffix in keyof _SliceMap<
|
|
58
|
+
type SliceInitFetch<D extends SliceFetchDescriptor> = {
|
|
59
|
+
[Suffix in keyof _SliceMap<D> as Suffix extends string ? `init${_Cap<D>}${Capitalize<Suffix>}` : never]: (...args: [...SliceInfoArgs<_SliceMap<D>[Suffix]>, option?: _SliceFetchInitOption<D>]) => Promise<InitReturn<_RefName<D>, Suffix & string, _Light<D>, _Insight<D>, SliceInfoArgs<_SliceMap<D>[Suffix]>, _Filter<D>, _Cap<D>, Suffix extends string ? Capitalize<Suffix> : never, _LightWithId<D>, _StateLight<D>, _StateInsight<D>, _Sort<D>>>;
|
|
38
60
|
};
|
|
39
|
-
type SliceGetInitFetch<
|
|
40
|
-
[Suffix in keyof _SliceMap<
|
|
61
|
+
type SliceGetInitFetch<D extends SliceFetchDescriptor> = {
|
|
62
|
+
[Suffix in keyof _SliceMap<D> as Suffix extends string ? `get${_Cap<D>}Init${Capitalize<Suffix>}` : never]: (...args: [...SliceInfoArgs<_SliceMap<D>[Suffix]>, option?: _SliceFetchInitOption<D>]) => ClientInit<_RefName<D>, _Light<D>, _Insight<D>, SliceInfoArgs<_SliceMap<D>[Suffix]>, _Filter<D>, _Cap<D>, _StateLight<D>, _StateInsight<D>, _Sort<D>>;
|
|
41
63
|
};
|
|
42
|
-
export type
|
|
64
|
+
export type GetFetchTypeFromSliceDescriptor<Descriptor extends SliceFetchDescriptor> = SliceListFetch<Descriptor> & SliceInsightFetch<Descriptor> & SliceInitFetch<Descriptor> & SliceGetInitFetch<Descriptor> & RawBaseSliceFetchType<_RefName<Descriptor>, _Input<Descriptor>, _Full<Descriptor>, _Light<Descriptor>, _Cap<Descriptor>, _PurifiedInput<Descriptor>> & AppliedBaseSliceFetchType<_RefName<Descriptor>, _Input<Descriptor>, _Full<Descriptor>, _Cap<Descriptor>, _PurifiedInput<Descriptor>>;
|
|
65
|
+
export type GetFetchTypeFromSlice<SlceCls extends SliceCls> = GetFetchTypeFromSliceDescriptor<SliceFetchDescriptorOf<SlceCls>>;
|
|
43
66
|
type RawBaseSliceFetchType<RefName extends string, Input, Full, Light, _CapitalizedRefName extends string = Capitalize<RefName>, _PurifiedInput = PurifiedModel<Input>> = {
|
|
44
67
|
[K in RefName]: (id: string, fetchPolicy?: FetchPolicy) => Promise<Full>;
|
|
45
68
|
} & {
|
|
@@ -49,7 +72,7 @@ type RawBaseSliceFetchType<RefName extends string, Input, Full, Light, _Capitali
|
|
|
49
72
|
} & {
|
|
50
73
|
[K in `update${_CapitalizedRefName}`]: (id: string, input: _PurifiedInput, fetchPolicy?: FetchPolicy) => Promise<Full>;
|
|
51
74
|
} & {
|
|
52
|
-
[K in `remove${_CapitalizedRefName}`]: (id: string, fetchPolicy?: FetchPolicy) => Promise<
|
|
75
|
+
[K in `remove${_CapitalizedRefName}`]: (id: string, fetchPolicy?: FetchPolicy) => Promise<Full>;
|
|
53
76
|
};
|
|
54
77
|
type AppliedBaseSliceFetchType<RefName extends string, Input, Full, _CapitalizedRefName extends string = Capitalize<RefName>, _PurifiedInput = PurifiedModel<Input>> = {
|
|
55
78
|
[K in `view${_CapitalizedRefName}`]: (id: string, option?: FetchPolicy) => Promise<ViewReturn<RefName, Full>>;
|
package/types/fetch/types.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { DatabaseSignal } from "akanjs/signal";
|
|
1
|
+
import { type Environment } from "akanjs/base";
|
|
3
2
|
import type { SliceMeta } from "./fetchType/appliedReturn.type";
|
|
4
3
|
/** Account data made available to services for the current app/environment. */
|
|
5
4
|
export type Account<AddData = unknown> = {
|
|
@@ -7,10 +6,4 @@ export type Account<AddData = unknown> = {
|
|
|
7
6
|
environment: Environment;
|
|
8
7
|
} & AddData;
|
|
9
8
|
export declare const getDefaultAccount: () => Account;
|
|
10
|
-
type
|
|
11
|
-
_SliceMetaObj: infer SliceMetaObj extends Record<string, SliceMeta>;
|
|
12
|
-
} ? SliceMetaObj : Signal extends DatabaseSignal<infer _IntlCls, infer _EndpCls, infer SlceCls, infer _SrvrCls> ? {
|
|
13
|
-
[K in `${SlceCls["baseName"]}${Capitalize<keyof SlceCls[typeof SLICE_META] & string>}`]: SliceMeta;
|
|
14
|
-
} : Record<never, never>;
|
|
15
|
-
export type GetSliceMetaObjFromDatabaseSignals<Signals extends readonly unknown[], Acc extends Record<string, SliceMeta> = Record<never, never>> = Signals extends readonly [infer First, ...infer Rest] ? GetSliceMetaObjFromDatabaseSignals<Rest, Assign<Acc, GetSliceMetaObjFromSignal<First>>> : Acc;
|
|
16
|
-
export {};
|
|
9
|
+
export type GetSliceMetaObjFromDatabaseSignals<Signals extends readonly unknown[]> = Signals extends readonly [] ? Record<never, never> : Record<string, SliceMeta>;
|
package/ui/More.tsx
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { clsx, isMobileDevice } from "akanjs/client";
|
|
3
|
-
import {
|
|
3
|
+
import { InfiniteScroll } from "./InfiniteScroll";
|
|
4
4
|
import { Pagination } from "./Pagination";
|
|
5
5
|
|
|
6
|
-
const InfiniteScroll = lazy(() => import("./InfiniteScroll").then((mod) => mod.InfiniteScroll), { ssr: false });
|
|
7
|
-
|
|
8
6
|
interface MoreProps {
|
|
9
7
|
total: number;
|
|
10
8
|
itemsPerPage: number;
|