web-manager 4.1.6 → 4.1.8
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/CLAUDE.md +0 -1
- package/dist/index.js +3 -0
- package/dist/modules/auth.js +59 -1
- package/dist/modules/firestore.js +16 -7
- package/package.json +6 -7
- package/firebase-debug.log +0 -828
package/CLAUDE.md
CHANGED
|
@@ -257,7 +257,6 @@ Current test coverage is minimal - focuses on configuration and storage.
|
|
|
257
257
|
| `firebase` (^12.x) | Auth, Firestore, Messaging |
|
|
258
258
|
| `@sentry/browser` (^10.x) | Error tracking |
|
|
259
259
|
| `lodash` (^4.x) | get/set for path-based access |
|
|
260
|
-
| `resolve-account` (^2.x) | Account data resolution |
|
|
261
260
|
| `itwcw-package-analytics` | Analytics (internal) |
|
|
262
261
|
|
|
263
262
|
## Important Notes
|
package/dist/index.js
CHANGED
package/dist/modules/auth.js
CHANGED
|
@@ -1,4 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
const DEFAULT_ACCOUNT = {
|
|
2
|
+
auth: { uid: null, email: null, temporary: false },
|
|
3
|
+
subscription: {
|
|
4
|
+
product: { id: 'basic', name: 'Basic' },
|
|
5
|
+
status: 'active',
|
|
6
|
+
expires: { timestamp: null, timestampUNIX: null },
|
|
7
|
+
trial: { activated: false, expires: { timestamp: null, timestampUNIX: null } },
|
|
8
|
+
cancellation: { pending: false, date: { timestamp: null, timestampUNIX: null } },
|
|
9
|
+
payment: {
|
|
10
|
+
processor: null,
|
|
11
|
+
resourceId: null,
|
|
12
|
+
frequency: null,
|
|
13
|
+
startDate: { timestamp: null, timestampUNIX: null },
|
|
14
|
+
updatedBy: {
|
|
15
|
+
event: { name: null, id: null },
|
|
16
|
+
date: { timestamp: null, timestampUNIX: null },
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
roles: { admin: false, betaTester: false, developer: false },
|
|
21
|
+
affiliate: { code: null, referrals: [] },
|
|
22
|
+
activity: {
|
|
23
|
+
lastActivity: { timestamp: null, timestampUNIX: null },
|
|
24
|
+
created: { timestamp: null, timestampUNIX: null },
|
|
25
|
+
},
|
|
26
|
+
api: { clientId: null, privateKey: null },
|
|
27
|
+
usage: { requests: { total: 0, period: 0 } },
|
|
28
|
+
personal: { name: { first: '', last: '' } },
|
|
29
|
+
oauth2: {},
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
function resolveAccount(rawData, firebaseUser) {
|
|
33
|
+
const user = firebaseUser || {};
|
|
34
|
+
const data = rawData || {};
|
|
35
|
+
|
|
36
|
+
// Deep merge: rawData values take precedence over defaults
|
|
37
|
+
function deepMerge(target, source) {
|
|
38
|
+
const result = { ...target };
|
|
39
|
+
for (const key in source) {
|
|
40
|
+
if (!source.hasOwnProperty(key)) continue;
|
|
41
|
+
if (result[key] === null || result[key] === undefined) {
|
|
42
|
+
result[key] = source[key];
|
|
43
|
+
} else if (typeof result[key] === 'object' && !Array.isArray(result[key])
|
|
44
|
+
&& typeof source[key] === 'object' && !Array.isArray(source[key])) {
|
|
45
|
+
result[key] = deepMerge(result[key], source[key]);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return result;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const account = deepMerge(data, DEFAULT_ACCOUNT);
|
|
52
|
+
|
|
53
|
+
// Set auth from firebase user if not already set
|
|
54
|
+
account.auth = account.auth || {};
|
|
55
|
+
account.auth.uid = account.auth.uid || user.uid || null;
|
|
56
|
+
account.auth.email = account.auth.email || user.email || null;
|
|
57
|
+
|
|
58
|
+
return account;
|
|
59
|
+
}
|
|
2
60
|
|
|
3
61
|
class Auth {
|
|
4
62
|
constructor(manager) {
|
|
@@ -27,7 +27,7 @@ class Firestore {
|
|
|
27
27
|
|
|
28
28
|
// Dynamically import Firestore
|
|
29
29
|
const { getFirestore, doc: firestoreDoc, collection: firestoreCollection, getDoc, setDoc, updateDoc, deleteDoc, getDocs, query, where, orderBy, limit, startAt, endAt } = await import('firebase/firestore');
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
// Store references for later use
|
|
32
32
|
this._firestoreMethods = {
|
|
33
33
|
getFirestore,
|
|
@@ -48,6 +48,15 @@ class Firestore {
|
|
|
48
48
|
|
|
49
49
|
// Initialize Firestore
|
|
50
50
|
this._db = getFirestore(this.manager._firebaseApp);
|
|
51
|
+
|
|
52
|
+
// Connect to Firestore emulator in development
|
|
53
|
+
if (this.manager.isDevelopment() && this.manager.config.env?.FIREBASE_EMULATOR_CONNECT) {
|
|
54
|
+
console.log('[Firestore] Connecting to emulator at localhost:8080');
|
|
55
|
+
const { connectFirestoreEmulator } = await import('firebase/firestore');
|
|
56
|
+
connectFirestoreEmulator(this._db, 'localhost', 8080);
|
|
57
|
+
console.log('[Firestore] Emulator connected');
|
|
58
|
+
}
|
|
59
|
+
|
|
51
60
|
this._initialized = true;
|
|
52
61
|
|
|
53
62
|
return this._db;
|
|
@@ -78,7 +87,7 @@ class Firestore {
|
|
|
78
87
|
await self._ensureInitialized();
|
|
79
88
|
const docRef = self._firestoreMethods.doc(self._db, docPath);
|
|
80
89
|
const docSnap = await self._firestoreMethods.getDoc(docRef);
|
|
81
|
-
|
|
90
|
+
|
|
82
91
|
return {
|
|
83
92
|
exists: () => docSnap.exists(),
|
|
84
93
|
data: () => docSnap.data(),
|
|
@@ -110,13 +119,13 @@ class Firestore {
|
|
|
110
119
|
// Collection method for queries
|
|
111
120
|
collection(collectionPath) {
|
|
112
121
|
const self = this;
|
|
113
|
-
|
|
122
|
+
|
|
114
123
|
return {
|
|
115
124
|
async get() {
|
|
116
125
|
await self._ensureInitialized();
|
|
117
126
|
const collRef = self._firestoreMethods.collection(self._db, collectionPath);
|
|
118
127
|
const querySnapshot = await self._firestoreMethods.getDocs(collRef);
|
|
119
|
-
|
|
128
|
+
|
|
120
129
|
return {
|
|
121
130
|
docs: querySnapshot.docs.map(doc => ({
|
|
122
131
|
id: doc.id,
|
|
@@ -185,7 +194,7 @@ class Firestore {
|
|
|
185
194
|
async get() {
|
|
186
195
|
await self._ensureInitialized();
|
|
187
196
|
const collRef = self._firestoreMethods.collection(self._db, collectionPath);
|
|
188
|
-
|
|
197
|
+
|
|
189
198
|
// Build query constraints
|
|
190
199
|
const queryConstraints = [];
|
|
191
200
|
for (const constraint of constraints) {
|
|
@@ -210,7 +219,7 @@ class Firestore {
|
|
|
210
219
|
|
|
211
220
|
const q = self._firestoreMethods.query(collRef, ...queryConstraints);
|
|
212
221
|
const querySnapshot = await self._firestoreMethods.getDocs(q);
|
|
213
|
-
|
|
222
|
+
|
|
214
223
|
return {
|
|
215
224
|
docs: querySnapshot.docs.map(doc => ({
|
|
216
225
|
id: doc.id,
|
|
@@ -239,4 +248,4 @@ class Firestore {
|
|
|
239
248
|
}
|
|
240
249
|
}
|
|
241
250
|
|
|
242
|
-
export default Firestore;
|
|
251
|
+
export default Firestore;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "web-manager",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.8",
|
|
4
4
|
"description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "src/index.js",
|
|
@@ -42,14 +42,13 @@
|
|
|
42
42
|
"@sentry/browser": "Resolved by using OVERRIDES in web-manager (lighthouse is the issue"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@sentry/browser": "^10.
|
|
46
|
-
"firebase": "^12.
|
|
47
|
-
"itwcw-package-analytics": "^1.0.
|
|
48
|
-
"lodash": "^4.17.
|
|
49
|
-
"resolve-account": "^2.0.1"
|
|
45
|
+
"@sentry/browser": "^10.38.0",
|
|
46
|
+
"firebase": "^12.9.0",
|
|
47
|
+
"itwcw-package-analytics": "^1.0.8",
|
|
48
|
+
"lodash": "^4.17.23"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
51
|
"mocha": "^8.4.0",
|
|
53
|
-
"prepare-package": "^1.2.
|
|
52
|
+
"prepare-package": "^1.2.6"
|
|
54
53
|
}
|
|
55
54
|
}
|