@ic-reactor/react 3.6.0 → 3.8.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/README.md +117 -13
- package/dist/auth/authentication-manager.d.ts +98 -0
- package/dist/auth/authentication-manager.d.ts.map +1 -0
- package/dist/auth/authentication-manager.js +532 -0
- package/dist/auth/authentication-manager.js.map +1 -0
- package/dist/auth/constants.d.ts +18 -0
- package/dist/auth/constants.d.ts.map +1 -0
- package/dist/auth/constants.js +18 -0
- package/dist/auth/constants.js.map +1 -0
- package/dist/auth/createIdentityAttributeHooks.d.ts +14 -0
- package/dist/auth/createIdentityAttributeHooks.d.ts.map +1 -0
- package/dist/auth/createIdentityAttributeHooks.js +54 -0
- package/dist/auth/createIdentityAttributeHooks.js.map +1 -0
- package/dist/auth/identity-attributes-manager.d.ts +26 -0
- package/dist/auth/identity-attributes-manager.d.ts.map +1 -0
- package/dist/auth/identity-attributes-manager.js +108 -0
- package/dist/auth/identity-attributes-manager.js.map +1 -0
- package/dist/auth/identity-attributes.d.ts +19 -0
- package/dist/auth/identity-attributes.d.ts.map +1 -0
- package/dist/auth/identity-attributes.js +170 -0
- package/dist/auth/identity-attributes.js.map +1 -0
- package/dist/auth/index.d.ts +8 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +8 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/auth/types.d.ts +182 -0
- package/dist/auth/types.d.ts.map +1 -0
- package/dist/auth/types.js +2 -0
- package/dist/auth/types.js.map +1 -0
- package/dist/createActorHooks.d.ts +16 -16
- package/dist/createActorHooks.d.ts.map +1 -1
- package/dist/createActorHooks.js +6 -6
- package/dist/createActorHooks.js.map +1 -1
- package/dist/createInfiniteQuery.d.ts +33 -33
- package/dist/createInfiniteQuery.d.ts.map +1 -1
- package/dist/createInfiniteQuery.js +6 -6
- package/dist/createInfiniteQuery.js.map +1 -1
- package/dist/createMutation.d.ts +13 -2
- package/dist/createMutation.d.ts.map +1 -1
- package/dist/createMutation.js +11 -0
- package/dist/createMutation.js.map +1 -1
- package/dist/createQuery.d.ts +13 -3
- package/dist/createQuery.d.ts.map +1 -1
- package/dist/createQuery.js +16 -6
- package/dist/createQuery.js.map +1 -1
- package/dist/createSuspenseInfiniteQuery.d.ts +32 -32
- package/dist/createSuspenseInfiniteQuery.d.ts.map +1 -1
- package/dist/createSuspenseInfiniteQuery.js +6 -6
- package/dist/createSuspenseInfiniteQuery.js.map +1 -1
- package/dist/createSuspenseQuery.d.ts +3 -3
- package/dist/createSuspenseQuery.d.ts.map +1 -1
- package/dist/createSuspenseQuery.js +1 -1
- package/dist/createSuspenseQuery.js.map +1 -1
- package/dist/defineReactor.d.ts +124 -0
- package/dist/defineReactor.d.ts.map +1 -0
- package/dist/defineReactor.js +145 -0
- package/dist/defineReactor.js.map +1 -0
- package/dist/{createAuthHooks.d.ts → hooks/createAuthHooks.d.ts} +6 -13
- package/dist/hooks/createAuthHooks.d.ts.map +1 -0
- package/dist/{createAuthHooks.js → hooks/createAuthHooks.js} +18 -58
- package/dist/hooks/createAuthHooks.js.map +1 -0
- package/dist/hooks/index.d.ts +2 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useActorInfiniteQuery.d.ts +9 -9
- package/dist/hooks/useActorInfiniteQuery.d.ts.map +1 -1
- package/dist/hooks/useActorInfiniteQuery.js +3 -1
- package/dist/hooks/useActorInfiniteQuery.js.map +1 -1
- package/dist/hooks/useActorMethod.d.ts +17 -17
- package/dist/hooks/useActorMethod.d.ts.map +1 -1
- package/dist/hooks/useActorMethod.js.map +1 -1
- package/dist/hooks/useActorMutation.d.ts +18 -7
- package/dist/hooks/useActorMutation.d.ts.map +1 -1
- package/dist/hooks/useActorMutation.js +11 -0
- package/dist/hooks/useActorMutation.js.map +1 -1
- package/dist/hooks/useActorQuery.d.ts +8 -8
- package/dist/hooks/useActorQuery.d.ts.map +1 -1
- package/dist/hooks/useActorQuery.js.map +1 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +9 -9
- package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +1 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.js +3 -1
- package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +1 -1
- package/dist/hooks/useActorSuspenseQuery.d.ts +8 -8
- package/dist/hooks/useActorSuspenseQuery.d.ts.map +1 -1
- package/dist/hooks/useActorSuspenseQuery.js.map +1 -1
- package/dist/index.d.ts +11 -10
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -10
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +24 -24
- package/dist/types.d.ts.map +1 -1
- package/dist/utils.d.ts +3 -0
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +10 -2
- package/dist/utils.js.map +1 -1
- package/llms.txt +48 -0
- package/package.json +34 -23
- package/src/auth/authentication-manager.ts +591 -0
- package/src/auth/constants.ts +25 -0
- package/src/auth/createIdentityAttributeHooks.ts +83 -0
- package/src/auth/identity-attributes-manager.ts +136 -0
- package/src/auth/identity-attributes.ts +270 -0
- package/src/auth/index.ts +7 -0
- package/src/auth/types.ts +204 -0
- package/src/createActorHooks.ts +90 -58
- package/src/createInfiniteQuery.ts +154 -98
- package/src/createMutation.ts +35 -19
- package/src/createQuery.ts +94 -50
- package/src/createSuspenseInfiniteQuery.ts +166 -115
- package/src/createSuspenseQuery.ts +69 -43
- package/src/defineReactor.ts +272 -0
- package/src/{createAuthHooks.ts → hooks/createAuthHooks.ts} +23 -99
- package/src/hooks/index.ts +4 -0
- package/src/hooks/useActorInfiniteQuery.ts +44 -30
- package/src/hooks/useActorMethod.ts +62 -53
- package/src/hooks/useActorMutation.ts +47 -30
- package/src/hooks/useActorQuery.ts +36 -32
- package/src/hooks/useActorSuspenseInfiniteQuery.ts +56 -30
- package/src/hooks/useActorSuspenseQuery.ts +42 -32
- package/src/index.ts +12 -10
- package/src/types.ts +76 -71
- package/src/utils.ts +15 -2
- package/dist/createAuthHooks.d.ts.map +0 -1
- package/dist/createAuthHooks.js.map +0 -1
- package/src/hooks/useActorInfiniteQuery.test.tsx +0 -457
- package/src/hooks/useActorMethod.test.tsx +0 -798
- package/src/hooks/useActorMutation.test.tsx +0 -220
- package/src/hooks/useActorQuery.test.tsx +0 -287
- package/src/hooks/useActorSuspenseInfiniteQuery.test.tsx +0 -472
- package/src/hooks/useActorSuspenseQuery.test.tsx +0 -254
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import type { Identity, SignIdentity } from "@icp-sdk/core/agent"
|
|
2
|
+
import type { PartialIdentity } from "@icp-sdk/core/identity"
|
|
3
|
+
import type { Principal } from "@icp-sdk/core/principal"
|
|
4
|
+
|
|
5
|
+
export interface SignedIdentityAttributes {
|
|
6
|
+
data: Uint8Array
|
|
7
|
+
signature: Uint8Array
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The 32-byte nonce issued by the relying-party canister.
|
|
12
|
+
*
|
|
13
|
+
* A function (or promise) lets the Internet Identity window open while the
|
|
14
|
+
* nonce is still being fetched, so the popup is opened inside the user gesture
|
|
15
|
+
* instead of after it. `@icp-sdk/auth` v8 requires the function form; v7
|
|
16
|
+
* accepts the promise form. IC Reactor normalizes whichever you pass to the
|
|
17
|
+
* shape the installed client expects.
|
|
18
|
+
*/
|
|
19
|
+
export type IdentityAttributeNonce =
|
|
20
|
+
Uint8Array | Promise<Uint8Array> | (() => Uint8Array | Promise<Uint8Array>)
|
|
21
|
+
|
|
22
|
+
export interface IdentityAttributeRequest {
|
|
23
|
+
keys: string[]
|
|
24
|
+
nonce: IdentityAttributeNonce
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface IdentityAttributeValues {
|
|
28
|
+
email?: string
|
|
29
|
+
name?: string
|
|
30
|
+
verified_email?: string
|
|
31
|
+
[key: string]: string | undefined
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface IdentityAttributeResult {
|
|
35
|
+
principal: string
|
|
36
|
+
requestedKeys: string[]
|
|
37
|
+
signedAttributes: SignedIdentityAttributes
|
|
38
|
+
decodedAttributes: IdentityAttributeValues
|
|
39
|
+
completedAt: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* The providers that Internet Identity supports for one-click sign-in. Only
|
|
44
|
+
* these three reach the underlying auth client.
|
|
45
|
+
*/
|
|
46
|
+
type IdentityAttributeOpenIdProviderAlias = "google" | "apple" | "microsoft"
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* An OpenID provider, either as a well-known alias or as a raw issuer URL.
|
|
50
|
+
*
|
|
51
|
+
* The two forms are **not** interchangeable, and what each one does depends on
|
|
52
|
+
* where it is passed:
|
|
53
|
+
*
|
|
54
|
+
* - An alias (`"google" | "apple" | "microsoft"`) is forwarded to the auth
|
|
55
|
+
* client, which adds an `openid` search param to the identity provider URL so
|
|
56
|
+
* the user signs in through that provider directly.
|
|
57
|
+
* - Any other string is treated as a raw issuer URL and is **never** forwarded
|
|
58
|
+
* to the auth client, so it never affects how the user signs in. It is only
|
|
59
|
+
* meaningful when passed to {@link IdentityAttributesManager.requestOpenId}
|
|
60
|
+
* (or `identityAttributeKeys`), which scopes the requested keys to
|
|
61
|
+
* `openid:<issuer>:<key>`. Passed anywhere else it has no effect at all.
|
|
62
|
+
*/
|
|
63
|
+
export type IdentityAttributeOpenIdProvider =
|
|
64
|
+
IdentityAttributeOpenIdProviderAlias | (string & {})
|
|
65
|
+
|
|
66
|
+
/** Session key algorithm used for each sign-in. */
|
|
67
|
+
export type AuthClientKeyType = "ECDSA" | "Ed25519"
|
|
68
|
+
|
|
69
|
+
/** Structural shape of an `@icp-sdk/auth` `AuthClientStorage`. */
|
|
70
|
+
export interface AuthClientStorageLike {
|
|
71
|
+
get(key: string): Promise<string | CryptoKeyPair | null>
|
|
72
|
+
set(key: string, value: string | CryptoKeyPair): Promise<void>
|
|
73
|
+
remove(key: string): Promise<void>
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Idle-session configuration forwarded to the underlying AuthClient. */
|
|
77
|
+
export interface AuthClientIdleOptions {
|
|
78
|
+
/** Called once the user has been idle for `idleTimeout` ms. */
|
|
79
|
+
onIdle?: () => unknown
|
|
80
|
+
/** Idle timeout in ms. @default 600_000 (10 minutes) */
|
|
81
|
+
idleTimeout?: number
|
|
82
|
+
/** Treat scroll events as activity. @default false */
|
|
83
|
+
captureScroll?: boolean
|
|
84
|
+
/** Scroll debounce in ms. @default 100 */
|
|
85
|
+
scrollDebounce?: number
|
|
86
|
+
/** Disable idle detection entirely. @default false */
|
|
87
|
+
disableIdle?: boolean
|
|
88
|
+
/**
|
|
89
|
+
* Disable the built-in idle callback, which signs the user out and reloads
|
|
90
|
+
* the page. @default false
|
|
91
|
+
*/
|
|
92
|
+
disableDefaultIdleCallback?: boolean
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export interface AuthenticationClientOptions {
|
|
96
|
+
/** Identity provider URL. @default "https://id.ai/authorize" */
|
|
97
|
+
identityProvider?: string | URL
|
|
98
|
+
/** `window.open` features string for the identity provider popup. */
|
|
99
|
+
windowOpenerFeatures?: string
|
|
100
|
+
/**
|
|
101
|
+
* Provider for one-click sign-in.
|
|
102
|
+
*
|
|
103
|
+
* Only the `"google" | "apple" | "microsoft"` aliases reach the auth client.
|
|
104
|
+
* Any other value is dropped here and has **no effect** — raw issuer URLs are
|
|
105
|
+
* only meaningful on `requestOpenId`, where they scope the requested keys.
|
|
106
|
+
* @see {@link IdentityAttributeOpenIdProvider}
|
|
107
|
+
*/
|
|
108
|
+
openIdProvider?: IdentityAttributeOpenIdProvider
|
|
109
|
+
/**
|
|
110
|
+
* Derivation origin for the identity provider.
|
|
111
|
+
*
|
|
112
|
+
* Required when the app is served from more than one origin (e.g. a custom
|
|
113
|
+
* domain plus `<canisterId>.icp0.io`) and every origin must resolve to the
|
|
114
|
+
* same principal.
|
|
115
|
+
* @see https://github.com/dfinity/internet-identity/blob/main/docs/internet-identity-spec.adoc
|
|
116
|
+
*/
|
|
117
|
+
derivationOrigin?: string | URL
|
|
118
|
+
/** Persistent storage backend. @default IndexedDB */
|
|
119
|
+
storage?: AuthClientStorageLike
|
|
120
|
+
/**
|
|
121
|
+
* Session key algorithm. Use `"Ed25519"` when the storage backend cannot
|
|
122
|
+
* hold a `CryptoKey`. @default "ECDSA"
|
|
123
|
+
*/
|
|
124
|
+
keyType?: AuthClientKeyType
|
|
125
|
+
/**
|
|
126
|
+
* Idle timeout configuration. Pass `{ disableIdle: true }` to opt out of the
|
|
127
|
+
* default behaviour, which signs the user out and reloads after 10 minutes.
|
|
128
|
+
*/
|
|
129
|
+
idleOptions?: AuthClientIdleOptions
|
|
130
|
+
/** An existing identity to authenticate via delegation. */
|
|
131
|
+
identity?: SignIdentity | PartialIdentity
|
|
132
|
+
/**
|
|
133
|
+
* How the client talks to the identity provider. `"redirect"` requires
|
|
134
|
+
* `@icp-sdk/auth` v8 or later and is ignored by older versions.
|
|
135
|
+
* @default "window"
|
|
136
|
+
*/
|
|
137
|
+
transport?: "window" | "redirect"
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export interface AuthClientSignInOptions {
|
|
141
|
+
maxTimeToLive?: bigint
|
|
142
|
+
targets?: Principal[]
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export interface AuthenticationSignInOptions
|
|
146
|
+
extends AuthClientSignInOptions, AuthenticationClientOptions {
|
|
147
|
+
onSuccess?: () => void | Promise<void>
|
|
148
|
+
onError?: (error?: string) => void | Promise<void>
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export interface RequestIdentityAttributesParameters extends AuthenticationClientOptions {
|
|
152
|
+
keys: string[]
|
|
153
|
+
nonce: IdentityAttributeNonce
|
|
154
|
+
/**
|
|
155
|
+
* Sign in as part of the same identity-provider interaction.
|
|
156
|
+
* @default true
|
|
157
|
+
*/
|
|
158
|
+
signIn?: boolean
|
|
159
|
+
maxTimeToLive?: bigint
|
|
160
|
+
targets?: Principal[]
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface RequestOpenIdIdentityAttributesParameters extends Omit<
|
|
164
|
+
RequestIdentityAttributesParameters,
|
|
165
|
+
"openIdProvider"
|
|
166
|
+
> {
|
|
167
|
+
/**
|
|
168
|
+
* Provider the requested `keys` are scoped to, producing
|
|
169
|
+
* `openid:<issuer>:<key>`.
|
|
170
|
+
*
|
|
171
|
+
* Passing one of the `"google" | "apple" | "microsoft"` aliases additionally
|
|
172
|
+
* routes sign-in through that provider, so the user grants attribute access
|
|
173
|
+
* in the same step. A raw issuer URL only scopes the keys.
|
|
174
|
+
* @see {@link IdentityAttributeOpenIdProvider}
|
|
175
|
+
*/
|
|
176
|
+
openIdProvider: IdentityAttributeOpenIdProvider
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Structural subset of `@icp-sdk/auth`'s `AuthClient` that IC Reactor relies
|
|
181
|
+
* on. Declared locally so `@icp-sdk/auth` stays an optional peer dependency.
|
|
182
|
+
*/
|
|
183
|
+
export interface AuthClientLike {
|
|
184
|
+
getIdentity(): Promise<Identity> | Identity
|
|
185
|
+
isAuthenticated(): Promise<boolean> | boolean
|
|
186
|
+
signIn(options?: AuthClientSignInOptions): Promise<Identity>
|
|
187
|
+
signOut(options?: { returnTo?: string }): Promise<void>
|
|
188
|
+
requestAttributes(params: {
|
|
189
|
+
keys: string[]
|
|
190
|
+
// Widened across `@icp-sdk/auth` v7 (value or promise) and v8 (thunk).
|
|
191
|
+
// Method-shorthand parameters are bivariant, so both real signatures are
|
|
192
|
+
// assignable to this one.
|
|
193
|
+
nonce: Uint8Array | Promise<Uint8Array> | (() => Promise<Uint8Array>)
|
|
194
|
+
}): Promise<SignedIdentityAttributes>
|
|
195
|
+
/** Present from `@icp-sdk/auth` v8; used to detect the nonce contract. */
|
|
196
|
+
memoize?<T>(produce: () => T | Promise<T>): Promise<T>
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export interface AuthState {
|
|
200
|
+
identity: Identity | null
|
|
201
|
+
isAuthenticating: boolean
|
|
202
|
+
isAuthenticated: boolean
|
|
203
|
+
error: Error | undefined
|
|
204
|
+
}
|
package/src/createActorHooks.ts
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
DisplayReactor,
|
|
22
22
|
ReactorReturnErr,
|
|
23
23
|
ReactorReturnOk,
|
|
24
|
+
ReactorQueryData,
|
|
24
25
|
BaseActor,
|
|
25
26
|
FunctionName,
|
|
26
27
|
TransformKey,
|
|
@@ -33,115 +34,146 @@ import {
|
|
|
33
34
|
UseMutationResult,
|
|
34
35
|
InfiniteData,
|
|
35
36
|
} from "@tanstack/react-query"
|
|
36
|
-
import { useActorQuery } from "./hooks/useActorQuery"
|
|
37
|
-
import { useActorSuspenseQuery } from "./hooks/useActorSuspenseQuery"
|
|
38
|
-
import { useActorInfiniteQuery } from "./hooks/useActorInfiniteQuery"
|
|
39
|
-
import { useActorSuspenseInfiniteQuery } from "./hooks/useActorSuspenseInfiniteQuery"
|
|
40
|
-
import { useActorMutation } from "./hooks/useActorMutation"
|
|
37
|
+
import { useActorQuery } from "./hooks/useActorQuery.js"
|
|
38
|
+
import { useActorSuspenseQuery } from "./hooks/useActorSuspenseQuery.js"
|
|
39
|
+
import { useActorInfiniteQuery } from "./hooks/useActorInfiniteQuery.js"
|
|
40
|
+
import { useActorSuspenseInfiniteQuery } from "./hooks/useActorSuspenseInfiniteQuery.js"
|
|
41
|
+
import { useActorMutation } from "./hooks/useActorMutation.js"
|
|
41
42
|
import {
|
|
42
43
|
useActorMethod,
|
|
43
44
|
UseActorMethodParameters,
|
|
44
|
-
} from "./hooks/useActorMethod"
|
|
45
|
-
import { InfiniteQueryConfig } from "./createInfiniteQuery"
|
|
46
|
-
import { SuspenseInfiniteQueryConfig } from "./createSuspenseInfiniteQuery"
|
|
47
|
-
import { QueryConfig, SuspenseQueryConfig, MutationConfig } from "./types"
|
|
45
|
+
} from "./hooks/useActorMethod.js"
|
|
46
|
+
import { InfiniteQueryConfig } from "./createInfiniteQuery.js"
|
|
47
|
+
import { SuspenseInfiniteQueryConfig } from "./createSuspenseInfiniteQuery.js"
|
|
48
|
+
import { QueryConfig, SuspenseQueryConfig, MutationConfig } from "./types.js"
|
|
48
49
|
|
|
49
|
-
export type ActorHooks<
|
|
50
|
+
export type ActorHooks<Service, Transform extends TransformKey> = {
|
|
50
51
|
useActorQuery: {
|
|
51
|
-
<
|
|
52
|
-
config: QueryConfig<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
52
|
+
<Method extends FunctionName<Service>>(
|
|
53
|
+
config: QueryConfig<
|
|
54
|
+
Service,
|
|
55
|
+
Method,
|
|
56
|
+
Transform,
|
|
57
|
+
ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>
|
|
58
|
+
>
|
|
59
|
+
): UseQueryResult<
|
|
60
|
+
ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>,
|
|
61
|
+
ReactorReturnErr<Service, Method, Transform>
|
|
62
|
+
>
|
|
63
|
+
<Method extends FunctionName<Service>, TData>(
|
|
64
|
+
config: QueryConfig<Service, Method, Transform, TData>
|
|
65
|
+
): UseQueryResult<TData, ReactorReturnErr<Service, Method, Transform>>
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
useActorSuspenseQuery: {
|
|
60
|
-
<
|
|
61
|
-
config: SuspenseQueryConfig<
|
|
69
|
+
<Method extends FunctionName<Service>>(
|
|
70
|
+
config: SuspenseQueryConfig<
|
|
71
|
+
Service,
|
|
72
|
+
Method,
|
|
73
|
+
Transform,
|
|
74
|
+
ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>
|
|
75
|
+
>
|
|
76
|
+
): UseSuspenseQueryResult<
|
|
77
|
+
ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>,
|
|
78
|
+
ReactorReturnErr<Service, Method, Transform>
|
|
79
|
+
>
|
|
80
|
+
<Method extends FunctionName<Service>, TData>(
|
|
81
|
+
config: SuspenseQueryConfig<Service, Method, Transform, TData>
|
|
62
82
|
): UseSuspenseQueryResult<
|
|
63
|
-
|
|
64
|
-
ReactorReturnErr<
|
|
83
|
+
TData,
|
|
84
|
+
ReactorReturnErr<Service, Method, Transform>
|
|
65
85
|
>
|
|
66
|
-
<M extends FunctionName<A>, TData>(
|
|
67
|
-
config: SuspenseQueryConfig<A, M, T, TData>
|
|
68
|
-
): UseSuspenseQueryResult<TData, ReactorReturnErr<A, M, T>>
|
|
69
86
|
}
|
|
70
87
|
|
|
71
|
-
useActorInfiniteQuery: <
|
|
72
|
-
|
|
88
|
+
useActorInfiniteQuery: <
|
|
89
|
+
Method extends FunctionName<Service>,
|
|
90
|
+
TPageParam = unknown,
|
|
91
|
+
>(
|
|
92
|
+
config: InfiniteQueryConfig<Service, Method, Transform, TPageParam>
|
|
73
93
|
) => UseInfiniteQueryResult<
|
|
74
|
-
InfiniteData<
|
|
75
|
-
|
|
94
|
+
InfiniteData<
|
|
95
|
+
ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>,
|
|
96
|
+
TPageParam
|
|
97
|
+
>,
|
|
98
|
+
ReactorReturnErr<Service, Method, Transform>
|
|
76
99
|
>
|
|
77
100
|
|
|
78
101
|
useActorSuspenseInfiniteQuery: <
|
|
79
|
-
|
|
102
|
+
Method extends FunctionName<Service>,
|
|
80
103
|
TPageParam = unknown,
|
|
81
104
|
>(
|
|
82
|
-
config: SuspenseInfiniteQueryConfig<
|
|
105
|
+
config: SuspenseInfiniteQueryConfig<Service, Method, Transform, TPageParam>
|
|
83
106
|
) => UseSuspenseInfiniteQueryResult<
|
|
84
|
-
InfiniteData<
|
|
85
|
-
|
|
107
|
+
InfiniteData<
|
|
108
|
+
ReactorQueryData<ReactorReturnOk<Service, Method, Transform>>,
|
|
109
|
+
TPageParam
|
|
110
|
+
>,
|
|
111
|
+
ReactorReturnErr<Service, Method, Transform>
|
|
86
112
|
>
|
|
87
113
|
|
|
88
|
-
useActorMutation: <
|
|
89
|
-
config: MutationConfig<
|
|
90
|
-
) => UseMutationResult<
|
|
114
|
+
useActorMutation: <Method extends FunctionName<Service>>(
|
|
115
|
+
config: MutationConfig<Service, Method, Transform>
|
|
116
|
+
) => UseMutationResult<
|
|
117
|
+
ReactorReturnOk<Service, Method, Transform>,
|
|
118
|
+
ReactorReturnErr<Service, Method, Transform>
|
|
119
|
+
>
|
|
91
120
|
|
|
92
|
-
useActorMethod: <
|
|
93
|
-
config: Omit<
|
|
94
|
-
|
|
121
|
+
useActorMethod: <Method extends FunctionName<Service>>(
|
|
122
|
+
config: Omit<
|
|
123
|
+
UseActorMethodParameters<Service, Method, Transform>,
|
|
124
|
+
"reactor"
|
|
125
|
+
>
|
|
126
|
+
) => ReturnType<typeof useActorMethod<Service, Method, Transform>>
|
|
95
127
|
}
|
|
96
128
|
|
|
97
|
-
export function createActorHooks<
|
|
98
|
-
reactor: DisplayReactor<
|
|
99
|
-
): ActorHooks<
|
|
129
|
+
export function createActorHooks<Service>(
|
|
130
|
+
reactor: DisplayReactor<Service>
|
|
131
|
+
): ActorHooks<Service, "display">
|
|
100
132
|
|
|
101
133
|
export function createActorHooks<
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
>(reactor: Reactor<
|
|
134
|
+
Service = BaseActor,
|
|
135
|
+
Transform extends TransformKey = "candid",
|
|
136
|
+
>(reactor: Reactor<Service, Transform>): ActorHooks<Service, Transform>
|
|
105
137
|
|
|
106
|
-
export function createActorHooks<
|
|
107
|
-
reactor: Reactor<
|
|
108
|
-
): ActorHooks<
|
|
138
|
+
export function createActorHooks<Service, Transform extends TransformKey>(
|
|
139
|
+
reactor: Reactor<Service, Transform>
|
|
140
|
+
): ActorHooks<Service, Transform> {
|
|
109
141
|
return {
|
|
110
142
|
useActorQuery: ((config: any) =>
|
|
111
143
|
useActorQuery({ ...config, reactor })) as ActorHooks<
|
|
112
|
-
|
|
113
|
-
|
|
144
|
+
Service,
|
|
145
|
+
Transform
|
|
114
146
|
>["useActorQuery"],
|
|
115
147
|
|
|
116
148
|
useActorSuspenseQuery: ((config: any) =>
|
|
117
149
|
useActorSuspenseQuery({ ...config, reactor })) as ActorHooks<
|
|
118
|
-
|
|
119
|
-
|
|
150
|
+
Service,
|
|
151
|
+
Transform
|
|
120
152
|
>["useActorSuspenseQuery"],
|
|
121
153
|
|
|
122
154
|
useActorInfiniteQuery: ((config: any) =>
|
|
123
155
|
useActorInfiniteQuery({ ...config, reactor })) as ActorHooks<
|
|
124
|
-
|
|
125
|
-
|
|
156
|
+
Service,
|
|
157
|
+
Transform
|
|
126
158
|
>["useActorInfiniteQuery"],
|
|
127
159
|
|
|
128
160
|
useActorSuspenseInfiniteQuery: ((config: any) =>
|
|
129
161
|
useActorSuspenseInfiniteQuery({ ...config, reactor })) as ActorHooks<
|
|
130
|
-
|
|
131
|
-
|
|
162
|
+
Service,
|
|
163
|
+
Transform
|
|
132
164
|
>["useActorSuspenseInfiniteQuery"],
|
|
133
165
|
|
|
134
166
|
useActorMutation: ((config: any) =>
|
|
135
167
|
useActorMutation({ ...config, reactor })) as ActorHooks<
|
|
136
|
-
|
|
137
|
-
|
|
168
|
+
Service,
|
|
169
|
+
Transform
|
|
138
170
|
>["useActorMutation"],
|
|
139
171
|
|
|
140
172
|
useActorMethod: (config) =>
|
|
141
173
|
useActorMethod({ ...config, reactor } as UseActorMethodParameters<
|
|
142
|
-
|
|
174
|
+
Service,
|
|
143
175
|
any,
|
|
144
|
-
|
|
176
|
+
Transform
|
|
145
177
|
>),
|
|
146
178
|
}
|
|
147
179
|
}
|