@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/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
- Agent: () => Agent,
24
- Application: () => Application,
25
- ApplicationQuestion: () => ApplicationQuestion,
26
- AuthUser: () => AuthUser,
27
- Client: () => Client,
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/models/Application.ts
38
- var Application;
39
- ((Application2) => {
40
- Application2.Status = {
41
- New: "new",
42
- Submitted: "submitted",
43
- Interviewing: "interviewing",
44
- Accepted: "accepted",
45
- Rejected: "rejected",
46
- Withdrawn: "withdrawn",
47
- Applying: "applying",
48
- Suggested: "suggested",
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/models/VacancySuggestion.ts
318
- var VacancySuggestion;
319
- ((VacancySuggestion2) => {
320
- VacancySuggestion2.collection = (clientId) => `clients/${clientId}/vacancySuggestions`;
321
- VacancySuggestion2.document = (clientId, suggestionId) => `clients/${clientId}/vacancySuggestions/${suggestionId}`;
322
- VacancySuggestion2.formatSummary = (suggestion) => {
323
- return `${suggestion.position} at ${suggestion.company} (${suggestion.status})`;
324
- };
325
- VacancySuggestion2.createNew = (clientId, vacancyId, status, company, position, location, description, advertisingUrl, applicationUrl, applicationDomain, advertisingDomain, fullPageText, jobId, category) => {
326
- return {
327
- clientId,
328
- vacancyId,
329
- status,
330
- company,
331
- position,
332
- location,
333
- description,
334
- advertisingUrl,
335
- applicationUrl,
336
- applicationDomain,
337
- advertisingDomain,
338
- fullPageText,
339
- jobId,
340
- category,
341
- createdAt: (/* @__PURE__ */ new Date()).toISOString()
342
- };
343
- };
344
- })(VacancySuggestion || (VacancySuggestion = {}));
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/models/ApplicationQuestion.ts
347
- var ApplicationQuestion;
348
- ((ApplicationQuestion2) => {
349
- ApplicationQuestion2.TypeOptions = ["text", "select"];
350
- ApplicationQuestion2.collection = (clientId, applicationId) => `clients/${clientId}/applications/${applicationId}/questions`;
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/models/Agent.ts
363
- var Agent;
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/models/GmailMessage.ts
381
- var GmailMessage;
382
- ((GmailMessage2) => {
383
- GmailMessage2.collection = (clientId) => `clientEmails/${clientId}/messages`;
384
- GmailMessage2.document = (clientId, messageId) => `${(0, GmailMessage2.collection)(clientId)}/${messageId}`;
385
- GmailMessage2.createNew = (messageId, threadId, payload, labelIds, snippet, internalDate) => {
386
- return {
387
- messageId,
388
- threadId,
389
- payload,
390
- labelIds,
391
- snippet,
392
- internalDate,
393
- createdAt: /* @__PURE__ */ new Date()
394
- };
395
- };
396
- })(GmailMessage || (GmailMessage = {}));
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
- Agent,
400
- Application,
401
- ApplicationQuestion,
402
- AuthUser,
403
- Client,
404
- ClientData,
405
- ClientLogin,
406
- ClientQuestion,
407
- GmailMessage,
408
- Vacancy,
409
- VacancySuggestion
124
+ ApplicationQuestionTypeOptions,
125
+ ApplicationStatus,
126
+ ClientQuestionTypeOptions,
127
+ VacancyCategory,
128
+ pathStrings
410
129
  });