@goweekdays/core 2.11.17 → 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 +6 -0
- package/dist/index.d.ts +55 -2
- package/dist/index.js +301 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +304 -4
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1163,7 +1163,7 @@ type TJobPost = {
|
|
|
1163
1163
|
_id?: ObjectId;
|
|
1164
1164
|
org: ObjectId | string;
|
|
1165
1165
|
orgName?: string;
|
|
1166
|
-
company: ObjectId;
|
|
1166
|
+
company: ObjectId | string;
|
|
1167
1167
|
companyName?: string;
|
|
1168
1168
|
title: string;
|
|
1169
1169
|
setup: string;
|
|
@@ -1276,6 +1276,59 @@ declare function useLedgerBillingController(): {
|
|
|
1276
1276
|
getSummary: (req: Request, res: Response, next: NextFunction) => Promise<void>;
|
|
1277
1277
|
};
|
|
1278
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
|
+
|
|
1279
1332
|
declare const MONGO_URI: string;
|
|
1280
1333
|
declare const MONGO_DB: string;
|
|
1281
1334
|
declare const PORT: number;
|
|
@@ -1315,4 +1368,4 @@ declare const XENDIT_BASE_URL: string;
|
|
|
1315
1368
|
declare const DOMAIN: string;
|
|
1316
1369
|
declare const APP_ORG: string;
|
|
1317
1370
|
|
|
1318
|
-
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,
|
|
@@ -12974,10 +12979,12 @@ function modelJobPost(value) {
|
|
|
12974
12979
|
} catch (error2) {
|
|
12975
12980
|
throw new import_utils66.BadRequestError("Invalid Org ID");
|
|
12976
12981
|
}
|
|
12977
|
-
|
|
12978
|
-
|
|
12979
|
-
|
|
12980
|
-
|
|
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
|
+
}
|
|
12981
12988
|
}
|
|
12982
12989
|
return {
|
|
12983
12990
|
_id: value._id,
|
|
@@ -13102,7 +13109,11 @@ function useJobPostRepo() {
|
|
|
13102
13109
|
{
|
|
13103
13110
|
$project: {
|
|
13104
13111
|
_id: 1,
|
|
13112
|
+
org: 1,
|
|
13105
13113
|
orgName: 1,
|
|
13114
|
+
company: 1,
|
|
13115
|
+
companyName: 1,
|
|
13116
|
+
description: 1,
|
|
13106
13117
|
minSalary: 1,
|
|
13107
13118
|
maxSalary: 1,
|
|
13108
13119
|
currency: 1,
|
|
@@ -13896,6 +13907,287 @@ function useJobPostController() {
|
|
|
13896
13907
|
getCurrencies
|
|
13897
13908
|
};
|
|
13898
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
|
+
}
|
|
13899
14191
|
// Annotate the CommonJS export names for ESM import in node:
|
|
13900
14192
|
0 && (module.exports = {
|
|
13901
14193
|
ACCESS_TOKEN_EXPIRY,
|
|
@@ -13940,9 +14232,11 @@ function useJobPostController() {
|
|
|
13940
14232
|
XENDIT_SECRET_KEY,
|
|
13941
14233
|
currencies,
|
|
13942
14234
|
isDev,
|
|
14235
|
+
jobApplicationStatuses,
|
|
13943
14236
|
ledgerBillStatuses,
|
|
13944
14237
|
ledgerBillTypes,
|
|
13945
14238
|
modelApp,
|
|
14239
|
+
modelJobApplication,
|
|
13946
14240
|
modelJobPost,
|
|
13947
14241
|
modelLedgerBill,
|
|
13948
14242
|
modelMember,
|
|
@@ -13961,6 +14255,7 @@ function useJobPostController() {
|
|
|
13961
14255
|
schemaBuilding,
|
|
13962
14256
|
schemaBuildingUnit,
|
|
13963
14257
|
schemaInviteMember,
|
|
14258
|
+
schemaJobApplication,
|
|
13964
14259
|
schemaJobPost,
|
|
13965
14260
|
schemaJobPostUpdate,
|
|
13966
14261
|
schemaLedgerBill,
|
|
@@ -14009,6 +14304,8 @@ function useJobPostController() {
|
|
|
14009
14304
|
useFileRepo,
|
|
14010
14305
|
useFileService,
|
|
14011
14306
|
useGitHubService,
|
|
14307
|
+
useJobApplicationController,
|
|
14308
|
+
useJobApplicationRepo,
|
|
14012
14309
|
useJobPostController,
|
|
14013
14310
|
useJobPostRepo,
|
|
14014
14311
|
useJobPostService,
|