@goweekdays/core 2.11.16 → 2.11.18
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/CHANGELOG.md +12 -0
- package/dist/index.d.ts +56 -2
- package/dist/index.js +361 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +364 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @goweekdays/core
|
|
2
2
|
|
|
3
|
+
## 2.11.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 0574284: Fix query return value
|
|
8
|
+
|
|
9
|
+
## 2.11.17
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- 029e07e: Add getByUserOrg to member repo and update verification logic
|
|
14
|
+
|
|
3
15
|
## 2.11.16
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -345,6 +345,7 @@ declare function useMemberRepo(): {
|
|
|
345
345
|
deleteById: (_id: string | ObjectId, session?: ClientSession) => Promise<string>;
|
|
346
346
|
updateStatusByOrg: (org: string | ObjectId, status: string, session?: ClientSession) => Promise<string>;
|
|
347
347
|
countUserByOrg: (org: string | ObjectId) => Promise<any>;
|
|
348
|
+
getByUserOrg: (user: string | ObjectId, org: string | ObjectId) => Promise<TMember | null>;
|
|
348
349
|
};
|
|
349
350
|
|
|
350
351
|
declare function useMemberController(): {
|
|
@@ -1162,7 +1163,7 @@ type TJobPost = {
|
|
|
1162
1163
|
_id?: ObjectId;
|
|
1163
1164
|
org: ObjectId | string;
|
|
1164
1165
|
orgName?: string;
|
|
1165
|
-
company: ObjectId;
|
|
1166
|
+
company: ObjectId | string;
|
|
1166
1167
|
companyName?: string;
|
|
1167
1168
|
title: string;
|
|
1168
1169
|
setup: string;
|
|
@@ -1275,6 +1276,59 @@ declare function useLedgerBillingController(): {
|
|
|
1275
1276
|
getSummary: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1276
1277
|
};
|
|
1277
1278
|
|
|
1279
|
+
type TJobApplicationMetadata = {
|
|
1280
|
+
resume?: string;
|
|
1281
|
+
resumeUrl?: string;
|
|
1282
|
+
portfolio?: string;
|
|
1283
|
+
portfolioUrl?: string;
|
|
1284
|
+
coverLetter?: string;
|
|
1285
|
+
coverLetterUrl?: string;
|
|
1286
|
+
};
|
|
1287
|
+
type TJobApplication = {
|
|
1288
|
+
_id?: ObjectId;
|
|
1289
|
+
post: ObjectId | string;
|
|
1290
|
+
jobTitle?: string;
|
|
1291
|
+
company?: ObjectId | string;
|
|
1292
|
+
companyName?: string;
|
|
1293
|
+
location?: string;
|
|
1294
|
+
user: ObjectId | string;
|
|
1295
|
+
name: string;
|
|
1296
|
+
email: string;
|
|
1297
|
+
contact?: string;
|
|
1298
|
+
metadata?: TJobApplicationMetadata;
|
|
1299
|
+
status?: string;
|
|
1300
|
+
createdAt?: Date | String;
|
|
1301
|
+
updatedAt?: Date | String;
|
|
1302
|
+
deletedAt?: Date | String;
|
|
1303
|
+
};
|
|
1304
|
+
declare const jobApplicationStatuses: string[];
|
|
1305
|
+
declare const schemaJobApplication: Joi.ObjectSchema<any>;
|
|
1306
|
+
declare function modelJobApplication(data: TJobApplication): TJobApplication;
|
|
1307
|
+
|
|
1308
|
+
declare function useJobApplicationRepo(): {
|
|
1309
|
+
createIndexes: () => Promise<string>;
|
|
1310
|
+
delCachedData: () => void;
|
|
1311
|
+
add: (data: TJobApplication) => Promise<bson.ObjectId>;
|
|
1312
|
+
getAll: ({ page, limit, search, status, }?: {
|
|
1313
|
+
page?: number | undefined;
|
|
1314
|
+
limit?: number | undefined;
|
|
1315
|
+
search?: string | undefined;
|
|
1316
|
+
status?: string | undefined;
|
|
1317
|
+
}) => Promise<{
|
|
1318
|
+
items: any[];
|
|
1319
|
+
pages: number;
|
|
1320
|
+
pageRange: string;
|
|
1321
|
+
} | {
|
|
1322
|
+
data: TJobApplication[];
|
|
1323
|
+
total: number;
|
|
1324
|
+
}>;
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
declare function useJobApplicationController(): {
|
|
1328
|
+
add: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1329
|
+
getAll: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1330
|
+
};
|
|
1331
|
+
|
|
1278
1332
|
declare const MONGO_URI: string;
|
|
1279
1333
|
declare const MONGO_DB: string;
|
|
1280
1334
|
declare const PORT: number;
|
|
@@ -1314,4 +1368,4 @@ declare const XENDIT_BASE_URL: string;
|
|
|
1314
1368
|
declare const DOMAIN: string;
|
|
1315
1369
|
declare const APP_ORG: string;
|
|
1316
1370
|
|
|
1317
|
-
export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, APP_ORG, DEFAULT_USER_EMAIL, DEFAULT_USER_FIRST_NAME, DEFAULT_USER_LAST_NAME, DEFAULT_USER_PASSWORD, DOMAIN, MAILER_EMAIL, MAILER_PASSWORD, MAILER_TRANSPORT_HOST, MAILER_TRANSPORT_PORT, MAILER_TRANSPORT_SECURE, MBuilding, MBuildingUnit, MFile, MONGO_DB, MONGO_URI, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PAYPAL_WEBHOOK_ID, PORT, PaypalWebhookHeaders, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REFRESH_TOKEN_EXPIRY, REFRESH_TOKEN_SECRET, SECRET_KEY, SPACES_ACCESS_KEY, SPACES_BUCKET, SPACES_ENDPOINT, SPACES_REGION, SPACES_SECRET_KEY, TApp, TBuilding, TBuildingUnit, TCounter, TFile, TJobPost, TLedgerBill, TMember, TOrg, TPermission, TPermissionGroup, TPlan, TPromo, TRole, TSubscribe, TSubscription, TSubscriptionTransaction, TUser, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, currencies, isDev, ledgerBillStatuses, ledgerBillTypes, modelApp, modelJobPost, modelLedgerBill, modelMember, modelOrg, modelPermission, modelPermissionGroup, modelPlan, modelPromo, modelRole, modelSubscription, modelSubscriptionTransaction, modelUser, modelVerification, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaInviteMember, schemaJobPost, schemaJobPostUpdate, schemaLedgerBill, schemaLedgerBillingSummary, schemaMember, schemaMemberRole, schemaMemberStatus, schemaOrg, schemaOrgAdd, schemaOrgPilot, schemaOrgUpdate, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaPlan, schemaPromo, schemaRole, schemaRoleUpdate, schemaSubscribe, schemaSubscription, schemaSubscriptionCompute, schemaSubscriptionPromoCode, schemaSubscriptionSeats, schemaSubscriptionTransaction, schemaSubscriptionUpdate, schemaUpdateOptions, schemaUser, schemaVerification, schemaVerificationOrgInvite, transactionSchema, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCounterModel, useCounterRepo, useFileController, useFileRepo, useFileService, useGitHubService, useJobPostController, useJobPostRepo, useJobPostService, useLedgerBillingController, useLedgerBillingRepo, useMemberController, useMemberRepo, useOrgController, useOrgRepo, useOrgService, usePaypalService, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, usePlanController, usePlanRepo, usePlanService, usePromoController, usePromoRepo, usePromoUsageRepo, useRoleController, useRoleRepo, useRoleService, useSubscriptionController, useSubscriptionRepo, useSubscriptionService, useSubscriptionTransactionController, useSubscriptionTransactionRepo, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };
|
|
1371
|
+
export { ACCESS_TOKEN_EXPIRY, ACCESS_TOKEN_SECRET, APP_ACCOUNT, APP_MAIN, APP_ORG, DEFAULT_USER_EMAIL, DEFAULT_USER_FIRST_NAME, DEFAULT_USER_LAST_NAME, DEFAULT_USER_PASSWORD, DOMAIN, MAILER_EMAIL, MAILER_PASSWORD, MAILER_TRANSPORT_HOST, MAILER_TRANSPORT_PORT, MAILER_TRANSPORT_SECURE, MBuilding, MBuildingUnit, MFile, MONGO_DB, MONGO_URI, PAYPAL_API_URL, PAYPAL_CLIENT_ID, PAYPAL_CLIENT_SECRET, PAYPAL_WEBHOOK_ID, PORT, PaypalWebhookHeaders, REDIS_HOST, REDIS_PASSWORD, REDIS_PORT, REFRESH_TOKEN_EXPIRY, REFRESH_TOKEN_SECRET, SECRET_KEY, SPACES_ACCESS_KEY, SPACES_BUCKET, SPACES_ENDPOINT, SPACES_REGION, SPACES_SECRET_KEY, TApp, TBuilding, TBuildingUnit, TCounter, TFile, TJobApplication, TJobApplicationMetadata, TJobPost, TLedgerBill, TMember, TOrg, TPermission, TPermissionGroup, TPlan, TPromo, TRole, TSubscribe, TSubscription, TSubscriptionTransaction, TUser, TVerification, TVerificationMetadata, VERIFICATION_FORGET_PASSWORD_DURATION, VERIFICATION_USER_INVITE_DURATION, XENDIT_BASE_URL, XENDIT_SECRET_KEY, currencies, isDev, jobApplicationStatuses, ledgerBillStatuses, ledgerBillTypes, modelApp, modelJobApplication, modelJobPost, modelLedgerBill, modelMember, modelOrg, modelPermission, modelPermissionGroup, modelPlan, modelPromo, modelRole, modelSubscription, modelSubscriptionTransaction, modelUser, modelVerification, schemaApp, schemaAppUpdate, schemaBuilding, schemaBuildingUnit, schemaInviteMember, schemaJobApplication, schemaJobPost, schemaJobPostUpdate, schemaLedgerBill, schemaLedgerBillingSummary, schemaMember, schemaMemberRole, schemaMemberStatus, schemaOrg, schemaOrgAdd, schemaOrgPilot, schemaOrgUpdate, schemaPermission, schemaPermissionGroup, schemaPermissionGroupUpdate, schemaPermissionUpdate, schemaPlan, schemaPromo, schemaRole, schemaRoleUpdate, schemaSubscribe, schemaSubscription, schemaSubscriptionCompute, schemaSubscriptionPromoCode, schemaSubscriptionSeats, schemaSubscriptionTransaction, schemaSubscriptionUpdate, schemaUpdateOptions, schemaUser, schemaVerification, schemaVerificationOrgInvite, transactionSchema, useAppController, useAppRepo, useAppService, useAuthController, useAuthService, useBuildingController, useBuildingRepo, useBuildingService, useBuildingUnitController, useBuildingUnitRepo, useBuildingUnitService, useCounterModel, useCounterRepo, useFileController, useFileRepo, useFileService, useGitHubService, useJobApplicationController, useJobApplicationRepo, useJobPostController, useJobPostRepo, useJobPostService, useLedgerBillingController, useLedgerBillingRepo, useMemberController, useMemberRepo, useOrgController, useOrgRepo, useOrgService, usePaypalService, usePermissionController, usePermissionGroupController, usePermissionGroupRepo, usePermissionGroupService, usePermissionRepo, usePermissionService, usePlanController, usePlanRepo, usePlanService, usePromoController, usePromoRepo, usePromoUsageRepo, useRoleController, useRoleRepo, useRoleService, useSubscriptionController, useSubscriptionRepo, useSubscriptionService, useSubscriptionTransactionController, useSubscriptionTransactionRepo, useUserController, useUserRepo, useUserService, useUtilController, useVerificationController, useVerificationRepo, useVerificationService };
|
package/dist/index.js
CHANGED
|
@@ -72,9 +72,11 @@ __export(src_exports, {
|
|
|
72
72
|
XENDIT_SECRET_KEY: () => XENDIT_SECRET_KEY,
|
|
73
73
|
currencies: () => currencies,
|
|
74
74
|
isDev: () => isDev,
|
|
75
|
+
jobApplicationStatuses: () => jobApplicationStatuses,
|
|
75
76
|
ledgerBillStatuses: () => ledgerBillStatuses,
|
|
76
77
|
ledgerBillTypes: () => ledgerBillTypes,
|
|
77
78
|
modelApp: () => modelApp,
|
|
79
|
+
modelJobApplication: () => modelJobApplication,
|
|
78
80
|
modelJobPost: () => modelJobPost,
|
|
79
81
|
modelLedgerBill: () => modelLedgerBill,
|
|
80
82
|
modelMember: () => modelMember,
|
|
@@ -93,6 +95,7 @@ __export(src_exports, {
|
|
|
93
95
|
schemaBuilding: () => schemaBuilding,
|
|
94
96
|
schemaBuildingUnit: () => schemaBuildingUnit,
|
|
95
97
|
schemaInviteMember: () => schemaInviteMember,
|
|
98
|
+
schemaJobApplication: () => schemaJobApplication,
|
|
96
99
|
schemaJobPost: () => schemaJobPost,
|
|
97
100
|
schemaJobPostUpdate: () => schemaJobPostUpdate,
|
|
98
101
|
schemaLedgerBill: () => schemaLedgerBill,
|
|
@@ -141,6 +144,8 @@ __export(src_exports, {
|
|
|
141
144
|
useFileRepo: () => useFileRepo,
|
|
142
145
|
useFileService: () => useFileService,
|
|
143
146
|
useGitHubService: () => useGitHubService,
|
|
147
|
+
useJobApplicationController: () => useJobApplicationController,
|
|
148
|
+
useJobApplicationRepo: () => useJobApplicationRepo,
|
|
144
149
|
useJobPostController: () => useJobPostController,
|
|
145
150
|
useJobPostRepo: () => useJobPostRepo,
|
|
146
151
|
useJobPostService: () => useJobPostService,
|
|
@@ -2066,6 +2071,49 @@ function useMemberRepo() {
|
|
|
2066
2071
|
);
|
|
2067
2072
|
}
|
|
2068
2073
|
}
|
|
2074
|
+
async function getByUserOrg(user, org) {
|
|
2075
|
+
try {
|
|
2076
|
+
org = new import_mongodb7.ObjectId(org);
|
|
2077
|
+
} catch (error) {
|
|
2078
|
+
throw new import_utils7.BadRequestError("Invalid organization ID.");
|
|
2079
|
+
}
|
|
2080
|
+
try {
|
|
2081
|
+
user = new import_mongodb7.ObjectId(user);
|
|
2082
|
+
} catch (error) {
|
|
2083
|
+
throw new import_utils7.BadRequestError("Invalid user ID.");
|
|
2084
|
+
}
|
|
2085
|
+
try {
|
|
2086
|
+
const cacheKey = (0, import_utils7.makeCacheKey)(namespace_collection, {
|
|
2087
|
+
user: String(user),
|
|
2088
|
+
org: String(org)
|
|
2089
|
+
});
|
|
2090
|
+
const cached = await getCache(cacheKey);
|
|
2091
|
+
if (cached) {
|
|
2092
|
+
import_utils7.logger.log({
|
|
2093
|
+
level: "info",
|
|
2094
|
+
message: `Cache hit for getByUserOrg member: ${cacheKey}`
|
|
2095
|
+
});
|
|
2096
|
+
return cached;
|
|
2097
|
+
}
|
|
2098
|
+
const data = await collection.findOne({ user, org });
|
|
2099
|
+
setCache(cacheKey, data, 300).then(() => {
|
|
2100
|
+
import_utils7.logger.log({
|
|
2101
|
+
level: "info",
|
|
2102
|
+
message: `Cache set for member by user and org: ${cacheKey}`
|
|
2103
|
+
});
|
|
2104
|
+
}).catch((err) => {
|
|
2105
|
+
import_utils7.logger.log({
|
|
2106
|
+
level: "error",
|
|
2107
|
+
message: `Failed to set cache for member by user and org: ${err.message}`
|
|
2108
|
+
});
|
|
2109
|
+
});
|
|
2110
|
+
return data;
|
|
2111
|
+
} catch (error) {
|
|
2112
|
+
throw new import_utils7.InternalServerError(
|
|
2113
|
+
"Internal server error, failed to retrieve member."
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
}
|
|
2069
2117
|
return {
|
|
2070
2118
|
createIndexes,
|
|
2071
2119
|
add,
|
|
@@ -2085,7 +2133,8 @@ function useMemberRepo() {
|
|
|
2085
2133
|
updateStatusById,
|
|
2086
2134
|
deleteById,
|
|
2087
2135
|
updateStatusByOrg,
|
|
2088
|
-
countUserByOrg
|
|
2136
|
+
countUserByOrg,
|
|
2137
|
+
getByUserOrg
|
|
2089
2138
|
};
|
|
2090
2139
|
}
|
|
2091
2140
|
|
|
@@ -10781,7 +10830,11 @@ function useVerificationService() {
|
|
|
10781
10830
|
getVerifications: _getVerifications
|
|
10782
10831
|
} = useVerificationRepo();
|
|
10783
10832
|
const { getUserByEmail } = useUserRepo();
|
|
10784
|
-
const {
|
|
10833
|
+
const {
|
|
10834
|
+
add: addMember,
|
|
10835
|
+
countUserByOrg,
|
|
10836
|
+
getByUserOrg: getMemberByUserOrg
|
|
10837
|
+
} = useMemberRepo();
|
|
10785
10838
|
const { getById: getOrgById } = useOrgRepo();
|
|
10786
10839
|
const { getById: getRoleById } = useRoleRepo();
|
|
10787
10840
|
async function createUserInvite({
|
|
@@ -11113,8 +11166,17 @@ function useVerificationService() {
|
|
|
11113
11166
|
);
|
|
11114
11167
|
}
|
|
11115
11168
|
}
|
|
11169
|
+
const user = await getUserByEmail(value.email);
|
|
11170
|
+
let userId = "";
|
|
11171
|
+
if (user) {
|
|
11172
|
+
userId = String(user._id);
|
|
11173
|
+
}
|
|
11116
11174
|
const memberCount = await countUserByOrg(String(value.org));
|
|
11117
|
-
|
|
11175
|
+
const existingMember = await getMemberByUserOrg(
|
|
11176
|
+
userId,
|
|
11177
|
+
String(value.org)
|
|
11178
|
+
);
|
|
11179
|
+
if (subscription.seats <= memberCount && !existingMember) {
|
|
11118
11180
|
throw new import_utils53.BadRequestError(
|
|
11119
11181
|
"Organization has reached the maximum number of members for its subscription plan."
|
|
11120
11182
|
);
|
|
@@ -12917,10 +12979,12 @@ function modelJobPost(value) {
|
|
|
12917
12979
|
} catch (error2) {
|
|
12918
12980
|
throw new import_utils66.BadRequestError("Invalid Org ID");
|
|
12919
12981
|
}
|
|
12920
|
-
|
|
12921
|
-
|
|
12922
|
-
|
|
12923
|
-
|
|
12982
|
+
if (value.company && typeof value.company === "string" && value.company.length === 24) {
|
|
12983
|
+
try {
|
|
12984
|
+
value.company = new import_mongodb29.ObjectId(value.company);
|
|
12985
|
+
} catch (error2) {
|
|
12986
|
+
throw new import_utils66.BadRequestError("Invalid Company ID");
|
|
12987
|
+
}
|
|
12924
12988
|
}
|
|
12925
12989
|
return {
|
|
12926
12990
|
_id: value._id,
|
|
@@ -13045,7 +13109,11 @@ function useJobPostRepo() {
|
|
|
13045
13109
|
{
|
|
13046
13110
|
$project: {
|
|
13047
13111
|
_id: 1,
|
|
13112
|
+
org: 1,
|
|
13048
13113
|
orgName: 1,
|
|
13114
|
+
company: 1,
|
|
13115
|
+
companyName: 1,
|
|
13116
|
+
description: 1,
|
|
13049
13117
|
minSalary: 1,
|
|
13050
13118
|
maxSalary: 1,
|
|
13051
13119
|
currency: 1,
|
|
@@ -13839,6 +13907,287 @@ function useJobPostController() {
|
|
|
13839
13907
|
getCurrencies
|
|
13840
13908
|
};
|
|
13841
13909
|
}
|
|
13910
|
+
|
|
13911
|
+
// src/resources/job-applications/job.applications.model.ts
|
|
13912
|
+
var import_utils72 = require("@goweekdays/utils");
|
|
13913
|
+
var import_joi54 = __toESM(require("joi"));
|
|
13914
|
+
var import_mongodb32 = require("mongodb");
|
|
13915
|
+
var jobApplicationStatuses = [
|
|
13916
|
+
"new",
|
|
13917
|
+
"shortlisted",
|
|
13918
|
+
"interview-scheduled",
|
|
13919
|
+
"interviewed",
|
|
13920
|
+
"offer-extended",
|
|
13921
|
+
"hired",
|
|
13922
|
+
"on-hold",
|
|
13923
|
+
"withdrawn",
|
|
13924
|
+
"rejected",
|
|
13925
|
+
// Agency specific
|
|
13926
|
+
"contacted",
|
|
13927
|
+
"endorsed",
|
|
13928
|
+
"client-interested",
|
|
13929
|
+
"pooled",
|
|
13930
|
+
// HR specific
|
|
13931
|
+
"under-review",
|
|
13932
|
+
"for-approval"
|
|
13933
|
+
];
|
|
13934
|
+
var schemaJobApplication = import_joi54.default.object({
|
|
13935
|
+
post: import_joi54.default.string().required(),
|
|
13936
|
+
jobTitle: import_joi54.default.string().optional().allow(""),
|
|
13937
|
+
company: import_joi54.default.string().hex().optional().allow(""),
|
|
13938
|
+
companyName: import_joi54.default.string().optional().allow(""),
|
|
13939
|
+
location: import_joi54.default.string().optional().allow(""),
|
|
13940
|
+
user: import_joi54.default.string().required(),
|
|
13941
|
+
name: import_joi54.default.string().required(),
|
|
13942
|
+
email: import_joi54.default.string().email().required(),
|
|
13943
|
+
contact: import_joi54.default.string().optional().allow(""),
|
|
13944
|
+
metadata: import_joi54.default.object({
|
|
13945
|
+
resume: import_joi54.default.string().optional().allow(""),
|
|
13946
|
+
resumeUrl: import_joi54.default.string().uri().optional().allow(""),
|
|
13947
|
+
portfolio: import_joi54.default.string().optional().allow(""),
|
|
13948
|
+
portfolioUrl: import_joi54.default.string().uri().optional().allow(""),
|
|
13949
|
+
coverLetter: import_joi54.default.string().optional().allow(""),
|
|
13950
|
+
coverLetterUrl: import_joi54.default.string().uri().optional().allow("")
|
|
13951
|
+
}).optional()
|
|
13952
|
+
});
|
|
13953
|
+
function modelJobApplication(data) {
|
|
13954
|
+
const { error } = schemaJobApplication.validate(data);
|
|
13955
|
+
if (error) {
|
|
13956
|
+
throw new import_utils72.BadRequestError(`Invalid job application data: ${error.message}`);
|
|
13957
|
+
}
|
|
13958
|
+
if (data._id && typeof data._id === "string") {
|
|
13959
|
+
try {
|
|
13960
|
+
data._id = new import_mongodb32.ObjectId(data._id);
|
|
13961
|
+
} catch (error2) {
|
|
13962
|
+
throw new import_utils72.BadRequestError(`Invalid job application _id: ${data._id}`);
|
|
13963
|
+
}
|
|
13964
|
+
}
|
|
13965
|
+
try {
|
|
13966
|
+
data.post = new import_mongodb32.ObjectId(data.post);
|
|
13967
|
+
} catch (error2) {
|
|
13968
|
+
throw new import_utils72.BadRequestError(`Invalid job application post id: ${data.post}`);
|
|
13969
|
+
}
|
|
13970
|
+
if (data.company && typeof data.company === "string") {
|
|
13971
|
+
try {
|
|
13972
|
+
data.company = new import_mongodb32.ObjectId(data.company);
|
|
13973
|
+
} catch (error2) {
|
|
13974
|
+
throw new import_utils72.BadRequestError(
|
|
13975
|
+
`Invalid job application company id: ${data.company}`
|
|
13976
|
+
);
|
|
13977
|
+
}
|
|
13978
|
+
}
|
|
13979
|
+
return {
|
|
13980
|
+
_id: data._id,
|
|
13981
|
+
post: data.post,
|
|
13982
|
+
jobTitle: data.jobTitle,
|
|
13983
|
+
company: data.company,
|
|
13984
|
+
companyName: data.companyName ?? "",
|
|
13985
|
+
location: data.location ?? "",
|
|
13986
|
+
user: data.user,
|
|
13987
|
+
name: data.name,
|
|
13988
|
+
email: data.email,
|
|
13989
|
+
contact: data.contact ?? "",
|
|
13990
|
+
metadata: data.metadata ?? {},
|
|
13991
|
+
status: data.status ?? "new",
|
|
13992
|
+
createdAt: data.createdAt ?? /* @__PURE__ */ new Date(),
|
|
13993
|
+
updatedAt: data.updatedAt ?? "",
|
|
13994
|
+
deletedAt: data.deletedAt ?? ""
|
|
13995
|
+
};
|
|
13996
|
+
}
|
|
13997
|
+
|
|
13998
|
+
// src/resources/job-applications/job.application.repository.ts
|
|
13999
|
+
var import_utils73 = require("@goweekdays/utils");
|
|
14000
|
+
function useJobApplicationRepo() {
|
|
14001
|
+
const db = import_utils73.useAtlas.getDb();
|
|
14002
|
+
if (!db) {
|
|
14003
|
+
throw new import_utils73.BadRequestError("Unable to connect to server.");
|
|
14004
|
+
}
|
|
14005
|
+
const namespace_collection = "job.applications";
|
|
14006
|
+
const collection = db.collection(namespace_collection);
|
|
14007
|
+
const { getCache, setCache, delNamespace } = (0, import_utils73.useCache)(namespace_collection);
|
|
14008
|
+
function delCachedData() {
|
|
14009
|
+
delNamespace().then(() => {
|
|
14010
|
+
import_utils73.logger.log({
|
|
14011
|
+
level: "info",
|
|
14012
|
+
message: `Cache namespace cleared for ${namespace_collection}`
|
|
14013
|
+
});
|
|
14014
|
+
}).catch((err) => {
|
|
14015
|
+
import_utils73.logger.log({
|
|
14016
|
+
level: "error",
|
|
14017
|
+
message: `Failed to clear cache namespace for ${namespace_collection}: ${err.message}`
|
|
14018
|
+
});
|
|
14019
|
+
});
|
|
14020
|
+
}
|
|
14021
|
+
async function createIndexes() {
|
|
14022
|
+
try {
|
|
14023
|
+
await collection.createIndexes([
|
|
14024
|
+
{ key: { jobTitle: 1 } },
|
|
14025
|
+
{ key: { company: 1 } },
|
|
14026
|
+
{ key: { companyName: 1 } },
|
|
14027
|
+
{ key: { location: 1 } },
|
|
14028
|
+
{ key: { user: 1 } },
|
|
14029
|
+
{ key: { email: 1 } },
|
|
14030
|
+
{
|
|
14031
|
+
key: {
|
|
14032
|
+
jobTitle: "text",
|
|
14033
|
+
company: "text",
|
|
14034
|
+
companyName: "text",
|
|
14035
|
+
location: "text",
|
|
14036
|
+
name: "text"
|
|
14037
|
+
},
|
|
14038
|
+
name: "job_application_text_search"
|
|
14039
|
+
}
|
|
14040
|
+
]);
|
|
14041
|
+
return "Successfully created job application indexes.";
|
|
14042
|
+
} catch (error) {
|
|
14043
|
+
throw new import_utils73.BadRequestError("Failed to create job application indexes.");
|
|
14044
|
+
}
|
|
14045
|
+
}
|
|
14046
|
+
async function add(data) {
|
|
14047
|
+
const { error } = schemaJobApplication.validate(data);
|
|
14048
|
+
if (error) {
|
|
14049
|
+
throw new import_utils73.BadRequestError(
|
|
14050
|
+
`Invalid job application data: ${error.message}`
|
|
14051
|
+
);
|
|
14052
|
+
}
|
|
14053
|
+
try {
|
|
14054
|
+
data = modelJobApplication(data);
|
|
14055
|
+
const res = await collection.insertOne(data);
|
|
14056
|
+
delCachedData();
|
|
14057
|
+
return res.insertedId;
|
|
14058
|
+
} catch (error2) {
|
|
14059
|
+
if (error2 instanceof import_utils73.AppError) {
|
|
14060
|
+
throw error2;
|
|
14061
|
+
}
|
|
14062
|
+
throw new import_utils73.BadRequestError(
|
|
14063
|
+
`Failed to create job application: ${error2.message}`
|
|
14064
|
+
);
|
|
14065
|
+
}
|
|
14066
|
+
}
|
|
14067
|
+
async function getAll({
|
|
14068
|
+
page = 1,
|
|
14069
|
+
limit = 10,
|
|
14070
|
+
search = "",
|
|
14071
|
+
status = "new"
|
|
14072
|
+
} = {}) {
|
|
14073
|
+
page = page > 0 ? page - 1 : 0;
|
|
14074
|
+
const query = { status };
|
|
14075
|
+
const cacheKeyOptions = {
|
|
14076
|
+
page,
|
|
14077
|
+
limit,
|
|
14078
|
+
status,
|
|
14079
|
+
tag: "getAll"
|
|
14080
|
+
};
|
|
14081
|
+
if (search) {
|
|
14082
|
+
query.$text = { $search: search };
|
|
14083
|
+
cacheKeyOptions.search = search;
|
|
14084
|
+
}
|
|
14085
|
+
const cacheKey = (0, import_utils73.makeCacheKey)(namespace_collection, cacheKeyOptions);
|
|
14086
|
+
const cachedData = await getCache(cacheKey);
|
|
14087
|
+
if (cachedData) {
|
|
14088
|
+
return cachedData;
|
|
14089
|
+
}
|
|
14090
|
+
try {
|
|
14091
|
+
const items = await collection.aggregate([
|
|
14092
|
+
{ $match: query },
|
|
14093
|
+
{ $skip: page * limit },
|
|
14094
|
+
{ $limit: limit }
|
|
14095
|
+
]).toArray();
|
|
14096
|
+
const length = await collection.countDocuments(query);
|
|
14097
|
+
const data = (0, import_utils73.paginate)(items, page, limit, length);
|
|
14098
|
+
setCache(cacheKey, data).then(() => {
|
|
14099
|
+
import_utils73.logger.log({
|
|
14100
|
+
level: "info",
|
|
14101
|
+
message: `Cache set for getAll job applications: ${cacheKey}`
|
|
14102
|
+
});
|
|
14103
|
+
}).catch((err) => {
|
|
14104
|
+
import_utils73.logger.log({
|
|
14105
|
+
level: "error",
|
|
14106
|
+
message: `Failed to set cache for getAll job applications: ${cacheKey}, error: ${err.message}`
|
|
14107
|
+
});
|
|
14108
|
+
});
|
|
14109
|
+
return data;
|
|
14110
|
+
} catch (error) {
|
|
14111
|
+
if (error instanceof import_utils73.AppError) {
|
|
14112
|
+
throw error;
|
|
14113
|
+
}
|
|
14114
|
+
throw new import_utils73.BadRequestError(
|
|
14115
|
+
`Failed to get job applications: ${error.message}`
|
|
14116
|
+
);
|
|
14117
|
+
}
|
|
14118
|
+
}
|
|
14119
|
+
return {
|
|
14120
|
+
createIndexes,
|
|
14121
|
+
delCachedData,
|
|
14122
|
+
add,
|
|
14123
|
+
getAll
|
|
14124
|
+
};
|
|
14125
|
+
}
|
|
14126
|
+
|
|
14127
|
+
// src/resources/job-applications/job.application.controller.ts
|
|
14128
|
+
var import_utils74 = require("@goweekdays/utils");
|
|
14129
|
+
var import_joi55 = __toESM(require("joi"));
|
|
14130
|
+
function useJobApplicationController() {
|
|
14131
|
+
const { add: _add, getAll: _getAll } = useJobApplicationRepo();
|
|
14132
|
+
async function add(req, res, next) {
|
|
14133
|
+
const { error } = schemaJobApplication.validate(req.body);
|
|
14134
|
+
if (error) {
|
|
14135
|
+
next(
|
|
14136
|
+
new import_utils74.BadRequestError(`Invalid job application data: ${error.message}`)
|
|
14137
|
+
);
|
|
14138
|
+
return;
|
|
14139
|
+
}
|
|
14140
|
+
try {
|
|
14141
|
+
const message = await _add(req.body);
|
|
14142
|
+
res.json({ message });
|
|
14143
|
+
return;
|
|
14144
|
+
} catch (error2) {
|
|
14145
|
+
if (error2 instanceof import_utils74.AppError) {
|
|
14146
|
+
next(error2);
|
|
14147
|
+
return;
|
|
14148
|
+
}
|
|
14149
|
+
next(
|
|
14150
|
+
new import_utils74.BadRequestError(
|
|
14151
|
+
`Failed to create job application: ${error2.message}`
|
|
14152
|
+
)
|
|
14153
|
+
);
|
|
14154
|
+
}
|
|
14155
|
+
}
|
|
14156
|
+
async function getAll(req, res, next) {
|
|
14157
|
+
const validation = import_joi55.default.object({
|
|
14158
|
+
page: import_joi55.default.number().integer().min(1).optional(),
|
|
14159
|
+
limit: import_joi55.default.number().integer().min(1).max(100).optional(),
|
|
14160
|
+
search: import_joi55.default.string().optional().allow(""),
|
|
14161
|
+
status: import_joi55.default.string().valid(...jobApplicationStatuses).optional()
|
|
14162
|
+
});
|
|
14163
|
+
const { error } = validation.validate(req.query);
|
|
14164
|
+
if (error) {
|
|
14165
|
+
next(new import_utils74.BadRequestError(`Invalid query parameters: ${error.message}`));
|
|
14166
|
+
return;
|
|
14167
|
+
}
|
|
14168
|
+
const page = req.query.page ? parseInt(req.query.page) : 1;
|
|
14169
|
+
const limit = req.query.limit ? parseInt(req.query.limit) : 10;
|
|
14170
|
+
const search = req.query.search ? req.query.search : "";
|
|
14171
|
+
const status = req.query.status ? req.query.status : "new";
|
|
14172
|
+
try {
|
|
14173
|
+
const data = await _getAll({ page, limit, search, status });
|
|
14174
|
+
res.json(data);
|
|
14175
|
+
return;
|
|
14176
|
+
} catch (error2) {
|
|
14177
|
+
if (error2 instanceof import_utils74.AppError) {
|
|
14178
|
+
next(error2);
|
|
14179
|
+
return;
|
|
14180
|
+
}
|
|
14181
|
+
next(
|
|
14182
|
+
new import_utils74.BadRequestError(`Failed to get job applications: ${error2.message}`)
|
|
14183
|
+
);
|
|
14184
|
+
}
|
|
14185
|
+
}
|
|
14186
|
+
return {
|
|
14187
|
+
add,
|
|
14188
|
+
getAll
|
|
14189
|
+
};
|
|
14190
|
+
}
|
|
13842
14191
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13843
14192
|
0 && (module.exports = {
|
|
13844
14193
|
ACCESS_TOKEN_EXPIRY,
|
|
@@ -13883,9 +14232,11 @@ function useJobPostController() {
|
|
|
13883
14232
|
XENDIT_SECRET_KEY,
|
|
13884
14233
|
currencies,
|
|
13885
14234
|
isDev,
|
|
14235
|
+
jobApplicationStatuses,
|
|
13886
14236
|
ledgerBillStatuses,
|
|
13887
14237
|
ledgerBillTypes,
|
|
13888
14238
|
modelApp,
|
|
14239
|
+
modelJobApplication,
|
|
13889
14240
|
modelJobPost,
|
|
13890
14241
|
modelLedgerBill,
|
|
13891
14242
|
modelMember,
|
|
@@ -13904,6 +14255,7 @@ function useJobPostController() {
|
|
|
13904
14255
|
schemaBuilding,
|
|
13905
14256
|
schemaBuildingUnit,
|
|
13906
14257
|
schemaInviteMember,
|
|
14258
|
+
schemaJobApplication,
|
|
13907
14259
|
schemaJobPost,
|
|
13908
14260
|
schemaJobPostUpdate,
|
|
13909
14261
|
schemaLedgerBill,
|
|
@@ -13952,6 +14304,8 @@ function useJobPostController() {
|
|
|
13952
14304
|
useFileRepo,
|
|
13953
14305
|
useFileService,
|
|
13954
14306
|
useGitHubService,
|
|
14307
|
+
useJobApplicationController,
|
|
14308
|
+
useJobApplicationRepo,
|
|
13955
14309
|
useJobPostController,
|
|
13956
14310
|
useJobPostRepo,
|
|
13957
14311
|
useJobPostService,
|