@jobsearch-works/firestore-models 1.0.33 → 1.1.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 +58 -284
- package/dist/index.d.mts +225 -313
- package/dist/index.d.ts +225 -313
- package/dist/index.js +97 -378
- package/dist/index.mjs +92 -367
- package/package.json +1 -1
package/dist/index.js
CHANGED
@@ -20,391 +20,110 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
20
20
|
// src/index.ts
|
21
21
|
var src_exports = {};
|
22
22
|
__export(src_exports, {
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
ClientData: () => ClientData,
|
29
|
-
ClientLogin: () => ClientLogin,
|
30
|
-
ClientQuestion: () => ClientQuestion,
|
31
|
-
GmailMessage: () => GmailMessage,
|
32
|
-
Vacancy: () => Vacancy,
|
33
|
-
VacancySuggestion: () => VacancySuggestion
|
23
|
+
ApplicationQuestionTypeOptions: () => ApplicationQuestionTypeOptions,
|
24
|
+
ApplicationStatus: () => ApplicationStatus,
|
25
|
+
ClientQuestionTypeOptions: () => ClientQuestionTypeOptions,
|
26
|
+
VacancyCategory: () => VacancyCategory,
|
27
|
+
pathStrings: () => pathStrings
|
34
28
|
});
|
35
29
|
module.exports = __toCommonJS(src_exports);
|
36
30
|
|
37
|
-
// src/
|
38
|
-
var
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
Approved: "approved"
|
50
|
-
};
|
51
|
-
Application2.StatusOptions = Object.values(Application2.Status);
|
52
|
-
Application2.collection = (clientId) => `clients/${clientId}/applications`;
|
53
|
-
Application2.document = (clientId, applicationId) => `clients/${clientId}/applications/${applicationId}`;
|
54
|
-
Application2.formatSummary = (application) => {
|
55
|
-
return `${application.position} at ${application.company} (${application.status})`;
|
56
|
-
};
|
57
|
-
Application2.formatDate = (date) => {
|
58
|
-
const dateObj = date instanceof Date ? date : new Date(date);
|
59
|
-
return dateObj.toLocaleDateString();
|
60
|
-
};
|
61
|
-
Application2.createNew = (clientId, vacancyId, vacancyData = {}) => {
|
62
|
-
return {
|
63
|
-
clientId,
|
64
|
-
vacancyId,
|
65
|
-
status: "new",
|
66
|
-
company: vacancyData.company,
|
67
|
-
position: vacancyData.position,
|
68
|
-
location: vacancyData.location,
|
69
|
-
jobId: vacancyData.jobId,
|
70
|
-
advertisingUrl: vacancyData.advertisingUrl,
|
71
|
-
applicationUrl: vacancyData.applicationUrl,
|
72
|
-
applicationDomain: vacancyData.applicationDomain,
|
73
|
-
advertisingDomain: vacancyData.advertisingDomain,
|
74
|
-
description: vacancyData.description,
|
75
|
-
fullPageText: vacancyData.fullPageText,
|
76
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
77
|
-
};
|
78
|
-
};
|
79
|
-
Application2.updateStatus = (application, newStatus) => {
|
80
|
-
return {
|
81
|
-
...application,
|
82
|
-
status: newStatus,
|
83
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
84
|
-
};
|
85
|
-
};
|
86
|
-
})(Application || (Application = {}));
|
87
|
-
|
88
|
-
// src/models/AuthUser.ts
|
89
|
-
var AuthUser;
|
90
|
-
((AuthUser2) => {
|
91
|
-
AuthUser2.collection = () => "users";
|
92
|
-
AuthUser2.document = (userId) => `users/${userId}`;
|
93
|
-
AuthUser2.getTimestampFields = () => [
|
94
|
-
"lastSignIn",
|
95
|
-
"createdAt",
|
96
|
-
"updatedAt"
|
97
|
-
];
|
98
|
-
AuthUser2.isFirestoreTimestamp = (value) => {
|
99
|
-
return typeof value === "object" && value !== null && ("seconds" in value || "_firestore_timestamp" in value);
|
100
|
-
};
|
101
|
-
AuthUser2.fromFirebaseUser = (user) => {
|
102
|
-
return {
|
103
|
-
id: user.uid,
|
104
|
-
email: user.email,
|
105
|
-
displayName: user.displayName,
|
106
|
-
photoURL: user.photoURL,
|
107
|
-
emailVerified: user.emailVerified,
|
108
|
-
lastSignIn: (/* @__PURE__ */ new Date()).toISOString(),
|
109
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
110
|
-
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
111
|
-
};
|
112
|
-
};
|
113
|
-
AuthUser2.format = (user) => {
|
114
|
-
return `${user.email}${user.displayName ? " (" + user.displayName + ")" : ""}`;
|
115
|
-
};
|
116
|
-
AuthUser2.formatDates = (user) => {
|
117
|
-
const formatDate = (dateValue) => {
|
118
|
-
if (!dateValue)
|
119
|
-
return "N/A";
|
120
|
-
const date = dateValue instanceof Date ? dateValue : new Date(dateValue);
|
121
|
-
return date.toLocaleString();
|
122
|
-
};
|
123
|
-
return {
|
124
|
-
lastSignIn: formatDate(user.lastSignIn),
|
125
|
-
createdAt: formatDate(user.createdAt),
|
126
|
-
updatedAt: user.updatedAt ? formatDate(user.updatedAt) : void 0
|
127
|
-
};
|
128
|
-
};
|
129
|
-
AuthUser2.toFirestore = (user) => {
|
130
|
-
const { id, ...data } = user;
|
131
|
-
(0, AuthUser2.getTimestampFields)().forEach((field) => {
|
132
|
-
if (data[field] instanceof Date) {
|
133
|
-
data[field] = data[field].toISOString();
|
134
|
-
} else if (!data[field]) {
|
135
|
-
if (field === "updatedAt") {
|
136
|
-
data.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
137
|
-
}
|
138
|
-
}
|
139
|
-
});
|
140
|
-
return data;
|
141
|
-
};
|
142
|
-
AuthUser2.fromFirestore = (data) => {
|
143
|
-
const processed = { ...data };
|
144
|
-
(0, AuthUser2.getTimestampFields)().forEach((field) => {
|
145
|
-
if (data[field]) {
|
146
|
-
if ((0, AuthUser2.isFirestoreTimestamp)(data[field])) {
|
147
|
-
processed[field] = new Date(
|
148
|
-
data[field].seconds * 1e3
|
149
|
-
).toISOString();
|
150
|
-
} else if (typeof data[field] === "string") {
|
151
|
-
processed[field] = data[field];
|
152
|
-
}
|
153
|
-
}
|
154
|
-
});
|
155
|
-
return processed;
|
156
|
-
};
|
157
|
-
AuthUser2.createNew = (email, displayName, photoURL) => {
|
158
|
-
const now = (/* @__PURE__ */ new Date()).toISOString();
|
159
|
-
return {
|
160
|
-
id: void 0,
|
161
|
-
email,
|
162
|
-
displayName,
|
163
|
-
photoURL,
|
164
|
-
emailVerified: false,
|
165
|
-
lastSignIn: now,
|
166
|
-
createdAt: now,
|
167
|
-
updatedAt: now
|
168
|
-
};
|
169
|
-
};
|
170
|
-
})(AuthUser || (AuthUser = {}));
|
171
|
-
|
172
|
-
// src/models/Client.ts
|
173
|
-
var Client;
|
174
|
-
((Client2) => {
|
175
|
-
Client2.collection = () => "clients";
|
176
|
-
Client2.document = (clientId) => `clients/${clientId}`;
|
177
|
-
Client2.formatClient = (client) => {
|
178
|
-
return `${client.name} (${client.email}) - ${client.status}`;
|
179
|
-
};
|
180
|
-
Client2.createNew = (name, email) => {
|
181
|
-
return {
|
182
|
-
name,
|
183
|
-
email,
|
184
|
-
status: "active",
|
185
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
186
|
-
};
|
187
|
-
};
|
188
|
-
})(Client || (Client = {}));
|
189
|
-
|
190
|
-
// src/models/ClientData.ts
|
191
|
-
var ClientData;
|
192
|
-
((ClientData2) => {
|
193
|
-
ClientData2.collection = () => "clientData";
|
194
|
-
ClientData2.document = (clientDataId) => `clientData/${clientDataId}`;
|
195
|
-
ClientData2.formatClientData = (clientData) => {
|
196
|
-
return `${clientData.firstName} ${clientData.lastName} (${clientData.email})`;
|
197
|
-
};
|
198
|
-
ClientData2.createNew = (firstName, lastName, email, phone, address, city, state, zip, country, countryPhoneCode, suburb, nationality, dateOfBirth, middleName, preferredName) => {
|
199
|
-
return {
|
200
|
-
firstName,
|
201
|
-
lastName,
|
202
|
-
middleName,
|
203
|
-
preferredName,
|
204
|
-
email,
|
205
|
-
phone,
|
206
|
-
address,
|
207
|
-
city,
|
208
|
-
suburb,
|
209
|
-
state,
|
210
|
-
zip,
|
211
|
-
country,
|
212
|
-
countryPhoneCode,
|
213
|
-
nationality,
|
214
|
-
dateOfBirth
|
215
|
-
};
|
216
|
-
};
|
217
|
-
})(ClientData || (ClientData = {}));
|
218
|
-
|
219
|
-
// src/models/ClientLogin.ts
|
220
|
-
var ClientLogin;
|
221
|
-
((ClientLogin2) => {
|
222
|
-
ClientLogin2.collection = (userId) => `clientLogins/${userId}`;
|
223
|
-
ClientLogin2.document = (userId, domain) => `clientLogins/${userId}/logins/${domain}`;
|
224
|
-
ClientLogin2.formatClientLogin = (clientLogin) => {
|
225
|
-
return `${clientLogin.domain} (${clientLogin.username || clientLogin.email || "no username"})`;
|
226
|
-
};
|
227
|
-
ClientLogin2.createNew = (userId, url, domain, password, username, email) => {
|
228
|
-
return {
|
229
|
-
userId,
|
230
|
-
url,
|
231
|
-
domain,
|
232
|
-
password,
|
233
|
-
username,
|
234
|
-
email,
|
235
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
236
|
-
};
|
237
|
-
};
|
238
|
-
})(ClientLogin || (ClientLogin = {}));
|
239
|
-
|
240
|
-
// src/models/ClientQuestion.ts
|
241
|
-
var ClientQuestion;
|
242
|
-
((ClientQuestion2) => {
|
243
|
-
ClientQuestion2.TypeOptions = ["text", "select"];
|
244
|
-
ClientQuestion2.collection = (clientId) => `clients/${clientId}/questions`;
|
245
|
-
ClientQuestion2.document = (clientId, questionId) => `clients/${clientId}/questions/${questionId}`;
|
246
|
-
ClientQuestion2.createNew = (questionText, type, answerText, options) => {
|
247
|
-
return {
|
248
|
-
questionText,
|
249
|
-
type,
|
250
|
-
answerText,
|
251
|
-
options,
|
252
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
253
|
-
};
|
254
|
-
};
|
255
|
-
})(ClientQuestion || (ClientQuestion = {}));
|
256
|
-
|
257
|
-
// src/models/Vacancy.ts
|
258
|
-
var Vacancy;
|
259
|
-
((Vacancy2) => {
|
260
|
-
Vacancy2.Category = {
|
261
|
-
Accounting: "Accounting",
|
262
|
-
AdministrationAndOfficeSupport: "Administration & Office Support",
|
263
|
-
AdvertisingArtsAndMedia: "Advertising, Arts & Media",
|
264
|
-
BankingAndFinancialServices: "Banking & Financial Services",
|
265
|
-
CallCentreAndCustomerService: "Call Centre & Customer Service",
|
266
|
-
CEOAndGeneralManagement: "CEO & General Management",
|
267
|
-
CommunityServicesAndDevelopment: "Community Services & Development",
|
268
|
-
Construction: "Construction",
|
269
|
-
ConsultingAndStrategy: "Consulting & Strategy",
|
270
|
-
DesignAndArchitecture: "Design & Architecture",
|
271
|
-
EducationAndTraining: "Education & Training",
|
272
|
-
Engineering: "Engineering",
|
273
|
-
FarmingAnimalsAndConservation: "Farming, Animals & Conservation",
|
274
|
-
GovernmentAndDefence: "Government & Defence",
|
275
|
-
HealthcareAndMedical: "Healthcare & Medical",
|
276
|
-
HospitalityAndTourism: "Hospitality & Tourism",
|
277
|
-
HumanResourcesAndRecruitment: "Human Resources & Recruitment",
|
278
|
-
InformationAndCommunicationTechnology: "Information & Communication Technology",
|
279
|
-
InsuranceAndSuperannuation: "Insurance & Superannuation",
|
280
|
-
Legal: "Legal",
|
281
|
-
ManufacturingTransportAndLogistics: "Manufacturing, Transport & Logistics",
|
282
|
-
MarketingAndCommunications: "Marketing & Communications",
|
283
|
-
MiningResourcesAndEnergy: "Mining, Resources & Energy",
|
284
|
-
RealEstateAndProperty: "Real Estate & Property",
|
285
|
-
RetailAndConsumerProducts: "Retail & Consumer Products",
|
286
|
-
Sales: "Sales",
|
287
|
-
ScienceAndTechnology: "Science & Technology",
|
288
|
-
SelfEmployment: "Self Employment",
|
289
|
-
SportAndRecreation: "Sport & Recreation",
|
290
|
-
TradesAndServices: "Trades & Services"
|
291
|
-
};
|
292
|
-
Vacancy2.collection = () => "vacancies";
|
293
|
-
Vacancy2.document = (vacancyId) => `vacancies/${vacancyId}`;
|
294
|
-
Vacancy2.formatSummary = (vacancy) => `${vacancy.position} at ${vacancy.company} (${vacancy.location})`;
|
295
|
-
Vacancy2.formatDate = (date) => {
|
296
|
-
const dateObj = date instanceof Date ? date : new Date(date);
|
297
|
-
return dateObj.toLocaleDateString();
|
298
|
-
};
|
299
|
-
Vacancy2.createNew = (company, position, location, description, advertisingUrl, applicationUrl, applicationDomain, advertisingDomain, fullPageText, jobId, category) => {
|
300
|
-
return {
|
301
|
-
company,
|
302
|
-
position,
|
303
|
-
location,
|
304
|
-
description,
|
305
|
-
advertisingUrl,
|
306
|
-
applicationUrl,
|
307
|
-
applicationDomain,
|
308
|
-
advertisingDomain,
|
309
|
-
fullPageText,
|
310
|
-
jobId,
|
311
|
-
category,
|
312
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
313
|
-
};
|
314
|
-
};
|
315
|
-
})(Vacancy || (Vacancy = {}));
|
31
|
+
// src/types/Application.ts
|
32
|
+
var ApplicationStatus = {
|
33
|
+
New: "new",
|
34
|
+
Submitted: "submitted",
|
35
|
+
Interviewing: "interviewing",
|
36
|
+
Accepted: "accepted",
|
37
|
+
Rejected: "rejected",
|
38
|
+
Withdrawn: "withdrawn",
|
39
|
+
Applying: "applying",
|
40
|
+
Suggested: "suggested",
|
41
|
+
Approved: "approved"
|
42
|
+
};
|
316
43
|
|
317
|
-
// src/
|
318
|
-
var
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
44
|
+
// src/types/Vacancy.ts
|
45
|
+
var VacancyCategory = {
|
46
|
+
Accounting: "Accounting",
|
47
|
+
AdministrationAndOfficeSupport: "Administration & Office Support",
|
48
|
+
AdvertisingArtsAndMedia: "Advertising, Arts & Media",
|
49
|
+
BankingAndFinancialServices: "Banking & Financial Services",
|
50
|
+
CallCentreAndCustomerService: "Call Centre & Customer Service",
|
51
|
+
CEOAndGeneralManagement: "CEO & General Management",
|
52
|
+
CommunityServicesAndDevelopment: "Community Services & Development",
|
53
|
+
Construction: "Construction",
|
54
|
+
ConsultingAndStrategy: "Consulting & Strategy",
|
55
|
+
DesignAndArchitecture: "Design & Architecture",
|
56
|
+
EducationAndTraining: "Education & Training",
|
57
|
+
Engineering: "Engineering",
|
58
|
+
FarmingAnimalsAndConservation: "Farming, Animals & Conservation",
|
59
|
+
GovernmentAndDefence: "Government & Defence",
|
60
|
+
HealthcareAndMedical: "Healthcare & Medical",
|
61
|
+
HospitalityAndTourism: "Hospitality & Tourism",
|
62
|
+
HumanResourcesAndRecruitment: "Human Resources & Recruitment",
|
63
|
+
InformationAndCommunicationTechnology: "Information & Communication Technology",
|
64
|
+
InsuranceAndSuperannuation: "Insurance & Superannuation",
|
65
|
+
Legal: "Legal",
|
66
|
+
ManufacturingTransportAndLogistics: "Manufacturing, Transport & Logistics",
|
67
|
+
MarketingAndCommunications: "Marketing & Communications",
|
68
|
+
MiningResourcesAndEnergy: "Mining, Resources & Energy",
|
69
|
+
RealEstateAndProperty: "Real Estate & Property",
|
70
|
+
RetailAndConsumerProducts: "Retail & Consumer Products",
|
71
|
+
Sales: "Sales",
|
72
|
+
ScienceAndTechnology: "Science & Technology",
|
73
|
+
SelfEmployment: "Self Employment",
|
74
|
+
SportAndRecreation: "Sport & Recreation",
|
75
|
+
TradesAndServices: "Trades & Services"
|
76
|
+
};
|
345
77
|
|
346
|
-
// src/
|
347
|
-
var
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
ApplicationQuestion2.document = (clientId, applicationId, questionId) => `clients/${clientId}/applications/${applicationId}/questions/${questionId}`;
|
352
|
-
ApplicationQuestion2.createNew = (questionText, type, answerText) => {
|
353
|
-
return {
|
354
|
-
questionText,
|
355
|
-
type,
|
356
|
-
answerText,
|
357
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
358
|
-
};
|
359
|
-
};
|
360
|
-
})(ApplicationQuestion || (ApplicationQuestion = {}));
|
78
|
+
// src/types/ClientQuestion.ts
|
79
|
+
var ClientQuestionTypeOptions = [
|
80
|
+
"text",
|
81
|
+
"select"
|
82
|
+
];
|
361
83
|
|
362
|
-
// src/
|
363
|
-
var
|
364
|
-
((Agent2) => {
|
365
|
-
Agent2.collection = () => "agents";
|
366
|
-
Agent2.document = (agentId) => `agents/${agentId}`;
|
367
|
-
Agent2.formatAgent = (agent) => {
|
368
|
-
return `${agent.name} (${agent.email}) - ${agent.status}`;
|
369
|
-
};
|
370
|
-
Agent2.createNew = (name, email) => {
|
371
|
-
return {
|
372
|
-
name,
|
373
|
-
email,
|
374
|
-
status: "active",
|
375
|
-
createdAt: (/* @__PURE__ */ new Date()).toISOString()
|
376
|
-
};
|
377
|
-
};
|
378
|
-
})(Agent || (Agent = {}));
|
84
|
+
// src/types/ApplicationQuestion.ts
|
85
|
+
var ApplicationQuestionTypeOptions = ["text", "select"];
|
379
86
|
|
380
|
-
// src/
|
381
|
-
var
|
382
|
-
(
|
383
|
-
|
384
|
-
|
385
|
-
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
}
|
396
|
-
|
87
|
+
// src/paths/pathStrings.ts
|
88
|
+
var pathStrings = {
|
89
|
+
clients: () => "clients",
|
90
|
+
client: (clientId) => `clients/${clientId}`,
|
91
|
+
// Application paths
|
92
|
+
applications: (clientId) => `clients/${clientId}/applications`,
|
93
|
+
application: (clientId, applicationId) => `clients/${clientId}/applications/${applicationId}`,
|
94
|
+
// AuthUser paths
|
95
|
+
users: () => "users",
|
96
|
+
user: (userId) => `users/${userId}`,
|
97
|
+
// Vacancy paths
|
98
|
+
vacancies: () => "vacancies",
|
99
|
+
vacancy: (vacancyId) => `vacancies/${vacancyId}`,
|
100
|
+
// Agent paths
|
101
|
+
agents: () => "agents",
|
102
|
+
agent: (agentId) => `agents/${agentId}`,
|
103
|
+
// ClientQuestion paths
|
104
|
+
clientQuestions: (clientId) => `clients/${clientId}/questions`,
|
105
|
+
clientQuestion: (clientId, questionId) => `clients/${clientId}/questions/${questionId}`,
|
106
|
+
// ClientData paths
|
107
|
+
clientData: () => "clientData",
|
108
|
+
clientDataItem: (clientDataId) => `clientData/${clientDataId}`,
|
109
|
+
// ClientLogin paths
|
110
|
+
clientLogins: (userId) => `clientLogins/${userId}`,
|
111
|
+
clientLogin: (userId, domain) => `clientLogins/${userId}/logins/${domain}`,
|
112
|
+
// ApplicationQuestion paths
|
113
|
+
applicationQuestions: (clientId, applicationId) => `clients/${clientId}/applications/${applicationId}/questions`,
|
114
|
+
applicationQuestion: (clientId, applicationId, questionId) => `clients/${clientId}/applications/${applicationId}/questions/${questionId}`,
|
115
|
+
// VacancySuggestion paths
|
116
|
+
vacancySuggestions: (clientId) => `clients/${clientId}/vacancySuggestions`,
|
117
|
+
vacancySuggestion: (clientId, suggestionId) => `clients/${clientId}/vacancySuggestions/${suggestionId}`,
|
118
|
+
// GmailMessage paths
|
119
|
+
gmailMessages: (clientId) => `clientEmails/${clientId}/messages`,
|
120
|
+
gmailMessage: (clientId, messageId) => `clientEmails/${clientId}/messages/${messageId}`
|
121
|
+
};
|
397
122
|
// Annotate the CommonJS export names for ESM import in node:
|
398
123
|
0 && (module.exports = {
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
ClientData,
|
405
|
-
ClientLogin,
|
406
|
-
ClientQuestion,
|
407
|
-
GmailMessage,
|
408
|
-
Vacancy,
|
409
|
-
VacancySuggestion
|
124
|
+
ApplicationQuestionTypeOptions,
|
125
|
+
ApplicationStatus,
|
126
|
+
ClientQuestionTypeOptions,
|
127
|
+
VacancyCategory,
|
128
|
+
pathStrings
|
410
129
|
});
|