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