@jobsearch-works/firestore-models 1.0.3 → 1.0.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/README.md +184 -100
- package/dist/index.d.mts +308 -0
- package/dist/index.d.ts +308 -10
- package/dist/index.js +308 -12
- package/dist/index.mjs +279 -0
- package/package.json +2 -2
- package/dist/BaseModel.d.ts +0 -8
- package/dist/BaseModel.js +0 -1
- package/dist/models/VacancySuggestion.d.ts +0 -19
- package/dist/models/VacancySuggestion.js +0 -18
- package/dist/models/application.d.ts +0 -40
- package/dist/models/application.js +0 -37
- package/dist/models/authUser.d.ts +0 -31
- package/dist/models/authUser.js +0 -80
- package/dist/models/client.d.ts +0 -13
- package/dist/models/client.js +0 -16
- package/dist/models/clientData.d.ts +0 -25
- package/dist/models/clientData.js +0 -24
- package/dist/models/clientLogin.d.ts +0 -18
- package/dist/models/clientLogin.js +0 -19
- package/dist/models/question.d.ts +0 -34
- package/dist/models/question.js +0 -1
- package/dist/models/userLogin.d.ts +0 -0
- package/dist/models/userLogin.js +0 -59
- package/dist/models/userQuestion.d.ts +0 -15
- package/dist/models/userQuestion.js +0 -37
- package/dist/models/vacancy.d.ts +0 -24
- package/dist/models/vacancy.js +0 -27
package/dist/index.mjs
ADDED
@@ -0,0 +1,279 @@
|
|
1
|
+
var __defProp = Object.defineProperty;
|
2
|
+
var __export = (target, all) => {
|
3
|
+
for (var name in all)
|
4
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
5
|
+
};
|
6
|
+
|
7
|
+
// src/models2/Application.ts
|
8
|
+
var Application_exports = {};
|
9
|
+
__export(Application_exports, {
|
10
|
+
Application: () => Application
|
11
|
+
});
|
12
|
+
var Application;
|
13
|
+
((Application2) => {
|
14
|
+
Application2.collection = (clientId) => `clients/${clientId}/applications`;
|
15
|
+
Application2.document = (clientId, applicationId) => `clients/${clientId}/applications/${applicationId}`;
|
16
|
+
Application2.formatSummary = (application) => {
|
17
|
+
return `${application.position} at ${application.company} (${application.status})`;
|
18
|
+
};
|
19
|
+
Application2.formatDate = (date) => {
|
20
|
+
const dateObj = date instanceof Date ? date : new Date(date);
|
21
|
+
return dateObj.toLocaleDateString();
|
22
|
+
};
|
23
|
+
Application2.createNew = (clientId, vacancyId, vacancyData = {}) => {
|
24
|
+
return {
|
25
|
+
clientId,
|
26
|
+
vacancyId,
|
27
|
+
status: "new",
|
28
|
+
company: vacancyData.company,
|
29
|
+
position: vacancyData.position,
|
30
|
+
location: vacancyData.location,
|
31
|
+
jobId: vacancyData.jobId,
|
32
|
+
advertisingUrl: vacancyData.advertisingUrl,
|
33
|
+
applicationUrl: vacancyData.applicationUrl,
|
34
|
+
applicationDomain: vacancyData.applicationDomain,
|
35
|
+
advertisingDomain: vacancyData.advertisingDomain,
|
36
|
+
description: vacancyData.description,
|
37
|
+
fullPageText: vacancyData.fullPageText,
|
38
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
39
|
+
};
|
40
|
+
};
|
41
|
+
Application2.updateStatus = (application, newStatus) => {
|
42
|
+
return {
|
43
|
+
...application,
|
44
|
+
status: newStatus,
|
45
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
46
|
+
};
|
47
|
+
};
|
48
|
+
})(Application || (Application = {}));
|
49
|
+
|
50
|
+
// src/models2/AuthUser.ts
|
51
|
+
var AuthUser_exports = {};
|
52
|
+
__export(AuthUser_exports, {
|
53
|
+
AuthUserCollectionPath: () => AuthUserCollectionPath,
|
54
|
+
AuthUserUtils: () => AuthUserUtils,
|
55
|
+
getAuthUserDocumentPath: () => getAuthUserDocumentPath
|
56
|
+
});
|
57
|
+
var AuthUserCollectionPath = "users";
|
58
|
+
var getAuthUserDocumentPath = (userId) => `users/${userId}`;
|
59
|
+
var AuthUserUtils = {
|
60
|
+
// Get timestamp fields for AuthUser
|
61
|
+
getTimestampFields: () => [],
|
62
|
+
// Check if value is a Firestore timestamp
|
63
|
+
isFirestoreTimestamp: (value) => {
|
64
|
+
return typeof value === "object" && value !== null && ("seconds" in value || "_firestore_timestamp" in value);
|
65
|
+
},
|
66
|
+
// Create from Firebase user object
|
67
|
+
fromFirebaseUser: (user) => {
|
68
|
+
return {
|
69
|
+
id: user.uid,
|
70
|
+
email: user.email,
|
71
|
+
displayName: user.displayName,
|
72
|
+
photoURL: user.photoURL,
|
73
|
+
emailVerified: user.emailVerified,
|
74
|
+
lastSignIn: (/* @__PURE__ */ new Date()).toISOString(),
|
75
|
+
// Current timestamp for new logins
|
76
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
77
|
+
};
|
78
|
+
},
|
79
|
+
// Convert dates to display format
|
80
|
+
formatDates: (user) => {
|
81
|
+
const formatDate = (dateValue) => {
|
82
|
+
if (!dateValue)
|
83
|
+
return "N/A";
|
84
|
+
const date = typeof dateValue === "string" ? new Date(dateValue) : dateValue;
|
85
|
+
return date.toLocaleString();
|
86
|
+
};
|
87
|
+
return {
|
88
|
+
lastSignIn: formatDate(user.lastSignIn),
|
89
|
+
createdAt: formatDate(user.createdAt),
|
90
|
+
updatedAt: user.updatedAt ? formatDate(user.updatedAt) : void 0
|
91
|
+
};
|
92
|
+
},
|
93
|
+
// Convert AuthUser to format for storage
|
94
|
+
toFirestore: (user) => {
|
95
|
+
const { id, ...data } = user;
|
96
|
+
if (data.lastSignIn && data.lastSignIn instanceof Date) {
|
97
|
+
data.lastSignIn = data.lastSignIn.toISOString();
|
98
|
+
}
|
99
|
+
if (data.createdAt && data.createdAt instanceof Date) {
|
100
|
+
data.createdAt = data.createdAt.toISOString();
|
101
|
+
}
|
102
|
+
if (data.updatedAt && data.updatedAt instanceof Date) {
|
103
|
+
data.updatedAt = data.updatedAt.toISOString();
|
104
|
+
} else {
|
105
|
+
data.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
106
|
+
}
|
107
|
+
return data;
|
108
|
+
},
|
109
|
+
// Convert from Firestore data to AuthUser
|
110
|
+
fromFirestore: (data) => {
|
111
|
+
const processedData = { ...data };
|
112
|
+
const timestampFields = [];
|
113
|
+
timestampFields.forEach((field) => {
|
114
|
+
if (data[field]) {
|
115
|
+
if (AuthUserUtils.isFirestoreTimestamp(data[field])) {
|
116
|
+
processedData[field] = new Date(
|
117
|
+
data[field].seconds * 1e3
|
118
|
+
).toISOString();
|
119
|
+
} else if (typeof data[field] === "string") {
|
120
|
+
processedData[field] = data[field];
|
121
|
+
}
|
122
|
+
}
|
123
|
+
});
|
124
|
+
return processedData;
|
125
|
+
}
|
126
|
+
};
|
127
|
+
|
128
|
+
// src/models2/Client.ts
|
129
|
+
var Client_exports = {};
|
130
|
+
__export(Client_exports, {
|
131
|
+
Client: () => Client
|
132
|
+
});
|
133
|
+
var Client;
|
134
|
+
((Client2) => {
|
135
|
+
Client2.collection = () => "clients";
|
136
|
+
Client2.document = (clientId) => `clients/${clientId}`;
|
137
|
+
Client2.formatClient = (client) => {
|
138
|
+
return `${client.name} (${client.email}) - ${client.status}`;
|
139
|
+
};
|
140
|
+
Client2.createNew = (name, email) => {
|
141
|
+
return {
|
142
|
+
name,
|
143
|
+
email,
|
144
|
+
status: "active",
|
145
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
146
|
+
};
|
147
|
+
};
|
148
|
+
})(Client || (Client = {}));
|
149
|
+
|
150
|
+
// src/models2/ClientData.ts
|
151
|
+
var ClientData_exports = {};
|
152
|
+
__export(ClientData_exports, {
|
153
|
+
ClientData: () => ClientData
|
154
|
+
});
|
155
|
+
var ClientData;
|
156
|
+
((ClientData2) => {
|
157
|
+
ClientData2.collection = () => "clientData";
|
158
|
+
ClientData2.document = (clientDataId) => `clientData/${clientDataId}`;
|
159
|
+
ClientData2.formatClientData = (clientData) => {
|
160
|
+
return `${clientData.firstName} ${clientData.lastName} (${clientData.email})`;
|
161
|
+
};
|
162
|
+
ClientData2.createNew = (firstName, lastName, email, phone, address, city, state, zip, country, countryPhoneCode, suburb) => {
|
163
|
+
return {
|
164
|
+
firstName,
|
165
|
+
lastName,
|
166
|
+
middleName: "",
|
167
|
+
preferredName: "",
|
168
|
+
email,
|
169
|
+
phone,
|
170
|
+
address,
|
171
|
+
city,
|
172
|
+
suburb,
|
173
|
+
state,
|
174
|
+
zip,
|
175
|
+
country,
|
176
|
+
countryPhoneCode,
|
177
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
178
|
+
};
|
179
|
+
};
|
180
|
+
})(ClientData || (ClientData = {}));
|
181
|
+
|
182
|
+
// src/models2/ClientLogin.ts
|
183
|
+
var ClientLogin_exports = {};
|
184
|
+
__export(ClientLogin_exports, {
|
185
|
+
ClientLogin: () => ClientLogin
|
186
|
+
});
|
187
|
+
var ClientLogin;
|
188
|
+
((ClientLogin2) => {
|
189
|
+
ClientLogin2.collection = (userId) => `clientLogins/${userId}`;
|
190
|
+
ClientLogin2.document = (userId, domain) => `clientLogins/${userId}/logins/${domain}`;
|
191
|
+
ClientLogin2.formatClientLogin = (clientLogin) => {
|
192
|
+
return `${clientLogin.domain} (${clientLogin.username || clientLogin.email || "no username"})`;
|
193
|
+
};
|
194
|
+
ClientLogin2.createNew = (userId, url, domain, password, username, email) => {
|
195
|
+
return {
|
196
|
+
userId,
|
197
|
+
url,
|
198
|
+
domain,
|
199
|
+
password,
|
200
|
+
username,
|
201
|
+
email,
|
202
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
203
|
+
};
|
204
|
+
};
|
205
|
+
})(ClientLogin || (ClientLogin = {}));
|
206
|
+
|
207
|
+
// src/models2/Question.ts
|
208
|
+
var Question_exports = {};
|
209
|
+
|
210
|
+
// src/models2/UserQuestion.ts
|
211
|
+
var UserQuestion_exports = {};
|
212
|
+
|
213
|
+
// src/models2/Vacancy.ts
|
214
|
+
var Vacancy_exports = {};
|
215
|
+
__export(Vacancy_exports, {
|
216
|
+
Vacancy: () => Vacancy
|
217
|
+
});
|
218
|
+
var Vacancy;
|
219
|
+
((Vacancy2) => {
|
220
|
+
Vacancy2.collection = () => "vacancies";
|
221
|
+
Vacancy2.document = (vacancyId) => `vacancies/${vacancyId}`;
|
222
|
+
Vacancy2.formatSummary = (vacancy) => {
|
223
|
+
return `${vacancy.position} at ${vacancy.company} (${vacancy.location})`;
|
224
|
+
};
|
225
|
+
Vacancy2.formatDate = (date) => {
|
226
|
+
const dateObj = date instanceof Date ? date : new Date(date);
|
227
|
+
return dateObj.toLocaleDateString();
|
228
|
+
};
|
229
|
+
Vacancy2.createNew = (company, position, location, description, advertisingUrl, applicationUrl, applicationDomain, advertisingDomain, fullPageText, jobId) => {
|
230
|
+
return {
|
231
|
+
company,
|
232
|
+
position,
|
233
|
+
location,
|
234
|
+
description,
|
235
|
+
advertisingUrl,
|
236
|
+
applicationUrl,
|
237
|
+
applicationDomain,
|
238
|
+
advertisingDomain,
|
239
|
+
fullPageText,
|
240
|
+
jobId,
|
241
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
242
|
+
};
|
243
|
+
};
|
244
|
+
})(Vacancy || (Vacancy = {}));
|
245
|
+
|
246
|
+
// src/models2/VacancySuggestion.ts
|
247
|
+
var VacancySuggestion_exports = {};
|
248
|
+
__export(VacancySuggestion_exports, {
|
249
|
+
VacancySuggestion: () => VacancySuggestion
|
250
|
+
});
|
251
|
+
var VacancySuggestion;
|
252
|
+
((VacancySuggestion2) => {
|
253
|
+
VacancySuggestion2.collection = (clientId) => `clients/${clientId}/vacancySuggestions`;
|
254
|
+
VacancySuggestion2.document = (clientId, suggestionId) => `clients/${clientId}/vacancySuggestions/${suggestionId}`;
|
255
|
+
VacancySuggestion2.formatSummary = (suggestion) => {
|
256
|
+
return `${suggestion.vacancyPosition} at ${suggestion.vacancyCompany} (${suggestion.status})`;
|
257
|
+
};
|
258
|
+
VacancySuggestion2.createNew = (clientId, vacancyId, vacancyCompany, vacancyPosition, status = "new") => {
|
259
|
+
return {
|
260
|
+
clientId,
|
261
|
+
vacancyId,
|
262
|
+
vacancyCompany,
|
263
|
+
vacancyPosition,
|
264
|
+
status,
|
265
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
266
|
+
};
|
267
|
+
};
|
268
|
+
})(VacancySuggestion || (VacancySuggestion = {}));
|
269
|
+
export {
|
270
|
+
Application_exports as Application,
|
271
|
+
AuthUser_exports as AuthUser,
|
272
|
+
Client_exports as Client,
|
273
|
+
ClientData_exports as ClientData,
|
274
|
+
ClientLogin_exports as ClientLogin,
|
275
|
+
Question_exports as Question,
|
276
|
+
UserQuestion_exports as UserQuestion,
|
277
|
+
Vacancy_exports as Vacancy,
|
278
|
+
VacancySuggestion_exports as VacancySuggestion
|
279
|
+
};
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@jobsearch-works/firestore-models",
|
3
|
-
"version": "1.0.
|
3
|
+
"version": "1.0.8",
|
4
4
|
"description": "A shared library for standardizing Firestore document schemas and paths across multiple projects",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "dist/index.d.ts",
|
@@ -8,7 +8,7 @@
|
|
8
8
|
"dist"
|
9
9
|
],
|
10
10
|
"scripts": {
|
11
|
-
"build": "
|
11
|
+
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
|
12
12
|
"prepare": "npm run build",
|
13
13
|
"test": "vitest",
|
14
14
|
"lint": "eslint ./src",
|
package/dist/BaseModel.d.ts
DELETED
package/dist/BaseModel.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
export {};
|
@@ -1,19 +0,0 @@
|
|
1
|
-
import { BaseModel } from "../BaseModel";
|
2
|
-
export declare namespace VacancySuggestion {
|
3
|
-
/**
|
4
|
-
* Represents a job vacancy suggestion for a client
|
5
|
-
*/
|
6
|
-
interface Model extends BaseModel {
|
7
|
-
clientId: string;
|
8
|
-
vacancyId: string;
|
9
|
-
vacancyCompany: string;
|
10
|
-
vacancyPosition: string;
|
11
|
-
status: string;
|
12
|
-
createdAt: Date | string;
|
13
|
-
updatedAt?: Date | string;
|
14
|
-
}
|
15
|
-
const collection: (clientId: string) => string;
|
16
|
-
const document: (clientId: string, suggestionId: string) => string;
|
17
|
-
const formatSummary: (suggestion: VacancySuggestion.Model) => string;
|
18
|
-
const createNew: (clientId: string, vacancyId: string, vacancyCompany: string, vacancyPosition: string, status?: string) => VacancySuggestion.Model;
|
19
|
-
}
|
@@ -1,18 +0,0 @@
|
|
1
|
-
export var VacancySuggestion;
|
2
|
-
(function (VacancySuggestion) {
|
3
|
-
VacancySuggestion.collection = (clientId) => `clients/${clientId}/vacancySuggestions`;
|
4
|
-
VacancySuggestion.document = (clientId, suggestionId) => `clients/${clientId}/vacancySuggestions/${suggestionId}`;
|
5
|
-
VacancySuggestion.formatSummary = (suggestion) => {
|
6
|
-
return `${suggestion.vacancyPosition} at ${suggestion.vacancyCompany} (${suggestion.status})`;
|
7
|
-
};
|
8
|
-
VacancySuggestion.createNew = (clientId, vacancyId, vacancyCompany, vacancyPosition, status = "new") => {
|
9
|
-
return {
|
10
|
-
clientId,
|
11
|
-
vacancyId,
|
12
|
-
vacancyCompany,
|
13
|
-
vacancyPosition,
|
14
|
-
status,
|
15
|
-
createdAt: new Date().toISOString(),
|
16
|
-
};
|
17
|
-
};
|
18
|
-
})(VacancySuggestion || (VacancySuggestion = {}));
|
@@ -1,40 +0,0 @@
|
|
1
|
-
import { BaseModel } from "../BaseModel";
|
2
|
-
export declare namespace Application {
|
3
|
-
/**
|
4
|
-
* Represents a job application
|
5
|
-
*/
|
6
|
-
interface Model extends BaseModel {
|
7
|
-
vacancyId: string;
|
8
|
-
clientId: string;
|
9
|
-
status: "new" | "submitted" | "interviewing" | "accepted" | "rejected" | "withdrawn" | "applying" | "suggested" | "approved";
|
10
|
-
coverLetter?: string;
|
11
|
-
resume?: string;
|
12
|
-
company?: string;
|
13
|
-
position?: string;
|
14
|
-
location?: string;
|
15
|
-
jobId?: string;
|
16
|
-
advertisingUrl?: string;
|
17
|
-
applicationUrl?: string;
|
18
|
-
applicationDomain?: string;
|
19
|
-
advertisingDomain?: string;
|
20
|
-
description?: string;
|
21
|
-
fullPageText?: string;
|
22
|
-
}
|
23
|
-
const collection: (clientId: string) => string;
|
24
|
-
const document: (clientId: string, applicationId: string) => string;
|
25
|
-
const formatSummary: (application: Application.Model) => string;
|
26
|
-
const formatDate: (date: Date | string) => string;
|
27
|
-
const createNew: (clientId: string, vacancyId: string, vacancyData?: {
|
28
|
-
company?: string;
|
29
|
-
position?: string;
|
30
|
-
location?: string;
|
31
|
-
jobId?: string;
|
32
|
-
advertisingUrl?: string;
|
33
|
-
applicationUrl?: string;
|
34
|
-
applicationDomain?: string;
|
35
|
-
advertisingDomain?: string;
|
36
|
-
description?: string;
|
37
|
-
fullPageText?: string;
|
38
|
-
}) => Application.Model;
|
39
|
-
const updateStatus: (application: Application.Model, newStatus: Application.Model["status"]) => Application.Model;
|
40
|
-
}
|
@@ -1,37 +0,0 @@
|
|
1
|
-
export var Application;
|
2
|
-
(function (Application) {
|
3
|
-
Application.collection = (clientId) => `clients/${clientId}/applications`;
|
4
|
-
Application.document = (clientId, applicationId) => `clients/${clientId}/applications/${applicationId}`;
|
5
|
-
Application.formatSummary = (application) => {
|
6
|
-
return `${application.position} at ${application.company} (${application.status})`;
|
7
|
-
};
|
8
|
-
Application.formatDate = (date) => {
|
9
|
-
const dateObj = date instanceof Date ? date : new Date(date);
|
10
|
-
return dateObj.toLocaleDateString();
|
11
|
-
};
|
12
|
-
Application.createNew = (clientId, vacancyId, vacancyData = {}) => {
|
13
|
-
return {
|
14
|
-
clientId,
|
15
|
-
vacancyId,
|
16
|
-
status: "new",
|
17
|
-
company: vacancyData.company,
|
18
|
-
position: vacancyData.position,
|
19
|
-
location: vacancyData.location,
|
20
|
-
jobId: vacancyData.jobId,
|
21
|
-
advertisingUrl: vacancyData.advertisingUrl,
|
22
|
-
applicationUrl: vacancyData.applicationUrl,
|
23
|
-
applicationDomain: vacancyData.applicationDomain,
|
24
|
-
advertisingDomain: vacancyData.advertisingDomain,
|
25
|
-
description: vacancyData.description,
|
26
|
-
fullPageText: vacancyData.fullPageText,
|
27
|
-
createdAt: new Date().toISOString(),
|
28
|
-
};
|
29
|
-
};
|
30
|
-
Application.updateStatus = (application, newStatus) => {
|
31
|
-
return {
|
32
|
-
...application,
|
33
|
-
status: newStatus,
|
34
|
-
updatedAt: new Date().toISOString(),
|
35
|
-
};
|
36
|
-
};
|
37
|
-
})(Application || (Application = {}));
|
@@ -1,31 +0,0 @@
|
|
1
|
-
import { BaseModel } from "../BaseModel";
|
2
|
-
interface FirestoreTimestamp {
|
3
|
-
seconds: number;
|
4
|
-
nanoseconds: number;
|
5
|
-
_firestore_timestamp?: boolean;
|
6
|
-
}
|
7
|
-
/**
|
8
|
-
* AuthUser interface - replaces the old class-based model
|
9
|
-
*/
|
10
|
-
export interface AuthUser extends BaseModel {
|
11
|
-
email: string;
|
12
|
-
displayName?: string;
|
13
|
-
photoURL?: string;
|
14
|
-
lastSignIn?: Date | string;
|
15
|
-
emailVerified?: boolean;
|
16
|
-
}
|
17
|
-
export declare const AuthUserCollectionPath = "users";
|
18
|
-
export declare const getAuthUserDocumentPath: (userId: string) => string;
|
19
|
-
export declare const AuthUserUtils: {
|
20
|
-
getTimestampFields: () => string[];
|
21
|
-
isFirestoreTimestamp: (value: any) => value is FirestoreTimestamp;
|
22
|
-
fromFirebaseUser: (user: any) => AuthUser;
|
23
|
-
formatDates: (user: AuthUser) => {
|
24
|
-
lastSignIn: string;
|
25
|
-
createdAt: string;
|
26
|
-
updatedAt?: string;
|
27
|
-
};
|
28
|
-
toFirestore: (user: AuthUser) => Record<string, any>;
|
29
|
-
fromFirestore: (data: Record<string, any>) => AuthUser;
|
30
|
-
};
|
31
|
-
export {};
|
package/dist/models/authUser.js
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
// Path constants
|
2
|
-
export const AuthUserCollectionPath = "users";
|
3
|
-
export const getAuthUserDocumentPath = (userId) => `users/${userId}`;
|
4
|
-
// Helper utilities for working with AuthUser
|
5
|
-
export const AuthUserUtils = {
|
6
|
-
// Get timestamp fields for AuthUser
|
7
|
-
getTimestampFields: () => [],
|
8
|
-
// Check if value is a Firestore timestamp
|
9
|
-
isFirestoreTimestamp: (value) => {
|
10
|
-
return (typeof value === "object" &&
|
11
|
-
value !== null &&
|
12
|
-
("seconds" in value || "_firestore_timestamp" in value));
|
13
|
-
},
|
14
|
-
// Create from Firebase user object
|
15
|
-
fromFirebaseUser: (user) => {
|
16
|
-
return {
|
17
|
-
id: user.uid,
|
18
|
-
email: user.email,
|
19
|
-
displayName: user.displayName,
|
20
|
-
photoURL: user.photoURL,
|
21
|
-
emailVerified: user.emailVerified,
|
22
|
-
lastSignIn: new Date().toISOString(), // Current timestamp for new logins
|
23
|
-
createdAt: new Date().toISOString(),
|
24
|
-
};
|
25
|
-
},
|
26
|
-
// Convert dates to display format
|
27
|
-
formatDates: (user) => {
|
28
|
-
const formatDate = (dateValue) => {
|
29
|
-
if (!dateValue)
|
30
|
-
return "N/A";
|
31
|
-
const date = typeof dateValue === "string" ? new Date(dateValue) : dateValue;
|
32
|
-
return date.toLocaleString();
|
33
|
-
};
|
34
|
-
return {
|
35
|
-
lastSignIn: formatDate(user.lastSignIn),
|
36
|
-
createdAt: formatDate(user.createdAt),
|
37
|
-
updatedAt: user.updatedAt ? formatDate(user.updatedAt) : undefined,
|
38
|
-
};
|
39
|
-
},
|
40
|
-
// Convert AuthUser to format for storage
|
41
|
-
toFirestore: (user) => {
|
42
|
-
// Create a copy of the object without the id field
|
43
|
-
const { id, ...data } = user;
|
44
|
-
// Ensure dates are in ISO string format
|
45
|
-
if (data.lastSignIn && data.lastSignIn instanceof Date) {
|
46
|
-
data.lastSignIn = data.lastSignIn.toISOString();
|
47
|
-
}
|
48
|
-
if (data.createdAt && data.createdAt instanceof Date) {
|
49
|
-
data.createdAt = data.createdAt.toISOString();
|
50
|
-
}
|
51
|
-
if (data.updatedAt && data.updatedAt instanceof Date) {
|
52
|
-
data.updatedAt = data.updatedAt.toISOString();
|
53
|
-
}
|
54
|
-
else {
|
55
|
-
// Add standard updatedAt timestamp to all documents
|
56
|
-
data.updatedAt = new Date().toISOString();
|
57
|
-
}
|
58
|
-
return data;
|
59
|
-
},
|
60
|
-
// Convert from Firestore data to AuthUser
|
61
|
-
fromFirestore: (data) => {
|
62
|
-
// Convert any timestamp fields
|
63
|
-
const processedData = { ...data };
|
64
|
-
// Process each timestamp field
|
65
|
-
const timestampFields = [];
|
66
|
-
timestampFields.forEach((field) => {
|
67
|
-
if (data[field]) {
|
68
|
-
if (AuthUserUtils.isFirestoreTimestamp(data[field])) {
|
69
|
-
// Convert Firestore timestamp to Date
|
70
|
-
processedData[field] = new Date(data[field].seconds * 1000).toISOString();
|
71
|
-
}
|
72
|
-
else if (typeof data[field] === "string") {
|
73
|
-
// Keep ISO string as is
|
74
|
-
processedData[field] = data[field];
|
75
|
-
}
|
76
|
-
}
|
77
|
-
});
|
78
|
-
return processedData;
|
79
|
-
},
|
80
|
-
};
|
package/dist/models/client.d.ts
DELETED
@@ -1,13 +0,0 @@
|
|
1
|
-
import { BaseModel } from "../BaseModel";
|
2
|
-
export declare namespace Client {
|
3
|
-
interface Model extends BaseModel {
|
4
|
-
name: string;
|
5
|
-
email: string;
|
6
|
-
status: "active" | "inactive";
|
7
|
-
resume?: string;
|
8
|
-
}
|
9
|
-
const collection: () => string;
|
10
|
-
const document: (clientId: string) => string;
|
11
|
-
const formatClient: (client: Client.Model) => string;
|
12
|
-
const createNew: (name: string, email: string) => Client.Model;
|
13
|
-
}
|
package/dist/models/client.js
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
export var Client;
|
2
|
-
(function (Client) {
|
3
|
-
Client.collection = () => "clients";
|
4
|
-
Client.document = (clientId) => `clients/${clientId}`;
|
5
|
-
Client.formatClient = (client) => {
|
6
|
-
return `${client.name} (${client.email}) - ${client.status}`;
|
7
|
-
};
|
8
|
-
Client.createNew = (name, email) => {
|
9
|
-
return {
|
10
|
-
name,
|
11
|
-
email,
|
12
|
-
status: "active",
|
13
|
-
createdAt: new Date().toISOString(),
|
14
|
-
};
|
15
|
-
};
|
16
|
-
})(Client || (Client = {}));
|
@@ -1,25 +0,0 @@
|
|
1
|
-
import { BaseModel } from "../BaseModel";
|
2
|
-
export declare namespace ClientData {
|
3
|
-
/**
|
4
|
-
* Represents a user's personal data.
|
5
|
-
*/
|
6
|
-
interface Model extends BaseModel {
|
7
|
-
firstName: string;
|
8
|
-
lastName: string;
|
9
|
-
middleName: string;
|
10
|
-
preferredName: string;
|
11
|
-
email: string;
|
12
|
-
phone: string;
|
13
|
-
address: string;
|
14
|
-
city: string;
|
15
|
-
state: string;
|
16
|
-
zip: string;
|
17
|
-
country: string;
|
18
|
-
linkedIn?: string;
|
19
|
-
countryPhoneCode?: string;
|
20
|
-
}
|
21
|
-
const collection: () => string;
|
22
|
-
const document: (clientDataId: string) => string;
|
23
|
-
const formatClientData: (clientData: ClientData.Model) => string;
|
24
|
-
const createNew: (firstName: string, lastName: string, email: string, phone: string, address: string, city: string, state: string, zip: string, country: string) => ClientData.Model;
|
25
|
-
}
|
@@ -1,24 +0,0 @@
|
|
1
|
-
export var ClientData;
|
2
|
-
(function (ClientData) {
|
3
|
-
ClientData.collection = () => "clientData";
|
4
|
-
ClientData.document = (clientDataId) => `clientData/${clientDataId}`;
|
5
|
-
ClientData.formatClientData = (clientData) => {
|
6
|
-
return `${clientData.firstName} ${clientData.lastName} (${clientData.email})`;
|
7
|
-
};
|
8
|
-
ClientData.createNew = (firstName, lastName, email, phone, address, city, state, zip, country) => {
|
9
|
-
return {
|
10
|
-
firstName,
|
11
|
-
lastName,
|
12
|
-
middleName: "",
|
13
|
-
preferredName: "",
|
14
|
-
email,
|
15
|
-
phone,
|
16
|
-
address,
|
17
|
-
city,
|
18
|
-
state,
|
19
|
-
zip,
|
20
|
-
country,
|
21
|
-
createdAt: new Date().toISOString(),
|
22
|
-
};
|
23
|
-
};
|
24
|
-
})(ClientData || (ClientData = {}));
|
@@ -1,18 +0,0 @@
|
|
1
|
-
import { BaseModel } from "../BaseModel";
|
2
|
-
export declare namespace ClientLogin {
|
3
|
-
/**
|
4
|
-
* Represents login credentials for a client website
|
5
|
-
*/
|
6
|
-
interface Model extends BaseModel {
|
7
|
-
userId: string;
|
8
|
-
url: string;
|
9
|
-
domain: string;
|
10
|
-
username?: string;
|
11
|
-
password: string;
|
12
|
-
email?: string;
|
13
|
-
}
|
14
|
-
const collection: (userId: string) => string;
|
15
|
-
const document: (userId: string, domain: string) => string;
|
16
|
-
const formatClientLogin: (clientLogin: ClientLogin.Model) => string;
|
17
|
-
const createNew: (userId: string, url: string, domain: string, password: string, username?: string, email?: string) => ClientLogin.Model;
|
18
|
-
}
|
@@ -1,19 +0,0 @@
|
|
1
|
-
export var ClientLogin;
|
2
|
-
(function (ClientLogin) {
|
3
|
-
ClientLogin.collection = (userId) => `clientLogins/${userId}`;
|
4
|
-
ClientLogin.document = (userId, domain) => `clientLogins/${userId}/logins/${domain}`;
|
5
|
-
ClientLogin.formatClientLogin = (clientLogin) => {
|
6
|
-
return `${clientLogin.domain} (${clientLogin.username || clientLogin.email || "no username"})`;
|
7
|
-
};
|
8
|
-
ClientLogin.createNew = (userId, url, domain, password, username, email) => {
|
9
|
-
return {
|
10
|
-
userId,
|
11
|
-
url,
|
12
|
-
domain,
|
13
|
-
password,
|
14
|
-
username,
|
15
|
-
email,
|
16
|
-
createdAt: new Date().toISOString(),
|
17
|
-
};
|
18
|
-
};
|
19
|
-
})(ClientLogin || (ClientLogin = {}));
|