@fanapps/react-native 0.2.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 +324 -0
- package/dist/index.d.mts +238 -0
- package/dist/index.d.ts +238 -0
- package/dist/index.js +804 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +770 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +64 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { QueryClient, UseQueryResult, UseMutationResult } from '@tanstack/react-query';
|
|
3
|
+
import { ReactNode } from 'react';
|
|
4
|
+
|
|
5
|
+
interface StorageAdapter {
|
|
6
|
+
getItem(key: string): Promise<string | null>;
|
|
7
|
+
setItem(key: string, value: string): Promise<void>;
|
|
8
|
+
removeItem(key: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
type Locale = string;
|
|
12
|
+
type EntryData = Record<string, unknown>;
|
|
13
|
+
interface Entry {
|
|
14
|
+
id: string | number;
|
|
15
|
+
slug: string;
|
|
16
|
+
published: boolean;
|
|
17
|
+
date: string | null;
|
|
18
|
+
order: number | null;
|
|
19
|
+
collection: string | null;
|
|
20
|
+
blueprint: string;
|
|
21
|
+
data: EntryData;
|
|
22
|
+
created_at: string;
|
|
23
|
+
updated_at: string;
|
|
24
|
+
locale: Locale;
|
|
25
|
+
available_locales?: Locale[];
|
|
26
|
+
}
|
|
27
|
+
interface Article {
|
|
28
|
+
id: string | number;
|
|
29
|
+
title: string;
|
|
30
|
+
content: string;
|
|
31
|
+
is_published: boolean;
|
|
32
|
+
featured_image_url: string | null;
|
|
33
|
+
created_at: string;
|
|
34
|
+
updated_at: string;
|
|
35
|
+
locale: Locale;
|
|
36
|
+
available_locales?: Locale[];
|
|
37
|
+
}
|
|
38
|
+
interface TriviaAnswer {
|
|
39
|
+
id: string | number;
|
|
40
|
+
text: string;
|
|
41
|
+
is_correct: boolean;
|
|
42
|
+
sort_order: number;
|
|
43
|
+
}
|
|
44
|
+
interface Trivia {
|
|
45
|
+
id: string | number;
|
|
46
|
+
title: string;
|
|
47
|
+
description: string | null;
|
|
48
|
+
featured_image_id: string | number | null;
|
|
49
|
+
featured_image?: {
|
|
50
|
+
id: string | number;
|
|
51
|
+
url: string;
|
|
52
|
+
[key: string]: unknown;
|
|
53
|
+
} | null;
|
|
54
|
+
awards_points: boolean;
|
|
55
|
+
points_amount: number;
|
|
56
|
+
max_time_seconds: number | null;
|
|
57
|
+
show_correct_after: boolean;
|
|
58
|
+
starts_at: string | null;
|
|
59
|
+
ends_at: string | null;
|
|
60
|
+
answers: TriviaAnswer[];
|
|
61
|
+
responses_count?: number;
|
|
62
|
+
created_at: string;
|
|
63
|
+
updated_at: string;
|
|
64
|
+
}
|
|
65
|
+
interface TriviaResponseResult {
|
|
66
|
+
is_correct: boolean;
|
|
67
|
+
points_awarded: number;
|
|
68
|
+
correct_answer?: TriviaAnswer;
|
|
69
|
+
}
|
|
70
|
+
interface PaginationMeta {
|
|
71
|
+
current_page: number;
|
|
72
|
+
last_page: number;
|
|
73
|
+
per_page: number;
|
|
74
|
+
total: number;
|
|
75
|
+
from: number | null;
|
|
76
|
+
to: number | null;
|
|
77
|
+
path?: string;
|
|
78
|
+
}
|
|
79
|
+
interface PaginationLinks {
|
|
80
|
+
first: string | null;
|
|
81
|
+
last: string | null;
|
|
82
|
+
prev: string | null;
|
|
83
|
+
next: string | null;
|
|
84
|
+
}
|
|
85
|
+
interface Paginated<T> {
|
|
86
|
+
data: T[];
|
|
87
|
+
meta: PaginationMeta;
|
|
88
|
+
links: PaginationLinks;
|
|
89
|
+
}
|
|
90
|
+
interface PaginationParams {
|
|
91
|
+
page?: number;
|
|
92
|
+
perPage?: number;
|
|
93
|
+
sort?: string;
|
|
94
|
+
}
|
|
95
|
+
interface EntryFilters extends PaginationParams {
|
|
96
|
+
blueprint?: string;
|
|
97
|
+
collection?: string;
|
|
98
|
+
slug?: string;
|
|
99
|
+
published?: boolean;
|
|
100
|
+
}
|
|
101
|
+
interface ArticleFilters extends PaginationParams {
|
|
102
|
+
is_published?: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface HookOptions {
|
|
105
|
+
locale?: Locale;
|
|
106
|
+
enabled?: boolean;
|
|
107
|
+
}
|
|
108
|
+
type AuthStatus = 'loading' | 'signed-in' | 'signed-out';
|
|
109
|
+
interface AuthUser {
|
|
110
|
+
uid: string;
|
|
111
|
+
email: string | null;
|
|
112
|
+
displayName: string | null;
|
|
113
|
+
photoURL: string | null;
|
|
114
|
+
phoneNumber: string | null;
|
|
115
|
+
isAnonymous: boolean;
|
|
116
|
+
providerId: string | null;
|
|
117
|
+
}
|
|
118
|
+
interface PushTarget {
|
|
119
|
+
id: string;
|
|
120
|
+
app_user_id: number | string | null;
|
|
121
|
+
identifier: string;
|
|
122
|
+
provider: 'fcm' | 'apns';
|
|
123
|
+
provider_id: string | null;
|
|
124
|
+
device_brand: string | null;
|
|
125
|
+
device_model: string | null;
|
|
126
|
+
os_name: string | null;
|
|
127
|
+
os_version: string | null;
|
|
128
|
+
last_seen_at: string | null;
|
|
129
|
+
created_at: string;
|
|
130
|
+
updated_at: string;
|
|
131
|
+
}
|
|
132
|
+
interface CreatePushTargetInput {
|
|
133
|
+
targetId: string;
|
|
134
|
+
identifier: string;
|
|
135
|
+
providerId?: string;
|
|
136
|
+
deviceBrand?: string;
|
|
137
|
+
deviceModel?: string;
|
|
138
|
+
osName?: string;
|
|
139
|
+
osVersion?: string;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
interface FanappsProviderProps {
|
|
143
|
+
apiKey: string;
|
|
144
|
+
project: string;
|
|
145
|
+
locale?: Locale;
|
|
146
|
+
baseUrl?: string;
|
|
147
|
+
queryClient?: QueryClient;
|
|
148
|
+
storage?: StorageAdapter;
|
|
149
|
+
children: ReactNode;
|
|
150
|
+
}
|
|
151
|
+
declare function FanappsProvider({ apiKey, project, locale, baseUrl, queryClient, storage, children, }: FanappsProviderProps): react_jsx_runtime.JSX.Element;
|
|
152
|
+
|
|
153
|
+
interface FanappsClientOptions {
|
|
154
|
+
apiKey: string;
|
|
155
|
+
project: string;
|
|
156
|
+
baseUrl: string;
|
|
157
|
+
getIdToken?: () => Promise<string | null>;
|
|
158
|
+
}
|
|
159
|
+
type QueryParams = Record<string, unknown>;
|
|
160
|
+
declare class FanappsClient {
|
|
161
|
+
private readonly apiKey;
|
|
162
|
+
private readonly project;
|
|
163
|
+
private readonly baseUrl;
|
|
164
|
+
private readonly getIdToken?;
|
|
165
|
+
constructor(options: FanappsClientOptions);
|
|
166
|
+
get<T>(path: string, params?: QueryParams, signal?: AbortSignal): Promise<T>;
|
|
167
|
+
post<T>(path: string, body?: unknown, signal?: AbortSignal): Promise<T>;
|
|
168
|
+
patch<T>(path: string, body?: unknown, signal?: AbortSignal): Promise<T>;
|
|
169
|
+
delete<T>(path: string, signal?: AbortSignal): Promise<T>;
|
|
170
|
+
createPushTarget(input: CreatePushTargetInput): Promise<PushTarget>;
|
|
171
|
+
updatePushTarget(targetId: string, identifier: string): Promise<PushTarget>;
|
|
172
|
+
deletePushTarget(targetId: string): Promise<void>;
|
|
173
|
+
private request;
|
|
174
|
+
private buildUrl;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
declare class FanappsError extends Error {
|
|
178
|
+
readonly status: number;
|
|
179
|
+
readonly body: unknown;
|
|
180
|
+
constructor(message: string, status: number, body: unknown);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
declare class FanappsAuthError extends Error {
|
|
184
|
+
readonly code: string;
|
|
185
|
+
constructor(message: string, code: string);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
declare function useFanappsClient(): FanappsClient;
|
|
189
|
+
|
|
190
|
+
interface UseAuthResult {
|
|
191
|
+
user: AuthUser | null;
|
|
192
|
+
status: AuthStatus;
|
|
193
|
+
signInWithEmail(email: string, password: string): Promise<AuthUser>;
|
|
194
|
+
signUpWithEmail(email: string, password: string): Promise<AuthUser>;
|
|
195
|
+
sendPasswordResetEmail(email: string): Promise<void>;
|
|
196
|
+
sendEmailVerification(): Promise<void>;
|
|
197
|
+
signInWithGoogle(): Promise<AuthUser>;
|
|
198
|
+
signInWithApple(): Promise<AuthUser>;
|
|
199
|
+
signOut(): Promise<void>;
|
|
200
|
+
}
|
|
201
|
+
declare function useAuth(): UseAuthResult;
|
|
202
|
+
|
|
203
|
+
declare function useEntries(filters?: EntryFilters, options?: HookOptions): UseQueryResult<Paginated<Entry>>;
|
|
204
|
+
|
|
205
|
+
declare function useEntry(id: string | number | null | undefined, options?: HookOptions): UseQueryResult<Entry>;
|
|
206
|
+
|
|
207
|
+
declare function useArticles(filters?: ArticleFilters, options?: HookOptions): UseQueryResult<Paginated<Article>>;
|
|
208
|
+
|
|
209
|
+
declare function useArticle(id: string | number | null | undefined, options?: HookOptions): UseQueryResult<Article>;
|
|
210
|
+
|
|
211
|
+
interface UseRegisterDeviceResult {
|
|
212
|
+
targetId: string | null;
|
|
213
|
+
token: string | null;
|
|
214
|
+
target: PushTarget | null;
|
|
215
|
+
isRegistering: boolean;
|
|
216
|
+
error: Error | null;
|
|
217
|
+
register(): Promise<PushTarget>;
|
|
218
|
+
unregister(): Promise<void>;
|
|
219
|
+
}
|
|
220
|
+
declare function useRegisterDevice(): UseRegisterDeviceResult;
|
|
221
|
+
|
|
222
|
+
declare function useTrivias(options?: HookOptions): UseQueryResult<Trivia[]>;
|
|
223
|
+
|
|
224
|
+
declare function useTrivia(id: string | number | null | undefined, options?: HookOptions): UseQueryResult<Trivia>;
|
|
225
|
+
|
|
226
|
+
interface SubmitTriviaResponseInput {
|
|
227
|
+
triviaId: string | number;
|
|
228
|
+
answerId: string | number;
|
|
229
|
+
}
|
|
230
|
+
declare function useSubmitTriviaResponse(): UseMutationResult<TriviaResponseResult, FanappsError, SubmitTriviaResponseInput>;
|
|
231
|
+
|
|
232
|
+
interface UseTopicSubscriptionResult {
|
|
233
|
+
subscribe(topic: string): Promise<void>;
|
|
234
|
+
unsubscribe(topic: string): Promise<void>;
|
|
235
|
+
}
|
|
236
|
+
declare function useTopicSubscription(): UseTopicSubscriptionResult;
|
|
237
|
+
|
|
238
|
+
export { type Article, type ArticleFilters, type AuthStatus, type AuthUser, type CreatePushTargetInput, type Entry, type EntryData, type EntryFilters, FanappsAuthError, FanappsClient, type FanappsClientOptions, FanappsError, FanappsProvider, type FanappsProviderProps, type HookOptions, type Locale, type Paginated, type PaginationLinks, type PaginationMeta, type PaginationParams, type PushTarget, type StorageAdapter, type SubmitTriviaResponseInput, type Trivia, type TriviaAnswer, type TriviaResponseResult, type UseAuthResult, type UseRegisterDeviceResult, type UseTopicSubscriptionResult, useArticle, useArticles, useAuth, useEntries, useEntry, useFanappsClient, useRegisterDevice, useSubmitTriviaResponse, useTopicSubscription, useTrivia, useTrivias };
|