svelte-firekit 0.1.4 → 0.1.6
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/components/Collection.svelte +49 -77
- package/dist/components/Doc.svelte +140 -0
- package/dist/components/{Ddoc.svelte.d.ts → Doc.svelte.d.ts} +3 -3
- package/dist/components/upload-task.svelte +1 -1
- package/dist/firebase.d.ts +9 -0
- package/dist/firebase.js +24 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +3 -1
- package/dist/services/analytics.d.ts +272 -0
- package/dist/services/analytics.js +476 -0
- package/dist/services/auth.d.ts +26 -21
- package/dist/services/auth.js +93 -22
- package/dist/services/collection.svelte.d.ts +1 -14
- package/dist/services/collection.svelte.js +10 -85
- package/dist/services/index.d.ts +9 -0
- package/dist/services/index.js +10 -0
- package/dist/services/mutations.d.ts +5 -37
- package/dist/services/mutations.js +43 -140
- package/dist/services/presence.svelte.d.ts +1 -22
- package/dist/services/presence.svelte.js +1 -101
- package/dist/types/analytics.d.ts +84 -0
- package/dist/types/analytics.js +6 -0
- package/dist/types/auth.d.ts +65 -7
- package/dist/types/collection.d.ts +0 -25
- package/dist/types/firebase.d.ts +2 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/mutations.d.ts +0 -22
- package/dist/types/presence.d.ts +0 -20
- package/package.json +1 -1
- package/dist/components/Ddoc.svelte +0 -131
package/dist/types/auth.d.ts
CHANGED
|
@@ -37,6 +37,46 @@ export interface AuthState {
|
|
|
37
37
|
loading: boolean;
|
|
38
38
|
initialized: boolean;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Base authentication result interface
|
|
42
|
+
*/
|
|
43
|
+
export interface AuthResult {
|
|
44
|
+
success: boolean;
|
|
45
|
+
user: UserProfile;
|
|
46
|
+
method: AuthMethodType;
|
|
47
|
+
timestamp: Date;
|
|
48
|
+
additionalData?: Record<string, any>;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Sign-in result interface
|
|
52
|
+
*/
|
|
53
|
+
export interface SignInResult extends AuthResult {
|
|
54
|
+
isNewUser: boolean;
|
|
55
|
+
requiresEmailVerification?: boolean;
|
|
56
|
+
requiresPhoneVerification?: boolean;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Registration result interface
|
|
60
|
+
*/
|
|
61
|
+
export interface RegistrationResult extends AuthResult {
|
|
62
|
+
emailVerificationSent: boolean;
|
|
63
|
+
requiresEmailVerification: boolean;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* OAuth sign-in result interface
|
|
67
|
+
*/
|
|
68
|
+
export interface OAuthSignInResult extends SignInResult {
|
|
69
|
+
provider: OAuthProviderType;
|
|
70
|
+
accessToken?: string;
|
|
71
|
+
refreshToken?: string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Phone verification result interface
|
|
75
|
+
*/
|
|
76
|
+
export interface PhoneVerificationResult {
|
|
77
|
+
verificationId: string;
|
|
78
|
+
confirm: (code: string) => Promise<SignInResult>;
|
|
79
|
+
}
|
|
40
80
|
/**
|
|
41
81
|
* Password update result interface
|
|
42
82
|
*/
|
|
@@ -52,13 +92,6 @@ export interface AccountDeletionResult {
|
|
|
52
92
|
success: boolean;
|
|
53
93
|
message: string;
|
|
54
94
|
}
|
|
55
|
-
/**
|
|
56
|
-
* Phone verification result interface
|
|
57
|
-
*/
|
|
58
|
-
export interface PhoneVerificationResult {
|
|
59
|
-
verificationId: string;
|
|
60
|
-
confirm: (code: string) => Promise<UserProfile>;
|
|
61
|
-
}
|
|
62
95
|
/**
|
|
63
96
|
* User registration data interface
|
|
64
97
|
*/
|
|
@@ -75,6 +108,31 @@ export interface UserProfileUpdateData {
|
|
|
75
108
|
displayName?: string;
|
|
76
109
|
photoURL?: string;
|
|
77
110
|
}
|
|
111
|
+
/**
|
|
112
|
+
* Profile update result interface
|
|
113
|
+
*/
|
|
114
|
+
export interface ProfileUpdateResult {
|
|
115
|
+
success: boolean;
|
|
116
|
+
user: UserProfile;
|
|
117
|
+
updatedFields: string[];
|
|
118
|
+
message: string;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Email verification result interface
|
|
122
|
+
*/
|
|
123
|
+
export interface EmailVerificationResult {
|
|
124
|
+
success: boolean;
|
|
125
|
+
message: string;
|
|
126
|
+
emailSent: boolean;
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Password reset result interface
|
|
130
|
+
*/
|
|
131
|
+
export interface PasswordResetResult {
|
|
132
|
+
success: boolean;
|
|
133
|
+
message: string;
|
|
134
|
+
emailSent: boolean;
|
|
135
|
+
}
|
|
78
136
|
/**
|
|
79
137
|
* OAuth provider types
|
|
80
138
|
*/
|
|
@@ -133,31 +133,6 @@ export interface DocumentChange<T> {
|
|
|
133
133
|
/** Change timestamp */
|
|
134
134
|
timestamp: Date;
|
|
135
135
|
}
|
|
136
|
-
/**
|
|
137
|
-
* Collection event types
|
|
138
|
-
*/
|
|
139
|
-
export type CollectionEventType = 'data_changed' | 'document_added' | 'document_modified' | 'document_removed' | 'error' | 'loading_started' | 'loading_finished' | 'query_changed' | 'cache_hit' | 'cache_miss';
|
|
140
|
-
/**
|
|
141
|
-
* Collection event interface
|
|
142
|
-
*/
|
|
143
|
-
export interface CollectionEvent<T> {
|
|
144
|
-
/** Event type */
|
|
145
|
-
type: CollectionEventType;
|
|
146
|
-
/** Event data */
|
|
147
|
-
data?: any;
|
|
148
|
-
/** Document changes */
|
|
149
|
-
changes?: DocumentChange<T>[];
|
|
150
|
-
/** Error if applicable */
|
|
151
|
-
error?: CollectionError;
|
|
152
|
-
/** Event timestamp */
|
|
153
|
-
timestamp: Date;
|
|
154
|
-
/** Collection path */
|
|
155
|
-
path?: string;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Collection event callback function type
|
|
159
|
-
*/
|
|
160
|
-
export type CollectionEventCallback<T> = (event: CollectionEvent<T>) => void;
|
|
161
136
|
/**
|
|
162
137
|
* Collection metadata interface
|
|
163
138
|
*/
|
package/dist/types/firebase.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { Auth } from 'firebase/auth';
|
|
|
4
4
|
import type { Functions } from 'firebase/functions';
|
|
5
5
|
import type { Database } from 'firebase/database';
|
|
6
6
|
import type { FirebaseStorage } from 'firebase/storage';
|
|
7
|
+
import type { Analytics } from 'firebase/analytics';
|
|
7
8
|
/**
|
|
8
9
|
* Type definition for required Firebase environment variables
|
|
9
10
|
*/
|
|
@@ -38,6 +39,7 @@ export interface FirebaseServiceInstance {
|
|
|
38
39
|
functions: Functions | null;
|
|
39
40
|
database: Database | null;
|
|
40
41
|
storage: FirebaseStorage | null;
|
|
42
|
+
analytics: Analytics | null;
|
|
41
43
|
status: FirebaseServiceStatus;
|
|
42
44
|
initializationError: Error | null;
|
|
43
45
|
isBrowser: boolean;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from './auth.js';
|
|
2
|
+
export * from './analytics.js';
|
|
2
3
|
export * from './firebase.js';
|
|
3
4
|
export type { CollectionState, CollectionOptions, PaginationConfig, CacheConfig, ErrorHandlingConfig, QueryBuilder, FirestoreOperator, CollectionChangeType, DocumentChange, CollectionEventType, CollectionEvent, CollectionEventCallback, CollectionMetadata, CollectionStats, CollectionErrorCode, CollectionError, CollectionSubscription, CollectionQueryResult, CollectionAggregation, ListenerConfig as CollectionListenerConfig, CollectionPerformanceMetrics } from './collection.js';
|
|
4
5
|
export type { DocumentState, DocumentOptions, MutationOptions as DocumentMutationOptions, MutationResponse as DocumentMutationResponse, BatchOperation as DocumentBatchOperation, BatchResult as DocumentBatchResult, ListenerConfig as DocumentListenerConfig, CacheEntry, CacheSource, DocumentErrorCode, DocumentError, DocumentFieldValue, DocumentUpdateData, DocumentMetadata, DocumentSnapshot, DocumentQueryConstraint, DocumentObserver, DocumentSubscription, DocumentAnalytics, DocumentPerformanceMetrics } from './document.js';
|
package/dist/types/index.js
CHANGED
|
@@ -330,28 +330,6 @@ export declare class MutationError extends Error {
|
|
|
330
330
|
/**
|
|
331
331
|
* Mutation event types for tracking operations
|
|
332
332
|
*/
|
|
333
|
-
export type MutationEventType = 'mutation_start' | 'mutation_success' | 'mutation_error' | 'mutation_retry' | 'batch_start' | 'batch_progress' | 'batch_complete' | 'validation_failed' | 'optimistic_update' | 'rollback';
|
|
334
|
-
/**
|
|
335
|
-
* Mutation event interface
|
|
336
|
-
*/
|
|
337
|
-
export interface MutationEvent {
|
|
338
|
-
/** Event type */
|
|
339
|
-
type: MutationEventType;
|
|
340
|
-
/** Event data */
|
|
341
|
-
data?: any;
|
|
342
|
-
/** Error if applicable */
|
|
343
|
-
error?: MutationError;
|
|
344
|
-
/** Event timestamp */
|
|
345
|
-
timestamp: Date;
|
|
346
|
-
/** Operation ID for tracking */
|
|
347
|
-
operationId?: string;
|
|
348
|
-
/** User who triggered the event */
|
|
349
|
-
userId?: string;
|
|
350
|
-
}
|
|
351
|
-
/**
|
|
352
|
-
* Mutation event callback function type
|
|
353
|
-
*/
|
|
354
|
-
export type MutationEventCallback = (event: MutationEvent) => void;
|
|
355
333
|
/**
|
|
356
334
|
* Mutation analytics data
|
|
357
335
|
*/
|
package/dist/types/presence.d.ts
CHANGED
|
@@ -113,25 +113,6 @@ export interface PresenceStats {
|
|
|
113
113
|
averageSessionDuration: number;
|
|
114
114
|
lastActivity: string;
|
|
115
115
|
}
|
|
116
|
-
/**
|
|
117
|
-
* Presence event types
|
|
118
|
-
*/
|
|
119
|
-
export type PresenceEventType = 'status_change' | 'session_created' | 'session_updated' | 'session_expired' | 'location_update' | 'location_error' | 'error' | 'init' | 'disconnect' | 'reconnect' | 'consent_requested' | 'consent_granted' | 'consent_denied' | 'device_detected' | 'visibility_change';
|
|
120
|
-
/**
|
|
121
|
-
* Presence event structure
|
|
122
|
-
*/
|
|
123
|
-
export interface PresenceEvent {
|
|
124
|
-
type: PresenceEventType;
|
|
125
|
-
data?: any;
|
|
126
|
-
error?: Error;
|
|
127
|
-
timestamp: number;
|
|
128
|
-
sessionId?: string;
|
|
129
|
-
userId?: string;
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Presence event callback function type
|
|
133
|
-
*/
|
|
134
|
-
export type PresenceEventCallback = (event: PresenceEvent) => void;
|
|
135
116
|
/**
|
|
136
117
|
* Geolocation provider interface
|
|
137
118
|
*/
|
|
@@ -159,7 +140,6 @@ export interface PresenceService {
|
|
|
159
140
|
getCurrentSession(): SessionData | null;
|
|
160
141
|
getAllSessions(): SessionData[];
|
|
161
142
|
getPresenceStats(): PresenceStats;
|
|
162
|
-
addEventListener(callback: PresenceEventCallback): () => void;
|
|
163
143
|
dispose(): Promise<void>;
|
|
164
144
|
}
|
|
165
145
|
/**
|
package/package.json
CHANGED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
<script lang="ts">
|
|
2
|
-
import { firekitDoc } from '../services/document.svelte.js';
|
|
3
|
-
import { firebaseService } from '../firebase.js';
|
|
4
|
-
import { doc } from 'firebase/firestore';
|
|
5
|
-
import { browser } from '$app/environment';
|
|
6
|
-
import { onDestroy } from 'svelte';
|
|
7
|
-
import type { DocumentReference, DocumentData, Firestore } from 'firebase/firestore';
|
|
8
|
-
import type { Snippet } from 'svelte';
|
|
9
|
-
import type { DocumentOptions } from '../types/document.js';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Props for Doc component
|
|
13
|
-
*/
|
|
14
|
-
let {
|
|
15
|
-
ref,
|
|
16
|
-
startWith,
|
|
17
|
-
children,
|
|
18
|
-
loading,
|
|
19
|
-
options = {}
|
|
20
|
-
}: {
|
|
21
|
-
/**
|
|
22
|
-
* Firestore document reference or path string
|
|
23
|
-
*/
|
|
24
|
-
ref: DocumentReference | string;
|
|
25
|
-
/**
|
|
26
|
-
* Initial value to use before document is fetched
|
|
27
|
-
*/
|
|
28
|
-
startWith?: DocumentData | null;
|
|
29
|
-
/**
|
|
30
|
-
* Content to render when document is loaded
|
|
31
|
-
*/
|
|
32
|
-
children: Snippet<[DocumentData | null, DocumentReference, Firestore]>;
|
|
33
|
-
/**
|
|
34
|
-
* Content to render while loading
|
|
35
|
-
*/
|
|
36
|
-
loading?: Snippet<[]>;
|
|
37
|
-
/**
|
|
38
|
-
* Document options for configuration
|
|
39
|
-
*/
|
|
40
|
-
options?: DocumentOptions;
|
|
41
|
-
} = $props();
|
|
42
|
-
|
|
43
|
-
// Get Firestore instance only in browser environment
|
|
44
|
-
let firestore: Firestore | null = $state(null);
|
|
45
|
-
let docRef: DocumentReference | null = $state(null);
|
|
46
|
-
let documentService: any = $state(null);
|
|
47
|
-
|
|
48
|
-
// Reactive document state
|
|
49
|
-
let componentState = $state({
|
|
50
|
-
loading: true,
|
|
51
|
-
data: null as DocumentData | null,
|
|
52
|
-
error: null as Error | null,
|
|
53
|
-
exists: false
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// Initialize in browser environment
|
|
57
|
-
$effect(() => {
|
|
58
|
-
if (!browser) return;
|
|
59
|
-
|
|
60
|
-
firestore = firebaseService.getDbInstance();
|
|
61
|
-
if (!firestore) {
|
|
62
|
-
throw new Error('Firestore instance not available');
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
// Create document reference if path string is provided
|
|
66
|
-
docRef = typeof ref === 'string' ? doc(firestore, ref) : ref;
|
|
67
|
-
|
|
68
|
-
// Create document service
|
|
69
|
-
documentService = firekitDoc(docRef.path, startWith ?? undefined, options);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
// Subscribe to document changes only if in browser and document service exists
|
|
73
|
-
$effect(() => {
|
|
74
|
-
if (!browser || !documentService) {
|
|
75
|
-
componentState = {
|
|
76
|
-
loading: false,
|
|
77
|
-
data: startWith ?? null,
|
|
78
|
-
error: null,
|
|
79
|
-
exists: !!startWith
|
|
80
|
-
};
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Update component state based on document service state
|
|
85
|
-
componentState = {
|
|
86
|
-
loading: documentService.loading,
|
|
87
|
-
data: documentService.data,
|
|
88
|
-
error: documentService.error,
|
|
89
|
-
exists: documentService.exists
|
|
90
|
-
};
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
// Cleanup on component destruction
|
|
94
|
-
onDestroy(() => {
|
|
95
|
-
if (documentService) {
|
|
96
|
-
documentService.dispose();
|
|
97
|
-
}
|
|
98
|
-
});
|
|
99
|
-
</script>
|
|
100
|
-
|
|
101
|
-
{#if !browser}
|
|
102
|
-
{@render children(startWith ?? null, null as any, null as any)}
|
|
103
|
-
{:else if componentState.loading}
|
|
104
|
-
{#if loading}
|
|
105
|
-
{@render loading()}
|
|
106
|
-
{:else}
|
|
107
|
-
<div class="flex items-center justify-center min-h-screen">
|
|
108
|
-
<div class="text-center">
|
|
109
|
-
<div class="animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900 mx-auto"></div>
|
|
110
|
-
<p class="mt-2 text-gray-600">Loading document...</p>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
{/if}
|
|
114
|
-
{:else if componentState.error}
|
|
115
|
-
<div class="flex items-center justify-center min-h-screen">
|
|
116
|
-
<div class="text-center">
|
|
117
|
-
<div class="text-red-500 text-lg font-semibold mb-2">Error Loading Document</div>
|
|
118
|
-
<p class="text-gray-600 mb-4">{componentState.error.message}</p>
|
|
119
|
-
{#if documentService?.canRefresh}
|
|
120
|
-
<button
|
|
121
|
-
class="px-4 py-2 bg-blue-500 text-white rounded hover:bg-blue-600"
|
|
122
|
-
onclick={() => documentService?.refresh()}
|
|
123
|
-
>
|
|
124
|
-
Retry
|
|
125
|
-
</button>
|
|
126
|
-
{/if}
|
|
127
|
-
</div>
|
|
128
|
-
</div>
|
|
129
|
-
{:else}
|
|
130
|
-
{@render children(componentState.data ?? null, docRef!, firestore!)}
|
|
131
|
-
{/if}
|